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

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,5 +1,5 @@
1
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",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(`
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
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
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
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(`
@@ -17,4 +17,4 @@ ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_sch
17
17
  `);await t.measureAsync("write",()=>rd(e,zn,a.shadowsConfigPath,xe))}tr=t.measure("stringify",()=>`${JSON.stringify(Ir,null,2)}
18
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
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",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}
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}