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

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 mP}from"node:events";var Uo="medium",sd={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 yi(e=Uo,t={}){let r=sd[e]??sd[Uo];return{opacity:Vo(t.opacity,r.opacity),softness:Vo(t.softness,r.softness),bias:Vo(t.bias,r.bias),normalBias:Vo(t.normalBias,r.normalBias),maxDistance:Vo(t.maxDistance,r.maxDistance),resolution:hP(t.resolution,r.resolution),cascadeCount:EP(t.cascadeCount,r.cascadeCount),bakeSamples:SP(t.bakeSamples,r.bakeSamples),blurKernel:yP(t.blurKernel,r.blurKernel)}}function Vo(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function SP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function yP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function hP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function EP(e,t){return e===1||e===2||e===4?e:t}function hi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ei(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Ii(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Pi(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function Ti(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function xi(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function hf(e){let t=hi(e);if(!t)return;let r={};Ei(t.cast)&&(r.cast=t.cast),Ii(t.receive)&&(r.receive=t.receive),Pi(t.mode)&&(r.mode=t.mode),Ti(t.quality)&&(r.quality=t.quality);let n=hi(t.light);if(n){let a={};xi(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=IP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function He(e){let t=hf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function cd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function dd(e,t=Uo){let r=e?.quality;return r&&r!=="inherit"?r:t}function IP(e){let t=hi(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 PP=new Set(["cast","receive","mode","quality","light","params"]),TP=new Set(["mode","lightId"]),xP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Ko(e,t="$.shadow"){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,PP,t),"cast"in r&&!Ei(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!Ii(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!Pi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!Ti(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&AP(r.light,`${t}.light`),"params"in r&&DP(r.params,`${t}.params`)}function AP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,TP,t),"mode"in r&&!xi(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 DP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,xP,t),Wr(r,"opacity",t,n=>n>=0&&n<=1),Wr(r,"softness",t,n=>n>=0),Wr(r,"bias",t,()=>!0),Wr(r,"normalBias",t,()=>!0),Wr(r,"maxDistance",t,n=>n>0),Wr(r,"bakeSamples",t,n=>n>0),Wr(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 Wr(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 ld(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 ud(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var gd="fps.shadow-map-experiment";function MP(e,t="$.scene.shadowMapExperiment"){let r=ft(e,t);Gt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&vt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&vt(r.behaviorProfile,`${t}.behaviorProfile`)}function wP(e,t="$.shadowMapExperiment"){let r=ft(e,t);Gt(r,["behaviorProfile"],t),vt(r.behaviorProfile,`${t}.behaviorProfile`)}function Di(e,t="$"){let r=ft(e,t);Gt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),vt(r.lightRef,`${t}.lightRef`);let n=vt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=vt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=If(r.qualityProfiles,`${t}.qualityProfiles`),i=If(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))OP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))RP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Pf(e){Di(e.config),e.settings!==void 0&&MP(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=fd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");fd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&wP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=fd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:vt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze($P(s.renderableIds,`${d}.renderableIds`)),cast:Ef(s.cast,`${d}.cast`)??l.cast==="enabled",receive:Ef(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];FP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return Tf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:vt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Wo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:_P(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function Ef(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function kP(e,t){let r=ft(e,t);Gt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Wo(r.center,`${t}.center`),Wo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=Ai(r.near,`${t}.near`),a=Ai(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function OP(e,t){let r=ft(e,t);Gt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),CP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&vP(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),Ho(r.bias,`${t}.bias`,0,.1),Ho(r.normalBias,`${t}.normalBias`,0,1),Ho(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Ho(r.softness,`${t}.softness`,0,1),kP(r.bounds,`${t}.bounds`),GP(r.backend,`${t}.backend`),jP(r.culling,`${t}.culling`),NP(r.diagnostics,`${t}.diagnostics`)}function RP(e,t){let r=ft(e,t);Gt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function CP(e,t){let r=ft(e,t);Gt(r,["staticResolution","dynamicResolution","compositeResolution"],t),md(r.staticResolution,`${t}.staticResolution`),md(r.dynamicResolution,`${t}.dynamicResolution`),md(r.compositeResolution,`${t}.compositeResolution`)}function md(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function vP(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function GP(e,t){let r=ft(e,t);Gt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function jP(e,t){let r=ft(e,t);Gt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Ho(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function NP(e,t){let r=ft(e,t);Gt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),pd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),pd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),pd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function FP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function If(e,t){let r=ft(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))vt(n,`${t} key`);return r}function fd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function _P(e){return Object.freeze({mode:"fixed",center:Wo(e.center,"$.bounds.center"),extent:Wo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Wo(e,t){let r=LP(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>Ai(n,`${t}[${o}]`)))}function $P(e,t){let r=e.map((n,o)=>vt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function Ai(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function Ho(e,t,r,n){let o=Ai(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function pd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function vt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function ft(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function LP(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function Gt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function Tf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))Tf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var xf=["useBlobShadow","blobSettings"],zP=["resolution","maxSize"],BP=new Set(["none","blob","static","planar","dynamic"]);function gt(e){let t=qr(e);if(!t)throw X("schema.invalidType","$");for(let o of xf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),KP(t.globalVolume,"$.globalVolume"),HP(t.materials,"$.materials"),VP(t.renderingGroups,"$.renderingGroups"),UP(t.globalVolume,"$.globalVolume"),ZP(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 xf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!BP.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"),Mi(n.shadowColor,"$.shadows.settings.shadowColor",!1)}qP(r.blob,"$.shadows.blob"),JP(r.staticProjected,"$.shadows.staticProjected"),XP(r.planar,"$.shadows.planar"),Jr(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),Jr(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),YP(r.csm,"$.shadows.csm")}function VP(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`);Sd(u,"alphaIndex",d)})})}function UP(e,t){if(e===void 0)return;let r=be(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=be(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=be(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(Jr(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=be(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=be(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=pt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?pt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function KP(e,t){if(e===void 0)return;let r=be(e,t),n=pt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),WP(n,"hardwareScalingLevel",`${t}.rendering`));let o=pt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function HP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&be(r[n],`${t}.${n}`)}function WP(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function qP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),Mi(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),Jr(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function JP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),Mi(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=be(r.bake,`${t}.bake`);for(let a of zP)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 XP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=pt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),QP(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=pt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),Mi(o.color,`${t}.appearance.color`,!0)),Jr(r.projection,`${t}.projection`,["footprintScale"]);let a=pt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=pt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])bd(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=pt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),bd(s.patterns,`${t}.receivers.patterns`))}function YP(e,t){if(e===void 0)return;let r=be(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 ZP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])bd(r[n],`${t}.${n}`)}function Jr(e,t,r){if(e===void 0)return;let n=be(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function Mi(e,t,r){if(e===void 0)return;let n=be(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)Sd(n,a,t)}function QP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])Sd(r,n,t)}function bd(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function Sd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function pt(e,t){return e===void 0?null:be(e,t)}function be(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 Af(e,t){let r=L(e);return{x:Se(r.x,t.x),y:Se(r.y,t.y),z:Se(r.z,t.z)}}function yd(e,t){let r=L(e);return{r:rr(r.r,t.r,0,1),g:rr(r.g,t.g,0,1),b:rr(r.b,t.b,0,1)}}function qo(e,t){let r=L(e);return{...yd(r,t),a:rr(r.a,t.a,0,1)}}function Pr(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function hd(e){return(typeof e=="string"?e.trim():"")||null}function Ed(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function Df(e){return e===0||e===1||e===2||e===3?e:null}function Mf(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function wf(e,t){return e===1||e===2||e===4||e===8?e:t}function kf(e,t){return e==="fixed"||e==="receiver"?e:t}function Of(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function Se(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=Se(e,t);return Math.max(0,r)}function Tr(e,t){let r=Se(e,t);return r>0?r:t}function rr(e,t,r,n){let o=Se(e,t);return Math.min(n,Math.max(r,o))}var Rf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Cf=[...Rf,"_blobShadow"],eT=[...Cf,"_staticProjectedShadow"];var vf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&gt(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=tT(o),i=nT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Gf(t.renderingGroups),environment:oT(t.globalVolume),postProcess:aT(t.globalVolume),shadows:{defaultMode:Of(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:yd(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:Se(c.left,-20),right:Se(c.right,20),top:Se(c.top,20),bottom:Se(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:rr(d.lambda,.5,0,1),cascadeBlendPercentage:rr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:rT(r.planar)},shadowMeshes:{shadowReceivers:Pr(u.shadowReceivers),shadowCasters:Pr(u.shadowCasters),excludeFromShadow:Pr(u.excludeFromShadow)}}}function Bn(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 tT(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:Se(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,a),edgeSoftness:rr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Tr(o.maxSize,20)}}}function Gf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:vf.map(n=>{let o=r.find(i=>Df(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Ed(a.name,n.name),alphaIndexPresets:jf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function jf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=Se(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Ed(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function rT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:Af(r.normal,{x:0,y:1,z:0}),height:Se(r.height,0),heightMode:kf(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:rr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Pr(i.includePatterns),excludePatterns:Pr(i.excludePatterns),rootBoundaryPatterns:Pr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Pr(s.patterns)}}}function nT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Tr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:Se(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Tr(o.texelsPerMeter,256),atlasSize:Tr(o.atlasSize,4096),maxAtlasPages:Tr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Tr(o.targetChunkCount,64)}}}function oT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=hd(n.textureAssetId),a=hd(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:Se(r.rotationY,0)}}function aT(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:Se(r.exposure,1),contrast:Se(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:Mf(n.type,"aces")},antialiasing:{samples:wf(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Tr(i.scale,.5)}}}var wi=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Nf=1e-6,iT=1e-4,sT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),cT=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),dT=new Set(["x","y","z"]),lT=new Set(["r","g","b"]);function Xo(e,t="$.direction"){let r=Ff(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Nf&&bt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Vn(e,t="$.light"){let r=Td(e,t);r.schemaVersion!==1&&bt(`${t}.schemaVersion`,"expected 1");let n=uT(r.intensity,`${t}.intensity`);if(r.type==="directional"){ki(r,sT,t);let o=Ff(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Nf&&bt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>iT&&bt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return ki(r,cT,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`),groundColor:Id(r.groundColor,`${t}.groundColor`)});bt(`${t}.type`,"expected directional or hemispheric")}function Ff(e,t){let r=Td(e,t);return ki(r,dT,t),Object.freeze({x:Jo(r.x,`${t}.x`),y:Jo(r.y,`${t}.y`),z:Jo(r.z,`${t}.z`)})}function Id(e,t){let r=Td(e,t);return ki(r,lT,t),Object.freeze({r:Pd(r.r,`${t}.r`),g:Pd(r.g,`${t}.g`),b:Pd(r.b,`${t}.b`)})}function Td(e,t){(!e||typeof e!="object"||Array.isArray(e))&&bt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&bt(t,"expected a plain object"),e}function ki(e,t,r){for(let n of Object.keys(e))t.has(n)||bt(`${r}.${n}`,"unknown field")}function Jo(e,t){return(typeof e!="number"||!Number.isFinite(e))&&bt(t,"expected a finite number"),e}function uT(e,t){let r=Jo(e,t);return r<0&&bt(t,"expected a non-negative number"),r}function Pd(e,t){let r=Jo(e,t);return(r<0||r>1)&&bt(t,"expected a number between 0 and 1"),r}function bt(e,t){throw new wi(e,t)}var mT=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function _f(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function $f(e){return mT.has(e)}function Hn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Lf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=zf(e.baseColor?.color);n&&(r.color=n);let o=Xr(e.baseColor?.texture);o!==void 0&&(r.texture=o),nr(e.baseColor,r,"brightness"),nr(e.baseColor,r,"saturation"),nr(e.baseColor,r,"contrast"),nr(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=Xr(e.normal?.texture);i!==void 0&&(a.texture=i),nr(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Kn(e.metallic)&&(t.metallic=e.metallic),Kn(e.roughness)&&(t.roughness=e.roughness);let s={},c=Xr(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=Xr(e.occlusion?.texture);u!==void 0&&(d.texture=u),nr(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=zf(e.emission?.color);m&&(l.color=m),nr(e.emission,l,"intensity");let f=Xr(e.emission?.texture);f!==void 0&&(l.texture=f);let S=Xr(e.emission?.maskTexture);S!==void 0&&(l.maskTexture=S),Object.keys(l).length>0&&(t.emission=l);let g={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(g.mode=e.alpha.mode),nr(e.alpha,g,"opacity"),nr(e.alpha,g,"cutoff");let b=Xr(e.alpha?.texture);return b!==void 0&&(g.texture=b),Object.keys(g).length>0&&(t.alpha=g),Object.keys(t).length>0?t:void 0}function xd(...e){let t={};for(let r of e){let n=Lf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Un(t,n,"baseColor"),Un(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Un(t,n,"metallicRoughness"),Un(t,n,"occlusion"),Un(t,n,"emission"),Un(t,n,"alpha"))}return Lf(t)??{}}function Un(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function zf(e){return e&&Kn(e.r)&&Kn(e.g)&&Kn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function Xr(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function nr(e,t,r){Kn(e?.[r])&&(t[r]=e[r])}function Kn(e){return typeof e=="number"&&Number.isFinite(e)}var Bf="staticShadows";function Ar(e){let t=ar(e);if(!t)return null;let r=pe(t.sourceHash),n=pe(t.lightHash),o=pe(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=ET(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=fT(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=pT(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 Wn(e,t="$.staticShadows"){let r=Ar(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function fT(e){let t=ar(e);if(!t)return null;let r=pe(t.id),n=vi(t.width),o=vi(t.height),a=IT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function pT(e,t){let r=ar(e);if(!r)return null;let n=pe(r.id),o=yT(r.bounds),a=hT(r.plane),i=pe(r.pageId),s=bT(r.atlasRect),c=ST(r.atlasUv),d=PT(r.sourceNodeIds),u=pe(r.sourceHash),l=pe(r.lightHash),m=pe(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let S=gT(r.binding);return S?{binding:S}:{}})()}}function gT(e){let t=ar(e);if(!t)return null;let r=pe(t.id),n=pe(t.ownerCasterId),o=pe(t.receiverId),a=pe(t.generatedAt),i=pe(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=pe(t.lightId),c=pe(t.textureAssetId),d=pe(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 bT(e){let t=ar(e);if(!t)return null;let r=xr(t.x),n=xr(t.y),o=vi(t.width),a=vi(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function ST(e){let t=ar(e);if(!t)return null;let r=Oi(t.u0),n=Oi(t.v0),o=Oi(t.u1),a=Oi(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 yT(e){let t=ar(e);if(!t)return null;let r=jt(t.minX),n=jt(t.maxX),o=jt(t.minZ),a=jt(t.maxZ),i=jt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function hT(e){let t=ar(e);if(!t)return null;let r=jt(t.height),n=jt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function ET(e){let t=ar(e);if(!t)return null;let r=xr(t.sourceRootCount),n=xr(t.sourceMeshCount),o=xr(t.attemptedChunkCount),a=xr(t.chunkCount),i=xr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...Ri(t.skippedChunkCount,"skippedChunkCount"),...Ri(t.pageCount,"pageCount"),...or(t.resolution,"resolution"),...or(t.chunkSize,"chunkSize"),...or(t.atlasSize,"atlasSize"),...Ci(t.atlasUsedPixels,"atlasUsedPixels"),...Ci(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...TT(t.atlasOccupancy,"atlasOccupancy"),...or(t.texelsPerMeter,"texelsPerMeter"),...or(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...or(t.maxAtlasPages,"maxAtlasPages"),...Ci(t.sdfRadiusPx,"sdfRadiusPx"),...or(t.spatialChunkSize,"spatialChunkSize"),...or(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...or(t.targetChunkCount,"targetChunkCount"),...Ri(t.bakedChunkCount,"bakedChunkCount"),...Ri(t.reusedChunkCount,"reusedChunkCount"),...Ci(t.durationMs,"durationMs")}}function IT(e){let t=pe(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function PT(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=pe(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function pe(e){return typeof e=="string"&&e.trim()?e.trim():null}function jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function vi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function Oi(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function Ri(e,t){let r=xr(e);return r==null?{}:{[t]:r}}function or(e,t){let r=jt(e);return r==null||r<=0?{}:{[t]:r}}function Ci(e,t){let r=jt(e);return r==null||r<0?{}:{[t]:r}}function TT(e,t){let r=jt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ar(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var xT="@fps-games/editor.playable-sdk.scene-compiler",AT="2",DT=1e-4,et={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},MT=new Set(et.nodeKinds),wT=new Set(et.primitiveShapes),kT=new Set(et.assetTypes),OT=new Set(et.materialModes),RT=new Set(et.materialScopes),CT=new Set(et.materialAssetSystemPresets),vT=new Set(et.transformTypes),Yo=new Set(et.hierarchy.parentTargets),GT=et.runtimeOnlyTokens,jT=new Set(et.runtimeV3.assetFields),NT=new Set(et.runtimeV3.materialSlotFields),FT=new Set(et.runtimeV3.materialSlotSourceSurfaceFields);function _T(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,D)=>{c.length<s&&c.push({path:p,message:D})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),QT(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=cx(e),S=e.scene;if(!M(S))return l("$.scene","scene must be an object"),c;if(O(S.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(S.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(S.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(S.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(S.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(S.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&Vf(()=>Wn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let g=new Set,b=new Map,y=new Map,E=new Set,I=new Set([S.rootId]),P=new Map,A=new Map,$=new Set;return S.assets.forEach((p,D)=>{let h=`$.scene.assets[${D}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?g.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(g.add(p.id),b.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),kT.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&&!OT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),ZT(p.defaults,`${h}.defaults`,l),m===3)for(let F of Object.keys(p))jT.has(F)||l(`${h}.${F}`,`runtime schema v3 asset field is not allowed: ${F}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((F,Ir)=>{let er=`${K}[${Ir}]`;if(!M(F)||!O(F.slotId)){l(er,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(F.ownerNodePath)){l(er,"material slot must contain stable slotId and ownerNodePath");return}ne.has(F.slotId)?l(`${er}.slotId`,`duplicate material slot id: ${F.slotId}`):ne.add(F.slotId),m===3&&YT(F,er,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Hf(p,h,l)}),S.nodes.forEach((p,D)=>{let h=`$.scene.nodes[${D}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&P.set(p.id,p),O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(I.add(p.id),typeof p.kind=="string"&&A.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&$.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),MT.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),S.materialAssets.forEach((p,D)=>{let h=`$.scene.materialAssets[${D}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):E.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=Hn(p.shaderId),K=VT(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!UT(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?qf(p.properties,`${h}.properties`,l):KT(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}`);HT(p.system,`${h}.system`,l),WT(p.origin,`${h}.origin`,l),qT(p,h,l)}),S.nodes.forEach((p,D)=>{if(!M(p))return;let h=`$.scene.nodes[${D}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:S.rootId;O(K)&&JT(K,S.rootId,I,`${h}.parentId`,l),O(p.id)&&XT(p.id,S.rootId,P,`${h}.parentId`,l),ex(p.source,`${h}.source`,l),Xf(p.transform,`${h}.transform`,l),hx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Vf(()=>Ko(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?g.has(p.instance.assetId)?b.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?wT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(g.has(p.image.assetId)?b.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Kf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Kf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!vT.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?ux(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"&&(sx(p.camera,`${h}.camera`,l),dx(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"):(tx(p.marker,`${h}.marker`,l),rx(p.marker,p.id,I,$,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&LT(p.overrides,`${h}.overrides`,E,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Hf(p,h,l)}),S.materials.forEach((p,D)=>{let h=`$.scene.materials[${D}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!RT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!g.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!I.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&I.has(p.nodeId)){let R=A.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?Zf(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function $T(e,t={}){let r=_T(e,t);return{ok:r.length===0,errors:r}}function Vf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function LT(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}Wf(e.materialBinding,`${t}.materialBinding`,r,a),zT(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 zT(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):Wf(c,d,n,i)}}}function Wf(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&qf(e.override,`${t}.override`,n)}}function qf(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{Gi(e.baseColor.color,`${t}.baseColor.color`,r),Yr(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!We(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(Yr(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!We(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?Yr(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(Yr(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!We(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(Gi(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!We(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),Yr(e.emission.texture,`${t}.emission.texture`,r),Yr(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!We(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!We(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),Yr(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var BT=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function Qo(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&BT.test(e)}function VT(e){return Qo(e)?e:null}function UT(e){return Number.isSafeInteger(e)&&e>0}function KT(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Ad(e,t,r)}function Ad(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)=>Ad(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Ad(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function Yr(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 HT(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&&!CT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function WT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function qT(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function JT(e,t,r,n,o){if(e===t){Yo.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(Yo.has("sceneNode")&&r.has(e))return;let a=Yo.has("root")&&Yo.has("sceneNode")?"root or scene node":Yo.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function XT(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 YT(e,t,r){for(let n of Object.keys(e))NT.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))FT.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 ZT(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(Xf(e.transform,`${t}.transform`,r),Uf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Uf(o,`${t}.childOutlines.${n}`,r)}}function QT(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}Jf(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function ex(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}Jf(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function Jf(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function ji(e,t){let r=$T(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
- ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function Xf(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Nt(e.position,`${t}.position`,r),Nt(e.rotation,`${t}.rotation`,r),Nt(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Nt(e.scale,`${t}.scale`,r)}}function tx(e,t,r){if(!M(e)){r(t,"marker must be an object");return}Dr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&ax(e.color,`${t}.color`,r),e.target!=null&&Dd(e.target,`${t}.target`,r),e.semanticFrame!=null&&nx(e.semanticFrame,`${t}.semanticFrame`,r),ox(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function rx(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 Dd(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}Dr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function nx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}Dr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Nt(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Nt(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function ox(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){Dr(e,["kind"],t,r);return}if(e.kind==="point"){Dr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Nt(e.position,`${t}.position`,r),e.offset!=null&&Nt(e.offset,`${t}.offset`,r),e.target!=null&&Dd(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){Dr(e,["kind","target"],t,r),Dd(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Dr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Nt(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function ax(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}Dr(e,["r","g","b"],t,r);for(let n of["r","g","b"])Yf(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Dr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Nt(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function ix(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function We(e){return typeof e=="number"&&Number.isFinite(e)}function Zr(e){return We(e)&&e>0}function Yf(e){return We(e)&&e>=0&&e<=1}function Gi(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 sx(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!Zr(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Nt(e.targetOffset,`${t}.targetOffset`,r),ix(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!Yf(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),Zr(e.minZ)&&Zr(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),We(e.lowerBetaLimit)&&We(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),Zr(e.lowerRadiusLimit)&&Zr(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function cx(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===xT&&t.compilerVersion===AT}function dx(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?lx(e,t):e;try{Vn(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 lx(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)>DT?r:{...r,direction:Xo(e.direction,`${t}.direction`)}}function Uf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),Gi(e.outlineColor,`${t}.outlineColor`,r)}}function ux(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}mx(e,t,r)}function mx(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"),fx(e.mask,`${t}.mask`,r),px(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)=>gx(n,`${t}.layers[${o}]`,r)),bx(e.layers,`${t}.layers`,r)}function fx(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 px(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 gx(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]"),Sx(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"),qn(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"),qn(e.tint,`${t}.tint`,r)):e.kind==="color"?qn(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"),qn(e.color,`${t}.color`,r)):e.kind==="text"?yx(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function bx(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 Sx(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 yx(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"),qn(e.color,`${t}.color`,r),qn(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 qn(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 hx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Kf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Zf(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&Gi(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?Zf(o,a,r):r(a,`${n} must be an object`))}}function Hf(e,t,r){let n=JSON.stringify(e),o=GT.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function Ex(e,t,r){let n=Qf(e)??512,o=Qf(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function Ni(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 Ex(t,r,n)}function Qf(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function ep(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!ir(e,s))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=ir(e,s);if(!c)return J("missing-node");if(!op(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):Fi();let o=ir(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>rp(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!np(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=Md(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"):Fi()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=ir(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=Md(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"):Fi()}function tp(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!ir(e,i))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=ir(e,i);if(!s)return J("missing-node");if(!op(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=ir(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!np(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||rp(e,o.id,i)))return J("cannot-parent-to-descendant");let a=Md(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=ir(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return Fi()}function ir(e,t){return t?e.find(r=>r.id===t)??null:null}function wd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function St(e,t){let r=wd(t).filter(o=>!!ir(e,o)),n=new Set(r);return r.filter(o=>!Ix(e,o).some(a=>n.has(a)))}function Md(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function rp(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function np(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function op(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function Ix(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 Fi(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var yt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Qr={kind:"texture"},ap={kind:"color"},Px={kind:"enum",values:["lit","unlit"]},Tx={kind:"enum",values:["opaque","mask","blend"]},cp={lightingModel:Px,baseColor:{kind:"object",properties:{color:ap,texture:Qr,brightness:yt(0),saturation:yt(0),contrast:yt(0),hue:yt(-180,180)}},normal:{kind:"object",properties:{texture:Qr,strength:yt(0)}},emission:{kind:"object",properties:{color:ap,intensity:yt(0),texture:Qr,maskTexture:Qr}},alpha:{kind:"object",properties:{mode:Tx,opacity:yt(0,1),cutoff:yt(0,1),texture:Qr}}},xx={kind:"object",properties:{...cp,metallic:yt(0,1),roughness:yt(0,1),metallicRoughness:{kind:"object",properties:{texture:Qr}},occlusion:{kind:"object",properties:{texture:Qr,strength:yt(0)}}}},Ax={kind:"object",properties:cp},Dx={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}},Mx={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},ip=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],en={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},dp=[Xn("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Xn("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Yn("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),ht("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),Yn("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[en]),ht("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.normal.texture.textureAssetId","normalTexture")]}),Xn("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),ht("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Yn("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Xn("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),ht("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),ht("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Yn("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],wx=[...dp,ht("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[en]}),ht("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[en]}),Yn("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[en]),Yn("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[en]),ht("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],kx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:xx,defaultProperties:Dx,inspector:{sections:ip,fields:wx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Ax,defaultProperties:Mx,inspector:{sections:ip,fields:dp}}],Mr=Ox(kx);function Ox(e){let t=new Map;for(let n of e){Cx(n,t);let o=vx(n);t.set(n.shaderId,mp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Od(e,t=Mr){return t.get(e)}function De(e){return Od(e)}function Rx(e,t,r=Mr){let n=Cd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function Zn(e,t,r=Mr){let n=Od(e,r);if(!n)return null;let o=Rx(e,t,r),i=(o?.schemaPath??Cd(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 Rd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function Qn(e,t,r="properties",n=Mr){let o=Od(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return vd(o.propertiesSchema,t,r,a),a}function Xn(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function ht(e,t,r,n,o,a,i={}){return Xn(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Yn(e,t,r,n,o,a,i,s){return Xn(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Jn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Cx(e,t){if(!Hn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!jx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);lp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(vd(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.`);Gx(e,a),o.add(a.path)}}function vx(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=up(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Gx(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=up(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function lp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))lp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function jx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Cd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function up(e,t){let r=Cd(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 vd(e,t,r,n){if(e.kind==="object"){if(!kd(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&&vd(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];sp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){sp(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!kd(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function sp(e,t,r,n,o){if(!kd(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mp(t)}return e}function kd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eo(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Fx(n));for(let n of ea(e)){let o=r.get(n.type)??null;r.set(n.type,_x(o,n))}return[...r.values()]}function jd(e){return structuredClone(e)}function Fx(e){return{...jd(e),metadata:{...e.metadata??{},builtIn:!0}}}function _x(e,t){let r=e??null;return{...r??{},...jd(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function $x(e,t,r={}){if(!bp(t)||_d(t.type,r))return e;let n=ea(e);return n.some(o=>o.type===t.type)?e:Fd(e,[...n,Nd(t,!1)])}function Lx(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=_d(o,n),i=ea(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=Nd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return Fd(e,[...i.filter(u=>u.type!==o),d])}function zx(e,t,r={}){let n=t.trim();if(!n||Sp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=ea(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:Fd(e,a)}function Nd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function ea(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(Bx).filter(r=>!!r):[]}function Fd(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(jd),{...e,metadata:Object.keys(r).length>0?r:void 0}}function Bx(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim()?null:Nd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(r=>typeof r=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0)}function bp(e){return!!e.type.trim()&&!!e.label.trim()}function _d(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function Sp(e,t={}){return!!_d(e,t)}function sr(e){let{spatial:t,...r}=structuredClone(e);return r}function _i(e){return structuredClone(e)}function yp(e,t){return{..._i(e),from:fp(e.from,t),to:fp(e.to,t)}}function hp(e,t){return{...sr(e),...e.target?{target:Gd(e.target,t)}:{},geometry:Vx(e.geometry,t)}}function Vx(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:Gd(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:Gd(e.target,t)};case"box":case"polyhedron":return structuredClone(e)}}function Gd(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function fp(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function Ep(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function $d(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function ta(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function Ld(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function pp(e,t){return e.kind==="marker"&&e.id===t}function cr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(sr),relations:e.relations.map(_i),...r?{metadata:structuredClone(r)}:{}}}function zd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function Ux(e,t){let r=sr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function Kx(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,sr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function Hx(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!pp(r.from,t)&&!pp(r.to,t))}}function gp(e,t){let r=_i(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 Wx(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{..._i(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function Ip(e,t,r={}){switch(t.type){case"marker.create-box":return Ux(e,t.marker);case"marker.update":return Kx(e,t.markerId,t.patch);case"marker.delete":return Hx(e,t.markerId);case"relation.create":return gp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>gp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return Wx(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return $x(e,t.definition,r);case"marker-type.update":return Lx(e,t.typeId,t.patch,r);case"marker-type.delete":return zx(e,t.typeId,r)}}function Pp(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=sr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=qx(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=Xx(n.label||n.id,a)),{...t,marker:n}}function qx(e,t,r){let o=(r??Jx)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function Jx(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Xx(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function Tp(e,t,r,n={}){switch(t.type){case"marker.create-box":return Yx(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&Zx(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return bp(t.definition)&&!eo(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&eo(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Sp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&ea(r).some(a=>a.type===o)}default:return!0}}function Yx(e,t){switch(t.kind){case"box":case"point":return!0;case"object-bounds":return ta(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function Zx(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function xp(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Ap(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function Bd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=sr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function ra(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Dp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var $i="summary",Mp="body";function Et(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Qx(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function zi(e){let t=Cp(e);return t&&eA(t)?{mode:"matrix",matrix:t}:null}function wp(e){return tt(e)?{mode:"matrix",matrix:Jd(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:Li(e.position),rotation:Li(e.rotation),scale:Li(e.scale)}}function tt(e){return e.mode==="matrix"}function It(e){return e.mode!=="matrix"}function Bi(e){return tt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:Li(e.position)}function eA(e){return!!Cp(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!kp(e)}function Fe(e){if(tt(e))return Jd(e.matrix);let t=tA(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,S=o*c,g=a*i,b=a*s,y=a*c,E=e.scale.x,I=e.scale.y,P=e.scale.z;return[(1-(m+S))*E,(u+y)*E,(l-b)*E,0,(u-y)*I,(1-(d+S))*I,(f+g)*I,0,(l+b)*P,(f-g)*P,(1-(d+m))*P,0,e.position.x,e.position.y,e.position.z,1]}function Hd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function kp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=t*i-r*a,E=t*s-n*a,I=t*c-o*a,P=r*s-n*i,A=r*c-o*i,$=n*c-o*s,z=d*S-u*f,p=d*g-l*f,D=d*b-m*f,h=u*g-l*S,R=u*b-m*S,K=l*b-m*g,ne=y*K-E*R+I*h+P*D-A*p+$*z;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let F=1/ne;return[(i*K-s*R+c*h)*F,(n*R-r*K-o*h)*F,(S*$-g*A+b*P)*F,(l*A-u*$-m*P)*F,(s*D-a*K-c*p)*F,(t*K-n*D+o*p)*F,(g*I-f*$-b*E)*F,(d*$-l*I+m*E)*F,(a*R-i*D+c*z)*F,(r*D-t*R-o*z)*F,(f*A-S*I+b*y)*F,(u*I-d*A-m*y)*F,(i*p-a*h-s*z)*F,(t*h-r*p+n*z)*F,(S*E-f*P-g*y)*F,(d*P-u*E+l*y)*F]}function Wd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Vd(e[0],e[1],e[2]),y:Vd(e[4],e[5],e[6]),z:Vd(e[8],e[9],e[10])};if(aA(e)<=0&&(r.y*=-1),!Kd(t)||!Kd(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(!iA(i))return null;let s=oA(nA(i));if(!s)return null;let c=rA(s);if(!Kd(c))return null;let d={position:t,rotation:c,scale:r};return na(Fe(d),e,1e-5)?d:null}function qd(e,t={}){let r=Wd(e);return r||(t.allowMatrixFallback?zi(e):null)}function Op(e){let t=Qx();for(let r of e)t=Hd(Fe(r),t);return qd(t,{allowMatrixFallback:!0})}function Rp(e,t){return qd(Hd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function to(e,t,r={}){let n=kp(Fe(e));return n?qd(Hd(Fe(t),n),r):null}function na(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function Jd(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function Cp(e){return e.length!==16||!e.every(Number.isFinite)?null:Jd(e)}function Li(e){return{x:e.x,y:e.y,z:e.z}}function tA(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 rA(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 nA(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 oA(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 aA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=l*b-g*m,E=u*b-S*m,I=u*g-S*l,P=d*b-f*m,A=d*g-l*f,$=d*S-f*u,z=+(i*y-s*E+c*I),p=-(a*y-s*P+c*A),D=+(a*E-i*P+c*$),h=-(a*I-i*A+s*$);return t*z+r*p+n*D+o*h}function Vd(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function iA(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(Ud(t,r))<1e-6&&Math.abs(Ud(t,n))<1e-6&&Math.abs(Ud(r,n))<1e-6}function Ud(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Kd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var sA={supportsShear:!1,supportsMatrixTransform:!1};function Vi(e={}){let t={...sA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function tn(e){return e==null||typeof e=="string"}function rn(e){return e==null||typeof e=="string"&&e.trim().length>0}function Ui(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ki(e){return e==null||typeof e=="boolean"}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function Hi(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function oa(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function Ft(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function _t(e){return w(e)&&e>0}function aa(e){return w(e)&&e>=0}function Wi(e){return w(e)&&e>=0&&e<=1}function qi(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!qe(t.position)||t.rotation!==void 0&&!qe(t.rotation)||t.rotationDeg!==void 0&&!qe(t.rotationDeg)||t.scale!==void 0&&!oa(t.scale))}function Ji(e){return e==="orthographic"||e==="perspective"}function Xi(e){return e==="hemispheric"||e==="directional"}var $t=["group","instance","transform","primitive"],vp=["instance","transform","primitive"],cA=["position","rotation","scale"],dA=["x","y","z"];function lA(e){return{path:`transform.${e}`,appliesTo:$t,validate:t=>t==null||(e==="scale"?oa(t):qe(t))}}function uA(e,t){return{path:`transform.${e}.${t}`,appliesTo:$t,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?aa(r):w(r))}}function mA(e){return[lA(e),...dA.map(t=>uA(e,t))]}var Xd=[{path:"name",appliesTo:$t,validate:tn},{path:"parentId",appliesTo:$t,validate:tn},{path:"enabled",appliesTo:$t,validate:Ki},{path:"shadow.cast",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:$t,validate:e=>e==null||qi(e)},...cA.flatMap(mA),{path:"transform.rotationDeg",appliesTo:$t,validate:e=>e==null||qe(e)},{path:"transform.rotationDeg.x",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:$t,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:Ji,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||qe(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:Wi,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||Hi(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:Xi,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:aa,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:qe,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.type",appliesTo:["transform"],validate:tn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:rn},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Ui(e)},{path:"marker.note",appliesTo:["transform"],validate:tn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var ie=["instance","transform","primitive"];function Je(e){return{path:e,appliesTo:ie,validate:t=>t==null||Ft(t)}}function V(e){return{path:e,appliesTo:ie,validate:t=>t==null||w(t)}}function Gp(e){return{path:e,appliesTo:ie,validate:t=>t==null||typeof t=="boolean"}}function le(e){return{path:e,appliesTo:ie,validate:rn}}function pA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function gA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="lit"||t==="unlit"}}var bA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:ie,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:ie,validate:e=>e==null||w(e)},Je("overrides.material.albedoColor"),Je("overrides.material.diffuseColor"),Je("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Gp("overrides.material.backFaceCulling"),le("overrides.material.albedoTexture.url"),le("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),le("overrides.material.metallicTexture.url"),le("overrides.material.occlusionTexture.url"),le("overrides.material.emissiveTexture.url"),le("overrides.material.opacityTexture.url"),Je("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Je("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Je("overrides.material.pbr.emissiveColor"),Je("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Je("overrides.material.standard.diffuseColor"),Je("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Je("overrides.material.standard.emissiveColor"),Je("overrides.material.standard.ambientColor"),Gp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:ie,validate:rn},gA("overrides.materialBinding.override.lightingModel"),Je("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},le("overrides.materialBinding.override.baseColor.texture.url"),le("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),le("overrides.materialBinding.override.normal.texture.url"),le("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),le("overrides.materialBinding.override.metallicRoughness.texture.url"),le("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),le("overrides.materialBinding.override.occlusion.texture.url"),le("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Je("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),le("overrides.materialBinding.override.emission.texture.url"),le("overrides.materialBinding.override.emission.texture.textureAssetId"),le("overrides.materialBinding.override.emission.maskTexture.url"),le("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),pA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),le("overrides.materialBinding.override.alpha.texture.url"),le("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:ie,validate:e=>e==null||SA(e)},{path:"overrides.outline.strategy",appliesTo:ie,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:ie,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:ie,validate:e=>e==null||Ft(e)},{path:"overrides.outline.outlineColor.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1}],jp=[...Xd,...bA];function SA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||Ft(t.outlineColor))}function Yd(e,t){let r=jp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var dr="scene.materialAssets.",Zd="__fps_duplicate_material_asset__:",yA="mat_";function hA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function nn(e){let t=hA(e);return`${yA}${t||"material"}`}function Qd(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Np(e,t=dr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function wr(e){return e==="overrides.materialBinding.materialAssetId"||Lt(e,"materialAssetId")!=null}function el(e){if(wr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return Yi(`properties.${e.slice(t.length)}`);let r=EA(e);return r?Yi(`properties.${r}`):!1}function Zi(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||Lt(e,"materialAssetId")!=null||Lt(e,"override")!=null}function Lt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function EA(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 Yi(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function ro(e,t){if(!De(e)||!Yi(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return Zn(e,r)?.kind==="texture"}function rt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(Yi(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function zt(e,t,r,n=Mr){let o=rt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=IA(e,r,n);return a?PA(a,o):!1}function IA(e,t,r){if(t!=null)return Zn(t,e,r);for(let n of r.list()){let o=Zn(n.shaderId,e,r);if(o)return o}return null}function PA(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?xA(t):TA(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 Qi(e){return typeof e!="string"||!e.startsWith(Zd)?null:e.slice(Zd.length).trim()||null}function Fp(e){return e.trim().replace(/^\/+|\/+$/g,"")}function TA(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 xA(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 AA={r:.78,g:.78,b:.78};function Bt(e,t={}){let r=e??{},n=wA(r.baseColor?.texture,t),o=MA(r,t),a=DA(r,t);return{kind:"material-sphere",baseColor:kA(r),metallic:ia(r.metallic??0),roughness:ia(r.roughness??1),...r.emission?.color?{emissionColor:Lp(r.emission.color)}:{},emissionIntensity:OA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function DA(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=tl(o,t);return a?[{channel:n,...a}]:[]})}function MA(e,t){let r=structuredClone(e),n=on(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=on(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=on(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=on(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=on(r.emission?.texture,t),c=on(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=on(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function on(e,t){if(!e)return;let r=tl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function wA(e,t){let r=tl(e,t);return r?.state==="ready"?r.url:void 0}function tl(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 $p(e,t){let r=e??{},n=_p(r.metallic??0),o=_p(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function kA(e){let r=(e.baseColor??{}).color??AA;return Lp(r)}function Lp(e){return{r:ia(e.r),g:ia(e.g),b:ia(e.b)}}function ia(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function _p(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function OA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Vt(e,t){return!!ee(e,t)}function qp(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function sa(e,t){let r=new Set;for(let n of rl(e,t))r.add(n.gameObjectId);return[...r]}function rl(e,t){let r=t.trim();return r?an(e).filter(n=>n.materialAssetId===r):[]}function an(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=_A(n),a=es(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=lr(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=es(u);if(!l)continue;let m=s.get(d),f=$A(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Ut(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){zp(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??[])zp(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 zp(e,t){let r=es(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=es(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 rs(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=an(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 lr(e,t,r){let n=new Map;for(let o of os(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 Jp(e,t){return os(e,t).length>0}function nt(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Ut(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function Xp(e){return e.slotId}function ns(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function nl(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function Yp(e){let t=Zp(e);if(!t)return;let r={},n=FA(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 os(e,t,r){let n=ue(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=no(s);c&&i.push(c)}return i}function no(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=RA(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=vA(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 RA(e){return Array.isArray(e)?e.flatMap(t=>{let r=Zp(t);if(!r)return[];let n=Fp(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=CA(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 CA(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Bp(t.min),n=Bp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Bp(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 vA(e){if(!Array.isArray(e))return;let t=e.map(GA).filter(r=>!!r);return t.length>0?t:void 0}function GA(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=jA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function jA(e){if(!Array.isArray(e))return;let t=e.map(NA).filter(r=>!!r);return t.length>0?t:void 0}function NA(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 Zp(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function FA(e){return typeof e=="string"&&e.trim()?e.trim():null}function _A(e){return e.name?.trim()||e.id}function es(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function $A(e,t){return e?.label?.trim()||Ut(e)?.trim()||e?.slotId?.trim()||t}var ts=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of an(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)??[]}},Vp=new WeakMap;function LA(e){let t=Vp.get(e);return t||(t=new ts(e),Vp.set(e,t)),t}function ol(e){return e?.system?.preset}function Up(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Kp(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function zA(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Hp(e.document,r.id,e.ownershipText,t):null,a=r?Kp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?Wp(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?Up(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Bt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Hp(e.document,s.id,e.ownershipText,t);return{label:Up(s,e.displayText),value:s.id,meta:Wp(Kp(s,e.displayText),c),kind:"material",preview:Bt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Hp(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 Wp(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function BA(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:$p(n.properties,n.id),preview:Bt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||ol(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var VA={createUsageIndex(e){return new ts(e)},getCachedUsageIndex:LA,createPickerControlOptions:zA,createBrowserAssetItems:BA},_e=VA;var sn=1;var il="prefab.";function da(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=>UA(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>KA(o,r)),{document:t,summary:r}}function dn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function UA(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),dn(r)?(r.shadow=eg(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function KA(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:eg(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 eg(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 zF=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(JA)??null}function ue(e){return e.components.find(XA)??null}function kr(e){return e.components.find(YA)??null}function Xe(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Xe(r)?r:null}function as(e){return te(e?.prefab?.prefabId)!=null}function ca(e){return te(e?.prefab?.sourceAssetId)}function Ye(e){if(!e?.prefab)return null;let t=cl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Ze(e){return e?.prefab?cl(e.prefab):[]}function oo(e,t){let r=te(t);return r?Ze(e).find(n=>n.id===r)??null:null}function sl(e,t){let r=te(t);return Ze(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function tg(e){if(!Xe(e))return al(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=cl(e.prefab),r=Ye(e);if(e.prefab.compositionVersion!==sn||t.length===0||!r)return al(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${sn} with an explicit root node.`,assetId:e.id}]);let n=HA(e);return al(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function al(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 HA(e){let t=structuredClone(e),r=Ze(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=sn,t.prefab.nodes=r;let n=Ye({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function cl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=WA(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function WA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!qA(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 qA(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function rg(e){let t=ca(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 ng(e){if(!e.startsWith(il))return null;let t=e.slice(il.length);return Zi(t)?t:null}function dl(e){return ng(e)?.endsWith(".materialAssetId")===!0}function og(e){return e.startsWith(il)&&e.endsWith(".materialAssetId")&&dl(e)}function ag(e,t){if(t.slotId)return Yp(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function la(e,t,r){let n=ng(t);if(!n||!Xe(e))return e;let o=QA(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),tD(a.prefab,o,r);let i=lg(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function ig(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=xd(e?.override,t?.override);return ul({...n??r?{materialAssetId:n??r}:{},...cn(o)?{override:o}:{}})}function is(e,t){let r={},n=ig(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=nD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ss(e,t){let r=ln(e,t);if(!(!r.gameObject||!r.prefab))return is(r.definition?.prefab?.overrides,oD(r.gameObject.overrides))}function ln(e,t){let r=typeof t=="string"?ZA(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=as(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Xe(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=ca(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Xe(u)&&ca(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:as(e)?"instance":e.primitive?"primitive":ue(e)?"instance":kr(e)||e.transformType?"transform":"group"}function sg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=ll(t?.renderingGroupId),n=dg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function ll(e){return e===0||e===1||e===2||e===3?e:null}function cg(e){return dg(e)}function JA(e){return e.type==="Transform"}function XA(e){return e.type==="ModelRenderer"}function YA(e){return e.type==="ImageRenderer"}function dg(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 ZA(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function QA(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 Qp(["overrides","materialBinding","override"],o)}let r=Lt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=Lt(e,"override");if(n){let o=eD(e);return o?Qp(["overrides","materialSlotBindings",n,"override"],o):null}return null}function eD(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function Qp(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(ug)?null:[...e,...r]}function tD(e,t,r){if(t.some(ug))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 lg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=ul(t.materialBinding);n&&(r.materialBinding=n);let o=rD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ul(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=xd(t.override),o={...r?{materialAssetId:r}:{},...cn(n)?{override:n}:{}};return cn(o)?o:void 0}function rD(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=ul(n);a&&(t[o]=a)}return cn(t)?t:void 0}function nD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=ig(e?.[o],t?.[o]);a&&(n[o]=a)}return cn(n)?n:void 0}function oD(e){return lg(e)}function cn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function ug(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var aD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function mg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&N("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))aD.has(s)||N("schema.invalidValue",`${r}.${s}`);ua(e.parentId)||N("schema.invalidReference",`${r}.parentId`),dD(e.transform,`${r}.transform`),iD(e.marker,`${r}.marker`);let n=ua(e.id),o=e.marker,a=sD(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&N("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&N("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&N("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&N("schema.invalidReference",`${s.path}.kind`))}}function iD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&N("schema.unsupportedVersion",`${t}.schemaVersion`),ua(r.type)||N("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!ua(r.kind)&&N("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&mD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&N("schema.invalidType",`${t}.note`),r.color!==void 0&&uD(r.color,`${t}.color`),r.target!==void 0&&ml(r.target,`${t}.target`),r.semanticFrame!==void 0&&lD(r.semanticFrame,`${t}.semanticFrame`),cD(r.geometry,`${t}.geometry`),r.metadata!==void 0&&fD(r.metadata,`${t}.metadata`)}function sD(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 cD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.kind==="box"){Pt(r,["kind"],t);return}if(r.kind==="point"){Pt(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&N("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Or(r.position,`${t}.position`),r.offset!==void 0&&Or(r.offset,`${t}.offset`),r.target!==void 0&&ml(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){Pt(r,["kind","target"],t),ml(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){Pt(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&N("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||N("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Or(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||N("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||N("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&N("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}N("schema.invalidValue",`${t}.kind`)}function ml(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&N("schema.invalidValue",`${t}.kind`),ua(r.id)||N("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&N("schema.invalidType",`${t}.label`)}function dD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.type!=="Transform"&&N("schema.invalidValue",`${t}.type`),r.mode==="matrix"){Pt(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&N("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>cs(n,`${t}.matrix[${o}]`));return}Pt(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&N("schema.invalidValue",`${t}.mode`),Or(r.position,`${t}.position`),Or(r.rotation,`${t}.rotation`),r.scale!==void 0&&Or(r.scale,`${t}.scale`)}function lD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["origin","forward","right","up","label","description"],t),Or(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Or(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&N("schema.invalidType",`${t}.${n}`)}function uD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["r","g","b"],t);for(let n of["r","g","b"])cs(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&N("schema.invalidValue",`${t}.${n}`)}function Or(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["x","y","z"],t);for(let n of["x","y","z"])cs(r[n],`${t}.${n}`)}function mD(e,t){Array.isArray(e)||N("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&N("schema.invalidType",`${t}[${n}]`)})}function fD(e,t){let r=Rr(e);r||N("schema.invalidType",t),fl(r,t,new Set)}function fl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){cs(e,t);return}(!e||typeof e!="object")&&N("schema.invalidType",t),r.has(e)&&N("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&N("schema.invalidType",t):n!==Object.prototype&&n!==null&&N("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>fl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))fl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function Pt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||N("schema.invalidValue",`${r}.${o}`)}function cs(e,t){(typeof e!="number"||!Number.isFinite(e))&&N("schema.invalidValue",t)}function Rr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ua(e){return typeof e=="string"&&e.trim()?e.trim():null}function N(e,t){throw new Error(`${e}: ${t}`)}function ao(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${pD(t)}`}function pD(e){return encodeURIComponent(e)}function pl(e,t){return{...structuredClone(e),id:ao(t,e.id)}}function ma(e,t){let r=structuredClone(e);return r.target&&(r.target=pl(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=pl(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=pl(r.geometry.target,t)),r}function B(e,t){if(fg(e))try{return e[t]}catch{return}}function ce(e,t){let r=B(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=B(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=B(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=B(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Kt(e){if(!fg(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=B(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function un(e){let t=Kt(e),r=ce(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function fg(e){return!!e&&(typeof e=="object"||typeof e=="function")}function ds(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)?gD(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=>ds(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=ds(B(n,a),t,r+1);return o}function gD(e){return Math.round(e*1e6)/1e6}function Cr(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(!bD(e.value))return null;let t=ds(e.value);return{path:e.path,label:e.label,valueType:e.valueType??SD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:hD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??yD(e.source,e.persistence),disabledReason:e.disabledReason}}function gl(e,t){let r=j(t);r&&e.push(r)}function io(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function bl(e){let t=mn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function mn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function bD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function SD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function yD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function hD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function fa(e){let t=e.projectedRoot??e.root??null,r=gg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:bg(t),meshes:r,primaryMesh:n,material:ED(t)}}function ls(e){let t=we(e,"getHierarchyBoundingVectors"),r=mn(B(t,"min")),n=mn(B(t,"max"));if(r&&n)return pg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=mn(B(a,"minimumWorld")),s=mn(B(a,"maximumWorld"));return i&&s?pg(i,s):null}function gg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return Sg(e)&&r.unshift(e),[...new Set(r)]}function bg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function Sg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(e,"getBoundingInfo")=="function")}function us(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function so(e,t){let r=B(e,t);return Array.isArray(r)?r.length:0}function ms(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function Sl(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 pg(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 ED(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 ps={x:-.3,y:-1,z:-.2},yg=-180,hg=180,ga=-90,ba=90;function Sa(e,t=ps){let r=e&&TD(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 hl(e,t){let r=vr(bs(e)),n=vr(Ag(t,ga,ba)),o=Math.cos(n);return{x:yl(o*Math.cos(r)),y:yl(-Math.sin(n)),z:yl(o*Math.sin(r))}}function El(e){if(!Ss(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=Tg({direction:e.light.direction,rotation:r}),o=hl(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:vr(n.elevationAngleDeg),y:vr(n.horizontalAngleDeg),z:co(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function Eg(e,t){if(!Ss(e.light))return e;let r=El(e);if(!r)return e;let n=co(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=co(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=hl(n,o),i={...r.rotation,x:vr(o),y:vr(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function ID(e,t=ps){let{horizontalAngleDeg:r,elevationAngleDeg:n}=Tg({direction:t,rotation:e});return hl(r,n)}function PD(e,t){let r=Pg(e);return{x:vr(r.elevationAngleDeg),y:vr(r.horizontalAngleDeg),z:co(t?.z)?t.z:0}}function lo(e){if(!Ss(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=ID(t.rotation,e.light.direction);return xg(r,Sa(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function gs(e){if(!Ss(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=PD(e.light.direction,t.rotation);return xg(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function Ig(e){let t=Sa(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function bs(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function TD(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 Ss(e){return e?.type==="directional"}function Pg(e){let t=Sa(e);return{horizontalAngleDeg:bs(fs(Math.atan2(t.z,t.x))),elevationAngleDeg:fs(Math.asin(Ag(-t.y,-1,1)))}}function Tg(e){let t=Pg(e.direction);return{horizontalAngleDeg:co(e.rotation?.y)?fs(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:co(e.rotation?.x)?fs(e.rotation.x):t.elevationAngleDeg}}function co(e){return typeof e=="number"&&Number.isFinite(e)}function xg(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 fs(e){return e*180/Math.PI}function vr(e){return e*Math.PI/180}function yl(e){return Math.round(e*1e6)/1e6}function Ag(e,t,r){return Math.min(r,Math.max(t,e))}var fn="light.directionHorizontalAngleDeg",pn="light.directionElevationAngleDeg";function uo(e){return e===fn||e===pn}function Dg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=xD(t);return r==null?t:e===fn?Math.round(bs(r)):e===pn?Math.round(AD(r,ga,ba)):t}function xD(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 AD(e,t,r){return Math.min(r,Math.max(t,e))}function gn(e){return t=>mo({...e,value:t})}function mo(e){let t=DD(e);if(t)return t;let r=Yd(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function bn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?Mg(t):t}function ys(e,t,r={}){if((r.isDirectionalLightAnglePath??wg)(e))return Dg(e,t);if(e==="marker.type"&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return wD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return el(e)&&typeof t=="string"?Mg(t):bn(e,t)}function Il(e){return t=>MD(t,e)}function DD(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 MD(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??wg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(wr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(wr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(el(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function Mg(e){let t=e.trim();return t||null}function wD(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 wg(e){return e===fn||e===pn}function ya(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:gn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function ot(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Tt(e){return e*180/Math.PI}function Ht(e){return e*Math.PI/180}function at(e){return Math.round(e*1e6)/1e6}var kg={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"}},Og=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function Pl(e){return kg[e]??kg.zh}function kD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function Rg(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=Pl(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:Og,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:kD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:at(Tt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Ht(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return gl(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function Tl(e){let t=Pl(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:Rg(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 hs="scene.main",Es="scene";function Wt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||hs,sourceType:t?.sourceType||Es,revision:typeof t?.revision=="number"?t.revision:1}}function Cg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:hs,sourceType:Es,revision:t.revision??1}}}}function vg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:hs,sourceType:Es,revision:(t.revision??0)+1}}}}function Gg(e,t){let r=Wt(e),n=OD(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 OD(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 RD="sun_light";function Is(e){let t=CD(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function CD(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 vD(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=He(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function GD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=Ts(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...xl(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;He(n.shadow).shadow?.receive==="enabled"&&FD(t,{receiverId:n.id,source:"explicit",score:100,...xl(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function Ps(e){let t=e.caster?.id===e.casterId?e.caster:Ts(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:yi(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=He(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():vD(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?cd(n.settings,e.fallbackMode??"none"):"none",i=dd(n.settings,e.fallbackQuality??"medium"),s=yi(i,n.settings?.params),c=jD(a),d=_D(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?$D(e.document,t.id,d):{candidates:GD({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:ND(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 ND(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&jg(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??RD;if(jg(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Ng(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function jg(e,t){let r=Ts(e,t);return!!r&&r.active!==!1&&Ng(r)}function Ng(e){return Y(e)==="transform"&&e.light?.type==="directional"}function FD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function _D(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 $D(e,t,r){let n=[],o=[];for(let a of r){let i=Ts(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,...xl(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function xl(e,t,r,n){let o=He(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function Ts(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var LD="main_camera",zD="environment_light",BD="sun_light";function Al(e){return Y(e)==="group"}function xt(e){return!!G(e)}function At(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function fo(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Dt(e){return e.id===LD||e.id===zD||e.id===BD||At(e)||fo(e)}function Dl(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Dt(r)}var Gr="root",VD="go_",Ml="GameObject";function me(e){return e===Gr}function Z(e){return me(e.id)}function kl(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=KD(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`${VD}${e}`}function it(e,t){let r=new Set(e),n=xs(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function Fg(e,t=Ml){return wl(e)??wl(t)??Ml}function st(e,t,r={}){let n=Fg(t,r.fallbackName??Ml),o=new Set(e.map(s=>wl(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 wl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function xs(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function UD(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function KD(e,t){let r=UD(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 jr=Et();function ke(e,t){if(me(t))return Et();let r=_(e,t);if(!r)return null;let n=[],o=Ol(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return Op(n.map(qt))}function _(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Ol(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ur(e,t,r,n){let o=t?ke(e,t):Et();return o?to(o,r,n):null}function ha(e,t,r,n={}){let o=Vi(n);return ur(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function qt(e){return Z(e)?Et():go(e)}function Ea(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=go(r),o=!!G(r)&&!WD(n,jr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=_g(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Gr||!G(s))return s;let d=Rp(n,go(s));if(!d)return s;let u=Rl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function _g(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return Ds(s)&&po(s.position,jr.position)&&po(s.rotation,jr.rotation)&&po($g(s,"scale"),jr.scale)?i:(n=!0,As())});if(r||(n=!0,o.unshift(As())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function As(){return Mt(jr)}function go(e){let t=G(e);return t?Ee(t)?zi(t.matrix)??Et():{position:{...t.position},rotation:{...t.rotation},scale:{...$g(t,"scale")}}:Et()}function Rl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:mr(t)??r)}}function mr(e){let t=Sn(e);return t?tt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function Sn(e){return tt(e)?zi(e.matrix):wp(e)}function Mt(e){let t=mr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function Ds(e){return e.mode!=="matrix"}function $g(e,t){return HD(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 HD(e){return!!e.position&&!!e.rotation}function WD(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):po(e.position,t.position)&&po(e.rotation,t.rotation)&&po(e.scale,t.scale)}function po(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function ye(e){return e.scene.gameObjects.find(t=>t.id===Gr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function Ms(e,t){return me(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function Cl(e,t){return!t||t===Gr?!1:!!_(e,t)}function fr(e){let t=ye(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Gr).map(n=>{let o=Dt(n),a=xt(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,qD(r,n)-(t?1:0)),role:a&&Al(n)?"group":"object",...as(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&JD(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 qD(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 JD(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 vl(e){let t=Ea(e,{normalizeRootActive:!0}),r=ye(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=qt(s),d=o?to(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:Mt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function pr(e,t){return[...wt(e,t)]}function wt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Nl(e){let t=[Lg(e)],r=Bg(e);r&&t.push(r);let n=Kg(e);n&&t.push(n);let o=qg(e);o&&t.push(o);let a=Yg(e);a&&t.push(a);let i=ZD(e);i&&t.push(i);let s=Qg(e);s&&t.push(s);let c=eb(e);c&&t.push(c);let d=rb(e);return d&&t.push(d),t}function Lg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:Os(e),persistence:"document",collapsedByDefault:!1,properties:zg(e)}}function zg(e){let{document:t,gameObject:r}=e,n=Os(e),o=[Qe("id","ID",r.id,0),Jt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Jt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),Qe("kind.resolved","Resolved Kind",n,3),Qe("kind.explicit","Explicit Kind",r.kind??"inferred",4),Qe("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Jt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??Pa})):o.push(Qe("common.transformType","Transform Type",r.transformType??"none",6)),o}function Bg(e){return Cr({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Vg(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Ug(e)})}function Vg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Ug(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?_(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(pr(t,[r.id]).length-1,0),s=Wt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Kg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:Wg(e),persistence:"document",collapsedByDefault:!1,properties:Hg(e)}:null}function Hg(e){if(!G(e.gameObject))return[];let r=Os(e),n=Z(e.gameObject),o=n?e.rootTransform??Et():go(e.gameObject);if(tt(o))return XD(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=iM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?at(Tt(d[u])):d[u];n?i.push(Qe(l,`${jl(c)}.${u}`,m,s)):i.push(Jt(e,{document:null,path:l,label:`${a?`Local ${jl(c)}`:jl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!tt(c))for(let d of["x","y","z"])i.push(Qe(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function Wg(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 XD(e,t){if(!tt(e))return[];let r=[Qe("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(Qe(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(ws).join(", "),n)),n+=1;let o=Wd(e.matrix);return r.push(Qe("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${Gl(o.position)}`,`R ${Gl({x:Tt(o.rotation.x),y:Tt(o.rotation.y),z:Tt(o.rotation.z)})}`,`S ${Gl(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function qg(e){let t=ue(e.gameObject),r=kr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:Xg(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?YD(e,r):Jg(e)}:null}function YD(e,t){let r=Ia(e.document,t.assetId);return[Qe("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),Qe("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),Qe("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function Jg(e){let t=ue(e.gameObject);if(!t)return[];let{document:r}=e,n=Ia(r,t.assetId),o=[Jt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function Xg(e,t){let r=Ia(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function Yg(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:Zg(e)}:null}function Zg(e){let t=e.gameObject.primitive;return t?[Jt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??sM})]:[]}function ZD(e){if(e.gameObject.prefab)return QD(e);if(!bo(e))return null;let t=He(e.gameObject.shadow).shadow,r=Jt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Jt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=ks(e.renderingProfile),a=e.renderingProfile!==void 0&&Is(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?[Fl()]:[]]}}function QD(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=He(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[io({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function Fl(){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 ks(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 Qg(e){if(!eM(e))return null;let t=ks(e.renderingProfile),r=tM(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=rM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:nM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Jt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Jt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:oM(n,o)})]}}function eb(e){return Cr({id:"components",title:"Scripts / Components",order:65,summary:_l(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:tb(e.gameObject)})}function _l(e){return e.components.map(t=>t.type).join(", ")||"none"}function tb(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:_l(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function rb(e){let t=e.assetId??ue(e.gameObject)?.assetId??kr(e.gameObject)?.assetId??null,r=nb({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:ob({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function nb(e){let t=[],r=e.assetId?Ia(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 ob(e){let t=e.assetId?Ia(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Jt(e,t,r=Os(e)){let{document:n,...o}=t;return ya({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function Qe(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Os(e){return e.nodeKind??Y(e.gameObject)}function bo(e){let t=e.gameObject;return Z(t)?!1:dn(t)}function eM(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 tM(e){return e===1||e===2||e===3?e:0}function rM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function nM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${aM(e,t)}`}function oM(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 aM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function iM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Gl(e){return`${ws(e.x)}, ${ws(e.y)}, ${ws(e.z)}`}function ws(e){return at(e).toString()}function jl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Ia(e,t){return e.assets.find(r=>r.id===t)??null}var Pa=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],sM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function ab(e){return[cb(e),db(e.runtime),lb(e.runtime),ub(e.runtime),mb(e.runtime),fb(e.runtime),pb(e.runtime),gb(e.runtime),bb(e.runtime),Sb(e.runtime),yb(e.runtime),hb(e.runtime),Eb(e)].filter(t=>!!t)}function $l(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=fa({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return ab({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:ce(e.projectionNode,"id")??null,projectionName:ce(e.projectionNode,"name")??null,projectionParentId:ce(e.projectionNode,"parentId")??null,projectionAssetId:ib(e.projectionNode)},projectionAssetMetadata:sb(e.projectionNode)})}function ib(e){let t=B(e,"asset");return ce(t,"assetId")??ce(t,"id")}function sb(e){return B(B(e,"asset"),"metadata")}function cb(e){let{binding:t,runtime:r}=e,n=[];return x(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),x(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),x(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),x(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),x(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),x(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),x(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),x(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),x(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),x(n,{path:"runtime.root.className",label:"Runtime Class",value:Kt(r.root)??"none",order:9,source:"Runtime"}),x(n,{path:"runtime.root.name",label:"Runtime Name",value:ce(r.root,"name")??"none",order:10,source:"Runtime"}),x(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:un(r.primaryMesh)??"none",order:11,source:"Derived"}),x(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:un(r.material)??"none",order:12,source:"Derived"}),x(n,{path:"runtime.material.kind",label:"Material Kind",value:Ab(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?un(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function db(e){let t=[],r=ls(e.root)??ls(e.primaryMesh);return r?(yn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),yn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),yn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),yn(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):x(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),x(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),x(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),x(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:us(e.meshes,"getTotalVertices"),source:"Derived"}),x(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:us(e.meshes,"getTotalIndices"),source:"Derived"}),x(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+so(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function lb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Kt(t)??"none"}),x(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:Sl(t)??"not available"}),x(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),x(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),x(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),x(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),x(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),x(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),x(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:ce(t,"name")??Kt(t)??"not available",collapsedByDefault:!0,properties:r})}function ub(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),x(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),x(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),x(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),x(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof B(t,"moveWithCollisions")=="function"?"available":"not available"}),yn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),yn(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",B(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function mb(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(t,"physicsImpostor"),o=r??n,a=[];return x(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),x(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Kt(o)??"none"}),x(a,{path:"runtime.physics.bodyName",label:"Body Name",value:ce(o,"name")??ce(o,"id")??"none"}),x(a,{path:"runtime.physics.mass",label:"Mass",value:pa(o,"mass")??"not available"}),x(a,{path:"runtime.physics.friction",label:"Friction",value:pa(o,"friction")??"not available"}),x(a,{path:"runtime.physics.restitution",label:"Restitution",value:pa(o,"restitution")??"not available"}),x(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?un(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function fb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),x(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),x(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:un(B(e.material,"shadowDepthWrapper"))??"none"}),x(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function pb(e){let t=e.material,r=[];return x(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),x(r,{path:"runtime.material.className",label:"Class",value:Kt(t)??"none"}),x(r,{path:"runtime.material.name",label:"Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.material.id",label:"ID",value:ce(t,"id")??"none"}),x(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),x(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),x(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),x(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),x(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),x(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),x(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),x(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),x(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:ms(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:un(t)??"none",collapsedByDefault:!0,properties:r})}function gb(e){let t=e.material,r=[];x(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:ms(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of Db){let a=B(t,o);a&&(n+=1,Pb(r,`runtime.material.textures.${o}`,Ta(o),a))}return n===0&&x(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function bb(e){let t=[],r=0;for(let n of Mb){let o=B(e.material,n);Ib(t,`runtime.material.colors.${n}`,Ta(n),o,t.length)&&(r+=1)}return r===0&&x(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function Sb(e){let t=[];for(let r of wb)x(t,{path:`runtime.material.metallicRoughness.${r}`,label:Ta(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 yb(e){let t=[];for(let r of kb)x(t,{path:`runtime.material.intensity.${r}`,label:Ta(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 hb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return x(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:so(e.root,"animations"),source:"Derived"}),x(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:so(t,"animations"),source:"Derived"}),x(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),x(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Kt(r)??"none"}),x(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:ce(r,"name")??"none"}),x(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:ce(r,"id")??"none"}),x(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:so(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?ce(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function Eb(e){let{runtime:t}=e,r=[];return x(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(t.material,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),x(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return Cr({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function x(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function yn(e,t,r,n,o,a="Runtime",i){let s=bl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&x(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function Ib(e,t,r,n,o){let a=xb(n);return a?(x(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),x(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),x(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&x(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function Pb(e,t,r,n){let o=e.length;x(e,{path:`${t}.className`,label:`${r} Class`,value:Kt(n)??"Texture",order:o}),x(e,{path:`${t}.name`,label:`${r} Name`,value:ce(n,"name")??"none",order:o+1}),x(e,{path:`${t}.url`,label:`${r} URL`,value:Tb(n)??"none",order:o+2}),x(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),x(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),x(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function Tb(e){return ce(e,"url")??ce(e,"name")??ce(we(e,"getInternalTexture"),"url")}function xb(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 Ab(e){let t=Kt(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function Ta(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Db=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],Mb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],wb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],kb=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var Rb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],Ob={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 Ll(e){return Ob[e]??Ob.zh}function zl(e){return e.inspectorLanguage==="en"?"en":"zh"}function Cb(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=zl(n),s=Ll(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:Rb,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=El(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:fn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:yg,max:hg,step:1,coerce:m=>a(fn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:pn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:ga,max:ba,step:1,coerce:m=>a(pn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return dM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function vb(e){let t=e.renderingProfile.shadows.planar;return Cr({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:at(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:uM(Ig(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),lM(e.text)]})}function Bl(e){let t=Ll(zl(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:Cb(e)}];return e.light.type==="directional"&&r.push(vb({light:e.light,text:t,renderingProfile:cM(e.renderingProfile)})),r}function cM(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 dM(e,t){let r=j(t);r&&e.push(r)}function lM(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 uM(e){return`x${at(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(mM))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 mM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Vl(e){let t=Nr(e.overrides);if(!t)return;let r=Gb(t.material);r?t.material=r:delete t.material;let n=Nr(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=Nr(s);if(!c){delete n[i];continue}let d=Gb(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=Nr(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=Nr(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function Gb(e){let t=Nr(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function Nr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Nb(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 Ul(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=Nb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Nb(e,t){let r=jb(e),n=fM(e,t),o=jb(n);return r&&o&&!pM(r,o)?lo(n):n}function fM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?mr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function jb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function pM(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 Fb(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)||!gM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Kl(e){let t=Fb({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 gM(e,t){return(ll(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&cg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var xa=it,Rs=xs;function Hl(e){let t=st(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=xa(e.document.scene.gameObjects.map(n=>n.id),Rs(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function _b(e){let t=e.scene.gameObjects.filter(r=>!!ue(r)||!!kr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function Wl(e,t){let r=t&&It(t)?t:null;return{position:r?.position?{...r.position}:_b(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Gs(e){return e.filter(t=>IM(t.kind)&&Jl(t)).map(ql).sort(Xl)}function Da(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(ql).sort(Xl)}function ql(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=En(e.guid),n=SM(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??bM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:vs(e.defaults),prefab:vs(e.prefab),external:vs(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??EM(e.external)??e.assetId,placeable:Jl(e)}}function Lb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function Jl(e){return Lb(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function Xl(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function bM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function SM(e){return yM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...vs(e.metadata)})}function yM(e){if(!Array.isArray(e.materialSlots))return e;let t=Cs(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Cs(c),u=Aa(d?.meshIndex),l=En(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Cs(c),u=Aa(d?.nodeIndex),l=En(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=$b(t,"meshCount",r.length)||$b(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Cs(c);if(!d||En(d.sourceMeshName))return c;let u=Aa(d.meshIndex);if(u==null)return c;let l=Aa(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?hM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function hM(e){let t=En(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return En(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function $b(e,t,r){let n=Aa(e?.[t]);return n!=null&&n>r}function EM(e){return!e||typeof e!="object"||Array.isArray(e)?null:En(e.platformAssetId)}function En(e){return typeof e=="string"&&e.trim()?e.trim():null}function Aa(e){return Number.isInteger(e)&&e>=0?e:null}function Cs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function vs(e){return e==null?void 0:structuredClone(e)}function IM(e){return e==="model"||e==="prefab"||e==="texture"}function Yl(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?Fr(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of PM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push(Fr({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function PM(e){let t=[],r=new Set,n=o=>{let a=Ve(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=ct(ct(o)?.instance);n(a?.assetId)}return t}function Zl(e,t){Ma(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 Ma(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}`);AM(o,a),xM(o,a),TM(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=Ve(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),So(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),So(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Ze(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),So(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ve(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},ct(a.origin)?.sourceAssetId),So(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function TM(e){let t=ct(e.metadata),r=ct(e.external);if(!(Ve(t?.url)??Ve(t?.relativePath)??Ve(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=ct(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=ct(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ve(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=ct(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ve(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function xM(e,t){let r=ct(e.metadata),n=ct(t.metadata),o=ct(e.external),a=ct(t.external),i=Ve(r?.url)??Ve(r?.relativePath)??Ve(o?.assetUrl),s=Ve(n?.url)??Ve(n?.relativePath)??Ve(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function AM(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 Fr(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:js(t.defaults??e.defaults),prefab:js(t.prefab??e.prefab),external:js(t.external??e.external),metadata:js(t.metadata??e.metadata)}}function js(e){return e==null?void 0:structuredClone(e)}function So(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>So(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):So(o,a,r)}}}function ct(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ve(e){return(typeof e=="string"?e.trim():"")||void 0}function wa(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function DM(e){let t=structuredClone(e??{});return In(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,In(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,In(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,In(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(In(t.emission,"texture"),In(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),In(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function In(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Bb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=rt(t,r);if(a?!ro(e.shaderId,t)||!zt(t,null,e.shaderId,n):!zt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),MM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=DM(s.properties)),Qn(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function MM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var Pn="mat_default_pbr",yo="mat_default_standard",wM="00000000-0000-4000-8000-000000000001",kM="00000000-0000-4000-8000-000000000002",Tn=Pn,ka={id:Pn,guid:wM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Rd("fps.builtin.pbr")},OM={id:yo,guid:kM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Rd("fps.builtin.standard")};function RM(){return structuredClone(ka)}function CM(){return structuredClone(OM)}function Vb(e){let t=[RM(),CM()],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 Ub(e){return e?.system?.preset==="default-pbr"||e?.id===Pn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===yo?"default-standard":null}function Ns(e){let t=structuredClone(ka.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 xn(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=ho(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function ho(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var Ql=[Pn,yo],vM="New Material";function Kb(e,t,r=`${t.displayName} Material`){let n=Fs(e);return{id:nn(n),guid:n,name:eu(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function GM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Fs(e);return{id:nn(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 Hb(e,t,r){let n=t.name?.trim()||t.id,o=Fs(e);return{id:nn(o),guid:o,name:eu(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function jM(e,t){let r=Fs(e);return{id:nn(r),guid:r,name:eu(e,t.name),shaderId:ka.shaderId,definitionVersion:ka.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:Ns(t.profile)}}function Wb(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 Fs(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=Qd(),n=nn(r);for(;t.has(n);)r=Qd(),n=nn(r);return r}function eu(e,t){let r=rt("name",t),n=typeof r=="string"&&zt("name",r)?r:vM,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 qb(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=GM(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 Jb(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=jM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function _s(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Bb(d,r,rt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function Xb(e,t,r=[]){let n=ee(e,t),o=rl(e,t);return n?wa(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 Yb(e,t){return Xb(e,t,Ql)}function NM(e,t,r=[]){return Xb(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function tu(e){return wa(e,Ql)}function Zb(e,t){return NM(e,t,Ql)}function $s(e,t){return Vt(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function Qb(e,t,r,n){return Vt(e,n.id)?e:FM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function FM(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 _M(a,r,n),a})}}}function _M(e,t,r){let n=$M(t)??t.split(".").filter(Boolean);if(n.some(LM))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 $M(e){let t=Lt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function LM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function zs(e,t){let r=ue(t),n=r?e.assets.find(g=>g.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=os(e,t),i=new Map(a.filter(g=>!!g.slotId).map(g=>[g.slotId,g])),s=t.overrides?.materialSlotBindings??{},c=zM({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(g=>[g.toSlotId,g])),l=new Set([...d.map(g=>g.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[g,b]of Object.entries(s))!b||l.has(g)||m.set(g,b);for(let g of d){let b=s[g.fromSlotId];b&&m.set(g.toSlotId,b)}let f=[];for(let[g,b]of a.entries()){let y=b.slotId?m.get(b.slotId):void 0,E=Eo(y),I=E?ee(e,E):null,P=tS(b),A=P[0],$=b.slotId?u.get(b.slotId):void 0;if($){f.push({status:"changed",reason:"slot-remapped",...b.slotId?{slotId:b.slotId}:{},previousSlotId:$.fromSlotId,ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},materialAssetId:E,bindingPath:`overrides.materialSlotBindings.${b.slotId}.materialAssetId`,conflict:!1});continue}let z=rS(I,o,n?.id)?.sourceMaterialIndex;if(z!=null&&P.length>0&&!P.includes(z)){f.push(eS({status:"changed",reason:"source-material-changed",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},previousSourceMaterialIndex:z,...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:""}));continue}if(!E&&P.length>0){f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1})}for(let[g,b]of Object.entries(s))!b||i.has(g)||l.has(g)||f.push(eS({status:"removed",reason:"slot-removed",slotId:g,...Eo(b)?{materialAssetId:Eo(b)}:{},bindingPath:`overrides.materialSlotBindings.${g}.materialAssetId`}));let S=f.filter(VM);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:S.length===0,items:f,issues:S,bindingRemaps:d,bindingRemapIssues:c.issues,counts:UM(f)}}function zM(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=Eo(u),m=l?ee(e.document,l):null,f=rS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let S=e.currentSlots.filter(g=>!!g.slotId&&tS(g).includes(f.sourceMaterialIndex)).map(g=>g.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:S,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(g=>c.add(g));let l=u.filter(g=>a.get(g)?.anchored).sort((g,b)=>g.localeCompare(b));if(l.length===0){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(g=>BM(f.binding,a.get(g).binding))||r.has(d)){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(g=>g!==m).sort((g,b)=>g.localeCompare(b))}:{}});for(let g of u)g!==m&&s.add(g)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function BM(e,t){return Eo(e)===Eo(t)&&ru(e.override,t.override)}function ru(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>ru(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&ru(r[i],n[i]))}function tS(e){return nt(e)}function rS(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 Ls(e,t){return e.label?.trim()||Ut(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function Eo(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function eS(e){return{...e,conflict:!0}}function VM(e){return e.conflict}function UM(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Bs(e){let t=rs(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 KM(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=zs(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 HM(e,t,r){let n=!1,o=new Map(t.filter(l=>l.origin?.type==="imported").map(l=>[l.id,l]));if(o.size===0)return{materialAssets:t,gameObjects:r,changed:!1};let a=new Map(e.assets.map(l=>[l.id,l])),i={...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},s=r.map(l=>{let m=ue(l);if(!m)return l;let f=a.get(m.assetId);if(!f)return l;let S=lr(i,l,a),g=l;for(let b of S){let y=g.overrides?.materialSlotBindings?.[b.slotId],E=y?.materialAssetId?o.get(y.materialAssetId):null;if(!E||!WM(E,f))continue;let I=E.origin?.sourceMaterialIndex;if(!Number.isInteger(I)||!nt(b).includes(I))continue;g===l&&(g=structuredClone(l));let P=g.overrides?.materialSlotBindings;P&&(delete P[b.slotId],Object.keys(P).length===0&&delete g.overrides.materialSlotBindings,Object.keys(g.overrides??{}).length===0&&delete g.overrides,n=!0)}return g}),c={...i,scene:{...i.scene,gameObjects:s}},d=new Set(an(c).map(l=>l.materialAssetId)),u=t.filter(l=>l.origin?.type!=="imported"||d.has(l.id));return n=n||u.length!==t.length,{materialAssets:u,gameObjects:s,changed:n}}function nS(e,t,r){let n=KM({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r),o=HM(e,t,n.gameObjects);return{materialAssets:o.materialAssets,gameObjects:o.gameObjects,changed:n.changed||o.changed}}function WM(e,t){let r=e.origin;return r?.type!=="imported"?!1:r.sourceAssetId===t.id||!!r.sourceAssetGuid&&!!t.guid&&r.sourceAssetGuid===t.guid}function oS(e,t){let r=new Set,n=e.properties,o=An(n)?n:{},a=An(t.defaultProperties)?t.defaultProperties:{},i=aS(t.propertiesSchema,o,a,"properties",r),s=new Set;iS(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 aS(e,t,r,n,o){if(e.kind!=="object")return qM(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=An(t)?t:{},i=An(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=aS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function qM(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return nu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return nu(t,["x","y"]);if(e.kind==="vec3")return nu(t,["x","y","z"]);if(t===null)return!0;if(!An(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 iS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;An(o)&&!JM(o)?iS(o,a,r):r.add(a)}}function JM(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function nu(e,t){return An(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function An(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function XM(e){return e?.system?.preset}function cS(e,t){let r=XM(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Vs(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function sS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function dS(e){let t=e.currentTexture??Vs(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(YM);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?sS(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:sS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function YM(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function lS(e){return{path:`${e.pathPrefix??dr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var uS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function gr(e){return uS[e]??uS.zh}function Us(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var ZM={},mS=new WeakMap;function fS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function pS(e,t){return cS(e,SS(t))}function QM(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 ew(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function SS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function yS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=sw(e,t,r,n,o,a??void 0);if(ES(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=>tw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function tw(e){let{fieldDefinition:t}=e,r=gS(e.text,t.labelKey,t.label??t.path),n=ow(e.text,t.tooltipKey,t.tooltip),o=hS(e.materialAsset.properties,t),a=t.control==="texture"&&ro(e.materialAsset.shaderId,t.path)?rw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=cw({path:`${dr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=lw(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=uw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:gS(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"?Zn(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=>!nw(e.definition,e.materialAsset.properties,d));return c&&(i=gw(i,!1,aw(e.text,c))),a?fw(i,e.text,a):mw(i,e.text,t.defaultValue)}function rw(e,t){let r=Ks(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function hS(e,t){if(t.control==="texture"){let n=Ks(e,t.schemaPath??t.path);return IS(n)}let r=Ks(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Ks(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 nw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?hS(t,n):Ks(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 gS(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function ow(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function aw(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 iw(e){return e.defaultMaterialAssetIds??[Pn,yo]}function ES(e,t){return wa(e,iw(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function sw(e,t,r,n,o,a){if(!ES(t,o)){let i=o.materialShaderDefinitions??Mr;return[qs(e,t,"name",r.assetName,pS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${dr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[fS(`${dr}${t.id}.name`,r.assetName,pS(t,r),n,r.tooltips.assetName),fS(`${dr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function cw(e){let t=ou(e.context,e.value),r=Ws(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=bS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=bS(e.context,e.path,n);return o.ok?o.value:null}}}function Ws(e,t,r,n){return{...dS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:dw(t),candidateValue:"assetId"})}}function ou(e,t){return Vs(e.textureAssets,t)}function IS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function bS(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=Vs(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 lw(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 uw(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{...lS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:dr}),validate:l=>{let m=rt(r,l);return zt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>rt(r,l)}}function mw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!pw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function fw(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 pw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function gw(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function PS(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:yw(Hs(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=Qi(a);return i&&Vt(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Vt(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:bw(t,r.value),validation:Sw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function bw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Sw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function yw(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 hw(e,t,r){return PS(e,t,r,_e.getCachedUsageIndex(e))}function Hs(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:QM(r),displayText:SS(r),document:e,ownershipText:ew(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Ew(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=mS.get(e);a||(a=new WeakMap,mS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??ZM,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var Iw={createSelectorInspectorPropertyWithUsage:PS,createSelectorInspectorPropertyWithCachedUsage:hw,createPickerControlOptionsWithUsage:Hs,createPickerControlOptionsWithCachedUsage:Ew},Dn=Iw;function TS(e,t,r){let n=qp(e,t);if(n.state==="asset"&&n.materialAsset){let o=Ub(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 xS(e,t,r){let n=lr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Pw(e,t,r,n,o,a={}){let i=gr(Us(t)),s=[];return lr(e,t).forEach((d,u)=>{let l=Ut(d)??d.slotId,m=nl(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,S=f?.materialAssetId?ee(e,f.materialAssetId):null,g=(u+1)*100,b=ns(d),y=nt(d)[0],E=y==null?null:ho(d,y)?.profile,I=Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:b,label:d.label||au(l,u,i),value:m?.materialAssetId??"",order:g,text:i,currentAsset:S,currentAction:S?{actionId:"material.open-asset",params:{materialAssetId:S.id,browserAssetId:`material:${S.id}`,sourceObjectId:t.id,sourceBindingPath:b}}:E?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:b}}:void 0,previewContext:a},n);s.push(Tw(I,d,f,i,a))}),s}function Tw(e,t,r,n,o){let a=nt(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:xn(t,a),s=a==null?null:ho(t,a)?.profile,c=s?Bt(Ns(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 xw(e,t,r,n){let o=lr(e,t);if(o.length===0)return[];let a=[],i=zs(e,t),s=ss(e,t.id)??t.overrides;i.issues.length>0&&a.push(ww("asset.materialSlots.reimportConflicts",r.reimportConflicts,Aw(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Dw(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 Aw(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 Dw(e,t,r,n,o,a,i){let s=nl(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Tn),u=Dn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=nt(r),m=l[0],f=m==null?null:xn(r,m),S=r.sourceSurfaces[0],g=S.ownerNodePath;return{key:Xp(r),label:r.label||au(g,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:g,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof S.triangleCount=="number"?{triangleCount:S.triangleCount}:{},...r.sourceSurfaces.length===1&&S.boundingBox?{boundingBox:S.boundingBox}:{},bindingPath:ns(r)}}var Mw={createChildMaterialBindingInspectorPropertiesWithUsage:Pw,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:xw},AS=Mw;function au(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function ww(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var DS="materialAsset::",kw=5;function Ow(e){return e.startsWith(DS)&&e.slice(DS.length).trim()||null}function Rw(e,t,r,n,o,a){let i=[],s=Us(t),c=gr(s),d=t.overrides?.materialBinding,u=ss(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Tn,f=ee(e,m),S=l?.materialAssetId?l:{...l,materialAssetId:Tn};if(!Jp(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:TS(S,f,c),persistence:"document",collapsedByDefault:!1,properties:[Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let b=r==="primitive"?[]:AS.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return b.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:xS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:b}),i}function Cw(e,t,r,n){let o=Ow(t),a=o?ee(e,o):null;if(!a)return null;let i=gr("zh"),s=n.forMaterial(a.id),c=yS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=I=>I.path===d||I.path.startsWith(u),m=c.filter(I=>!l(I)),f=c.filter(l),S=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Bt(a.properties,r)},document:e},...m,Nw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],g=[io({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),io({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],b=[{id:"materialAssetSummary",title:"Material",order:10,regionId:$i,persistence:"readonly",collapsedByDefault:!1,properties:S}];b.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:g}),b.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:kw,items:s.map((I,P)=>({key:`${I.scope}:${I.gameObjectId}:${I.bindingPath}:${P}`,label:I.label,scope:I.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:I.scope,sourceObjectId:I.gameObjectId,sourceBindingPath:I.bindingPath,slotId:I.slotId,ownerNodePath:I.ownerNodePath,prefabAssetId:I.prefabAssetId,prefabNodeId:I.prefabNodeId}).filter(A=>typeof A[1]=="string"&&A[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[I,P]of[...y?.inspector.sections??[]].sort((A,$)=>A.order-$.order||A.id.localeCompare($.id)).entries())MS(b,{id:`material${P.id.charAt(0).toUpperCase()}${P.id.slice(1)}`,title:P.title,order:P.order,properties:[...I===0?f.filter(A=>A.path===d):[],...f.filter(A=>A.controlOptions?.materialShaderSectionId===P.id)]});let E=new Set(b.flatMap(I=>I.properties.map(P=>P.path)));return MS(b,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(I=>!E.has(I.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:b}}function vw(e,t,r,n={},o){return Rw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function Gw(e,t,r={}){return Cw(e,t,r,_e.getCachedUsageIndex(e))}var jw={createArtistMaterialInspectorSectionsWithCachedUsage:vw,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:Gw},iu=jw;function MS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function Nw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var wS="modelAsset::";function Fw(e){return e.startsWith(wS)&&e.slice(wS.length).trim()||null}function kS(e,t,r={}){let n=Fw(t),o=n?_w(e,n,r.modelAssets):null;if(!o)return null;let a=Bw(o),i=[$w(o)];return i.push(Lw(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 _w(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?Fr(n??{id:t,type:"glb"},o):n??null}function $w(e){let t=Vw(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:$i,persistence:"readonly",collapsedByDefault:!1,properties:[Oa(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Oa(`assets.${e.id}.id`,"Asset ID",e.id,1),Oa(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Oa(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function Lw(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:[Oa(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>zw(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 zw(e,t,r){let n=e.sourceSurfaces[0],o=nt(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:xn(e,a),s=a==null?null:ho(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Bt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function Bw(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(no).filter(r=>!!r)}function Oa(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Vw(e){return typeof e=="string"&&e.trim()?e.trim():""}function Ra(e,t,r,n={}){if(t.type==="prefab"){let s=OS(e,t),c=s?Fr(s,t):su(t),d=CS(e,t,c,r,n),u=Kw(s?e.assets.map(l=>l.id===c.id?c:l):[...e.assets,c],c);return{document:{...e,assets:u,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,d]}},gameObject:d}}let o=OS(e,t),a=o?Fr(o,t):su(t),i=t.type==="texture"?Uw(e,t,a.id,r,n):RS(e,t,a.id,r,n);return{document:{...e,assets:o?e.assets.map(s=>s.id===a.id?a:s):[...e.assets,a],scene:{...e.scene,gameObjects:[...e.scene.gameObjects,i]}},gameObject:i}}function Uw(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[Mt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function su(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Js(e.defaults),prefab:Js(e.prefab),external:Js(e.external),metadata:Js(e.metadata)}}function RS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[Mt(d),{type:"ModelRenderer",assetId:r}]}}function CS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return rg({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:Mt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function cu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function OS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function Kw(e,t){let r=ca(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function du(e,t,r,n){if(n.localTransform)return structuredClone(n.localTransform);let o=Wl(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??ur(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function lu(e,t,r){if(t===void 0)return xa(e,Rs(r));if(xa([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function uu(e,t){let r=t??ye(e);if(r){if(!e.scene.gameObjects.some(n=>n.id===r))throw new Error(`Requested asset instance parent does not exist: ${r}`);return r}}function Js(e){return e==null?void 0:structuredClone(e)}function Hw(e){return!!e&&tt(e)}function pu(e,t,r={}){let n=t.type==="document.replace"?t.document:GS({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function GS(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return va({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return Mn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return Ca(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return Ra(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return me(r.targetId)?t:hn(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(Hw(a.transform))return hn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return hn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...ot(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??Ww,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=Jw(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?mu(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(me))return t;let o=wt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??qw;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(me(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?mr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!vS(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=mr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),S=!vS(G(l),f);if(l.parentId===m.parentId&&!S)return l;let g={...l,parentId:m.parentId,components:S?l.components.map(b=>b.type==="Transform"?f:b):l.components};return s=!0,g}),d=mu(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!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=mr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:mu([...i,r.gameObject],r.order)}}}return t}function Ww(e){return Dt(e)}function qw(e){return At(e)}function Jw(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function mu(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function vS(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):fu(e.position,t.position)&&fu(e.rotation,t.rotation)&&fu(ot(e,"scale"),ot(t,"scale"))}function fu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var Xw="main_camera",Yw="environment_light",Zw="sun_light",Xs={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"},Na={type:"directional",intensity:2,direction:{...ps},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},wn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function NS(){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 FS(e){let t=yu({...e,kind:"transform",transformType:"camera",camera:Fa(e.camera)});return delete t.light,delete t.primitive,hu(t,e)?e:t}function Su(e,t){let r=yu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:kn(e.light,t)});return delete r.camera,delete r.primitive,hu(r,e)?e:r}function _S(e){let t=yu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,hu(t,e)?e:t}function yu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function Fa(e){let t=Xs;return{...t,...e??{},projection:Qw(e?.projection),fov:Ga(e?.fov,t.fov??.85),targetOffset:nk(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:Ga(e?.minZ,t.minZ??1),maxZ:Ga(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:ja(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:ja(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:Ga(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:Ga(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:tk(e?.inertia,t.inertia??.9),targetScreenOffset:rk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:ek(e?.inspectorLanguage)}}function $S(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=ja(e[r.valueField],Xs[r.valueField]),s=ja(e[r.lowerField],i),c=ja(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 Qw(e){return e==="perspective"?"perspective":"orthographic"}function ek(e){return e==="en"?"en":"zh"}function LS(e){return e==="en"?"en":"zh"}function ja(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Ga(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function tk(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function rk(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 nk(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 zS(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 ok(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function kn(e,t="directional"){return ok(e,t)==="hemispheric"?ik(e):ak(e)}function ak(e){let t=Na,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:LS(BS(r))}}function ik(e){let t=wn,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:LS(BS(r))}}function BS(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function hu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function VS(e,t,r){return{id:Eu(t,Xw,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:Fa(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 US(e,t,r){return{id:Eu(t,Zw,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(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 KS(e,t,r){return{id:Eu(t,Yw,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function Eu(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function WS(e,t){let r=t.name.trim();if(!r)return null;let n=_(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function qS(e,t){let r=ry(e,t);if(r===null)return null;let n=st(Qs(e),t.name,{fallbackName:"Empty"}),o=XS(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 JS(e,t){let r=yk(t.shape);if(!r)return null;let n=mk(e,t);if(n===null)return null;let o=st(Qs(e),t.name,{fallbackName:hk(r)}),a=XS(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Ek(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[Mt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function XS(e,t,r){return t===void 0?it(e,r):it([],t)===t&&!e.includes(t)?t:null}function YS(e,t){if(t.ids.some(me))return null;let r=wt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&At(a)))return null;let n=bk(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Pu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=_(e,t.draggedId),o=_(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?xt(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:Sk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!Zs(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 ZS(e,t,r={}){if(!Pu(e,t,r).ok)return null;let o=_(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?qt(o):Zs(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&cy(qt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function Tu(e,t,r={}){let n=fr(e),o=ep(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=Du(e,t);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=_(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!Zs(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function QS(e,t,r={}){if(!Tu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids),i=Du(e,t),s=a.map(l=>{let m=_(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?qt(m):Zs(e,l,i,t,r),S=f?Sn(f):null;return S?i?{targetId:l,parentId:i,transform:S}:{targetId:l,transform:S}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=fk(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||!cy(qt(m),l.transform)})&&Ik(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function xu(e,t,r={}){let n=fr(e),o=tp(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=ny(e,t.parentId??null);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=sy(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!ha(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||!oy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function ey(e,t,r={}){if(!xu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids);if(a.length===0)return null;let i=ny(e,t.parentId??null),s=sy(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=ha(e,i,c,r);if(!d)return null;let u=st(Qs(e),t.name,{fallbackName:"Parent"}),l=it(e.scene.gameObjects.map(g=>g.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[Mt(d)]},f={};for(let g of a){let b=_(e,g);if(!b)return null;if(t.preserveWorldTransform===!1){f[g]=qt(b);continue}let y=ke(e,g);if(!y)return null;let E=oy(c,y,r);if(!E)return null;f[g]=E}let S=pk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:S},createdId:l,changedIds:[l,...a]}}function ty(e){let t=e.isProtectedDuplicateSource??sk,r=fr(e.document),n=new Set(St(r,e.targetIds).filter(b=>{let y=_(e.document,b);return!!y&&!Z(y)&&!t(y,e.document)&&!dk(e.document,y.id,t)})),o=Au(e.document).filter(b=>n.has(b));if(o.length===0)return null;let a=wt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(b=>b.id)),c=new Map,d=Qs(e.document),u=lk(e.document,o,a,t);for(let b of u){let y=_(e.document,b),E=st(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(E);let I=it([...s],E);s.add(I),i.set(y.id,I),c.set(y.id,E)}let l=u.map(b=>_(e.document,b)).filter(b=>!!b&&i.has(b.id)).map(b=>{let y=structuredClone(b);return y.id=i.get(b.id),y.guid=he(),y.name=c.get(b.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(b=>b.id),f=o.map(b=>i.get(b)).filter(b=>!!b),S=ck(e.document,o,e.activeId),g=S&&i.has(S)?i.get(S):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:uk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:g,changedIds:m}}function sk(e){return Dt(e)}function ck(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(wt(e,[n]).has(r))return n}return t[t.length-1]??null}function 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 lk(e,t,r,n){let o=Au(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=_(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function uk(e,t,r){let n=Au(e),o=new Map;for(let i of t){let s=wt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Au(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=ye(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function ry(e,t){if(t.parentId){let n=_(e,t.parentId);return n&&xt(n)?n.id:null}let r=t.activeId?_(e,t.activeId):null;if(r&&xt(r))return r.id;if(r?.parentId){let n=_(e,r.parentId);if(n&&xt(n))return n.id}return ye(e)}function mk(e,t){return t.parentId===null?ye(e):ry(e,t)}function Du(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?_(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function ny(e,t){return t&&Mu(e,t)?t:ye(e)}function Mu(e,t){let r=_(e,t);return!!r&&xt(r)}function Zs(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=_(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return Sn(s);let c=ha(e,r,a,o.preserveWorldPolicy);return c?Sn(c):null}function oy(e,t,r={}){let n=Vi(r),o=to(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Sn(o):null}function fk(e,t,r){let n=ay(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=gk(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Du(e,r)});return iy(a,n,i)}function pk(e,t,r,n){let o=ay(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 iy(s,[t,...o],u)}function ay(e,t){let r=wt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function gk(e,t,r){return r.beforeId?HS(t.indexOf(r.beforeId),t.length):r.afterId?Ys(e,t,r.afterId):r.placement==="before"&&r.targetId?HS(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?Ys(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?Ys(e,t,r.parentId):t.length}function Ys(e,t,r){let n=wt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function iy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function HS(e,t){return e>=0?e:t}function sy(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Bi);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 bk(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 Sk(e,t,r){let n=Ol(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 yk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function hk(e){return e[0].toUpperCase()+e.slice(1)}function Ek(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Qs(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function cy(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):Iu(e.position,t.position)&&Iu(e.rotation,t.rotation)&&Iu(e.scale,t.scale)}function Iu(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Ik(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ku(e){return{getHierarchyItems(t){return wu(t,e)},normalizeHierarchyDocument(t){return vl(t)},createRenamePatch(t,r){return br(WS(t,r))},createCreateGroupPatch(t,r){return br(qS(t,r))},createCreatePrimitivePatch(t,r){return br(JS(t,r))},createDeleteSubtreePatch(t,r){let n=YS(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:br(n)},collectSubtreeIdList(t,r){return pr(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Pu(t,r)},createReparentPatch(t,r){return br(ZS(t,r))},validateHierarchyMove(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Pk(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Tu(t,r)},createHierarchyMovePatch(t,r){return br(QS(t,r))},validateGroupSelection(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=Tk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:xu(t,r)},createGroupSelectionPatch(t,r){return br(ey(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return br(ty({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return br(Hl(t))}}}function wu(e,t){let r=fr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Pk(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 Tk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&xt(n)?n.id:r.resolveRootContainerId(e)}function br(e){return e?{...e,patch:e.patch}:null}function Ou(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(S=>{if(S.id===t.systemDefaults.environmentLightId){a=!0;let g=t.systemDefaults.normalizeEnvironmentLightGameObject(S);return s=s||g!==S,g}if(S.id===t.systemDefaults.sunLightId){i=!0;let g=t.systemDefaults.normalizeSunLightGameObject(S);return s=s||g!==S,g}if(t.isCameraGameObject(S)){if(!o){o=!0;let g=t.systemDefaults.normalizeCameraGameObject(S);return s=s||g!==S,g}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(S)}if(t.isLightGameObject(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=!0,g}if(!t.isCustomTransformType?.(S.transformType)&&xk(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=s||g!==S,g}return S}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(S=>S.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function xk(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function Ru(e,t,r){let n=r.normalizeRootTransformDocument(Ak(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function ec(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})=>tc(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Cu(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=Eg(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 tc(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 Ak(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 Mk(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return pu(e,t,Dk(r))}function Dk(e){return{field:ec(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 Mk(e,t){return Kl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Io(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return wk(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?dy(i,"marker.target",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?dy(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 rc(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):kk(e,t,r,c,o)}let i=Mn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function ly(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)=>rc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return Ok(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>rc(c,d,r,n,o),e);let s=Ca(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function dy(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function wk(e,t,r,n,o){let a=qb({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 kk(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 Ok(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 my(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:bn(r.path,r.value)};return va({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return uy({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=bn(t.path,t.value),n=uy({...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 uy(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 Rk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Ck=/^transform\.(position|rotation|scale)$/,vk=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Mn(e,t,r,n,o={}){return Gk({document:e,targetId:t,path:r,value:n,options:o})}function Ca(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||vu(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=bu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function gu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if(vu(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=by(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 Gk(e){if(vu(e.targetId,e.path))return e.document;let t=_(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=bu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function bu(e,t,r,n={}){let o=by(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function by(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?fy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?py(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return dn(a)&&jk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=Fk(t,r);return Oe(a,t,c),_k(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=ue(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??Bk)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return $k(a,r,n),a;if(Lk(a,t,r)){let c=i?fy(a):null;return i&&c&&!gy(i,c)?lo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=Sy(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=zk(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=yy(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=Sa(a.light.direction,s??void 0));let c=s?py(a):null;return s&&c&&!gy(s,c)?gs(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Vl(a)),a}function fy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function py(e){return e.light?.type==="directional"?{...e.light.direction}:null}function gy(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(!Nk(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 Nk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function Fk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function _k(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function vu(e,t){return me(e)&&Rk.test(t)}function $k(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=Sy(e.camera,r):delete e.camera,a==="light"?e.light=yy(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function Lk(e,t,r){let n=t.match(Ck);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:qe(r)&&(a.scale={...r}),!0):(qe(r)&&(a[i]=i==="rotation"?{x:Ht(r.x),y:Ht(r.y),z:Ht(r.z)}:{...r}),!0)}let o=t.match(vk);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Ht(r):r;return i==="scale"?a.scale={...ot(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function Sy(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):hy(e)}function zk(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function yy(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):hy(e)}function Bk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function hy(e){return Vk(e)??{}}function Vk(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var Ty=["position","rotation","scale"],xy=["x","y","z"],Uk=1e-6;function Gu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Et():Ds(r)?r:null;if(!a)return t;for(let i of Ty)for(let s of xy)t.push(Wk({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=ue(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),wy(e.gameObject)&&t.push(...Kk({gameObject:e.gameObject,validateField:e.validateField})),t}function Ay(e){let t=[];for(let r of Ty)for(let n of xy){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?ot(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(Tt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>Uk),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:at(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function nc(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 _a(e){return e.length===0||e.some(r=>!wy(r))?[]:[Iy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Iy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Kk(e){return[Ey({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Ey({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Ey(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>Dy(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=bn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:Mn(t,n.targetId,e.path,o)}}}function Iy(e,t){let n=e.map(a=>Dy(a,t.path,t.defaultValue))[0]??t.defaultValue,o=Hk(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 Hk(e,t){let r=e.map(n=>My(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function Dy(e,t,r){let n=My(e);return t==="shadow.cast"?Py(n.cast):t==="shadow.receive"?Py(n.receive):r}function Py(e){return e==="enabled"}function My(e){return He(e.shadow).shadow??{}}function wy(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 Wk(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=ot(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?at(Tt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>qk({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function qk(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=_(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Ht(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...ot(n,"scale"),[e.axis]:i}:ot(n,"scale");return Jk(e.document,e.targetId,{position:s,rotation:c,scale:d})}function Jk(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Rl(n,r):n)}}}function ky(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:[...nc(r),...Ay(r),..._a(r)]}}var Nu="enabled",Oy="shadow.",Ry=200;function _u(e){let t=Xk(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??Ry,a=Yk(t),i=_a(a),s=t.length>o,c=s?Zk({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):ky({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>vy(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Cy({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 Cy(e){let t=Qk(e.document,e.serialized,e.serialized.properties.filter(n=>vy(n.path)),e.renderingProfile),r=ju("common","Common",10,e.serialized.properties.filter(n=>n.path===Nu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,ju("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,ju("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Nu&&!n.path.startsWith(Oy)),e.document)].filter(n=>!!n)}function Xk(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 Yk(e){return e.filter(t=>bo({gameObject:t,nodeKind:Y(t)}))}function Zk(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:_a(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...nc(e.gameObjects),...t]}}function Qk(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(b=>[b.id,b])),a=t.targetIds.map(b=>o.get(b)).filter(b=>!!b).filter(b=>bo({gameObject:b,nodeKind:Y(b)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&bo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(b=>b.path==="shadow.cast"),u=r.find(b=>b.path==="shadow.receive");if(!d||!u)return null;let l=Fu(d,0),m=Fu(u,1),f=gn({path:d.path,nodeKind:c,document:e}),S=gn({path:u.path,nodeKind:c,document:e}),g=n!==void 0&&Is(ks(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...g?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:S},...g?[Fl()]:[]]}}function vy(e){return e.startsWith(Oy)}function ju(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=Fu(a,i),c=eO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?gn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Fu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":tO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:rO(e.valueType),order:t,source:e}}function eO(e,t){if(t.startsWith("transform."))return"transform";if(t===Nu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function tO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function rO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var nO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function va(e){if(me(e.patch.targetId)&&nO.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")?Gy(t):null,n=e.patch.path.startsWith("light.direction")?jy(t):null,o=Dp(e.document,Gu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=_(o,e.patch.targetId);if(!a)return o;let i=r?Gy(a):null,s=n?jy(a):null,c=r&&i&&!Ny(r,i),d=n&&s&&!Ny(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?lo(u):u;return d?gs(l):l})}}}function Gy(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function jy(e){return e.light?.type==="directional"?e.light.direction:null}function Ny(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lu(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function zu(e){let t=_u({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function Bu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return $u(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),$a(t,a&&r?e.createCameraSection?.():null),$u(t,a&&n?e.createLightSections?.():null),$a(t,a&&o?e.createMarkerSection?.():null),$a(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&($u(t,e.createMaterialSections?.()),$a(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function $a(e,t){t&&e.push(t)}function $u(e,t){if(t)for(let r of t)$a(e,r)}function Vu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?Fy: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:aO(oO(e),r,n)}}var Fy="Outline fields are showing defaults; configure an outline override before edits affect this object.";function oO(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 aO(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 iO={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"},sO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},cO={box:"\u76D2\u4F53",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Wu(e){let t={...iO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=dO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=pO(r),i=a?.kind==="scene-object"?a.id:"",s=lO(e.document,e.gameObject.id,i,e.isMarkerGameObject,t),c=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,options:o.length>0?o:void 0,commitMode:"change",order:0}),Ku("marker.kind",t.kindLabel,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(", ")??"",commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",commitMode:"blur",placeholder:t.notePlaceholder,order:4}),Ku("marker.geometry.kind",t.geometryLabel,fO(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:i,options:s,commitMode:"change",order:6}),Ku("marker.target.status",t.targetStatusLabel,gO(e.document,a,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:uO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:c}}function dO(e,t,r,n){let o=[{label:r.emptyTypeOption,value:""},...e.map(a=>({label:Hu(a.type,a.label||a.type,n),value:a.type}))];return t&&!o.some(a=>a.value===t)&&o.push({label:Hu(t,t,n),value:t}),o}function lO(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 uO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Hu(t,o?.label||t,n)}function Hu(e,t,r){return r?.(e,t)??t}function mO(e,t){return t?.(e)??sO[e]??e}function fO(e,t){return t?.(e)??cO[e]??e}function pO(e){return e.target?Uu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Uu(e.geometry.target):null}function gO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Uu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Ku(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var La={r:1,g:1,b:1,a:1};function bO(e){return{...e}}function zy(e){let t=bO(e);return{services:t,normalizeLayoutPatchValue:r=>dc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>Wy(r,n,t),canPatchMultiField:(r,n,o,a)=>IO(r,n,o,a,t),patchLayout:(r,n,o)=>PO(r,n,o,t),patchKind:(r,n,o)=>TO(r,n,o,t),patchInspectorField:(r,n,o,a)=>xO(r,n,o,a,t),normalizeGameObject:r=>On(r,t),replaceUi:(r,n,o)=>DO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>oc(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>MO(r,n,t),normalizeScales:(r,n,o)=>cc(r,t,n,o),mergeDefaults:r=>dt(r,t.createDefaultGroundDecal,t)}}function By(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 SO=75;function qu(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:Jy({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 dc(e,t={}){let r=Ha(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>yO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function yO(e,t,r={}){let n=Ha(e);if(!n)return null;let o=ZO(n.id)??`layer_${t}`,a=To(n.rect),i=n.fontSize==null?null:ac(n.fontSize),s=n.rotationDeg==null?null:Ao(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:_r(i)}}}function To(e){let t=Ha(e);if(!t)return null;let r=Xt(t.x),n=Xt(t.z),o=ac(t.width),a=ac(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Xt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ac(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Vy(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(lc(e))return To(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Uy(e)){let r=Ao(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(uc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(pc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Ky(e)){let r=Xu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(mc(e)||Sc(e)||gc(e)){let r=za(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(fc(e)||yc(e)||bc(e)){let r=Ba(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(hc(e)){let r=Ju(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if($r(e)){let r=Ka(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Va(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 lc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function Uy(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function uc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function mc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function fc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function pc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function Ky(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function gc(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function $r(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ec(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Va(e)||$r(e)}function Ua(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ec(e)}function hO(e,t,r={}){return t==="rect"?xo(e,r):t==="rotationDeg"?Pc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?ic(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?Hy(e,r):t==="color"||t==="color.a"?sc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?ic(e,r):e.kind==="progress"&&sc(e,r):!1}function Ic(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function xo(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Pc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function ic(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function sc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function Hy(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function Wy(e,t,r={}){let n=e.layers.filter(o=>xo(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Pc(o,r))})}function za(e){let t=Ha(e);if(!t)return null;let r=Xt(t.r),n=Xt(t.g),o=Xt(t.b);if(r==null||n==null||o==null)return null;let a=Xt(t.a);return{r:_r(Math.max(0,Math.min(1,r))),g:_r(Math.max(0,Math.min(1,n))),b:_r(Math.max(0,Math.min(1,o))),...a==null?{}:{a:_r(Math.max(0,Math.min(1,a)))}}}function Ba(e){let t=Xt(e);return t==null?null:_r(Math.max(0,Math.min(1,t)))}function Ju(e){let t=Xt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Ao(e){let t=Xt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=_r(r);return Object.is(n,-0)?0:n}function Xu(e){let t=ac(e);return t==null?null:_r(t)}function Ka(e){let t=Xt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function _r(e){return Math.round(e*1e3)/1e3}function Tc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?dc(t)??t:lc(e)?To(t)??t:Uy(e)?Ao(t)??t:uc(e)&&typeof t=="string"?t.trim():pc(e)&&typeof t=="string"?t:Ky(e)?Xu(t)??t:mc(e)||Sc(e)||gc(e)?za(t)??t:fc(e)||yc(e)||bc(e)?Ba(t)??t:hc(e)?Ju(t)??t:$r(e)?Ka(t)??t:t}function qy(e,t,r){if(t==="rect"){let n=To(r);return n?EO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Ao(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=Xu(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Po(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ba(r);if(n===null)return null;let o={...e.color,a:n};return Po(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=Ju(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Po(e.tint??La,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ba(r);if(n===null)return null;let o={...La,...e.tint??{},a:n};return Po(e.tint??La,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ba(r);if(n===null)return null;let o={...e.text.color,a:n};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function dt(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function Po(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function EO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function Jy(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 IO(e,t,r,n,o){if(!Ua(r))return!1;let a=vO(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=dt(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||$r(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=dc(n,o);return d?Wy(i,d,o):!1}let s=Va(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Ic(c,o)&&hO(c,s.field,o)}function PO(e,t,r,n){let o=dc(r,n);return o?Yy(e,a=>a.id===t?wO(a,o,n):a):e}function TO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:Yy(e,a=>a.id===t?kO(a,o,n):a)}function xO(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=dt(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,On({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if($r(r))return AO(e,t,r,n,o);let a=Va(r);if(!a)return null;let i=!1,s=Tc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Ic(l,o)||a.field==="rect"&&!xo(l,o))return d;let m=qy(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,On({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function AO(e,t,r,n,o){let a=Ka(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,On({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function DO(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,On({...i,kind:"transform",transformType:"groundDecal",groundDecal:dt(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function oc(e,t,r,n,o){return r.startsWith("transform.scale")?cc(e,o,t,qu(r,n)):e}function MO(e,t,r){if(t.type==="document.replace")return cc(e,r);let n=t.patch;return n.kind==="game-object.field"?oc(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=Ha(a);return oc(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)=>oc(o,String(a),String(n.path??""),n.value,r),e):e:cc(e,r)}function cc(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||!CO(s)||!s.scale)return i;let c=n??Jy(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 On(e,t){let r=OO({...e,kind:"transform",transformType:"groundDecal",groundDecal:dt(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function Xy(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function wO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=dt(e.groundDecal,r.createDefaultGroundDecal,r);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!xo(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Pc(a,r)&&(d=qy(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function kO(e,t,r){let n=dt(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function OO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[RO(),...e.components]}}function RO(){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 CO(e){return e.type==="Transform"&&e.mode!=="matrix"}function vO(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function Yy(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function Zy(e,t,r={},n){let o=dt(t,n.createDefaultGroundDecal,n),a=[YO("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:nh(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:JO(o),aspectRatioUsesDecalSize:qO(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(Ly({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(Ly({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||!Ic(c,n))continue;let d=oh(c,n);if(ic(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=VO(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(HO(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&sc(c,n)||c.kind==="textureProgress"&&ic(c,n))&&(a.push(KO(e,c,s,d,i,n)),i+=1),sc(c,n)&&(a.push(UO(e,c,s,d,i,n)),i+=1),Hy(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(WO(e,c,s,d,i,n)),i+=1)}return XO(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function Qy(e,t,r,n){let o=n.getTargetGroundDecal(e),a=dt(o,n.createDefaultGroundDecal,n),i=Zy(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:[GO(a,[s,...c],n),...c]}}function GO(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 eh(e,t,r,n,o){let a=rh(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=NO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=Zy(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>_O(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:$O(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 th(e,t,r){return rh(e,t,r).map(n=>r.getTargetId(n.target))}function rh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:dt(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function NO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>FO(o,t));return n.every(o=>o===r)}function FO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Ic(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function _O(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"||$r(e.path)?!0:e.path==="groundDecal.layers"||Va(e.path)?t:!1}function $O(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(LO(i.decal,t,r,n)));return a.some(i=>i!==o)}function LO(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 nh(e,r,n).layers;let o=Va(t);if(!o)return;let a=e.layers[o.index];if(a)return zO(a,o.field)}function zO(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??La:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?Yu(e):void 0}function nh(e,t,r){let n=Ni(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>xo(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>_y(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=_y(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 _y(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:oh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Pc(t,n),enabled:t.enabled!==!1,editable:xo(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:BO(e,t,n)}}function oh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function BO(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:$y(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:$y(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function Yu(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:SO;return Math.round(Math.max(0,Math.min(100,t)))}function $y(e){return Yu(e)/100}function VO(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 UO(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 KO(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:Yu(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function HO(e,t,r,n,o,a){let i=t.tint??La;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 WO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function qO(e){return e.size.width>0&&e.size.depth>0}function JO(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function XO(e,t){let r=j(t);r&&e.push(r)}function YO(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Ly(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 Ha(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ZO(e){return typeof e=="string"&&e.trim()?e.trim():null}var Rn="groundDecal";function QO(e){if(e.id!==Rn||e.scene?.kind!==Rn||!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 ah(e,t){let r=QO(e);if(!r)return null;let n=r.documentPolicy,o=eR(n),a=s=>s?.transformType===Rn&&o.isGroundDecalConfig(s.groundDecal);return tR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>By({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:Tc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>ou(d,u??""),getMaterialText:gr,createTexturePickerControlOptions:(d,u,l,m)=>Ws(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 eR(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 tR(e){let r=(e.features.find(i=>i.id===Rn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=zy({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=rR({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===Rn&&i.scene?.kind===Rn?a:null}}}function rR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Rn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?Tc(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 Vy(n,o)},isInspectorPatchPath:Ec,isProjectionPath:Xy,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),oR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=qu(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ec(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)=>nR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[Qy(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>eh(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>th(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ua,isSerializedMultiProjectionPath:Ua,getSerializedMultiProbeValue:aR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ua(a)||t.canPatchMultiField(n,o,a,i)}}function nR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=it(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:ye(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function oR(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 aR(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(uc(e))return"texture_probe";if(pc(e))return"30";if(mc(e)||Sc(e)||gc(e))return{r:1,g:1,b:1,a:1};if(fc(e)||yc(e)||bc(e))return 1;if(hc(e))return 75;if(lc(e))return To({x:0,z:0,width:1,depth:1});if($r(e))return Ka(512)}function Wa(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function xc(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: ${iR(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 iR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var Zu=64*1024,sR=8,ih=256,cR=8*1024,dR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function sh(e){if(!qa(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}`);fR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:uR(t.assetPath),n=Do(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=Do(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=mR(t[a],a));if(t.metadata!==void 0&&!qa(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!qa(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:lR(t.external.assetPath,"external.assetPath");t.external={...Do(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Do(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Do(t.external.assetUrl,"external.assetUrl")?{assetUrl:Do(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function lR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=Wa(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 uR(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 Wa(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Do(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function mR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(qa(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 fR(e){let t=0,r=(n,o)=>{if(o>sR)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>cR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>ih)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!qa(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>ih)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>Zu)throw new Error("asset_import_payload_too_large")}function qa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ja(){return{isCoreMaterialOverridePath:dl,isMaterialAssetIdOverridePath:og,addMaterialAsset:$s}}function ch(e,t=[]){return e.assets.filter(Xe).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=pR(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 pR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function Qu(e,t,r=Ja()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(tm(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function em(e,t,r=Ja()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(tm(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return mo({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function tm(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function dh(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Ac(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function rm(e,t,r,n,o=Ja()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Xe(s));if(!a)return e;let i=gR(uh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function lh(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Xe(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Ac({...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 gR(e,t,r,n=Ja()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||tm(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Ac(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,Ac(o)}return la(e,t,r)}function uh(e){if(!Xe(e))return e;let t=tg(e);return t.ok?t.prefabAsset:e}function Ac(e){if(!Xe(e))return e;let t=uh(e),r=Ye(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function mh(e,t,r,n,o=Ja()){let a=o.addMaterialAsset(e,n);return rm(a,t,r,n.id,o)}function ph(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=bR(i,a),c=Dc(i),d=SR(c,!!n.importStructureReady),u=bh(n.importStructure)?Sh(n.importStructure):[];return Mc([s,...d?[d]:[],...u],r)}function bR(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 SR(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 Dc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(hR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=hh(o.ownerNodePath),i=nt(r),s=i.map(m=>xn(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${om(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function gh(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 hR(e){return no(e)}function bh(e){return["nodes","materials","textures","animations"].some(t=>Xa(e,t).length>0)}function Sh(e){let t=[],r=Xa(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:ER(r)});let n=Xa(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>nm(i,s,"material"))});let o=Xa(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>nm(i,s,"texture"))});let a=Xa(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>nm(i,s,"animation"))}),t}function ER(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${om(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function nm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${om(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function yh(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=Dc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return(bh(n.importStructure)?Sh(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function Mc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?Mc(r.children,t):null;if(n)return n}return null}function hh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function om(e,t){return hh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Xa(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 Eh(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ye(n),a=sl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>Ih(n,s))}]}function Ih(e,t){let r=sl(e,t.id).map(n=>Ih(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??IR(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 IR(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 Ph(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(S=>S.id===n),a=Dc(o),i=kc(o?.metadata?.assetAnalysis),s=am(i?.nodes),c=am(i?.meshes),d=wc(r.importStructure,"nodes").length,u=wc(r.importStructure,"materials").length,l=wc(r.importStructure,"textures").length,m=wc(r.importStructure,"animations").length,f=[kt("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),kt("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(kt("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(kt("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),kt("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?PR(s):"No SDK node analysis",11),kt("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?TR(c):"No SDK mesh primitive analysis",12),kt("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),kt("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),kt("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),kt("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(kt("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",gh(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 PR(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.ownerNodePath)??Oc(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 TR(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=am(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Oc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
- `)}function wc(e,t){let n=kc(e)?.[t];return Array.isArray(n)?n.map(kc).filter(o=>!!o):[]}function kc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function am(e){return Array.isArray(e)?e.map(kc).filter(t=>!!t):[]}function Oc(e){return typeof e=="string"&&e.trim()?e.trim():null}function kt(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Th(e,t,r){let n=e.prefab?.defaults?.shadow;return[Ya({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),Ya({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 Ya(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 xR(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?AR(e,t,r,n,o,a()):r.itemType==="runtime-material"?xh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?xh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function AR(e,t,r,n,o,a){let i=gr("en"),s=ag(t,r),c=r.prefabNodeId?oo(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Tn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Editable",0),Mo("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),Mo("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Dn.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 DR(e,t,r,n,o){return xR(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var MR={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:DR},Ah=MR;function xh(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Read Only",0),Mo("prefab.materialOverride.reason","Reason",e,1),Mo("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function Mo(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function wR(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(b=>b.id===t.sourceAssetId)??null:null,c=r?Mc(Eh(e,t,n),r)??ph(e,t,r,n):null,d=c?yh(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Ph(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?oo(i,m):null,S=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?RR(i,f):null,g=f?.kind==="marker"&&f.marker?jR(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:[Ya({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}),Ya({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...Th(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(b=>!!b)},...S?[S]:[],...g?[g]:[],...l?[l]:[],...u?[u]:[]]}}function kR(e,t,r,n={},o){return wR(e,t,r,n,o,Ah.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var OR={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:kR},Mh=OR;function RR(e,t){let r=CR(t),n=t.parentId?oo(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${vR(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?GR(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 CR(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 vR(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function GR(e){return Math.round(e*180/Math.PI*1e6)/1e6}function jR(e,t,r){let n=t.marker,o=n.target??null,a=o?Dh(o):"",i=[{label:"Unbound",value:""},...Ze(e).filter(c=>c.id!==t.id).map(c=>{let d=c.kind==="marker"?"marker":"scene-object";return{label:c.name??c.id,value:Dh({kind:d,id:c.id})}})];o&&a&&!i.some(c=>c.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(c=>({label:c.label||c.type,value:c.type}));return s.some(c=>c.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type}),{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(c=>c.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[Za({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:c=>typeof c=="string"&&r.markerTypeCatalog.some(d=>d.type===c)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),Za({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:c=>typeof c=="string"&&i.some(d=>d.value===c)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(c=>c.value===a&&!c.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),Za({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:c=>typeof c=="string"}),Za({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:c=>typeof c=="string"}),Za({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:NR})].filter(c=>!!c)}}function Za(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 Dh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function NR(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 wh(e,t){let r=ln(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
- `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(im({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function im(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function kh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function cm(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function Cn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return $R(r)?fe(r):Ie(1,1,1)}return Ie(1,1,1)}function Lr(e,t){let r=ke(e,t);return r&&It(r)?r:null}function dm(e,t,r){let n=ur(e,t??void 0,r);return n&&It(n)?n:null}function Ch(e,t){let r=ke(e,t.id);return r?Gh(r,t.name??t.id):null}function vh(e,t){let r=mm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:Gh(o,r.label||n.name||r.id)}function Gh(e,t){let r=Fe(e),n=Rc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Rc(FR(o,sm(n,Oh(o,n))));if(!a)return null;let i=Rc(Rh(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);Oh(i,s)<0&&(i=sm(i,-1));let c=Rc(Rh(i,n));return c?{origin:Bi(e),right:n,up:c,forward:i,label:t}:null}function Oh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Rh(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 FR(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 Rc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?sm(e,1/t):null}function Sr(e,t,r,n={}){let o=t.trim(),a=o?eo(zR(e),n).find(i=>i.type===o)?.kind:void 0;return Cc(a??r??(o?void 0:"point"))}function Cc(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function jh(e,t){return lm(t)?"box":um(t)&&mm(e)?"object-bounds":"point"}function vc(e,t,r,n,o={}){let a=Lr(e,t.id),i=fe(a?.position??Ie(0,0,0)),s=fe(a?.rotation??Ie(0,0,0)),c=_R(e,t,r,o)?wo(r):fe(a?.scale??Cn(t));if(lm(r))return{kind:"box",coordinateSpace:"world",center:i,size:Nc(c),rotation:s};let d=mm(t.marker);return um(r)&&d?{kind:"object-bounds",target:d}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:i,...d?{target:d}:{}}}function Nh(e,t,r,n,o){if(o)return um(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Lr(e,t.id);return{kind:"point",coordinateSpace:"world",position:fe(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function Fh(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 _R(e,t,r,n={}){let o=Sr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Lr(e,t.id)?.scale??Cn(t);return $h(a,wo(o))}function _h(e,t,r,n={}){if(!de(t))return!1;let o=Sr(e,t.marker.type,t.marker.kind,n),a=Cc(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Lr(e,t.id)?.scale??Cn(t);return $h(i,wo(o))}function wo(e){return lm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function lm(e){return Cc(e)==="region"}function um(e){return Cc(e)==="object"}function mm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function $h(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 Lh(e){switch(e.kind){case"box":return{kind:"box"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:fe(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(fe),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function Gc(e){switch(e.kind){case"box":return fe(e.center);case"point":return e.coordinateSpace==="world"?fe(e.position):Ie(0,0,0);case"polyhedron":return LR(e.vertices);case"object-bounds":return Ie(0,0,0)}}function jc(e){return e.kind==="box"&&e.rotation?fe(e.rotation):Ie(0,0,0)}function fm(e,t){return e.kind==="box"?Nc(e.size):fe(t)}function Nc(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 Fc(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function fe(e){return{x:e.x,y:e.y,z:e.z}}function $R(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 zh(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function LR(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 zR(e){return e.scene.markerGraph??null}function _c(e,t={}){let r=qR(e,t);if(r!==e)return _c(r,t);let n=BR(e);if(n!==e)return _c(n,t);let o=$c(e);if(!o)return e;let a=cr(o),i=VR(e,a);return ra(o,i)?e:zd(e,i)}function BR(e){let t=$c(e),r=t?cr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?QR(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>Vh(e,hp(c.marker,o),c.gameObjectId,null)),s=cr({...r,markers:[],relations:r.relations.map(c=>yp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function VR(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>UR(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>Ld(i.from,r,o)&&Ld(i.to,r,o));return{...t,markers:n,relations:a}}function UR(e,t){if(!ta(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ta(e.geometry.target,t);case"point":return ta(e.geometry.target,t);case"box":case"polyhedron":return!0}}function Bh(e,t,r={}){switch(t.type){case"marker.create-box":return KR(e,t.marker,t.parentId??null);case"marker.update":return HR(e,t.markerId,t.patch,r);case"marker.delete":return WR(e,t.markerId);default:return null}}function KR(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=cr($c(e)),o=Vh(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return zd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function HR(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=zr(e,o,n),i=sr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=cr(void 0);if(ra({...s,markers:[a]},{...s,markers:[i]}))return e;let c=Uh(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function WR(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=Ep(e,t),o=cr($c(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!$d(a.from,n)&&!$d(a.to,n))}}}}function qR(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=JR(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function JR(e,t,r={}){return YR(e,t,r)}function Vh(e,t,r,n){let o=wo(t.kind),a={position:Gc(t.geometry),rotation:jc(t.geometry),scale:fm(t.geometry,o)},i=n?dm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:Hh(t),components:[{type:"Transform",...i}]}}function Uh(e,t,r,n={}){let o=Lr(e,t.id)?.scale??Cn(t),a=_h(e,t,r,n)?wo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:Hh(r),components:XR(e,t,t.components,r.geometry,a)}}function XR(e,t,r,n,o){let a=o??Cn(t),i=Lr(e,t.id),s={position:cm(n)?fe(i?.position??Gc(n)):Gc(n),rotation:cm(n)?fe(i?.rotation??jc(n)):jc(n),scale:fm(n,a)},c=dm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function YR(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=Sr(e,t.marker.type,t.marker.kind,r),o=jh(t.marker,n);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===o)return t;let a=zr(e,t,r),i=sr({...a,kind:n,markerType:t.marker.type.trim(),geometry:vc(e,t,n,a.geometry,r)});return Uh(e,t,i,r)}function Kh(e,t={}){return e.scene.gameObjects.filter(de).map(r=>zr(e,r,t))}function zr(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?vh(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):Ch(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Sr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:ZR(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 ZR(e,t){let r=t.marker,n=Lr(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??Cn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:fe(o),size:Nc(i),rotation:fe(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?zh(o,r.geometry.offset):fe(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?fe(r.geometry.position):fe(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(fe),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function Hh(e){let t=e.metadata?structuredClone(e.metadata):{},r=eC(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:Lh(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function QR(e,t){let r=Fc(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function eC(e){if(!e||typeof e!="object")return null;let t=e,r=pm(t.r),n=pm(t.g),o=pm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function pm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function $c(e){return e.scene.markerGraph??null}function qh(e){let t=n=>e.getMarkerTypeCatalogFromGraph(Wh(n)),r=n=>{let o=cr(Wh(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of Kh(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Pp(n,o,{sanitizeMarkerGameObjectId:Fc});return Tp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(Bd(a)),label:xp(a),...Ap(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:Bd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?t(n).find(m=>m.type===s)??null:null;if(s&&!c)return null;let d=Sr(n,s,i.marker.kind,e.options),u=zr(n,i,e.options),l=vc(n,i,d,u.geometry,e.options);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?Fh(n,s):null;if(s&&!c)return null;let d=zr(n,i,e.options),u=Sr(n,i.marker.type,i.marker.kind,e.options),l=Nh(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Sr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=Bh(n,o,e.options);if(a)return a;let i=r(n),s=Ip(i,o,e.options);return ra(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return _c(n,e.options)}}}function Wh(e){return e?.scene.markerGraph}function Jh(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?Yh(e,n,r,r.id,t):[]})}function Xh(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[Lc()]};return Yh(e,o,a,r,n)}function Yh(e,t,r,n,o){let a=[],i=[];Zh(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??Lc(),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:zr(c,u,{builtInMarkerTypes:o})}]:[]})}function Zh(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Ze(t),o=Ye(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>ao(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(g=>g.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let g=Le(e,d.childPrefabId);g&&Zh(e,g,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??Lc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let S=d.kind==="marker"&&d.marker?ma({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...S?{marker:S}:{},components:[l?r.rootTransform:d.transform??Lc()]}),S&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function Lc(){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 tC(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 Qh(e){let t=my(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),...tC(n.materialShaderDefinitions),...ch(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=Ra(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function rC(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=nE(r.contribution);return n?gm(n):t?ah(e,t):null}function tE(e){let t=(e.features??[]).flatMap(p=>{let D=e.resolveFeatureSceneContribution?.(p);if(D)return[gm(D)];let h=rC(p,()=>d);if(h)return[h];let R=nE(p.scene);return R?[gm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=kC(t),o=qh({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>xC(e.markerTypes,p)}),a=(p,D)=>D?_(p,D):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>TC(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Il({hasMaterialAsset:Vt,isMarkerGameObject:de,isDirectionalLightAnglePath:uo})],s=(p,D)=>n?.normalizeInspectorValue?.(p,D)??ys(p,D,{isDirectionalLightAnglePath:uo}),c=(p,D,h,R)=>{if(uo(h)&&D.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:D,path:h,value:R});return K||mo({document:p,path:h,nodeKind:Qa(D),value:R,extraValidators:i()})},d=(p,D,h)=>ya({document:p,nodeKind:D,property:h,extraValidators:i()}),l={systemDefaults:SC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:kh,findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isProtectedSystemGameObject:Dt,hasCamera:(p,D)=>p.scene.gameObjects.some(h=>h.id!==D&&At(h)),...n?.fieldMutation},m=hC(e,o,l,a,s,c,n),f=(p,D,h,R)=>rc(p,D,h,R,m),S=(p,D,h,R)=>ly(p,D,h,R,m),g=(p,D)=>gu(p,D,m.fieldMutationOptions),b=(p,D,h)=>hn(p,D,{transform:h}),y=(p,D)=>Ul(p,D),E=yC(e,o,l,f,S,n),I=EC(o),P={isRootTransformPath:Ms,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isSerializedMultiFieldPath:p=>DC(p,n),isSerializedMultiProjectionPath:p=>MC(p,n),getSerializedMultiPropertyProbeValue:p=>wC(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Io(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},A=Qh({hierarchyFacade:I,objectCommandServices:P,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:D,worldTransform:h})=>ur(p,D??void 0,h)}}),$={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(D=>D.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(D=>D.type==="ImageRenderer"),readNodeKind:Qa},z={};return Object.assign(z,{historyDocumentStorage:r,defaults:{camera:Xs,sunLight:Na,environmentLight:wn},reduceDocument:(p,D)=>Ru(p,D,E),ensureEnvironmentDefaults:p=>Ou(p,E),isSelectableHierarchyId:(p,D)=>Cl(p,D),resolveDiagnosticLocator:(p,D)=>{let h=D.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=lr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:Mp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:A.getHierarchyItems,normalizeHierarchyDocument:A.normalizeHierarchyDocument,createRenamePatch:A.createRenamePatch,createCreateGroupPatch:A.createCreateGroupPatch,createCreatePrimitivePatch:A.createCreatePrimitivePatch,createDeleteSubtreePatch:A.createDeleteSubtreePatch,createReparentPatch:A.createReparentPatch,createHierarchyMovePatch:A.createHierarchyMovePatch,createGroupSelectionPatch:A.createGroupSelectionPatch,createDuplicateSelectionPatch:A.createDuplicateSelectionPatch,createPlacedAssetPatch:A.createPlacedAssetPatch,validateReparent:A.validateReparent,validateHierarchyMove:A.validateHierarchyMove,validateGroupSelection:A.validateGroupSelection,collectSubtreeIds:pr,createFeatureHierarchyPatch:(p,D)=>n?.createHierarchyPatch?.(p,D)??null,createInspectorPropertyPatch:p=>aC(m,p),createSceneMaterialBindingPatch:p=>oC(e,m,p),createPrefabMaterialBindingPatch:p=>iC(e,p),createMaterialPropertiesPatch:p=>bC(e,m,p),createMaterialAssetCreatePatch:p=>dC(e,p),createMaterialAssetRestorePatch:p=>lC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>uC(e,p),createMaterialAssetDuplicatePatch:p=>mC(e,p),createMaterialAssetDeletePatch:p=>fC(e,p),createMaterialAssetRenamePatch:p=>pC(e,p),createMaterialAssetSetShaderPatch:p=>gC(e,p),patchGameObjectField:f,patchGameObjectsField:S,patchGameObjectPropertiesMany:g,patchGameObjectTransform:b,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>nC(e,m,p),canCreateSerializedMultiPropertyPatch:A.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:A.createSerializedMultiPropertyPatch,createBrowserAssetItems:A.createBrowserAssetItems,addAssetLibraryItemToDocument:A.addAssetLibraryItemToDocument,getInspectorObject:(p,D,h={})=>IC(z,e,o,p,D,eE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,D,h,R={})=>PC(p,D,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,D,h,R={})=>Mh.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,D,h,eE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:NS,mergeLightDefaults:kn,sunLightId:"sun_light",normalizePrefabAssetFieldValue:Qu,validatePrefabAssetFieldValue:em,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>$l({...p,sourceRef:Wt(p.document)},$),createRuntimeInspectorSnapshot:p=>fa({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>Jh(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,D,h)=>Xh(p,D,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Bs}),z}function nC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=Io({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function oC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=Io({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=rE(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 aC(e,t){let r=Io(t,e);if(!r||!wr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:rE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function iC(e,t){if(t.targets.length===0||t.materialAssetId&&!Vt(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=Qu(d,t.materialAssetId);if(!em(d,u))return null;if(!s.nodeId){a=la(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(b=>b.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},S=la(f,d,u),g={...m,...S.prefab?.overrides?{overrides:structuredClone(S.prefab.overrides)}:{}};S.prefab?.overrides||delete g.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=g}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:sC(t.document,t.targets,t.materialAssetId)}}function rE(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 an(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function sC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=cC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function cC(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[Lt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function dC(e,t){let r=Kb(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 lC(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 uC(e,t){let r=Jb({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 mC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=Hb(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 fC(e,t){let r=Yb(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 pC(e,t){let r=ee(t.document,t.materialAssetId),n=rt("name",t.name);return!r||tu(r)||typeof n!="string"||!zt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:sa(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function gC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||tu(r))return null;let n=oS(r,t.definition),o=sa(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function bC(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(!ro(n.shaderId,c.path))return null;a=_s(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=Io({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=_s(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=sa(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function SC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>Su(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Su(n,"directional"))(r),normalizeCameraGameObject:t(FS),normalizePlainTransformGameObject:t(_S),createDefaultCameraGameObject:VS,createDefaultEnvironmentLightGameObject:KS,createDefaultSunLightGameObject:US,mergeCameraDefaults:Fa,normalizeCameraAfterFieldPatch:$S,hasInvalidCameraRelationships:zS,mergeLightDefaults:kn}}function yC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Ea,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:kl,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>_s(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>Wb(i,s,c),addMaterialAsset:(i,s)=>$s(i,s),deleteMaterialAsset:(i,s)=>Zb(i,s),addMaterialAssetAndBind:(i,s,c,d)=>Qb(i,s,c,d),addPrefabAsset:(i,s,c)=>dh(i,s,c),patchPrefabAssetField:(i,s,c,d)=>rm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>lh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>mh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:uo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:it,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>ur(i,s??void 0,c),resolveRootContainerId:ye,ensureDefaultMaterialAssets:Vb,normalizeMaterialBindings:nS}}function hC(e,t,r,n,o,a,i){return{fieldMutationOptions:ec(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>tc(s,c,d,u,r),isRootTransformPath:Ms,parseDuplicateMaterialAssetValue:Qi,isMaterialBindingPath:wr,isMaterialBindingPathAllowed:(s,c)=>wr(c)&&(!!e.resolveFieldSchema?.(c,Qa(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Np,normalizeMaterialAssetValue:rt,hasMaterialAsset:Vt,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return zt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:sa,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:uo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Cu(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>pr(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:AC,isArtistMaterialPatchPath:Zi,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?pr(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function EC(e){return ku({findGameObject:(t,r)=>r?_(t,r):null,resolveRootContainerId:ye,isProtectedSystemGameObject:Dt,isProtectedSystemGameObjectId:Dl,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function eE(e,t){return{materialShaderDefinitions:e,...t}}function IC(e,t,r,n,o,a,i,s,c,d){let u=kS(n,o,a);if(u)return u;let l=iu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Lu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:Qa,isMarkerGameObject:de,createInspectorSections:(m,f,S)=>{let g=Qa(f);return Bu({document:m,gameObject:f,context:S,nodeKind:g,isCameraGameObject:At,isLightGameObject:fo,isMarkerGameObject:de,createBaseSections:()=>Nl({document:m,gameObject:f,nodeKind:g,extraValidators:c(),rootTransform:jr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:oE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:g,context:S,createDocumentInspectorProperty:i})??[],createCameraSection:()=>Tl({nodeKind:g,camera:f.camera,rig:Fa(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>Bl({nodeKind:g,gameObject:f,light:kn(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(b,y)=>d?.normalizeInspectorValue?.(b,y)??ys(b,y),defaultEnvironmentGroundColor:wn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Wu({document:m,gameObject:f,nodeKind:g,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(b,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((b,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>wh(m,f),createMaterialSections:()=>iu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,g,S,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Vu({nodeKind:g,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function PC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return zu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function TC(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 xC(e,t){return eo(t,{builtInMarkerTypes:e})}var Qa=Y;function AC(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function DC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function MC(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function wC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function nE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function gm(e){let{documentReducerImmutability:t,...r}=e;return r}function kC(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:oE(e.flatMap(r=>r.transformTypeOptions??[])).slice(Pa.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:OC(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 oE(e=[]){let t=[],r=new Set;for(let n of[...Pa,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function OC(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var bm=["model","texture","image","sound"],zc=[".glb",".gltf"],Sm=[".png",".jpg",".jpeg",".webp"],aE=[".env",".hdr",".dds",".ktx",".ktx2"],Bc=[...Sm,...aE],Vc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],ko=[...zc,...Bc,...Vc];function iE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Uc(e,t){let r=iE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Kc(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 Hc(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=sE(t);return zc.includes(n)?"model":Vc.includes(n)?"sound":Bc.includes(n)?"texture":null}function sE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function ym(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...ko].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function hm(e,t){return String(e??"").trim()||ym(t)||"Asset"}function Em(e,t){return ym(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function Im(e){return e==="model"?zc:e==="sound"?Vc:e==="texture"?Bc:e==="image"?Sm:[]}function Tm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Pm(t.x),n=Pm(t.y),o=Pm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Pm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xm(e){return e==="shared"||e==="instance"?e:void 0}function Am(e){return Number.isInteger(e)&&e>=0?e:void 0}var cE="rendering",vn=Bf;function Br(e){let t=se(e);return RC(t?.companionConfigs)}function Mm(e){return Br(e)[cE]??null}function dE(e){return Ar(Br(e)[vn])}function RC(e){if(e==null)return{};let t=CC(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw Dm("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=se(o);if(!i)throw Dm("schema.invalidType",`$.companionConfigs.${a}`);a===cE&&gt(i),a===vn&&Wn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function CC(e,t){let r=se(e);if(!r)throw Dm("schema.invalidType",t);return r}function Dm(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var gE="@fps-games/editor.playable-sdk.scene-compiler",bE="3",vC=new Set(["shadowMode","childMaterialBindings","childMaterials"]),GC=new Set(["coordinateSpace","center","size","rotation"]),lE=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function Wc(e){yE(e,!0)}function SE(e){let t=da(e);return Wc(t.document),t}function Rm(e){yE(e,!1)}function yE(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw T("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 T("schema.forbiddenField","$.scene.shadowMapExperiment");_C(r.assets,n.gameObjects),Om(r,"$"),$C(r.assets),FC(r.assets,n.gameObjects),LC(n.gameObjects,r.assets),zC(n.gameObjects),NC(n.materialAssets??[]),t&&BC(r.assets,n.gameObjects),Bs(r),jC(r.assets,n.gameObjects)}function jC(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 T("schema.forbiddenField",`${o}.shadow`)}else if(dn(n))uE(n.shadow,`${o}.shadow`);else if(a)throw T("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw T("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 T("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(uE(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw T("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 T("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function uE(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw T("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw T("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw T("schema.forbiddenField",`${t}.${n}`)}function NC(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 T("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw T("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw T("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw T("schema.invalidType",`${a}.id`);if(t.has(i))throw T("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw T("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw T("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw T("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw T("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw T("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=Qn(c,o.properties,`${a}.properties`);if(l[0])throw T("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw T("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw T("schema.unknownField",`${a}.${l}`)}}function FC(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 T("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 T("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let S=C(m.childPrefabId),g=S?o.get(S):null;if(C(m.id)===d&&c!==g)throw T("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==g)throw T("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 T("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 T("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 T("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!pE(m.width)||!pE(m.height))throw T("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function _C(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw T("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw T("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw T("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 T("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw T("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw T("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw T("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 T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function Om(e,t){if(Array.isArray(e)){e.forEach((n,o)=>Om(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(vC.has(n))throw T("schema.deprecatedField",a);n==="shadow"&&Ko(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&Om(o,a)}}function $C(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 T("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);mE(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let S=0;S<c.nodes.length;S+=1){let g=`$.assets[${i}].prefab.nodes[${S}]`,b=k(c.nodes[S]);if(!b)throw T("schema.invalidType",g);mE(b.defaults,`${g}.defaults`);let y=C(b.id);if(!y||!lE.has(String(b.kind)))throw T("schema.invalidValue",g);if(u.has(y))throw T("schema.invalidValue",`${g}.id`);u.add(y),d.push(b)}let l=C(c?.rootNodeId),m=l?d.find(S=>C(S?.id)===l):null,f=!!m&&lE.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==sn||d.length===0||!f)throw T("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((S,g)=>{let b=C(S.childPrefabId);return b?[{prefabId:b,path:`$.assets[${i}].prefab.nodes[${g}].childPrefabId`}]:[]}));for(let S=0;S<d.length;S+=1){let g=d[S];mg(g,new Map(d.map(P=>[C(P.id),P])),`$.assets[${i}].prefab.nodes[${S}]`);let b=C(g.id),y=C(g.parentId);if(b!==l&&(!y||!u.has(y)))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);if(g.kind==="prefabInstance"){let P=C(g.childPrefabId);if(!P||!t.has(P))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].childPrefabId`)}let E=new Set([b]),I=y;for(;I;){if(E.has(I))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);E.add(I);let P=d.find(A=>C(A.id)===I);I=P?C(P.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 T("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function mE(e,t){if(e==null)return;let r=k(e);if(!r)throw T("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw T("schema.invalidType",`${t}.active`)}function LC(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 T("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw T("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 T("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function zC(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box")continue;for(let o of GC)if(Object.prototype.hasOwnProperty.call(r,o))throw T("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 T("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function BC(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 T("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=VC(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 T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let S=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let g of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,g))throw T("schema.deprecatedField",`${S}.${g}`);if(!Array.isArray(m.sourceSurfaces))throw T("schema.invalidType",`${S}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw T("schema.invalidValue",`${S}.sourceSurfaces`);for(let g=0;g<m.sourceSurfaces.length;g+=1){let b=`${S}.sourceSurfaces[${g}]`,y=k(m.sourceSurfaces[g]);if(!y||!C(y.ownerNodePath))throw T("schema.invalidValue",b);fE(y,"nodeIndex",b),fE(y,"sourceMaterialIndex",b);for(let I of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[I])||y[I]<0)throw T("schema.invalidValue",`${b}.${I}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(I=>!Number.isInteger(I)||I<0)))throw T("schema.invalidValue",`${b}.nodeIndexPath`);let E=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(E))throw T("schema.invalidValue",`${b}.sourceMeshName`)}if(u.has(f))throw T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);wm(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);wm(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);wm(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function wm(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw T("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw T("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw T("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw T("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw T("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw T("schema.invalidType",`${s}.override`);"override"in c&&UC(c.override,`${s}.override`)}}function fE(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw T("schema.invalidValue",`${r}.${t}`)}function VC(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 UC(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);if(Oo(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw T("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ti(r,n,t);KC(r.baseColor,`${t}.baseColor`),km(r.normal,`${t}.normal`,["texture","strength"]),km(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),km(r.occlusion,`${t}.occlusion`,["texture","strength"]),HC(r.emission,`${t}.emission`),WC(r.alpha,`${t}.alpha`)}function KC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","texture","brightness","saturation","contrast","hue"],t),hE(r.color,`${t}.color`),ei(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ti(r,n,t)}function km(e,t,r){if(e==null)return;let n=Ro(e,t);Oo(n,r,t),ei(n.texture,`${t}.texture`),r.includes("strength")&&ti(n,"strength",t)}function HC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","intensity","texture","maskTexture"],t),hE(r.color,`${t}.color`),ti(r,"intensity",t),ei(r.texture,`${t}.texture`),ei(r.maskTexture,`${t}.maskTexture`)}function WC(e,t){if(e==null)return;let r=Ro(e,t);if(Oo(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw T("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ti(r,n,t);ei(r.texture,`${t}.texture`)}function ei(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw T("schema.invalidValue",`${t}.${n}`)}function hE(e,t){if(e==null)return;let r=Ro(e,t);for(let n of["r","g","b"])qC(r,n,t)}function Oo(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw T("schema.deprecatedField",`${r}.${o}`)}function ti(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw T("schema.invalidType",`${r}.${t}`)}function qC(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw T("schema.invalidValue",`${r}.${t}`)}function Ro(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);return r}function T(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 pE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}var JC=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"}),XC=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),YC=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 Cm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return XC[r]??JC[qc(r)]??null}function EE(e){return Cm(e)!==null}function vm(e){return YC[qc(e)]??null}var ZC="fps.plugin.ground-decal",IE="@fps-games/plugin-ground-decal";function PE(e){tv(e);let t=e.plugins.find(i=>i.pluginId===ZC),r=t?ev(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:QC(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:rv(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 QC(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=>nv(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=>ov(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 ev(e){if(e.packageName!==IE)throw new Error(`Ground Decal Plugin package must be ${IE}.`);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 tv(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 rv(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 nv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!Jc(e.size.width)||!Jc(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)||!Jc(n.rect.width)||!Jc(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function Jc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ov(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var av=["/__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 TE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??av,o=sv(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=cv(a);return i?{route:a,routeName:i,prefix:o}:null}function sv(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function cv(e){return iv.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function Xc(e){return{statusCode:e,body:null}}async function xE(e,t){let r=TE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return Xc(204);try{if(dv(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 lv(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 uv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:se(o?.details)})}}function dv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function lv(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 uv(e,t,r){if(e.routeName==="asset-import"){let n=sh(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 fv(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 fv(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 DE(e,t,r={}){let n=SE(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&Wn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ue(a)?a:void 0,d=Wt(n),u={...d,compilerId:gE,compilerVersion:bE,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(E=>E.id!==l),f=yv(n,r.materialShaderDefinitions,!0),S={...n,scene:{...n.scene,materialAssets:f}},g=m.flatMap(E=>kv(E,d,S,r)),b=g.map(ME);gv(l,b),bv(l,b);let y={rootId:l,assets:S.assets.filter(Iv).map(Pv),nodes:b,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Rv(s.plugins,r.shadowMapExperimentConfig,g,l,d.revision),ji(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function ME(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function gv(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 bv(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 Sv(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 Sv(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 yv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Gm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Gm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=Qn(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Gm("material.propertiesInvalid",c[0].path,c[0].message)}let o=rs(hv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Gm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function hv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=jE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...Ev(r)]}}}function Ev(e){let t=[];for(let r of e.scene.gameObjects){let n=ln(e,r);!n.definition||!Yc(n.definition)||t.push(...wE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function wE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=vE(Ze(e.prefabAsset),Ye(e.prefabAsset)??""),r=t.find(a=>a.id===Ye(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=GE(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&&Yc(d)){o.push(...wE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=zv(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=$m({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function Iv(e){return e.type==="glb"||e.type==="texture"}function Pv(e){let t=Av(e),r=e.type==="glb"?Dv(e):[],n=xv(e.external),o=Tv(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 Tv(e){if(!e)return;let t=structuredClone(e);return Ue(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function xv(e){let t=Ue(e)?e:void 0,r=yr(t?.platformAssetId),n=yr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Av(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Ue(e.external)?e.external:void 0;return yr(t?.url)??yr(r?.assetUrl)??void 0}function Dv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Mv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ue(o))return[];let a=yr(o.slotId);if(!a)return[];let i=yr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ue(c))return[];let d=yr(c.ownerNodePath),u=ri(c.meshIndex),l=ri(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=ri(c.nodeIndex),f=wv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),S=ri(c.sourceMaterialIndex),g=yr(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...S==null?{}:{sourceMaterialIndex:S},...g?{sourceMeshName:g}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Mv(e){let t=Ue(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ue(n))return[];let o=ri(n.meshIndex),a=yr(n.name);return o==null||!a?[]:[[o,a]]}))}function wv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function ri(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function kv(e,t,r,n){let o=ln(r,e);return(o.definition&&Yc(o.definition)?vv(e,o.definition,t,r,new Set,n):[Ov(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:ME(i),...s?{asset:s}:{}})??Cv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function Ov(e,t,r,n={}){let o=G(e),a=ue(e),i=kr(e),s=Vv(e),c=Y(e),d=jE(e,r),u=sg(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)}:{},...Nv(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=jv(e,n),S=f.transformType;delete f.transformType;let g=AE(S)??AE(e.transformType);return{...m,kind:"transform",...g?{transformType:g}:{},...e.camera?{camera:Hv(e.camera)}:{},...e.light?{light:NE(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 Rv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==gd);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Pf({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:gd,schemaVersion:3,data:d}]}function Cv(e){let t=Ue(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=jm(t.skinCount),n=jm(t.morphTargetCount);return r>0||n>0?"skinned":jm(t.animationCount)>0?"dynamic":"static"}function jm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function vv(e,t,r,n,o,a){return kE({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 kE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Ze(e.prefabAsset),r=Ye(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>ao(o,d.id),i=vE(t,n.id),s=GE(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&&Yc(m)){let f=d.id===n.id;c.push(...kE({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?ni(ni(Yt(e.prefabAsset.prefab?.overrides),Yt(d.overrides)),Yt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Nm({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push(Gv({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:_m(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),_v({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:_m(e.compilerOptions)})}function Gv(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=OE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:NE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...ma(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Nm(e){return{...OE({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 jv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function OE(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)}:{},...Fv(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 Nv(e,t,r){let n=Ps({document:e,casterId:t.id,caster:t,fallbackMode:_m(r)});return Lm(n,!!t.shadow)?{shadowPlan:n}:{}}function Fv(e){if(!e.editorDocument)return{};let t=He(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=Ps({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return Lm(o,r)?{shadowPlan:o}:{}}function Lm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function _v(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>$v(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=Ps({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!Lm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function _m(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function $v(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function $m(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?CE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=Bv([Fm(Yt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Fm(Yt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:Fm(Yt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Yt(e.instanceOverrides);return RE(ni(n,o),e.asset)}function Fm(e,t,r){return RE(e,t&&t===r?.id?r:void 0)}function RE(e,t){if(!e?.materialSlotBindings)return e;let r=Ue(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ue(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function CE(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 Lv(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 zv(e,t){return t.kind==="model"&&t.sourceAssetId?CE(e,t,t.sourceAssetId):t.kind==="primitive"?Lv(e,t):null}function Bv(e){let t;for(let r of e){let n=Yt(r);n&&(t=ni(t,n))}return t}function vE(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 GE(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 Yc(e){return Xe(e)&&e.prefab.compositionVersion===sn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ye(e)}function Vv(e){return e.primitive??null}function jE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=ue(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return Uv(e,t,o)}function Uv(e,t,r){let n=Yt(e.overrides),o=ln(t,e),a=Yt(o.definition?.prefab?.overrides);return ni(a,n)}function ni(e,t){let r=is(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))Kv(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Yt(e){if(!Ue(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function Kv(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ue(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function yr(e){return(typeof e=="string"?e.trim():"")||void 0}function AE(e){return typeof e=="string"?e:void 0}function Hv(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function NE(e){return e.type==="directional"?Vn({schemaVersion:1,type:"directional",intensity:e.intensity,direction:Xo(e.direction),diffuseColor:e.diffuseColor??Na.diffuseColor}):Vn({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??wn.diffuseColor,groundColor:e.groundColor??wn.groundColor})}var Wv=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function $E(e){let t=Ni(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>qv(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function qv(e,t){let r=Ao(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:Jv(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:_E(e.value),...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...FE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Co(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:_E(e.value??0),color:Co(e.color),...FE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Co(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Co(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function Jv(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Co(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function FE(e){return typeof e=="string"&&Wv.has(e)}function _E(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function LE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return Xc(204);try{if(r==="GET"){let c=Qv(await t.loadConfig?.()),d=c.renderingConfig;gt(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:Zv(d),normalized:u,summary:Bn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=oi(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});gt(o);let a=Ne(o),i=Bn(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=Xv(n),a=Yv(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:oi(n?.details)})}}function Xv(e){let t=e?.code;return typeof t=="string"&&t?t:null}function Yv(e){let t=e?.path;return typeof t=="string"&&t?t:null}function oi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Zv(e){return oi(e)??{}}function Qv(e){let t=oi(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:oi(t.response)??{}}:{renderingConfig:e??{},response:{}}}function zE(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 ${Kc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
- `),i=e.map(d=>{let u=_f(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!$f(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Kc(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 SP}from"node:events";var Uo="medium",cd={low:{opacity:.32,softness:.25,bias:.0015,normalBias:.02,maxDistance:24,resolution:512,cascadeCount:1,bakeSamples:8,blurKernel:2},medium:{opacity:.42,softness:.4,bias:.001,normalBias:.01,maxDistance:48,resolution:1024,cascadeCount:2,bakeSamples:24,blurKernel:4},high:{opacity:.5,softness:.58,bias:8e-4,normalBias:.006,maxDistance:80,resolution:2048,cascadeCount:4,bakeSamples:64,blurKernel:8},ultra:{opacity:.56,softness:.72,bias:6e-4,normalBias:.004,maxDistance:120,resolution:4096,cascadeCount:4,bakeSamples:128,blurKernel:12}};function Ei(e=Uo,t={}){let r=cd[e]??cd[Uo];return{opacity:Vo(t.opacity,r.opacity),softness:Vo(t.softness,r.softness),bias:Vo(t.bias,r.bias),normalBias:Vo(t.normalBias,r.normalBias),maxDistance:Vo(t.maxDistance,r.maxDistance),resolution:xP(t.resolution,r.resolution),cascadeCount:AP(t.cascadeCount,r.cascadeCount),bakeSamples:PP(t.bakeSamples,r.bakeSamples),blurKernel:TP(t.blurKernel,r.blurKernel)}}function Vo(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function PP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function TP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function xP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function AP(e,t){return e===1||e===2||e===4?e:t}function Ii(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Pi(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Ti(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function xi(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function Ai(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function Di(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function hf(e){let t=Ii(e);if(!t)return;let r={};Pi(t.cast)&&(r.cast=t.cast),Ti(t.receive)&&(r.receive=t.receive),xi(t.mode)&&(r.mode=t.mode),Ai(t.quality)&&(r.quality=t.quality);let n=Ii(t.light);if(n){let a={};Di(n.mode)&&(a.mode=n.mode),typeof n.lightId=="string"&&n.lightId.trim()&&(a.lightId=n.lightId.trim()),Object.keys(a).length>0&&(r.light=a)}let o=DP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function He(e){let t=hf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function dd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function ld(e,t=Uo){let r=e?.quality;return r&&r!=="inherit"?r:t}function DP(e){let t=Ii(e);if(!t)return;let r={};return typeof t.opacity=="number"&&Number.isFinite(t.opacity)&&(r.opacity=t.opacity),typeof t.softness=="number"&&Number.isFinite(t.softness)&&(r.softness=t.softness),typeof t.bias=="number"&&Number.isFinite(t.bias)&&(r.bias=t.bias),typeof t.normalBias=="number"&&Number.isFinite(t.normalBias)&&(r.normalBias=t.normalBias),typeof t.maxDistance=="number"&&Number.isFinite(t.maxDistance)&&(r.maxDistance=t.maxDistance),(t.resolution===512||t.resolution===1024||t.resolution===2048||t.resolution===4096)&&(r.resolution=t.resolution),(t.cascadeCount===1||t.cascadeCount===2||t.cascadeCount===4)&&(r.cascadeCount=t.cascadeCount),typeof t.bakeSamples=="number"&&Number.isFinite(t.bakeSamples)&&(r.bakeSamples=t.bakeSamples),typeof t.blurKernel=="number"&&Number.isFinite(t.blurKernel)&&(r.blurKernel=t.blurKernel),Object.keys(r).length>0?r:void 0}var MP=new Set(["cast","receive","mode","quality","light","params"]),wP=new Set(["mode","lightId"]),kP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Ko(e,t="$.shadow"){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,MP,t),"cast"in r&&!Pi(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!Ti(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!xi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!Ai(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&OP(r.light,`${t}.light`),"params"in r&&RP(r.params,`${t}.params`)}function OP(e,t){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,wP,t),"mode"in r&&!Di(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("lightId"in r&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`);if(r.mode==="explicit"&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`)}function RP(e,t){let r=md(e);if(!r)throw ve("schema.invalidType",t);if(ud(r,kP,t),Jr(r,"opacity",t,n=>n>=0&&n<=1),Jr(r,"softness",t,n=>n>=0),Jr(r,"bias",t,()=>!0),Jr(r,"normalBias",t,()=>!0),Jr(r,"maxDistance",t,n=>n>0),Jr(r,"bakeSamples",t,n=>n>0),Jr(r,"blurKernel",t,n=>n>=0),"resolution"in r&&![512,1024,2048,4096].includes(r.resolution))throw ve("schema.invalidValue",`${t}.resolution`);if("cascadeCount"in r&&![1,2,4].includes(r.cascadeCount))throw ve("schema.invalidValue",`${t}.cascadeCount`)}function Jr(e,t,r,n){if(!(t in e))return;let o=e[t];if(typeof o!="number"||!Number.isFinite(o)||!n(o))throw ve("schema.invalidValue",`${r}.${t}`)}function ud(e,t,r){for(let n of Object.keys(e))if(!t.has(n))throw ve("schema.deprecatedField",`${r}.${n}`)}function ve(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function md(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var bd="fps.shadow-map-experiment";function CP(e,t="$.scene.shadowMapExperiment"){let r=ft(e,t);Gt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&vt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&vt(r.behaviorProfile,`${t}.behaviorProfile`)}function vP(e,t="$.shadowMapExperiment"){let r=ft(e,t);Gt(r,["behaviorProfile"],t),vt(r.behaviorProfile,`${t}.behaviorProfile`)}function wi(e,t="$"){let r=ft(e,t);Gt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),vt(r.lightRef,`${t}.lightRef`);let n=vt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=vt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=If(r.qualityProfiles,`${t}.qualityProfiles`),i=If(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))jP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))NP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Pf(e){wi(e.config),e.settings!==void 0&&CP(e.settings),(!Number.isInteger(e.revision)||e.revision<0)&&H("$.revision","expected a non-negative integer");let t=e.settings?.qualityProfile??e.config.defaultQualityProfile,r=e.settings?.behaviorProfile??e.config.defaultBehaviorProfile,n=pd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");pd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&vP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=pd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:vt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze(UP(s.renderableIds,`${d}.renderableIds`)),cast:Ef(s.cast,`${d}.cast`)??l.cast==="enabled",receive:Ef(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];BP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return Tf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:vt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Wo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:VP(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function Ef(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function GP(e,t){let r=ft(e,t);Gt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Wo(r.center,`${t}.center`),Wo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=Mi(r.near,`${t}.near`),a=Mi(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function jP(e,t){let r=ft(e,t);Gt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),FP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&_P(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),Ho(r.bias,`${t}.bias`,0,.1),Ho(r.normalBias,`${t}.normalBias`,0,1),Ho(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Ho(r.softness,`${t}.softness`,0,1),GP(r.bounds,`${t}.bounds`),$P(r.backend,`${t}.backend`),LP(r.culling,`${t}.culling`),zP(r.diagnostics,`${t}.diagnostics`)}function NP(e,t){let r=ft(e,t);Gt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function FP(e,t){let r=ft(e,t);Gt(r,["staticResolution","dynamicResolution","compositeResolution"],t),fd(r.staticResolution,`${t}.staticResolution`),fd(r.dynamicResolution,`${t}.dynamicResolution`),fd(r.compositeResolution,`${t}.compositeResolution`)}function fd(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function _P(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function $P(e,t){let r=ft(e,t);Gt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function LP(e,t){let r=ft(e,t);Gt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Ho(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function zP(e,t){let r=ft(e,t);Gt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),gd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),gd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),gd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function BP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function If(e,t){let r=ft(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))vt(n,`${t} key`);return r}function pd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function VP(e){return Object.freeze({mode:"fixed",center:Wo(e.center,"$.bounds.center"),extent:Wo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Wo(e,t){let r=KP(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>Mi(n,`${t}[${o}]`)))}function UP(e,t){let r=e.map((n,o)=>vt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function Mi(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function Ho(e,t,r,n){let o=Mi(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function gd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function vt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function ft(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function KP(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function Gt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function Tf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))Tf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var xf=["useBlobShadow","blobSettings"],HP=["resolution","maxSize"],WP=new Set(["none","blob","static","planar","dynamic"]);function gt(e){let t=Xr(e);if(!t)throw X("schema.invalidType","$");for(let o of xf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),XP(t.globalVolume,"$.globalVolume"),YP(t.materials,"$.materials"),qP(t.renderingGroups,"$.renderingGroups"),JP(t.globalVolume,"$.globalVolume"),nT(t.shadowMeshes,"$.shadowMeshes"),!Object.prototype.hasOwnProperty.call(t,"shadows"))return;let r=Xr(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of xf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!WP.has(String(r.defaultMode)))throw X("schema.invalidValue","$.shadows.defaultMode");Ge(r,"enabled","$.shadows"),Ge(r,"useCsm","$.shadows");let n=Xr(r.settings);if(Object.prototype.hasOwnProperty.call(r,"settings")&&!n)throw X("schema.invalidType","$.shadows.settings");if(n){q(n,["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ","useBlurExponentialShadowMap","shadowColor"],"$.shadows.settings");for(let o of["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ"])Ae(n,o,"$.shadows.settings");Ge(n,"useBlurExponentialShadowMap","$.shadows.settings"),ki(n.shadowColor,"$.shadows.settings.shadowColor",!1)}QP(r.blob,"$.shadows.blob"),eT(r.staticProjected,"$.shadows.staticProjected"),tT(r.planar,"$.shadows.planar"),Yr(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),Yr(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),rT(r.csm,"$.shadows.csm")}function qP(e,t){if(e===void 0)return;let r=Xr(e);if(!r||!Array.isArray(r.slots))throw X("schema.invalidType",t);q(r,["slots"],t),r.slots.forEach((n,o)=>{let a=`${t}.slots[${o}]`,i=Xr(n);if(!i)throw X("schema.invalidType",a);if(q(i,["renderingGroupId","name","alphaIndexPresets"],a),![0,1,2,3].includes(i.renderingGroupId))throw X("schema.invalidValue",`${a}.renderingGroupId`);if(typeof i.name!="string"||!i.name.trim())throw X("schema.invalidValue",`${a}.name`);if(!Array.isArray(i.alphaIndexPresets))throw X("schema.invalidType",`${a}.alphaIndexPresets`);i.alphaIndexPresets.forEach((s,c)=>{let d=`${a}.alphaIndexPresets[${c}]`,u=Xr(s);if(!u)throw X("schema.invalidType",d);if(q(u,["name","alphaIndex"],d),typeof u.name!="string"||!u.name.trim())throw X("schema.invalidValue",`${d}.name`);yd(u,"alphaIndex",d)})})}function JP(e,t){if(e===void 0)return;let r=ge(e,t);for(let a of["samples","camera","lights"])if(a in r)throw X("schema.deprecatedField",`${t}.${a}`);if(q(r,["enabled","hdr","environment","imageProcessing","toneMapping","antialiasing","postProcessing","rendering","textures"],t),Ge(r,"enabled",t),Ge(r,"hdr",t),r.environment!==void 0){let a=ge(r.environment,`${t}.environment`);for(let i of["textureAssetId","textureUrl","intensity"])if(i in a)throw X("schema.deprecatedField",`${t}.environment.${i}`);if(q(a,["texture","iblIntensity","rotationY","useCocosIBL"],`${t}.environment`),a.texture!==void 0&&a.texture!==null){let i=ge(a.texture,`${t}.environment.texture`);for(let s of Object.keys(i))if(s!=="textureAssetId"&&s!=="url")throw X("schema.deprecatedField",`${t}.environment.texture.${s}`);for(let s of["textureAssetId","url"])if(s in i&&i[s]!=null&&(typeof i[s]!="string"||!i[s].trim()))throw X("schema.invalidValue",`${t}.environment.texture.${s}`)}Ae(a,"iblIntensity",`${t}.environment`),Ae(a,"rotationY",`${t}.environment`),Ge(a,"useCocosIBL",`${t}.environment`)}if(Yr(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=ge(r.toneMapping,`${t}.toneMapping`);if(q(a,["enabled","type"],`${t}.toneMapping`),Ge(a,"enabled",`${t}.toneMapping`),"type"in a&&!["standard","aces","khr-pbr-neutral"].includes(String(a.type)))throw X("schema.invalidValue",`${t}.toneMapping.type`)}if(r.antialiasing!==void 0){let a=ge(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=pt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?pt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function XP(e,t){if(e===void 0)return;let r=ge(e,t),n=pt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),ZP(n,"hardwareScalingLevel",`${t}.rendering`));let o=pt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function YP(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&ge(r[n],`${t}.${n}`)}function ZP(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function QP(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),Yr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),ki(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),Yr(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function eT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),Yr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),ki(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=ge(r.bake,`${t}.bake`);for(let a of HP)if(a in o)throw X("schema.deprecatedField",`${t}.bake.${a}`);q(o,["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"],`${t}.bake`);for(let a of["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"])Ae(o,a,`${t}.bake`)}function tT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=pt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),oT(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=pt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),ki(o.color,`${t}.appearance.color`,!0)),Yr(r.projection,`${t}.projection`,["footprintScale"]);let a=pt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=pt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])Sd(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=pt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),Sd(s.patterns,`${t}.receivers.patterns`))}function rT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["numCascades","lambda","cascadeBlendPercentage","stabilizeCascades"],t);for(let n of["numCascades","lambda","cascadeBlendPercentage"])Ae(r,n,t);Ge(r,"stabilizeCascades",t)}function nT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])Sd(r[n],`${t}.${n}`)}function Yr(e,t,r){if(e===void 0)return;let n=ge(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function ki(e,t,r){if(e===void 0)return;let n=ge(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)yd(n,a,t)}function oT(e,t){if(e===void 0)return;let r=ge(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])yd(r,n,t)}function Sd(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function yd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function pt(e,t){return e===void 0?null:ge(e,t)}function ge(e,t){let r=Xr(e);if(!r)throw X("schema.invalidType",t);return r}function Ge(e,t,r){if(t in e&&typeof e[t]!="boolean")throw X("schema.invalidValue",`${r}.${t}`)}function Ae(e,t,r){if(!(t in e))return;let n=e[t];if(typeof n!="number"||!Number.isFinite(n))throw X("schema.invalidValue",`${r}.${t}`)}function q(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw X("schema.unknownField",`${r}.${o}`)}function X(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function Xr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Af(e,t){let r=L(e);return{x:be(r.x,t.x),y:be(r.y,t.y),z:be(r.z,t.z)}}function hd(e,t){let r=L(e);return{r:rr(r.r,t.r,0,1),g:rr(r.g,t.g,0,1),b:rr(r.b,t.b,0,1)}}function qo(e,t){let r=L(e);return{...hd(r,t),a:rr(r.a,t.a,0,1)}}function Pr(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function Ed(e){return(typeof e=="string"?e.trim():"")||null}function Id(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function Df(e){return e===0||e===1||e===2||e===3?e:null}function Mf(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function wf(e,t){return e===1||e===2||e===4||e===8?e:t}function kf(e,t){return e==="fixed"||e==="receiver"?e:t}function Of(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function be(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=be(e,t);return Math.max(0,r)}function Tr(e,t){let r=be(e,t);return r>0?r:t}function rr(e,t,r,n){let o=be(e,t);return Math.min(n,Math.max(r,o))}var Rf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Cf=[...Rf,"_blobShadow"],aT=[...Cf,"_staticProjectedShadow"];var vf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&gt(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=iT(o),i=cT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Gf(t.renderingGroups),environment:dT(t.globalVolume),postProcess:lT(t.globalVolume),shadows:{defaultMode:Of(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:hd(n.shadowColor,{r:0,g:0,b:0})},blob:a,staticProjected:i,shadowRange:{minZ:Q(s.minZ,1),maxZ:Q(s.maxZ,60)},shadowOrtho:{left:be(c.left,-20),right:be(c.right,20),top:be(c.top,20),bottom:be(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:rr(d.lambda,.5,0,1),cascadeBlendPercentage:rr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:sT(r.planar)},shadowMeshes:{shadowReceivers:Pr(u.shadowReceivers),shadowCasters:Pr(u.shadowCasters),excludeFromShadow:Pr(u.excludeFromShadow)}}}function Vn(e){let t=e?.environment?.texture!=null;return{environmentTextureAssetId:e?.environment?.texture?.textureAssetId??null,environmentTextureUrl:e?.environment?.texture?.url??null,environmentIblIntensity:t?e?.environment?.iblIntensity??null:null,postProcessEnabled:e?.postProcess?.enabled??null,postProcessExposure:e?.postProcess?.imageProcessing?.exposure??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??null,blobEnabled:e?.shadows?.blob?.enabled??null,blobOpacity:e?.shadows?.blob?.appearance?.color?.a??null,staticProjectedEnabled:e?.shadows?.staticProjected?.enabled??null,staticProjectedOpacity:e?.shadows?.staticProjected?.appearance?.color?.a??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}function iT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.size),a=qo(n.color,{r:0,g:0,b:0,a:.35});return{enabled:je(t.enabled,!0),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,a),edgeSoftness:rr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Tr(o.maxSize,20)}}}function Gf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:vf.map(n=>{let o=r.find(i=>Df(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Id(a.name,n.name),alphaIndexPresets:jf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function jf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=be(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Id(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function sT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:Af(r.normal,{x:0,y:1,z:0}),height:be(r.height,0),heightMode:kf(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:rr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Pr(i.includePatterns),excludePatterns:Pr(i.excludePatterns),rootBoundaryPatterns:Pr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Pr(s.patterns)}}}function cT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Tr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:be(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Tr(o.texelsPerMeter,256),atlasSize:Tr(o.atlasSize,4096),maxAtlasPages:Tr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Tr(o.targetChunkCount,64)}}}function dT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=Ed(n.textureAssetId),a=Ed(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:be(r.rotationY,0)}}function lT(e){let t=L(e),r=L(t.imageProcessing),n=L(t.toneMapping),o=L(t.antialiasing),a=L(t.postProcessing),i=L(a.bloom);return{enabled:je(t.enabled,!0),hdr:je(t.hdr,!0),imageProcessing:{exposure:be(r.exposure,1),contrast:be(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:Mf(n.type,"aces")},antialiasing:{samples:wf(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Tr(i.scale,.5)}}}var Oi=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Nf=1e-6,uT=1e-4,mT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),fT=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),pT=new Set(["x","y","z"]),gT=new Set(["r","g","b"]);function Xo(e,t="$.direction"){let r=Ff(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Nf&&bt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Un(e,t="$.light"){let r=xd(e,t);r.schemaVersion!==1&&bt(`${t}.schemaVersion`,"expected 1");let n=bT(r.intensity,`${t}.intensity`);if(r.type==="directional"){Ri(r,mT,t);let o=Ff(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Nf&&bt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>uT&&bt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Pd(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return Ri(r,fT,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Pd(r.diffuseColor,`${t}.diffuseColor`),groundColor:Pd(r.groundColor,`${t}.groundColor`)});bt(`${t}.type`,"expected directional or hemispheric")}function Ff(e,t){let r=xd(e,t);return Ri(r,pT,t),Object.freeze({x:Jo(r.x,`${t}.x`),y:Jo(r.y,`${t}.y`),z:Jo(r.z,`${t}.z`)})}function Pd(e,t){let r=xd(e,t);return Ri(r,gT,t),Object.freeze({r:Td(r.r,`${t}.r`),g:Td(r.g,`${t}.g`),b:Td(r.b,`${t}.b`)})}function xd(e,t){(!e||typeof e!="object"||Array.isArray(e))&&bt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&bt(t,"expected a plain object"),e}function Ri(e,t,r){for(let n of Object.keys(e))t.has(n)||bt(`${r}.${n}`,"unknown field")}function Jo(e,t){return(typeof e!="number"||!Number.isFinite(e))&&bt(t,"expected a finite number"),e}function bT(e,t){let r=Jo(e,t);return r<0&&bt(t,"expected a non-negative number"),r}function Td(e,t){let r=Jo(e,t);return(r<0||r>1)&&bt(t,"expected a number between 0 and 1"),r}function bt(e,t){throw new Oi(e,t)}var ST=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function _f(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function $f(e){return ST.has(e)}function Wn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Lf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=zf(e.baseColor?.color);n&&(r.color=n);let o=Zr(e.baseColor?.texture);o!==void 0&&(r.texture=o),nr(e.baseColor,r,"brightness"),nr(e.baseColor,r,"saturation"),nr(e.baseColor,r,"contrast"),nr(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=Zr(e.normal?.texture);i!==void 0&&(a.texture=i),nr(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Hn(e.metallic)&&(t.metallic=e.metallic),Hn(e.roughness)&&(t.roughness=e.roughness);let s={},c=Zr(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=Zr(e.occlusion?.texture);u!==void 0&&(d.texture=u),nr(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=zf(e.emission?.color);m&&(l.color=m),nr(e.emission,l,"intensity");let f=Zr(e.emission?.texture);f!==void 0&&(l.texture=f);let S=Zr(e.emission?.maskTexture);S!==void 0&&(l.maskTexture=S),Object.keys(l).length>0&&(t.emission=l);let g={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(g.mode=e.alpha.mode),nr(e.alpha,g,"opacity"),nr(e.alpha,g,"cutoff");let b=Zr(e.alpha?.texture);return b!==void 0&&(g.texture=b),Object.keys(g).length>0&&(t.alpha=g),Object.keys(t).length>0?t:void 0}function Ad(...e){let t={};for(let r of e){let n=Lf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Kn(t,n,"baseColor"),Kn(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Kn(t,n,"metallicRoughness"),Kn(t,n,"occlusion"),Kn(t,n,"emission"),Kn(t,n,"alpha"))}return Lf(t)??{}}function Kn(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function zf(e){return e&&Hn(e.r)&&Hn(e.g)&&Hn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function Zr(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function nr(e,t,r){Hn(e?.[r])&&(t[r]=e[r])}function Hn(e){return typeof e=="number"&&Number.isFinite(e)}var Bf="staticShadows";function Ar(e){let t=ar(e);if(!t)return null;let r=fe(t.sourceHash),n=fe(t.lightHash),o=fe(t.profileHash);if(!r||!n||!o)return null;let a={sourceHash:r,lightHash:n,profileHash:o,...typeof t.generatedAt=="string"&&t.generatedAt.trim()?{generatedAt:t.generatedAt.trim()}:{},...(()=>{let u=AT(t.stats);return u?{stats:u}:{}})()};if(t.version!==2||t.format!=="sdf-atlas"||!Array.isArray(t.pages)||!Array.isArray(t.chunks))return null;let i=[],s=new Map;for(let u of t.pages){let l=yT(u);if(!l||s.has(l.id))return null;i.push(l),s.set(l.id,l)}let c=[],d=new Set;for(let u of t.chunks){let l=hT(u,s);if(!l||d.has(l.id))return null;c.push(l),d.add(l.id)}return{version:2,format:"sdf-atlas",pages:i,chunks:c,...a}}function qn(e,t="$.staticShadows"){let r=Ar(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function yT(e){let t=ar(e);if(!t)return null;let r=fe(t.id),n=ji(t.width),o=ji(t.height),a=DT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function hT(e,t){let r=ar(e);if(!r)return null;let n=fe(r.id),o=TT(r.bounds),a=xT(r.plane),i=fe(r.pageId),s=IT(r.atlasRect),c=PT(r.atlasUv),d=MT(r.sourceNodeIds),u=fe(r.sourceHash),l=fe(r.lightHash),m=fe(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let S=ET(r.binding);return S?{binding:S}:{}})()}}function ET(e){let t=ar(e);if(!t)return null;let r=fe(t.id),n=fe(t.ownerCasterId),o=fe(t.receiverId),a=fe(t.generatedAt),i=fe(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=fe(t.lightId),c=fe(t.textureAssetId),d=fe(t.projectionNodeId);return{id:r,ownerCasterId:n,receiverId:o,...s?{lightId:s}:{},...c?{textureAssetId:c}:{},...d?{projectionNodeId:d}:{},visibleWhenOwnerVisible:!0,staleWhenOwnerTransformChanges:!0,staleWhenLightChanges:!0,generatedAt:a,sourceHash:i}}function IT(e){let t=ar(e);if(!t)return null;let r=xr(t.x),n=xr(t.y),o=ji(t.width),a=ji(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function PT(e){let t=ar(e);if(!t)return null;let r=Ci(t.u0),n=Ci(t.v0),o=Ci(t.u1),a=Ci(t.v1);return r==null||n==null||o==null||a==null||o<=r||a<=n?null:{u0:r,v0:n,u1:o,v1:a}}function TT(e){let t=ar(e);if(!t)return null;let r=jt(t.minX),n=jt(t.maxX),o=jt(t.minZ),a=jt(t.maxZ),i=jt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function xT(e){let t=ar(e);if(!t)return null;let r=jt(t.height),n=jt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function AT(e){let t=ar(e);if(!t)return null;let r=xr(t.sourceRootCount),n=xr(t.sourceMeshCount),o=xr(t.attemptedChunkCount),a=xr(t.chunkCount),i=xr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...vi(t.skippedChunkCount,"skippedChunkCount"),...vi(t.pageCount,"pageCount"),...or(t.resolution,"resolution"),...or(t.chunkSize,"chunkSize"),...or(t.atlasSize,"atlasSize"),...Gi(t.atlasUsedPixels,"atlasUsedPixels"),...Gi(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...wT(t.atlasOccupancy,"atlasOccupancy"),...or(t.texelsPerMeter,"texelsPerMeter"),...or(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...or(t.maxAtlasPages,"maxAtlasPages"),...Gi(t.sdfRadiusPx,"sdfRadiusPx"),...or(t.spatialChunkSize,"spatialChunkSize"),...or(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...or(t.targetChunkCount,"targetChunkCount"),...vi(t.bakedChunkCount,"bakedChunkCount"),...vi(t.reusedChunkCount,"reusedChunkCount"),...Gi(t.durationMs,"durationMs")}}function DT(e){let t=fe(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function MT(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=fe(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function fe(e){return typeof e=="string"&&e.trim()?e.trim():null}function jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ji(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function Ci(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function vi(e,t){let r=xr(e);return r==null?{}:{[t]:r}}function or(e,t){let r=jt(e);return r==null||r<=0?{}:{[t]:r}}function Gi(e,t){let r=jt(e);return r==null||r<0?{}:{[t]:r}}function wT(e,t){let r=jt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ar(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var kT="@fps-games/editor.playable-sdk.scene-compiler",OT="2",RT=1e-4,et={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},CT=new Set(et.nodeKinds),vT=new Set(et.primitiveShapes),GT=new Set(et.assetTypes),jT=new Set(et.materialModes),NT=new Set(et.materialScopes),FT=new Set(et.materialAssetSystemPresets),_T=new Set(et.transformTypes),Yo=new Set(et.hierarchy.parentTargets),$T=et.runtimeOnlyTokens,LT=new Set(et.runtimeV3.assetFields),zT=new Set(et.runtimeV3.materialSlotFields),BT=new Set(et.runtimeV3.materialSlotSourceSurfaceFields);function VT(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,D)=>{c.length<s&&c.push({path:p,message:D})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),ox(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=fx(e),S=e.scene;if(!M(S))return l("$.scene","scene must be an object"),c;if(O(S.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(S.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(S.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(S.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(S.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(S.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&Vf(()=>qn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let g=new Set,b=new Map,y=new Map,I=new Set,E=new Set([S.rootId]),T=new Map,A=new Map,$=new Set;return S.assets.forEach((p,D)=>{let h=`$.scene.assets[${D}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?g.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(g.add(p.id),b.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),GT.has(p.type)||l(`${h}.type`,"asset.type must be glb or texture"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"asset.guid must be a non-empty string when present"),p.url!=null&&!O(p.url)&&l(`${h}.url`,"url must be a non-empty string when present"),p.external!=null&&!M(p.external)&&l(`${h}.external`,"external must be an object when present"),p.warmupCount!=null&&(!Number.isInteger(p.warmupCount)||p.warmupCount<0)&&l(`${h}.warmupCount`,"warmupCount must be a non-negative integer when present"),p.singleton!=null&&typeof p.singleton!="boolean"&&l(`${h}.singleton`,"singleton must be a boolean when present"),p.materialMode!=null&&!jT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),nx(p.defaults,`${h}.defaults`,l),m===3)for(let F of Object.keys(p))LT.has(F)||l(`${h}.${F}`,`runtime schema v3 asset field is not allowed: ${F}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((F,Ir)=>{let er=`${K}[${Ir}]`;if(!M(F)||!O(F.slotId)){l(er,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(F.ownerNodePath)){l(er,"material slot must contain stable slotId and ownerNodePath");return}ne.has(F.slotId)?l(`${er}.slotId`,`duplicate material slot id: ${F.slotId}`):ne.add(F.slotId),m===3&&rx(F,er,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Hf(p,h,l)}),S.nodes.forEach((p,D)=>{let h=`$.scene.nodes[${D}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&T.set(p.id,p),O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(E.add(p.id),typeof p.kind=="string"&&A.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&$.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),CT.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),S.materialAssets.forEach((p,D)=>{let h=`$.scene.materialAssets[${D}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):I.add(p.id):l(`${h}.id`,"material asset id must be a non-empty string"),p.name!=null&&!O(p.name)&&l(`${h}.name`,"material asset name must be a non-empty string when present"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"material asset guid must be a non-empty string when present"),Object.prototype.hasOwnProperty.call(p,"materialKind")&&l(`${h}.materialKind`,"materialKind is not supported; use shaderId"),Object.prototype.hasOwnProperty.call(p,"profile")&&l(`${h}.profile`,"profile is not supported; use properties");let R=Wn(p.shaderId),K=qT(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!JT(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?qf(p.properties,`${h}.properties`,l):XT(p.properties,`${h}.properties`,l);for(let ne of Object.keys(p))["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(ne)||l(`${h}.${ne}`,`material asset field is not allowed: ${ne}`);YT(p.system,`${h}.system`,l),ZT(p.origin,`${h}.origin`,l),QT(p,h,l)}),S.nodes.forEach((p,D)=>{if(!M(p))return;let h=`$.scene.nodes[${D}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:S.rootId;O(K)&&ex(K,S.rootId,E,`${h}.parentId`,l),O(p.id)&&tx(p.id,S.rootId,T,`${h}.parentId`,l),ax(p.source,`${h}.source`,l),Xf(p.transform,`${h}.transform`,l),xx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Vf(()=>Ko(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?g.has(p.instance.assetId)?b.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?vT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(g.has(p.image.assetId)?b.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Kf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Kf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!_T.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?bx(p.groundDecal,`${h}.groundDecal`,l):Object.prototype.hasOwnProperty.call(p,"groundDecal")&&l(`${h}.groundDecal`,"groundDecal is only allowed on transform nodes with transformType groundDecal"),p.kind==="transform"&&(mx(p.camera,`${h}.camera`,l),px(p.light,`${h}.light`,l,f)),Object.prototype.hasOwnProperty.call(p,"marker")&&(p.kind!=="transform"?l(`${h}.marker`,"marker is only allowed on transform nodes"):(ix(p.marker,`${h}.marker`,l),sx(p.marker,p.id,E,$,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&KT(p.overrides,`${h}.overrides`,I,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Hf(p,h,l)}),S.materials.forEach((p,D)=>{let h=`$.scene.materials[${D}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!NT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!g.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!E.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&E.has(p.nodeId)){let R=A.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?Zf(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function UT(e,t={}){let r=VT(e,t);return{ok:r.length===0,errors:r}}function Vf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function KT(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}Wf(e.materialBinding,`${t}.materialBinding`,r,a),HT(e.materialSlotBindings,`${t}.materialSlotBindings`,"slotId",r,n,o,a),Object.prototype.hasOwnProperty.call(e,"childMaterialBindings")&&a(`${t}.childMaterialBindings`,"deprecated field; use materialSlotBindings keyed by slotId"),Object.prototype.hasOwnProperty.call(e,"childMaterials")&&a(`${t}.childMaterials`,"deprecated field; use materialSlotBindings keyed by slotId")}}function HT(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):Wf(c,d,n,i)}}}function Wf(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&qf(e.override,`${t}.override`,n)}}function qf(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{Ni(e.baseColor.color,`${t}.baseColor.color`,r),Qr(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!We(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(Qr(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!We(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?Qr(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(Qr(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!We(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(Ni(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!We(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),Qr(e.emission.texture,`${t}.emission.texture`,r),Qr(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!We(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!We(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),Qr(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var WT=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function Qo(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&WT.test(e)}function qT(e){return Qo(e)?e:null}function JT(e){return Number.isSafeInteger(e)&&e>0}function XT(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Dd(e,t,r)}function Dd(e,t,r){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||r(t,"project shader material numbers must be finite");return}if(Array.isArray(e)){e.forEach((n,o)=>Dd(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Dd(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function Qr(e,t,r){if(e!=null){if(!M(e)){r(t,"texture ref must be an object");return}e.url!=null&&!O(e.url)&&r(`${t}.url`,"texture url must be non-empty when present"),e.textureAssetId!=null&&!O(e.textureAssetId)&&r(`${t}.textureAssetId`,"textureAssetId must be non-empty when present")}}function YT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset system must be an object");return}e.readonly!=null&&typeof e.readonly!="boolean"&&r(`${t}.readonly`,"readonly must be boolean"),e.preset!=null&&!FT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function ZT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function QT(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function ex(e,t,r,n,o){if(e===t){Yo.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(Yo.has("sceneNode")&&r.has(e))return;let a=Yo.has("root")&&Yo.has("sceneNode")?"root or scene node":Yo.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function tx(e,t,r,n,o){if(!O(t))return;let a=new Set([e]),i=O(r.get(e)?.parentId)?r.get(e)?.parentId:t;for(;O(i)&&i!==t;){if(a.has(i)){o(n,`parentId creates a node cycle involving ${e}`);return}a.add(i);let s=r.get(i);if(!s)return;i=O(s.parentId)?s.parentId:t}}function rx(e,t,r){for(let n of Object.keys(e))zT.has(n)||r(`${t}.${n}`,`runtime schema v3 material slot field is not allowed: ${n}`);if(e.label!=null&&!O(e.label)&&r(`${t}.label`,"label must be a non-empty string when present"),!Array.isArray(e.sourceSurfaces)||e.sourceSurfaces.length===0){r(`${t}.sourceSurfaces`,"sourceSurfaces must be a non-empty array");return}for(let n=0;n<e.sourceSurfaces.length;n+=1){let o=`${t}.sourceSurfaces[${n}]`,a=e.sourceSurfaces[n];if(!M(a)){r(o,"source surface must be an object");continue}for(let i of Object.keys(a))BT.has(i)||r(`${o}.${i}`,`runtime schema v3 material slot source surface field is not allowed: ${i}`);O(a.ownerNodePath)||r(`${o}.ownerNodePath`,"ownerNodePath must be a non-empty string");for(let i of["meshIndex","primitiveIndex"])(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer`);for(let i of["nodeIndex","sourceMaterialIndex"])a[i]!=null&&(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer when present`);a.nodeIndexPath!=null&&(!Array.isArray(a.nodeIndexPath)||a.nodeIndexPath.some(i=>!Number.isInteger(i)||i<0))&&r(`${o}.nodeIndexPath`,"nodeIndexPath must contain non-negative integers"),O(a.sourceMeshName)||r(`${o}.sourceMeshName`,"sourceMeshName is required")}}function nx(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(Xf(e.transform,`${t}.transform`,r),Uf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Uf(o,`${t}.childOutlines.${n}`,r)}}function ox(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}Jf(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function ax(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}Jf(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function Jf(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function Fi(e,t){let r=UT(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
+ ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function Xf(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Nt(e.position,`${t}.position`,r),Nt(e.rotation,`${t}.rotation`,r),Nt(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Nt(e.scale,`${t}.scale`,r)}}function ix(e,t,r){if(!M(e)){r(t,"marker must be an object");return}Dr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&lx(e.color,`${t}.color`,r),e.target!=null&&Md(e.target,`${t}.target`,r),e.semanticFrame!=null&&cx(e.semanticFrame,`${t}.semanticFrame`,r),dx(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function sx(e,t,r,n,o,a){if(!M(e))return;let i=[];e.target!=null&&i.push({value:e.target,path:`${o}.target`}),M(e.geometry)&&e.geometry.target!=null&&i.push({value:e.geometry.target,path:`${o}.geometry.target`});for(let s of i)M(s.value)&&(s.value.kind!=="scene-object"&&s.value.kind!=="marker"&&a(`${s.path}.kind`,"runtime marker target kind must be scene-object or marker"),O(s.value.id)&&(s.value.id===t?a(`${s.path}.id`,"runtime marker target must not reference its marker node"):r.has(s.value.id)?s.value.kind==="marker"&&!n.has(s.value.id)?a(`${s.path}.id`,`runtime marker target must reference a marker node: ${s.value.id}`):s.value.kind==="scene-object"&&n.has(s.value.id)&&a(`${s.path}.id`,`runtime scene-object target must not reference a marker node: ${s.value.id}`):a(`${s.path}.id`,`runtime marker target must reference scene.nodes: ${s.value.id}`)))}function Md(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}Dr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function cx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}Dr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Nt(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Nt(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function dx(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){Dr(e,["kind"],t,r);return}if(e.kind==="point"){Dr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Nt(e.position,`${t}.position`,r),e.offset!=null&&Nt(e.offset,`${t}.offset`,r),e.target!=null&&Md(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){Dr(e,["kind","target"],t,r),Md(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Dr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Nt(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function lx(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}Dr(e,["r","g","b"],t,r);for(let n of["r","g","b"])Yf(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Dr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Nt(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function ux(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function We(e){return typeof e=="number"&&Number.isFinite(e)}function en(e){return We(e)&&e>0}function Yf(e){return We(e)&&e>=0&&e<=1}function Ni(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"color component must be a finite number")}}function mx(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!en(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!en(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Nt(e.targetOffset,`${t}.targetOffset`,r),ux(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!en(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!Yf(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),en(e.minZ)&&en(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),We(e.lowerBetaLimit)&&We(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),en(e.lowerRadiusLimit)&&en(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function fx(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===kT&&t.compilerVersion===OT}function px(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?gx(e,t):e;try{Un(o,t)}catch(a){let i=a;r(typeof i.path=="string"?i.path:t,typeof i.reason=="string"?i.reason:typeof i.message=="string"?i.message:"light does not satisfy the Engine Runtime Light contract")}}function gx(e,t){let r={...e,schemaVersion:1};if(e.type!=="directional"||!M(e.direction))return r;let{x:n,y:o,z:a}=e.direction;if(![n,o,a].every(s=>typeof s=="number"&&Number.isFinite(s)))return r;let i=Math.hypot(n,o,a);return i<=0||Math.abs(i-1)>RT?r:{...r,direction:Xo(e.direction,`${t}.direction`)}}function Uf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),Ni(e.outlineColor,`${t}.outlineColor`,r)}}function bx(e,t,r){if(e==null){r(t,"groundDecal is required when transformType is groundDecal");return}if(!M(e)){r(t,"groundDecal must be an object");return}Sx(e,t,r)}function Sx(e,t,r){if(O(e.uiKind)||r(`${t}.uiKind`,"groundDecal UI kind must be non-empty"),!M(e.size))r(`${t}.size`,"groundDecal.size must be an object");else for(let n of["width","depth"])(typeof e.size[n]!="number"||!Number.isFinite(e.size[n])||e.size[n]<=0)&&r(`${t}.size.${n}`,"groundDecal size must be a positive finite number");if(e.aspectSourceLayerId!=null&&!O(e.aspectSourceLayerId)&&r(`${t}.aspectSourceLayerId`,"aspectSourceLayerId must be non-empty when present"),e.lockAspectToBorder!=null&&typeof e.lockAspectToBorder!="boolean"&&r(`${t}.lockAspectToBorder`,"lockAspectToBorder must be boolean when present"),e.editorPreviewActive!=null&&r(`${t}.editorPreviewActive`,"editorPreviewActive is editor-only and must not appear in runtime scene data"),yx(e.mask,`${t}.mask`,r),hx(e.rendering,`${t}.rendering`,r),!Array.isArray(e.layers)){r(`${t}.layers`,"groundDecal UI layers must be an array");return}e.layers.forEach((n,o)=>Ex(n,`${t}.layers[${o}]`,r)),Ix(e.layers,`${t}.layers`,r)}function yx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI mask must be an object");return}e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"mask.enabled must be boolean"),e.source!=null&&e.source!=="roundedRect"&&e.source!=="borderAlpha"&&e.source!=="texture"&&r(`${t}.source`,"mask.source must be roundedRect, borderAlpha, or texture"),e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"mask.textureId must be non-empty when present");for(let n of["cornerRadius","padding"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)&&r(`${t}.${n}`,`${n} must be a non-negative finite number`)}}function hx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI rendering must be an object");return}for(let n of["textureWidth","textureHeight"])e[n]!=null&&(!Number.isInteger(e[n])||e[n]<=0)&&r(`${t}.${n}`,`${n} must be a positive integer`);for(let n of["alphaIndex","diffuseTextureLevel","emissiveTextureLevel"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`${n} must be a finite number`)}}function Ex(e,t,r){if(!M(e)){r(t,"groundDecal UI layer must be an object");return}O(e.id)||r(`${t}.id`,"layer.id must be non-empty"),O(e.role)||r(`${t}.role`,"layer.role must be non-empty"),e.editorPreviewPercent!=null&&r(`${t}.editorPreviewPercent`,"editorPreviewPercent is editor-only and must not appear in runtime scene data"),e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"layer.enabled must be boolean"),(typeof e.zOrder!="number"||!Number.isFinite(e.zOrder))&&r(`${t}.zOrder`,"layer.zOrder must be a finite number"),e.opacity!=null&&(typeof e.opacity!="number"||!Number.isFinite(e.opacity))&&r(`${t}.opacity`,"layer.opacity must be finite"),e.rotationDeg!=null&&(typeof e.rotationDeg!="number"||!Number.isFinite(e.rotationDeg)||e.rotationDeg<=-180||e.rotationDeg>180)&&r(`${t}.rotationDeg`,"layer.rotationDeg must be in the range (-180, 180]"),Px(e.rect,`${t}.rect`,r),e.kind==="texture"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture layer imageFit must be contain or stretch"),Jn(e.tint,`${t}.tint`,r)):e.kind==="textureProgress"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture progress layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture progress layer imageFit must be contain or stretch"),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"texture progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"texture progress direction is invalid"),Jn(e.tint,`${t}.tint`,r)):e.kind==="color"?Jn(e.color,`${t}.color`,r):e.kind==="progress"?((typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"progress direction is invalid"),Jn(e.color,`${t}.color`,r)):e.kind==="text"?Tx(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function Ix(e,t,r){let n=new Map;e.forEach((o,a)=>{if(!M(o)||!O(o.id))return;let i=n.get(o.id);if(i!=null){r(`${t}[${a}].id`,`layer.id must be unique; duplicate of layers[${i}]`);return}n.set(o.id,a)})}function Px(e,t,r){if(!M(e)){r(t,"layer.rect must be an object");return}for(let n of["x","z","width","depth"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`rect.${n} must be a finite number`);for(let n of["width","depth"])typeof e[n]=="number"&&e[n]<=0&&r(`${t}.${n}`,`rect.${n} must be positive`)}function Tx(e,t,r){if(!M(e)){r(t,"text layer text must be an object");return}typeof e.value!="string"&&r(`${t}.value`,"text.value must be a string"),e.fontFamily!=null&&typeof e.fontFamily!="string"&&r(`${t}.fontFamily`,"fontFamily must be a string"),e.fontSize!=null&&(typeof e.fontSize!="number"||!Number.isFinite(e.fontSize)||e.fontSize<=0)&&r(`${t}.fontSize`,"fontSize must be a positive finite number"),e.fontWeight!=null&&typeof e.fontWeight!="string"&&r(`${t}.fontWeight`,"fontWeight must be a string"),Jn(e.color,`${t}.color`,r),Jn(e.strokeColor,`${t}.strokeColor`,r),e.strokeWidth!=null&&(typeof e.strokeWidth!="number"||!Number.isFinite(e.strokeWidth)||e.strokeWidth<0)&&r(`${t}.strokeWidth`,"strokeWidth must be a non-negative finite number")}function Jn(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`color.${n} must be finite`);e.a!=null&&(typeof e.a!="number"||!Number.isFinite(e.a))&&r(`${t}.a`,"color.a must be finite")}}function xx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Kf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Zf(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&Ni(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?Zf(o,a,r):r(a,`${n} must be an object`))}}function Hf(e,t,r){let n=JSON.stringify(e),o=$T.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function Ax(e,t,r){let n=Qf(e)??512,o=Qf(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function _i(e){let t=e.rendering?.textureWidth??512,r=e.rendering?.textureHeight??512,n=e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:t/r;return Ax(t,r,n)}function Qf(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function ep(e,t){let r=kd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!ir(e,s))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=ir(e,s);if(!c)return J("missing-node");if(!op(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):$i();let o=ir(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>rp(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!np(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=wd(e,o.id).filter(c=>!n.includes(c));return t.beforeId&&!s.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!s.includes(t.afterId)?J("invalid-after-anchor"):$i()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=ir(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=wd(e,o.parentId??null).filter(s=>!n.includes(s));return t.beforeId&&!i.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!i.includes(t.afterId)?J("invalid-after-anchor"):t.placement==="before"&&t.beforeId!==o.id?J("invalid-before-anchor"):t.placement==="after"&&t.afterId!==o.id?J("invalid-after-anchor"):$i()}function tp(e,t){let r=kd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!ir(e,i))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=ir(e,i);if(!s)return J("missing-node");if(!op(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=ir(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!np(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||rp(e,o.id,i)))return J("cannot-parent-to-descendant");let a=wd(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=ir(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return $i()}function ir(e,t){return t?e.find(r=>r.id===t)??null:null}function kd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function St(e,t){let r=kd(t).filter(o=>!!ir(e,o)),n=new Set(r);return r.filter(o=>!Dx(e,o).some(a=>n.has(a)))}function wd(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function rp(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function np(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function op(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function Dx(e,t){let r=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,a=r.get(t)??null;for(;a?.parentId&&!o.has(a.parentId);)o.add(a.parentId),n.push(a.parentId),a=r.get(a.parentId)??null;return n}function $i(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var yt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),tn={kind:"texture"},ap={kind:"color"},Mx={kind:"enum",values:["lit","unlit"]},wx={kind:"enum",values:["opaque","mask","blend"]},cp={lightingModel:Mx,baseColor:{kind:"object",properties:{color:ap,texture:tn,brightness:yt(0),saturation:yt(0),contrast:yt(0),hue:yt(-180,180)}},normal:{kind:"object",properties:{texture:tn,strength:yt(0)}},emission:{kind:"object",properties:{color:ap,intensity:yt(0),texture:tn,maskTexture:tn}},alpha:{kind:"object",properties:{mode:wx,opacity:yt(0,1),cutoff:yt(0,1),texture:tn}}},kx={kind:"object",properties:{...cp,metallic:yt(0,1),roughness:yt(0,1),metallicRoughness:{kind:"object",properties:{texture:tn}},occlusion:{kind:"object",properties:{texture:tn,strength:yt(0)}}}},Ox={kind:"object",properties:cp},Rx={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Cx={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},ip=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],rn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},dp=[Yn("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Yn("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Zn("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),ht("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Xn("properties.baseColor.texture.textureAssetId","baseTexture")]}),Zn("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[rn]),ht("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[rn,Xn("properties.normal.texture.textureAssetId","normalTexture")]}),Yn("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),ht("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Zn("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Yn("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),ht("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),ht("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Zn("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],vx=[...dp,ht("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[rn]}),ht("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[rn]}),Zn("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[rn]),Zn("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[rn]),ht("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[rn,Xn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Gx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:kx,defaultProperties:Rx,inspector:{sections:ip,fields:vx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Ox,defaultProperties:Cx,inspector:{sections:ip,fields:dp}}],Mr=jx(Gx);function jx(e){let t=new Map;for(let n of e){Fx(n,t);let o=_x(n);t.set(n.shaderId,mp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Rd(e,t=Mr){return t.get(e)}function De(e){return Rd(e)}function Nx(e,t,r=Mr){let n=vd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function Qn(e,t,r=Mr){let n=Rd(e,r);if(!n)return null;let o=Nx(e,t,r),i=(o?.schemaPath??vd(t)).replace(/^properties\./,"").split(".").filter(Boolean);if(i.length===0)return null;let s=n.propertiesSchema;for(let c=0;c<i.length;c+=1){let d=i[c];if(s.kind==="texture"&&c===i.length-1&&(d==="url"||d==="textureAssetId"))return{kind:"string",nullable:!0};if(s.kind!=="object")return null;let u=s.properties[d];if(!u)return null;s=u}return o?.control==="texture"&&s.kind==="texture"?{kind:"string",nullable:!0}:s}function Cd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function eo(e,t,r="properties",n=Mr){let o=Rd(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return Gd(o.propertiesSchema,t,r,a),a}function Yn(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function ht(e,t,r,n,o,a,i={}){return Yn(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Zn(e,t,r,n,o,a,i,s){return Yn(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Xn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Fx(e,t){if(!Wn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Lx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);lp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(Gd(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);$x(e,a),o.add(a.path)}}function _x(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=up(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function $x(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=up(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function lp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))lp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function Lx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function vd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function up(e,t){let r=vd(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function Gd(e,t,r,n){if(e.kind==="object"){if(!Od(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&Gd(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];sp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){sp(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!Od(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function sp(e,t,r,n,o){if(!Od(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mp(t)}return e}function Od(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function to(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Bx(n));for(let n of ea(e)){let o=r.get(n.type)??null;r.set(n.type,Vx(o,n))}return[...r.values()]}function Nd(e){return structuredClone(e)}function Bx(e){return{...Nd(e),metadata:{...e.metadata??{},builtIn:!0}}}function Vx(e,t){let r=e??null;return{...r??{},...Nd(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function Ux(e,t,r={}){if(!bp(t)||$d(t.type,r))return e;let n=ea(e);return n.some(o=>o.type===t.type)?e:_d(e,[...n,Fd(t,!1)])}function Kx(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=$d(o,n),i=ea(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=Fd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return _d(e,[...i.filter(u=>u.type!==o),d])}function Hx(e,t,r={}){let n=t.trim();if(!n||Sp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=ea(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:_d(e,a)}function Fd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function ea(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(Wx).filter(r=>!!r):[]}function _d(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(Nd),{...e,metadata:Object.keys(r).length>0?r:void 0}}function Wx(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim()?null:Fd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(r=>typeof r=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0)}function bp(e){return!!e.type.trim()&&!!e.label.trim()}function $d(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function Sp(e,t={}){return!!$d(e,t)}function sr(e){let{spatial:t,...r}=structuredClone(e);return r}function Li(e){return structuredClone(e)}function yp(e,t){return{...Li(e),from:fp(e.from,t),to:fp(e.to,t)}}function hp(e,t){return{...sr(e),...e.target?{target:jd(e.target,t)}:{},geometry:qx(e.geometry,t)}}function qx(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:jd(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:jd(e.target,t)};case"box":case"polyhedron":return structuredClone(e)}}function jd(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function fp(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function Ep(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function Ld(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function ta(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function zd(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function pp(e,t){return e.kind==="marker"&&e.id===t}function cr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(sr),relations:e.relations.map(Li),...r?{metadata:structuredClone(r)}:{}}}function Bd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function Jx(e,t){let r=sr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function Xx(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,sr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function Yx(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!pp(r.from,t)&&!pp(r.to,t))}}function gp(e,t){let r=Li(t),n=e.relations.some(o=>o.id===r.id);return{...e,relations:n?e.relations.map(o=>o.id===r.id?r:o):[...e.relations,r]}}function Zx(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{...Li(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function Ip(e,t,r={}){switch(t.type){case"marker.create-box":return Jx(e,t.marker);case"marker.update":return Xx(e,t.markerId,t.patch);case"marker.delete":return Yx(e,t.markerId);case"relation.create":return gp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>gp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return Zx(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return Ux(e,t.definition,r);case"marker-type.update":return Kx(e,t.typeId,t.patch,r);case"marker-type.delete":return Hx(e,t.typeId,r)}}function Pp(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=sr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=Qx(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=tA(n.label||n.id,a)),{...t,marker:n}}function Qx(e,t,r){let o=(r??eA)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function eA(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function tA(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function Tp(e,t,r,n={}){switch(t.type){case"marker.create-box":return rA(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&nA(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return bp(t.definition)&&!to(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&to(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Sp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&ea(r).some(a=>a.type===o)}default:return!0}}function rA(e,t){switch(t.kind){case"box":case"point":return!0;case"object-bounds":return ta(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function nA(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function xp(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Ap(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function Vd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=sr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function ra(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Dp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var zi="summary",Mp="body";function Et(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function oA(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Vi(e){let t=Cp(e);return t&&aA(t)?{mode:"matrix",matrix:t}:null}function wp(e){return tt(e)?{mode:"matrix",matrix:Xd(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:Bi(e.position),rotation:Bi(e.rotation),scale:Bi(e.scale)}}function tt(e){return e.mode==="matrix"}function It(e){return e.mode!=="matrix"}function Ui(e){return tt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:Bi(e.position)}function aA(e){return!!Cp(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!kp(e)}function Fe(e){if(tt(e))return Xd(e.matrix);let t=iA(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,S=o*c,g=a*i,b=a*s,y=a*c,I=e.scale.x,E=e.scale.y,T=e.scale.z;return[(1-(m+S))*I,(u+y)*I,(l-b)*I,0,(u-y)*E,(1-(d+S))*E,(f+g)*E,0,(l+b)*T,(f-g)*T,(1-(d+m))*T,0,e.position.x,e.position.y,e.position.z,1]}function Wd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function kp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=t*i-r*a,I=t*s-n*a,E=t*c-o*a,T=r*s-n*i,A=r*c-o*i,$=n*c-o*s,z=d*S-u*f,p=d*g-l*f,D=d*b-m*f,h=u*g-l*S,R=u*b-m*S,K=l*b-m*g,ne=y*K-I*R+E*h+T*D-A*p+$*z;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let F=1/ne;return[(i*K-s*R+c*h)*F,(n*R-r*K-o*h)*F,(S*$-g*A+b*T)*F,(l*A-u*$-m*T)*F,(s*D-a*K-c*p)*F,(t*K-n*D+o*p)*F,(g*E-f*$-b*I)*F,(d*$-l*E+m*I)*F,(a*R-i*D+c*z)*F,(r*D-t*R-o*z)*F,(f*A-S*E+b*y)*F,(u*E-d*A-m*y)*F,(i*p-a*h-s*z)*F,(t*h-r*p+n*z)*F,(S*I-f*T-g*y)*F,(d*T-u*I+l*y)*F]}function qd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Ud(e[0],e[1],e[2]),y:Ud(e[4],e[5],e[6]),z:Ud(e[8],e[9],e[10])};if(lA(e)<=0&&(r.y*=-1),!Hd(t)||!Hd(r)||Math.abs(r.x)<1e-6||Math.abs(r.y)<1e-6||Math.abs(r.z)<1e-6)return null;let n=1/r.x,o=1/r.y,a=1/r.z,i=[e[0]*n,e[1]*n,e[2]*n,0,e[4]*o,e[5]*o,e[6]*o,0,e[8]*a,e[9]*a,e[10]*a,0,0,0,0,1];if(!uA(i))return null;let s=dA(cA(i));if(!s)return null;let c=sA(s);if(!Hd(c))return null;let d={position:t,rotation:c,scale:r};return na(Fe(d),e,1e-5)?d:null}function Jd(e,t={}){let r=qd(e);return r||(t.allowMatrixFallback?Vi(e):null)}function Op(e){let t=oA();for(let r of e)t=Wd(Fe(r),t);return Jd(t,{allowMatrixFallback:!0})}function Rp(e,t){return Jd(Wd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function ro(e,t,r={}){let n=kp(Fe(e));return n?Jd(Wd(Fe(t),n),r):null}function na(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function Xd(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function Cp(e){return e.length!==16||!e.every(Number.isFinite)?null:Xd(e)}function Bi(e){return{x:e.x,y:e.y,z:e.z}}function iA(e){let t=e.z*.5,r=e.x*.5,n=e.y*.5,o=Math.sin(t),a=Math.cos(t),i=Math.sin(r),s=Math.cos(r),c=Math.sin(n),d=Math.cos(n);return{x:d*i*a+c*s*o,y:c*s*a-d*i*o,z:d*s*o-c*i*a,w:d*s*a+c*i*o}}function sA(e){let t=e.z,r=e.x,n=e.y,o=e.w,a=n*t-r*o,i=.4999999;if(a<-i)return{x:Math.PI/2,y:2*Math.atan2(n,o),z:0};if(a>i)return{x:-Math.PI/2,y:2*Math.atan2(n,o),z:0};let s=o*o,c=t*t,d=r*r,u=n*n;return{z:Math.atan2(2*(r*n+t*o),-c-d+u+s),x:Math.asin(-2*a),y:Math.atan2(2*(t*r+n*o),c-d-u+s)}}function cA(e){let t=e[0],r=e[4],n=e[8],o=e[1],a=e[5],i=e[9],s=e[2],c=e[6],d=e[10],u=t+a+d;if(u>0){let m=.5/Math.sqrt(u+1);return{w:.25/m,x:(c-i)*m,y:(n-s)*m,z:(o-r)*m}}if(t>a&&t>d){let m=2*Math.sqrt(1+t-a-d);return{w:(c-i)/m,x:.25*m,y:(r+o)/m,z:(n+s)/m}}if(a>d){let m=2*Math.sqrt(1+a-t-d);return{w:(n-s)/m,x:(r+o)/m,y:.25*m,z:(i+c)/m}}let l=2*Math.sqrt(1+d-t-a);return{w:(o-r)/l,x:(n+s)/l,y:(i+c)/l,z:.25*l}}function dA(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);return!Number.isFinite(t)||t<1e-6?null:{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}function lA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=l*b-g*m,I=u*b-S*m,E=u*g-S*l,T=d*b-f*m,A=d*g-l*f,$=d*S-f*u,z=+(i*y-s*I+c*E),p=-(a*y-s*T+c*A),D=+(a*I-i*T+c*$),h=-(a*E-i*A+s*$);return t*z+r*p+n*D+o*h}function Ud(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function uA(e){let t={x:e[0],y:e[1],z:e[2]},r={x:e[4],y:e[5],z:e[6]},n={x:e[8],y:e[9],z:e[10]};return Math.abs(Kd(t,r))<1e-6&&Math.abs(Kd(t,n))<1e-6&&Math.abs(Kd(r,n))<1e-6}function Kd(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Hd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var mA={supportsShear:!1,supportsMatrixTransform:!1};function Ki(e={}){let t={...mA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function nn(e){return e==null||typeof e=="string"}function on(e){return e==null||typeof e=="string"&&e.trim().length>0}function Hi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Wi(e){return e==null||typeof e=="boolean"}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function qi(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function oa(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function Ft(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function _t(e){return w(e)&&e>0}function aa(e){return w(e)&&e>=0}function Ji(e){return w(e)&&e>=0&&e<=1}function Xi(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!qe(t.position)||t.rotation!==void 0&&!qe(t.rotation)||t.rotationDeg!==void 0&&!qe(t.rotationDeg)||t.scale!==void 0&&!oa(t.scale))}function Yi(e){return e==="orthographic"||e==="perspective"}function Zi(e){return e==="hemispheric"||e==="directional"}var $t=["group","instance","transform","primitive"],vp=["instance","transform","primitive"],fA=["position","rotation","scale"],pA=["x","y","z"];function gA(e){return{path:`transform.${e}`,appliesTo:$t,validate:t=>t==null||(e==="scale"?oa(t):qe(t))}}function bA(e,t){return{path:`transform.${e}.${t}`,appliesTo:$t,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?aa(r):w(r))}}function SA(e){return[gA(e),...pA.map(t=>bA(e,t))]}var Yd=[{path:"name",appliesTo:$t,validate:nn},{path:"parentId",appliesTo:$t,validate:nn},{path:"enabled",appliesTo:$t,validate:Wi},{path:"shadow.cast",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:$t,validate:e=>e==null||Xi(e)},...fA.flatMap(SA),{path:"transform.rotationDeg",appliesTo:$t,validate:e=>e==null||qe(e)},{path:"transform.rotationDeg.x",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:$t,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:Yi,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||qe(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:Ji,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||qi(e)},{path:"camera.targetScreenOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetScreenOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.type",appliesTo:["transform"],validate:Zi,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:aa,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:qe,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.type",appliesTo:["transform"],validate:nn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:on},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Hi(e)},{path:"marker.note",appliesTo:["transform"],validate:nn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var ie=["instance","transform","primitive"];function Je(e){return{path:e,appliesTo:ie,validate:t=>t==null||Ft(t)}}function V(e){return{path:e,appliesTo:ie,validate:t=>t==null||w(t)}}function Gp(e){return{path:e,appliesTo:ie,validate:t=>t==null||typeof t=="boolean"}}function le(e){return{path:e,appliesTo:ie,validate:on}}function hA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function EA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="lit"||t==="unlit"}}var IA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:ie,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:ie,validate:e=>e==null||w(e)},Je("overrides.material.albedoColor"),Je("overrides.material.diffuseColor"),Je("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Gp("overrides.material.backFaceCulling"),le("overrides.material.albedoTexture.url"),le("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),le("overrides.material.metallicTexture.url"),le("overrides.material.occlusionTexture.url"),le("overrides.material.emissiveTexture.url"),le("overrides.material.opacityTexture.url"),Je("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Je("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Je("overrides.material.pbr.emissiveColor"),Je("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Je("overrides.material.standard.diffuseColor"),Je("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Je("overrides.material.standard.emissiveColor"),Je("overrides.material.standard.ambientColor"),Gp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:ie,validate:on},EA("overrides.materialBinding.override.lightingModel"),Je("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},le("overrides.materialBinding.override.baseColor.texture.url"),le("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),le("overrides.materialBinding.override.normal.texture.url"),le("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),le("overrides.materialBinding.override.metallicRoughness.texture.url"),le("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),le("overrides.materialBinding.override.occlusion.texture.url"),le("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Je("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),le("overrides.materialBinding.override.emission.texture.url"),le("overrides.materialBinding.override.emission.texture.textureAssetId"),le("overrides.materialBinding.override.emission.maskTexture.url"),le("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),hA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),le("overrides.materialBinding.override.alpha.texture.url"),le("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:ie,validate:e=>e==null||PA(e)},{path:"overrides.outline.strategy",appliesTo:ie,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:ie,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:ie,validate:e=>e==null||Ft(e)},{path:"overrides.outline.outlineColor.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1}],jp=[...Yd,...IA];function PA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||Ft(t.outlineColor))}function Zd(e,t){let r=jp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var dr="scene.materialAssets.",Qd="__fps_duplicate_material_asset__:",TA="mat_";function xA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function lr(e){let t=xA(e);return`${TA}${t||"material"}`}function el(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Np(e){let t=String(e??"").trim()||"material",r=[0,1,2,3].map(n=>AA(`${t}\0${n}`)).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-4${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20,32)}`}function AA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Fp(e,t=dr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function wr(e){return e==="overrides.materialBinding.materialAssetId"||Lt(e,"materialAssetId")!=null}function tl(e){if(wr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return Qi(`properties.${e.slice(t.length)}`);let r=DA(e);return r?Qi(`properties.${r}`):!1}function es(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||Lt(e,"materialAssetId")!=null||Lt(e,"override")!=null}function Lt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function DA(e){let t="overrides.materialSlotBindings.";if(!e.startsWith(t))return null;let r=e.slice(t.length),n=".override.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return a&&i?i:null}function Qi(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function no(e,t){if(!De(e)||!Qi(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return Qn(e,r)?.kind==="texture"}function rt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(Qi(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function zt(e,t,r,n=Mr){let o=rt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=MA(e,r,n);return a?wA(a,o):!1}function MA(e,t,r){if(t!=null)return Qn(t,e,r);for(let n of r.list()){let o=Qn(n.shaderId,e,r);if(o)return o}return null}function wA(e,t){if(t==null)return e.kind==="texture"||e.kind==="string"&&e.nullable===!0;if(e.kind==="number")return!(!w(t)||e.min!=null&&t<e.min||e.max!=null&&t>e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"&&t.trim().length>0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return e.channels===4?OA(t):kA(t);if(e.kind==="vec2"||e.kind==="vec3"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t,n=e.kind==="vec2"?["x","y"]:["x","y","z"];return Object.keys(r).every(o=>n.includes(o))&&n.every(o=>w(r[o]))}if(e.kind==="texture"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t;return Object.keys(r).every(n=>n==="url"||n==="textureAssetId")&&["url","textureAssetId"].every(n=>r[n]===void 0||typeof r[n]=="string"&&r[n].trim().length>0)}return!1}function ts(e){return typeof e!="string"||!e.startsWith(Qd)?null:e.slice(Qd.length).trim()||null}function _p(e){return e.trim().replace(/^\/+|\/+$/g,"")}function kA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b")&&w(t.r)&&w(t.g)&&w(t.b)}function OA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b"||r==="a")&&w(t.r)&&w(t.g)&&w(t.b)&&w(t.a)}var RA={r:.78,g:.78,b:.78};function Bt(e,t={}){let r=e??{},n=GA(r.baseColor?.texture,t),o=vA(r,t),a=CA(r,t);return{kind:"material-sphere",baseColor:jA(r),metallic:ia(r.metallic??0),roughness:ia(r.roughness??1),...r.emission?.color?{emissionColor:zp(r.emission.color)}:{},emissionIntensity:NA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function CA(e,t){return[["baseColor",e.baseColor?.texture],["normal",e.normal?.texture],["metallicRoughness",e.metallicRoughness?.texture],["occlusion",e.occlusion?.texture],["emission",e.emission?.texture],["emissionMask",e.emission?.maskTexture],["alpha",e.alpha?.texture]].flatMap(([n,o])=>{let a=rl(o,t);return a?[{channel:n,...a}]:[]})}function vA(e,t){let r=structuredClone(e),n=an(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=an(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=an(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=an(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=an(r.emission?.texture,t),c=an(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=an(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function an(e,t){if(!e)return;let r=rl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function GA(e,t){let r=rl(e,t);return r?.state==="ready"?r.url:void 0}function rl(e,t){let r=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";if(r){let o=t.resolveTextureAssetUrl?.(r)?.trim();if(o)return{reference:r,state:"ready",url:o};let a=t.textureAssets?.find(i=>i.id===r)?.url?.trim();if(a)return{reference:r,state:"ready",url:a};if(t.resolveTextureAssetUrl||Array.isArray(t.textureAssets))return{reference:r,state:"missing"}}let n=typeof e?.url=="string"?e.url.trim():"";return n?{reference:r||n,state:"ready",url:n}:null}function Lp(e,t){let r=e??{},n=$p(r.metallic??0),o=$p(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function jA(e){let r=(e.baseColor??{}).color??RA;return zp(r)}function zp(e){return{r:ia(e.r),g:ia(e.g),b:ia(e.b)}}function ia(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function $p(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function NA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Vt(e,t){return!!ee(e,t)}function Jp(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function sa(e,t){let r=new Set;for(let n of nl(e,t))r.add(n.gameObjectId);return[...r]}function nl(e,t){let r=t.trim();return r?ca(e).filter(n=>n.materialAssetId===r):[]}function ca(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=UA(n),a=rs(n.overrides?.materialBinding);a&&t.push({kind:"root",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:a,bindingPath:"overrides.materialBinding.materialAssetId",label:o});let i=kr(e,n,r),s=new Map(i.filter(d=>!!d.slotId).map(d=>[d.slotId,d])),c=n.overrides?.materialSlotBindings??{};for(let[d,u]of Object.entries(c)){let l=rs(u);if(!l)continue;let m=s.get(d),f=KA(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Ut(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){Bp(t,{ownerId:n.id,ownerName:n.displayName??n.id,prefabAssetId:n.id,path:`assets.${n.id}.prefab.overrides`,overrides:n.prefab.overrides});for(let o of n.prefab.nodes??[])Bp(t,{ownerId:`${n.id}:${o.id}`,ownerName:`${n.displayName??n.id} / ${o.name??o.id}`,prefabAssetId:n.id,prefabNodeId:o.id,path:`assets.${n.id}.prefab.nodes.${o.id}.overrides`,overrides:o.overrides})}return t}function Bp(e,t){let r=rs(t.overrides?.materialBinding);r&&e.push({kind:"root",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:r,bindingPath:`${t.path}.materialBinding.materialAssetId`,label:t.ownerName,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}});for(let[n,o]of Object.entries(t.overrides?.materialSlotBindings??{})){let a=rs(o);a&&e.push({kind:"slot",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:a,bindingPath:`${t.path}.materialSlotBindings.${n}.materialAssetId`,label:`${t.ownerName} / ${n}`,slotId:n,ownerNodePath:n,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}})}}function os(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=ca(e),o=n.filter(s=>!r.has(s.materialAssetId)),a=new Map;for(let s of o){let c=a.get(s.materialAssetId)??[];c.push(s),a.set(s.materialAssetId,c)}let i=[...a.entries()].map(([s,c])=>({kind:"missing-material-asset",materialAssetId:s,usages:c}));return{ok:i.length===0,materialAssetIds:t,references:n,missingMaterialAssetIds:i.map(s=>s.materialAssetId),missingReferences:o,issues:i}}function kr(e,t,r){let n=new Map;for(let o of is(e,t,r))n.set(o.slotId,o);return[...n.values()].sort((o,a)=>(o.label??o.slotId).localeCompare(a.label??a.slotId)||o.slotId.localeCompare(a.slotId))}function Xp(e,t){return is(e,t).length>0}function nt(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Ut(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function Yp(e){return e.slotId}function as(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function ol(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function Zp(e){let t=Qp(e);if(!t)return;let r={},n=VA(t.materialAssetId);return n&&(r.materialAssetId=n),t.override&&typeof t.override=="object"&&!Array.isArray(t.override)&&(r.override=t.override),Object.keys(r).length>0?r:void 0}function is(e,t,r){let n=Se(t);if(!n)return[];let a=(r?.get(n.assetId)??e.assets.find(s=>s.id===n.assetId))?.metadata?.materialSlots;if(!Array.isArray(a))return[];let i=[];for(let s of a){let c=Or(s);c&&i.push(c)}return i}function Or(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.slotId=="string"&&t.slotId.trim()?t.slotId.trim():"",n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces:null,o=FA(n);if(!r||!n||o.length===0||o.length!==n.length)return null;let a=typeof t.label=="string"&&t.label.trim()?t.label.trim():o[0].ownerNodePath,i=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",s=Array.isArray(t.materialNames)?t.materialNames.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim()):void 0,c=$A(t.sourceMaterialProfiles);return{slotId:r,label:a,sourceSurfaces:o,...i?{materialName:i}:{},...s&&s.length>0?{materialNames:s}:{},...c&&c.length>0?{sourceMaterialProfiles:c}:{}}}function FA(e){return Array.isArray(e)?e.flatMap(t=>{let r=Qp(t);if(!r)return[];let n=_p(typeof r.ownerNodePath=="string"?r.ownerNodePath:""),o=Number.isInteger(r.meshIndex)&&r.meshIndex>=0?r.meshIndex:void 0,a=Number.isInteger(r.primitiveIndex)&&r.primitiveIndex>=0?r.primitiveIndex:void 0;if(!n||o==null||a==null)return[];let i=Number.isInteger(r.nodeIndex)&&r.nodeIndex>=0?r.nodeIndex:void 0,s=Array.isArray(r.nodeIndexPath)?r.nodeIndexPath.filter(m=>Number.isInteger(m)&&m>=0):void 0,c=Number.isInteger(r.sourceMaterialIndex)&&r.sourceMaterialIndex>=0?r.sourceMaterialIndex:void 0,d=typeof r.sourceMeshName=="string"&&r.sourceMeshName.trim()?r.sourceMeshName.trim():void 0,u=typeof r.triangleCount=="number"&&Number.isFinite(r.triangleCount)&&r.triangleCount>=0?r.triangleCount:void 0,l=_A(r.boundingBox);return[{ownerNodePath:n,...i!=null?{nodeIndex:i}:{},...s&&s.length>0?{nodeIndexPath:s}:{},meshIndex:o,primitiveIndex:a,...c!=null?{sourceMaterialIndex:c}:{},...d?{sourceMeshName:d}:{},...u!=null?{triangleCount:u}:{},...l?{boundingBox:l}:{}}]}):[]}function _A(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Vp(t.min),n=Vp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Vp(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return typeof t=="number"&&Number.isFinite(t)&&typeof r=="number"&&Number.isFinite(r)&&typeof n=="number"&&Number.isFinite(n)?[t,r,n]:null}function $A(e){if(!Array.isArray(e))return;let t=e.map(LA).filter(r=>!!r);return t.length>0?t:void 0}function LA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!Number.isInteger(t.sourceMaterialIndex))return null;let r=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",n=t.profile&&typeof t.profile=="object"&&!Array.isArray(t.profile)?t.profile:void 0,o=zA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function zA(e){if(!Array.isArray(e))return;let t=e.map(BA).filter(r=>!!r);return t.length>0?t:void 0}function BA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.profilePath=="string"&&t.profilePath.trim()?t.profilePath.trim():"",n=typeof t.reason=="string"&&t.reason.trim()?t.reason.trim():"";return!r||!n?null:{profilePath:r,reason:n,...Number.isInteger(t.textureIndex)?{textureIndex:t.textureIndex}:{},...Number.isInteger(t.imageIndex)?{imageIndex:t.imageIndex}:{},...Number.isInteger(t.bufferView)?{bufferView:t.bufferView}:{},...typeof t.mimeType=="string"&&t.mimeType.trim()?{mimeType:t.mimeType.trim()}:{},...typeof t.uri=="string"&&t.uri.trim()?{uri:t.uri.trim()}:{}}}function Qp(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function VA(e){return typeof e=="string"&&e.trim()?e.trim():null}function UA(e){return e.name?.trim()||e.id}function rs(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function KA(e,t){return e?.label?.trim()||Ut(e)?.trim()||e?.slotId?.trim()||t}var ns=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of ca(t)){let n=this.byMaterialId.get(r.materialAssetId)??[];n.push(r),this.byMaterialId.set(r.materialAssetId,n);let o=this.byOwnerId.get(r.gameObjectId)??[];o.push(r),this.byOwnerId.set(r.gameObjectId,o)}}forMaterial(t){return this.byMaterialId.get(t.trim())??[]}forOwner(t){return this.byOwnerId.get(t)??[]}},Up=new WeakMap;function HA(e){let t=Up.get(e);return t||(t=new ns(e),Up.set(e,t)),t}function al(e){return e?.system?.preset}function Kp(e,t){let r=al(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Hp(e,t){let r=al(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function WA(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Wp(e.document,r.id,e.ownershipText,t):null,a=r?Hp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?qp(a,o):a;return{pickerKind:"material",pickerTitle:e.pickerText.materialPickerTitle,pickerTrigger:"preview",placeholder:e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.inheritNone,...r?{currentMaterialAssetId:r.id,currentMaterialShaderId:r.shaderId,...r.definitionVersion!=null?{currentMaterialDefinitionVersion:r.definitionVersion}:{}}:{},currentLabel:r?Kp(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Bt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Wp(e.document,s.id,e.ownershipText,t);return{label:Kp(s,e.displayText),value:s.id,meta:qp(Hp(s,e.displayText),c),kind:"material",preview:Bt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Wp(e,t,r,n){if(!e||!n)return null;let o=t.trim(),a=n.forMaterial(o),i=a.length;return{materialAssetId:o,usage:{count:i,items:a.map(s=>structuredClone(s))},usageCount:i,used:i>0,shared:i>1,...r?{usageLabel:r.formatUsageCount(i),editImpactLabel:r.formatEditImpact(i),duplicateImpactLabel:r.formatDuplicateImpact(i)}:{}}}function qp(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function qA(e,t,r={}){return(e.scene.materialAssets??[]).map(n=>{let o=t.forMaterial(n.id);return{id:`material:${n.id}`,assetId:n.id,kind:"material",label:n.name||n.id,meta:Lp(n.properties,n.id),preview:Bt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||al(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var JA={createUsageIndex(e){return new ns(e)},getCachedUsageIndex:HA,createPickerControlOptions:WA,createBrowserAssetItems:qA},_e=JA;var sn=1;var sl="prefab.";function la(e){let t=structuredClone(e),r={ordinaryObjects:0,prefabRoots:0,discardedFields:0},n=$e(t.scene);return n&&(Me(n,"shadowMapExperiment",r),Array.isArray(n.gameObjects)&&n.gameObjects.forEach(o=>XA(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>YA(o,r)),{document:t,summary:r}}function dn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function XA(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),dn(r)?(r.shadow=tg(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function YA(e,t){let r=$e(e);if(!r)return;let n=$e(r.defaults);n&&(Me(n,"shadowMode",t),Me(n,"shadow",t),Me(n,"shadowMapExperiment",t));let o=$e(r.prefab);if(!o)return;let a=$e(o.defaults);a&&Me(a,"shadowMode",t),o.defaults={...a??{},shadow:tg(a?.shadow)},t.prefabRoots+=1;let i=$e(o.defaults);if(Me(i,"shadowMapExperiment",t),Array.isArray(o.nodes))for(let s of o.nodes){let c=$e(s);if(!c)continue;Me(c,"shadowMode",t),Me(c,"shadow",t),Me(c,"shadowMapExperiment",t);let d=$e(c.defaults);d&&(Me(d,"shadowMode",t),Me(d,"shadow",t),Me(d,"shadowMapExperiment",t))}}function tg(e){let t=$e(e);return{cast:t?.cast==="enabled"?"enabled":"none",receive:t?.receive==="enabled"?"enabled":"none"}}function Me(e,t,r){Object.prototype.hasOwnProperty.call(e,t)&&(delete e[t],r.discardedFields+=1)}function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var HF=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(tD)??null}function Se(e){return e.components.find(rD)??null}function Rr(e){return e.components.find(nD)??null}function Xe(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Xe(r)?r:null}function ss(e){return te(e?.prefab?.prefabId)!=null}function da(e){return te(e?.prefab?.sourceAssetId)}function Ye(e){if(!e?.prefab)return null;let t=dl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Ze(e){return e?.prefab?dl(e.prefab):[]}function oo(e,t){let r=te(t);return r?Ze(e).find(n=>n.id===r)??null:null}function cl(e,t){let r=te(t);return Ze(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function rg(e){if(!Xe(e))return il(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=dl(e.prefab),r=Ye(e);if(e.prefab.compositionVersion!==sn||t.length===0||!r)return il(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${sn} with an explicit root node.`,assetId:e.id}]);let n=ZA(e);return il(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function il(e,t,r=null,n=[],o={}){return{ok:n.every(a=>a.severity!=="error"),changed:t,prefabAsset:e,...o.selectedNodeId?{selectedNodeId:o.selectedNodeId}:{},...o.createdNodeId?{createdNodeId:o.createdNodeId}:{},...o.deletedNodeIds?{deletedNodeIds:[...o.deletedNodeIds]}:{},...r?{node:structuredClone(r)}:{},diagnostics:n.map(a=>({...a}))}}function ZA(e){let t=structuredClone(e),r=Ze(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=sn,t.prefab.nodes=r;let n=Ye({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function dl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=QA(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function QA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!eD(t.kind)?null:{id:r,...te(t.guid)?{guid:te(t.guid)}:{},...te(t.name)?{name:te(t.name)}:{},...te(t.parentId)?{parentId:te(t.parentId)}:{},kind:t.kind,...t.transform?{transform:structuredClone(t.transform)}:{},...te(t.sourceAssetId)?{sourceAssetId:te(t.sourceAssetId)}:{},...te(t.sourceNodePath)?{sourceNodePath:te(t.sourceNodePath)}:{},...te(t.childPrefabId)?{childPrefabId:te(t.childPrefabId)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.light?{light:structuredClone(t.light)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults?{defaults:structuredClone(t.defaults)}:{},...t.overrides?{overrides:structuredClone(t.overrides)}:{},...t.metadata?{metadata:structuredClone(t.metadata)}:{}}}function eD(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function ng(e){let t=da(e.prefabAsset);if(!t)throw new Error(`Prefab asset "${e.prefabAsset.id}" does not define a source asset.`);let r=e.prefabAsset.prefab?.defaults;return{id:e.id,...e.guid?{guid:e.guid}:{},name:e.name??e.prefabAsset.displayName??e.prefabAsset.id,kind:"instance",...e.parentId?{parentId:e.parentId}:{},active:e.active??r?.active??!0,prefab:{prefabId:e.prefabAsset.id,...e.prefabAsset.guid?{prefabGuid:e.prefabAsset.guid}:{},sourceAssetId:t},...e.metadata?{metadata:{...e.metadata}}:{},...e.overrides!==void 0?{overrides:e.overrides}:{},components:[e.transform,{type:"ModelRenderer",assetId:t}]}}function og(e){if(!e.startsWith(sl))return null;let t=e.slice(sl.length);return es(t)?t:null}function ll(e){return og(e)?.endsWith(".materialAssetId")===!0}function ag(e){return e.startsWith(sl)&&e.endsWith(".materialAssetId")&&ll(e)}function ig(e,t){if(t.slotId)return Zp(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function ua(e,t,r){let n=og(t);if(!n||!Xe(e))return e;let o=aD(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),sD(a.prefab,o,r);let i=ug(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function sg(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=Ad(e?.override,t?.override);return ml({...n??r?{materialAssetId:n??r}:{},...cn(o)?{override:o}:{}})}function cs(e,t){let r={},n=sg(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=dD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ds(e,t){let r=ln(e,t);if(!(!r.gameObject||!r.prefab))return cs(r.definition?.prefab?.overrides,lD(r.gameObject.overrides))}function ln(e,t){let r=typeof t=="string"?oD(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=ss(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Xe(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=da(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Xe(u)&&da(u)===s).map(u=>u.id);d.length>1&&o.push({code:"duplicate-source-prefab",severity:"info",message:`Source asset "${s}" is referenced by ${d.length} prefab definitions.`,prefabId:a.prefabId,sourceAssetId:s})}return{gameObject:r,prefab:a,definition:i??null,sourceAsset:c??null,diagnostics:o}}function Y(e){return e.kind==="group"||e.kind==="instance"||e.kind==="transform"||e.kind==="primitive"?e.kind:ss(e)?"instance":e.primitive?"primitive":Se(e)?"instance":Rr(e)||e.transformType?"transform":"group"}function cg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=ul(t?.renderingGroupId),n=lg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function ul(e){return e===0||e===1||e===2||e===3?e:null}function dg(e){return lg(e)}function tD(e){return e.type==="Transform"}function rD(e){return e.type==="ModelRenderer"}function nD(e){return e.type==="ImageRenderer"}function lg(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function te(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function oD(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function aD(e){if(e==="overrides.materialBinding.materialAssetId")return["overrides","materialBinding","materialAssetId"];let t="overrides.materialBinding.override.";if(e.startsWith(t)){let o=e.slice(t.length);return eg(["overrides","materialBinding","override"],o)}let r=Lt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=Lt(e,"override");if(n){let o=iD(e);return o?eg(["overrides","materialSlotBindings",n,"override"],o):null}return null}function iD(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function eg(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(mg)?null:[...e,...r]}function sD(e,t,r){if(t.some(mg))return;let n=e;for(let a of t.slice(0,-1)){let i=n[a];(!i||typeof i!="object"||Array.isArray(i))&&(n[a]={}),n=n[a]}let o=t[t.length-1];o&&(r==null?delete n[o]:n[o]=structuredClone(r))}function ug(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=ml(t.materialBinding);n&&(r.materialBinding=n);let o=cD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ml(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=Ad(t.override),o={...r?{materialAssetId:r}:{},...cn(n)?{override:n}:{}};return cn(o)?o:void 0}function cD(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[r,n]of Object.entries(e)){let o=te(r);if(!o)continue;let a=ml(n);a&&(t[o]=a)}return cn(t)?t:void 0}function dD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=sg(e?.[o],t?.[o]);a&&(n[o]=a)}return cn(n)?n:void 0}function lD(e){return ug(e)}function cn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function mg(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var uD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function fg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&N("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))uD.has(s)||N("schema.invalidValue",`${r}.${s}`);ma(e.parentId)||N("schema.invalidReference",`${r}.parentId`),gD(e.transform,`${r}.transform`),mD(e.marker,`${r}.marker`);let n=ma(e.id),o=e.marker,a=fD(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&N("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&N("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&N("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&N("schema.invalidReference",`${s.path}.kind`))}}function mD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&N("schema.unsupportedVersion",`${t}.schemaVersion`),ma(r.type)||N("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!ma(r.kind)&&N("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&yD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&N("schema.invalidType",`${t}.note`),r.color!==void 0&&SD(r.color,`${t}.color`),r.target!==void 0&&fl(r.target,`${t}.target`),r.semanticFrame!==void 0&&bD(r.semanticFrame,`${t}.semanticFrame`),pD(r.geometry,`${t}.geometry`),r.metadata!==void 0&&hD(r.metadata,`${t}.metadata`)}function fD(e,t){let r=[];return e.target&&r.push({target:e.target,path:`${t}.target`}),e.geometry.kind==="point"&&e.geometry.target&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),e.geometry.kind==="object-bounds"&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),r}function pD(e,t){let r=vr(e);if(r||N("schema.invalidType",t),r.kind==="box"){Pt(r,["kind"],t);return}if(r.kind==="point"){Pt(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&N("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Cr(r.position,`${t}.position`),r.offset!==void 0&&Cr(r.offset,`${t}.offset`),r.target!==void 0&&fl(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){Pt(r,["kind","target"],t),fl(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){Pt(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&N("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||N("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Cr(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||N("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||N("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&N("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}N("schema.invalidValue",`${t}.kind`)}function fl(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&N("schema.invalidValue",`${t}.kind`),ma(r.id)||N("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&N("schema.invalidType",`${t}.label`)}function gD(e,t){let r=vr(e);if(r||N("schema.invalidType",t),r.type!=="Transform"&&N("schema.invalidValue",`${t}.type`),r.mode==="matrix"){Pt(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&N("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>ls(n,`${t}.matrix[${o}]`));return}Pt(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&N("schema.invalidValue",`${t}.mode`),Cr(r.position,`${t}.position`),Cr(r.rotation,`${t}.rotation`),r.scale!==void 0&&Cr(r.scale,`${t}.scale`)}function bD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["origin","forward","right","up","label","description"],t),Cr(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Cr(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&N("schema.invalidType",`${t}.${n}`)}function SD(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["r","g","b"],t);for(let n of["r","g","b"])ls(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&N("schema.invalidValue",`${t}.${n}`)}function Cr(e,t){let r=vr(e);r||N("schema.invalidType",t),Pt(r,["x","y","z"],t);for(let n of["x","y","z"])ls(r[n],`${t}.${n}`)}function yD(e,t){Array.isArray(e)||N("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&N("schema.invalidType",`${t}[${n}]`)})}function hD(e,t){let r=vr(e);r||N("schema.invalidType",t),pl(r,t,new Set)}function pl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){ls(e,t);return}(!e||typeof e!="object")&&N("schema.invalidType",t),r.has(e)&&N("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&N("schema.invalidType",t):n!==Object.prototype&&n!==null&&N("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>pl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))pl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function Pt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||N("schema.invalidValue",`${r}.${o}`)}function ls(e,t){(typeof e!="number"||!Number.isFinite(e))&&N("schema.invalidValue",t)}function vr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ma(e){return typeof e=="string"&&e.trim()?e.trim():null}function N(e,t){throw new Error(`${e}: ${t}`)}function ao(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${ED(t)}`}function ED(e){return encodeURIComponent(e)}function gl(e,t){return{...structuredClone(e),id:ao(t,e.id)}}function fa(e,t){let r=structuredClone(e);return r.target&&(r.target=gl(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=gl(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=gl(r.geometry.target,t)),r}function B(e,t){if(pg(e))try{return e[t]}catch{return}}function ce(e,t){let r=B(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=B(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=B(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=B(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Kt(e){if(!pg(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=B(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function un(e){let t=Kt(e),r=ce(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function pg(e){return!!e&&(typeof e=="object"||typeof e=="function")}function us(e,t=new WeakSet,r=0){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?ID(e):"[NonFiniteNumber]";if(typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e!="object")return String(e);if(t.has(e))return"[Circular]";if(r>6)return"[MaxDepth]";if(t.add(e),Array.isArray(e))return e.map(a=>us(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=us(B(n,a),t,r+1);return o}function ID(e){return Math.round(e*1e6)/1e6}function Gr(e){let t=e.properties.filter(r=>!!r).map((r,n)=>r.order==null?{...r,order:n}:r);return t.length===0&&e.omitWhenEmpty!==!1?null:{id:e.id,title:e.title,order:e.order,placement:"body",summary:e.summary,persistence:e.persistence??(e.runtimeOnly?"runtime":"readonly"),runtimeOnly:e.runtimeOnly,effect:e.effect??(e.runtimeOnly?"runtime":void 0),disabledReason:e.disabledReason,collapsedByDefault:e.collapsedByDefault,tags:e.tags,properties:t}}function j(e){if(!PD(e.value))return null;let t=us(e.value);return{path:e.path,label:e.label,valueType:e.valueType??TD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:AD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??xD(e.source,e.persistence),disabledReason:e.disabledReason}}function bl(e,t){let r=j(t);r&&e.push(r)}function io(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Sl(e){let t=mn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function mn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function PD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function TD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function xD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function AD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function pa(e){let t=e.projectedRoot??e.root??null,r=bg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:Sg(t),meshes:r,primaryMesh:n,material:DD(t)}}function ms(e){let t=we(e,"getHierarchyBoundingVectors"),r=mn(B(t,"min")),n=mn(B(t,"max"));if(r&&n)return gg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=mn(B(a,"minimumWorld")),s=mn(B(a,"maximumWorld"));return i&&s?gg(i,s):null}function bg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return yg(e)&&r.unshift(e),[...new Set(r)]}function Sg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function yg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(e,"getBoundingInfo")=="function")}function fs(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function so(e,t){let r=B(e,t);return Array.isArray(r)?r.length:0}function ps(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function yl(e){let t=we(e,"isEnabled");return typeof t=="boolean"?t:null}function ga(e,t){let r=re(e,t);if(r!=null)return r;let n=we(e,"getParam",[t]);return typeof n=="number"&&Number.isFinite(n)?n:null}function gg(e,t){return{min:e,max:t,center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2},size:{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}}function DD(e){let t=B(e,"material");if(t)return t;let r=we(e,"getChildMeshes",[!1]);if(Array.isArray(r)){let n=r.find(o=>!!B(o,"material"));if(n)return B(n,"material")}return null}var bs={x:-.3,y:-1,z:-.2},hg=-180,Eg=180,ba=-90,Sa=90;function ya(e,t=bs){let r=e&&kD(e)?e:t,n=Math.hypot(r.x,r.y,r.z);if(!Number.isFinite(n)||n<=1e-6){let o=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/o,y:t.y/o,z:t.z/o}}return{x:r.x/n,y:r.y/n,z:r.z/n}}function El(e,t){let r=jr(ys(e)),n=jr(Dg(t,ba,Sa)),o=Math.cos(n);return{x:hl(o*Math.cos(r)),y:hl(-Math.sin(n)),z:hl(o*Math.sin(r))}}function Il(e){if(!hs(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=xg({direction:e.light.direction,rotation:r}),o=El(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:jr(n.elevationAngleDeg),y:jr(n.horizontalAngleDeg),z:co(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function Ig(e,t){if(!hs(e.light))return e;let r=Il(e);if(!r)return e;let n=co(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=co(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=El(n,o),i={...r.rotation,x:jr(o),y:jr(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function MD(e,t=bs){let{horizontalAngleDeg:r,elevationAngleDeg:n}=xg({direction:t,rotation:e});return El(r,n)}function wD(e,t){let r=Tg(e);return{x:jr(r.elevationAngleDeg),y:jr(r.horizontalAngleDeg),z:co(t?.z)?t.z:0}}function lo(e){if(!hs(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=MD(t.rotation,e.light.direction);return Ag(r,ya(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function Ss(e){if(!hs(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=wD(e.light.direction,t.rotation);return Ag(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function Pg(e){let t=ya(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function ys(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function kD(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.z=="number"&&Number.isFinite(e.z)}function hs(e){return e?.type==="directional"}function Tg(e){let t=ya(e);return{horizontalAngleDeg:ys(gs(Math.atan2(t.z,t.x))),elevationAngleDeg:gs(Math.asin(Dg(-t.y,-1,1)))}}function xg(e){let t=Tg(e.direction);return{horizontalAngleDeg:co(e.rotation?.y)?gs(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:co(e.rotation?.x)?gs(e.rotation.x):t.elevationAngleDeg}}function co(e){return typeof e=="number"&&Number.isFinite(e)}function Ag(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function gs(e){return e*180/Math.PI}function jr(e){return e*Math.PI/180}function hl(e){return Math.round(e*1e6)/1e6}function Dg(e,t,r){return Math.min(r,Math.max(t,e))}var fn="light.directionHorizontalAngleDeg",pn="light.directionElevationAngleDeg";function uo(e){return e===fn||e===pn}function Mg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=OD(t);return r==null?t:e===fn?Math.round(ys(r)):e===pn?Math.round(RD(r,ba,Sa)):t}function OD(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function RD(e,t,r){return Math.min(r,Math.max(t,e))}function gn(e){return t=>mo({...e,value:t})}function mo(e){let t=CD(e);if(t)return t;let r=Zd(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function bn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?wg(t):t}function Es(e,t,r={}){if((r.isDirectionalLightAnglePath??kg)(e))return Mg(e,t);if(e==="marker.type"&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return GD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return tl(e)&&typeof t=="string"?wg(t):bn(e,t)}function Pl(e){return t=>vD(t,e)}function CD(e){for(let t of e.extraValidators??[]){let r=t({path:e.path,nodeKind:e.nodeKind,value:e.value,document:e.document});if(r)return r}return null}function vD(e,t){if(e.path==="camera.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: camera.inspectorLanguage."};if(e.path==="light.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: light.inspectorLanguage."};if((t.isDirectionalLightAnglePath??kg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(wr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(wr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(tl(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function wg(e){let t=e.trim();return t||null}function GD(e){let r=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>typeof n=="string"?n.trim():"").filter((n,o,a)=>n.length>0&&a.indexOf(n)===o);return r.length>0?r:null}function kg(e){return e===fn||e===pn}function ha(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:gn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function ot(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Tt(e){return e*180/Math.PI}function Ht(e){return e*Math.PI/180}function at(e){return Math.round(e*1e6)/1e6}var Og={zh:{title:"\u6444\u50CF\u673A",summaryOrthographic:"ArcRotate \u6B63\u4EA4",summaryPerspective:"ArcRotate \u900F\u89C6",language:"\u8BED\u8A00",projection:"\u6295\u5F71\u6A21\u5F0F",projectionOrthographic:"\u6B63\u4EA4",projectionPerspective:"\u900F\u89C6",alpha:"Alpha",beta:"Beta",radius:"\u534A\u5F84",orthoSize:"\u6B63\u4EA4\u5C3A\u5BF8",fov:"\u89C6\u91CE\u89D2\u5EA6",targetOffset:"\u76EE\u6807\u504F\u79FB",nearClip:"\u8FD1\u88C1\u526A",farClip:"\u8FDC\u88C1\u526A",minBeta:"\u6700\u5C0F Beta",maxBeta:"\u6700\u5927 Beta",minRadius:"\u6700\u5C0F\u534A\u5F84",maxRadius:"\u6700\u5927\u534A\u5F84",inertia:"\u60EF\u6027",screenOffset:"\u5C4F\u5E55\u504F\u79FB",rawCamera:"\u539F\u59CB\u6444\u50CF\u673A"},en:{title:"Camera",summaryOrthographic:"ArcRotate Orthographic",summaryPerspective:"ArcRotate Perspective",language:"Language",projection:"Projection",projectionOrthographic:"Orthographic",projectionPerspective:"Perspective",alpha:"Alpha",beta:"Beta",radius:"Radius",orthoSize:"Ortho Size",fov:"FOV",targetOffset:"Target Offset",nearClip:"Near Clip",farClip:"Far Clip",minBeta:"Min Beta",maxBeta:"Max Beta",minRadius:"Min Radius",maxRadius:"Max Radius",inertia:"Inertia",screenOffset:"Screen Offset",rawCamera:"Raw Camera"}},Rg=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function Tl(e){return Og[e]??Og.zh}function jD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function Cg(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=Tl(a),s=[],c=0;s.push(r(null,n,{path:"camera.inspectorLanguage",label:i.language,valueType:"enum",control:"enum",value:a,commitMode:"immediate",order:c,options:Rg,controlOptions:{variant:"segmented"}})),c+=1,s.push(r(null,n,{path:"camera.projection",label:i.projection,valueType:"enum",control:"enum",value:o.projection??"orthographic",commitMode:"immediate",order:c,options:jD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:at(Tt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Ht(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return bl(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function xl(e){let t=Tl(e.rig.inspectorLanguage??"zh");return{id:"camera",title:t.title,order:42,placement:"body",summary:e.rig.projection==="perspective"?t.summaryPerspective:t.summaryOrthographic,persistence:"document",collapsedByDefault:!1,properties:Cg(e)}}function ze(e,t,r){return t(null,e,{path:r.path,label:r.label,valueType:"number",control:"number",value:r.value,commitMode:"live",order:r.order,min:r.min,max:r.max,step:r.step??.05,coerce:r.coerce})}var Is="scene.main",Ps="scene";function Wt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||Is,sourceType:t?.sourceType||Ps,revision:typeof t?.revision=="number"?t.revision:1}}function vg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Is,sourceType:Ps,revision:t.revision??1}}}}function Gg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Is,sourceType:Ps,revision:(t.revision??0)+1}}}}function jg(e,t){let r=Wt(e),n=ND(t),o=r.revision??null;if(!n)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:null,reason:"missing-generated-from"};let a=typeof n.revision=="number"?n.revision:null;return n.sourceId!==r.sourceId||n.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"source-mismatch"}:o!==a?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a}}function ND(e){if(!e||typeof e!="object")return null;let t=e.meta;if(!t||typeof t!="object")return null;let r=t.generatedFrom;if(!r||typeof r!="object")return null;let n=r.sourceId,o=r.sourceType;return typeof n!="string"||typeof o!="string"?null:{sourceId:n,sourceType:o,revision:typeof r.revision=="number"?r.revision:void 0}}var FD="sun_light";function Ts(e){let t=_D(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function _D(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function $D(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=He(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function LD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=As(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...Al(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;He(n.shadow).shadow?.receive==="enabled"&&VD(t,{receiverId:n.id,source:"explicit",score:100,...Al(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function xs(e){let t=e.caster?.id===e.casterId?e.caster:As(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:Ei(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=He(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():$D(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?dd(n.settings,e.fallbackMode??"none"):"none",i=ld(n.settings,e.fallbackQuality??"medium"),s=Ei(i,n.settings?.params),c=zD(a),d=UD(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?KD(e.document,t.id,d):{candidates:LD({document:e.document,casterId:t.id,explicitReceiverIds:d.length>0?d:void 0}),diagnostics:[]};r.push(...u.diagnostics);let l=u.candidates;c!=="none"&&l.length===0&&r.push({code:"shadow.receiverNotFound",severity:"warning",message:`No shadow receiver was found for caster "${t.id}".`,casterId:t.id});let m=c==="none"?null:BD(e.document,n.settings??void 0,e.defaultLightId);return m?.diagnostic&&r.push(m.diagnostic),{casterId:t.id,receiverIds:l.map(f=>f.receiverId),...m?.lightId?{lightId:m.lightId}:{},backend:c,mode:a,quality:i,params:s,diagnostics:r}}function zD(e){return e==="dynamic"?"dynamic-map":e==="static"?"static-baked":e==="blob"?"blob":e==="projected"?"projected":"none"}function BD(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&Ng(e,a)?{lightId:a}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:a?`Explicit shadow light "${a}" was not found.`:"Shadow light mode is explicit, but no lightId was configured.",...a?{lightId:a}:{}}}}let n=r??FD;if(Ng(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Fg(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function Ng(e,t){let r=As(e,t);return!!r&&r.active!==!1&&Fg(r)}function Fg(e){return Y(e)==="transform"&&e.light?.type==="directional"}function VD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function UD(e){let t=new Set,r=[];for(let n of e??[]){let o=typeof n=="string"?n.trim():"";!o||t.has(o)||(t.add(o),r.push(o))}return r}function KD(e,t,r){let n=[],o=[];for(let a of r){let i=As(e,a);if(!i){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" was not found.`,casterId:t,receiverId:a,details:{source:"explicit"}});continue}if(i.id===t){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Shadow caster "${t}" cannot be used as its own receiver.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"self"}});continue}if(i.active===!1){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" is inactive.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"inactive"}});continue}n.push({receiverId:i.id,source:"explicit",score:120,...Al(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function Al(e,t,r,n){let o=He(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function As(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var HD="main_camera",WD="environment_light",qD="sun_light";function Dl(e){return Y(e)==="group"}function xt(e){return!!G(e)}function At(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function fo(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Dt(e){return e.id===HD||e.id===WD||e.id===qD||At(e)||fo(e)}function Ml(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Dt(r)}var Nr="root",JD="go_",wl="GameObject";function ue(e){return e===Nr}function Z(e){return ue(e.id)}function Ol(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=YD(o,t);return r=r||a!==o,a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function he(){let e=globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${JD}${e}`}function it(e,t){let r=new Set(e),n=Ds(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function _g(e,t=wl){return kl(e)??kl(t)??wl}function st(e,t,r={}){let n=_g(t,r.fallbackName??wl),o=new Set(e.map(s=>kl(s)).filter(s=>!!s));if(!r.alwaysAppendSuffix&&!o.has(n))return n;let a=1,i=`${n}_${a}`;for(;o.has(i);)a+=1,i=`${n}_${a}`;return i}function kl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function Ds(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function XD(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function YD(e,t){let r=XD(e);if(r&&!t.has(r))return t.add(r),r===e.guid?e:{...e,guid:r};let n=he();for(;t.has(n);)n=he();return t.add(n),{...e,guid:n}}var Fr=Et();function ke(e,t){if(ue(t))return Et();let r=_(e,t);if(!r)return null;let n=[],o=Rl(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return Op(n.map(qt))}function _(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Rl(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ur(e,t,r,n){let o=t?ke(e,t):Et();return o?ro(o,r,n):null}function Ea(e,t,r,n={}){let o=Ki(n);return ur(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function qt(e){return Z(e)?Et():go(e)}function Ia(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=go(r),o=!!G(r)&&!QD(n,Fr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=$g(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Nr||!G(s))return s;let d=Rp(n,go(s));if(!d)return s;let u=Cl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function $g(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return ws(s)&&po(s.position,Fr.position)&&po(s.rotation,Fr.rotation)&&po(Lg(s,"scale"),Fr.scale)?i:(n=!0,Ms())});if(r||(n=!0,o.unshift(Ms())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function Ms(){return Mt(Fr)}function go(e){let t=G(e);return t?Ee(t)?Vi(t.matrix)??Et():{position:{...t.position},rotation:{...t.rotation},scale:{...Lg(t,"scale")}}:Et()}function Cl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:mr(t)??r)}}function mr(e){let t=Sn(e);return t?tt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function Sn(e){return tt(e)?Vi(e.matrix):wp(e)}function Mt(e){let t=mr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function ws(e){return e.mode!=="matrix"}function Lg(e,t){return ZD(e)?t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]:t==="scale"?{x:1,y:1,z:1}:{x:0,y:0,z:0}}function ZD(e){return!!e.position&&!!e.rotation}function QD(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):po(e.position,t.position)&&po(e.rotation,t.rotation)&&po(e.scale,t.scale)}function po(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function ye(e){return e.scene.gameObjects.find(t=>t.id===Nr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function ks(e,t){return ue(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function vl(e,t){return!t||t===Nr?!1:!!_(e,t)}function fr(e){let t=ye(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Nr).map(n=>{let o=Dt(n),a=xt(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,eM(r,n)-(t?1:0)),role:a&&Dl(n)?"group":"object",...ss(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&tM(r,n.parentId,t),directEnabled:i,canToggleEnabled:!o,enableToggleDisabledReason:o?"Protected system objects cannot be hidden from Hierarchy.":void 0,protected:o,canHaveChildren:!o&&a,renamable:!o,deletable:!o,draggable:!o}})}function eM(e,t){let r=new Set,n=0,o=t.parentId??null;for(;o;){if(r.has(o))return n;r.add(o);let a=e.get(o);if(!a)return n;n+=1,o=a.parentId??null}return n}function tM(e,t,r){let n=new Set,o=t??null;for(;o;){if(n.has(o))return!0;n.add(o);let a=e.get(o);if(!a)return!0;if(a.id!==r&&a.active===!1)return!1;o=a.parentId??null}return!0}function Gl(e){let t=Ia(e,{normalizeRootActive:!0}),r=ye(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=qt(s),d=o?ro(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:Mt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function pr(e,t){return[...wt(e,t)]}function wt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Fl(e){let t=[zg(e)],r=Vg(e);r&&t.push(r);let n=Hg(e);n&&t.push(n);let o=Jg(e);o&&t.push(o);let a=Zg(e);a&&t.push(a);let i=oM(e);i&&t.push(i);let s=eb(e);s&&t.push(s);let c=tb(e);c&&t.push(c);let d=nb(e);return d&&t.push(d),t}function zg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:Cs(e),persistence:"document",collapsedByDefault:!1,properties:Bg(e)}}function Bg(e){let{document:t,gameObject:r}=e,n=Cs(e),o=[Qe("id","ID",r.id,0),Jt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Jt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),Qe("kind.resolved","Resolved Kind",n,3),Qe("kind.explicit","Explicit Kind",r.kind??"inferred",4),Qe("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Jt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??Ta})):o.push(Qe("common.transformType","Transform Type",r.transformType??"none",6)),o}function Vg(e){return Gr({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Ug(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Kg(e)})}function Ug(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Kg(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?_(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(pr(t,[r.id]).length-1,0),s=Wt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Hg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:qg(e),persistence:"document",collapsedByDefault:!1,properties:Wg(e)}:null}function Wg(e){if(!G(e.gameObject))return[];let r=Cs(e),n=Z(e.gameObject),o=n?e.rootTransform??Et():go(e.gameObject);if(tt(o))return rM(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=mM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?at(Tt(d[u])):d[u];n?i.push(Qe(l,`${Nl(c)}.${u}`,m,s)):i.push(Jt(e,{document:null,path:l,label:`${a?`Local ${Nl(c)}`:Nl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!tt(c))for(let d of["x","y","z"])i.push(Qe(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function qg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;if(Z(e.gameObject))return"Identity Root";let r=G(e.gameObject);return r&&Ee(r)?"Matrix Transform":`Relative to: ${t?t.name??t.id:"Scene"}`}function rM(e,t){if(!tt(e))return[];let r=[Qe("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(Qe(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(Os).join(", "),n)),n+=1;let o=qd(e.matrix);return r.push(Qe("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${jl(o.position)}`,`R ${jl({x:Tt(o.rotation.x),y:Tt(o.rotation.y),z:Tt(o.rotation.z)})}`,`S ${jl(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function Jg(e){let t=Se(e.gameObject),r=Rr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:Yg(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?nM(e,r):Xg(e)}:null}function nM(e,t){let r=Pa(e.document,t.assetId);return[Qe("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),Qe("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),Qe("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function Xg(e){let t=Se(e.gameObject);if(!t)return[];let{document:r}=e,n=Pa(r,t.assetId),o=[Jt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function Yg(e,t){let r=Pa(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function Zg(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:Qg(e)}:null}function Qg(e){let t=e.gameObject.primitive;return t?[Jt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??fM})]:[]}function oM(e){if(e.gameObject.prefab)return aM(e);if(!bo(e))return null;let t=He(e.gameObject.shadow).shadow,r=Jt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Jt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=Rs(e.renderingProfile),a=e.renderingProfile!==void 0&&Ts(o)==="none";return{id:"shadow",title:"\u9634\u5F71",order:34,placement:"body",...a?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[r,n,...a?[_l()]:[]]}}function aM(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=He(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[io({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function _l(){return{path:"rendering.shadows.open",label:"\u6253\u5F00 Rendering / Shadows",valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:"\u6253\u5F00 Rendering / Shadows",icon:"world"},value:"\u6253\u5F00 Rendering / Shadows",readOnly:!0,persistence:"readonly",commitMode:"immediate",order:2,tags:["Rendering"],effect:"active"}}function Rs(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function eb(e){if(!iM(e))return null;let t=Rs(e.renderingProfile),r=sM(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=cM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:dM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Jt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Jt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:lM(n,o)})]}}function tb(e){return Gr({id:"components",title:"Scripts / Components",order:65,summary:$l(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:rb(e.gameObject)})}function $l(e){return e.components.map(t=>t.type).join(", ")||"none"}function rb(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:$l(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function nb(e){let t=e.assetId??Se(e.gameObject)?.assetId??Rr(e.gameObject)?.assetId??null,r=ob({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:ab({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function ob(e){let t=[],r=e.assetId?Pa(e.document,e.assetId):null;return oe(t,{path:"metadata.document",label:"Document Meta",value:e.document.meta??"none",order:0,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.gameObject",label:"GameObject Metadata",value:e.gameObject.metadata??"none",order:1,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.asset",label:"Asset Metadata",value:r?.metadata??"none",order:2,source:"Asset",tags:["Raw"]}),t}function ab(e){let t=e.assetId?Pa(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Jt(e,t,r=Cs(e)){let{document:n,...o}=t;return ha({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function Qe(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Cs(e){return e.nodeKind??Y(e.gameObject)}function bo(e){let t=e.gameObject;return Z(t)?!1:dn(t)}function iM(e){let t=e.gameObject;if(Z(t)||t.transformType==="camera"||t.transformType==="light"||t.camera||t.light)return!1;let r=e.nodeKind??Y(t);return r==="instance"||r==="primitive"||r==="transform"}function sM(e){return e===1||e===2||e===3?e:0}function cM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function dM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${uM(e,t)}`}function lM(e,t){let r=[{label:"Babylon \u9ED8\u8BA4",value:null},...e.alphaIndexPresets.map(n=>({label:`${n.name} (${n.alphaIndex})`,value:n.alphaIndex}))];return t!=null&&!e.alphaIndexPresets.some(n=>n.alphaIndex===t)&&r.push({label:`\u672A\u547D\u540D\u503C ${t}`,value:t,batchCompatibility:"ignore"}),r}function uM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function mM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function jl(e){return`${Os(e.x)}, ${Os(e.y)}, ${Os(e.z)}`}function Os(e){return at(e).toString()}function Nl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Pa(e,t){return e.assets.find(r=>r.id===t)??null}var Ta=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],fM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function ib(e){return[db(e),lb(e.runtime),ub(e.runtime),mb(e.runtime),fb(e.runtime),pb(e.runtime),gb(e.runtime),bb(e.runtime),Sb(e.runtime),yb(e.runtime),hb(e.runtime),Eb(e.runtime),Ib(e)].filter(t=>!!t)}function Ll(e,t){if(!e.activeId)return[];let r=t.findGameObject(e.document,e.activeId);if(!r||e.targetIds&&e.targetIds.length!==1)return[];let n=pa({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return ib({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:ce(e.projectionNode,"id")??null,projectionName:ce(e.projectionNode,"name")??null,projectionParentId:ce(e.projectionNode,"parentId")??null,projectionAssetId:sb(e.projectionNode)},projectionAssetMetadata:cb(e.projectionNode)})}function sb(e){let t=B(e,"asset");return ce(t,"assetId")??ce(t,"id")}function cb(e){return B(B(e,"asset"),"metadata")}function db(e){let{binding:t,runtime:r}=e,n=[];return x(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),x(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),x(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),x(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),x(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),x(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),x(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),x(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),x(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),x(n,{path:"runtime.root.className",label:"Runtime Class",value:Kt(r.root)??"none",order:9,source:"Runtime"}),x(n,{path:"runtime.root.name",label:"Runtime Name",value:ce(r.root,"name")??"none",order:10,source:"Runtime"}),x(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:un(r.primaryMesh)??"none",order:11,source:"Derived"}),x(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:un(r.material)??"none",order:12,source:"Derived"}),x(n,{path:"runtime.material.kind",label:"Material Kind",value:Db(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?un(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function lb(e){let t=[],r=ms(e.root)??ms(e.primaryMesh);return r?(yn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),yn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),yn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),yn(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):x(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),x(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),x(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),x(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:fs(e.meshes,"getTotalVertices"),source:"Derived"}),x(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:fs(e.meshes,"getTotalIndices"),source:"Derived"}),x(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+so(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function ub(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Kt(t)??"none"}),x(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:yl(t)??"not available"}),x(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),x(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),x(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),x(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),x(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),x(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),x(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:ce(t,"name")??Kt(t)??"not available",collapsedByDefault:!0,properties:r})}function mb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),x(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),x(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),x(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),x(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof B(t,"moveWithCollisions")=="function"?"available":"not available"}),yn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),yn(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",B(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function fb(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(t,"physicsImpostor"),o=r??n,a=[];return x(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),x(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Kt(o)??"none"}),x(a,{path:"runtime.physics.bodyName",label:"Body Name",value:ce(o,"name")??ce(o,"id")??"none"}),x(a,{path:"runtime.physics.mass",label:"Mass",value:ga(o,"mass")??"not available"}),x(a,{path:"runtime.physics.friction",label:"Friction",value:ga(o,"friction")??"not available"}),x(a,{path:"runtime.physics.restitution",label:"Restitution",value:ga(o,"restitution")??"not available"}),x(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?un(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function pb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),x(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),x(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:un(B(e.material,"shadowDepthWrapper"))??"none"}),x(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function gb(e){let t=e.material,r=[];return x(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),x(r,{path:"runtime.material.className",label:"Class",value:Kt(t)??"none"}),x(r,{path:"runtime.material.name",label:"Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.material.id",label:"ID",value:ce(t,"id")??"none"}),x(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),x(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),x(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),x(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),x(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),x(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),x(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),x(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),x(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:ps(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:un(t)??"none",collapsedByDefault:!0,properties:r})}function bb(e){let t=e.material,r=[];x(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:ps(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of Mb){let a=B(t,o);a&&(n+=1,Tb(r,`runtime.material.textures.${o}`,xa(o),a))}return n===0&&x(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function Sb(e){let t=[],r=0;for(let n of wb){let o=B(e.material,n);Pb(t,`runtime.material.colors.${n}`,xa(n),o,t.length)&&(r+=1)}return r===0&&x(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function yb(e){let t=[];for(let r of kb)x(t,{path:`runtime.material.metallicRoughness.${r}`,label:xa(r),value:re(e.material,r)??"not available"});return Be({id:"metallicRoughness",title:"Metallic / Roughness",order:1e3,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function hb(e){let t=[];for(let r of Ob)x(t,{path:`runtime.material.intensity.${r}`,label:xa(r),value:re(e.material,r)??"not available"});return Be({id:"intensityProperties",title:"Intensity Properties",order:1010,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function Eb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return x(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:so(e.root,"animations"),source:"Derived"}),x(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:so(t,"animations"),source:"Derived"}),x(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),x(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Kt(r)??"none"}),x(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:ce(r,"name")??"none"}),x(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:ce(r,"id")??"none"}),x(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:so(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?ce(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function Ib(e){let{runtime:t}=e,r=[];return x(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(t.material,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),x(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return Gr({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function x(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function yn(e,t,r,n,o,a="Runtime",i){let s=Sl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&x(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function Pb(e,t,r,n,o){let a=Ab(n);return a?(x(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),x(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),x(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&x(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function Tb(e,t,r,n){let o=e.length;x(e,{path:`${t}.className`,label:`${r} Class`,value:Kt(n)??"Texture",order:o}),x(e,{path:`${t}.name`,label:`${r} Name`,value:ce(n,"name")??"none",order:o+1}),x(e,{path:`${t}.url`,label:`${r} URL`,value:xb(n)??"none",order:o+2}),x(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),x(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),x(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function xb(e){return ce(e,"url")??ce(e,"name")??ce(we(e,"getInternalTexture"),"url")}function Ab(e){if(!e||typeof e!="object")return null;let t=re(e,"r"),r=re(e,"g"),n=re(e,"b");if(t==null||r==null||n==null)return null;let o=re(e,"a");return o==null?{r:t,g:r,b:n}:{r:t,g:r,b:n,a:o}}function Db(e){let t=Kt(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function xa(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Mb=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],wb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],kb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],Ob=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var Cb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],Rb={zh:{hemisphericTitle:"\u73AF\u5883\u5149",directionalTitle:"\u76F4\u5C04\u5149",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"\u8BED\u8A00",type:"\u7C7B\u578B",typeHemispheric:"\u73AF\u5883\u5149",typeDirectional:"\u76F4\u5C04\u5149",intensity:"\u5F3A\u5EA6",skyLightColor:"\u5929\u7A7A\u5149\u989C\u8272",groundColor:"\u5730\u9762\u989C\u8272",lightColor:"\u5149\u7167\u989C\u8272",horizontalAngle:"\u6C34\u5E73\u89D2",elevationAngle:"\u9AD8\u5EA6\u89D2",shadowsTitle:"\u9634\u5F71",shadowsSummary:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",shadowSystem:"\u7CFB\u7EDF",shadowEnabled:"\u542F\u7528",shadowOpacity:"\u4E0D\u900F\u660E\u5EA6",shadowLength:"\u9634\u5F71\u957F\u5EA6",shadowFollowDirectional:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",openShadows:"\u6253\u5F00\u9634\u5F71\u8BBE\u7F6E",rawLight:"\u539F\u59CB\u5149\u6E90\u6570\u636E",tooltips:{language:"\u5207\u6362\u6B64\u5149\u6E90\u68C0\u67E5\u5668\u7684\u5C5E\u6027\u663E\u793A\u8BED\u8A00\u3002\u8BE5\u5B57\u6BB5\u53EA\u7528\u4E8E\u7F16\u8F91\u5668\uFF0C\u4E0D\u4F1A\u5BFC\u51FA\u5230\u8FD0\u884C\u65F6\u3002",type:"\u7CFB\u7EDF\u5149\u6E90\u7C7B\u578B\u53EA\u8BFB\u3002\u5BF9\u5E94 BabylonJS \u7684 HemisphericLight \u6216 DirectionalLight\u3002",intensity:"\u5149\u6E90\u5F3A\u5EA6\uFF0C\u5FC5\u987B\u662F\u975E\u8D1F\u6570\u3002BabylonJS \u4E0D\u8BBE\u7F6E\u786C\u4E0A\u9650\uFF1B\u767D\u8272\u6750\u8D28\u5728\u8F83\u9AD8\u5F3A\u5EA6\u4E0B\u901A\u5E38\u5DF2\u7ECF\u63A5\u8FD1\u663E\u793A\u9971\u548C\uFF0C\u7EE7\u7EED\u589E\u5927\u89C6\u89C9\u53D8\u5316\u4F1A\u4E0D\u660E\u663E\u3002",skyLightColor:"\u73AF\u5883\u5149\u6765\u81EA\u5929\u7A7A\u65B9\u5411\u7684\u6F2B\u53CD\u5C04\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.diffuse\u3002",groundColor:"\u73AF\u5883\u5149\u6765\u81EA\u5730\u9762\u53CD\u5C04\u65B9\u5411\u7684\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.groundColor\u3002",lightColor:"\u76F4\u5C04\u5149\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS DirectionalLight.diffuse\u3002",horizontalAngle:"\u76F4\u5C04\u5149\u5728 XZ \u5E73\u9762\u5185\u7684\u671D\u5411\u89D2\u5EA6\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",elevationAngle:"\u76F4\u5C04\u5149\u76F8\u5BF9\u5730\u5E73\u7EBF\u7684\u9AD8\u5EA6\u89D2\uFF1B90 \u5EA6\u8868\u793A\u4ECE\u6B63\u4E0A\u65B9\u7167\u4E0B\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",shadowSystem:"\u9634\u5F71\u7CFB\u7EDF\u53EA\u8BFB\u6458\u8981\u3002Planar \u9634\u5F71\u65B9\u5411\u6765\u81EA\u5F53\u524D\u76F4\u5C04\u5149\uFF0C\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowEnabled:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u662F\u5426\u542F\u7528\u3002\u8FD9\u91CC\u4EC5\u663E\u793A\u6458\u8981\uFF0C\u4E0D\u5728\u5149\u6E90 Inspector \u4E2D\u7F16\u8F91\u3002",shadowOpacity:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u4E0D\u900F\u660E\u5EA6\u3002\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowLength:"\u6839\u636E\u76F4\u5C04\u5149\u65B9\u5411\u4F30\u7B97\u7684\u5E73\u9762\u9634\u5F71\u957F\u5EA6\u500D\u7387\uFF1B\u9AD8\u5EA6\u89D2\u8D8A\u4F4E\uFF0C\u9634\u5F71\u8D8A\u957F\u3002",openShadows:"\u5207\u6362\u5230\u53F3\u4FA7 Rendering \u9762\u677F\uFF0C\u7F16\u8F91\u9879\u76EE\u7EA7\u9634\u5F71\u8BBE\u7F6E\u3002",rawLight:"\u7F16\u8F91\u5668\u6587\u6863\u4E2D\u7684\u5149\u6E90\u539F\u59CB\u6570\u636E\uFF0C\u53EA\u8BFB\u663E\u793A\u3002"}},en:{hemisphericTitle:"Environment Light",directionalTitle:"Directional Light",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"Language",type:"Type",typeHemispheric:"Environment Light",typeDirectional:"Directional Light",intensity:"Intensity",skyLightColor:"Sky Light Color",groundColor:"Ground Color",lightColor:"Light Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",shadowsTitle:"Shadows",shadowsSummary:"Planar Main / Follow Directional Light",shadowSystem:"System",shadowEnabled:"Enabled",shadowOpacity:"Opacity",shadowLength:"Shadow Length",shadowFollowDirectional:"Planar Main / Follow Directional Light",openShadows:"Open Shadows",rawLight:"Raw Light Data",tooltips:{language:"Switches the display language for this light inspector. This editor-only field is not exported to runtime.",type:"Read-only system light type. Maps to BabylonJS HemisphericLight or DirectionalLight.",intensity:"Light intensity. Must be a non-negative number. BabylonJS does not impose a hard upper limit; white surfaces often saturate at high intensity, so further increases may look subtle.",skyLightColor:"Diffuse sky color for the environment light. Maps to BabylonJS HemisphericLight.diffuse.",groundColor:"Ground bounce color for the environment light. Maps to BabylonJS HemisphericLight.groundColor.",lightColor:"Directional light color. Maps to BabylonJS DirectionalLight.diffuse.",horizontalAngle:"Directional light heading in the XZ plane. The editor converts it to BabylonJS DirectionalLight.direction.",elevationAngle:"Directional light elevation above the horizon; 90 degrees points straight down. The editor converts it to BabylonJS DirectionalLight.direction.",shadowSystem:"Read-only shadow system summary. Planar shadow direction follows this Directional Light; edit full settings in Rendering.",shadowEnabled:"Whether the project-level planar shadow system is enabled. This is summary-only in the light Inspector.",shadowOpacity:"Current project-level planar shadow opacity. Edit full settings in Rendering.",shadowLength:"Estimated planar shadow length multiplier from this light direction. Lower elevation makes longer shadows.",openShadows:"Switches the right dock to the Rendering panel for project-level shadow settings.",rawLight:"Read-only raw light data from the editor document."}}};function zl(e){return Rb[e]??Rb.zh}function Bl(e){return e.inspectorLanguage==="en"?"en":"zh"}function vb(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=Bl(n),s=zl(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:Cb,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),j({path:"light.type",label:s.type,value:n.type==="hemispheric"?s.typeHemispheric:s.typeDirectional,order:1,source:"Document",tooltip:s.tooltips.type}),t(null,o,{path:"light.intensity",label:s.intensity,valueType:"number",control:"number",value:n.intensity,commitMode:"live",order:2,min:0,step:.05,tooltip:s.tooltips.intensity})],d=3;if(n.type==="hemispheric")c.push(t(null,o,{path:"light.diffuseColor",label:s.skyLightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.skyLightColor})),d+=1,c.push(t(null,o,{path:"light.groundColor",label:s.groundColor,valueType:"color",control:"color",value:n.groundColor??e.defaultEnvironmentGroundColor??{r:.48,g:.52,b:.62},commitMode:"immediate",order:d,tooltip:s.tooltips.groundColor})),d+=1;else{let l=Il(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:fn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:hg,max:Eg,step:1,coerce:m=>a(fn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:pn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:ba,max:Sa,step:1,coerce:m=>a(pn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return gM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function Gb(e){let t=e.renderingProfile.shadows.planar;return Gr({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:at(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:SM(Pg(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),bM(e.text)]})}function Vl(e){let t=zl(Bl(e.light)),r=[{id:"light",title:e.light.type==="hemispheric"?t.hemisphericTitle:t.directionalTitle,order:44,placement:"body",summary:e.light.type==="hemispheric"?t.hemisphericSummary:t.directionalSummary,persistence:"document",collapsedByDefault:!1,properties:vb(e)}];return e.light.type==="directional"&&r.push(Gb({light:e.light,text:t,renderingProfile:pM(e.renderingProfile)})),r}function pM(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function gM(e,t){let r=j(t);r&&e.push(r)}function bM(e){return{path:"rendering.shadows.summary.open",label:e.openShadows,valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:e.openShadows,icon:"world"},value:e.openShadows,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:4,tags:["Rendering"],tooltip:e.tooltips.openShadows,effect:"active"}}function SM(e){return`x${at(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(yM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function yM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Ul(e){let t=_r(e.overrides);if(!t)return;let r=jb(t.material);r?t.material=r:delete t.material;let n=_r(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=_r(s);if(!c){delete n[i];continue}let d=jb(c.override);d?c.override=d:delete c.override,Object.keys(c).length===0&&delete n[i]}Object.keys(n).length===0&&delete t.materialSlotBindings}let o=_r(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=_r(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function jb(e){let t=_r(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=_r(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=_r(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function _r(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Fb(n,r);return JSON.stringify(o)===JSON.stringify(n)?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>a.id===t?o:a)}}}function Kl(e,t){if(t.length===0)return e;let r=new Map;for(let a of t)r.set(a.targetId,a.patch);let n=!1,o=e.scene.gameObjects.map(a=>{let i=r.get(a.id);if(!i)return a;let s=Fb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Fb(e,t){let r=Nb(e),n=hM(e,t),o=Nb(n);return r&&o&&!EM(r,o)?lo(n):n}function hM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?mr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function Nb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function EM(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function _b(e){let t=new Set(e.targetIds);if(t.size===0||!Number.isFinite(e.fromAlphaIndex)||!Number.isFinite(e.toAlphaIndex)||e.fromAlphaIndex===e.toAlphaIndex)return e.gameObjects;let r=!1,n=e.gameObjects.map(o=>!t.has(o.id)||!IM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Hl(e){let t=_b({gameObjects:e.document.scene.gameObjects,targetIds:e.targetIds,renderingGroupId:e.renderingGroupId,fromAlphaIndex:e.fromAlphaIndex,toAlphaIndex:e.toAlphaIndex});return t===e.document.scene.gameObjects?e.document:{...e.document,scene:{...e.document.scene,gameObjects:t}}}function IM(e,t){return(ul(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&dg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var Aa=it,vs=Ds;function Wl(e){let t=st(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=Aa(e.document.scene.gameObjects.map(n=>n.id),vs(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function $b(e){let t=e.scene.gameObjects.filter(r=>!!Se(r)||!!Rr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function ql(e,t){let r=t&&It(t)?t:null;return{position:r?.position?{...r.position}:$b(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Ns(e){return e.filter(t=>MM(t.kind)&&Xl(t)).map(Jl).sort(Yl)}function Ma(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(Jl).sort(Yl)}function Jl(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=En(e.guid),n=TM(e);return{id:e.assetId,...r?{guid:r}:{},assetId:e.assetId,type:t,kind:e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"model",displayName:e.displayName,category:e.category??PM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:js(e.defaults),prefab:js(e.prefab),external:js(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??DM(e.external)??e.assetId,placeable:Xl(e)}}function zb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function Xl(e){return zb(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function Yl(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function PM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function TM(e){return xM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...js(e.metadata)})}function xM(e){if(!Array.isArray(e.materialSlots))return e;let t=Gs(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Gs(c),u=Da(d?.meshIndex),l=En(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Gs(c),u=Da(d?.nodeIndex),l=En(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=Lb(t,"meshCount",r.length)||Lb(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Gs(c);if(!d||En(d.sourceMeshName))return c;let u=Da(d.meshIndex);if(u==null)return c;let l=Da(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?AM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function AM(e){let t=En(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return En(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function Lb(e,t,r){let n=Da(e?.[t]);return n!=null&&n>r}function DM(e){return!e||typeof e!="object"||Array.isArray(e)?null:En(e.platformAssetId)}function En(e){return typeof e=="string"&&e.trim()?e.trim():null}function Da(e){return Number.isInteger(e)&&e>=0?e:null}function Gs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function js(e){return e==null?void 0:structuredClone(e)}function MM(e){return e==="model"||e==="prefab"||e==="texture"}function Zl(e,t){let r=new Map(t.filter(a=>a.type==="glb").map(a=>[a.assetId,a])),n=e.assets.map(a=>{if(a.type!=="glb")return a;let i=r.get(a.id);return i?$r(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of wM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push($r({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function wM(e){let t=[],r=new Set,n=o=>{let a=Ve(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=ct(ct(o)?.instance);n(a?.assetId)}return t}function Ql(e,t){wa(e,t);let r=new Map(t.filter(n=>n.type==="glb").map(n=>[n.assetId,n]));return{...e,assets:e.assets.map(n=>{if(n.type!=="glb")return structuredClone(n);let o=r.get(n.id);if(!o)throw new Error(`asset.catalog.missing: ${n.id}`);let a=o.guid??n.guid;return{id:n.id,...a?{guid:a}:{},type:"glb"}})}}function wa(e,t){let r=new Map(t.map(o=>[o.assetId,o])),n=new Map(t.filter(o=>o.type==="glb").map(o=>[o.assetId,o]));for(let o of e.assets){if(o.type!=="glb")continue;let a=n.get(o.id);if(!a)throw new Error(`asset.catalog.missing: ${o.id}`);RM(o,a),OM(o,a),kM(a)}for(let o of Bb(e)){if(o.kind!=="material.textureAssetId")continue;let a=r.get(o.assetId);if(!a||a.kind!=="texture"&&a.type!=="texture")throw new Error(`asset.catalog.missing: ${o.assetId} at ${o.path}`)}}function Bb(e){let t=[],r=(o,a)=>{let i=Ve(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),So(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),So(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Ze(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),So(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ve(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},ct(a.origin)?.sourceAssetId),So(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function kM(e){let t=ct(e.metadata),r=ct(e.external);if(!(Ve(t?.url)??Ve(t?.relativePath)??Ve(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=ct(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=ct(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ve(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=ct(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ve(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function OM(e,t){let r=ct(e.metadata),n=ct(t.metadata),o=ct(e.external),a=ct(t.external),i=Ve(r?.url)??Ve(r?.relativePath)??Ve(o?.assetUrl),s=Ve(n?.url)??Ve(n?.relativePath)??Ve(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function RM(e,t){for(let r of["materialMode","defaults","external","warmupCount","singleton"])if(e[r]!==void 0&&t[r]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.${r}`)}function $r(e,t){return{...e,guid:t.guid??e.guid,displayName:t.displayName||e.displayName,category:t.category??e.category,warmupCount:t.warmupCount??e.warmupCount,singleton:t.singleton??e.singleton,materialMode:t.materialMode??e.materialMode,defaults:Fs(t.defaults??e.defaults),prefab:Fs(t.prefab??e.prefab),external:Fs(t.external??e.external),metadata:Fs(t.metadata??e.metadata)}}function Fs(e){return e==null?void 0:structuredClone(e)}function So(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>So(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):So(o,a,r)}}}function ct(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ve(e){return(typeof e=="string"?e.trim():"")||void 0}function ka(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function CM(e){let t=structuredClone(e??{});return In(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,In(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,In(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,In(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(In(t.emission,"texture"),In(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),In(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function In(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Vb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=rt(t,r);if(a?!no(e.shaderId,t)||!zt(t,null,e.shaderId,n):!zt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),vM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=CM(s.properties)),eo(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function vM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var Pn="mat_default_pbr",yo="mat_default_standard",GM="00000000-0000-4000-8000-000000000001",jM="00000000-0000-4000-8000-000000000002",Tn=Pn,xn={id:Pn,guid:GM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Cd("fps.builtin.pbr")},NM={id:yo,guid:jM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Cd("fps.builtin.standard")};function FM(){return structuredClone(xn)}function _M(){return structuredClone(NM)}function Ub(e){let t=[FM(),_M()],r=new Set(t.map(o=>o.id)),n=[...t,...e.filter(o=>!r.has(o.id))];return JSON.stringify(n)===JSON.stringify(e)?e:n}function Kb(e){return e?.system?.preset==="default-pbr"||e?.id===Pn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===yo?"default-standard":null}function Oa(e){let t=structuredClone(xn.properties);if(!e||typeof e!="object")return t;let r={...t,...structuredClone(e)};return r.baseColor={...t.baseColor??{},...e.baseColor??{}},(t.normal||e.normal)&&(r.normal={...t.normal??{},...e.normal??{}}),(t.metallicRoughness||e.metallicRoughness)&&(r.metallicRoughness={...t.metallicRoughness??{},...e.metallicRoughness??{}}),(t.occlusion||e.occlusion)&&(r.occlusion={...t.occlusion??{},...e.occlusion??{}}),r.emission={...t.emission??{},...e.emission??{}},(t.alpha||e.alpha)&&(r.alpha={...t.alpha??{},...e.alpha??{}}),r}function An(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=ho(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function ho(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var eu=[Pn,yo],$M="New Material";function Hb(e,t,r=`${t.displayName} Material`){let n=Ra(e);return{id:lr(n),guid:n,name:_s(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function LM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Ra(e);return{id:lr(a),guid:a,name:`${n} - ${o}`,shaderId:r.shaderId,...r.definitionVersion!=null?{definitionVersion:r.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:r.id},properties:structuredClone(r.properties)}}function Wb(e,t,r){let n=t.name?.trim()||t.id,o=Ra(e);return{id:lr(o),guid:o,name:_s(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function zM(e,t){let r=Ra(e);return{id:lr(r),guid:r,name:_s(e,t.name),shaderId:xn.shaderId,definitionVersion:xn.definitionVersion,origin:{type:"created",...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Oa(t.profile)}}function qb(e,t){let r=`${t.sourceAssetGuid||t.sourceAssetId}:material:${t.sourceMaterialIndex}`,n=Np(r),o=lr(n),i=(e.scene.materialAssets??[]).some(s=>s.id===o||s.guid===n)?Ra(e):n;return{id:lr(i),guid:i,name:_s(e,t.name),shaderId:xn.shaderId,definitionVersion:xn.definitionVersion,origin:{type:"imported",sourceAssetId:t.sourceAssetId,...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},...t.sourceSlotId?{sourceSlotId:t.sourceSlotId}:{},sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Oa(t.profile)}}function Jb(e,t,r){let n=t.trim(),o=e.scene.materialAssets?.findIndex(s=>s.id===n)??-1;if(o<0||r.id!==n)return e;let a=e.scene.materialAssets[o];if(JSON.stringify(a)===JSON.stringify(r))return e;let i=[...e.scene.materialAssets];return i[o]=structuredClone(r),{...e,scene:{...e.scene,materialAssets:i}}}function Ra(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=el(),n=lr(r);for(;t.has(n);)r=el(),n=lr(r);return r}function _s(e,t){let r=rt("name",t),n=typeof r=="string"&&zt("name",r)?r:$M,o=new Set((e.scene.materialAssets??[]).map(s=>s.name?.trim()).filter(s=>!!s).map(s=>s.toLocaleLowerCase()));if(!o.has(n.toLocaleLowerCase()))return n;let a=2,i=`${n} ${a}`;for(;o.has(i.toLocaleLowerCase());)a+=1,i=`${n} ${a}`;return i}function Xb(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=LM(e.document,e.gameObject,t);return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function Yb(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=zM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function $s(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Vb(d,r,rt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function Zb(e,t,r=[]){let n=ee(e,t),o=nl(e,t);return n?ka(n,r)?{ok:!1,reason:"readonly",materialAsset:n,usages:o}:o.length>0?{ok:!1,reason:"in-use",materialAsset:n,usages:o}:{ok:!0,materialAsset:n,usages:o}:{ok:!1,reason:"missing",usages:o}}function Qb(e,t){return Zb(e,t,eu)}function BM(e,t,r=[]){return Zb(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function tu(e){return ka(e,eu)}function eS(e,t){return BM(e,t,eu)}function Ls(e,t){return Vt(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function tS(e,t,r,n){return Vt(e,n.id)?e:VM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function VM(e,t,r,n){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(o=>{if(o.id!==t)return o;let a=structuredClone(o);return UM(a,r,n),a})}}}function UM(e,t,r){let n=KM(t)??t.split(".").filter(Boolean);if(n.some(HM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function KM(e){let t=Lt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function HM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Bs(e,t){let r=Se(t),n=r?e.assets.find(g=>g.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=is(e,t),i=new Map(a.filter(g=>!!g.slotId).map(g=>[g.slotId,g])),s=t.overrides?.materialSlotBindings??{},c=WM({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(g=>[g.toSlotId,g])),l=new Set([...d.map(g=>g.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[g,b]of Object.entries(s))!b||l.has(g)||m.set(g,b);for(let g of d){let b=s[g.fromSlotId];b&&m.set(g.toSlotId,b)}let f=[];for(let[g,b]of a.entries()){let y=b.slotId?m.get(b.slotId):void 0,I=Eo(y),E=I?ee(e,I):null,T=nS(b),A=T[0],$=b.slotId?u.get(b.slotId):void 0;if($){f.push({status:"changed",reason:"slot-remapped",...b.slotId?{slotId:b.slotId}:{},previousSlotId:$.fromSlotId,ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},materialAssetId:I,bindingPath:`overrides.materialSlotBindings.${b.slotId}.materialAssetId`,conflict:!1});continue}let z=oS(E,o,n?.id)?.sourceMaterialIndex;if(z!=null&&T.length>0&&!T.includes(z)){f.push(rS({status:"changed",reason:"source-material-changed",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},previousSourceMaterialIndex:z,...I?{materialAssetId:I}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:""}));continue}if(!I&&T.length>0){f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:zs(b,g),...A==null?{}:{sourceMaterialIndex:A},...T.length>0?{sourceMaterialIndices:T}:{},...I?{materialAssetId:I}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1})}for(let[g,b]of Object.entries(s))!b||i.has(g)||l.has(g)||f.push(rS({status:"removed",reason:"slot-removed",slotId:g,...Eo(b)?{materialAssetId:Eo(b)}:{},bindingPath:`overrides.materialSlotBindings.${g}.materialAssetId`}));let S=f.filter(JM);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:S.length===0,items:f,issues:S,bindingRemaps:d,bindingRemapIssues:c.issues,counts:XM(f)}}function WM(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=Eo(u),m=l?ee(e.document,l):null,f=oS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let S=e.currentSlots.filter(g=>!!g.slotId&&nS(g).includes(f.sourceMaterialIndex)).map(g=>g.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:S,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(g=>c.add(g));let l=u.filter(g=>a.get(g)?.anchored).sort((g,b)=>g.localeCompare(b));if(l.length===0){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(g=>qM(f.binding,a.get(g).binding))||r.has(d)){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(g=>g!==m).sort((g,b)=>g.localeCompare(b))}:{}});for(let g of u)g!==m&&s.add(g)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function qM(e,t){return Eo(e)===Eo(t)&&ru(e.override,t.override)}function ru(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>ru(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&ru(r[i],n[i]))}function nS(e){return nt(e)}function oS(e,t,r){if(e?.origin?.type!=="imported")return null;let n=e.origin.sourceMaterialIndex;if(typeof n!="number"||!Number.isInteger(n))return null;let o=e.origin.sourceAssetGuid,a=e.origin.sourceAssetId;if((o||a)&&!(!!t&&!!o&&o===t)&&!(!!r&&!!a&&a===r)||!o&&!a&&(t||r))return null;let c=typeof e.origin.sourceSlotId=="string"&&e.origin.sourceSlotId.trim()?e.origin.sourceSlotId.trim():void 0;return{sourceMaterialIndex:n,...c?{sourceSlotId:c}:{}}}function zs(e,t){return e.label?.trim()||Ut(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function Eo(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function rS(e){return{...e,conflict:!0}}function JM(e){return e.conflict}function XM(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Vs(e){let t=os(e);if(t.ok)return;let r=new Error(`editor_scene_material_assets_missing: ${t.missingMaterialAssetIds.join(", ")}`);throw r.details={missingMaterialAssetIds:t.missingMaterialAssetIds,missingReferences:t.missingReferences.map(n=>({materialAssetId:n.materialAssetId,gameObjectId:n.gameObjectId,bindingPath:n.bindingPath,label:n.label,kind:n.kind,...n.slotId?{slotId:n.slotId}:{},...n.ownerNodePath?{ownerNodePath:n.ownerNodePath}:{}}))},r}function YM(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=Bs(e,o);if(a.bindingRemaps.length===0)return o;let i=o;for(let s of a.bindingRemaps){let c=i.overrides?.materialSlotBindings?.[s.fromSlotId];if(!(!c||i.overrides?.materialSlotBindings?.[s.toSlotId])){i=structuredClone(i),i.overrides=i.overrides??{},i.overrides.materialSlotBindings=i.overrides.materialSlotBindings??{},i.overrides.materialSlotBindings[s.toSlotId]=structuredClone(c),delete i.overrides.materialSlotBindings[s.fromSlotId];for(let d of s.coalescedFromSlotIds??[])delete i.overrides.materialSlotBindings[d];Object.keys(i.overrides.materialSlotBindings).length===0&&delete i.overrides.materialSlotBindings,r=!0}}return i}),changed:r}}function aS(e,t,r){let n=YM({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r);return{materialAssets:t,gameObjects:n.gameObjects,changed:n.changed}}function iS(e,t){let r=cS(t);if(r.length===0)return ZM(e);let n={};for(let a of e.scene.materialAssets??[]){let i=a.origin;if(!i||!Number.isInteger(i.sourceMaterialIndex))continue;(i.sourceAssetGuid&&t.guid?i.sourceAssetGuid===t.guid:i.sourceAssetId===t.assetId)&&(n[String(i.sourceMaterialIndex)]=a.id)}let o=[];for(let a of r)for(let i of a.sourceMaterialProfiles??[]){let s=String(i.sourceMaterialIndex);if(n[s]||!i.profile)continue;let c=o.length===0?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},d=qb(c,{profile:i.profile,name:i.materialName?.trim()||`${t.displayName} Material ${i.sourceMaterialIndex+1}`,sourceAssetId:t.assetId,...t.guid?{sourceAssetGuid:t.guid}:{},sourceSlotId:a.slotId,sourceMaterialIndex:i.sourceMaterialIndex,...i.materialName?.trim()?{sourceMaterialName:i.materialName.trim()}:{}});o.push(d),n[s]=d.id}return o.length===0?{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:n}:{document:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],...o]}},createdMaterialAssetIds:o.map(a=>a.id),materialAssetIdsBySourceMaterialIndex:n}}function sS(e,t,r){let n={};for(let o of cS(t)){let a=nt(o);if(a.length!==1)continue;let i=r[String(a[0])];i&&(n[o.slotId]={materialAssetId:i})}return Object.keys(n).length===0?e:{...e,overrides:{...e.overrides??{},materialSlotBindings:{...e.overrides?.materialSlotBindings??{},...n}}}}function cS(e){if(e.type!=="glb"&&e.type!=="gltf")return[];let t=e.metadata?.materialSlots;return Array.isArray(t)?t.map(Or).filter(r=>!!r):[]}function ZM(e){return{document:e,createdMaterialAssetIds:[],materialAssetIdsBySourceMaterialIndex:{}}}function dS(e,t){let r=new Set,n=e.properties,o=Dn(n)?n:{},a=Dn(t.defaultProperties)?t.defaultProperties:{},i=lS(t.propertiesSchema,o,a,"properties",r),s=new Set;uS(o,"properties",s);let c=[...s].filter(d=>!r.has(d)).sort();return{materialAsset:{...structuredClone(e),shaderId:t.shaderId,definitionVersion:t.version,properties:i},preservedPaths:[...r].sort(),resetPaths:c}}function lS(e,t,r,n,o){if(e.kind!=="object")return QM(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=Dn(t)?t:{},i=Dn(r)?r:{},s={};for(let[c,d]of Object.entries(e.properties)){let u=Object.prototype.hasOwnProperty.call(a,c),l=Object.prototype.hasOwnProperty.call(i,c);if(!u&&!l)continue;let m=lS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function QM(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return nu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return nu(t,["x","y"]);if(e.kind==="vec3")return nu(t,["x","y","z"]);if(t===null)return!0;if(!Dn(t))return!1;let r=Object.keys(t);return r.every(n=>n==="url"||n==="textureAssetId")&&r.every(n=>typeof t[n]=="string"&&!!t[n].trim())}function uS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;Dn(o)&&!ew(o)?uS(o,a,r):r.add(a)}}function ew(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function nu(e,t){return Dn(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function Dn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function tw(e){return e?.system?.preset}function fS(e,t){let r=tw(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Us(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function mS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function pS(e){let t=e.currentTexture??Us(e.textureAssets,e.currentValue),r=e.currentValue.trim(),n=!!r&&!t,o=!!t&&!t.disabled&&!!t.url.trim(),a=n?"missing":t?o?"ready":"failed":void 0,i=e.candidateValue??"url",s=(e.textureAssets??[]).filter(rw);return{pickerKind:"texture",pickerTitle:e.pickerText.texturePickerTitle,pickerTrigger:"preview",placeholder:e.pickerText.emptyTexture,currentLabel:n?e.pickerText.missingTexture:t?.label??(r||e.pickerText.emptyTexture),currentMeta:n?`${e.pickerText.missingTextureMeta} \xB7 ${r}`:t?.previewUnavailableReason??t?.meta??(r||e.pickerText.emptyTextureMeta),...a?{currentResourceState:a}:{},...r?{currentResourceReference:r}:{},resourceStatusText:{missing:e.pickerText.missingTexture,loading:e.pickerText.loadingTexture,failed:e.pickerText.failedTexture},currentPreview:o?mS(t,e.pickerText):void 0,candidates:[{label:e.pickerText.clearTexture,value:"",meta:e.pickerText.clearTextureMeta},...s.map(c=>({label:c.label,value:i==="assetId"?c.id:c.url,meta:c.meta??c.id,kind:"texture",...typeof c.width=="number"?{width:c.width}:{},...typeof c.height=="number"?{height:c.height}:{},...!c.disabled&&c.url.trim()?{preview:mS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function rw(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function gS(e){return{path:`${e.pathPrefix??dr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var bS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function gr(e){return bS[e]??bS.zh}function Ks(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var nw={},SS=new WeakMap;function yS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function hS(e,t){return fS(e,PS(t))}function ow(e){return{materialPickerTitle:e.materialPickerTitle,replace:e.replace,duplicateForObject:e.duplicateForObject,duplicateForObjectTooltip:e.tooltips.duplicateForObject,summaryMissingAsset:e.summaryMissingAsset,summaryInherit:e.summaryInherit,inheritNone:e.inheritNone}}function aw(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function PS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function TS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=mw(e,t,r,n,o,a??void 0);if(AS(t,o))return[...i,j({path:`scene.materialAssets.${t.id}.properties`,label:r.assetProfile,value:r.defaultMaterialReadOnly,order:n+2,source:"Document",effect:"default",disabledReason:r.defaultMaterialReadOnly,tags:["ArtistMaterial","MaterialAsset"],tooltip:r.tooltips.assetProfile})];if(!a)return i;let s=[...a.inspector.fields].sort((c,d)=>c.order-d.order||c.path.localeCompare(d.path)).map(c=>iw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function iw(e){let{fieldDefinition:t}=e,r=ES(e.text,t.labelKey,t.label??t.path),n=dw(e.text,t.tooltipKey,t.tooltip),o=xS(e.materialAsset.properties,t),a=t.control==="texture"&&no(e.materialAsset.shaderId,t.path)?sw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=fw({path:`${dr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=gw(e.document,e.materialAsset,t.path,r,typeof o=="number"?o:Number(t.defaultValue),e.orderOffset+t.order,t,n,e.context.materialShaderDefinitions);else if(t.control==="enum")i=bw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:ES(e.text,d.labelKey,d.label??d.value)})),n,e.context.materialShaderDefinitions);else{let d=t.control;i=Js(e.document,e.materialAsset,t.path,r,o,e.orderOffset+t.order,d,d,"immediate",n,e.context.materialShaderDefinitions)}let s=t.control==="color"?Qn(e.definition.shaderId,t.path,e.context.materialShaderDefinitions):null;i={...i,displayPrecision:t.displayPrecision,precision:t.precision,controlOptions:{...i.controlOptions,...t.control==="color"?{colorChannels:s?.kind==="color"&&s.channels===4?4:3}:{},materialShaderSectionId:t.sectionId,materialShaderUpdateClass:t.updateClass,materialShaderBinding:t.binding}};let c=t.conditions?.find(d=>!cw(e.definition,e.materialAsset.properties,d));return c&&(i=Ew(i,!1,lw(e.text,c))),a?yw(i,e.text,a):Sw(i,e.text,t.defaultValue)}function sw(e,t){let r=Hs(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function xS(e,t){if(t.control==="texture"){let n=Hs(e,t.schemaPath??t.path);return DS(n)}let r=Hs(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Hs(e,t){let r=t.replace(/^properties\./,"").split(".").filter(Boolean),n=e;for(let o of r){if(!n||typeof n!="object"||Array.isArray(n))return;n=n[o]}return n}function cw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?xS(t,n):Hs(t,r.path);if(r.operator==="truthy")return!!o;let a=JSON.stringify(o??null)===JSON.stringify(r.value??null);return r.operator==="equals"?a:!a}function ES(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function dw(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function lw(e,t){let r=t.inactiveReasonKey?e.inactiveReasons[t.inactiveReasonKey]:void 0;return typeof r=="string"?r:t.inactiveReason??"This field is inactive for the current material state."}function uw(e){return e.defaultMaterialAssetIds??[Pn,yo]}function AS(e,t){return ka(e,uw(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function mw(e,t,r,n,o,a){if(!AS(t,o)){let i=o.materialShaderDefinitions??Mr;return[Js(e,t,"name",r.assetName,hS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${dr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[yS(`${dr}${t.id}.name`,r.assetName,hS(t,r),n,r.tooltips.assetName),yS(`${dr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function fw(e){let t=ou(e.context,e.value),r=qs(e.context,e.text,e.value,t);return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:e.value,readOnly:!1,persistence:"document",commitMode:"change",order:e.order,tooltip:e.tooltip,tags:["ArtistMaterial","TextureAsset"],controlOptions:{...r,...e.textureState?{materialTextureState:e.textureState}:{},...!e.value&&e.textureState==="inherited"?{currentLabel:e.text.inheritTexture,currentMeta:e.text.inheritTextureMeta}:!e.value&&e.textureState==="cleared"?{currentLabel:e.text.clearTexture,currentMeta:e.text.clearTextureMeta}:{}},validate:n=>{let o=IS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=IS(e.context,e.path,n);return o.ok?o.value:null}}}function qs(e,t,r,n){return{...pS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:pw(t),candidateValue:"assetId"})}}function ou(e,t){return Us(e.textureAssets,t)}function DS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function IS(e,t,r){if(r==null||r==="")return{ok:!0,value:null};if(typeof r!="string")return{ok:!1};let n=r.trim();if(!n)return{ok:!0,value:null};if(!t.endsWith(".textureAssetId"))return{ok:!0,value:n};let o=Us(e.textureAssets,n);return o?{ok:!0,value:o.id}:/^[A-Za-z0-9_-]+$/.test(n)?{ok:!0,value:n}:{ok:!0,value:null}}function pw(e){return{texturePickerTitle:e.texturePickerTitle,replace:e.replace,emptyTexture:e.emptyTexture,emptyTextureMeta:e.emptyTextureMeta,clearTexture:e.clearTexture,clearTextureMeta:e.clearTextureMeta,missingTexture:e.missingTexture,missingTextureMeta:e.missingTextureMeta,loadingTexture:e.loadingTexture,failedTexture:e.failedTexture}}function gw(e,t,r,n,o,a,i={},s,c){return{...Js(e,t,r,n,o,a,"number","number","live",s,c),...i.min!=null?{min:i.min}:{},...i.max!=null?{max:i.max}:{},...i.softMin!=null?{softMin:i.softMin}:{},...i.softMax!=null?{softMax:i.softMax}:{},step:i.step??.05}}function bw(e,t,r,n,o,a,i,s,c){return{...Js(e,t,r,n,o,a,"enum","enum","immediate",s,c),options:i,controlOptions:{variant:"segmented"}}}function Js(e,t,r,n,o,a,i,s,c,d,u){return{...gS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:dr}),validate:l=>{let m=rt(r,l);return zt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>rt(r,l)}}function Sw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!hw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function yw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:"",resetMode:"inherit",modified:r!=="inherited",resetLabel:t.inheritTexture,modifiedLabel:r==="cleared"?t.clearTexture:t.modifiedValue}}}function hw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Ew(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function MS(e,t,r,n){let o=r.currentAsset??ee(e,r.value);return{path:r.path,label:r.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.value,readOnly:!1,persistence:"document",commitMode:"change",order:r.order,controlOptions:Tw(Ws(e,o,r.text,r.value,n,r.previewContext),r.currentAction),tooltip:r.text.tooltips.materialAsset,tags:["ArtistMaterial","MaterialAsset"],document:e,validate:a=>{let i=ts(a);return i&&Vt(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Vt(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:Iw(t,r.value),validation:Pw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function Iw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Pw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function Tw(e,t){return t?{...e,currentActionId:t.actionId,currentActionParams:Object.fromEntries(Object.entries(t.params).filter(r=>typeof r[1]=="string"&&r[1].length>0))}:e}function xw(e,t,r){return MS(e,t,r,_e.getCachedUsageIndex(e))}function Ws(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:ow(r),displayText:PS(r),document:e,ownershipText:aw(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Aw(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Ws(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=SS.get(e);a||(a=new WeakMap,SS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??nw,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Ws(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var Dw={createSelectorInspectorPropertyWithUsage:MS,createSelectorInspectorPropertyWithCachedUsage:xw,createPickerControlOptionsWithUsage:Ws,createPickerControlOptionsWithCachedUsage:Aw},Mn=Dw;function wS(e,t,r){let n=Jp(e,t);if(n.state==="asset"&&n.materialAsset){let o=Kb(n.materialAsset),a=o==="default-pbr"?r.defaultMaterial:o==="default-standard"?r.defaultStandardMaterial:n.materialAsset.name??n.materialAsset.id;return r.summaryAsset(a)}return n.state==="missing-asset"?r.summaryMissingAsset:n.state==="override"?r.summaryCustomOverride:r.summaryInherit}function kS(e,t,r){let n=kr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Mw(e,t,r,n,o,a={}){let i=gr(Ks(t)),s=[];return kr(e,t).forEach((d,u)=>{let l=Ut(d)??d.slotId,m=ol(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,S=f?.materialAssetId?ee(e,f.materialAssetId):null,g=(u+1)*100,b=as(d),y=nt(d)[0],I=y==null?null:ho(d,y)?.profile,E=Mn.createSelectorInspectorPropertyWithUsage(e,r,{path:b,label:d.label||au(l,u,i),value:m?.materialAssetId??"",order:g,text:i,currentAsset:S,currentAction:S?{actionId:"material.open-asset",params:{materialAssetId:S.id,browserAssetId:`material:${S.id}`,sourceObjectId:t.id,sourceBindingPath:b}}:I?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:b}}:void 0,previewContext:a},n);s.push(ww(E,d,f,i,a))}),s}function ww(e,t,r,n,o){let a=nt(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:An(t,a),s=a==null?null:ho(t,a)?.profile,c=s?Bt(Oa(s),o):void 0,d=i?`GLB \u6E90\u6750\u8D28\uFF1A${i}`:"GLB \u6E90\u6750\u8D28",u=e.controlOptions??{},l=Array.isArray(u.candidates)?u.candidates.map(f=>f&&typeof f=="object"&&!Array.isArray(f)&&f.value===""?{...f,label:"\u6062\u590D\u7EE7\u627F",meta:d,...c?{preview:c}:{}}:f):void 0,m=r?.materialAssetId&&typeof u.currentMeta=="string"&&u.currentMeta?`${u.currentMeta} \xB7 ${d}`:d;return{...e,tooltip:n.tooltips.slotMaterialAsset,controlOptions:{...u,...r?.materialAssetId?{}:{currentLabel:i?`\u7EE7\u627F GLB\uFF1A${i}`:"\u7EE7\u627F GLB \u539F\u6750\u8D28",...c?{currentPreview:c}:{}},currentMeta:m,...l?{candidates:l}:{},...i?{sourceMaterialName:i}:{}}}}function kw(e,t,r,n){let o=kr(e,t);if(o.length===0)return[];let a=[],i=Bs(e,t),s=ds(e,t.id)??t.overrides;i.issues.length>0&&a.push(vw("asset.materialSlots.reimportConflicts",r.reimportConflicts,Ow(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Rw(e,t,d,u,r,n,s));return a.push({path:"asset.materialSlots",label:r.slotList,valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:o.length,slots:c},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:r.slotMaterialAsset,slotId:r.slotId,ownerNodePath:r.slotOwnerPath,sourceMaterial:r.slotSourceMaterial,primitive:"Primitive",triangles:"Triangles",bounds:"Bounds",bindingPath:r.slotBindingPath},slots:c},tags:["ArtistMaterial","MaterialSlot","Readonly"],tooltip:r.tooltips.slotList,document:e}),a}function Ow(e,t){let r=e.map(n=>{let o=n.label||n.ownerNodePath||n.slotId||n.previousSlotId||n.bindingPath||"slot";if(n.reason==="source-material-changed"){let a=n.previousSourceMaterialIndex==null?"?":`#${n.previousSourceMaterialIndex}`,i=n.sourceMaterialIndex==null?"?":`#${n.sourceMaterialIndex}`;return`${o}: source material ${a} -> ${i}; ${n.materialAssetId??t.inheritNone}`}return n.reason==="slot-removed"?`${o}: removed slot; ${n.materialAssetId??t.inheritNone}`:`${o}: ${n.status}`});return[t.formatReimportConflictSummary(e.length),...r].join(`
3
+ `)}function Rw(e,t,r,n,o,a,i){let s=ol(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Tn),u=Mn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=nt(r),m=l[0],f=m==null?null:An(r,m),S=r.sourceSurfaces[0],g=S.ownerNodePath;return{key:Yp(r),label:r.label||au(g,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:g,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof S.triangleCount=="number"?{triangleCount:S.triangleCount}:{},...r.sourceSurfaces.length===1&&S.boundingBox?{boundingBox:S.boundingBox}:{},bindingPath:as(r)}}var Cw={createChildMaterialBindingInspectorPropertiesWithUsage:Mw,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:kw},OS=Cw;function au(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function vw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var RS="materialAsset::",Gw=5;function jw(e){return e.startsWith(RS)&&e.slice(RS.length).trim()||null}function Nw(e,t,r,n,o,a){let i=[],s=Ks(t),c=gr(s),d=t.overrides?.materialBinding,u=ds(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Tn,f=ee(e,m),S=l?.materialAssetId?l:{...l,materialAssetId:Tn};if(!Xp(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:wS(S,f,c),persistence:"document",collapsedByDefault:!1,properties:[Mn.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let b=r==="primitive"?[]:OS.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return b.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:kS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:b}),i}function Fw(e,t,r,n){let o=jw(t),a=o?ee(e,o):null;if(!a)return null;let i=gr("zh"),s=n.forMaterial(a.id),c=TS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=E=>E.path===d||E.path.startsWith(u),m=c.filter(E=>!l(E)),f=c.filter(l),S=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Bt(a.properties,r)},document:e},...m,zw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],g=[io({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),io({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],b=[{id:"materialAssetSummary",title:"Material",order:10,regionId:zi,persistence:"readonly",collapsedByDefault:!1,properties:S}];b.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:g}),b.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:Gw,items:s.map((E,T)=>({key:`${E.scope}:${E.gameObjectId}:${E.bindingPath}:${T}`,label:E.label,scope:E.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:E.scope,sourceObjectId:E.gameObjectId,sourceBindingPath:E.bindingPath,slotId:E.slotId,ownerNodePath:E.ownerNodePath,prefabAssetId:E.prefabAssetId,prefabNodeId:E.prefabNodeId}).filter(A=>typeof A[1]=="string"&&A[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[E,T]of[...y?.inspector.sections??[]].sort((A,$)=>A.order-$.order||A.id.localeCompare($.id)).entries())CS(b,{id:`material${T.id.charAt(0).toUpperCase()}${T.id.slice(1)}`,title:T.title,order:T.order,properties:[...E===0?f.filter(A=>A.path===d):[],...f.filter(A=>A.controlOptions?.materialShaderSectionId===T.id)]});let I=new Set(b.flatMap(E=>E.properties.map(T=>T.path)));return CS(b,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(E=>!I.has(E.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:b}}function _w(e,t,r,n={},o){return Nw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function $w(e,t,r={}){return Fw(e,t,r,_e.getCachedUsageIndex(e))}var Lw={createArtistMaterialInspectorSectionsWithCachedUsage:_w,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:$w},iu=Lw;function CS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function zw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var vS="modelAsset::";function Bw(e){return e.startsWith(vS)&&e.slice(vS.length).trim()||null}function GS(e,t,r={}){let n=Bw(t),o=n?Vw(e,n,r.modelAssets):null;if(!o)return null;let a=Ww(o),i=[Uw(o)];return i.push(Kw(e,o,a,r)),{targetIds:[t],activeId:t,label:o.displayName??o.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"modelAsset",capabilities:["asset","materialSlots"],document:e},sections:i}}function Vw(e,t,r){let n=e.assets.find(a=>a.id===t);if(n&&n.type!=="glb")return null;let o=r?.find(a=>a.assetId===t&&a.type==="glb");return o?$r(n??{id:t,type:"glb"},o):n??null}function Uw(e){let t=qw(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:zi,persistence:"readonly",collapsedByDefault:!1,properties:[Ca(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Ca(`assets.${e.id}.id`,"Asset ID",e.id,1),Ca(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Ca(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function Kw(e,t,r,n){let o=`\u6750\u8D28\u63D2\u69FD (${r.length})`;if(r.length===0)return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:"\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",persistence:"readonly",collapsedByDefault:!1,properties:[Ca(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>Hw(s,c,n)),i={path:`assets.${t.id}.materialSlots`,label:"GLB \u6E90\u6750\u8D28",valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:r.length,slots:a},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:"\u5F53\u524D\u6765\u6E90",slotId:"Slot ID",ownerNodePath:"\u8282\u70B9\u8DEF\u5F84",sourceMaterial:"\u6E90\u6750\u8D28",primitive:"Primitive",triangles:"\u4E09\u89D2\u9762",bounds:"Bounds",bindingPath:"\u7ED1\u5B9A\u8DEF\u5F84"},slots:a},tags:["Asset","MaterialSlot","Readonly"],tooltip:"GLB / glTF \u6587\u4EF6\u4E2D\u89E3\u6790\u51FA\u7684\u53EA\u8BFB\u6750\u8D28\u63D2\u69FD\u3002",document:e};return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:`${r.length} \u4E2A\u5DF2\u89E3\u6790\u6E90\u63D2\u69FD`,persistence:"readonly",collapsedByDefault:!1,properties:[i]}}function Hw(e,t,r){let n=e.sourceSurfaces[0],o=nt(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:An(e,a),s=a==null?null:ho(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Bt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function Ww(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(Or).filter(r=>!!r)}function Ca(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function qw(e){return typeof e=="string"&&e.trim()?e.trim():""}function va(e,t,r,n={}){let o=iS(e,t),a=o.document;if(t.type==="prefab"){let u=jS(a,t),l=u?$r(u,t):su(t),m=FS(a,t,l,r,n),f=Xw(u?a.assets.map(S=>S.id===l.id?l:S):[...a.assets,l],l);return{document:{...a,assets:f,scene:{...a.scene,gameObjects:[...a.scene.gameObjects,m]}},gameObject:m}}let i=jS(a,t),s=i?$r(i,t):su(t),c=t.type==="texture"?Jw(a,t,s.id,r,n):NS(a,t,s.id,r,n),d=sS(c,t,o.materialAssetIdsBySourceMaterialIndex);return{document:{...a,assets:i?a.assets.map(u=>u.id===s.id?s:u):[...a.assets,s],scene:{...a.scene,gameObjects:[...a.scene.gameObjects,d]}},gameObject:d}}function Jw(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[Mt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function su(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Xs(e.defaults),prefab:Xs(e.prefab),external:Xs(e.external),metadata:Xs(e.metadata)}}function NS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[Mt(d),{type:"ModelRenderer",assetId:r}]}}function FS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return ng({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:Mt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function cu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function jS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function Xw(e,t){let r=da(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function du(e,t,r,n){if(n.localTransform)return structuredClone(n.localTransform);let o=ql(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??ur(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function lu(e,t,r){if(t===void 0)return Aa(e,vs(r));if(Aa([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function uu(e,t){let r=t??ye(e);if(r){if(!e.scene.gameObjects.some(n=>n.id===r))throw new Error(`Requested asset instance parent does not exist: ${r}`);return r}}function Xs(e){return e==null?void 0:structuredClone(e)}function Yw(e){return!!e&&tt(e)}function pu(e,t,r={}){let n=t.type==="document.replace"?t.document:$S({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function $S(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return ja({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return wn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return Ga(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return va(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return ue(r.targetId)?t:hn(t,r.targetId,{transform:r.transform});if(r.kind==="game-object.transform-batch")return r.targets.reduce((o,a)=>{if(ue(a.targetId))return o;let i=_(o,a.targetId),s=i?G(i):null;if(!s)return o;if(Yw(a.transform))return hn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return hn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...ot(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??Zw,i=new Set(t.scene.gameObjects.filter(l=>a(l,t)).map(l=>l.id)),s=new Set,c=[];for(let l of r.gameObjects)o.has(l.id)||s.has(l.id)||Z(l)||a(l,t)||(s.add(l.id),c.push(l));let d=ek(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?mu(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(ue))return t;let o=wt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??Qw;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(ue(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?mr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!_S(G(o),a);if(o.parentId===r.parentId&&!i)return t;let s={...o,parentId:r.parentId,components:i?o.components.map(c=>c.type==="Transform"?a:c):o.components};return{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(c=>c.id===r.targetId?s:c)}}}if(r.kind==="game-object.hierarchy-move"){let o=r.moves.filter(l=>!ue(l.targetId)),a=new Map;for(let l of o){let m=mr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),S=!_S(G(l),f);if(l.parentId===m.parentId&&!S)return l;let g={...l,parentId:m.parentId,components:S?l.components.map(b=>b.type==="Transform"?f:b):l.components};return s=!0,g}),d=mu(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!ue(s)));if(o.size===0)return t;let a=new Map;for(let[s,c]of Object.entries(r.childTransforms)){if(!o.has(s))continue;let d=mr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:mu([...i,r.gameObject],r.order)}}}return t}function Zw(e){return Dt(e)}function Qw(e){return At(e)}function ek(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function mu(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function _S(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):fu(e.position,t.position)&&fu(e.rotation,t.rotation)&&fu(ot(e,"scale"),ot(t,"scale"))}function fu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var tk="main_camera",rk="environment_light",nk="sun_light",Ys={projection:"orthographic",alpha:3.9269908169872414,beta:.8,radius:14,orthoSize:6,fov:.85,targetOffset:{x:0,y:0,z:0},minZ:1,maxZ:1e4,lowerBetaLimit:.8,upperBetaLimit:.8,lowerRadiusLimit:14,upperRadiusLimit:14,inertia:.9,targetScreenOffset:{x:0,y:0},inspectorLanguage:"zh"},_a={type:"directional",intensity:2,direction:{...bs},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},kn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function zS(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function BS(e){let t=yu({...e,kind:"transform",transformType:"camera",camera:$a(e.camera)});return delete t.light,delete t.primitive,hu(t,e)?e:t}function Su(e,t){let r=yu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:On(e.light,t)});return delete r.camera,delete r.primitive,hu(r,e)?e:r}function VS(e){let t=yu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,hu(t,e)?e:t}function yu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function $a(e){let t=Ys;return{...t,...e??{},projection:ok(e?.projection),fov:Na(e?.fov,t.fov??.85),targetOffset:ck(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:Na(e?.minZ,t.minZ??1),maxZ:Na(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:Fa(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:Fa(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:Na(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:Na(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:ik(e?.inertia,t.inertia??.9),targetScreenOffset:sk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:ak(e?.inspectorLanguage)}}function US(e,t){return LS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),LS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function LS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=Fa(e[r.valueField],Ys[r.valueField]),s=Fa(e[r.lowerField],i),c=Fa(e[r.upperField],i);Number.isFinite(r.minValue)&&(i=Math.max(r.minValue,i),s=Math.max(r.minValue,s),c=Math.max(r.minValue,c)),c<s&&(t===a?s=c:c=s),t===o||t===a?i=Math.min(c,Math.max(s,i)):t===n&&(i<s&&(s=i),i>c&&(c=i)),e[r.valueField]=i,e[r.lowerField]=s,e[r.upperField]=c}function ok(e){return e==="perspective"?"perspective":"orthographic"}function ak(e){return e==="en"?"en":"zh"}function KS(e){return e==="en"?"en":"zh"}function Fa(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Na(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function ik(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function sk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)}function ck(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)&&typeof t.z=="number"&&Number.isFinite(t.z)}function HS(e){return e.maxZ!=null&&e.minZ!=null&&e.maxZ<=e.minZ||e.upperBetaLimit!=null&&e.lowerBetaLimit!=null&&e.upperBetaLimit<e.lowerBetaLimit||e.upperRadiusLimit!=null&&e.lowerRadiusLimit!=null&&e.upperRadiusLimit<e.lowerRadiusLimit}function dk(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function On(e,t="directional"){return dk(e,t)==="hemispheric"?uk(e):lk(e)}function lk(e){let t=_a,r=e?.type==="directional"?e:void 0;return{...t,...r??{},type:"directional",direction:{...t.direction,...r?.direction??{}},diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,inspectorLanguage:KS(WS(r))}}function uk(e){let t=kn,r=e?.type==="hemispheric"?e:void 0;return{...t,...r??{},type:"hemispheric",diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,groundColor:r?.groundColor?{...t.groundColor,...r.groundColor}:t.groundColor,inspectorLanguage:KS(WS(r))}}function WS(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function hu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qS(e,t,r){return{id:Eu(t,tk,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:$a(void 0),components:[{type:"Transform",position:{x:0,y:5,z:-8},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function JS(e,t,r){return{id:Eu(t,nk,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:On(void 0,"directional"),components:[{type:"Transform",position:{x:0,y:4,z:-3},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function XS(e,t,r){return{id:Eu(t,rk,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:On(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function Eu(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function ZS(e,t){let r=t.name.trim();if(!r)return null;let n=_(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function QS(e,t){let r=sy(e,t);if(r===null)return null;let n=st(ec(e),t.name,{fallbackName:"Empty"}),o=ty(e.scene.gameObjects.map(i=>i.id),t.objectId,n);if(!o)return null;let a={id:o,guid:he(),name:n,kind:"transform",transformType:"plain",...r?{parentId:r}:{},active:!0,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Create empty ${n}`,patch:{kind:"game-object.create-group",gameObject:a},createdId:o,changedIds:[o]}}function ey(e,t){let r=Tk(t.shape);if(!r)return null;let n=Sk(e,t);if(n===null)return null;let o=st(ec(e),t.name,{fallbackName:xk(r)}),a=ty(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Ak(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[Mt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function ty(e,t,r){return t===void 0?it(e,r):it([],t)===t&&!e.includes(t)?t:null}function ry(e,t){if(t.ids.some(ue))return null;let r=wt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&At(a)))return null;let n=Ik(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Pu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=_(e,t.draggedId),o=_(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?xt(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:Pk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!Qs(e,n.id,o.id,void 0,{preserveWorldPolicy:r})?{ok:!1,reason:"Cannot preserve world transform under the target parent."}:{ok:!0}:{ok:!1,reason:`${t.targetId} cannot have children.`}:{ok:!1,reason:`${t.draggedId} has no Transform to preserve.`}:{ok:!1,reason:`Parent GameObject not found: ${t.targetId}`}:{ok:!1,reason:`GameObject not found: ${t.draggedId}`}}function ny(e,t,r={}){if(!Pu(e,t,r).ok)return null;let o=_(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?qt(o):Qs(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&fy(qt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function Tu(e,t,r={}){let n=fr(e),o=ep(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(ue))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=Du(e,t);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=_(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!Qs(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function oy(e,t,r={}){if(!Tu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids),i=Du(e,t),s=a.map(l=>{let m=_(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?qt(m):Qs(e,l,i,t,r),S=f?Sn(f):null;return S?i?{targetId:l,parentId:i,transform:S}:{targetId:l,transform:S}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=yk(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=_(e,l.targetId);return!m||m.parentId!==l.parentId||!fy(qt(m),l.transform)})&&Dk(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function xu(e,t,r={}){let n=fr(e),o=tp(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(ue))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=cy(e,t.parentId??null);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=my(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!Ea(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=_(e,d);if(!u)return{ok:!1,reason:`GameObject not found: ${d}`};if(!G(u))return{ok:!1,reason:`${d} has no Transform to preserve.`};let l=ke(e,d);if(!l||!dy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function ay(e,t,r={}){if(!xu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids);if(a.length===0)return null;let i=cy(e,t.parentId??null),s=my(e,a);if(!s)return null;let c={position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},d=Ea(e,i,c,r);if(!d)return null;let u=st(ec(e),t.name,{fallbackName:"Parent"}),l=it(e.scene.gameObjects.map(g=>g.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[Mt(d)]},f={};for(let g of a){let b=_(e,g);if(!b)return null;if(t.preserveWorldTransform===!1){f[g]=qt(b);continue}let y=ke(e,g);if(!y)return null;let I=dy(c,y,r);if(!I)return null;f[g]=I}let S=hk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:S},createdId:l,changedIds:[l,...a]}}function iy(e){let t=e.isProtectedDuplicateSource??mk,r=fr(e.document),n=new Set(St(r,e.targetIds).filter(b=>{let y=_(e.document,b);return!!y&&!Z(y)&&!t(y,e.document)&&!pk(e.document,y.id,t)})),o=Au(e.document).filter(b=>n.has(b));if(o.length===0)return null;let a=wt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(b=>b.id)),c=new Map,d=ec(e.document),u=gk(e.document,o,a,t);for(let b of u){let y=_(e.document,b),I=st(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(I);let E=it([...s],I);s.add(E),i.set(y.id,E),c.set(y.id,I)}let l=u.map(b=>_(e.document,b)).filter(b=>!!b&&i.has(b.id)).map(b=>{let y=structuredClone(b);return y.id=i.get(b.id),y.guid=he(),y.name=c.get(b.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(b=>b.id),f=o.map(b=>i.get(b)).filter(b=>!!b),S=fk(e.document,o,e.activeId),g=S&&i.has(S)?i.get(S):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:bk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:g,changedIds:m}}function mk(e){return Dt(e)}function fk(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(wt(e,[n]).has(r))return n}return t[t.length-1]??null}function pk(e,t,r){let n=new Map(e.scene.gameObjects.map(i=>[i.id,i])),o=new Set,a=n.get(t);for(;a?.parentId;){if(o.has(a.parentId))return!0;o.add(a.parentId);let i=n.get(a.parentId);if(!i)return!1;if(r(i,e))return!0;a=i}return!1}function gk(e,t,r,n){let o=Au(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=_(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function bk(e,t,r){let n=Au(e),o=new Map;for(let i of t){let s=wt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Au(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=ye(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function sy(e,t){if(t.parentId){let n=_(e,t.parentId);return n&&xt(n)?n.id:null}let r=t.activeId?_(e,t.activeId):null;if(r&&xt(r))return r.id;if(r?.parentId){let n=_(e,r.parentId);if(n&&xt(n))return n.id}return ye(e)}function Sk(e,t){return t.parentId===null?ye(e):sy(e,t)}function Du(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?_(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function cy(e,t){return t&&Mu(e,t)?t:ye(e)}function Mu(e,t){let r=_(e,t);return!!r&&xt(r)}function Qs(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=_(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return Sn(s);let c=Ea(e,r,a,o.preserveWorldPolicy);return c?Sn(c):null}function dy(e,t,r={}){let n=Ki(r),o=ro(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Sn(o):null}function yk(e,t,r){let n=ly(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=Ek(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Du(e,r)});return uy(a,n,i)}function hk(e,t,r,n){let o=ly(e,r),a=new Set(o),i=e.scene.gameObjects.map(l=>l.id),s=i.filter(l=>!a.has(l)),c=Math.min(...r.map(l=>i.indexOf(l)).filter(l=>l>=0)),d=Number.isFinite(c)?s.filter(l=>i.indexOf(l)<c).length:s.length,u=n?Math.max(0,s.indexOf(n)):d;return uy(s,[t,...o],u)}function ly(e,t){let r=wt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function Ek(e,t,r){return r.beforeId?YS(t.indexOf(r.beforeId),t.length):r.afterId?Zs(e,t,r.afterId):r.placement==="before"&&r.targetId?YS(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?Zs(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?Zs(e,t,r.parentId):t.length}function Zs(e,t,r){let n=wt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function uy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function YS(e,t){return e>=0?e:t}function my(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Ui);return{x:n.reduce((o,a)=>o+a.x,0)/n.length,y:n.reduce((o,a)=>o+a.y,0)/n.length,z:n.reduce((o,a)=>o+a.z,0)/n.length}}function Ik(e,t,r){let n=r?_(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&_(e,n.parentId))return n.parentId;for(let o=e.scene.gameObjects.length-1;o>=0;o-=1){let a=e.scene.gameObjects[o];if(!t.has(a.id))return a.id}return null}function Pk(e,t,r){let n=Rl(e),o=new Set,a=n.get(r);for(;a?.parentId&&!o.has(a.parentId);){if(a.parentId===t)return!0;o.add(a.parentId),a=n.get(a.parentId)}return!1}function Tk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function xk(e){return e[0].toUpperCase()+e.slice(1)}function Ak(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function ec(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function fy(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):Iu(e.position,t.position)&&Iu(e.rotation,t.rotation)&&Iu(e.scale,t.scale)}function Iu(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Dk(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ku(e){return{getHierarchyItems(t){return wu(t,e)},normalizeHierarchyDocument(t){return Gl(t)},createRenamePatch(t,r){return br(ZS(t,r))},createCreateGroupPatch(t,r){return br(QS(t,r))},createCreatePrimitivePatch(t,r){return br(ey(t,r))},createDeleteSubtreePatch(t,r){let n=ry(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:br(n)},collectSubtreeIdList(t,r){return pr(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Pu(t,r)},createReparentPatch(t,r){return br(ny(t,r))},validateHierarchyMove(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Mk(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Tu(t,r)},createHierarchyMovePatch(t,r){return br(oy(t,r))},validateGroupSelection(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=wk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:xu(t,r)},createGroupSelectionPatch(t,r){return br(ay(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return br(iy({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return br(Wl(t))}}}function wu(e,t){let r=fr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Mk(e,t,r){if(t.placement==="root")return r.resolveRootContainerId(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let n=t.targetId?r.findGameObject(e,t.targetId):null;return t.parentId??n?.parentId??r.resolveRootContainerId(e)}function wk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&xt(n)?n.id:r.resolveRootContainerId(e)}function br(e){return e?{...e,patch:e.patch}:null}function Ou(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(S=>{if(S.id===t.systemDefaults.environmentLightId){a=!0;let g=t.systemDefaults.normalizeEnvironmentLightGameObject(S);return s=s||g!==S,g}if(S.id===t.systemDefaults.sunLightId){i=!0;let g=t.systemDefaults.normalizeSunLightGameObject(S);return s=s||g!==S,g}if(t.isCameraGameObject(S)){if(!o){o=!0;let g=t.systemDefaults.normalizeCameraGameObject(S);return s=s||g!==S,g}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(S)}if(t.isLightGameObject(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=!0,g}if(!t.isCustomTransformType?.(S.transformType)&&kk(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=s||g!==S,g}return S}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(S=>S.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function kk(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function Ru(e,t,r){let n=r.normalizeRootTransformDocument(Ok(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function tc(e){return{normalizeFieldValue:e.normalizeFieldValue,validateField:({document:t,gameObject:r,path:n,value:o})=>e.validateField(t,r,n,o),blockFieldPatch:({document:t,targetId:r,path:n,value:o})=>rc(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Cu(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=Ig(a,{...r===o.systemDefaults.horizontalLightAnglePath?{horizontalAngleDeg:n}:{},...r===o.systemDefaults.elevationLightAnglePath?{elevationAngleDeg:n}:{}});return i===a?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(s=>s.id===t?i:s)}}}function rc(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return!1;let i=o.isCameraGameObject(a),s=o.isLightGameObject(a),c=o.isProtectedSystemGameObject(a),d=a.id===o.systemDefaults.sunLightId&&a.light?.type==="directional"&&(r==="transform.rotation"||r.startsWith("transform.rotation."));if(r.startsWith("transform.")&&c&&!d||r.startsWith("camera.")&&!i)return!0;if(r.startsWith("camera.")&&i){let u={camera:o.systemDefaults.mergeCameraDefaults(a.camera)};if(Oe(u,r,n),u.camera&&(u.camera=o.systemDefaults.normalizeCameraAfterFieldPatch(u.camera,r),o.systemDefaults.hasInvalidCameraRelationships(u.camera)))return!0}return!!(r.startsWith("light.")&&!s||r==="light.type"&&(a.id===o.systemDefaults.environmentLightId&&n!=="hemispheric"||a.id===o.systemDefaults.sunLightId&&n!=="directional")||r==="transformType"&&(i&&n!=="camera"||s&&n!=="light"||!s&&n==="light"||n==="camera"&&!i&&o.hasCamera(e,t)))}function Ok(e,t,r){let n=t.type==="document.replace"?null:t.patch;if(n){if(n.kind==="scene.material-asset.field")return r.patchMaterialAssetField(e,n.materialAssetId,n.path,n.value);if(n.kind==="scene.material-asset.replace")return r.replaceMaterialAsset(e,n.materialAssetId,n.materialAsset);if(n.kind==="scene.material-asset.create")return r.addMaterialAsset(e,n.materialAsset);if(n.kind==="scene.material-asset.delete")return r.deleteMaterialAsset(e,n.materialAssetId);if(n.kind==="scene.material-asset.create-and-bind")return r.addMaterialAssetAndBind(e,n.targetId,n.bindingPath,n.materialAsset);if(n.kind==="scene.prefab-asset.create")return r.addPrefabAsset(e,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-asset.create-from-game-object"||n.kind==="scene.prefab-asset.duplicate")return r.addPrefabAsset(e,n.prefabAsset);if(n.kind==="scene.prefab-asset.field")return r.patchPrefabAssetField(e,n.assetId,n.path,n.value);if(n.kind==="scene.prefab-asset.replace")return r.replacePrefabAsset(e,n.assetId,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-material-asset.duplicate-and-bind")return r.addMaterialAssetAndBindPrefabOverride(e,n.assetId,n.bindingPath,n.materialAsset);let o=r.reduceExtensionPatch?.({document:e,patch:n,command:t});if(o)return o;if(n.kind==="game-object.field"&&r.isDirectionalLightAnglePath(n.path)||n.kind==="game-object.field"&&r.isCustomFieldPatchPath?.(n.path))return r.patchGameObjectField(e,n.targetId,n.path,n.value);if(n.kind==="game-object.rendering-alpha-index-migration")return Ck(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return pu(e,t,Rk(r))}function Rk(e){return{field:tc(e),serializedProperty:{validateField:e.validateSerializedPropertyField},assetPlacement:{createGameObjectGuid:e.createGameObjectGuid,resolveLocalTransform:({document:t,parentId:r,worldTransform:n})=>e.resolveLocalTransform({document:t,parentId:r,worldTransform:n})},isProtectedDuplicateSource:t=>e.isProtectedSystemGameObject(t),isProtectedDeleteTarget:t=>e.isProtectedSystemGameObject(t)}}function Ck(e,t){return Hl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Io(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return vk(e.document,a,r,s,t);if(t.isRootTransformPath(i,r))return null;if(r==="marker.target.objectId"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTargetUpdateCommand(e.document,i,n);return l?py(i,"marker.target",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?py(i,"marker.type",l,t):null}if(t.isDirectionalLightAnglePath(r)&&typeof n=="number"&&Number.isFinite(n))return{label:`Patch ${i} ${r}`,patch:t.createDirectionalLightPatch(i,r,n),changedId:i,changedIds:[i],reprojectIds:[i]};let c=t.createCustomInspectorPropertyPatch?.({...e,gameObject:a,path:r,value:n});if(c)return c;let d=t.collectChangedIdsForFieldPath(e.document,i,r),u=t.isProjectionShapePath(r)||t.isArtistMaterialPatchPath(r)||t.isCustomProjectionPath?.(r)?[i]:void 0;return{label:`Patch ${i} ${r}`,patch:t.createGameObjectFieldPatch(i,r,n),changedId:i,changedIds:d,...u?{reprojectIds:u}:{}}}function nc(e,t,r,n,o){let a=o.patchCustomGameObjectField?.({document:e,targetId:t,path:r,value:n});if(a)return a;if(r.startsWith("metadata.")||o.isDirectionalLightAnglePath(r)){let s=o.findGameObject(e,t);if(!s)return e;let c=o.normalizeValue(r,n);return!o.validateValue(e,s,r,c).ok||o.blockFieldPatch(e,t,r,c)?e:o.isDirectionalLightAnglePath(r)&&typeof c=="number"&&Number.isFinite(c)?o.patchDirectionalLightAngleField(e,t,r,c):Gk(e,t,r,c,o)}let i=wn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function gy(e,t,r,n,o){let a=Array.from(new Set(t.filter(Boolean)));if(a.length===0)return e;let i=o.patchCustomGameObjectsField?.({document:e,targetIds:a,path:r,value:n,patchSingle:(c,d,u,l)=>nc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return jk(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>nc(c,d,r,n,o),e);let s=Ga(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function py(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function vk(e,t,r,n,o){let a=Xb({document:e,gameObject:t,bindingPath:r,sourceMaterialAssetId:n,isBindingPathAllowed:s=>o.isMaterialBindingPathAllowed(t,s)});return a?{label:`Duplicate material ${o.findMaterialAssetName(e,n)??n} for ${t.name??t.id}`,patch:a.patch,changedId:a.changedId,changedIds:a.changedIds,createdId:a.createdId,reprojectIds:a.reprojectIds}:null}function Gk(e,t,r,n,o){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>{if(a.id!==t)return a;let i=structuredClone(a);return Oe(i,r,n),i.metadata&&Object.keys(i.metadata).length===0&&delete i.metadata,i})}}}function jk(e,t,r,n,o){let a=new Set(t),i=o.normalizeValue(r,n),s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id))return d;let u=d;if(!o.validateValue(e,u,r,i).ok||o.blockFieldPatch(e,d.id,r,i))return d;let l=structuredClone(d);return Oe(l,r,i),l.metadata&&Object.keys(l.metadata).length===0&&delete l.metadata,s=!0,l});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function Sy(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:bn(r.path,r.value)};return ja({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return by({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=bn(t.path,t.value),n=by({...t,value:r,services:e});return n.length===0?null:{label:`Patch ${n.length} GameObjects ${t.path}`,patch:e.createFieldBatchPatch(n.map(o=>({targetId:o,path:t.path,value:r}))),changedIds:n,...e.isSerializedMultiProjectionPath(t.path)?{reprojectIds:n}:{}}}}}function by(e){return e.services.isSerializedMultiFieldPath(e.path)?e.targetIds.filter(t=>{let r=e.services.findGameObject(e.document,t);return e.services.canPatchCustomSerializedMultiField?.({document:e.document,targetId:t,path:e.path,value:e.value})===!1||e.services.isSerializedMultiProjectionPath(e.path)&&(!r||e.services.isCameraGameObject(r)||e.services.isLightGameObject(r))?!1:!!e.services.createInspectorPropertyPatch({document:e.document,targetId:t,path:e.path,value:e.value})}):[]}var Nk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Fk=/^transform\.(position|rotation|scale)$/,_k=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function wn(e,t,r,n,o={}){return $k({document:e,targetId:t,path:r,value:n,options:o})}function Ga(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||vu(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=bu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function gu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if(vu(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=Iy(c,d.path,u,r,!0)))}return!c||JSON.stringify(c)===JSON.stringify(i)?i:(o=!0,c)});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function $k(e){if(vu(e.targetId,e.path))return e.document;let t=_(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=bu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function bu(e,t,r,n={}){let o=Iy(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function Iy(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?yy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?hy(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return dn(a)&&Lk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=Bk(t,r);return Oe(a,t,c),Vk(a),a}if(t.startsWith("metadata."))return Oe(a,t,r),a.metadata&&Object.keys(a.metadata).length===0&&delete a.metadata,a;if(t==="instance.assetId"){let c=Se(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??Wk)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return Uk(a,r,n),a;if(Kk(a,t,r)){let c=i?yy(a):null;return i&&c&&!Ey(i,c)?lo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=Py(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=Hk(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=Ty(a.light,n),delete a.camera,n.clearCustomTransformState?.(a,"light"),delete a.primitive,Oe(a,t,r),(t==="light.direction"||t.startsWith("light.direction."))&&a.light?.type==="directional"&&(a.light.direction=ya(a.light.direction,s??void 0));let c=s?hy(a):null;return s&&c&&!Ey(s,c)?Ss(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Ul(a)),a}function yy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function hy(e){return e.light?.type==="directional"?{...e.light.direction}:null}function Ey(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lk(e,t,r){if(!zk(t,r))return;let n=e.shadow;e.shadow={cast:t==="shadow.cast"?r===!0?"enabled":"none":n?.cast==="enabled"?"enabled":"none",receive:t==="shadow.receive"?r===!0?"enabled":"none":n?.receive==="enabled"?"enabled":"none"}}function zk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function Bk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function Vk(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function vu(e,t){return ue(e)&&Nk.test(t)}function Uk(e,t,r){let n=t==="plain"||t==="light"||t==="camera",o=!n&&r.isCustomTransformType?.(t)===!0;if(!n&&!o)return;let a=t;e.kind="transform",e.transformType=a,delete e.primitive,a==="camera"?e.camera=Py(e.camera,r):delete e.camera,a==="light"?e.light=Ty(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function Kk(e,t,r){let n=t.match(Fk);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:qe(r)&&(a.scale={...r}),!0):(qe(r)&&(a[i]=i==="rotation"?{x:Ht(r.x),y:Ht(r.y),z:Ht(r.z)}:{...r}),!0)}let o=t.match(_k);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Ht(r):r;return i==="scale"?a.scale={...ot(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function Py(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):xy(e)}function Hk(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function Ty(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):xy(e)}function Wk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function xy(e){return qk(e)??{}}function qk(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var wy=["position","rotation","scale"],ky=["x","y","z"],Jk=1e-6;function Gu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Et():ws(r)?r:null;if(!a)return t;for(let i of wy)for(let s of ky)t.push(Zk({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=Se(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),vy(e.gameObject)&&t.push(...Xk({gameObject:e.gameObject,validateField:e.validateField})),t}function Oy(e){let t=[];for(let r of wy)for(let n of ky){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?ot(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(Tt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>Jk),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:at(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function oc(e){if(e.length===0)return[];let t=e.map(n=>n.active!==!1),r=t[0]??!0;return[{path:"enabled",label:"Enabled",valueType:"boolean",value:r,mixed:t.some(n=>n!==r),readOnly:!1,descriptor:{path:"enabled",label:"Enabled",valueType:"boolean",getValue:()=>r}}]}function La(e){return e.length===0||e.some(r=>!vy(r))?[]:[Dy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Dy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Xk(e){return[Ay({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Ay({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Ay(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>Ry(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=bn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:wn(t,n.targetId,e.path,o)}}}function Dy(e,t){let n=e.map(a=>Ry(a,t.path,t.defaultValue))[0]??t.defaultValue,o=Yk(e,t.path);return{path:t.path,label:t.label,valueType:t.valueType,value:n,mixed:o,readOnly:!1,...t.options?{options:t.options}:{},descriptor:{path:t.path,label:t.label,valueType:t.valueType,...t.options?{options:t.options}:{},getValue:()=>n}}}function Yk(e,t){let r=e.map(n=>Cy(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function Ry(e,t,r){let n=Cy(e);return t==="shadow.cast"?My(n.cast):t==="shadow.receive"?My(n.receive):r}function My(e){return e==="enabled"}function Cy(e){return He(e.shadow).shadow??{}}function vy(e){if(Z(e)||e.transformType==="camera"||e.transformType==="light"||e.camera||e.light)return!1;let t=Y(e);return t==="instance"||t==="primitive"||t==="transform"}function Zk(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=ot(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?at(Tt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>Qk({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function Qk(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=_(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Ht(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...ot(n,"scale"),[e.axis]:i}:ot(n,"scale");return eO(e.document,e.targetId,{position:s,rotation:c,scale:d})}function eO(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Cl(n,r):n)}}}function Gy(e){let t=new Map(e.document.scene.gameObjects.map(o=>[o.id,o])),r=e.targetIds.map(o=>t.get(o)??null).filter(o=>!!o&&!Z(o));if(r.length===0)return null;let n=r.map(o=>o.id);return{targetIds:n,activeId:e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null,label:e.label??`${r.length} GameObjects`,properties:[...oc(r),...Oy(r),...La(r)]}}var Nu="enabled",jy="shadow.",Ny=200;function _u(e){let t=tO(e.document,e.selectedIds);if(t.length===0)return null;let r=t.map(l=>l.id),n=e.activeId&&r.includes(e.activeId)?e.activeId:r[0]??null,o=e.largeSelectionThreshold??Ny,a=rO(t),i=La(a),s=t.length>o,c=s?nO({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):Gy({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>_y(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Fy({document:e.document,serialized:d,shadowOnly:s,renderingProfile:e.renderingProfile});return u.length===0?null:{targetIds:d.targetIds,activeId:d.activeId,label:d.label,document:e.document,selection:{targetIds:d.targetIds,activeId:d.activeId,document:e.document},sections:u}}function Fy(e){let t=oO(e.document,e.serialized,e.serialized.properties.filter(n=>_y(n.path)),e.renderingProfile),r=ju("common","Common",10,e.serialized.properties.filter(n=>n.path===Nu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,ju("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,ju("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Nu&&!n.path.startsWith(jy)),e.document)].filter(n=>!!n)}function tO(e,t){let r=new Map(e.scene.gameObjects.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.get(a);i&&(Z(i)||o.push(i))}return o}function rO(e){return e.filter(t=>bo({gameObject:t,nodeKind:Y(t)}))}function nO(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:La(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...oc(e.gameObjects),...t]}}function oO(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(b=>[b.id,b])),a=t.targetIds.map(b=>o.get(b)).filter(b=>!!b).filter(b=>bo({gameObject:b,nodeKind:Y(b)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&bo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(b=>b.path==="shadow.cast"),u=r.find(b=>b.path==="shadow.receive");if(!d||!u)return null;let l=Fu(d,0),m=Fu(u,1),f=gn({path:d.path,nodeKind:c,document:e}),S=gn({path:u.path,nodeKind:c,document:e}),g=n!==void 0&&Ts(Rs(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...g?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:S},...g?[_l()]:[]]}}function _y(e){return e.startsWith(jy)}function ju(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=Fu(a,i),c=aO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?gn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Fu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":iO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:sO(e.valueType),order:t,source:e}}function aO(e,t){if(t.startsWith("transform."))return"transform";if(t===Nu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function iO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function sO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var cO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function ja(e){if(ue(e.patch.targetId)&&cO.test(e.patch.path))return e.document;let t=_(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?$y(t):null,n=e.patch.path.startsWith("light.direction")?Ly(t):null,o=Dp(e.document,Gu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=_(o,e.patch.targetId);if(!a)return o;let i=r?$y(a):null,s=n?Ly(a):null,c=r&&i&&!zy(r,i),d=n&&s&&!zy(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?lo(u):u;return d?Ss(l):l})}}}function $y(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function Ly(e){return e.light?.type==="directional"?e.light.direction:null}function zy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lu(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function zu(e){let t=_u({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function Bu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return $u(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),za(t,a&&r?e.createCameraSection?.():null),$u(t,a&&n?e.createLightSections?.():null),za(t,a&&o?e.createMarkerSection?.():null),za(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&($u(t,e.createMaterialSections?.()),za(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function za(e,t){t&&e.push(t)}function $u(e,t){if(t)for(let r of t)za(e,r)}function Vu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?By:void 0;return{id:"outline",title:"Outline",order:60,placement:"body",summary:t?"Configured":"Defaults",persistence:r==="default"?"readonly":"document",effect:r,disabledReason:n,collapsedByDefault:!0,properties:lO(dO(e),r,n)}}var By="Outline fields are showing defaults; configure an outline override before edits affect this object.";function dO(e){let t=e.outline,r=[e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.renderOutline",label:"Render Outline",valueType:"boolean",control:"boolean",value:t?.renderOutline??!1,commitMode:"immediate",order:0}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineWidth",label:"Width",valueType:"number",control:"number",value:t?.outlineWidth??.04,commitMode:"live",order:1,min:0,step:.005,displayPrecision:3,precision:3,stepPrecision:.001}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineColor",label:"Color",valueType:"color",control:"color",value:t?.outlineColor??{r:.03,g:.03,b:.03},commitMode:"immediate",order:2})],n=j({path:"overrides.outline.raw",label:"Raw Override",value:t??"not configured",order:r.length,source:"Document",tags:["Raw"]});return n&&r.push(n),r}function lO(e,t,r){return!t||t==="active"?e:e.map(n=>({...n,readOnly:!0,persistence:n.persistence==="runtime"?"runtime":"readonly",control:n.control==="custom"?n.control:"readonly",effect:n.effect??t,disabledReason:n.disabledReason??r}))}var uO={title:"\u6807\u8BB0",typeLabel:"\u6807\u8BB0\u7C7B\u578B",kindLabel:"\u7A7A\u95F4\u7C7B\u522B",tagsLabel:"\u6807\u7B7E",colorLabel:"\u989C\u8272",noteLabel:"\u5907\u6CE8",geometryLabel:"\u51E0\u4F55",targetLabel:"\u7ED1\u5B9A\u5BF9\u8C61",targetStatusLabel:"\u7ED1\u5B9A\u72B6\u6001",emptyTypeOption:"\u672A\u9009\u62E9",emptyTargetOption:"\u672A\u7ED1\u5B9A",tagsPlaceholder:"\u6807\u7B7E, \u53E6\u4E00\u4E2A\u6807\u7B7E",notePlaceholder:"\u53EF\u9009\u6807\u8BB0\u5907\u6CE8",unselectedSummary:"\u672A\u9009\u62E9",missingTargetPrefix:"\u7F3A\u5931",missingTargetStatus:"\u76EE\u6807\u7F3A\u5931",targetStatusUnbound:"\u672A\u7ED1\u5B9A",targetStatusOk:"\u6B63\u5E38",unsupportedTargetPrefix:"\u4E0D\u652F\u6301\u76EE\u6807"},mO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},fO={box:"\u76D2\u4F53",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Wu(e){let t={...uO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=pO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=hO(r),i=a?.kind==="scene-object"?a.id:"",s=gO(e.document,e.gameObject.id,i,e.isMarkerGameObject,t),c=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,options:o.length>0?o:void 0,commitMode:"change",order:0}),Ku("marker.kind",t.kindLabel,SO(n,e.formatMarkerKindLabel),1),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.tags",label:t.tagsLabel,valueType:"string",control:"string",value:r.tags?.join(", ")??"",commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",commitMode:"blur",placeholder:t.notePlaceholder,order:4}),Ku("marker.geometry.kind",t.geometryLabel,yO(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:i,options:s,commitMode:"change",order:6}),Ku("marker.target.status",t.targetStatusLabel,EO(e.document,a,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:bO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:c}}function pO(e,t,r,n){let o=[{label:r.emptyTypeOption,value:""},...e.map(a=>({label:Hu(a.type,a.label||a.type,n),value:a.type}))];return t&&!o.some(a=>a.value===t)&&o.push({label:Hu(t,t,n),value:t}),o}function gO(e,t,r,n,o){let a=[{label:o.emptyTargetOption,value:""},...e.scene.gameObjects.filter(i=>i.id!==t&&!n(i)).map(i=>({label:i.name||i.id,value:i.id}))];return r&&!a.some(i=>i.value===r)&&a.push({label:`${o.missingTargetPrefix}: ${r}`,value:r}),a}function bO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Hu(t,o?.label||t,n)}function Hu(e,t,r){return r?.(e,t)??t}function SO(e,t){return t?.(e)??mO[e]??e}function yO(e,t){return t?.(e)??fO[e]??e}function hO(e){return e.target?Uu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Uu(e.geometry.target):null}function EO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Uu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Ku(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var Ba={r:1,g:1,b:1,a:1};function IO(e){return{...e}}function Hy(e){let t=IO(e);return{services:t,normalizeLayoutPatchValue:r=>lc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>Zy(r,n,t),canPatchMultiField:(r,n,o,a)=>DO(r,n,o,a,t),patchLayout:(r,n,o)=>MO(r,n,o,t),patchKind:(r,n,o)=>wO(r,n,o,t),patchInspectorField:(r,n,o,a)=>kO(r,n,o,a,t),normalizeGameObject:r=>Rn(r,t),replaceUi:(r,n,o)=>RO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>ac(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>CO(r,n,t),normalizeScales:(r,n,o)=>dc(r,t,n,o),mergeDefaults:r=>dt(r,t.createDefaultGroundDecal,t)}}function Wy(e){return{...e.policy,createDocumentInspectorProperty:e.createDocumentInspectorProperty,normalizeValue:e.normalizeValue,findTarget:e.findTarget,getTargetId:e.getTargetId,getTargetNodeKind:e.getTargetNodeKind,getTargetGroundDecal:e.getTargetGroundDecal,canShowTarget:e.canShowTarget,isUiTarget:e.isUiTarget,canPatchMultiField:e.canPatchMultiField,findTextureAsset:e.findTextureAsset,resolveTextureAssetUrl:e.resolveTextureAssetUrl,getMaterialText:e.getMaterialText,createTexturePickerControlOptions:e.createTexturePickerControlOptions}}var PO=75;function qu(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:eh({x:typeof r.x=="number"?r.x:1,y:typeof r.y=="number"?r.y:1,z:typeof r.z=="number"?r.z:1})}return!/^transform\.scale\.(x|y|z)$/.test(e)||typeof t!="number"||!Number.isFinite(t)?null:Math.max(.001,Math.abs(t))}function lc(e,t={}){let r=qa(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>TO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function TO(e,t,r={}){let n=qa(e);if(!n)return null;let o=nR(n.id)??`layer_${t}`,a=To(n.rect),i=n.fontSize==null?null:ic(n.fontSize),s=n.rotationDeg==null?null:Ao(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:Lr(i)}}}function To(e){let t=qa(e);if(!t)return null;let r=Xt(t.x),n=Xt(t.z),o=ic(t.width),a=ic(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Xt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ic(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function qy(e,t){if(e==="groundDecal.editorPreviewActive")return typeof t=="boolean"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(uc(e))return To(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Jy(e)){let r=Ao(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(mc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(gc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Xy(e)){let r=Xu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(fc(e)||yc(e)||bc(e)){let r=Va(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(pc(e)||hc(e)||Sc(e)){let r=Ua(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(Ec(e)){let r=Ju(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(zr(e)){let r=Wa(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Ka(e){let t=e.match(/^groundDecal\.layers\.(\d+)\.(rect|rotationDeg|textureId|text\.value|text\.fontSize|color|color\.a|tint|tint\.a|text\.color|text\.color\.a|editorPreviewPercent)$/);if(!t)return null;let r=Number(t[1]);return!Number.isInteger(r)||r<0?null:{index:r,field:t[2]}}function uc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function Jy(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function mc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function fc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function pc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function gc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function Xy(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function Ec(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function zr(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ic(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Ka(e)||zr(e)}function Ha(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ic(e)}function xO(e,t,r={}){return t==="rect"?xo(e,r):t==="rotationDeg"?Tc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?sc(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?Yy(e,r):t==="color"||t==="color.a"?cc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?sc(e,r):e.kind==="progress"&&cc(e,r):!1}function Pc(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function xo(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Tc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function sc(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function cc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function Yy(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function Zy(e,t,r={}){let n=e.layers.filter(o=>xo(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Tc(o,r))})}function Va(e){let t=qa(e);if(!t)return null;let r=Xt(t.r),n=Xt(t.g),o=Xt(t.b);if(r==null||n==null||o==null)return null;let a=Xt(t.a);return{r:Lr(Math.max(0,Math.min(1,r))),g:Lr(Math.max(0,Math.min(1,n))),b:Lr(Math.max(0,Math.min(1,o))),...a==null?{}:{a:Lr(Math.max(0,Math.min(1,a)))}}}function Ua(e){let t=Xt(e);return t==null?null:Lr(Math.max(0,Math.min(1,t)))}function Ju(e){let t=Xt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Ao(e){let t=Xt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=Lr(r);return Object.is(n,-0)?0:n}function Xu(e){let t=ic(e);return t==null?null:Lr(t)}function Wa(e){let t=Xt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function Lr(e){return Math.round(e*1e3)/1e3}function xc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?lc(t)??t:uc(e)?To(t)??t:Jy(e)?Ao(t)??t:mc(e)&&typeof t=="string"?t.trim():gc(e)&&typeof t=="string"?t:Xy(e)?Xu(t)??t:fc(e)||yc(e)||bc(e)?Va(t)??t:pc(e)||hc(e)||Sc(e)?Ua(t)??t:Ec(e)?Ju(t)??t:zr(e)?Wa(t)??t:t}function Qy(e,t,r){if(t==="rect"){let n=To(r);return n?AO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Ao(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=Xu(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Po(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ua(r);if(n===null)return null;let o={...e.color,a:n};return Po(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=Ju(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Po(e.tint??Ba,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ua(r);if(n===null)return null;let o={...Ba,...e.tint??{},a:n};return Po(e.tint??Ba,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=Va(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ua(r);if(n===null)return null;let o={...e.text.color,a:n};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function dt(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function Po(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function AO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function eh(e){let t=[e.x,e.y,e.z].filter(n=>Number.isFinite(n));if(t.length===0)return 1;let r=t.reduce((n,o)=>Math.abs(o-1)>Math.abs(n-1)?o:n,t[0]);return Math.max(.001,Math.abs(r))}function DO(e,t,r,n,o){if(!Ha(r))return!1;let a=_O(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=dt(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||zr(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=lc(n,o);return d?Zy(i,d,o):!1}let s=Ka(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Pc(c,o)&&xO(c,s.field,o)}function MO(e,t,r,n){let o=lc(r,n);return o?rh(e,a=>a.id===t?vO(a,o,n):a):e}function wO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:rh(e,a=>a.id===t?GO(a,o,n):a)}function kO(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=dt(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,Rn({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if(zr(r))return OO(e,t,r,n,o);let a=Ka(r);if(!a)return null;let i=!1,s=xc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Pc(l,o)||a.field==="rect"&&!xo(l,o))return d;let m=Qy(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,Rn({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function OO(e,t,r,n,o){let a=Wa(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,Rn({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function RO(e,t,r,n){if(!n.isGroundDecalConfig(r))return e;let o=!1,a=e.scene.gameObjects.map(i=>i.id!==t||!n.isGroundDecalUiGameObject(i)||i.groundDecal.uiKind!==r.uiKind?i:(o=!0,Rn({...i,kind:"transform",transformType:"groundDecal",groundDecal:dt(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function ac(e,t,r,n,o){return r.startsWith("transform.scale")?dc(e,o,t,qu(r,n)):e}function CO(e,t,r){if(t.type==="document.replace")return dc(e,r);let n=t.patch;return n.kind==="game-object.field"?ac(e,String(n.targetId??""),String(n.path??""),n.value,r):n.kind==="game-object.property-field-batch"&&Array.isArray(n.fields)?n.fields.reduce((o,a)=>{let i=qa(a);return ac(o,String(i?.targetId??""),String(i?.path??""),i?.value,r)},e):n.kind==="game-object.field-batch"?Array.isArray(n.targetIds)?n.targetIds.reduce((o,a)=>ac(o,String(a),String(n.path??""),n.value,r),e):e:dc(e,r)}function dc(e,t,r,n){let o=!1,a=e.scene.gameObjects.map(i=>{if(r&&i.id!==r||!t.isGroundDecalUiGameObject(i))return i;let s=G(i);if(!s||!FO(s)||!s.scale)return i;let c=n??eh(s.scale);return Math.abs(s.scale.x-c)<1e-6&&Math.abs(s.scale.y-c)<1e-6&&Math.abs(s.scale.z-c)<1e-6?i:(o=!0,{...i,components:i.components.map(d=>d===s?{...d,scale:{x:c,y:c,z:c}}:d)})});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function Rn(e,t){let r=jO({...e,kind:"transform",transformType:"groundDecal",groundDecal:dt(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function th(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function vO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=dt(e.groundDecal,r.createDefaultGroundDecal,r);return Rn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!xo(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Tc(a,r)&&(d=Qy(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function GO(e,t,r){let n=dt(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return Rn({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function jO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[NO(),...e.components]}}function NO(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function FO(e){return e.type==="Transform"&&e.mode!=="matrix"}function _O(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function rh(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function nh(e,t,r={},n){let o=dt(t,n.createDefaultGroundDecal,n),a=[rR("groundDecal.uiKind","Type",n.createUiKindLabel?.(o.uiKind)??o.uiKind,0),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.width",label:"Width",valueType:"number",control:"number",value:o.size.width,commitMode:"live",order:1,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.depth",label:"Depth",valueType:"number",control:"number",value:o.size.depth,commitMode:"live",order:2,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureWidth",label:"Texture Width",valueType:"number",control:"number",value:o.rendering?.textureWidth??512,commitMode:"change",order:3,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureHeight",label:"Texture Height",valueType:"number",control:"number",value:o.rendering?.textureHeight??512,commitMode:"change",order:4,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.layers",label:"Layout",valueType:"object",control:"custom",customControl:"ground-decal-layout",value:ch(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:eR(o),aspectRatioUsesDecalSize:QO(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(Ky({path:n.layerPairActions.addPath??"groundDecal.layerPairs.add",label:n.layerPairActions.addLabel??"Add item",actionId:n.layerPairActions.addActionId,order:i,icon:"asset",tooltip:n.layerPairActions.addTooltip??"Add an item.",params:{},disabled:!c,disabledReason:c?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"add",pairCount:s}),effect:c?"active":"unsupported"})),i+=1,a.push(Ky({path:n.layerPairActions.removePath??"groundDecal.layerPairs.remove",label:n.layerPairActions.removeLabel??"Remove item",actionId:n.layerPairActions.removeActionId,order:i,icon:"asset",tooltip:n.layerPairActions.removeTooltip??"Remove an item.",params:{},disabled:!d,disabledReason:d?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"remove",pairCount:s}),effect:d?"active":"unsupported"})),i+=1}for(let s=0;s<o.layers.length;s+=1){let c=o.layers[s];if(!c||!Pc(c,n))continue;let d=dh(c,n);if(sc(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=qO(e,r,c,s,d,i,n);u!=="stretch"&&o.lockAspectToBorder===!0&&o.aspectSourceLayerId===c.id&&(l.controlOptions={...l.controlOptions,groundDecalAspectSizeWidth:o.size.width,groundDecalAspectSizeDepthPath:"groundDecal.size.depth",groundDecalAspectTextureWidth:o.rendering?.textureWidth??512,groundDecalAspectTextureHeight:o.rendering?.textureHeight??512,groundDecalAspectTextureWidthPath:"groundDecal.rendering.textureWidth",groundDecalAspectTextureHeightPath:"groundDecal.rendering.textureHeight"}),a.push(l),i+=1,a.push(YO(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&cc(c,n)||c.kind==="textureProgress"&&sc(c,n))&&(a.push(XO(e,c,s,d,i,n)),i+=1),cc(c,n)&&(a.push(JO(e,c,s,d,i,n)),i+=1),Yy(c,n)&&(a.push(n.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${s}.text.value`,label:`${d} Text`,valueType:"string",control:"string",value:c.text.value,commitMode:"blur",order:i,tags:["GroundDecalUI","Text"]})),i+=1,a.push(ZO(e,c,s,d,i,n)),i+=1)}return tR(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function oh(e,t,r,n){let o=n.getTargetGroundDecal(e),a=dt(o,n.createDefaultGroundDecal,n),i=nh(t,a,{...r,enableGroundDecalUiActions:n.isUiTarget?.(e)??!1},n),s=i.find(d=>d.path==="groundDecal.layers");if(!s)throw new Error("Ground Decal Inspector requires the canonical layout property.");let c=i.filter(d=>d!==s).map(d=>({...d,controlOptions:{...d.controlOptions,groundDecalWorkbenchChild:!0}}));return{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:LO(a,n),persistence:"document",collapsedByDefault:!1,properties:[$O(a,[s,...c],n),...c]}}function $O(e,t,r){let n=t.find(a=>a.path==="groundDecal.layers");if(!n||!n.value||typeof n.value!="object"||Array.isArray(n.value))throw new Error("Ground Decal Inspector requires the canonical layout property.");let o={uiKind:e.uiKind,uiKindLabel:r.createUiKindLabel?.(e.uiKind)??e.uiKind,layout:n.value,properties:t.filter(a=>a!==n)};return{...n,label:"Ground Decal Editor",customControl:"ground-decal-workbench",value:o,controlOptions:{...n.controlOptions,refreshInspector:!1}}}function LO(e,t){let r=t.createUiKindLabel?.(e.uiKind)??e.uiKind,n=Math.max(1,Math.round(e.rendering?.textureWidth??512)),o=Math.max(1,Math.round(e.rendering?.textureHeight??512)),a=n===o?`${n}\xB2`:`${n}\xD7${o}`,i=t.canShowLayerPairActions?.(e)??!1?t.getLayerPairs?.(e).length??0:0;return i>0?`${r} \xB7 ${i} item${i===1?"":"s"} \xB7 ${a}`:`${r} \xB7 ${a}`}function ah(e,t,r,n,o){let a=sh(e,t,o);if(a.length<=1)return null;let i=a.find(l=>o.getTargetId(l.target)===r)??a[0];if(!i)return null;let s=zO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=nh(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>VO(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:UO(a,l.path,n,o)}));return d.length===0?null:{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:a.some(l=>l.decal.uiKind!==i.decal.uiKind)?"Mixed":`${a.length} ${o.createUiKindLabel?.(i.decal.uiKind)??i.decal.uiKind} UIs`,persistence:"document",collapsedByDefault:!1,properties:d}}function ih(e,t,r){return sh(e,t,r).map(n=>r.getTargetId(n.target))}function sh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:dt(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function zO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>BO(o,t));return n.every(o=>o===r)}function BO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Pc(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function VO(e,t){return e.path==="groundDecal.raw"?!1:e.path==="groundDecal.uiKind"||e.path==="groundDecal.size.width"||e.path==="groundDecal.size.depth"||e.path==="groundDecal.editorPreviewActive"||zr(e.path)?!0:e.path==="groundDecal.layers"||Ka(e.path)?t:!1}function UO(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(KO(i.decal,t,r,n)));return a.some(i=>i!==o)}function KO(e,t,r,n){if(t==="groundDecal.uiKind")return e.uiKind;if(t==="groundDecal.size.width")return e.size.width;if(t==="groundDecal.size.depth")return e.size.depth;if(t==="groundDecal.editorPreviewActive")return e.editorPreviewActive===!0;if(t==="groundDecal.rendering.textureWidth")return e.rendering?.textureWidth??512;if(t==="groundDecal.rendering.textureHeight")return e.rendering?.textureHeight??512;if(t==="groundDecal.layers")return ch(e,r,n).layers;let o=Ka(t);if(!o)return;let a=e.layers[o.index];if(a)return HO(a,o.field)}function HO(e,t){if(t==="rect")return e.rect;if(t==="rotationDeg")return e.rotationDeg??0;if(t==="textureId")return e.kind==="texture"||e.kind==="textureProgress"?e.textureId:void 0;if(t==="text.value")return e.kind==="text"?e.text.value:void 0;if(t==="text.fontSize")return e.kind==="text"?e.text.fontSize:void 0;if(t==="color")return e.kind==="color"||e.kind==="progress"?e.color:void 0;if(t==="color.a")return e.kind==="color"||e.kind==="progress"?e.color.a??1:void 0;if(t==="tint")return e.kind==="texture"||e.kind==="textureProgress"?e.tint??Ba:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?Yu(e):void 0}function ch(e,t,r){let n=_i(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>xo(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>Vy(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=Vy(t,a,i,r),c=r.getLayerPreviewVisibility?.(a,e);return c?{...s,enabled:s.enabled!==!1&&c.value,previewVisibilityPath:c.path,previewVisibilityBaseEnabled:s.enabled!==!1}:s})}}function Vy(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:dh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Tc(t,n),enabled:t.enabled!==!1,editable:xo(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:WO(e,t,n)}}function dh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function WO(e,t,r){if(t.kind==="texture"||t.kind==="textureProgress"){if(!t.textureId)return;let n=r.findTextureAsset?.(e,t.textureId)??null,o=n?.url??e.resolveTextureAssetUrl?.(t.textureId)??r.resolveTextureAssetUrl?.(t.textureId);return o?{kind:t.kind==="textureProgress"?"imageProgress":"image",url:o,alt:n?.label??t.textureId,imageFit:r.resolveImageFit?.(t)??t.imageFit??"contain",...t.tint?{tint:t.tint}:{},...t.kind==="textureProgress"?{value:Uy(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:Uy(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function Yu(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:PO;return Math.round(Math.max(0,Math.min(100,t)))}function Uy(e){return Yu(e)/100}function qO(e,t,r,n,o,a,i){let s=i.getMaterialText?.("zh"),c=i.findTextureAsset?.(t,r.textureId)??null,d=`groundDecal.layers.${n}.textureId`;return i.createDocumentInspectorProperty(null,e,{path:d,label:`${o} PNG`,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.textureId??"",commitMode:"change",order:a,tags:["GroundDecalUI","TextureAsset"],controlOptions:i.createTexturePickerControlOptions?.(t,s,r.textureId,c)??{currentTextureId:r.textureId,currentTexture:c},coerce:u=>i.normalizeValue(d,u)})}function JO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function XO(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:Yu(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function YO(e,t,r,n,o,a){let i=t.tint??Ba;return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.tint`,label:`${n} Color`,valueType:"color",control:"color",value:i,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function ZO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function QO(e){return e.size.width>0&&e.size.depth>0}function eR(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function tR(e,t){let r=j(t);r&&e.push(r)}function rR(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Ky(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function qa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function nR(e){return typeof e=="string"&&e.trim()?e.trim():null}var Cn="groundDecal";function oR(e){if(e.id!==Cn||e.scene?.kind!==Cn||!e.config||typeof e.config!="object"||Array.isArray(e.config))return null;let t=e.config;return!Array.isArray(t.uiKinds)||t.uiKinds.length===0||t.uiKinds.some(r=>typeof r!="string"||r.trim().length===0)||!t.documentPolicy||typeof t.documentPolicy!="object"||Array.isArray(t.documentPolicy)||typeof t.documentPolicy.createDefaultGroundDecal!="function"||typeof t.documentPolicy.isGroundDecalConfig!="function"?null:t}function lh(e,t){let r=oR(e);if(!r)return null;let n=r.documentPolicy,o=aR(n),a=s=>s?.transformType===Cn&&o.isGroundDecalConfig(s.groundDecal);return iR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>Wy({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:xc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>ou(d,u??""),getMaterialText:gr,createTexturePickerControlOptions:(d,u,l,m)=>qs(d,u,l??"",m)}),getDocumentInspectorPropertyFactory:t,createDefaultGroundDecal:o.createDefaultGroundDecal,createObjectPatch:s=>({kind:"game-object.create-primitive",gameObject:s}),isGroundDecalObject:a,createHierarchyLabel:r.createHierarchyLabel}).contribution}function aR(e){let t=e;return{...e,createDefaultGroundDecal:r=>structuredClone(e.createDefaultGroundDecal(r)),isGroundDecalConfig(r){return e.isGroundDecalConfig(structuredClone(r))},...typeof t.isProjectEditableLayer=="function"?{isProjectEditableLayer:r=>t.isProjectEditableLayer(structuredClone(r))}:{},...typeof t.isLayoutEditableLayer=="function"?{isLayoutEditableLayer:r=>t.isLayoutEditableLayer(structuredClone(r))}:{},...typeof t.isRotationEditableLayer=="function"?{isRotationEditableLayer:r=>t.isRotationEditableLayer(structuredClone(r))}:{}}}function iR(e){let r=(e.features.find(i=>i.id===Cn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=Hy({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=sR({uiKinds:n,documentBridge:o,createInspectorServices:i=>e.createInspectorServices(i,o),getDocumentInspectorPropertyFactory:e.getDocumentInspectorPropertyFactory,createDefaultGroundDecal:e.createDefaultGroundDecal,createObjectPatch:e.createObjectPatch,canShowInspector:e.isGroundDecalObject,isGroundDecalObject:e.isGroundDecalObject,createHierarchyLabel:e.createHierarchyLabel});return{bridge:o,contribution:a,uiKinds:n,resolve(i){return i.id===Cn&&i.scene?.kind===Cn?a:null}}}function sR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Cn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?xc(n,o):void 0,validateInspectorField({path:n,value:o}){if(n==="groundDecal.uiKind")return e.uiKinds.includes(String(o))?{ok:!0,value:o}:{ok:!1,message:"Invalid value for scene node field: groundDecal.uiKind."};if(n==="groundDecal.size.width"||n==="groundDecal.size.depth")return typeof o=="number"&&Number.isFinite(o)&&o>0?{ok:!0,value:o}:{ok:!1,message:`Invalid value for scene node field: ${n}.`};if(n==="groundDecal.layers"){let a=t.normalizeLayoutPatchValue(o);return a?{ok:!0,value:a}:{ok:!1,message:"Invalid value for scene node field: groundDecal.layers."}}return qy(n,o)},isInspectorPatchPath:Ic,isProjectionPath:th,normalizeDocumentAfterCommand:t.normalizeScalesForCommand,normalizeAfterFieldPatch:t.normalizeScaleAfterFieldPatch,fieldMutation:{isCustomTransformType:n=>n==="groundDecal",applyCustomTransformType(n,o){o==="groundDecal"&&(n.groundDecal=t.mergeDefaults(n.groundDecal))},clearCustomTransformState(n,o){o!=="groundDecal"&&delete n.groundDecal},patchCustomTransformField(n,o,a){return o.startsWith("groundDecal.")?(n.kind="transform",n.transformType=n.transformType??"groundDecal",delete n.primitive,n.groundDecal=t.mergeDefaults(n.groundDecal),dR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=qu(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ic(a)?o.reduce((c,d)=>s(c,d,a,i),n):null,reducePatch:({document:n,patch:o})=>o.kind==="game-object.ground-decal-ui.replace"?t.replaceUi(n,String(o.targetId),o.groundDecal):null,createHierarchyPatch:(n,o)=>cR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[oh(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>ah(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>ih(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ha,isSerializedMultiProjectionPath:Ha,getSerializedMultiProbeValue:lR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ha(a)||t.canPatchMultiField(n,o,a,i)}}function cR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=it(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:ye(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function dR(e,t,r){let n=t.split("."),o=e;for(let a of n.slice(0,-1))o=o[a]??={};o[n[n.length-1]]=r}function lR(e){if(e.endsWith(".width")||e.endsWith(".depth"))return 1;if(e.endsWith(".rotationDeg"))return 45;if(e.endsWith("textureWidth")||e.endsWith("textureHeight"))return 512;if(e==="groundDecal.layers")return{layers:[{id:"mainLogo",rect:{x:0,z:0,width:1,depth:1}}]};if(mc(e))return"texture_probe";if(gc(e))return"30";if(fc(e)||yc(e)||bc(e))return{r:1,g:1,b:1,a:1};if(pc(e)||hc(e)||Sc(e))return 1;if(Ec(e))return 75;if(uc(e))return To({x:0,z:0,width:1,depth:1});if(zr(e))return Wa(512)}function Ja(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ac(e,t=4,r="$"){if(!Number.isInteger(t)||t<0||t>100)throw new Error(`json.number.invalidDecimalPlaces: ${t}`);let n=[],o=a=>{if(typeof a=="number"){if(!Number.isFinite(a))throw new Error(`json.number.nonFinite: ${uR(r,n)}`);if(Object.is(a,-0))return 0;if(Number.isInteger(a))return a;let i=Number(a.toFixed(t));return Object.is(i,-0)?0:i}if(Array.isArray(a)){let i;for(let s=0;s<a.length;s+=1){let c=a[s];n.push(s);let d=o(c);n.pop(),!Object.is(d,c)&&(i??=a.slice(),i[s]=d)}return i??a}if(a&&typeof a=="object"){let i=a,s;for(let[c,d]of Object.entries(i)){n.push(c);let u=o(d);n.pop(),!Object.is(u,d)&&(s??={...i},s[c]=u)}return s??a}return a};return o(e)}function uR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var Zu=64*1024,mR=8,uh=256,fR=8*1024,pR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function mh(e){if(!Xa(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!pR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);yR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:bR(t.assetPath),n=Do(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=Do(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=SR(t[a],a));if(t.metadata!==void 0&&!Xa(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!Xa(t.external))throw new Error("asset_import_external_must_be_object");let a=new Set(["platformAssetId","assetPath","assetUrl"]);for(let s of Object.keys(t.external))if(!a.has(s))throw new Error(`asset_import_external_field_not_allowed:${s}`);let i=t.external.assetPath===void 0?void 0:gR(t.external.assetPath,"external.assetPath");t.external={...Do(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Do(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Do(t.external.assetUrl,"external.assetUrl")?{assetUrl:Do(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function gR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=Ja(e);if(!r)throw new Error("empty");if(r.length>1024)throw new Error("too_long");return r}catch{throw new Error(`asset_import_${t}_must_be_project_relative`)}}function bR(e){if(typeof e!="string")throw new Error("asset_import_assetPath_must_be_string");let t=e.trim();if(!t||t.includes("\0")||t.length>4096)throw new Error("asset_import_assetPath_invalid");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||r.startsWith("//"))return r;try{return Ja(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Do(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function SR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(Xa(e)&&Object.keys(e).every(r=>r==="x"||r==="y"||r==="z")&&typeof e.x=="number"&&Number.isFinite(e.x)&&e.x>0&&typeof e.y=="number"&&Number.isFinite(e.y)&&e.y>0&&typeof e.z=="number"&&Number.isFinite(e.z)&&e.z>0)return{x:e.x,y:e.y,z:e.z};throw new Error(`asset_import_${t}_invalid`)}function yR(e){let t=0,r=(n,o)=>{if(o>mR)throw new Error("asset_import_payload_too_deep");if(n===null||typeof n=="boolean")return;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("asset_import_payload_number_invalid");return}if(typeof n=="string"){if(n.length>fR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>uh)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!Xa(n)||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("asset_import_payload_not_json_safe");let a=Object.entries(n);if(t+=a.length,t>uh)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>Zu)throw new Error("asset_import_payload_too_large")}function Xa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ya(){return{isCoreMaterialOverridePath:ll,isMaterialAssetIdOverridePath:ag,addMaterialAsset:Ls}}function fh(e,t=[]){return e.assets.filter(Xe).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=hR(r,t);return[{id:`prefab:${r.id}`,assetId:r.id,guid:r.guid,type:"prefab",kind:"prefab",label:r.displayName??r.id,displayName:r.displayName??r.id,category:r.category??"Prefab",origin:"project",placeable:o.placeable,...o.availability?{availability:structuredClone(o.availability)}:{},dedupeKey:`prefab:${r.guid??r.id}`,prefab:{id:r.id,guid:r.guid,displayName:r.displayName??r.id,category:r.category??"Prefab",...structuredClone(r.prefab),sourceAssetId:n},metadata:structuredClone(r.metadata??{})}]})}function hR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function Qu(e,t,r=Ya()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(tm(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function em(e,t,r=Ya()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(tm(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return mo({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function tm(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function ph(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Dc(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function rm(e,t,r,n,o=Ya()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Xe(s));if(!a)return e;let i=ER(bh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function gh(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Xe(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Dc({...structuredClone(r),id:t});return JSON.stringify(i)===JSON.stringify(o)&&a===e.assets?e:{...e,assets:a.map(s=>s.id===t?i:s)}}function ER(e,t,r,n=Ya()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||tm(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Dc(o))}if(r!=="enabled"&&r!=="none")return e;let i=a.defaults.shadow;a.defaults.shadow={cast:t==="prefab.defaults.shadow.cast"?r:i?.cast==="enabled"?"enabled":"none",receive:t==="prefab.defaults.shadow.receive"?r:i?.receive==="enabled"?"enabled":"none"}}return Object.keys(a.defaults).length===0&&delete a.defaults,o.prefab=a,Dc(o)}return ua(e,t,r)}function bh(e){if(!Xe(e))return e;let t=rg(e);return t.ok?t.prefabAsset:e}function Dc(e){if(!Xe(e))return e;let t=bh(e),r=Ye(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function Sh(e,t,r,n,o=Ya()){let a=o.addMaterialAsset(e,n);return rm(a,t,r,n.id,o)}function hh(e,t,r,n){let o=Le(e,t.assetId),a=t.sourceAssetId??o?.prefab?.sourceAssetId,i=a?e.assets.find(l=>l.id===a):null,s=IR(i,a),c=Mc(i),d=PR(c,!!n.importStructureReady),u=Ih(n.importStructure)?Ph(n.importStructure):[];return wc([s,...d?[d]:[],...u],r)}function IR(e,t){return{id:"prefab-source",label:e?.displayName??t??"Missing source asset",kind:"source",sourceAssetId:t,...e?.metadata?.relativePath?{meta:e.metadata.relativePath}:{}}}function PR(e,t){return e.length===0?null:{id:"prefab-material-slots",label:`${t?"Editable Material Slots":"Meshes / Materials"} (${e.length})`,kind:"group",children:[...e]}}function Mc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(xR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=xh(o.ownerNodePath),i=nt(r),s=i.map(m=>An(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${om(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function Eh(e){return e.map(t=>[t.label,typeof t.primitiveIndex=="number"?`primitive #${t.primitiveIndex}`:null,typeof t.sourceMaterialIndex=="number"?`material #${t.sourceMaterialIndex}`:null,typeof t.triangleCount=="number"?`${t.triangleCount} triangles`:null,TR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
+ `)}function TR(e){if(!e)return null;let t=e.min?e.min.join(", "):"",r=e.max?e.max.join(", "):"";return t&&r?`bounds min ${t}; max ${r}`:t?`bounds min ${t}`:r?`bounds max ${r}`:null}function xR(e){return Or(e)}function Ih(e){return["nodes","materials","textures","animations"].some(t=>Za(e,t).length>0)}function Ph(e){let t=[],r=Za(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:AR(r)});let n=Za(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>nm(i,s,"material"))});let o=Za(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>nm(i,s,"texture"))});let a=Za(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>nm(i,s,"animation"))}),t}function AR(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${om(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function nm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${om(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function Th(e,t,r,n){if(r.itemType==="prefab-material-slot"||r.itemType==="runtime-material"||r.itemType==="runtime-texture")return r;if(r.itemType!=="prefab-node"||r.kind!=="model")return null;let o=typeof r.sourceAssetId=="string"?r.sourceAssetId:t.sourceAssetId;if(!o)return null;let a=e.assets.find(c=>c.id===o),i=Mc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return(Ih(n.importStructure)?Ph(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function wc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?wc(r.children,t):null;if(n)return n}return null}function xh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function om(e,t){return xh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Za(e,t){let n=yh(e)?.[t];return Array.isArray(n)?n.map(yh).filter(o=>!!o):[]}function yh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ah(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ye(n),a=cl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>Dh(n,s))}]}function Dh(e,t){let r=cl(e,t.id).map(n=>Dh(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??DR(t),kind:t.kind,itemType:"prefab-node",...t.guid?{guid:t.guid}:{},...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.childPrefabId?{childPrefabId:t.childPrefabId}:{},...t.sourceNodePath?{sourceNodePath:t.sourceNodePath}:{},...t.transform?{transform:structuredClone(t.transform)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults&&Object.keys(t.defaults).length>0?{defaults:structuredClone(t.defaults)}:{},...t.overrides&&Object.keys(t.overrides).length>0?{overrides:structuredClone(t.overrides)}:{},...r.length>0?{children:r}:{}}}function DR(e){return e.kind==="model"?e.sourceAssetId??e.id:e.kind==="prefabInstance"?e.childPrefabId??e.id:e.kind==="primitive"?e.primitive?.shape??e.id:e.id}function Mh(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(S=>S.id===n),a=Mc(o),i=Oc(o?.metadata?.assetAnalysis),s=am(i?.nodes),c=am(i?.meshes),d=kc(r.importStructure,"nodes").length,u=kc(r.importStructure,"materials").length,l=kc(r.importStructure,"textures").length,m=kc(r.importStructure,"animations").length,f=[kt("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),kt("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(kt("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(kt("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),kt("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?MR(s):"No SDK node analysis",11),kt("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?wR(c):"No SDK mesh primitive analysis",12),kt("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),kt("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),kt("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),kt("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(kt("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",Eh(a),30)),{id:"prefab-source-structure",title:"Source Structure",summary:o?"Readonly GLB / glTF anatomy":"Missing source asset",persistence:"readonly",effect:o?"active":"unsupported",properties:f}}function MR(e){return e.slice(0,8).map((t,r)=>{let n=Rc(t.ownerNodePath)??Rc(t.name)??`node #${typeof t.nodeIndex=="number"?t.nodeIndex:r}`,o=typeof t.meshIndex=="number"?`mesh #${t.meshIndex}`:null,a=typeof t.primitiveCount=="number"?`${t.primitiveCount} primitives`:null;return[n,o,a].filter(Boolean).join(" \xB7 ")}).join(`
5
+ `)}function wR(e){return e.slice(0,8).map((t,r)=>{let n=Rc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=am(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Rc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
+ `)}function kc(e,t){let n=Oc(e)?.[t];return Array.isArray(n)?n.map(Oc).filter(o=>!!o):[]}function Oc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function am(e){return Array.isArray(e)?e.map(Oc).filter(t=>!!t):[]}function Rc(e){return typeof e=="string"&&e.trim()?e.trim():null}function kt(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function wh(e,t,r){let n=e.prefab?.defaults?.shadow;return[Qa({path:"prefab.defaults.shadow.cast",label:"Cast Shadow",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",order:t+0,tooltip:"Controls shadow casting for the entire Prefab definition."},r),Qa({path:"prefab.defaults.shadow.receive",label:"Receive Shadow",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",order:t+1,tooltip:"Controls shadow receiving for the entire Prefab definition."},r)]}function Qa(e,t){let r=n=>t.normalizePrefabAssetFieldValue(e.path,e.coerce?e.coerce(n):n);return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,...e.mixed===!0?{mixed:!0}:{},readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},...e.tooltip?{tooltip:e.tooltip}:{},validate:n=>t.validatePrefabAssetFieldValue(e.path,r(n))?{ok:!0,value:r(n)}:{ok:!1,message:`Invalid prefab field: ${e.path}.`},coerce:r}}function kR(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?OR(e,t,r,n,o,a()):r.itemType==="runtime-material"?kh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?kh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function OR(e,t,r,n,o,a){let i=gr("en"),s=ig(t,r),c=r.prefabNodeId?oo(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Tn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Editable",0),Mo("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),Mo("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Mn.createSelectorInspectorPropertyWithUsage(m,"instance",{path:r.materialAssetIdPath,label:"Material",value:u,order:10,text:i,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,ownerScope:"prefab",prefabAssetId:t.id,prefabNodeId:r.prefabNodeId,sourceBindingPath:r.materialAssetIdPath}},previewContext:n},a)]}}function RR(e,t,r,n,o){return kR(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var CR={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:RR},Oh=CR;function kh(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Read Only",0),Mo("prefab.materialOverride.reason","Reason",e,1),Mo("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function Mo(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function vR(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(b=>b.id===t.sourceAssetId)??null:null,c=r?wc(Ah(e,t,n),r)??hh(e,t,r,n):null,d=c?Th(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Mh(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?oo(i,m):null,S=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?NR(i,f):null,g=f?.kind==="marker"&&f.marker?LR(i,f,o):null;return{targetIds:[i.id],activeId:i.id,label:n.importStructureReady?"Prefab Runtime Ready":t.label,document:e,selection:{targetIds:[i.id],activeId:i.id,scopeType:"prefab-stage",targetKind:"prefab",document:e},sections:[{id:"prefab-stage",title:"Prefab Stage",summary:n.importStructureReady?"Runtime Ready":"Preview",persistence:"document",properties:[Qa({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),j({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),Qa({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...wh(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(b=>!!b)},...S?[S]:[],...g?[g]:[],...l?[l]:[],...u?[u]:[]]}}function GR(e,t,r,n={},o){return vR(e,t,r,n,o,Oh.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var jR={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:GR},Ch=jR;function NR(e,t){let r=FR(t),n=t.parentId?oo(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${_R(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?$R(c):c,readOnly:!1,persistence:"document",commitMode:"live",order:a,step:i==="rotation"?1:.1,validate:d=>typeof d=="number"&&Number.isFinite(d)?{ok:!0,value:d}:{ok:!1,message:"Transform value must be a finite number."},coerce:d=>typeof d=="number"?d:Number(d)}),a+=1}return{id:"transform",title:"Transform",summary:`Relative to: ${n?.name??n?.id??"Prefab"}`,order:20,placement:"body",persistence:"document",collapsedByDefault:!1,properties:o}}function FR(e){return e.transform?.type==="Transform"&&e.transform.mode!=="matrix"?{...e.transform,mode:e.transform.mode??"trs",scale:e.transform.scale??{x:1,y:1,z:1}}:{type:"Transform",mode:"trs",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function _R(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function $R(e){return Math.round(e*180/Math.PI*1e6)/1e6}function LR(e,t,r){let n=t.marker,o=n.target??null,a=o?Rh(o):"",i=[{label:"Unbound",value:""},...Ze(e).filter(c=>c.id!==t.id).map(c=>{let d=c.kind==="marker"?"marker":"scene-object";return{label:c.name??c.id,value:Rh({kind:d,id:c.id})}})];o&&a&&!i.some(c=>c.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(c=>({label:c.label||c.type,value:c.type}));return s.some(c=>c.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type}),{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(c=>c.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[ei({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:c=>typeof c=="string"&&r.markerTypeCatalog.some(d=>d.type===c)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),ei({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:c=>typeof c=="string"&&i.some(d=>d.value===c)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(c=>c.value===a&&!c.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),ei({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:c=>typeof c=="string"}),ei({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:c=>typeof c=="string"}),ei({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:zR})].filter(c=>!!c)}}function ei(e){return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},validate:t=>e.validate(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid Prefab Marker field: ${e.path}.`}}}function Rh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function zR(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return["r","g","b"].every(r=>typeof t[r]=="number"&&Number.isFinite(t[r])&&t[r]>=0&&t[r]<=1)}function vh(e,t){let r=ln(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
+ `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(im({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function im(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Gh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function cm(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function vn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return UR(r)?me(r):Ie(1,1,1)}return Ie(1,1,1)}function Br(e,t){let r=ke(e,t);return r&&It(r)?r:null}function dm(e,t,r){let n=ur(e,t??void 0,r);return n&&It(n)?n:null}function Fh(e,t){let r=ke(e,t.id);return r?$h(r,t.name??t.id):null}function _h(e,t){let r=mm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:$h(o,r.label||n.name||r.id)}function $h(e,t){let r=Fe(e),n=Cc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Cc(BR(o,sm(n,jh(o,n))));if(!a)return null;let i=Cc(Nh(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);jh(i,s)<0&&(i=sm(i,-1));let c=Cc(Nh(i,n));return c?{origin:Ui(e),right:n,up:c,forward:i,label:t}:null}function jh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Nh(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function BR(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function sm(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Cc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?sm(e,1/t):null}function Sr(e,t,r,n={}){let o=t.trim(),a=o?to(HR(e),n).find(i=>i.type===o)?.kind:void 0;return vc(a??r??(o?void 0:"point"))}function vc(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function Lh(e,t){return lm(t)?"box":um(t)&&mm(e)?"object-bounds":"point"}function Gc(e,t,r,n,o={}){let a=Br(e,t.id),i=me(a?.position??Ie(0,0,0)),s=me(a?.rotation??Ie(0,0,0)),c=VR(e,t,r,o)?wo(r):me(a?.scale??vn(t));if(lm(r))return{kind:"box",coordinateSpace:"world",center:i,size:Fc(c),rotation:s};let d=mm(t.marker);return um(r)&&d?{kind:"object-bounds",target:d}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:i,...d?{target:d}:{}}}function zh(e,t,r,n,o){if(o)return um(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Br(e,t.id);return{kind:"point",coordinateSpace:"world",position:me(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function Bh(e,t){let r=e.scene.gameObjects.find(n=>n.id===t)??null;return!r||de(r)?null:{kind:"scene-object",id:r.id,label:r.name||r.id}}function VR(e,t,r,n={}){let o=Sr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Br(e,t.id)?.scale??vn(t);return Uh(a,wo(o))}function Vh(e,t,r,n={}){if(!de(t))return!1;let o=Sr(e,t.marker.type,t.marker.kind,n),a=vc(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Br(e,t.id)?.scale??vn(t);return Uh(i,wo(o))}function wo(e){return lm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function lm(e){return vc(e)==="region"}function um(e){return vc(e)==="object"}function mm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function Uh(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Kh(e){switch(e.kind){case"box":return{kind:"box"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:me(e.position)}:{},...e.target?{target:structuredClone(e.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(e.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:e.coordinateSpace,vertices:e.vertices.map(me),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function jc(e){switch(e.kind){case"box":return me(e.center);case"point":return e.coordinateSpace==="world"?me(e.position):Ie(0,0,0);case"polyhedron":return KR(e.vertices);case"object-bounds":return Ie(0,0,0)}}function Nc(e){return e.kind==="box"&&e.rotation?me(e.rotation):Ie(0,0,0)}function fm(e,t){return e.kind==="box"?Fc(e.size):me(t)}function Fc(e){return{x:Math.max(1e-6,Math.abs(e.x)),y:Math.max(1e-6,Math.abs(e.y)),z:Math.max(1e-6,Math.abs(e.z))}}function _c(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function me(e){return{x:e.x,y:e.y,z:e.z}}function UR(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Ie(e,t,r){return{x:e,y:t,z:r}}function Hh(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function KR(e){if(e.length===0)return Ie(0,0,0);let t={x:Math.min(...e.map(n=>n.x)),y:Math.min(...e.map(n=>n.y)),z:Math.min(...e.map(n=>n.z))},r={x:Math.max(...e.map(n=>n.x)),y:Math.max(...e.map(n=>n.y)),z:Math.max(...e.map(n=>n.z))};return{x:(t.x+r.x)/2,y:(t.y+r.y)/2,z:(t.z+r.z)/2}}function HR(e){return e.scene.markerGraph??null}function $c(e,t={}){let r=QR(e,t);if(r!==e)return $c(r,t);let n=WR(e);if(n!==e)return $c(n,t);let o=Lc(e);if(!o)return e;let a=cr(o),i=qR(e,a);return ra(o,i)?e:Bd(e,i)}function WR(e){let t=Lc(e),r=t?cr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?oC(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>qh(e,hp(c.marker,o),c.gameObjectId,null)),s=cr({...r,markers:[],relations:r.relations.map(c=>yp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function qR(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>JR(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>zd(i.from,r,o)&&zd(i.to,r,o));return{...t,markers:n,relations:a}}function JR(e,t){if(!ta(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ta(e.geometry.target,t);case"point":return ta(e.geometry.target,t);case"box":case"polyhedron":return!0}}function Wh(e,t,r={}){switch(t.type){case"marker.create-box":return XR(e,t.marker,t.parentId??null);case"marker.update":return YR(e,t.markerId,t.patch,r);case"marker.delete":return ZR(e,t.markerId);default:return null}}function XR(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=cr(Lc(e)),o=qh(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return Bd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function YR(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=Vr(e,o,n),i=sr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=cr(void 0);if(ra({...s,markers:[a]},{...s,markers:[i]}))return e;let c=Jh(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function ZR(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=Ep(e,t),o=cr(Lc(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!Ld(a.from,n)&&!Ld(a.to,n))}}}}function QR(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=eC(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function eC(e,t,r={}){return rC(e,t,r)}function qh(e,t,r,n){let o=wo(t.kind),a={position:jc(t.geometry),rotation:Nc(t.geometry),scale:fm(t.geometry,o)},i=n?dm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:Yh(t),components:[{type:"Transform",...i}]}}function Jh(e,t,r,n={}){let o=Br(e,t.id)?.scale??vn(t),a=Vh(e,t,r,n)?wo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:Yh(r),components:tC(e,t,t.components,r.geometry,a)}}function tC(e,t,r,n,o){let a=o??vn(t),i=Br(e,t.id),s={position:cm(n)?me(i?.position??jc(n)):jc(n),rotation:cm(n)?me(i?.rotation??Nc(n)):Nc(n),scale:fm(n,a)},c=dm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function rC(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=Sr(e,t.marker.type,t.marker.kind,r),o=Lh(t.marker,n);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===o)return t;let a=Vr(e,t,r),i=sr({...a,kind:n,markerType:t.marker.type.trim(),geometry:Gc(e,t,n,a.geometry,r)});return Jh(e,t,i,r)}function Xh(e,t={}){return e.scene.gameObjects.filter(de).map(r=>Vr(e,r,t))}function Vr(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?_h(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):Fh(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Sr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:nC(e,t),...n.target?{target:structuredClone(n.target)}:{},...i?{semanticFrame:i}:{},...n.tags?.length?{tags:[...n.tags]}:{},...Object.keys(o).length>0?{metadata:o}:{}}}function nC(e,t){let r=t.marker,n=Br(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??vn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:me(o),size:Fc(i),rotation:me(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?Hh(o,r.geometry.offset):me(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?me(r.geometry.position):me(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(r.geometry.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:r.geometry.coordinateSpace??"world",vertices:r.geometry.vertices.map(me),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function Yh(e){let t=e.metadata?structuredClone(e.metadata):{},r=aC(t.color),n=typeof t.note=="string",o=n?t.note:void 0;return r&&delete t.color,n&&delete t.note,{schemaVersion:1,type:e.markerType,...e.kind?{kind:e.kind}:{},...e.tags?.length?{tags:[...e.tags]}:{},...o!==void 0?{note:o}:{},...r?{color:r}:{},...e.target?{target:structuredClone(e.target)}:{},...e.semanticFrame?{semanticFrame:structuredClone(e.semanticFrame)}:{},geometry:Kh(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function oC(e,t){let r=_c(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function aC(e){if(!e||typeof e!="object")return null;let t=e,r=pm(t.r),n=pm(t.g),o=pm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function pm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function Lc(e){return e.scene.markerGraph??null}function Qh(e){let t=n=>e.getMarkerTypeCatalogFromGraph(Zh(n)),r=n=>{let o=cr(Zh(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of Xh(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Pp(n,o,{sanitizeMarkerGameObjectId:_c});return Tp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(Vd(a)),label:xp(a),...Ap(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:Vd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?t(n).find(m=>m.type===s)??null:null;if(s&&!c)return null;let d=Sr(n,s,i.marker.kind,e.options),u=Vr(n,i,e.options),l=Gc(n,i,d,u.geometry,e.options);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?Bh(n,s):null;if(s&&!c)return null;let d=Vr(n,i,e.options),u=Sr(n,i.marker.type,i.marker.kind,e.options),l=zh(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Sr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=Wh(n,o,e.options);if(a)return a;let i=r(n),s=Ip(i,o,e.options);return ra(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return $c(n,e.options)}}}function Zh(e){return e?.scene.markerGraph}function eE(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?rE(e,n,r,r.id,t):[]})}function tE(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[zc()]};return rE(e,o,a,r,n)}function rE(e,t,r,n,o){let a=[],i=[];nE(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??zc(),isHostRoot:!0,visitedPrefabIds:new Set,derivedObjects:a,markerDescriptors:i});let s=new Set([r.id,...a.map(d=>d.id)]);for(let d of a)d.marker&&(d.marker.target&&s.add(d.marker.target.id),d.marker.geometry.kind==="point"&&d.marker.geometry.target&&s.add(d.marker.geometry.target.id),d.marker.geometry.kind==="object-bounds"&&s.add(d.marker.geometry.target.id));let c={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects.filter(d=>!s.has(d.id)),r,...a]}};return i.flatMap(d=>{let u=c.scene.gameObjects.find(l=>l.id===d.runtimeId);return u?.marker?[{ownerInstanceId:n,prefabAssetId:d.prefabAssetId,localNodeId:d.localNodeId,marker:Vr(c,u,{builtInMarkerTypes:o})}]:[]})}function nE(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Ze(t),o=Ye(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>ao(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(g=>g.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let g=Le(e,d.childPrefabId);g&&nE(e,g,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??zc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let S=d.kind==="marker"&&d.marker?fa({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...S?{marker:S}:{},components:[l?r.rootTransform:d.transform??zc()]}),S&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function zc(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function iC(e){return e?e.list().filter(t=>De(t.shaderId)==null).map(t=>{let r=t.inspector.sections.length,n=t.inspector.fields.length;return{id:`shader:${t.shaderId}`,assetId:t.shaderId,label:t.displayName,kind:"shader",placeable:!1,meta:`${t.shaderId} \xB7 v${t.version} \xB7 ${n} fields`,shader:{shaderId:t.shaderId,displayName:t.displayName,version:t.version,runtimeKind:t.runtimeKind,sectionCount:r,fieldCount:n,...t.sourceFile?{sourceFile:t.sourceFile}:{}}}}):[]}function oE(e){let t=Sy(e.objectCommandServices);return{getHierarchyItems:e.hierarchyFacade.getHierarchyItems,normalizeHierarchyDocument:e.hierarchyFacade.normalizeHierarchyDocument,createRenamePatch:e.hierarchyFacade.createRenamePatch,createCreateGroupPatch:e.hierarchyFacade.createCreateGroupPatch,createCreatePrimitivePatch:e.hierarchyFacade.createCreatePrimitivePatch,createDeleteSubtreePatch:e.hierarchyFacade.createDeleteSubtreePatch,collectSubtreeIdList:e.hierarchyFacade.collectSubtreeIdList,validateReparent:e.hierarchyFacade.validateReparent,createReparentPatch:e.hierarchyFacade.createReparentPatch,validateHierarchyMove:e.hierarchyFacade.validateHierarchyMove,createHierarchyMovePatch:e.hierarchyFacade.createHierarchyMovePatch,validateGroupSelection:e.hierarchyFacade.validateGroupSelection,createGroupSelectionPatch:e.hierarchyFacade.createGroupSelectionPatch,createDuplicateSelectionPatch:e.hierarchyFacade.createDuplicateSelectionPatch,createPlacedAssetPatch:e.hierarchyFacade.createPlacedAssetPatch,applySerializedPropertyPatch:t.applySerializedPropertyPatch,canCreateSerializedMultiPropertyPatch:t.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:t.createSerializedMultiPropertyPatch,createBrowserAssetItems(r,n={}){let o=_e.getCachedUsageIndex(r);return[..._e.createBrowserAssetItems(r,o,n),...iC(n.materialShaderDefinitions),...fh(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=va(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function sC(e,t){if(!e.scene||typeof e.scene!="object"||Array.isArray(e.scene))return null;let r=e.scene;if(r.kind!==e.id)return null;let n=cE(r.contribution);return n?gm(n):t?lh(e,t):null}function iE(e){let t=(e.features??[]).flatMap(p=>{let D=e.resolveFeatureSceneContribution?.(p);if(D)return[gm(D)];let h=sC(p,()=>d);if(h)return[h];let R=cE(p.scene);return R?[gm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=GC(t),o=Qh({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>kC(e.markerTypes,p)}),a=(p,D)=>D?_(p,D):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>wC(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Pl({hasMaterialAsset:Vt,isMarkerGameObject:de,isDirectionalLightAnglePath:uo})],s=(p,D)=>n?.normalizeInspectorValue?.(p,D)??Es(p,D,{isDirectionalLightAnglePath:uo}),c=(p,D,h,R)=>{if(uo(h)&&D.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:D,path:h,value:R});return K||mo({document:p,path:h,nodeKind:ti(D),value:R,extraValidators:i()})},d=(p,D,h)=>ha({document:p,nodeKind:D,property:h,extraValidators:i()}),l={systemDefaults:PC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:Gh,findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isProtectedSystemGameObject:Dt,hasCamera:(p,D)=>p.scene.gameObjects.some(h=>h.id!==D&&At(h)),...n?.fieldMutation},m=xC(e,o,l,a,s,c,n),f=(p,D,h,R)=>nc(p,D,h,R,m),S=(p,D,h,R)=>gy(p,D,h,R,m),g=(p,D)=>gu(p,D,m.fieldMutationOptions),b=(p,D,h)=>hn(p,D,{transform:h}),y=(p,D)=>Kl(p,D),I=TC(e,o,l,f,S,n),E=AC(o),T={isRootTransformPath:ks,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isSerializedMultiFieldPath:p=>RC(p,n),isSerializedMultiProjectionPath:p=>CC(p,n),getSerializedMultiPropertyProbeValue:p=>vC(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Io(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},A=oE({hierarchyFacade:E,objectCommandServices:T,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:D,worldTransform:h})=>ur(p,D??void 0,h)}}),$={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(D=>D.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(D=>D.type==="ImageRenderer"),readNodeKind:ti},z={};return Object.assign(z,{historyDocumentStorage:r,defaults:{camera:Ys,sunLight:_a,environmentLight:kn},reduceDocument:(p,D)=>Ru(p,D,I),ensureEnvironmentDefaults:p=>Ou(p,I),isSelectableHierarchyId:(p,D)=>vl(p,D),resolveDiagnosticLocator:(p,D)=>{let h=D.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=kr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:Mp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:A.getHierarchyItems,normalizeHierarchyDocument:A.normalizeHierarchyDocument,createRenamePatch:A.createRenamePatch,createCreateGroupPatch:A.createCreateGroupPatch,createCreatePrimitivePatch:A.createCreatePrimitivePatch,createDeleteSubtreePatch:A.createDeleteSubtreePatch,createReparentPatch:A.createReparentPatch,createHierarchyMovePatch:A.createHierarchyMovePatch,createGroupSelectionPatch:A.createGroupSelectionPatch,createDuplicateSelectionPatch:A.createDuplicateSelectionPatch,createPlacedAssetPatch:A.createPlacedAssetPatch,validateReparent:A.validateReparent,validateHierarchyMove:A.validateHierarchyMove,validateGroupSelection:A.validateGroupSelection,collectSubtreeIds:pr,createFeatureHierarchyPatch:(p,D)=>n?.createHierarchyPatch?.(p,D)??null,createInspectorPropertyPatch:p=>lC(m,p),createSceneMaterialBindingPatch:p=>dC(e,m,p),createPrefabMaterialBindingPatch:p=>uC(e,p),createMaterialPropertiesPatch:p=>IC(e,m,p),createMaterialAssetCreatePatch:p=>pC(e,p),createMaterialAssetRestorePatch:p=>gC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>bC(e,p),createMaterialAssetDuplicatePatch:p=>SC(e,p),createMaterialAssetDeletePatch:p=>yC(e,p),createMaterialAssetRenamePatch:p=>hC(e,p),createMaterialAssetSetShaderPatch:p=>EC(e,p),patchGameObjectField:f,patchGameObjectsField:S,patchGameObjectPropertiesMany:g,patchGameObjectTransform:b,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>cC(e,m,p),canCreateSerializedMultiPropertyPatch:A.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:A.createSerializedMultiPropertyPatch,createBrowserAssetItems:A.createBrowserAssetItems,addAssetLibraryItemToDocument:A.addAssetLibraryItemToDocument,getInspectorObject:(p,D,h={})=>DC(z,e,o,p,D,aE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,D,h,R={})=>MC(p,D,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,D,h,R={})=>Ch.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,D,h,aE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:zS,mergeLightDefaults:On,sunLightId:"sun_light",normalizePrefabAssetFieldValue:Qu,validatePrefabAssetFieldValue:em,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>Ll({...p,sourceRef:Wt(p.document)},$),createRuntimeInspectorSnapshot:p=>pa({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>eE(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,D,h)=>tE(p,D,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Vs}),z}function cC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=Io({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function dC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=Io({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=sE(r.document,r.targets,r.materialAssetId);return{patch:e.createPatch.gameObjectFieldBatch(o),label:`${r.materialAssetId?"Set":"Clear"} ${o.length} scene material binding${o.length===1?"":"s"}`,changedIds:a,reprojectIds:a,presentationImpact:i}}function lC(e,t){let r=Io(t,e);if(!r||!wr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:sE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function uC(e,t){if(t.targets.length===0||t.materialAssetId&&!Vt(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=Qu(d,t.materialAssetId);if(!em(d,u))return null;if(!s.nodeId){a=ua(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(b=>b.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},S=ua(f,d,u),g={...m,...S.prefab?.overrides?{overrides:structuredClone(S.prefab.overrides)}:{}};S.prefab?.overrides||delete g.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=g}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:mC(t.document,t.targets,t.materialAssetId)}}function sE(e,t,r){let n=new Set(t.map(a=>`${a.objectId}\0${a.path}`)),o=new Set;r&&o.add(r);for(let a of ca(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function mC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=fC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function fC(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[Lt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function pC(e,t){let r=Hb(t.document,t.definition,t.name);return{patch:e.createPatch.materialAssetCreate?.(r)??{kind:"scene.material-asset.create",materialAsset:r},label:`Create material ${r.name}`,changedIds:[],createdId:r.id}}function gC(e,t){return ee(t.document,t.materialAsset.id)?null:{patch:e.createPatch.materialAssetCreate?.(t.materialAsset)??{kind:"scene.material-asset.create",materialAsset:t.materialAsset},label:`Restore material ${t.materialAsset.name}`,changedIds:[],createdId:t.materialAsset.id}}function bC(e,t){let r=Yb({document:t.document,gameObject:t.gameObject,bindingPath:t.bindingPath,profile:t.profile,sourceAsset:t.sourceAsset,sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,sourceMaterialName:t.sourceMaterialName});return r?{...r,patch:e.createPatch.materialAssetCreateAndBind?.({targetId:r.patch.targetId,bindingPath:r.patch.bindingPath,materialAsset:r.patch.materialAsset})??r.patch,label:`Create material ${r.patch.materialAsset.name} from GLB source`,presentationImpact:{inspector:["material"],materials:{assetIds:[r.createdId]}}}:null}function SC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=Wb(t.document,r);return{patch:e.createPatch.materialAssetCreate?.(n)??{kind:"scene.material-asset.create",materialAsset:n},label:`Duplicate material ${r.name??r.id}`,changedIds:[],createdId:n.id,presentationImpact:{inspector:["material"],materials:{assetIds:[n.id]}}}}function yC(e,t){let r=Qb(t.document,t.materialAssetId);return r.ok?{patch:e.createPatch.materialAssetDelete?.(t.materialAssetId)??{kind:"scene.material-asset.delete",materialAssetId:t.materialAssetId},label:`Delete material ${r.materialAsset.name??r.materialAsset.id}`,changedIds:[],presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}:null}function hC(e,t){let r=ee(t.document,t.materialAssetId),n=rt("name",t.name);return!r||tu(r)||typeof n!="string"||!zt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:sa(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function EC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||tu(r))return null;let n=dS(r,t.definition),o=sa(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function IC(e,t,r){if(r.changes.length===0)return null;let n=ee(r.document,r.materialAssetId);if(!n)return null;let o=new Set,a=r.document;for(let c of r.changes){if(!c.path.startsWith("properties.")||o.has(c.path))return null;if(o.add(c.path),c.inheritTexture){if(!no(n.shaderId,c.path))return null;a=$s(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=Io({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=$s(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=sa(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function PC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>Su(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Su(n,"directional"))(r),normalizeCameraGameObject:t(BS),normalizePlainTransformGameObject:t(VS),createDefaultCameraGameObject:qS,createDefaultEnvironmentLightGameObject:XS,createDefaultSunLightGameObject:JS,mergeCameraDefaults:$a,normalizeCameraAfterFieldPatch:US,hasInvalidCameraRelationships:HS,mergeLightDefaults:On}}function TC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Ia,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:Ol,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>$s(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>Jb(i,s,c),addMaterialAsset:(i,s)=>Ls(i,s),deleteMaterialAsset:(i,s)=>eS(i,s),addMaterialAssetAndBind:(i,s,c,d)=>tS(i,s,c,d),addPrefabAsset:(i,s,c)=>ph(i,s,c),patchPrefabAssetField:(i,s,c,d)=>rm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>gh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>Sh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:uo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:it,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>ur(i,s??void 0,c),resolveRootContainerId:ye,ensureDefaultMaterialAssets:Ub,normalizeMaterialBindings:aS}}function xC(e,t,r,n,o,a,i){return{fieldMutationOptions:tc(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>rc(s,c,d,u,r),isRootTransformPath:ks,parseDuplicateMaterialAssetValue:ts,isMaterialBindingPath:wr,isMaterialBindingPathAllowed:(s,c)=>wr(c)&&(!!e.resolveFieldSchema?.(c,ti(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Fp,normalizeMaterialAssetValue:rt,hasMaterialAsset:Vt,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return zt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:sa,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:uo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Cu(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>pr(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:OC,isArtistMaterialPatchPath:es,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?pr(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function AC(e){return ku({findGameObject:(t,r)=>r?_(t,r):null,resolveRootContainerId:ye,isProtectedSystemGameObject:Dt,isProtectedSystemGameObjectId:Ml,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function aE(e,t){return{materialShaderDefinitions:e,...t}}function DC(e,t,r,n,o,a,i,s,c,d){let u=GS(n,o,a);if(u)return u;let l=iu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Lu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:ti,isMarkerGameObject:de,createInspectorSections:(m,f,S)=>{let g=ti(f);return Bu({document:m,gameObject:f,context:S,nodeKind:g,isCameraGameObject:At,isLightGameObject:fo,isMarkerGameObject:de,createBaseSections:()=>Fl({document:m,gameObject:f,nodeKind:g,extraValidators:c(),rootTransform:Fr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:dE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:g,context:S,createDocumentInspectorProperty:i})??[],createCameraSection:()=>xl({nodeKind:g,camera:f.camera,rig:$a(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>Vl({nodeKind:g,gameObject:f,light:On(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(b,y)=>d?.normalizeInspectorValue?.(b,y)??Es(b,y),defaultEnvironmentGroundColor:kn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Wu({document:m,gameObject:f,nodeKind:g,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(b,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((b,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>vh(m,f),createMaterialSections:()=>iu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,g,S,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Vu({nodeKind:g,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function MC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return zu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function wC(e,t,r){return e?r==null&&e.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${t}.`}:e.validate(r)?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${t}.`}:null}function kC(e,t){return to(t,{builtInMarkerTypes:e})}var ti=Y;function OC(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function RC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function CC(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function vC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function cE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function gm(e){let{documentReducerImmutability:t,...r}=e;return r}function GC(e){if(e.length===0)return;let t=r=>{for(let n of e){let o=r(n);if(o!=null)return o}return null};return{documentReducerImmutability:e.every(r=>r.documentReducerImmutability==="preserves-input")?"preserves-input":void 0,transformTypeOptions:dE(e.flatMap(r=>r.transformTypeOptions??[])).slice(Ta.length),normalizeInspectorValue(r,n){for(let o of e){let a=o.normalizeInspectorValue?.(r,n);if(a!==void 0)return a}},validateInspectorField:r=>t(n=>n.validateInspectorField?.(r)),isInspectorPatchPath:r=>e.some(n=>n.isInspectorPatchPath?.(r)),isProjectionPath:r=>e.some(n=>n.isProjectionPath?.(r)),normalizeDocumentAfterCommand:(r,n)=>e.reduce((o,a)=>a.normalizeDocumentAfterCommand?.(o,n)??o,r),normalizeAfterFieldPatch:(r,n,o,a)=>e.reduce((i,s)=>s.normalizeAfterFieldPatch?.(i,n,o,a)??i,r),fieldMutation:jC(e),createInspectorPropertyPatch:r=>t(n=>n.createInspectorPropertyPatch?.(r)),patchGameObjectField:r=>t(n=>n.patchGameObjectField?.(r)),patchGameObjectsField:r=>t(n=>n.patchGameObjectsField?.(r)),reducePatch:r=>t(n=>n.reducePatch?.(r)),createHierarchyPatch:(r,n)=>t(o=>o.createHierarchyPatch?.(r,n)),createInspectorSections:r=>e.flatMap(n=>n.createInspectorSections?.(r)??[]),isSerializedMultiFieldPath:r=>e.some(n=>n.isSerializedMultiFieldPath?.(r)),isSerializedMultiProjectionPath:r=>e.some(n=>n.isSerializedMultiProjectionPath?.(r)),getSerializedMultiProbeValue(r){for(let n of e){let o=n.getSerializedMultiProbeValue?.(r);if(o!==void 0)return o}},canPatchSerializedMultiField:r=>e.every(n=>n.canPatchSerializedMultiField?.(r)!==!1)}}function dE(e=[]){let t=[],r=new Set;for(let n of[...Ta,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function jC(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var bm=["model","texture","image","sound"],Bc=[".glb",".gltf"],Sm=[".png",".jpg",".jpeg",".webp"],lE=[".env",".hdr",".dds",".ktx",".ktx2"],Vc=[...Sm,...lE],Uc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],ko=[...Bc,...Vc,...Uc];function uE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Kc(e,t){let r=uE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Hc(e){let o=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((a,i)=>i===0?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(o)?o:`asset${o}`}function Wc(e,t=""){let r=String(e??"").trim().toLowerCase();if(r==="glb"||r==="gltf"||r==="model")return"model";if(r==="groundtexture"||r==="ground-texture"||r==="texture")return"texture";if(r==="ui"||r==="image"||r==="img")return"image";if(r==="audio"||r==="sound")return"sound";let n=mE(t);return Bc.includes(n)?"model":Uc.includes(n)?"sound":Vc.includes(n)?"texture":null}function mE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function ym(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...ko].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function hm(e,t){return String(e??"").trim()||ym(t)||"Asset"}function Em(e,t){return ym(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function Im(e){return e==="model"?Bc:e==="sound"?Uc:e==="texture"?Vc:e==="image"?Sm:[]}function Tm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Pm(t.x),n=Pm(t.y),o=Pm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Pm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xm(e){return e==="shared"||e==="instance"?e:void 0}function Am(e){return Number.isInteger(e)&&e>=0?e:void 0}var fE="rendering",Gn=Bf;function Ur(e){let t=se(e);return NC(t?.companionConfigs)}function Mm(e){return Ur(e)[fE]??null}function pE(e){return Ar(Ur(e)[Gn])}function NC(e){if(e==null)return{};let t=FC(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw Dm("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=se(o);if(!i)throw Dm("schema.invalidType",`$.companionConfigs.${a}`);a===fE&&gt(i),a===Gn&&qn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function FC(e,t){let r=se(e);if(!r)throw Dm("schema.invalidType",t);return r}function Dm(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var EE="@fps-games/editor.playable-sdk.scene-compiler",IE="3",_C=new Set(["shadowMode","childMaterialBindings","childMaterials"]),$C=new Set(["coordinateSpace","center","size","rotation"]),gE=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function qc(e){TE(e,!0)}function PE(e){let t=la(e);return qc(t.document),t}function Rm(e){TE(e,!1)}function TE(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw P("schema.unsupportedVersion","$.schemaVersion");if(!Array.isArray(r.assets))throw new Error("editor_scene_assets_must_be_array");let n=k(r.scene);if(!Array.isArray(n?.gameObjects))throw new Error("editor_scene_game_objects_must_be_array");if(n.materialAssets!=null&&!Array.isArray(n.materialAssets))throw new Error("editor_scene_material_assets_must_be_array");if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField","$.scene.shadowMapExperiment");VC(r.assets,n.gameObjects),Om(r,"$"),UC(r.assets),BC(r.assets,n.gameObjects),KC(n.gameObjects,r.assets),HC(n.gameObjects),zC(n.materialAssets??[]),t&&WC(r.assets,n.gameObjects),Vs(r),LC(r.assets,n.gameObjects)}function LC(e,t){for(let r=0;r<t.length;r+=1){let n=k(t[r]),o=`$.scene.gameObjects[${r}]`,a=Object.prototype.hasOwnProperty.call(n,"shadow");if(k(n.prefab)){if(a)throw P("schema.forbiddenField",`${o}.shadow`)}else if(dn(n))bE(n.shadow,`${o}.shadow`);else if(a)throw P("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw P("schema.forbiddenField",`${o}.shadowMapExperiment`)}for(let r=0;r<e.length;r+=1){let n=k(e[r]),o=`$.assets[${r}]`,a=k(n.defaults);if(a?.shadow!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(bE(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${o}.prefab.defaults.shadowMapExperiment`);Array.isArray(i.nodes)&&i.nodes.forEach((c,d)=>{let u=k(c),l=`${o}.prefab.nodes[${d}]`,m=k(u?.defaults);if(u?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw P("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function bE(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw P("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw P("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw P("schema.forbiddenField",`${t}.${n}`)}function zC(e){let t=new Set,r=new Set;for(let n=0;n<e.length;n+=1){let o=k(e[n]),a=`$.scene.materialAssets[${n}]`;if(!o)throw P("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw P("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw P("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw P("schema.invalidType",`${a}.id`);if(t.has(i))throw P("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw P("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw P("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw P("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw P("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw P("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=eo(c,o.properties,`${a}.properties`);if(l[0])throw P("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw P("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw P("schema.unknownField",`${a}.${l}`)}}function BC(e,t){let r=new Set(e.map(k).filter(a=>a?.type==="glb").map(a=>C(a?.id)).filter(a=>!!a)),n=new Set(e.map(k).filter(a=>a?.type==="texture").map(a=>C(a?.id)).filter(a=>!!a)),o=new Map;for(let a of e.map(k)){if(a?.type!=="prefab")continue;let i=C(a.id),s=C(k(a.prefab)?.sourceAssetId);i&&s&&o.set(i,s)}for(let a=0;a<e.length;a+=1){let i=k(e[a]);if(i?.type!=="prefab")continue;let s=k(i.prefab),c=C(s?.sourceAssetId),d=C(s?.rootNodeId);if(!c||!r.has(c))throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);let u=Array.isArray(s?.nodes)?s.nodes:[];for(let l=0;l<u.length;l+=1){let m=k(u[l]),f=C(m?.sourceAssetId);if(m?.kind==="model"&&(!f||!r.has(f)))throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let S=C(m.childPrefabId),g=S?o.get(S):null;if(C(m.id)===d&&c!==g)throw P("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==g)throw P("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`)}}}for(let a=0;a<t.length;a+=1){let i=k(t[a]),s=C(k(i?.instance)?.assetId);if(s&&!r.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].instance.assetId`);let c=Array.isArray(i?.components)?i.components:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ModelRenderer")continue;let l=C(u.assetId);if(!l||!r.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`)}for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ImageRenderer")continue;let l=C(u.assetId);if(!l||!n.has(l))throw P("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!hE(m.width)||!hE(m.height))throw P("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function VC(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw P("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw P("schema.invalidValue",`$.assets[${i}].id`);r.add(c)});let n=new Set,o=new Map;t.forEach((a,i)=>{let s=k(a);if(!s)throw P("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw P("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw P("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw P("schema.invalidValue",`$.scene.gameObjects[${i}].components[${u}].type`)})});for(let[a,i]of o){if(!("parentId"in i.value))continue;let s=C(i.value.parentId);if(!s||!o.has(s))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw P("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function Om(e,t){if(Array.isArray(e)){e.forEach((n,o)=>Om(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(_C.has(n))throw P("schema.deprecatedField",a);n==="shadow"&&Ko(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&Om(o,a)}}function UC(e){let t=new Set(e.map(k).filter(i=>i?.type==="prefab").map(i=>C(i?.id)).filter(i=>!!i)),r=new Map;for(let i=0;i<e.length;i+=1){let s=k(e[i]);if(s?.type!=="prefab")continue;let c=k(s.prefab);if(!Array.isArray(c?.nodes))throw P("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);SE(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let S=0;S<c.nodes.length;S+=1){let g=`$.assets[${i}].prefab.nodes[${S}]`,b=k(c.nodes[S]);if(!b)throw P("schema.invalidType",g);SE(b.defaults,`${g}.defaults`);let y=C(b.id);if(!y||!gE.has(String(b.kind)))throw P("schema.invalidValue",g);if(u.has(y))throw P("schema.invalidValue",`${g}.id`);u.add(y),d.push(b)}let l=C(c?.rootNodeId),m=l?d.find(S=>C(S?.id)===l):null,f=!!m&&gE.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==sn||d.length===0||!f)throw P("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((S,g)=>{let b=C(S.childPrefabId);return b?[{prefabId:b,path:`$.assets[${i}].prefab.nodes[${g}].childPrefabId`}]:[]}));for(let S=0;S<d.length;S+=1){let g=d[S];fg(g,new Map(d.map(T=>[C(T.id),T])),`$.assets[${i}].prefab.nodes[${S}]`);let b=C(g.id),y=C(g.parentId);if(b!==l&&(!y||!u.has(y)))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);if(g.kind==="prefabInstance"){let T=C(g.childPrefabId);if(!T||!t.has(T))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].childPrefabId`)}let I=new Set([b]),E=y;for(;E;){if(I.has(E))throw P("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);I.add(E);let T=d.find(A=>C(A.id)===E);E=T?C(T.parentId):null}}}let n=new Set,o=new Set,a=i=>{if(!o.has(i)){n.add(i);for(let s of r.get(i)??[]){if(n.has(s.prefabId))throw P("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function SE(e,t){if(e==null)return;let r=k(e);if(!r)throw P("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw P("schema.invalidType",`${t}.active`)}function KC(e,t){let r=new Map;for(let n of t.map(k)){if(n?.type!=="prefab")continue;let o=C(n.id),a=C(k(n.prefab)?.sourceAssetId);o&&a&&r.set(o,a)}for(let n=0;n<e.length;n+=1){let o=k(e[n]);if(!o||o.prefab==null)continue;let a=k(o.prefab),i=C(a?.prefabId),s=i?r.get(i):null;if(!i||!s)throw P("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].instance.assetId`);let d=Array.isArray(o.components)?o.components:[];for(let u=0;u<d.length;u+=1){let l=k(d[u]);if(l?.type==="ModelRenderer"&&C(l.assetId)!==s)throw P("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function HC(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box")continue;for(let o of $C)if(Object.prototype.hasOwnProperty.call(r,o))throw P("schema.deprecatedField",`$.scene.gameObjects[${t}].marker.geometry.${o}`);if(!(Array.isArray(k(e[t])?.components)?k(e[t]).components:[]).some(o=>k(o)?.type==="Transform"))throw P("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function WC(e,t){let r=new Map,n=new Map;for(let o=0;o<e.length;o+=1){let a=k(e[o]),i=C(a?.id);if(!a||!i)continue;if(a.type==="prefab"){let l=C(k(a.prefab)?.sourceAssetId);l&&n.set(i,l)}let s=k(a.metadata),c=s?.materialSlots;if(c==null){r.set(i,new Set);continue}if(!Array.isArray(c))throw P("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=qC(s?.assetAnalysis),u=new Set;for(let l=0;l<c.length;l+=1){let m=k(c[l]),f=C(m?.slotId);if(!m||!f)throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let S=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let g of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,g))throw P("schema.deprecatedField",`${S}.${g}`);if(!Array.isArray(m.sourceSurfaces))throw P("schema.invalidType",`${S}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw P("schema.invalidValue",`${S}.sourceSurfaces`);for(let g=0;g<m.sourceSurfaces.length;g+=1){let b=`${S}.sourceSurfaces[${g}]`,y=k(m.sourceSurfaces[g]);if(!y||!C(y.ownerNodePath))throw P("schema.invalidValue",b);yE(y,"nodeIndex",b),yE(y,"sourceMaterialIndex",b);for(let E of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[E])||y[E]<0)throw P("schema.invalidValue",`${b}.${E}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(E=>!Number.isInteger(E)||E<0)))throw P("schema.invalidValue",`${b}.nodeIndexPath`);let I=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(I))throw P("schema.invalidValue",`${b}.sourceMeshName`)}if(u.has(f))throw P("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);wm(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);wm(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);wm(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function wm(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw P("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw P("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw P("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw P("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw P("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw P("schema.invalidType",`${s}.override`);"override"in c&&JC(c.override,`${s}.override`)}}function yE(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw P("schema.invalidValue",`${r}.${t}`)}function qC(e){let t=k(e),r=Array.isArray(t?.meshes)?t.meshes:[];return new Set(r.flatMap(n=>{let o=k(n),a=o?.meshIndex,i=Number.isInteger(a)?a:null;return i!=null&&C(o?.name)?[i]:[]}))}function JC(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);if(Oo(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw P("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ni(r,n,t);XC(r.baseColor,`${t}.baseColor`),km(r.normal,`${t}.normal`,["texture","strength"]),km(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),km(r.occlusion,`${t}.occlusion`,["texture","strength"]),YC(r.emission,`${t}.emission`),ZC(r.alpha,`${t}.alpha`)}function XC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","texture","brightness","saturation","contrast","hue"],t),xE(r.color,`${t}.color`),ri(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ni(r,n,t)}function km(e,t,r){if(e==null)return;let n=Ro(e,t);Oo(n,r,t),ri(n.texture,`${t}.texture`),r.includes("strength")&&ni(n,"strength",t)}function YC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","intensity","texture","maskTexture"],t),xE(r.color,`${t}.color`),ni(r,"intensity",t),ri(r.texture,`${t}.texture`),ri(r.maskTexture,`${t}.maskTexture`)}function ZC(e,t){if(e==null)return;let r=Ro(e,t);if(Oo(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw P("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ni(r,n,t);ri(r.texture,`${t}.texture`)}function ri(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw P("schema.invalidValue",`${t}.${n}`)}function xE(e,t){if(e==null)return;let r=Ro(e,t);for(let n of["r","g","b"])QC(r,n,t)}function Oo(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw P("schema.deprecatedField",`${r}.${o}`)}function ni(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw P("schema.invalidType",`${r}.${t}`)}function QC(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw P("schema.invalidValue",`${r}.${t}`)}function Ro(e,t){let r=k(e);if(!r)throw P("schema.invalidType",t);return r}function P(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function C(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function hE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}var ev=Object.freeze({bash:"shell",cjs:"javascript",conf:"config",config:"config",css:"css",env:"dotenv",frag:"glsl",fs:"glsl",glsl:"glsl",htm:"html",html:"html",ini:"config",js:"javascript",json:"json",jsonc:"jsonc",jsx:"javascript",less:"less",md:"markdown",mjs:"javascript",scss:"scss",shader:"glsl",sh:"shell",toml:"toml",ts:"typescript",tsx:"typescript",txt:"text",vert:"glsl",vs:"glsl",wgsl:"wgsl",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"shell"}),tv=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),rv=Object.freeze({png:{kind:"image",mimeType:"image/png"},jpg:{kind:"image",mimeType:"image/jpeg"},jpeg:{kind:"image",mimeType:"image/jpeg"},webp:{kind:"image",mimeType:"image/webp"},gif:{kind:"image",mimeType:"image/gif"},bmp:{kind:"image",mimeType:"image/bmp"},glb:{kind:"model",mimeType:"model/gltf-binary"},mp3:{kind:"audio",mimeType:"audio/mpeg"},wav:{kind:"audio",mimeType:"audio/wav"},ogg:{kind:"audio",mimeType:"audio/ogg"},m4a:{kind:"audio",mimeType:"audio/mp4"},aac:{kind:"audio",mimeType:"audio/aac"},flac:{kind:"audio",mimeType:"audio/flac"}});function Jc(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"",n=r.lastIndexOf(".");return n>0?r.slice(n+1):""}function Cm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return tv[r]??ev[Jc(r)]??null}function AE(e){return Cm(e)!==null}function vm(e){return rv[Jc(e)]??null}var nv="fps.plugin.ground-decal",DE="@fps-games/plugin-ground-decal";function ME(e){iv(e);let t=e.plugins.find(i=>i.pluginId===nv),r=t?av(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:ov(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:sv(e.metadata),project:Object.freeze({projectId:e.projectId,projectName:e.projectName,source:Object.freeze({editorScene:o.document,runtimeScene:o.runtimeArtifact,...o.rendering?{rendering:o.rendering}:{},...o.shadows?{shadows:o.shadows}:{}}),assets:Object.freeze({...a}),features:Object.freeze(n),...e.metadata&&Ce(e.metadata)?{metadata:Object.freeze({...e.metadata})}:{}})})}function ov(e){let t=new Map(e.kinds.map(l=>[l.id,l])),r=new Set(e.editableLayerRoles??[]),n=new Set(e.layoutEditableLayerRoles??[]),o=new Set(e.rotationEditableLayerRoles??[]),a=new Set(e.stretchedImageRoles??[]),i=new Set(e.activePreviewKinds??[]),s=l=>t.has(l),c=l=>{let m=t.get(l)??t.get(e.defaultUiKind);if(!m)throw new Error(`Ground Decal kind is not configured: ${l}`);return structuredClone(m.defaultConfig)},d=l=>cv(l,t),u={defaultUiKind:e.defaultUiKind,isKnownUiKind:s,isProjectEditableLayer:l=>r.size===0||r.has(l.role),isLayoutEditableLayer:l=>n.has(l.role),isRotationEditableLayer:l=>o.has(l.role),createDefaultGroundDecal:c,isGroundDecalConfig:d};return{uiKinds:Object.freeze([...t.keys()]),documentPolicy:u,inspectorPolicy:{...u,isEditableTextureLayer:l=>(l.kind==="texture"||l.kind==="textureProgress")&&(r.size===0||r.has(l.role)),isEditableColorLayer:l=>(l.kind==="color"||l.kind==="progress")&&(r.size===0||r.has(l.role)),isEditableTextLayer:l=>l.kind==="text"&&(r.size===0||r.has(l.role)),useUniformLayoutScaleMode:l=>n.has(l.role),resolveImageFit:l=>"imageFit"in l&&(l.imageFit==="stretch"||l.imageFit==="contain")?l.imageFit:a.has(l.role)?"stretch":"contain",createLayerLabel:l=>dv(l.role),createUiKindLabel:l=>t.get(l)?.label??l,canShowActivePreview:l=>i.has(l.uiKind),getLayerPreviewVisibility:(l,m)=>i.has(m.uiKind)&&l.role==="activeBackground"?{path:"groundDecal.editorPreviewActive",value:m.editorPreviewActive===!0}:null},createHierarchyLabel:l=>t.get(l)?.hierarchyLabel??`${t.get(l)?.label??l} Ground Decal UI`}}function av(e){if(e.packageName!==DE)throw new Error(`Ground Decal Plugin package must be ${DE}.`);if(!e.targets.includes("editor"))throw new Error("Ground Decal Plugin must target editor.");let t=e.config;if(!Ce(t)||t.schemaVersion!==1)throw new Error("Ground Decal Plugin config schemaVersion must be 1.");if(typeof t.defaultUiKind!="string"||!Array.isArray(t.kinds)||t.kinds.length===0)throw new Error("Ground Decal Plugin config must define defaultUiKind and kinds.");let r=new Set;for(let n of t.kinds){if(!Ce(n)||typeof n.id!="string"||typeof n.label!="string"||!Ce(n.defaultConfig))throw new Error("Ground Decal Plugin kinds must contain id, label, and defaultConfig.");if(r.has(n.id))throw new Error(`Duplicate Ground Decal kind: ${n.id}`);if(r.add(n.id),n.defaultConfig.uiKind!==n.id)throw new Error(`Ground Decal defaultConfig.uiKind must match kind id: ${n.id}`)}if(!r.has(t.defaultUiKind))throw new Error(`Ground Decal defaultUiKind is not declared: ${t.defaultUiKind}`);for(let n of["editableLayerRoles","layoutEditableLayerRoles","rotationEditableLayerRoles","stretchedImageRoles","activePreviewKinds"]){let o=t[n];if(o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="string")))throw new Error(`Ground Decal Plugin config.${n} must be an array of strings.`)}return t}function iv(e){if(!Ce(e)||e.schemaVersion!==1)throw new Error("Editor Project definition schemaVersion must be 1.");if(typeof e.projectId!="string"||typeof e.projectName!="string")throw new Error("Editor Project identity is invalid.");if(!Ce(e.authoring)||!Ce(e.authoring.source)||!Ce(e.authoring.assets)||!Array.isArray(e.plugins))throw new Error("Editor Project authoring or Plugin configuration is invalid.")}function sv(e){return Ce(e)?Object.freeze({...Array.isArray(e.markerTypes)?{markerTypes:Object.freeze(e.markerTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{},...Array.isArray(e.relationTypes)?{relationTypes:Object.freeze(e.relationTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{}}):Object.freeze({})}function cv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!Xc(e.size.width)||!Xc(e.size.depth)||!Array.isArray(e.layers))return!1;let r=new Set;for(let n of e.layers){if(!Ce(n)||typeof n.id!="string"||!n.id||typeof n.role!="string"||!n.role||typeof n.kind!="string"||!Ce(n.rect)||!Number.isFinite(n.rect.x)||!Number.isFinite(n.rect.z)||!Xc(n.rect.width)||!Xc(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function Xc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function dv(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var lv=["/__fps_editor_authoring"],uv=[["manifest","/manifest"],["commit","/commit"],["editor-scene","/editor-scene"],["editor-asset-library","/editor-asset-library"],["project-files","/project-files"],["project-media","/project-media"],["project-file","/project-file"],["asset-import","/asset-import"],["save-editor-scene","/save-editor-scene"]];function wE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??lv,o=mv(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=fv(a);return i?{route:a,routeName:i,prefix:o}:null}function mv(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function fv(e){return uv.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function Yc(e){return{statusCode:e,body:null}}async function kE(e,t){let r=wE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return Yc(204);try{if(pv(r.routeName)){if(n!=="GET")return Pe(405,{ok:!1,error:"method_not_allowed"});if(r.routeName==="project-file"){let a=new URL(e.url??"","http://localhost").searchParams.get("path")?.trim()??"";if(!a)return Pe(400,{ok:!1,error:"missing_file_path"});let i=await t.loadProjectFile?.({path:a,route:r});return Pe(200,i??{ok:!1,error:"not_found"})}return Pe(200,await gv(r,t))}if(n!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let o=e.body??await t.readBody?.(e,r)??{};return await bv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:se(o?.details)})}}function pv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function gv(e,t){return e.routeName==="manifest"&&t.loadManifest?t.loadManifest(e):e.routeName==="editor-scene"&&t.loadEditorScene?t.loadEditorScene(e):e.routeName==="editor-asset-library"&&t.loadEditorAssetLibrary?t.loadEditorAssetLibrary(e):e.routeName==="project-files"&&t.loadProjectFiles?t.loadProjectFiles(e):{ok:!1,error:"not_found"}}async function bv(e,t,r){if(e.routeName==="asset-import"){let n=mh(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?Sv(e,t,r):e.routeName==="commit"?Pe(410,await yv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function Sv(e,t,r){let n=t.mode==="prepare-platform-save"?"prepare-platform-save":"local-commit-save",o=await r.saveEditorScene?.({body:t,mode:n,rawEditorScene:t.editorScene,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}async function yv(e,t,r){return r.commit?.({body:t,route:e})??{ok:!1,error:"platform_commit_route_disabled",message:"Save through /__fps_editor_authoring/save-editor-scene so scene.main remains the authoring source of truth."}}function RE(e,t,r={}){let n=PE(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&qn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ue(a)?a:void 0,d=Wt(n),u={...d,compilerId:EE,compilerVersion:IE,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(I=>I.id!==l),f=Tv(n,r.materialShaderDefinitions,!0),S={...n,scene:{...n.scene,materialAssets:f}},g=m.flatMap(I=>Gv(I,d,S,r)),b=g.map(CE);Ev(l,b),Iv(l,b);let y={rootId:l,assets:S.assets.filter(Dv).map(Mv),nodes:b,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Nv(s.plugins,r.shadowMapExperimentConfig,g,l,d.revision),Fi(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function CE(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function Ev(e,t){let r=new Set([e]);for(let n=0;n<t.length;n+=1){let o=t[n].id;if(r.has(o)){let a=new Error(`schema.invalidReference: $.scene.nodes[${n}].id`);throw Object.assign(a,{code:"schema.invalidReference",path:`$.scene.nodes[${n}].id`,nodeId:o}),a}r.add(o)}}function Iv(e,t){let r=new Map(t.map(n=>[n.id,n]));for(let n=0;n<t.length;n+=1){let o=t[n];if(!(o.source?.component!=="PrefabMarker"||!("marker"in o)||!o.marker))for(let a of Pv(o.marker)){let i=r.get(a.target.id);if(a.target.id!==e&&(!i||i.source?.objectId===o.source.objectId))continue;let s=`$.scene.nodes[${n}].marker.${a.path}.id`,c=new Error(`schema.invalidReference: ${s}`);throw Object.assign(c,{code:"schema.invalidReference",path:s,nodeId:o.id,targetId:a.target.id}),c}}}function Pv(e){let t=[];return e.target&&t.push({path:"target",target:e.target}),e.geometry.kind==="point"&&e.geometry.target&&t.push({path:"geometry.target",target:e.geometry.target}),e.geometry.kind==="object-bounds"&&t.push({path:"geometry.target",target:e.geometry.target}),t}function Tv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Gm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Gm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=eo(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Gm("material.propertiesInvalid",c[0].path,c[0].message)}let o=os(xv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Gm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function xv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=LE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...Av(r)]}}}function Av(e){let t=[];for(let r of e.scene.gameObjects){let n=ln(e,r);!n.definition||!Zc(n.definition)||t.push(...vE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function vE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=_E(Ze(e.prefabAsset),Ye(e.prefabAsset)??""),r=t.find(a=>a.id===Ye(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=$E(t,e.prefabAsset),o=[];for(let a of t){if(a.kind==="prefabInstance"&&a.childPrefabId){let d=e.editorDocument.assets.find(u=>u.id===a.childPrefabId);if(d&&Zc(d)){o.push(...vE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=Hv(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=$m({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function Dv(e){return e.type==="glb"||e.type==="texture"}function Mv(e){let t=Ov(e),r=e.type==="glb"?Rv(e):[],n=kv(e.external),o=wv(e.defaults);return{id:e.id,type:e.type,...e.guid?{guid:e.guid}:{},...t?{url:t}:{},...typeof e.warmupCount=="number"&&Number.isInteger(e.warmupCount)&&e.warmupCount>=0?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...typeof e.materialMode=="string"?{materialMode:e.materialMode}:{},...o!==void 0?{defaults:o}:{},...n?{external:n}:{},...r.length>0?{materialSlots:r}:{}}}function wv(e){if(!e)return;let t=structuredClone(e);return Ue(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function kv(e){let t=Ue(e)?e:void 0,r=yr(t?.platformAssetId),n=yr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Ov(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Ue(e.external)?e.external:void 0;return yr(t?.url)??yr(r?.assetUrl)??void 0}function Rv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Cv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ue(o))return[];let a=yr(o.slotId);if(!a)return[];let i=yr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ue(c))return[];let d=yr(c.ownerNodePath),u=oi(c.meshIndex),l=oi(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=oi(c.nodeIndex),f=vv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),S=oi(c.sourceMaterialIndex),g=yr(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...S==null?{}:{sourceMaterialIndex:S},...g?{sourceMeshName:g}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Cv(e){let t=Ue(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ue(n))return[];let o=oi(n.meshIndex),a=yr(n.name);return o==null||!a?[]:[[o,a]]}))}function vv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function oi(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function Gv(e,t,r,n){let o=ln(r,e);return(o.definition&&Zc(o.definition)?_v(e,o.definition,t,r,new Set,n):[jv(e,t,r,n)]).map(i=>{let s=i.kind==="instance"?r.assets.find(d=>d.id===i.instance.assetId):void 0,c=n.inferShadowMapExperimentUpdateClass?.({gameObject:e,runtimeNode:CE(i),...s?{asset:s}:{}})??Fv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function jv(e,t,r,n={}){let o=G(e),a=Se(e),i=Rr(e),s=qv(e),c=Y(e),d=LE(e,r),u=cg(e),l={sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision,...e.guid?{objectGuid:e.guid}:{},objectId:e.id,component:a?"ModelRenderer":i?"ImageRenderer":s||c==="primitive"?"PrimitiveRenderer":c==="transform"?"Transform":"GameObject"},m={id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...zv(r,e,n),...u?{rendering:u}:{},source:l,...o&&"position"in o?{transform:{position:o.position,rotation:o.rotation,...o.scale?{scale:o.scale}:{}}}:{}};if(c==="primitive")return{...m,kind:"primitive",primitive:{shape:s?.shape??"cube"},...d?{overrides:d}:{}};if(i)return{...m,kind:"image",image:{assetId:i.assetId,size:{width:i.size.width,height:i.size.height}},...d?{overrides:d}:{}};if(!a){if(c==="transform"){let f=Lv(e,n),S=f.transformType;delete f.transformType;let g=OE(S)??OE(e.transformType);return{...m,kind:"transform",...g?{transformType:g}:{},...e.camera?{camera:Yv(e.camera)}:{},...e.light?{light:zE(e.light)}:{},...e.marker?{marker:{label:e.name||e.id,...structuredClone(e.marker)}}:{},...f,...d?{overrides:d}:{}}}return{...m,kind:"group"}}return{...m,kind:"instance",instance:{assetId:a.assetId},...d?{overrides:d}:{}}}function Nv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==bd);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Pf({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:bd,schemaVersion:3,data:d}]}function Fv(e){let t=Ue(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=jm(t.skinCount),n=jm(t.morphTargetCount);return r>0||n>0?"skinned":jm(t.animationCount)>0?"dynamic":"static"}function jm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function _v(e,t,r,n,o,a){return GE({prefabAsset:t,sourceRef:r,editorDocument:n,hostGameObject:e,rootRuntimeId:e.id,rootParentId:e.parentId,rootName:e.name??t.displayName??t.id,rootTransform:G(e)??void 0,rootActive:e.active,instanceOverrides:e.overrides,propertyPathPrefix:`assets.${t.id}.prefab.nodes`,visitedPrefabIds:o,compilerOptions:a})}function GE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Ze(e.prefabAsset),r=Ye(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>ao(o,d.id),i=_E(t,n.id),s=$E(i,e.prefabAsset),c=[];for(let d of i){let u=a(d),l=d.id===n.id?e.rootParentId:a(t.find(m=>m.id===d.parentId)??n);if(d.kind==="prefabInstance"&&d.childPrefabId){let m=e.editorDocument.assets.find(f=>f.id===d.childPrefabId);if(m&&Zc(m)){let f=d.id===n.id;c.push(...GE({prefabAsset:m,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeId:u,rootParentId:l,rootName:f?e.rootName??d.name??m.displayName??m.id:d.name??m.displayName??m.id,rootTransform:f?e.rootTransform??d.transform:d.transform,rootActive:f?e.rootActive??d.defaults?.active??e.prefabAsset.prefab?.defaults?.active:d.defaults?.active,instanceOverrides:f?ai(ai(Yt(e.prefabAsset.prefab?.overrides),Yt(d.overrides)),Yt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Nm({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push($v({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:_m(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),Vv({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:_m(e.compilerOptions)})}function $v(e){let t=e.node.id===e.rootNode.id,r=t?e.rootRuntimeTransform??e.node.transform:e.node.transform,n=e.node.kind==="model"&&e.node.sourceAssetId?e.editorDocument.assets.find(i=>i.id===e.node.sourceAssetId):void 0,o=e.node.kind==="model"||e.node.kind==="primitive",a=jE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:zE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...fa(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Nm(e){return{...jE({id:e.id,name:e.name,parentId:e.parentId,transform:e.transform,editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.component,propertyPath:e.propertyPath}),kind:"group"}}function Lv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function jE(e){return{id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Bv(e),source:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,revision:e.sourceRef.revision,...e.hostGameObject.guid?{objectGuid:e.hostGameObject.guid}:{},objectId:e.hostGameObject.id,component:e.component,propertyPath:e.propertyPath},...e.transform&&"position"in e.transform?{transform:{position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}}:{}}}function zv(e,t,r){let n=xs({document:e,casterId:t.id,caster:t,fallbackMode:_m(r)});return Lm(n,!!t.shadow)?{shadowPlan:n}:{}}function Bv(e){if(!e.editorDocument)return{};let t=He(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=xs({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return Lm(o,r)?{shadowPlan:o}:{}}function Lm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function Vv(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>Uv(i)),n={...e.editorDocument,scene:{...e.editorDocument.scene,gameObjects:[...e.editorDocument.scene.gameObjects.filter(i=>!t.has(i.id)),...r]}},o=e.compiledNodes.filter(i=>i.shadow?.receive==="enabled").map(i=>i.id),a=r.find(i=>i.light?.type==="directional"&&i.active!==!1)?.id;return e.compiledNodes.map((i,s)=>{let c=r[s],d=xs({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!Lm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function _m(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function Uv(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function $m(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?FE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=Wv([Fm(Yt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Fm(Yt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:Fm(Yt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Yt(e.instanceOverrides);return NE(ai(n,o),e.asset)}function Fm(e,t,r){return NE(e,t&&t===r?.id?r:void 0)}function NE(e,t){if(!e?.materialSlotBindings)return e;let r=Ue(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ue(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function FE(e,t,r){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"instance",components:[...t.transform?[t.transform]:[],{type:"ModelRenderer",assetId:r}]}}function Kv(e,t){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"primitive",primitive:{shape:t.primitive?.shape??"cube"},components:[...t.transform?[t.transform]:[]]}}function Hv(e,t){return t.kind==="model"&&t.sourceAssetId?FE(e,t,t.sourceAssetId):t.kind==="primitive"?Kv(e,t):null}function Wv(e){let t;for(let r of e){let n=Yt(r);n&&(t=ai(t,n))}return t}function _E(e,t){let r=new Map;for(let s of e){if(!s.parentId)continue;let c=r.get(s.parentId)??[];c.push(s),r.set(s.parentId,c)}let n=[],o=new Set,a=s=>{if(!o.has(s.id)){o.add(s.id),n.push(s);for(let c of r.get(s.id)??[])a(c)}},i=e.find(s=>s.id===t);i&&a(i);for(let s of e)a(s);return n}function $E(e,t){let r=t.prefab?.sourceAssetId;return e.find(n=>n.kind==="model"&&n.sourceAssetId===r)?.id??e.find(n=>n.kind==="model")?.id}function Zc(e){return Xe(e)&&e.prefab.compositionVersion===sn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ye(e)}function qv(e){return e.primitive??null}function LE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=Se(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return Jv(e,t,o)}function Jv(e,t,r){let n=Yt(e.overrides),o=ln(t,e),a=Yt(o.definition?.prefab?.overrides);return ai(a,n)}function ai(e,t){let r=cs(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))Xv(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Yt(e){if(!Ue(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function Xv(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ue(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function yr(e){return(typeof e=="string"?e.trim():"")||void 0}function OE(e){return typeof e=="string"?e:void 0}function Yv(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function zE(e){return e.type==="directional"?Un({schemaVersion:1,type:"directional",intensity:e.intensity,direction:Xo(e.direction),diffuseColor:e.diffuseColor??_a.diffuseColor}):Un({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??kn.diffuseColor,groundColor:e.groundColor??kn.groundColor})}var Zv=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function UE(e){let t=_i(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>Qv(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function Qv(e,t){let r=Ao(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:eG(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:VE(e.value),...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...BE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Co(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:VE(e.value??0),color:Co(e.color),...BE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Co(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Co(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function eG(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Co(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function BE(e){return typeof e=="string"&&Zv.has(e)}function VE(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function KE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return Yc(204);try{if(r==="GET"){let c=oG(await t.loadConfig?.()),d=c.renderingConfig;gt(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:nG(d),normalized:u,summary:Vn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=ii(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});gt(o);let a=Ne(o),i=Vn(a),s=await t.saveConfig?.({body:n,renderingConfig:o,normalized:a,summary:i});return Pe(200,{ok:!0,...s??{},renderingConfig:o,normalized:a,summary:i})}catch(n){let o=tG(n),a=rG(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:ii(n?.details)})}}function tG(e){let t=e?.code;return typeof t=="string"&&t?t:null}function rG(e){let t=e?.path;return typeof t=="string"&&t?t:null}function ii(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function nG(e){return ii(e)??{}}function oG(e){let t=ii(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:ii(t.response)??{}}:{renderingConfig:e??{},response:{}}}function HE(e,t={}){let r=t.generatedBy??"scripts/register-asset.mjs",n=t.codeKeyPolicy??"legacy",o=e.filter(d=>d.codeKey);if(n==="disabled"&&o.length>0){let d=o[0];throw Object.assign(new Error("manifest_code_key_disabled"),{name:"PlayableEditorAssetCatalogGenerationError",details:{codeKeyPolicy:n,assetId:d.assetId,codeKey:d.codeKey}})}let a=e.map(d=>`import ${Hc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
+ `),i=e.map(d=>{let u=_f(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!$f(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Hc(d.assetId)}`,`format: ${JSON.stringify(u)}`,`relativePath: ${JSON.stringify(d.relativePath)}`,d.originalFileName?`originalFileName: ${JSON.stringify(d.originalFileName)}`:"",d.codeKey?`codeKey: ${JSON.stringify(d.codeKey)}`:"",d.category?`category: ${JSON.stringify(d.category)}`:"",typeof d.placeable=="boolean"?`placeable: ${JSON.stringify(d.placeable)}`:"",typeof d.warmupCount=="number"?`warmupCount: ${JSON.stringify(d.warmupCount)}`:"",typeof d.singleton=="boolean"?`singleton: ${JSON.stringify(d.singleton)}`:"",d.materialMode?`materialMode: ${JSON.stringify(d.materialMode)}`:"",d.defaults?`defaults: ${JSON.stringify(d.defaults)}`:"",d.contentHash?`contentHash: ${JSON.stringify(d.contentHash)}`:"",typeof d.byteSize=="number"?`byteSize: ${JSON.stringify(d.byteSize)}`:"",d.external?`external: ${JSON.stringify(d.external)}`:"",d.metadata?`metadata: ${JSON.stringify(d.metadata)}`:"",d.createdAt?`createdAt: ${JSON.stringify(d.createdAt)}`:"",d.updatedAt?`updatedAt: ${JSON.stringify(d.updatedAt)}`:""].filter(Boolean).join(", ");return` ${JSON.stringify(d.assetId)}: { ${l} },`}).join(`
9
9
  `),s=new Map;for(let d of o)s.set(d.codeKey,d.assetId);let c=[...s].map(([d,u])=>` ${JSON.stringify(d)}: ${JSON.stringify(u)},`).join(`
10
10
  `);return[`// This file is generated by ${r}.`,"// Do not edit by hand.","",a,"",'export type GeneratedAssetCatalogKind = "model" | "texture" | "image" | "sound";',"","export interface GeneratedAssetCatalogEntry {"," guid: string;"," assetId: string;"," kind: GeneratedAssetCatalogKind;"," displayName: string;"," url: string;"," format: `.${string}`;"," relativePath: string;"," originalFileName?: string;",...n==="legacy"?[" /** @deprecated Use the canonical assetId for persisted and runtime identity. */"," codeKey?: string;"]:[]," category?: string;"," placeable?: boolean;"," warmupCount?: number;"," singleton?: boolean;"," materialMode?: string;"," defaults?: Record<string, unknown>;"," contentHash?: string;"," byteSize?: number;"," external?: { platformAssetId?: string; assetPath?: string; assetUrl?: string };"," metadata?: Record<string, unknown>;"," createdAt?: string;"," updatedAt?: string;","}","","export const GENERATED_ASSET_CATALOG: Record<string, GeneratedAssetCatalogEntry> = {",i,"};","","export const GENERATED_ASSET_URL_MAP = Object.fromEntries("," Object.entries(GENERATED_ASSET_CATALOG).map(([assetId, entry]) => [assetId, entry.url]),",") as Record<string, string>;","","export const GENERATED_MODEL_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "model").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_TEXTURE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "texture").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_IMAGE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "image").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_SOUND_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "sound").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","/** @deprecated Resolve assets by canonical assetId through GENERATED_ASSET_CATALOG. */","export const ASSET_IDS = {",c,"} as const satisfies Record<string, string>;"].join(`
11
11
  `)+`
12
- `}import zm from"node:fs/promises";import lt from"node:path";var Bm=5;async function si(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await KE(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=PG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...ge(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Bm;let n=await HE(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 KE(e){return e.kind==="model"?eG(e.sourcePath):e.kind==="texture"||e.kind==="image"?tG(e.sourcePath):null}async function HE(e,t={}){try{let r=await WE(e);return mG(r,{...t,sourcePath:e})}catch{return[]}}async function WE(e){let t=lt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await zm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await zm.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function eG(e){try{let t=await WE(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=ZE(t),m=QE(n),f=new Set(l),S=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.length:0),0),g=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.reduce((A,$)=>A+(Array.isArray($?.targets)?$.targets.length:0),0):0),0),b=iG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=sG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,complexity:b});return{kind:"gltf",format:lt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${S} primitives, ${a.length} materials`,complexity:b,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,nodes:rG(n,o,a,u,m,f),meshes:nG(o,a,u),materials:oG(t),diagnostics:y}}catch{return null}}async function tG(e){try{let t=await zm.readFile(e),r=lt.extname(e).toLowerCase(),n=r===".png"?cG(t):r===".jpg"||r===".jpeg"?dG(t):r===".webp"?lG(t):null;if(!n)return null;let o=uG(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 rG(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=eI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:rI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=qE(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function nG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=qE(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function qE(e,t,r){let n=ge(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=nI(a,r),l=oI(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 oG(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=aG(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:XE(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function aG(e,t){let r=[];return ai(r,"baseColor",t?.baseColorTexture),ai(r,"metallicRoughness",t?.metallicRoughnessTexture),ai(r,"normal",e?.normalTexture),ai(r,"occlusion",e?.occlusionTexture),ai(r,"emissive",e?.emissiveTexture),r}function ai(e,t,r){!ge(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 sG(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 cG(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 dG(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 lG(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=BE(e,24)+1,o=BE(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 BE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function uG(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=pG(e,t),i=ZE(e),s=QE(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=hG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let S=r[f],g=Number.isInteger(S?.mesh)?S.mesh:-1;if(g<0||g>=n.length)continue;let b=eI(r,s,c,f);if(!b)continue;let y=n[g],E=Array.isArray(y?.primitives)?y.primitives:[],I=xG(S,y,b),P=tI(y),A=rI(s,f);for(let $=0;$<E.length;$+=1){let z=E[$],p=AG(z,o),D=YE({ownerNodePath:b,nodeIndex:f,meshIndex:g,primitiveIndex:$}),h=nI(z,d),R=oI(z,d),K=E.length>1?`${I} / Primitive ${$}`:I,ne={ownerNodePath:b,nodeIndex:f,nodeIndexPath:A,meshIndex:g,primitiveIndex:$,...P?{sourceMeshName:P}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let F=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};F.sourceSurfaces.push(ne),m.set(p.index,F);continue}l.push({slotId:u.byExactSource.get(D)??EG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:g,primitiveIndex:E.length>1?$:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,S]of m){let g=S.sourceSurfaces.sort(JE);l.push({slotId:u.bySourceMaterialIndex.get(f)??IG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:S.label,sourceSurfaces:g,...S.materialName?{materialName:S.materialName,materialNames:[S.materialName]}:{},...gG(a,[f])})}return l.sort(fG)}function fG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return JE(r,n)}function JE(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 pG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=bG(e,o,t);a&&n.push(a)}return n}function gG(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 bG(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=VE(c);d&&(s.color=d);let u=ii(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={};ii(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={};ii(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};ii(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let S={},g=VE(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),b=g&&(g.r!==0||g.g!==0||g.b!==0);b&&(S.color=g),ii(e,n.emissiveTexture,r,"emission.texture",S,"texture",a),b&&(S.intensity=1),Object.keys(S).length>0&&(o.emission=S);let y={},E=XE(n.alphaMode);if(E&&(y.mode=E),(E==="mask"||E==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:E==="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 I=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...I?{materialName:I}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function VE(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 XE(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function ii(e,t,r,n,o,a,i){let s=SG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function SG(e,t,r,n){let o=ge(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=yG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),S={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...S,reason:"embedded-texture"}};if(!m)return{hint:{...S,reason:"missing-image-uri"}};if(f)return{hint:{...S,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let g=m;try{g=decodeURIComponent(m)}catch{return{hint:{...S,reason:"unresolved-external-texture"}}}let b=lt.dirname(String(r.sourcePath??"")),y=lt.resolve(b,g),E=r.assetsDir?lt.resolve(r.assetsDir):"",I=r.cwd?lt.resolve(r.cwd):"",P=E?lt.relative(E,y):"../";return E&&I&&P&&!P.startsWith("..")&&!lt.isAbsolute(P)?{texture:{url:`/${lt.relative(I,y).split(lt.sep).join("/")}`},hint:{...S,reason:"external-texture"}}:{hint:{...S,reason:"external-texture"}}}function yG(e){let t=ge(e)?e:{},r=ge(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=ge(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=ge(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function hG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!ge(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(!ge(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(YE({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 YE(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function EG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${iI(r)}`}function IG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${iI(t)}`}function PG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(ge(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(ge(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=lt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function ZE(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 QE(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 eI(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(TG(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 TG(e,t){return(ge(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function xG(e,t,r){let n=ge(e)&&typeof e.name=="string"?e.name.trim():"",o=tI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function tI(e){return ge(e)&&typeof e.name=="string"?e.name.trim():""}function rI(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 AG(e,t){let r=ge(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 nI(e,t){let r=ge(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=aI(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 oI(e,t){let r=ge(e)?e:{},n=aI(r),o=n>=0?t[n]:null,a=UE(o?.min),i=UE(o?.max);return a&&i?{min:a,max:i}:null}function aI(e){let t=ge(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function UE(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 ge(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function iI(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 Qc from"node:crypto";import{constants as RG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import ci from"node:fs/promises";import Ot from"node:path";async function cI(e,t={}){try{let r=await DG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ut(n[i]);if(!s)continue;let c=await MG(e,r,s);if(!c)continue;let d=di(s.name)??(c.originalFileName?Ot.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function dI(e){let t=new Set;for(let r of uI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function lI(e){let t=new Map;for(let r of uI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function uI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ut(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ut(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ut(d);u&&t.push(u)}}}return t}function mI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ut(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ut(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let S=ut(f),g=hr(S?.imageIndex),b=di(S?.profilePath),y=g==null?null:r.get(g)??null;if(!y||!b||!kG(b)){m.push(f);continue}let E=ut(u.profile)??{};OG(E,b,{textureAssetId:y}),u.profile=E,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function DG(e){let t=Ot.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await ci.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>sI(e,ut(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await ci.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ut(c);return di(u?.uri)?sI(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 sI(e,t){let r=di(t?.uri);if(!r)return null;let n=gI(r);if(n)return n.bytes;if(Um(r))return null;let o=pI(r);return o?fI(e,o):null}async function MG(e,t,r){let n=di(r.uri);if(n){let f=gI(n);if(f){let E=Vm(f.bytes);return E?{bytes:f.bytes,...E}:null}if(Um(n))return null;let S=pI(n);if(!S)return null;let g=await fI(e,S);if(!g)return null;let b=Ot.basename(S),y=Vm(g);return y?{bytes:g,...y,originalFileName:b}:null}let o=hr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ut(a[o]),s=hr(i?.buffer)??0,c=t.buffers[s],d=hr(i?.byteOffset)??0,u=hr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Vm(l);return m?{bytes:l,...m}:null}async function fI(e,t){if(Ot.isAbsolute(t)||Ot.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await ci.realpath(Ot.dirname(e)),n=Ot.resolve(r,t),o=await ci.realpath(n);return wG(r,o)?await ci.readFile(o):null}catch{return null}}function pI(e){if(Um(e))return null;try{return decodeURIComponent(e)}catch{return null}}function wG(e,t){let r=Ot.relative(e,t);return r===""||!r.startsWith(`..${Ot.sep}`)&&r!==".."&&!Ot.isAbsolute(r)}function gI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function Vm(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function kG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function OG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ut(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Um(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Ot.win32.isAbsolute(e)}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function di(e){return typeof e=="string"&&e.trim()?e.trim():null}function hr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function Go(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await BG(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=jG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:PI(e)});try{await W.access(a,RG.R_OK)}catch(h){let R=vo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=KG(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Zt(e),d=await Qm(a),u=Hc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});Jm(u,a,"source_path");let l=UG(c,n,s,a,d,u,e),m=ae(n.assetName)??l?.originalFileName??v.basename(a),f=ae(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let S=l?.guid??f??Qc.randomUUID(),g=ae(n.projectAssetId),b=Uc(u,S);if(l?.assetId&&l.assetId!==b)throw new U("manifest_asset_id_must_match_guid",{guid:S,assetId:l.assetId,expectedAssetId:b});if(g&&g!==b)throw new U("project_asset_id_must_match_guid",{guid:S,projectAssetId:g,expectedAssetId:b});let y=i===".gltf"?v.posix.join(b,v.basename(a)):`${b}${i}`,E=NG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),I=ui(e,E,u,"target_path"),P=new Date().toISOString(),A=hm(ae(n.displayName)??l?.displayName,m),$=Zc({...Zc(l?.external)??{},...s??{}}),z=!1,p=[],D=null;try{await W.mkdir(v.dirname(I),{recursive:!0});let h=_G(a,I),R=h||await AI(I),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,I),z=!l,i===".gltf"&&await CG(a,I));let F=await xI(e,{existing:l,payload:n,sourcePath:a,targetPath:I,kind:u,guid:S,assetId:b}),Ir=Ke(l?.metadata),er=Ke(F);if(u==="model"&&(Ir.assetAnalysisStatus==="complete"||Object.keys(Ke(Ir.assetAnalysis)).length>0)&&er.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:b,guid:S});if(u==="model"){let tr=await vG({config:e,manifest:c,metadata:F,sourcePath:a,sourceAssetId:b,sourceAssetGuid:S,sourceDisplayName:A,now:P});p=tr.createdPaths,F=mI(F,tr.references)}let Hr=Ym({...l??{},guid:S,assetId:b,kind:u,displayName:A,relativePath:E,originalFileName:m,...o==="legacy"?{codeKey:Em(ae(n.codeKey)??ae(n.assetName)??l?.codeKey,m)}:{},...ae(n.category)?{category:ae(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Am(n.warmupCount)!=null?{warmupCount:Am(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...xm(n.materialMode)?{materialMode:xm(n.materialMode)}:{},...Tm(n.scale)?{defaults:{transform:{scale:Tm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:$,metadata:F,createdAt:l?.createdAt??P,updatedAt:K?P:l?.updatedAt??P});if(!Hr)throw new U("invalid_manifest_entry",{assetId:b,guid:S});D=Hr;let Si=c.findIndex(tr=>tr.guid===S||tr.assetId===b);Si>=0?c[Si]=Hr:c.push(Hr),c.sort(qG),await ZG(e,c)}catch(h){z&&await W.rm(i===".gltf"?v.dirname(I):I,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:S,assetId:b,kind:u,...D?.contentHash?{contentHash:D.contentHash}:{},...D?.external?{external:D.external}:{},displayName:D?.displayName,originalFileName:D?.originalFileName,assetUrl:zG(e,E,u),targetPath:I,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function CG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ae(Ke(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Km(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Km(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Km(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function vG(e){let t=dI(e.metadata),r=lI(e.metadata),n=await cI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=li(d.bytes),l=e.manifest.find(A=>A.kind==="texture"&&A.contentHash===u.contentHash&&Ke(Ke(A.metadata).capabilities).materialTexture!==!1&&Ke(A.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=XG(u.contentHash),f=Uc("texture",m),S=e.manifest.find(A=>A.guid===m||A.assetId===f);if(S)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let g=`${f}${d.extension}`,b=TI(e.config,"texture",g),y=ui(e.config,b,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await AI(y)){let A=await Qm(y);if(A.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:A.contentHash})}else await JG(y,d.bytes),i.push(y);let E=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,I=await xI(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}),P=Ym({guid:m,assetId:f,kind:"texture",displayName:E,relativePath:b,originalFileName:d.originalFileName??`${YG(E)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:I,createdAt:e.now,updatedAt:e.now});if(!P)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(P),a.set(d.imageIndex,P),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=Ke(d.metadata),l=GG(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([b],[y])=>b.localeCompare(y))),S=Object.values(f)[0],g={...u};S?(g.previewTextureAssetId=S,g.previewTextureAssetIdsBySourceAssetId=f):(delete g.previewTextureAssetId,delete g.previewTextureAssetIdsBySourceAssetId),d.metadata=g}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function GG(e){let t={},r=Ke(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ae(a),c=ae(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ae(e.previewTextureAssetId),o=ae(Ke(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function Wm(e,t={}){let r=await II(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function qm(e,t={}){return II(e,t,!0)}async function II(e,t,r){let n=await Zt(e),o=[],a=[];for(let i of n){let s=ui(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await Qm(s)}catch(m){let f=bI(i,m,t,"source-audit",s);if(!r||!f)throw SI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&Ke(i.metadata).assetMetadataVersion!==Bm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await Go(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=bI(i,m,t,"source-analysis",s);if(!r||!f)throw SI(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 bI(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=vo(t)?t.code:t instanceof U?ae(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=vo(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function SI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Zt(e){let t=await Xm(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=Ym(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function jo(e){return e.loadRules?e.loadRules():e.rulesPath?Xm(e.rulesPath,{}):{}}function yI(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 PI(e){let t=yI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:yI(ko)}function jG(e,t){let r=t.toLowerCase();return PI(e).find(n=>r.endsWith(n))??null}function NG(e,t){return t.existing?.relativePath?t.existing.relativePath:FG(e,t.sourcePath,t.kind)??TI(e,t.kind,t.targetFileName)}function TI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function FG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!hI(v.resolve(n),o)||hI(v.resolve(e.generatedDir),o)?null:(Jm(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function hI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function _G(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function $G(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 LG(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 ui(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return $G(a,o,n),LG(v.resolve(e.generatedDir),o,n),Jm(r,o,n),o}function zG(e,t,r){let n=ui(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function Jm(e,t,r){let n=v.extname(t).toLowerCase(),o=Im(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function Xm(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(vo(r)&&r.code==="ENOENT")return t;throw r}}async function BG(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await Xm(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function Ym(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?Zm:ae,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?bm.includes(i)?i:null:Hc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!Gn(r,"originalFileName")||!Gn(r,"codeKey")||!Gn(r,"category")||!Gn(r,"materialMode")||!Gn(r,"contentHash")||!Gn(r,"createdAt")||!Gn(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&&Vr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Vr(r.metadata)==null||"external"in r&&!VG(r.external)))return null;let u=Vr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),S=n(r.materialMode),g=Vr(r.defaults),b=n(r.contentHash),y=Zc(r.external),E=n(r.createdAt),I=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...S?{materialMode:S}:{},...g?{defaults:g}:{},...b?{contentHash:b}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...E?{createdAt:E}:{},...I?{updatedAt:I}:{}}}function Zm(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function Gn(e,t){return!(t in e)||Zm(e[t])!=null}function VG(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&Zm(t[o])!=null)}function Zc(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ae(r.platformAssetId),o;try{if(o=Wa(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ae(r.assetPath)})}let a=ae(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function Vr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function xI(e,t){let r=Vr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r}),o=Vr(n);return o||null}return si({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function UG(e,t,r,n,o,a,i){let s=ae(t.guid),c=ae(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&HG(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&WG(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(ui(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 KG(e){return Zc({...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 HG(e){return ae(Ke(e).platformAssetId)}function WG(e){return ae(Ke(e).assetPath)}function qG(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function Hm(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!vo(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function JG(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function Qm(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...li(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...li(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ae(Ke(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Km(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=Qc.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...li(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,...li(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function li(e){return{contentHash:`sha256:${Qc.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function XG(e){let t=Qc.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 YG(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function AI(e){try{return await W.access(e),!0}catch{return!1}}async function ZG(e,t){let r=zE(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 EI(e.manifestPath),o=await EI(e.registryPath);try{await Hm(e.manifestPath,`${JSON.stringify(t,null,2)}
13
- `),await Hm(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await QG(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 EI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(vo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function QG(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await Hm(e,t.content)}}function ae(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function vo(e){return e instanceof Error&&"code"in e}function DI(e){return{async loadManifest(){let t=await Zt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Zt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Gs(t)];return{ok:!0,assets:r,summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):ej(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await jo(r),o=nj(n.errorCodes),a=await Zt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await Go(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await rj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Gs(d)],l=u.find(m=>m.assetId===c||m.id===c);if(!l)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:l,assets:u,disposition:s&&a.some(m=>m.assetId===c)?"deduplicated":s?"created":"existing"}}}}function ej(e,t,r){return r&&tj(e)?r:t}function tj(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 rj(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 nj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function ef(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Ur(e,t,r){if(e.statusCode=t.statusCode,mi(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function mi(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 vI,readFileSync as GI}from"node:fs";import{mkdir as wI,rename as cj,rm as kI,writeFile as dj}from"node:fs/promises";import{randomUUID as lj}from"node:crypto";import jn from"node:path";import oj from"node:path";var ed=new Map;async function td(e,t){let r=[...new Set(e.map(i=>oj.resolve(i)))].sort(),n=[...new Set(r.map(i=>ed.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)ed.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)ed.get(i)===a&&ed.delete(i)}}import{performance as tf}from"node:perf_hooks";var aj=1,ij=["prepare","compile","validate","stringify","write","checkpoint"];function MI(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:rf(tf.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=tf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=tf.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return sj(e)}}}function sj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=rf(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=ij.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:aj,measuredDurationMs:rf(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function rf(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function jI(e){let t=e.paths,r=fi(t.editorScenePath),n=r?da(r).document:null,o=fi(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=await e.listEditorAssetLibrary(e.server,"report");n&&Rm(n),n&&Ma(n,i);let s=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),i)):null;s&&Wc(s);let c=t.renderingConfigPath?fi(t.renderingConfigPath):void 0;c&&gt(c);let d={...Br(s),...t.renderingConfigPath?{rendering:c}:{}},u=$I(t.shadowsConfigPath),l=se(o),m=typeof l?.version=="number"?l.version:void 0,f=typeof l?.updatedAt=="string"?l.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:s,assets:i,...m===void 0?{}:{version:m},...f===void 0?{}:{updatedAt:f},...Object.keys(d).length>0?{companionConfigs:d}:{},...u?{shadowMapExperimentConfig:u}:{},drift:s?a.detectRuntimeInputDrift(s,o):null,summary:_I(s)}}async function NI(e){Nn(e),RI(e.body,"$",!0),RI(e.rawEditorScene,"$.editorScene");let t=Mm(e.body),r=Br(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&gt(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&LI(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 td(a,()=>(Nn(e),uj(e)))}async function uj(e){let t=MI(),r=t.measure("prepare",()=>mj(e)),n=da(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Nn(e);let a=e.paths,i=Br(e.body),s=Mm(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,vn),u=i[vn],l=Ar(u),m=t.measure("prepare",()=>fi(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),g=LI(e.body)??$I(a.shadowsConfigPath);t.measure("validate",()=>{nf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let b=Br(n),y=b[vn];t.measure("validate",()=>{nf(y,Ar(y),{present:Object.prototype.hasOwnProperty.call(b,vn),path:"$.editorScene.companionConfigs.staticShadows"})});let E=se(m)?.staticShadows;t.measure("validate",()=>{nf(E,Ar(E),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),Rm(n)});let I=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,P=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Nn(e),t.measure("validate",()=>{Ma(n,P)});let A=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),P));return xc(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(A),o.assertEditorSceneMaterialAssetIntegrity(A)});let $=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(A)),z=d?l:l??dE(n)??Ar(se(m)?.staticShadows),p=t.measure("prepare",()=>xc(fj($,{staticShadows:z}),4)),D=t.measure("prepare",()=>Zl(p,P)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig($,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:g??null})),R=z?{...h.sceneConfig,staticShadows:z}:{...h.sceneConfig};z||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,F=new Date().toISOString(),Ir=t.measure("compile",()=>xc(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:F}:R,4));t.measure("validate",()=>{ji(Ir)});let er=se(Ir)?.version,Hr=e.saveMode==="local-commit-save"&&typeof er=="number"?er:ne,Si=`/${jn.relative(e.projectRoot,a.scenePath).split(jn.sep).join("/")}?v=${encodeURIComponent(String(Hr))}`,tr="",zn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(D,null,2)}
15
- `);await t.measureAsync("write",()=>rd(e,zn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Nn(e),await wI(jn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
- `);await t.measureAsync("write",()=>rd(e,zn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!g)throw new Error("shadows_config_path_missing");await wI(jn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(g,null,2)}
17
- `);await t.measureAsync("write",()=>rd(e,zn,a.shadowsConfigPath,xe))}tr=t.measure("stringify",()=>`${JSON.stringify(Ir,null,2)}
18
- `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>rd(e,zn,a.scenePath,tr)),Nn(e),await t.measureAsync("write",async()=>{for(let xe of zn)await cj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await kI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(zn.filter(xe=>!xe.committed).map(xe=>kI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let yf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return yf.length>0&&e.invalidateFiles?.(e.server,yf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:Hr,updatedAt:F,sceneUrl:Si}:{},editorScene:p,...g?{shadowMapExperimentConfig:g}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:z}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(I??null)??null}:{}}:{},sceneJsonText:tr,performanceProfile:t.snapshot(),summary:{editorScene:_I($),compiled:h.summary}}}async function rd(e,t,r,n){Nn(e);let o=jn.join(jn.dirname(r),`.${jn.basename(r)}.${process.pid}.${lj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await dj(o,n,{encoding:"utf8",signal:e.signal})}function Nn(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function mj(e){let t=fi(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=OI(t);if(!r)return e.rawEditorScene;let n=OI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=se(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=se(se(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function OI(e){let t=se(se(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function nf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function FI(e){Wc(e)}function _I(e){let t=se(e),r=se(t?.meta),n=se(r?.authoringSource),o=se(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function fj(e,t){let r={...Br(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 fi(e){return vI(e)?JSON.parse(GI(e,"utf8")||"{}"):null}function $I(e){if(!e)return null;if(!vI(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse(GI(e,"utf8")||"{}");return Di(t,"$"),structuredClone(t)}function LI(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(Di(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function RI(e,t,r=!1){let n=se(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw CI(`${t}.${a}`);let o=se(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw CI(`${t}.companionConfigs.shadows`)}function CI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import bi from"node:path";import{pipeline as Tj}from"node:stream/promises";import{realpathSync as pj}from"node:fs";import af from"node:path";function No(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of gj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function gj(e){let t=af.resolve(e),r=pi(t);return[...new Set([e,t,r,of(e),of(t),of(r)])]}function pi(e){let t=af.resolve(e);try{return pj(t)}catch{return t}}function of(e){return e.split(af.sep).join("/")}import{constants as zI}from"node:fs";import gi from"node:fs/promises";import Fn from"node:path";var bj=128*1024*1024,Sj=512*1024*1024;async function Fo(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function yj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||Fn.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 bj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Sj)}async function nd(e,t){let r=yj(t),n=await gi.realpath(Fn.resolve(e)),o=Fn.resolve(n,...r.split("/"));BI(n,o),await hj(n,r);let a;try{a=await gi.open(o,zI.O_RDONLY|(zI.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 gi.realpath(o);if(BI(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await gi.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await Fo(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function BI(e,t){let r=Fn.relative(e,t);if(!r||r===".."||r.startsWith(`..${Fn.sep}`)||Fn.isAbsolute(r))throw new Error("project_file_path_invalid")}async function hj(e,t){let r=e;for(let n of t.split("/"))if(r=Fn.join(r,n),(await gi.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Er from"node:fs/promises";import mt from"node:path";var VI=512*1024,Ej=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 UI(e,t={}){let r=await Er.realpath(mt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...Ej,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=mt.resolve(r,c),u=await Ij(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=mt.posix.join(c.split(mt.sep).join("/"),l.name),f=mt.resolve(r,...m.split("/")),S=await Pj(r,f);if(!S)continue;let g=S==="file"?mt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(mt.sep).join("/"):null,kind:S,...g?{extension:g}:{}}),S==="directory"&&await s(m)}}};return await s(""),{rootName:mt.basename(r)||"Project",entries:a,truncated:i}}async function Ij(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Er.realpath(t);if(n!==t||!cf(e,n))return null;let o=await Er.readdir(t,{withFileTypes:!0}),a=await Er.lstat(t),i=await Er.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!cf(e,i)?null:o}catch{return null}}async function KI(e,t,r={}){let n=await nd(e,t),{handle:o,relativePath:a,stat:i}=n;if(!EE(a))throw await Fo(o),new Error("project_file_preview_unsupported");let s=VI,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??VI,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await Fo(o)}let u=mt.basename(a);return{path:a,name:u,extension:qc(u),language:Cm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Pj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink())return null;let n=await Er.realpath(t);if(n===e||!cf(e,n)||n!==t)return null;let o=await Er.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function cf(e,t){let r=mt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${mt.sep}`)&&!mt.isAbsolute(r)}var df="/__fps_editor_authoring";function HI(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=>bi.resolve(e.projectRoot,a))).then(async o=>(xj(r,o),Aj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===df||c.startsWith(`${df}/`),u=d&&c.slice(df.length)||"/";if(d&&u==="/project-media"){if(mi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Ur(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Ur(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await nd(e.projectRoot,m),S=null,g=null;try{let b=vm(f.relativePath);if(!b)throw new Error("project_file_media_unsupported");if(f.stat.size>sf(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=bi.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",b.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(g=Buffer.allocUnsafe(1),(await f.handle.read(g,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await Tj(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(b){S=b}try{await Fo(f.handle)}catch(b){if(S){let y=new Error("project_file_close_failed");y.errors=[S,b],S=y}else S=b}if(S)throw S;g?a.end(g):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let S=f instanceof Error?f.message:String(f);Ur(a,{statusCode:S==="project_file_media_too_large"?413:404,body:{ok:!1,error:S}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(mi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:ef});Ur(a,m)}catch(m){Ur(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await xE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>ef(o,{...f.routeName==="asset-import"?{maxBytes:Zu}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return UI(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return KI(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:S}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:S})}});if(!l){if(d){mi(a),Ur(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Ur(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(od(r.file,n))return[]}}}function od(e,t){let r=pi(e);return t.some(n=>{let o=pi(n);if(r===o)return!0;let a=bi.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${bi.sep}`)&&!bi.isAbsolute(a)})}function xj(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"&&od(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?od(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Aj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!od(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import _n,{resolve as _o}from"node:path";import{pathToFileURL as Dj}from"node:url";function WI(e){let t=Promise.resolve();function r(m){let f=t.then(m);return t=f.then(()=>{},()=>{}),f}async function n(m,f="strict"){let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=[S,g].filter(P=>!!P),y=[],E=[],I=0;for(let P of b){let A=await jo(P),$=typeof A.errorCodes=="object"&&A.errorCodes?A.errorCodes:{},z=f==="report"?await qm(P,$):await Wm(P,$);I+=z.scannedAssetCount,y.push(...z.refreshedAssets);let p="availabilityIssues"in z&&Array.isArray(z.availabilityIssues)?z.availabilityIssues:[];E.push(...p)}return y.length>0&&No(m,[...b.flatMap(P=>[P.manifestPath,P.registryPath]),...lf(e)]),{scannedAssetCount:I,refreshedAssets:y,availabilityIssues:Mj(E)}}function o(m){return r(async()=>{let f=await n(m,"strict");return{scannedAssetCount:f.scannedAssetCount,refreshedAssets:f.refreshedAssets}})}function a(m){return r(async()=>{let f=await n(m,"report"),S=u(Da(await c(!1)),f.availabilityIssues??[]);return{scannedAssetCount:f.scannedAssetCount,refreshedAssetIds:f.refreshedAssets.map(g=>g.assetId),availabilityIssues:f.availabilityIssues??[],assets:S}})}function i(m,f){return r(async()=>{let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=f.kind??([".png",".jpg",".jpeg",".env"].includes(_n.extname(f.sourcePath).toLowerCase())?"texture":"model"),y=b==="texture"?g??S:S,E=await jo(y),I=typeof E.errorCodes=="object"&&E.errorCodes?E.errorCodes:{},P=await Zt(y),A=await Go(y,{payloadData:{sourcePath:f.sourcePath,...f.displayName?{displayName:f.displayName}:{},kind:b,...f.category?{category:f.category}:{},...f.placeable===void 0?{}:{placeable:f.placeable}}},I);No(m,[y.manifestPath,y.registryPath,...lf(e)]);let z=Da(await c(!1)).find(p=>p.assetId===A.assetId);if(!z)throw new Error("asset_import_catalog_projection_missing");return{asset:z,disposition:P.some(p=>p.assetId===A.assetId)?"deduplicated":"created"}})}async function s(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=DI({assetRegistryConfig:f,textureRegistryConfig:S,loadAssetCatalogEntries:()=>c(!0),additionalInvalidationFiles:lf(e),invalidateFiles(b){No(m,b)}});return{loadManifest:b=>r(async()=>(await n(m,"report"),g.loadManifest(b))),loadEditorAssetLibrary:b=>r(async()=>{let y=await n(m,"report"),E=await g.loadEditorAssetLibrary(b);return!E||typeof E!="object"||!Array.isArray(E.assets)?E:{...E,assets:u(E.assets,y.availabilityIssues??[])}}),importAsset:b=>r(async()=>g.importAsset(b))}}async function c(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=[f,S].filter(I=>!!I),b=[...new Map(g.map(I=>[I.manifestPath,I])).values()],y=(await Promise.all(b.map(I=>Zt(I)))).flat(),E=new Set;return y.filter(I=>{if(I.kind!=="model"&&I.kind!=="texture"||m&&I.kind==="model"&&I.placeable!==!0)return!1;if(E.has(I.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${I.assetId}`);return E.add(I.assetId),!0})}async function d(m,f="strict"){return r(async()=>{let S=await n(m,f);return u(Da(await c(!1)),S.availabilityIssues??[])})}function u(m,f){if(f.length===0)return m;let S=new Map;for(let g of f){let b=S.get(g.assetId)??[];b.push(g),S.set(g.assetId,b)}return m.map(g=>{let b=typeof g.assetId=="string"?g.assetId:typeof g.id=="string"?g.id:"",y=b?S.get(b):void 0;return!y||y.length===0?g:{...g,availability:{status:"unavailable",issues:y.map(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 l(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${Dj(_o(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadProjectAssetCatalogConfigModule:l,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Mj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function qI(e,t){let r=_o(e,t.importedDir),n=_o(e,t.generatedDir),o=_n.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:_n.join(n,"asset-catalog.manifest.json"),registryPath:_n.join(n,"asset-catalog.generated.ts"),scenePath:_o(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:_o(e,t.editorScene)}:{},supportedExtensions:ko,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=_n.join(r,s,i);return _n.relative(n,c).split(_n.sep).join("/")},resolveAssetMetadata(a){return si({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function lf(e){return(e.additionalInvalidationFiles??[]).map(t=>_o(e.projectRoot,t))}import ad from"node:path";function JI(e,t){return{editorScenePath:ad.resolve(t,e.source.editorScene),scenePath:ad.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:ad.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:ad.resolve(t,e.source.shadows)}:{}}}import{existsSync as wj,readFileSync as kj}from"node:fs";import{mkdir as Oj,writeFile as Rj}from"node:fs/promises";import uf from"node:path";function XI(e,t){let r=e.source.rendering,n=r?uf.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>uf.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:vj,async handleRoute(a){return n?LE({method:Cj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:wj(n)?JSON.parse(kj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return td([n],async()=>(await Oj(uf.dirname(n),{recursive:!0}),await Rj(n,`${JSON.stringify(i,null,2)}
19
- `,"utf8"),No(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Cj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function vj(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 Gj}from"node:crypto";import{realpath as jj}from"node:fs/promises";import{createServer as Nj}from"node:http";async function ZI(e){let t=await jj(e.projectRoot),r=Gj(),n=[...e.middlewares??[]],o=Nj((c,d)=>{Fj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){mf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){mf(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(S=>{if(d.headersSent){d.destroy(S instanceof Error?S:void 0);return}mf(d,500,{ok:!1,error:S instanceof Error?S.message:String(S)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await YI(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=YI(o).catch(c=>{throw s=null,c}),s)}})}function Fj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function mf(e,t,r){_j(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
- `))}function _j(e){return e.destroyed||e.writableEnded}async function YI(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Rt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),$n={kind:"texture"},QI={kind:"color"},$j={kind:"enum",values:["lit","unlit"]},Lj={kind:"enum",values:["opaque","mask","blend"]},rP={lightingModel:$j,baseColor:{kind:"object",properties:{color:QI,texture:$n,brightness:Rt(0),saturation:Rt(0),contrast:Rt(0),hue:Rt(-180,180)}},normal:{kind:"object",properties:{texture:$n,strength:Rt(0)}},emission:{kind:"object",properties:{color:QI,intensity:Rt(0),texture:$n,maskTexture:$n}},alpha:{kind:"object",properties:{mode:Lj,opacity:Rt(0,1),cutoff:Rt(0,1),texture:$n}}},zj={kind:"object",properties:{...rP,metallic:Rt(0,1),roughness:Rt(0,1),metallicRoughness:{kind:"object",properties:{texture:$n}},occlusion:{kind:"object",properties:{texture:$n,strength:Rt(0)}}}},Bj={kind:"object",properties:rP},Vj={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}},Uj={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}},eP=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],Ln={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},nP=[Lo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Lo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),zo("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),Ct("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),zo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Ln]),Ct("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,$o("properties.normal.texture.textureAssetId","normalTexture")]}),Lo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),Ct("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),zo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Lo("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),Ct("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),Ct("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),zo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Kj=[...nP,Ct("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Ln]}),Ct("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Ln]}),zo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Ln]),zo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Ln]),Ct("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,$o("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],pf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:zj,defaultProperties:Vj,inspector:{sections:eP,fields:Kj}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Bj,defaultProperties:Uj,inspector:{sections:eP,fields:nP}}],pK=gf(pf);function gf(e){let t=new Map;for(let n of e){Hj(n,t);let o=Wj(n);t.set(n.shaderId,sP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Lo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function Ct(e,t,r,n,o,a,i={}){return Lo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function zo(e,t,r,n,o,a,i,s){return Lo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function $o(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Hj(e,t){if(!Hn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Jj(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);oP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(iP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);qj(e,a),o.add(a.path)}}function Wj(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=aP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function qj(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=aP(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 oP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))oP(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 Jj(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Xj(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function aP(e,t){let r=Xj(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 iP(e,t,r,n){if(e.kind==="object"){if(!ff(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&iP(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"];tP(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){tP(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!ff(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function tP(e,t,r,n,o){if(!ff(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function sP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))sP(t)}return e}function ff(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Yj=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zj=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 id(e){return Qj(new TextEncoder().encode(e))}function cP(e){return`sha256:${id(JSON.stringify(e))}`}function Qj(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=[...Yj],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let g=0;g<16;g+=1)a[g]=n.getUint32(i+g*4,!1);for(let g=16;g<64;g+=1){let b=a[g-15],y=a[g-2],E=Qt(b,7)^Qt(b,18)^b>>>3,I=Qt(y,17)^Qt(y,19)^y>>>10;a[g]=a[g-16]+E+a[g-7]+I>>>0}let[s,c,d,u,l,m,f,S]=o;for(let g=0;g<64;g+=1){let b=Qt(l,6)^Qt(l,11)^Qt(l,25),y=l&m^~l&f,E=S+b+y+Zj[g]+a[g]>>>0,I=Qt(s,2)^Qt(s,13)^Qt(s,22),P=s&c^s&d^c&d,A=I+P>>>0;S=f,f=m,m=l,l=u+E>>>0,u=d,d=c,c=s,s=E+A>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+S>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function Qt(e,t){return e>>>t|e<<32-t}var eN="fps.plugin.materials";function lP(e){let t=e?.[eN];if(t==null)return null;if(!Bo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return tN(r),uP(r)}function bf(e){return gf([...pf,...e?.shaders.map(t=>t.definition)??[]])}function tN(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(let r of e.shaders)if(!Bo(r)||!Bo(r.definition)||!Bo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");bf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!dP(o.vertexSourcePath)||!dP(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(id(o.vertexSource)!==o.vertexSourceHash||id(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Bo(o.enumUniformValues)||!Bo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(cP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function dP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function uP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))uP(t);return Object.freeze(e)}function Bo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function fP(e){let t=PE(e.definition),r=lP(e.pluginSnapshots),n=bf(r),o=t.project,a=rN(e.projectRoot),i=qI(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=WI({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=XI(o,{projectRoot:e.projectRoot}),d=JI(o,e.projectRoot),u=tE({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(g,b,y)=>({kind:"game-object.field",targetId:g,path:b,value:y}),gameObjectFieldBatch:g=>({kind:"game-object.property-field-batch",fields:g}),materialAssetField:(g,b,y)=>({kind:"scene.material-asset.field",materialAssetId:g,path:b,value:y}),materialAssetReplace:(g,b)=>({kind:"scene.material-asset.replace",materialAssetId:g,materialAsset:b}),prefabAssetReplace:(g,b)=>({kind:"scene.prefab-asset.replace",assetId:g,prefabAsset:b}),markerGraph:g=>({kind:"scene.marker-graph",command:g})}}),l={ensureAuthoringSource:Cg,detectRuntimeInputDrift:Gg,enrichEditorSceneDocumentAssets:Yl,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:FI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:vg,compileEditorSceneDocumentToSceneConfig:(g,b,y)=>DE(g,b,{...y,materialShaderDefinitions:n,readCustomTransformRuntimeData:E=>E?.transformType==="groundDecal"&&oN(E.groundDecal)?{groundDecal:$E(E.groundDecal)}:null})},f=(g,b="report")=>s.listEditorAssetLibrary(a,b),S=HI({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>jI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadServices:async()=>l}),saveEditorScene:g=>NI({...g,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:b=>Ne(b),summarizeRenderingProfile:b=>Bn(b),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await nN(S.configureServer,a),ZI({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function rN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new mP,n=new mP;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 nN(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 oN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Kr=await fP({projectRoot:process.cwd(),definition:gP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:gP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Kr||typeof Kr.serviceInstanceId!="string"||typeof Kr.internalUrl!="string"||typeof Kr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Kr.serviceInstanceId,internalUrl:Kr.internalUrl});var Sf=!0,bP=setInterval(()=>{Sf&&process.send?.({type:"heartbeat",serviceInstanceId:Kr.serviceInstanceId})},1e3);bP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Sf=!1),e?.type==="test.start-heartbeat"&&(Sf=!0)});var pP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{pP||(pP=!0,clearInterval(bP),Kr.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 gP(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}
12
+ `}import zm from"node:fs/promises";import lt from"node:path";var Bm=5;async function di(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await XE(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=MG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...pe(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Bm;let n=await YE(e.sourcePath,{assetGuid:e.guid,assetId:e.assetId,cwd:e.cwd,assetsDir:e.assetsDir,existingMaterialSlots:t.materialSlots});return n.length===0?delete t.materialSlots:t.materialSlots=n,Object.keys(t).length>0?t:null}async function XE(e){return e.kind==="model"?aG(e.sourcePath):e.kind==="texture"||e.kind==="image"?iG(e.sourcePath):null}async function YE(e,t={}){try{let r=await ZE(e);return SG(r,{...t,sourcePath:e})}catch{return[]}}async function ZE(e){let t=lt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await zm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await zm.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function aG(e){try{let t=await ZE(e);if(!t||typeof t!="object")return null;let r=Array.isArray(t.scenes)?t.scenes:[],n=Array.isArray(t.nodes)?t.nodes:[],o=Array.isArray(t.meshes)?t.meshes:[],a=Array.isArray(t.materials)?t.materials:[],i=Array.isArray(t.textures)?t.textures:[],s=Array.isArray(t.images)?t.images:[],c=Array.isArray(t.animations)?t.animations:[],d=Array.isArray(t.skins)?t.skins:[],u=Array.isArray(t.accessors)?t.accessors:[],l=nI(t),m=oI(n),f=new Set(l),S=o.reduce((E,T)=>E+(Array.isArray(T?.primitives)?T.primitives.length:0),0),g=o.reduce((E,T)=>E+(Array.isArray(T?.primitives)?T.primitives.reduce((A,$)=>A+(Array.isArray($?.targets)?$.targets.length:0),0):0),0),b=uG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=mG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,complexity:b});return{kind:"gltf",format:lt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${S} primitives, ${a.length} materials`,complexity:b,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,nodes:sG(n,o,a,u,m,f),meshes:cG(o,a,u),materials:dG(t),diagnostics:y}}catch{return null}}async function iG(e){try{let t=await zm.readFile(e),r=lt.extname(e).toLowerCase(),n=r===".png"?fG(t):r===".jpg"||r===".jpeg"?pG(t):r===".webp"?gG(t):null;if(!n)return null;let o=bG(n);return{kind:"image",format:n.format,summary:`${n.width}x${n.height} ${n.mime}`,complexity:n.estimatedPixels>=4096*4096?"high":n.estimatedPixels>=2048*2048?"medium":"low",width:n.width,height:n.height,mime:n.mime,bitDepth:n.bitDepth,hasAlpha:n.hasAlpha,estimatedPixels:n.estimatedPixels,diagnostics:o}}catch{return null}}function sG(e,t,r,n,o,a){return e.slice(0,100).map((i,s)=>{let c=Number.isInteger(i?.mesh)?i.mesh:-1,d=c>=0&&c<t.length?t[c]:null,u=Array.isArray(i?.children)?i.children.filter(f=>Number.isInteger(f)):[],l=aI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:sI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=QE(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function cG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=QE(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function QE(e,t,r){let n=pe(e)?e:{};return(Array.isArray(n.primitives)?n.primitives:[]).map((a,i)=>{let s=Number.isInteger(a?.material)?a.material:-1,c=s>=0?t[s]:null,d=typeof c?.name=="string"&&c.name.trim()?c.name.trim():"",u=cI(a,r),l=dI(a,r);return{primitiveIndex:i,...Number.isInteger(a?.mode)?{mode:a.mode}:{},...s>=0?{sourceMaterialIndex:s}:{},...d?{materialName:d}:{},...Number.isFinite(u)?{triangleCount:u}:{},...l?{boundingBox:l}:{}}})}function dG(e){return(Array.isArray(e?.materials)?e.materials:[]).slice(0,50).map((r,n)=>{let o=r?.pbrMetallicRoughness&&typeof r.pbrMetallicRoughness=="object"?r.pbrMetallicRoughness:{},a=lG(r,o);return{sourceMaterialIndex:n,...typeof r?.name=="string"&&r.name.trim()?{materialName:r.name.trim()}:{},...Array.isArray(o.baseColorFactor)?{baseColorFactor:o.baseColorFactor.slice(0,4)}:{},metallicFactor:Number.isFinite(o.metallicFactor)?o.metallicFactor:1,roughnessFactor:Number.isFinite(o.roughnessFactor)?o.roughnessFactor:1,alphaMode:tI(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function lG(e,t){let r=[];return si(r,"baseColor",t?.baseColorTexture),si(r,"metallicRoughness",t?.metallicRoughnessTexture),si(r,"normal",e?.normalTexture),si(r,"occlusion",e?.occlusionTexture),si(r,"emissive",e?.emissiveTexture),r}function si(e,t,r){!pe(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function uG(e){return e.nodeCount>=300||e.meshCount>=250||e.primitiveCount>=300||e.materialCount>=200||e.textureCount>=80||e.imageCount>=80?"high":e.nodeCount>=100||e.meshCount>=80||e.primitiveCount>=100||e.materialCount>=50||e.textureCount>=24||e.imageCount>=24?"medium":"low"}function mG(e){let t=[];return e.complexity==="high"&&t.push({severity:"warning",source:"asset",code:"asset.analysis.highComplexity",message:"GLTF asset is structurally complex; agent should place and inspect it before duplicating or using dense shadows.",details:{nodeCount:e.nodeCount,meshCount:e.meshCount,primitiveCount:e.primitiveCount,materialCount:e.materialCount,textureCount:e.textureCount,imageCount:e.imageCount}}),(e.animationCount>0||e.skinCount>0||e.morphTargetCount>0)&&t.push({severity:"info",source:"asset",code:"asset.analysis.riggedOrAnimated",message:"GLTF asset contains animation, skin, or morph target data.",details:{animationCount:e.animationCount,skinCount:e.skinCount,morphTargetCount:e.morphTargetCount}}),t}function fG(e){if(e.length<33||e[0]!==137||e.toString("ascii",1,4)!=="PNG"||e[4]!==13||e[5]!==10||e[6]!==26||e[7]!==10||e.toString("ascii",12,16)!=="IHDR")return null;let r=e.readUInt32BE(16),n=e.readUInt32BE(20),o=e[24],a=e[25],i=!1,s=33;for(;s+12<=e.length;){let c=e.readUInt32BE(s),d=s+12+c;if(d>e.length)break;let u=e.toString("ascii",s+4,s+8);if(u==="tRNS"){i=!0;break}if(u==="IDAT"||u==="IEND")break;s=d}return{format:"png",mime:"image/png",width:r,height:n,bitDepth:o,hasAlpha:a===4||a===6||i,estimatedPixels:r*n}}function pG(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let r=e[t+1],n=e.readUInt16BE(t+2);if(n<2)return null;if(r>=192&&r<=207&&![196,200,204].includes(r)&&t+8<e.length){let a=e[t+4],i=e.readUInt16BE(t+5),s=e.readUInt16BE(t+7);return{format:"jpeg",mime:"image/jpeg",width:s,height:i,bitDepth:a,hasAlpha:!1,estimatedPixels:s*i}}t+=2+n}return null}function gG(e){if(e.length<30||e.toString("ascii",0,4)!=="RIFF"||e.toString("ascii",8,12)!=="WEBP")return null;let t=e.toString("ascii",12,16);if(t==="VP8X"&&e.length>=30){let r=e[20],n=WE(e,24)+1,o=WE(e,27)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:(r&16)!==0,estimatedPixels:n*o}}if(t==="VP8 "&&e.length>=30){let r=e.readUInt16LE(26)&16383,n=e.readUInt16LE(28)&16383;return{format:"webp",mime:"image/webp",width:r,height:n,hasAlpha:!1,estimatedPixels:r*n}}if(t==="VP8L"&&e.length>=25&&e[20]===47){let r=e.readUInt32LE(21),n=(r&16383)+1,o=(r>>14&16383)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:!0,estimatedPixels:n*o}}return null}function WE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function bG(e){let t=[];return e.estimatedPixels>=4096*4096&&t.push({severity:"warning",source:"asset",code:"asset.analysis.largeImage",message:"Image asset is large; agent should inspect texture usage before assigning it broadly.",details:{width:e.width,height:e.height,estimatedPixels:e.estimatedPixels}}),t}function SG(e,t={}){if(!e||typeof e!="object")return[];let r=Array.isArray(e.nodes)?e.nodes:[],n=Array.isArray(e.meshes)?e.meshes:[],o=Array.isArray(e.materials)?e.materials:[],a=hG(e,t),i=nI(e),s=oI(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=xG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let S=r[f],g=Number.isInteger(S?.mesh)?S.mesh:-1;if(g<0||g>=n.length)continue;let b=aI(r,s,c,f);if(!b)continue;let y=n[g],I=Array.isArray(y?.primitives)?y.primitives:[],E=kG(S,y,b),T=iI(y),A=sI(s,f);for(let $=0;$<I.length;$+=1){let z=I[$],p=OG(z,o),D=rI({ownerNodePath:b,nodeIndex:f,meshIndex:g,primitiveIndex:$}),h=cI(z,d),R=dI(z,d),K=I.length>1?`${E} / Primitive ${$}`:E,ne={ownerNodePath:b,nodeIndex:f,nodeIndexPath:A,meshIndex:g,primitiveIndex:$,...T?{sourceMeshName:T}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let F=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};F.sourceSurfaces.push(ne),m.set(p.index,F);continue}l.push({slotId:u.byExactSource.get(D)??AG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:g,primitiveIndex:I.length>1?$:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,S]of m){let g=S.sourceSurfaces.sort(eI);l.push({slotId:u.bySourceMaterialIndex.get(f)??DG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:S.label,sourceSurfaces:g,...S.materialName?{materialName:S.materialName,materialNames:[S.materialName]}:{},...EG(a,[f])})}return l.sort(yG)}function yG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return eI(r,n)}function eI(e,t){let r=String(e?.ownerNodePath??"").localeCompare(String(t?.ownerNodePath??""));if(r!==0)return r;let n=Number.isInteger(e?.nodeIndex)?e.nodeIndex:-1,o=Number.isInteger(t?.nodeIndex)?t.nodeIndex:-1;if(n!==o)return n-o;let a=Number.isInteger(e?.meshIndex)?e.meshIndex:-1,i=Number.isInteger(t?.meshIndex)?t.meshIndex:-1;if(a!==i)return a-i;let s=Number.isInteger(e?.primitiveIndex)?e.primitiveIndex:-1,c=Number.isInteger(t?.primitiveIndex)?t.primitiveIndex:-1;return s-c}function hG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=IG(e,o,t);a&&n.push(a)}return n}function EG(e,t){if(!t.length||!e.length)return{};let r=new Map(e.map(o=>[o.sourceMaterialIndex,o])),n=t.map(o=>r.get(o)).filter(Boolean);return n.length>0?{sourceMaterialProfiles:n}:{}}function IG(e,t,r={}){let n=Array.isArray(e?.materials)?e.materials[t]:null;if(!n||typeof n!="object")return null;let o={},a=[],i=n.pbrMetallicRoughness&&typeof n.pbrMetallicRoughness=="object"?n.pbrMetallicRoughness:{},s={},c=Array.isArray(i.baseColorFactor)?i.baseColorFactor:null,d=qE(c);d&&(s.color=d);let u=ci(e,i.baseColorTexture,r,"baseColor.texture",s,"texture",a);Object.keys(s).length>0&&(o.baseColor={...s,brightness:1,saturation:1,contrast:1,hue:0});let l={};ci(e,n.normalTexture,r,"normal.texture",l,"texture",a),Number.isFinite(n.normalTexture?.scale)?l.strength=n.normalTexture.scale:l.texture&&(l.strength=1),Object.keys(l).length>0&&(o.normal=l),o.metallic=Number.isFinite(i.metallicFactor)?i.metallicFactor:1,o.roughness=Number.isFinite(i.roughnessFactor)?i.roughnessFactor:1;let m={};ci(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};ci(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let S={},g=qE(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),b=g&&(g.r!==0||g.g!==0||g.b!==0);b&&(S.color=g),ci(e,n.emissiveTexture,r,"emission.texture",S,"texture",a),b&&(S.intensity=1),Object.keys(S).length>0&&(o.emission=S);let y={},I=tI(n.alphaMode);if(I&&(y.mode=I),(I==="mask"||I==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:I==="mask"&&(y.cutoff=.5),u.texture&&(y.texture=structuredClone(u.texture)),u.hint&&a.push({...u.hint,profilePath:"alpha.texture"})),Object.keys(y).length>0&&(o.alpha=y),Object.keys(o).length===0&&a.length===0)return null;let E=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...E?{materialName:E}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function qE(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?{r:t,g:r,b:n}:null}function tI(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function ci(e,t,r,n,o,a,i){let s=PG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function PG(e,t,r,n){let o=pe(t)?t:{},a=Number.isInteger(o.index)?o.index:-1;if(a<0)return{};let i=Array.isArray(e?.textures)?e.textures:[],s=Array.isArray(e?.images)?e.images:[],c=i[a],d=TG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),S={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...S,reason:"embedded-texture"}};if(!m)return{hint:{...S,reason:"missing-image-uri"}};if(f)return{hint:{...S,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let g=m;try{g=decodeURIComponent(m)}catch{return{hint:{...S,reason:"unresolved-external-texture"}}}let b=lt.dirname(String(r.sourcePath??"")),y=lt.resolve(b,g),I=r.assetsDir?lt.resolve(r.assetsDir):"",E=r.cwd?lt.resolve(r.cwd):"",T=I?lt.relative(I,y):"../";return I&&E&&T&&!T.startsWith("..")&&!lt.isAbsolute(T)?{texture:{url:`/${lt.relative(E,y).split(lt.sep).join("/")}`},hint:{...S,reason:"external-texture"}}:{hint:{...S,reason:"external-texture"}}}function TG(e){let t=pe(e)?e:{},r=pe(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=pe(r.KHR_texture_basisu)?r.KHR_texture_basisu:{};if(Number.isInteger(o.source))return{imageIndex:o.source,previewImageIndex:n>=0&&n!==o.source?n:-1};let a=pe(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function xG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!pe(o))continue;let a=Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[],i=typeof o.slotId=="string"?o.slotId.trim():"";if(!i)continue;let s=new Set;for(let c of a){if(!pe(c))continue;let d=typeof c.ownerNodePath=="string"?c.ownerNodePath.trim().replace(/^\/+|\/+$/g,""):"",u=Number.isInteger(c.nodeIndex)?c.nodeIndex:-1,l=Number.isInteger(c.meshIndex)?c.meshIndex:-1,m=Number.isInteger(c.primitiveIndex)?c.primitiveIndex:-1;a.length===1&&d&&u>=0&&l>=0&&m>=0&&t.set(rI({ownerNodePath:d,nodeIndex:u,meshIndex:l,primitiveIndex:m}),i),Number.isInteger(c.sourceMaterialIndex)&&c.sourceMaterialIndex>=0&&s.add(c.sourceMaterialIndex)}if(s.size===1){let[c]=s,d=r.get(c)??[];d.push(i),r.set(c,d)}}let n=new Map;for(let[o,a]of r)a.length===1&&n.set(o,a[0]);return{byExactSource:t,bySourceMaterialIndex:n}}function rI(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function AG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${uI(r)}`}function DG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${uI(t)}`}function MG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(pe(t.capabilities)&&t.capabilities.materialTexture===!0)return{usage:"material",materialTexture:!0,environmentTexture:!1};if(t.textureUsage==="environment"||t.usage==="environment")return{usage:"environment",materialTexture:!1,environmentTexture:!0};if(pe(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=lt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function nI(e){let t=Array.isArray(e.scenes)?e.scenes:[],r=Number.isInteger(e.scene)?e.scene:0,n=t[r]??t[0];return Array.isArray(n?.nodes)?n.nodes.filter(Number.isInteger):[]}function oI(e){let t=new Map;for(let r=0;r<e.length;r+=1){let n=Array.isArray(e[r]?.children)?e[r].children:[];for(let o of n)Number.isInteger(o)&&!t.has(o)&&t.set(o,r)}return t}function aI(e,t,r,n){let o=[],a=n,i=new Set;for(;Number.isInteger(a)&&a>=0&&a<e.length;){if(i.has(a))return"";i.add(a),o.push(wG(e[a],a));let s=t.get(a);if(typeof s!="number"||!Number.isInteger(s))break;a=s}return o.reverse(),o.length>1&&r.has(a)&&o.shift(),o.filter(Boolean).join("/")}function wG(e,t){return(pe(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function kG(e,t,r){let n=pe(e)&&typeof e.name=="string"?e.name.trim():"",o=iI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function iI(e){return pe(e)&&typeof e.name=="string"?e.name.trim():""}function sI(e,t){let r=[],n=t,o=new Set;for(;Number.isInteger(n)&&n>=0;){if(o.has(n))return[];o.add(n),r.push(n);let a=e.get(n);if(!Number.isInteger(a))break;n=a}return r.reverse(),r}function OG(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.material)?r.material:-1,o=n>=0?t[n]:null,a=typeof o?.name=="string"&&o.name.trim()?o.name.trim():"";return{index:n,name:a}}function cI(e,t){let r=pe(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=lI(r),a=n>=0?t[n]:null,i=o>=0?t[o]:null,s=Number.isFinite(a?.count)?Number(a.count):Number.isFinite(i?.count)?Number(i.count):null;if(s==null)return null;let c=Number.isInteger(r.mode)?r.mode:4;return c===4?Math.floor(s/3):c===5||c===6?Math.max(0,s-2):0}function dI(e,t){let r=pe(e)?e:{},n=lI(r),o=n>=0?t[n]:null,a=JE(o?.min),i=JE(o?.max);return a&&i?{min:a,max:i}:null}function lI(e){let t=pe(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function JE(e){if(!Array.isArray(e)||e.length<3)return null;let t=Number(e[0]),r=Number(e[1]),n=Number(e[2]);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?[t,r,n]:null}function pe(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function uI(e){let t=String(e??""),r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}import ed from"node:crypto";import{constants as NG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import li from"node:fs/promises";import Ot from"node:path";async function fI(e,t={}){try{let r=await RG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ut(n[i]);if(!s)continue;let c=await CG(e,r,s);if(!c)continue;let d=ui(s.name)??(c.originalFileName?Ot.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function pI(e){let t=new Set;for(let r of bI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function gI(e){let t=new Map;for(let r of bI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function bI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ut(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ut(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ut(d);u&&t.push(u)}}}return t}function SI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ut(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ut(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let S=ut(f),g=hr(S?.imageIndex),b=ui(S?.profilePath),y=g==null?null:r.get(g)??null;if(!y||!b||!GG(b)){m.push(f);continue}let I=ut(u.profile)??{};jG(I,b,{textureAssetId:y}),u.profile=I,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function RG(e){let t=Ot.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await li.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>mI(e,ut(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await li.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ut(c);return ui(u?.uri)?mI(e,u):o[d]??(d===0?o[0]??null:null)}));return s.length===0&&o.length>0&&s.push(o[0]),{gltf:n,buffers:s}}async function mI(e,t){let r=ui(t?.uri);if(!r)return null;let n=EI(r);if(n)return n.bytes;if(Um(r))return null;let o=hI(r);return o?yI(e,o):null}async function CG(e,t,r){let n=ui(r.uri);if(n){let f=EI(n);if(f){let I=Vm(f.bytes);return I?{bytes:f.bytes,...I}:null}if(Um(n))return null;let S=hI(n);if(!S)return null;let g=await yI(e,S);if(!g)return null;let b=Ot.basename(S),y=Vm(g);return y?{bytes:g,...y,originalFileName:b}:null}let o=hr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ut(a[o]),s=hr(i?.buffer)??0,c=t.buffers[s],d=hr(i?.byteOffset)??0,u=hr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Vm(l);return m?{bytes:l,...m}:null}async function yI(e,t){if(Ot.isAbsolute(t)||Ot.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await li.realpath(Ot.dirname(e)),n=Ot.resolve(r,t),o=await li.realpath(n);return vG(r,o)?await li.readFile(o):null}catch{return null}}function hI(e){if(Um(e))return null;try{return decodeURIComponent(e)}catch{return null}}function vG(e,t){let r=Ot.relative(e,t);return r===""||!r.startsWith(`..${Ot.sep}`)&&r!==".."&&!Ot.isAbsolute(r)}function EI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function Vm(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function GG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function jG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ut(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Um(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Ot.win32.isAbsolute(e)}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ui(e){return typeof e=="string"&&e.trim()?e.trim():null}function hr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function Go(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await WG(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new U("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=LG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:MI(e)});try{await W.access(a,NG.R_OK)}catch(h){let R=vo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=XG(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Zt(e),d=await Qm(a),u=Wc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});Jm(u,a,"source_path");let l=JG(c,n,s,a,d,u,e),m=ae(n.assetName)??l?.originalFileName??v.basename(a),f=ae(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let S=l?.guid??f??ed.randomUUID(),g=ae(n.projectAssetId),b=Kc(u,S);if(l?.assetId&&l.assetId!==b)throw new U("manifest_asset_id_must_match_guid",{guid:S,assetId:l.assetId,expectedAssetId:b});if(g&&g!==b)throw new U("project_asset_id_must_match_guid",{guid:S,projectAssetId:g,expectedAssetId:b});let y=i===".gltf"?v.posix.join(b,v.basename(a)):`${b}${i}`,I=zG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),E=fi(e,I,u,"target_path"),T=new Date().toISOString(),A=hm(ae(n.displayName)??l?.displayName,m),$=Qc({...Qc(l?.external)??{},...s??{}}),z=!1,p=[],D=null;try{await W.mkdir(v.dirname(E),{recursive:!0});let h=VG(a,E),R=h||await OI(E),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,E),z=!l,i===".gltf"&&await FG(a,E));let F=await kI(e,{existing:l,payload:n,sourcePath:a,targetPath:E,kind:u,guid:S,assetId:b}),Ir=Ke(l?.metadata),er=Ke(F);if(u==="model"&&(Ir.assetAnalysisStatus==="complete"||Object.keys(Ke(Ir.assetAnalysis)).length>0)&&er.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:b,guid:S});if(u==="model"){let tr=await _G({config:e,manifest:c,metadata:F,sourcePath:a,sourceAssetId:b,sourceAssetGuid:S,sourceDisplayName:A,now:T});p=tr.createdPaths,F=SI(F,tr.references)}let qr=Ym({...l??{},guid:S,assetId:b,kind:u,displayName:A,relativePath:I,originalFileName:m,...o==="legacy"?{codeKey:Em(ae(n.codeKey)??ae(n.assetName)??l?.codeKey,m)}:{},...ae(n.category)?{category:ae(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Am(n.warmupCount)!=null?{warmupCount:Am(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...xm(n.materialMode)?{materialMode:xm(n.materialMode)}:{},...Tm(n.scale)?{defaults:{transform:{scale:Tm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:$,metadata:F,createdAt:l?.createdAt??T,updatedAt:K?T:l?.updatedAt??T});if(!qr)throw new U("invalid_manifest_entry",{assetId:b,guid:S});D=qr;let hi=c.findIndex(tr=>tr.guid===S||tr.assetId===b);hi>=0?c[hi]=qr:c.push(qr),c.sort(QG),await nj(e,c)}catch(h){z&&await W.rm(i===".gltf"?v.dirname(E):E,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:S,assetId:b,kind:u,...D?.contentHash?{contentHash:D.contentHash}:{},...D?.external?{external:D.external}:{},displayName:D?.displayName,originalFileName:D?.originalFileName,assetUrl:HG(e,I,u),targetPath:E,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function FG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ae(Ke(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Km(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Km(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Km(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function _G(e){let t=pI(e.metadata),r=gI(e.metadata),n=await fI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=mi(d.bytes),l=e.manifest.find(A=>A.kind==="texture"&&A.contentHash===u.contentHash&&Ke(Ke(A.metadata).capabilities).materialTexture!==!1&&Ke(A.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=tj(u.contentHash),f=Kc("texture",m),S=e.manifest.find(A=>A.guid===m||A.assetId===f);if(S)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let g=`${f}${d.extension}`,b=wI(e.config,"texture",g),y=fi(e.config,b,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await OI(y)){let A=await Qm(y);if(A.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:A.contentHash})}else await ej(y,d.bytes),i.push(y);let I=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,E=await kI(e.config,{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:d.imageIndex,mimeType:d.mimeType}}},sourcePath:y,targetPath:y,kind:"texture",guid:m,assetId:f}),T=Ym({guid:m,assetId:f,kind:"texture",displayName:I,relativePath:b,originalFileName:d.originalFileName??`${rj(I)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:E,createdAt:e.now,updatedAt:e.now});if(!T)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(T),a.set(d.imageIndex,T),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=Ke(d.metadata),l=$G(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([b],[y])=>b.localeCompare(y))),S=Object.values(f)[0],g={...u};S?(g.previewTextureAssetId=S,g.previewTextureAssetIdsBySourceAssetId=f):(delete g.previewTextureAssetId,delete g.previewTextureAssetIdsBySourceAssetId),d.metadata=g}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function $G(e){let t={},r=Ke(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ae(a),c=ae(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ae(e.previewTextureAssetId),o=ae(Ke(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function Wm(e,t={}){let r=await DI(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function qm(e,t={}){return DI(e,t,!0)}async function DI(e,t,r){let n=await Zt(e),o=[],a=[];for(let i of n){let s=fi(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await Qm(s)}catch(m){let f=II(i,m,t,"source-audit",s);if(!r||!f)throw PI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&Ke(i.metadata).assetMetadataVersion!==Bm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await Go(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=II(i,m,t,"source-analysis",s);if(!r||!f)throw PI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new U("asset_refresh_missing_content_hash",{assetId:i.assetId,guid:i.guid,sourcePath:s});o.push({guid:i.guid,assetId:i.assetId,kind:i.kind,...i.contentHash?{previousContentHash:i.contentHash}:{},contentHash:l.contentHash})}return{ok:!0,scannedAssetCount:n.length,refreshedAssets:o,availabilityIssues:a}}function II(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=vo(t)?t.code:t instanceof U?ae(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=vo(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function PI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Zt(e){let t=await Xm(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=Ym(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function jo(e){return e.loadRules?e.loadRules():e.rulesPath?Xm(e.rulesPath,{}):{}}function TI(e){return(Array.isArray(e)?e:[e]).filter(r=>typeof r=="string"&&!!r.trim()).map(r=>{let n=r.trim().toLowerCase();return n.startsWith(".")?n:`.${n}`})}function MI(e){let t=TI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:TI(ko)}function LG(e,t){let r=t.toLowerCase();return MI(e).find(n=>r.endsWith(n))??null}function zG(e,t){return t.existing?.relativePath?t.existing.relativePath:BG(e,t.sourcePath,t.kind)??wI(e,t.kind,t.targetFileName)}function wI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function BG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!xI(v.resolve(n),o)||xI(v.resolve(e.generatedDir),o)?null:(Jm(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function xI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function VG(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function UG(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new U(`${r}_outside_allowed_directory`,{parent:e,child:t})}function KG(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new U(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function fi(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return UG(a,o,n),KG(v.resolve(e.generatedDir),o,n),Jm(r,o,n),o}function HG(e,t,r){let n=fi(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function Jm(e,t,r){let n=v.extname(t).toLowerCase(),o=Im(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function Xm(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(vo(r)&&r.code==="ENOENT")return t;throw r}}async function WG(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await Xm(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function Ym(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?Zm:ae,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?bm.includes(i)?i:null:Wc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!jn(r,"originalFileName")||!jn(r,"codeKey")||!jn(r,"category")||!jn(r,"materialMode")||!jn(r,"contentHash")||!jn(r,"createdAt")||!jn(r,"updatedAt")||"placeable"in r&&typeof r.placeable!="boolean"||"warmupCount"in r&&(!Number.isInteger(r.warmupCount)||r.warmupCount<0)||"singleton"in r&&typeof r.singleton!="boolean"||"defaults"in r&&Kr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Kr(r.metadata)==null||"external"in r&&!qG(r.external)))return null;let u=Kr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),S=n(r.materialMode),g=Kr(r.defaults),b=n(r.contentHash),y=Qc(r.external),I=n(r.createdAt),E=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...S?{materialMode:S}:{},...g?{defaults:g}:{},...b?{contentHash:b}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...I?{createdAt:I}:{},...E?{updatedAt:E}:{}}}function Zm(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function jn(e,t){return!(t in e)||Zm(e[t])!=null}function qG(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&Zm(t[o])!=null)}function Qc(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ae(r.platformAssetId),o;try{if(o=Ja(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ae(r.assetPath)})}let a=ae(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function Kr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function kI(e,t){let r=Kr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Kr(t.existing?.metadata),payloadMetadata:r}),o=Kr(n);return o||null}return di({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:Kr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function JG(e,t,r,n,o,a,i){let s=ae(t.guid),c=ae(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&YG(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&ZG(m.external)===r.assetPath);if(l)return l}let d=v.resolve(n),u=e.find(l=>{if(l.kind!==a)return!1;try{return v.resolve(fi(i,l.relativePath,l.kind,"manifest_asset_path"))===d}catch{return!1}});if(u)return u;if(o.contentHash){let l=e.find(m=>m.kind===a&&m.contentHash===o.contentHash);if(l)return l}return null}function XG(e){return Qc({...e.external&&typeof e.external=="object"&&!Array.isArray(e.external)?e.external:{},platformAssetId:e.external?.platformAssetId??e.platformAssetId??e.assetId,assetUrl:e.external?.assetUrl??e.assetUrl},!0)}function YG(e){return ae(Ke(e).platformAssetId)}function ZG(e){return ae(Ke(e).assetPath)}function QG(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function Hm(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!vo(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function ej(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function Qm(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...mi(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...mi(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ae(Ke(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Km(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=ed.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...mi(t)}],c=r.size;for(let[d,u]of[...a].sort(([l],[m])=>l.localeCompare(m))){let l=await W.readFile(u);s.push({path:d,...mi(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function mi(e){return{contentHash:`sha256:${ed.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function tj(e){let t=ed.createHash("sha256").update(`material-texture\0${e}`).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-5${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function rj(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function OI(e){try{return await W.access(e),!0}catch{return!1}}async function nj(e,t){let r=HE(t,{codeKeyPolicy:e.codeKeyPolicy??"legacy"});await W.mkdir(v.dirname(e.manifestPath),{recursive:!0}),await W.mkdir(v.dirname(e.registryPath),{recursive:!0});let n=await AI(e.manifestPath),o=await AI(e.registryPath);try{await Hm(e.manifestPath,`${JSON.stringify(t,null,2)}
13
+ `),await Hm(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await oj(s,c)}catch(d){i.push(d)}if(i.length>0){let s=new Error("generated_registry_transaction_rollback_failed");throw s.cause=a,s.rollbackErrors=i,s}throw a}}async function AI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(vo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function oj(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await Hm(e,t.content)}}function ae(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function vo(e){return e instanceof Error&&"code"in e}function RI(e){return{async loadManifest(){let t=await Zt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Zt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Ns(t)];return{ok:!0,assets:r,summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):aj(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await jo(r),o=cj(n.errorCodes),a=await Zt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await Go(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await sj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Ns(d)],l=u.find(m=>m.assetId===c||m.id===c);if(!l)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:l,assets:u,disposition:s&&a.some(m=>m.assetId===c)?"deduplicated":s?"created":"existing"}}}}function aj(e,t,r){return r&&ij(e)?r:t}function ij(e){let t=typeof e.assetType=="string"?e.assetType.toLowerCase():"";if(/^(texture|image|png|jpg|jpeg|webp)$/.test(t))return!0;let r=typeof e.kind=="string"?e.kind.toLowerCase():"";if(/^(texture|image)$/.test(r)||(typeof e.mimeType=="string"?e.mimeType.toLowerCase():"").startsWith("image/"))return!0;let o=[e.sourcePath,e.assetPath,e.assetName].filter(a=>typeof a=="string").join(`
14
+ `);return/\.(png|jpe?g|webp)(?:$|[?#])/i.test(o)}async function sj(e,t,r){if(!e.invalidateFiles)return;let n=typeof e.additionalInvalidationFiles=="function"?await e.additionalInvalidationFiles():e.additionalInvalidationFiles??[],o=new Set([...n,r.manifestPath||t.manifestPath,r.registryPath||t.registryPath]);await e.invalidateFiles([...o])}function cj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function ef(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Hr(e,t,r){if(e.statusCode=t.statusCode,pi(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function pi(e,t={}){e.setHeader("Access-Control-Allow-Origin",t.origin??"*"),e.setHeader("Access-Control-Allow-Methods",t.methods??"GET,POST,OPTIONS"),e.setHeader("Access-Control-Allow-Headers",t.headers??"Content-Type, Authorization"),e.setHeader("Cross-Origin-Resource-Policy",t.resourcePolicy??"cross-origin"),e.setHeader("Cross-Origin-Embedder-Policy",t.embedderPolicy??"credentialless"),e.setHeader("Cache-Control",t.cacheControl??"no-store")}import{existsSync as _I,readFileSync as $I}from"node:fs";import{mkdir as vI,rename as fj,rm as GI,writeFile as pj}from"node:fs/promises";import{randomUUID as gj}from"node:crypto";import Nn from"node:path";import dj from"node:path";var td=new Map;async function rd(e,t){let r=[...new Set(e.map(i=>dj.resolve(i)))].sort(),n=[...new Set(r.map(i=>td.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)td.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)td.get(i)===a&&td.delete(i)}}import{performance as tf}from"node:perf_hooks";var lj=1,uj=["prepare","compile","validate","stringify","write","checkpoint"];function CI(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:rf(tf.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=tf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=tf.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return mj(e)}}}function mj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=rf(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=uj.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:lj,measuredDurationMs:rf(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function rf(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function LI(e){let t=e.paths,r=gi(t.editorScenePath),n=r?la(r).document:null,o=gi(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=await e.listEditorAssetLibrary(e.server,"report");n&&Rm(n),n&&wa(n,i);let s=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),i)):null;s&&qc(s);let c=t.renderingConfigPath?gi(t.renderingConfigPath):void 0;c&&gt(c);let d={...Ur(s),...t.renderingConfigPath?{rendering:c}:{}},u=UI(t.shadowsConfigPath),l=se(o),m=typeof l?.version=="number"?l.version:void 0,f=typeof l?.updatedAt=="string"?l.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:s,assets:i,...m===void 0?{}:{version:m},...f===void 0?{}:{updatedAt:f},...Object.keys(d).length>0?{companionConfigs:d}:{},...u?{shadowMapExperimentConfig:u}:{},drift:s?a.detectRuntimeInputDrift(s,o):null,summary:VI(s)}}async function zI(e){Fn(e),NI(e.body,"$",!0),NI(e.rawEditorScene,"$.editorScene");let t=Mm(e.body),r=Ur(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&gt(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&KI(e.body),o&&!e.paths.shadowsConfigPath)throw new Error("shadows_config_path_missing");let a=[e.paths.editorScenePath,...e.saveMode==="local-commit-save"?[e.paths.scenePath]:[],...n&&e.paths.renderingConfigPath?[e.paths.renderingConfigPath]:[],...o&&e.paths.shadowsConfigPath?[e.paths.shadowsConfigPath]:[]];return rd(a,()=>(Fn(e),bj(e)))}async function bj(e){let t=CI(),r=t.measure("prepare",()=>Sj(e)),n=la(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Fn(e);let a=e.paths,i=Ur(e.body),s=Mm(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,Gn),u=i[Gn],l=Ar(u),m=t.measure("prepare",()=>gi(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),g=KI(e.body)??UI(a.shadowsConfigPath);t.measure("validate",()=>{nf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let b=Ur(n),y=b[Gn];t.measure("validate",()=>{nf(y,Ar(y),{present:Object.prototype.hasOwnProperty.call(b,Gn),path:"$.editorScene.companionConfigs.staticShadows"})});let I=se(m)?.staticShadows;t.measure("validate",()=>{nf(I,Ar(I),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),Rm(n)});let E=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,T=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Fn(e),t.measure("validate",()=>{wa(n,T)});let A=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),T));return Ac(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(A),o.assertEditorSceneMaterialAssetIntegrity(A)});let $=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(A)),z=d?l:l??pE(n)??Ar(se(m)?.staticShadows),p=t.measure("prepare",()=>Ac(yj($,{staticShadows:z}),4)),D=t.measure("prepare",()=>Ql(p,T)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig($,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:g??null})),R=z?{...h.sceneConfig,staticShadows:z}:{...h.sceneConfig};z||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,F=new Date().toISOString(),Ir=t.measure("compile",()=>Ac(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:F}:R,4));t.measure("validate",()=>{Fi(Ir)});let er=se(Ir)?.version,qr=e.saveMode==="local-commit-save"&&typeof er=="number"?er:ne,hi=`/${Nn.relative(e.projectRoot,a.scenePath).split(Nn.sep).join("/")}?v=${encodeURIComponent(String(qr))}`,tr="",Bn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(D,null,2)}
15
+ `);await t.measureAsync("write",()=>nd(e,Bn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Fn(e),await vI(Nn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
+ `);await t.measureAsync("write",()=>nd(e,Bn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!g)throw new Error("shadows_config_path_missing");await vI(Nn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(g,null,2)}
17
+ `);await t.measureAsync("write",()=>nd(e,Bn,a.shadowsConfigPath,xe))}tr=t.measure("stringify",()=>`${JSON.stringify(Ir,null,2)}
18
+ `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>nd(e,Bn,a.scenePath,tr)),Fn(e),await t.measureAsync("write",async()=>{for(let xe of Bn)await fj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await GI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(Bn.filter(xe=>!xe.committed).map(xe=>GI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let yf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return yf.length>0&&e.invalidateFiles?.(e.server,yf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:qr,updatedAt:F,sceneUrl:hi}:{},editorScene:p,...g?{shadowMapExperimentConfig:g}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:z}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(E??null)??null}:{}}:{},sceneJsonText:tr,performanceProfile:t.snapshot(),summary:{editorScene:VI($),compiled:h.summary}}}async function nd(e,t,r,n){Fn(e);let o=Nn.join(Nn.dirname(r),`.${Nn.basename(r)}.${process.pid}.${gj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await pj(o,n,{encoding:"utf8",signal:e.signal})}function Fn(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function Sj(e){let t=gi(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=jI(t);if(!r)return e.rawEditorScene;let n=jI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=se(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=se(se(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function jI(e){let t=se(se(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function nf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function BI(e){qc(e)}function VI(e){let t=se(e),r=se(t?.meta),n=se(r?.authoringSource),o=se(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function yj(e,t){let r={...Ur(e)};delete r.rendering;for(let[o,a]of Object.entries(t))a==null?delete r[o]:r[o]=a;let n={...e};return Object.keys(r).length>0?n.companionConfigs=r:delete n.companionConfigs,n}function gi(e){return _I(e)?JSON.parse($I(e,"utf8")||"{}"):null}function UI(e){if(!e)return null;if(!_I(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse($I(e,"utf8")||"{}");return wi(t,"$"),structuredClone(t)}function KI(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(wi(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function NI(e,t,r=!1){let n=se(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw FI(`${t}.${a}`);let o=se(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw FI(`${t}.companionConfigs.shadows`)}function FI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import yi from"node:path";import{pipeline as wj}from"node:stream/promises";import{realpathSync as hj}from"node:fs";import af from"node:path";function No(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of Ej(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function Ej(e){let t=af.resolve(e),r=bi(t);return[...new Set([e,t,r,of(e),of(t),of(r)])]}function bi(e){let t=af.resolve(e);try{return hj(t)}catch{return t}}function of(e){return e.split(af.sep).join("/")}import{constants as HI}from"node:fs";import Si from"node:fs/promises";import _n from"node:path";var Ij=128*1024*1024,Pj=512*1024*1024;async function Fo(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function Tj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||_n.posix.isAbsolute(t)||/^[A-Za-z]:\//.test(t))throw new Error("project_file_path_invalid");let r=t.split("/");if(r.some(n=>!n||n==="."||n===".."))throw new Error("project_file_path_invalid");return r.join("/")}function sf(e){if(e===void 0)return Ij;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Pj)}async function od(e,t){let r=Tj(t),n=await Si.realpath(_n.resolve(e)),o=_n.resolve(n,...r.split("/"));WI(n,o),await xj(n,r);let a;try{a=await Si.open(o,HI.O_RDONLY|(HI.O_NOFOLLOW??0))}catch(i){throw i?.code==="ELOOP"?new Error("project_file_symlink_unsupported"):i}try{let i=await a.stat();if(!i.isFile())throw new Error("project_file_not_found");let s=await Si.realpath(o);if(WI(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await Si.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await Fo(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function WI(e,t){let r=_n.relative(e,t);if(!r||r===".."||r.startsWith(`..${_n.sep}`)||_n.isAbsolute(r))throw new Error("project_file_path_invalid")}async function xj(e,t){let r=e;for(let n of t.split("/"))if(r=_n.join(r,n),(await Si.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Er from"node:fs/promises";import mt from"node:path";var qI=512*1024,Aj=new Set([".DS_Store",".cache",".git",".next",".nuxt",".parcel-cache",".turbo",".vite","build","coverage","dist","dist-tests","node_modules","output","playwright-report","test-results"]);async function JI(e,t={}){let r=await Er.realpath(mt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...Aj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=mt.resolve(r,c),u=await Dj(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=mt.posix.join(c.split(mt.sep).join("/"),l.name),f=mt.resolve(r,...m.split("/")),S=await Mj(r,f);if(!S)continue;let g=S==="file"?mt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(mt.sep).join("/"):null,kind:S,...g?{extension:g}:{}}),S==="directory"&&await s(m)}}};return await s(""),{rootName:mt.basename(r)||"Project",entries:a,truncated:i}}async function Dj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Er.realpath(t);if(n!==t||!cf(e,n))return null;let o=await Er.readdir(t,{withFileTypes:!0}),a=await Er.lstat(t),i=await Er.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!cf(e,i)?null:o}catch{return null}}async function XI(e,t,r={}){let n=await od(e,t),{handle:o,relativePath:a,stat:i}=n;if(!AE(a))throw await Fo(o),new Error("project_file_preview_unsupported");let s=qI,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??qI,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await Fo(o)}let u=mt.basename(a);return{path:a,name:u,extension:Jc(u),language:Cm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Mj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink())return null;let n=await Er.realpath(t);if(n===e||!cf(e,n)||n!==t)return null;let o=await Er.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function cf(e,t){let r=mt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${mt.sep}`)&&!mt.isAbsolute(r)}var df="/__fps_editor_authoring";function YI(e){let t=Promise.resolve([]);return{name:e.name??"fps-editor-project-authoring-api",enforce:"post",apply:"serve",async configureServer(r){let n=e.createAssetAuthoringHandlers(r);e.getAuthoringWrittenFiles&&(t=e.getAuthoringWrittenFiles(r).then(o=>o.map(a=>yi.resolve(e.projectRoot,a))).then(async o=>(kj(r,o),Oj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===df||c.startsWith(`${df}/`),u=d&&c.slice(df.length)||"/";if(d&&u==="/project-media"){if(pi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Hr(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Hr(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await od(e.projectRoot,m),S=null,g=null;try{let b=vm(f.relativePath);if(!b)throw new Error("project_file_media_unsupported");if(f.stat.size>sf(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=yi.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",b.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(g=Buffer.allocUnsafe(1),(await f.handle.read(g,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await wj(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(b){S=b}try{await Fo(f.handle)}catch(b){if(S){let y=new Error("project_file_close_failed");y.errors=[S,b],S=y}else S=b}if(S)throw S;g?a.end(g):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let S=f instanceof Error?f.message:String(f);Hr(a,{statusCode:S==="project_file_media_too_large"?413:404,body:{ok:!1,error:S}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(pi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:ef});Hr(a,m)}catch(m){Hr(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await kE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>ef(o,{...f.routeName==="asset-import"?{maxBytes:Zu}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return JI(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return XI(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:S}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:S})}});if(!l){if(d){pi(a),Hr(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Hr(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(ad(r.file,n))return[]}}}function ad(e,t){let r=bi(e);return t.some(n=>{let o=bi(n);if(r===o)return!0;let a=yi.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${yi.sep}`)&&!yi.isAbsolute(a)})}function kj(e,t){if(!e.watcher?.prependListener||!e.ws?.send)return;let r=null,n=null,o=()=>{r=null,n&&clearTimeout(n),n=null},a=s=>{o(),r=typeof s=="string"&&ad(s,t)?bi(s):null,r&&(n=setTimeout(o,1e3))};for(let s of["add","change","unlink"])e.watcher.prependListener(s,a);let i=e.ws.send.bind(e.ws);e.ws.send=(s,...c)=>{let d=typeof s?.triggeredBy=="string"?s.triggeredBy:void 0,u=d?ad(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Oj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!ad(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import $n,{resolve as _o}from"node:path";import{pathToFileURL as Rj}from"node:url";function ZI(e){let t=Promise.resolve();function r(m){let f=t.then(m);return t=f.then(()=>{},()=>{}),f}async function n(m,f="strict"){let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=[S,g].filter(T=>!!T),y=[],I=[],E=0;for(let T of b){let A=await jo(T),$=typeof A.errorCodes=="object"&&A.errorCodes?A.errorCodes:{},z=f==="report"?await qm(T,$):await Wm(T,$);E+=z.scannedAssetCount,y.push(...z.refreshedAssets);let p="availabilityIssues"in z&&Array.isArray(z.availabilityIssues)?z.availabilityIssues:[];I.push(...p)}return y.length>0&&No(m,[...b.flatMap(T=>[T.manifestPath,T.registryPath]),...lf(e)]),{scannedAssetCount:E,refreshedAssets:y,availabilityIssues:Cj(I)}}function o(m){return r(async()=>{let f=await n(m,"strict");return{scannedAssetCount:f.scannedAssetCount,refreshedAssets:f.refreshedAssets}})}function a(m){return r(async()=>{let f=await n(m,"report"),S=u(Ma(await c(!1)),f.availabilityIssues??[]);return{scannedAssetCount:f.scannedAssetCount,refreshedAssetIds:f.refreshedAssets.map(g=>g.assetId),availabilityIssues:f.availabilityIssues??[],assets:S}})}function i(m,f){return r(async()=>{let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=f.kind??([".png",".jpg",".jpeg",".env"].includes($n.extname(f.sourcePath).toLowerCase())?"texture":"model"),y=b==="texture"?g??S:S,I=await jo(y),E=typeof I.errorCodes=="object"&&I.errorCodes?I.errorCodes:{},T=await Zt(y),A=await Go(y,{payloadData:{sourcePath:f.sourcePath,...f.displayName?{displayName:f.displayName}:{},kind:b,...f.category?{category:f.category}:{},...f.placeable===void 0?{}:{placeable:f.placeable}}},E);No(m,[y.manifestPath,y.registryPath,...lf(e)]);let z=Ma(await c(!1)).find(p=>p.assetId===A.assetId);if(!z)throw new Error("asset_import_catalog_projection_missing");return{asset:z,disposition:T.some(p=>p.assetId===A.assetId)?"deduplicated":"created"}})}async function s(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=RI({assetRegistryConfig:f,textureRegistryConfig:S,loadAssetCatalogEntries:()=>c(!0),additionalInvalidationFiles:lf(e),invalidateFiles(b){No(m,b)}});return{loadManifest:b=>r(async()=>(await n(m,"report"),g.loadManifest(b))),loadEditorAssetLibrary:b=>r(async()=>{let y=await n(m,"report"),I=await g.loadEditorAssetLibrary(b);return!I||typeof I!="object"||!Array.isArray(I.assets)?I:{...I,assets:u(I.assets,y.availabilityIssues??[])}}),importAsset:b=>r(async()=>g.importAsset(b))}}async function c(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=[f,S].filter(E=>!!E),b=[...new Map(g.map(E=>[E.manifestPath,E])).values()],y=(await Promise.all(b.map(E=>Zt(E)))).flat(),I=new Set;return y.filter(E=>{if(E.kind!=="model"&&E.kind!=="texture"||m&&E.kind==="model"&&E.placeable!==!0)return!1;if(I.has(E.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${E.assetId}`);return I.add(E.assetId),!0})}async function d(m,f="strict"){return r(async()=>{let S=await n(m,f);return u(Ma(await c(!1)),S.availabilityIssues??[])})}function u(m,f){if(f.length===0)return m;let S=new Map;for(let g of f){let b=S.get(g.assetId)??[];b.push(g),S.set(g.assetId,b)}return m.map(g=>{let b=typeof g.assetId=="string"?g.assetId:typeof g.id=="string"?g.id:"",y=b?S.get(b):void 0;return!y||y.length===0?g:{...g,availability:{status:"unavailable",issues:y.map(I=>({code:I.code,reason:I.reason,stage:I.stage,severity:"error",relativePath:I.relativePath,...I.nodeCode?{nodeCode:I.nodeCode}:{},retryable:I.retryable}))}}})}async function l(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${Rj(_o(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadProjectAssetCatalogConfigModule:l,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Cj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function QI(e,t){let r=_o(e,t.importedDir),n=_o(e,t.generatedDir),o=$n.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:$n.join(n,"asset-catalog.manifest.json"),registryPath:$n.join(n,"asset-catalog.generated.ts"),scenePath:_o(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:_o(e,t.editorScene)}:{},supportedExtensions:ko,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=$n.join(r,s,i);return $n.relative(n,c).split($n.sep).join("/")},resolveAssetMetadata(a){return di({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function lf(e){return(e.additionalInvalidationFiles??[]).map(t=>_o(e.projectRoot,t))}import id from"node:path";function eP(e,t){return{editorScenePath:id.resolve(t,e.source.editorScene),scenePath:id.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:id.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:id.resolve(t,e.source.shadows)}:{}}}import{existsSync as vj,readFileSync as Gj}from"node:fs";import{mkdir as jj,writeFile as Nj}from"node:fs/promises";import uf from"node:path";function tP(e,t){let r=e.source.rendering,n=r?uf.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>uf.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:_j,async handleRoute(a){return n?KE({method:Fj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:vj(n)?JSON.parse(Gj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return rd([n],async()=>(await jj(uf.dirname(n),{recursive:!0}),await Nj(n,`${JSON.stringify(i,null,2)}
19
+ `,"utf8"),No(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Fj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function _j(e){return{postProcessEnabled:e?.postProcess?.enabled??e?.globalVolume?.enabled??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??e?.globalVolume?.postProcessing?.bloom?.enabled??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}import{randomUUID as $j}from"node:crypto";import{realpath as Lj}from"node:fs/promises";import{createServer as zj}from"node:http";async function nP(e){let t=await Lj(e.projectRoot),r=$j(),n=[...e.middlewares??[]],o=zj((c,d)=>{Bj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){mf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){mf(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(S=>{if(d.headersSent){d.destroy(S instanceof Error?S:void 0);return}mf(d,500,{ok:!1,error:S instanceof Error?S.message:String(S)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await rP(o).catch(()=>{}),new Error("Editor Project I/O worker address is unavailable.");let i=`http://127.0.0.1:${a.port}`;e.logger?.info?.(`[fps-editor] Project I/O worker ready at ${i}`);let s=null;return Object.freeze({serviceInstanceId:r,internalUrl:i,dispose(){return s||(s=rP(o).catch(c=>{throw s=null,c}),s)}})}function Bj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function mf(e,t,r){Vj(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
+ `))}function Vj(e){return e.destroyed||e.writableEnded}async function rP(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Rt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Ln={kind:"texture"},oP={kind:"color"},Uj={kind:"enum",values:["lit","unlit"]},Kj={kind:"enum",values:["opaque","mask","blend"]},sP={lightingModel:Uj,baseColor:{kind:"object",properties:{color:oP,texture:Ln,brightness:Rt(0),saturation:Rt(0),contrast:Rt(0),hue:Rt(-180,180)}},normal:{kind:"object",properties:{texture:Ln,strength:Rt(0)}},emission:{kind:"object",properties:{color:oP,intensity:Rt(0),texture:Ln,maskTexture:Ln}},alpha:{kind:"object",properties:{mode:Kj,opacity:Rt(0,1),cutoff:Rt(0,1),texture:Ln}}},Hj={kind:"object",properties:{...sP,metallic:Rt(0,1),roughness:Rt(0,1),metallicRoughness:{kind:"object",properties:{texture:Ln}},occlusion:{kind:"object",properties:{texture:Ln,strength:Rt(0)}}}},Wj={kind:"object",properties:sP},qj={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Jj={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},aP=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],zn={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},cP=[Lo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Lo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),zo("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),Ct("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),zo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[zn]),Ct("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[zn,$o("properties.normal.texture.textureAssetId","normalTexture")]}),Lo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),Ct("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),zo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Lo("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),Ct("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),Ct("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),zo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Xj=[...cP,Ct("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[zn]}),Ct("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[zn]}),zo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[zn]),zo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[zn]),Ct("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[zn,$o("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],pf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Hj,defaultProperties:qj,inspector:{sections:aP,fields:Xj}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Wj,defaultProperties:Jj,inspector:{sections:aP,fields:cP}}],EK=gf(pf);function gf(e){let t=new Map;for(let n of e){Yj(n,t);let o=Zj(n);t.set(n.shaderId,mP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Lo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function Ct(e,t,r,n,o,a,i={}){return Lo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function zo(e,t,r,n,o,a,i,s){return Lo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function $o(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Yj(e,t){if(!Wn(e.shaderId)&&!Qo(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!eN(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);dP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(uP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Qj(e,a),o.add(a.path)}}function Zj(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=lP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Qj(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=lP(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function dP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))dP(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function eN(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function tN(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function lP(e,t){let r=tN(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function uP(e,t,r,n){if(e.kind==="object"){if(!ff(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&uP(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];iP(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){iP(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!ff(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function iP(e,t,r,n,o){if(!ff(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mP(t)}return e}function ff(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var rN=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nN=Object.freeze([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function sd(e){return oN(new TextEncoder().encode(e))}function fP(e){return`sha256:${sd(JSON.stringify(e))}`}function oN(e){let t=Math.ceil((e.length+9)/64)*64,r=new Uint8Array(t);r.set(e),r[e.length]=128;let n=new DataView(r.buffer);n.setUint32(t-8,Math.floor(e.length/536870912),!1),n.setUint32(t-4,e.length*8>>>0,!1);let o=[...rN],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let g=0;g<16;g+=1)a[g]=n.getUint32(i+g*4,!1);for(let g=16;g<64;g+=1){let b=a[g-15],y=a[g-2],I=Qt(b,7)^Qt(b,18)^b>>>3,E=Qt(y,17)^Qt(y,19)^y>>>10;a[g]=a[g-16]+I+a[g-7]+E>>>0}let[s,c,d,u,l,m,f,S]=o;for(let g=0;g<64;g+=1){let b=Qt(l,6)^Qt(l,11)^Qt(l,25),y=l&m^~l&f,I=S+b+y+nN[g]+a[g]>>>0,E=Qt(s,2)^Qt(s,13)^Qt(s,22),T=s&c^s&d^c&d,A=E+T>>>0;S=f,f=m,m=l,l=u+I>>>0,u=d,d=c,c=s,s=I+A>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+S>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function Qt(e,t){return e>>>t|e<<32-t}var aN="fps.plugin.materials";function gP(e){let t=e?.[aN];if(t==null)return null;if(!Bo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return iN(r),bP(r)}function bf(e){return gf([...pf,...e?.shaders.map(t=>t.definition)??[]])}function iN(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(let r of e.shaders)if(!Bo(r)||!Bo(r.definition)||!Bo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");bf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!pP(o.vertexSourcePath)||!pP(o.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(o.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(o.fragmentSourceHash)||typeof o.vertexSource!="string"||!o.vertexSource.trim()||typeof o.fragmentSource!="string"||!o.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(sd(o.vertexSource)!==o.vertexSourceHash||sd(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Bo(o.enumUniformValues)||!Bo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(fP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function pP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function bP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))bP(t);return Object.freeze(e)}function Bo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function yP(e){let t=ME(e.definition),r=gP(e.pluginSnapshots),n=bf(r),o=t.project,a=sN(e.projectRoot),i=QI(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=ZI({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=tP(o,{projectRoot:e.projectRoot}),d=eP(o,e.projectRoot),u=iE({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(g,b,y)=>({kind:"game-object.field",targetId:g,path:b,value:y}),gameObjectFieldBatch:g=>({kind:"game-object.property-field-batch",fields:g}),materialAssetField:(g,b,y)=>({kind:"scene.material-asset.field",materialAssetId:g,path:b,value:y}),materialAssetReplace:(g,b)=>({kind:"scene.material-asset.replace",materialAssetId:g,materialAsset:b}),prefabAssetReplace:(g,b)=>({kind:"scene.prefab-asset.replace",assetId:g,prefabAsset:b}),markerGraph:g=>({kind:"scene.marker-graph",command:g})}}),l={ensureAuthoringSource:vg,detectRuntimeInputDrift:jg,enrichEditorSceneDocumentAssets:Zl,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:BI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:Gg,compileEditorSceneDocumentToSceneConfig:(g,b,y)=>RE(g,b,{...y,materialShaderDefinitions:n,readCustomTransformRuntimeData:I=>I?.transformType==="groundDecal"&&dN(I.groundDecal)?{groundDecal:UE(I.groundDecal)}:null})},f=(g,b="report")=>s.listEditorAssetLibrary(a,b),S=YI({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>LI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadServices:async()=>l}),saveEditorScene:g=>zI({...g,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:b=>Ne(b),summarizeRenderingProfile:b=>Vn(b),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await cN(S.configureServer,a),nP({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function sN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new SP,n=new SP;return n.unwatch=async()=>{},n.add=()=>n,{middlewares:t,httpServer:r,watcher:n,ws:{send(){}},moduleGraph:{getModulesByFile(){},invalidateModule(){}},config:{root:e,logger:console}}}async function cN(e,t){if(typeof e=="function"){await e(t);return}e&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"&&await e.handler(t)}function dN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Wr=await yP({projectRoot:process.cwd(),definition:EP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:EP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Wr||typeof Wr.serviceInstanceId!="string"||typeof Wr.internalUrl!="string"||typeof Wr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Wr.serviceInstanceId,internalUrl:Wr.internalUrl});var Sf=!0,IP=setInterval(()=>{Sf&&process.send?.({type:"heartbeat",serviceInstanceId:Wr.serviceInstanceId})},1e3);IP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Sf=!1),e?.type==="test.start-heartbeat"&&(Sf=!0)});var hP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{hP||(hP=!0,clearInterval(IP),Wr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function lN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function EP(e){let t=JSON.parse(lN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}