@fnndsc/argus 0.16.2 → 0.16.3

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,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-CQxasfu7.js","./_commonjsHelpers-CE1G-McA.js"])))=>i.map(i=>d[i]);
2
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();const gM=["cold","cached","failed"];function bM(n){return n.state??(n.restored===!0?"cached":"cold")}const zM=["upload","download","pull","workflow","pipeline","group","task"],_M=["transfer","retrieve","workflow","inspection"],wM=["scanning","transferring","watching","retrying","reading","working","complete","failed"],yM=["files","bytes","series","jobs","nodes"],vM=["running","done","unconfirmed","stalled","timeout","error","unknown"],Ec=1;var Tt;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{const r={};for(const a of i)r[a]=a;return r},n.getValidEnumValues=i=>{const r=n.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of r)a[o]=i[o];return n.objectValues(a)},n.objectValues=i=>n.objectKeys(i).map(function(r){return i[r]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const r=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&r.push(a);return r},n.find=(i,r)=>{for(const a of i)if(r(a))return a},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,r=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}n.joinValues=s,n.jsonStringifyReplacer=(i,r)=>typeof r=="bigint"?r.toString():r})(Tt||(Tt={}));var Su;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Su||(Su={}));const je=Tt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),hi=n=>{switch(typeof n){case"undefined":return je.undefined;case"string":return je.string;case"number":return Number.isNaN(n)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(n)?je.array:n===null?je.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?je.promise:typeof Map<"u"&&n instanceof Map?je.map:typeof Set<"u"&&n instanceof Set?je.set:typeof Date<"u"&&n instanceof Date?je.date:je.object;default:return je.unknown}},ze=Tt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Jn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(r){return r.message},s={_errors:[]},i=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)s._errors.push(t(a));else{let o=s,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),s}static assert(e){if(!(e instanceof Jn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Tt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const i of this.issues)if(i.path.length>0){const r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Jn.create=n=>new Jn(n);const Dc=(n,e)=>{let t;switch(n.code){case ze.invalid_type:n.received===je.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case ze.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,Tt.jsonStringifyReplacer)}`;break;case ze.unrecognized_keys:t=`Unrecognized key(s) in object: ${Tt.joinValues(n.keys,", ")}`;break;case ze.invalid_union:t="Invalid input";break;case ze.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Tt.joinValues(n.options)}`;break;case ze.invalid_enum_value:t=`Invalid enum value. Expected ${Tt.joinValues(n.options)}, received '${n.received}'`;break;case ze.invalid_arguments:t="Invalid function arguments";break;case ze.invalid_return_type:t="Invalid function return type";break;case ze.invalid_date:t="Invalid date";break;case ze.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:Tt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case ze.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case ze.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case ze.custom:t="Invalid input";break;case ze.invalid_intersection_types:t="Intersection results could not be merged";break;case ze.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case ze.not_finite:t="Number must be finite";break;default:t=e.defaultError,Tt.assertNever(n)}return{message:t}};let OM=Dc;function xM(){return OM}const SM=n=>{const{data:e,path:t,errorMaps:s,issueData:i}=n,r=[...t,...i.path||[]],a={...i,path:r};if(i.message!==void 0)return{...i,path:r,message:i.message};let o="";const l=s.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:e,defaultError:o}).message;return{...i,path:r,message:o}};function Ce(n,e){const t=xM(),s=SM({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Dc?void 0:Dc].filter(i=>!!i)});n.common.issues.push(s)}class Xs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const i of t){if(i.status==="aborted")return st;i.status==="dirty"&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const i of t){const r=await i.key,a=await i.value;s.push({key:r,value:a})}return Xs.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:r,value:a}=i;if(r.status==="aborted"||a.status==="aborted")return st;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(s[r.value]=a.value)}return{status:e.value,value:s}}}const st=Object.freeze({status:"aborted"}),fa=n=>({status:"dirty",value:n}),rn=n=>({status:"valid",value:n}),Au=n=>n.status==="aborted",Eu=n=>n.status==="dirty",Br=n=>n.status==="valid",Lo=n=>typeof Promise<"u"&&n instanceof Promise;var He;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(He||(He={}));class _i{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Du=(n,e)=>{if(Br(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Jn(n.common.issues);return this._error=t,this._error}}};function zt(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:i}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{const{message:l}=n;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:l??t??o.defaultError}},description:i}}class Dt{get description(){return this._def.description}_getType(e){return hi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:hi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Xs,ctx:{common:e.parent.common,data:e.data,parsedType:hi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Lo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:hi(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Du(s,i)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:hi(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return Br(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>Br(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:hi(e)},i=this._parse({data:e,path:s.path,parent:s}),r=await(Lo(i)?i:Promise.resolve(i));return Du(s,r)}refine(e,t){const s=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,r)=>{const a=e(i),o=()=>r.addIssue({code:ze.custom,...s(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,i)=>e(s)?!0:(i.addIssue(typeof t=="function"?t(s,i):t),!1))}_refinement(e){return new Hi({schema:this,typeName:at.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Yn.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return An.create(this)}promise(){return $o.create(this,this._def)}or(e){return Uo.create([this,e],this._def)}and(e){return Fo.create(this,e,this._def)}transform(e){return new Hi({...zt(this._def),schema:this,typeName:at.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ho({...zt(this._def),innerType:this,defaultValue:t,typeName:at.ZodDefault})}brand(){return new Op({typeName:at.ZodBranded,type:this,...zt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qo({...zt(this._def),innerType:this,catchValue:t,typeName:at.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return jd.create(this,e)}readonly(){return Xo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const AM=/^c[^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((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,UM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wp="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",FM=new RegExp(`^${wp}$`);function yp(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function jM(n){return new RegExp(`^${yp(n)}$`)}function VM(n){let e=`${wp}T${yp(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function $M(n,e){return!!((e==="v4"||!e)&&CM.test(n)||(e==="v6"||!e)&&WM.test(n))}function HM(n,e){if(!GM.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function qM(n,e){return!!((e==="v4"||!e)&&PM.test(n)||(e==="v6"||!e)&&LM.test(n))}class Mi extends Dt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.string,received:r.parsedType}),st}const s=new Xs;let i;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,o=e.data.length<r.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?Ce(i,{code:ze.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&Ce(i,{code:ze.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")BM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"email",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")El||(El=new RegExp(NM,"u")),El.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"emoji",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")IM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"uuid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")TM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"nanoid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")AM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cuid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")EM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cuid2",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")DM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"ulid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Ce(i,{validation:"url",code:ze.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"regex",code:ze.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?VM(r).test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?FM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?jM(r).test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?RM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"duration",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?$M(e.data,r.version)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"ip",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?HM(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"jwt",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?qM(e.data,r.version)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cidr",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?kM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"base64",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?UM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"base64url",code:ze.invalid_string,message:r.message}),s.dirty()):Tt.assertNever(r);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(i=>e.test(i),{validation:t,code:ze.invalid_string,...He.errToObj(s)})}_addCheck(e){return new Mi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...He.errToObj(e)})}url(e){return this._addCheck({kind:"url",...He.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...He.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...He.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...He.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...He.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...He.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...He.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...He.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...He.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...He.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...He.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...He.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...He.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...He.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...He.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...He.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...He.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...He.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...He.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...He.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...He.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...He.errToObj(t)})}nonempty(e){return this.min(1,He.errToObj(e))}trim(){return new Mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Mi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Mi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Mi.create=n=>new Mi({checks:[],typeName:at.ZodString,coerce:n?.coerce??!1,...zt(n)});function XM(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,r=Number.parseInt(n.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return r%a/10**i}class Nr extends Dt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==je.number){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.number,received:r.parsedType}),st}let s;const i=new Xs;for(const r of this._def.checks)r.kind==="int"?Tt.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.invalid_type,expected:"integer",received:"float",message:r.message}),i.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="multipleOf"?XM(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_finite,message:r.message}),i.dirty()):Tt.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,He.toString(t))}gt(e,t){return this.setLimit("min",e,!1,He.toString(t))}lte(e,t){return this.setLimit("max",e,!0,He.toString(t))}lt(e,t){return this.setLimit("max",e,!1,He.toString(t))}setLimit(e,t,s,i){return new Nr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:He.toString(i)}]})}_addCheck(e){return new Nr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:He.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:He.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:He.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:He.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:He.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:He.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:He.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:He.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:He.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Tt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Nr.create=n=>new Nr({checks:[],typeName:at.ZodNumber,coerce:n?.coerce||!1,...zt(n)});class va extends Dt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==je.bigint)return this._getInvalidInput(e);let s;const i=new Xs;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):Tt.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Ce(t,{code:ze.invalid_type,expected:je.bigint,received:t.parsedType}),st}gte(e,t){return this.setLimit("min",e,!0,He.toString(t))}gt(e,t){return this.setLimit("min",e,!1,He.toString(t))}lte(e,t){return this.setLimit("max",e,!0,He.toString(t))}lt(e,t){return this.setLimit("max",e,!1,He.toString(t))}setLimit(e,t,s,i){return new va({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:He.toString(i)}]})}_addCheck(e){return new va({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:He.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:He.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:He.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:He.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:He.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}va.create=n=>new va({checks:[],typeName:at.ZodBigInt,coerce:n?.coerce??!1,...zt(n)});class Ic extends Dt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==je.boolean){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.boolean,received:s.parsedType}),st}return rn(e.data)}}Ic.create=n=>new Ic({typeName:at.ZodBoolean,coerce:n?.coerce||!1,...zt(n)});class ko extends Dt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.date,received:r.parsedType}),st}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_date}),st}const s=new Xs;let i;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):Tt.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ko({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:He.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:He.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ko.create=n=>new ko({checks:[],coerce:n?.coerce||!1,typeName:at.ZodDate,...zt(n)});class Iu extends Dt{_parse(e){if(this._getType(e)!==je.symbol){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.symbol,received:s.parsedType}),st}return rn(e.data)}}Iu.create=n=>new Iu({typeName:at.ZodSymbol,...zt(n)});class Tc extends Dt{_parse(e){if(this._getType(e)!==je.undefined){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.undefined,received:s.parsedType}),st}return rn(e.data)}}Tc.create=n=>new Tc({typeName:at.ZodUndefined,...zt(n)});class Gc extends Dt{_parse(e){if(this._getType(e)!==je.null){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.null,received:s.parsedType}),st}return rn(e.data)}}Gc.create=n=>new Gc({typeName:at.ZodNull,...zt(n)});class Tu extends Dt{constructor(){super(...arguments),this._any=!0}_parse(e){return rn(e.data)}}Tu.create=n=>new Tu({typeName:at.ZodAny,...zt(n)});class Rc extends Dt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return rn(e.data)}}Rc.create=n=>new Rc({typeName:at.ZodUnknown,...zt(n)});class wi extends Dt{_parse(e){const t=this._getOrReturnCtx(e);return Ce(t,{code:ze.invalid_type,expected:je.never,received:t.parsedType}),st}}wi.create=n=>new wi({typeName:at.ZodNever,...zt(n)});class Gu extends Dt{_parse(e){if(this._getType(e)!==je.undefined){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.void,received:s.parsedType}),st}return rn(e.data)}}Gu.create=n=>new Gu({typeName:at.ZodVoid,...zt(n)});class An extends Dt{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),i=this._def;if(t.parsedType!==je.array)return Ce(t,{code:ze.invalid_type,expected:je.array,received:t.parsedType}),st;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(Ce(t,{code:a?ze.too_big:ze.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),s.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(Ce(t,{code:ze.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),s.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(Ce(t,{code:ze.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new _i(t,a,t.path,o)))).then(a=>Xs.mergeArray(s,a));const r=[...t.data].map((a,o)=>i.type._parseSync(new _i(t,a,t.path,o)));return Xs.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new An({...this._def,minLength:{value:e,message:He.toString(t)}})}max(e,t){return new An({...this._def,maxLength:{value:e,message:He.toString(t)}})}length(e,t){return new An({...this._def,exactLength:{value:e,message:He.toString(t)}})}nonempty(e){return this.min(1,e)}}An.create=(n,e)=>new An({type:n,minLength:null,maxLength:null,exactLength:null,typeName:at.ZodArray,...zt(e)});function Er(n){if(n instanceof as){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Yn.create(Er(s))}return new as({...n._def,shape:()=>e})}else return n instanceof An?new An({...n._def,type:Er(n.element)}):n instanceof Yn?Yn.create(Er(n.unwrap())):n instanceof qi?qi.create(Er(n.unwrap())):n instanceof Vi?Vi.create(n.items.map(e=>Er(e))):n}class as extends Dt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Tt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==je.object){const c=this._getOrReturnCtx(e);return Ce(c,{code:ze.invalid_type,expected:je.object,received:c.parsedType}),st}const{status:s,ctx:i}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof wi&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const d=r[c],h=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new _i(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof wi){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")o.length>0&&(Ce(i,{code:ze.unrecognized_keys,keys:o}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const h=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new _i(i,h,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const h=await d.key,u=await d.value;c.push({key:h,value:u,alwaysSet:d.alwaysSet})}return c}).then(c=>Xs.mergeObjectSync(s,c)):Xs.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return He.errToObj,new as({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const i=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:He.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new as({...this._def,unknownKeys:"strip"})}passthrough(){return new as({...this._def,unknownKeys:"passthrough"})}extend(e){return new as({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new as({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:at.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new as({...this._def,catchall:e})}pick(e){const t={};for(const s of Tt.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new as({...this._def,shape:()=>t})}omit(e){const t={};for(const s of Tt.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new as({...this._def,shape:()=>t})}deepPartial(){return Er(this)}partial(e){const t={};for(const s of Tt.objectKeys(this.shape)){const i=this.shape[s];e&&!e[s]?t[s]=i:t[s]=i.optional()}return new as({...this._def,shape:()=>t})}required(e){const t={};for(const s of Tt.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof Yn;)r=r._def.innerType;t[s]=r}return new as({...this._def,shape:()=>t})}keyof(){return vp(Tt.objectKeys(this.shape))}}as.create=(n,e)=>new as({shape:()=>n,unknownKeys:"strip",catchall:wi.create(),typeName:at.ZodObject,...zt(e)});as.strictCreate=(n,e)=>new as({shape:()=>n,unknownKeys:"strict",catchall:wi.create(),typeName:at.ZodObject,...zt(e)});as.lazycreate=(n,e)=>new as({shape:n,unknownKeys:"strip",catchall:wi.create(),typeName:at.ZodObject,...zt(e)});class Uo extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function i(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new Jn(o.ctx.common.issues));return Ce(t,{code:ze.invalid_union,unionErrors:a}),st}if(t.common.async)return Promise.all(s.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let r;const a=[];for(const l of s){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!r&&(r={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(l=>new Jn(l));return Ce(t,{code:ze.invalid_union,unionErrors:o}),st}}get options(){return this._def.options}}Uo.create=(n,e)=>new Uo({options:n,typeName:at.ZodUnion,...zt(e)});const jn=n=>n instanceof jo?jn(n.schema):n instanceof Hi?jn(n.innerType()):n instanceof Vo?[n.value]:n instanceof $i?n.options:n instanceof Nc?Tt.objectValues(n.enum):n instanceof Ho?jn(n._def.innerType):n instanceof Tc?[void 0]:n instanceof Gc?[null]:n instanceof Yn?[void 0,...jn(n.unwrap())]:n instanceof qi?[null,...jn(n.unwrap())]:n instanceof Op||n instanceof Xo?jn(n.unwrap()):n instanceof qo?jn(n._def.innerType):[];class Fd extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.object)return Ce(t,{code:ze.invalid_type,expected:je.object,received:t.parsedType}),st;const s=this.discriminator,i=t.data[s],r=this.optionsMap.get(i);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(Ce(t,{code:ze.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),st)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const r of t){const a=jn(r.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,r)}}return new Fd({typeName:at.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...zt(s)})}}function Bc(n,e){const t=hi(n),s=hi(e);if(n===e)return{valid:!0,data:n};if(t===je.object&&s===je.object){const i=Tt.objectKeys(e),r=Tt.objectKeys(n).filter(o=>i.indexOf(o)!==-1),a={...n,...e};for(const o of r){const l=Bc(n[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===je.array&&s===je.array){if(n.length!==e.length)return{valid:!1};const i=[];for(let r=0;r<n.length;r++){const a=n[r],o=e[r],l=Bc(a,o);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===je.date&&s===je.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Fo extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=(r,a)=>{if(Au(r)||Au(a))return st;const o=Bc(r.value,a.value);return o.valid?((Eu(r)||Eu(a))&&t.dirty(),{status:t.value,value:o.data}):(Ce(s,{code:ze.invalid_intersection_types}),st)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,a])=>i(r,a)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Fo.create=(n,e,t)=>new Fo({left:n,right:e,typeName:at.ZodIntersection,...zt(t)});class Vi extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.array)return Ce(s,{code:ze.invalid_type,expected:je.array,received:s.parsedType}),st;if(s.data.length<this._def.items.length)return Ce(s,{code:ze.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),st;!this._def.rest&&s.data.length>this._def.items.length&&(Ce(s,{code:ze.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new _i(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(r).then(a=>Xs.mergeArray(t,a)):Xs.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Vi({...this._def,rest:e})}}Vi.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Vi({items:n,typeName:at.ZodTuple,rest:null,...zt(e)})};class Ru extends Dt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.map)return Ce(s,{code:ze.invalid_type,expected:je.map,received:s.parsedType}),st;const i=this._def.keyType,r=this._def.valueType,a=[...s.data.entries()].map(([o,l],c)=>({key:i._parse(new _i(s,o,s.path,[c,"key"])),value:r._parse(new _i(s,l,s.path,[c,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return st;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return st;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}Ru.create=(n,e,t)=>new Ru({valueType:e,keyType:n,typeName:at.ZodMap,...zt(t)});class Oa extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.set)return Ce(s,{code:ze.invalid_type,expected:je.set,received:s.parsedType}),st;const i=this._def;i.minSize!==null&&s.data.size<i.minSize.value&&(Ce(s,{code:ze.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&s.data.size>i.maxSize.value&&(Ce(s,{code:ze.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const r=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return st;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...s.data.values()].map((l,c)=>r._parse(new _i(s,l,s.path,c)));return s.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Oa({...this._def,minSize:{value:e,message:He.toString(t)}})}max(e,t){return new Oa({...this._def,maxSize:{value:e,message:He.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Oa.create=(n,e)=>new Oa({valueType:n,minSize:null,maxSize:null,typeName:at.ZodSet,...zt(e)});class jo extends Dt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}jo.create=(n,e)=>new jo({getter:n,typeName:at.ZodLazy,...zt(e)});class Vo extends Dt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Ce(t,{received:t.data,code:ze.invalid_literal,expected:this._def.value}),st}return{status:"valid",value:e.data}}get value(){return this._def.value}}Vo.create=(n,e)=>new Vo({value:n,typeName:at.ZodLiteral,...zt(e)});function vp(n,e){return new $i({values:n,typeName:at.ZodEnum,...zt(e)})}class $i extends Dt{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return Ce(t,{expected:Tt.joinValues(s),received:t.parsedType,code:ze.invalid_type}),st}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return Ce(t,{received:t.data,code:ze.invalid_enum_value,options:s}),st}return rn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return $i.create(e,{...this._def,...t})}exclude(e,t=this._def){return $i.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}$i.create=vp;class Nc extends Dt{_parse(e){const t=Tt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==je.string&&s.parsedType!==je.number){const i=Tt.objectValues(t);return Ce(s,{expected:Tt.joinValues(i),received:s.parsedType,code:ze.invalid_type}),st}if(this._cache||(this._cache=new Set(Tt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Tt.objectValues(t);return Ce(s,{received:s.data,code:ze.invalid_enum_value,options:i}),st}return rn(e.data)}get enum(){return this._def.values}}Nc.create=(n,e)=>new Nc({values:n,typeName:at.ZodNativeEnum,...zt(e)});class $o extends Dt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.promise&&t.common.async===!1)return Ce(t,{code:ze.invalid_type,expected:je.promise,received:t.parsedType}),st;const s=t.parsedType===je.promise?t.data:Promise.resolve(t.data);return rn(s.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}$o.create=(n,e)=>new $o({type:n,typeName:at.ZodPromise,...zt(e)});class Hi extends Dt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===at.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=this._def.effect||null,r={addIssue:a=>{Ce(s,a),a.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),i.type==="preprocess"){const a=i.transform(s.data,r);if(s.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return st;const l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?st:l.status==="dirty"||t.value==="dirty"?fa(l.value):l});{if(t.value==="aborted")return st;const o=this._def.schema._parseSync({data:a,path:s.path,parent:s});return o.status==="aborted"?st:o.status==="dirty"||t.value==="dirty"?fa(o.value):o}}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,r);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?st:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?st:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Br(a))return st;const o=i.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>Br(a)?Promise.resolve(i.transform(a.value,r)).then(o=>({status:t.value,value:o})):st);Tt.assertNever(i)}}Hi.create=(n,e,t)=>new Hi({schema:n,typeName:at.ZodEffects,effect:e,...zt(t)});Hi.createWithPreprocess=(n,e,t)=>new Hi({schema:e,effect:{type:"preprocess",transform:n},typeName:at.ZodEffects,...zt(t)});class Yn extends Dt{_parse(e){return this._getType(e)===je.undefined?rn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(n,e)=>new Yn({innerType:n,typeName:at.ZodOptional,...zt(e)});class qi extends Dt{_parse(e){return this._getType(e)===je.null?rn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}qi.create=(n,e)=>new qi({innerType:n,typeName:at.ZodNullable,...zt(e)});class Ho extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===je.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ho.create=(n,e)=>new Ho({innerType:n,typeName:at.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...zt(e)});class qo extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Lo(i)?i.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Jn(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Jn(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}qo.create=(n,e)=>new qo({innerType:n,typeName:at.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...zt(e)});class Bu extends Dt{_parse(e){if(this._getType(e)!==je.nan){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.nan,received:s.parsedType}),st}return{status:"valid",value:e.data}}}Bu.create=n=>new Bu({typeName:at.ZodNaN,...zt(n)});class Op extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class jd extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?st:r.status==="dirty"?(t.dirty(),fa(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?st:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(e,t){return new jd({in:e,out:t,typeName:at.ZodPipeline})}}class Xo extends Dt{_parse(e){const t=this._def.innerType._parse(e),s=i=>(Br(i)&&(i.value=Object.freeze(i.value)),i);return Lo(t)?t.then(i=>s(i)):s(t)}unwrap(){return this._def.innerType}}Xo.create=(n,e)=>new Xo({innerType:n,typeName:at.ZodReadonly,...zt(e)});var at;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(at||(at={}));const V=Mi.create,pe=Nr.create,is=Ic.create,Vd=Rc.create;wi.create;const Et=An.create,_e=as.create;Uo.create;const xp=Fd.create;Fo.create;const YM=Vi.create,KM=jo.create,Gt=Vo.create,us=$i.create;$o.create;Yn.create;qi.create;const ZM=us(["ok","error"]),QM=_e({type:us(["error","warning"]),message:V()}),JM=_e({kind:V(),data:Vd()}),eg=_e({input:V(),proposed:V(),validated:is(),executed:V().optional()}),Sp=_e({status:ZM,rendered:V(),renderedErr:V().optional(),model:JM.optional(),errors:Et(QM).optional(),trace:eg.optional()}),tg=us(["data","err","status"]),sg=_e({shellCommands:is(),hiddenInput:is().optional(),color:is().optional(),fileDelivery:is().optional(),localFilesystem:is().optional()}),ng=_e({type:Gt("attach"),protocolVersion:pe().int(),token:V(),session:V().optional(),capabilities:sg.optional()}),ig=_e({type:Gt("execute"),id:V(),line:V(),instrument:is().optional()}),rg=_e({type:Gt("cancel"),id:V()}),ag=_e({type:Gt("complete"),id:V(),prefix:V()}),og=_e({type:Gt("promptAnswer"),promptId:V(),answer:V()}),lg=_e({type:Gt("promptError"),promptId:V(),reason:V()}),cg=_e({type:Gt("pipeResult"),pipeId:V(),output:V()}),dg=_e({type:Gt("pipeError"),pipeId:V(),reason:V()}),ug=_e({type:Gt("shellResult"),shellId:V(),exitCode:pe().int()}),hg=_e({type:Gt("shellError"),shellId:V(),reason:V()}),fg=_e({type:Gt("editResult"),editId:V(),content:V(),changed:is()}),pg=_e({type:Gt("editError"),editId:V(),reason:V()}),mg=_e({type:Gt("deliverResult"),deliverId:V(),location:V(),bytes:pe().nonnegative()}),Mg=_e({type:Gt("deliverError"),deliverId:V(),reason:V()}),gg=_e({address:V(),modelKind:V().optional(),groupId:V(),paneId:V()}),Ap=_e({type:Gt("regard"),regard:gg}),bg=_e({type:Gt("watch"),subject:V()}),zg=_e({type:Gt("unwatch"),subject:V()}),_g=["live","settled","stale"],wg=us(_g),yg=_e({type:Gt("watched"),subject:V(),state:wg}),vg=_e({type:Gt("numbered"),id:pe(),source:V(),rows:pe(),handles:Et(_e({kind:V(),ordinal:pe(),address:V()}))});xp("type",[ng,ig,rg,ag,og,lg,cg,dg,ug,hg,fg,pg,mg,Mg,Ap,bg,zg]);const Og=_e({type:Gt("attached"),session:V(),protocolVersion:pe().int(),stack:_e({chell:V(),calypso:V(),build:V(),brasa:V().optional(),chili:V().optional(),salsa:V().optional(),cumin:V().optional()}).optional(),hostControl:Et(V()).optional()}),xg=_e({type:Gt("result"),id:V(),envelopes:Et(Sp)}),Sg=_e({type:Gt("complete"),id:V(),prefix:V(),candidates:Et(V())}),Ag=_e({type:Gt("output"),id:V(),channel:tg,chunk:V()}),Eg=us(zM).catch("task"),Dg=us(_M).catch(void 0),Ig=us(wM).catch("working"),Tg=us(yM).catch(void 0),Gg=us(vM).catch("unknown"),Rg=_e({type:Gt("progress"),id:V(),operation:Eg,kind:Dg.optional(),phase:Ig,label:V().optional(),itemId:V().optional(),current:pe().nonnegative().optional(),total:pe().nonnegative().optional(),percent:pe().min(0).max(100).optional(),unit:Tg.optional(),status:Gg.optional(),path:V().optional()}),Bg=_e({type:Gt("session"),surface:V(),envelope:Sp}),Ng=_e({type:Gt("error"),id:V().optional(),reason:V()}),Cg=["text","secret","confirm","path"],Pg=us(Cg).catch("text"),Wg=_e({anchor:V().optional(),wantsDirectory:is(),suggest:V().optional()}),Lg=_e({type:Gt("prompt"),promptId:V(),message:V(),hidden:is(),wants:Pg.optional(),path:Wg.optional(),commit:V().optional()});function kg(n){return n.wants!==void 0?n.wants:n.hidden===!0?"secret":"text"}const Ug=_e({user:V(),uri:V(),cwd:V(),pacsserver:V().nullable(),physicalMode:is(),lastExitCode:pe(),lastCommandDurationMs:pe(),procWarmup:_e({loaded:pe(),total:pe().optional(),restored:is().optional(),state:us(gM).optional(),sweeping:is().optional(),feed:_e({id:pe(),loaded:pe(),total:pe(),failed:V().optional()}).optional(),feeds:Et(_e({id:pe(),loaded:pe(),total:pe(),failed:V().optional()})).optional(),arrived:Et(pe()).optional(),landed:Et(_e({id:pe(),title:V().default(""),jobs:pe(),status:V(),chain:Et(V()),groups:Et(_e({plugin:V(),count:pe(),errored:pe().default(0),status:V(),parent:pe().nullable()})).default([])})).optional(),roster:us(["delta","full"]).optional()}).optional(),procIndex:_e({jobs:pe(),feeds:pe()}).optional(),warmupFailures:Et(_e({label:V(),message:V()})).optional()}),Fg=_e({type:Gt("promptline"),context:Ug}),jg=_e({type:Gt("pipe"),pipeId:V(),command:V(),input:V()}),Vg=_e({type:Gt("shell"),shellId:V(),command:V()}),$g=_e({type:Gt("edit"),editId:V(),content:V(),extension:V().optional()}),Hg=_e({type:Gt("deliver"),deliverId:V(),path:V(),filename:V(),destination:V().optional(),size:pe().nonnegative().optional(),contentType:V().optional()}),qg=_e({type:Gt("telemetry"),index:_e({jobs:pe(),feeds:pe()}),lane:_e({running:_e({line:V(),sinceMs:pe(),surface:V()}).nullable(),waiting:pe()}).optional(),cube:_e({msPerPage:pe(),samples:pe()}).optional(),state:_e({running:pe(),runningFeeds:pe(),scheduled:pe(),errored:pe(),erroredFeeds:pe()}).optional()}),Ep=xp("type",[Og,xg,Sg,Ag,Rg,Bg,Ng,Lg,Fg,qg,jg,Vg,$g,Hg,Ap,yg,vg]);new Set(Ep.options.map(n=>n.shape.type.value));function Xg(n){return n.issues.map(e=>{const t=e.path.join(".");return t?`${t}: ${e.message}`:e.message}).join("; ")}function Yg(n,e){const t=n.safeParse(e);return t.success?{ok:!0,value:t.data}:{ok:!1,error:Xg(t.error)}}function Kg(n){return Yg(Ep,n)}const Dp=_e({id:V(),label:V(),parentIds:Et(V()),joinParentIds:Et(V())}),Zg=_e({name:V(),value:Vd()}),Qg=Dp.extend({pluginName:V(),pluginVersion:V().optional(),arguments:Et(Zg).optional()}),Cc=_e({name:V(),pipelineId:pe().optional(),nodes:Et(Qg)}),Jg=["created","waiting","scheduled","started","registeringFiles","finishedSuccessfully","finishedWithError","cancelled","unknown"],Ip=us(Jg).catch("unknown"),eb=_e({count:pe(),done:pe(),error:pe(),running:pe(),other:pe(),anomalies:Et(_e({id:V(),status:Ip})).optional()}),tb=_e({computeSeconds:pe().optional(),dataBytes:pe().optional()}),sb=Dp.extend({instanceId:pe(),pluginName:V(),pluginVersion:V().optional(),status:Ip,vfsPath:V(),metrics:tb.optional(),tally:eb.optional(),computeResource:V().optional()}),Pc=_e({feedId:pe(),feedName:V(),nodes:Et(sb)}),nb=_e({feedId:pe(),loaded:pe(),total:pe(),failed:V().optional()}),gi={pipelineDiagram:"pipeline.diagram",feedDag:"feed.dag",feedIndexing:"feed.indexing"},ib=_e({id:pe(),title:V(),owner:V(),status:V(),createdAt:V(),sizeBytes:pe().optional(),wallSeconds:pe().optional(),jobsDone:pe().optional(),jobsTotal:pe().optional(),jobsErrored:pe().optional()}),Tp=_e({feeds:Et(ib)}),Gp="feed.list",rb=_e({plugin:V(),count:pe(),errored:pe().default(0),status:V(),parent:pe().nullable()}),ab=_e({id:pe(),title:V().default(""),jobs:pe(),status:V(),chain:Et(V()),groups:Et(rb).default([])}),Rp=_e({feeds:Et(ab),whole:is()}),Bp="proc.universe",ob=_e({name:V(),type:V(),optional:is(),default:Vd().optional(),help:V().optional(),flag:V()}),lb=_e({id:pe().optional(),name:V(),version:V(),type:V(),title:V().optional(),description:V().optional(),authors:V().optional(),documentation:V().optional(),category:V().optional(),parameters:Et(ob),command:V().optional()}),cb="plugin.info",db=_e({seriesUID:V(),description:V(),modality:V(),fileCount:pe().optional(),vfsPath:V().optional(),pulled:is().optional(),pulledFiles:pe().optional(),folderPath:V().optional()}),ub=_e({studyUID:V().optional(),server:V().optional(),vfsPath:V().optional(),description:V(),patientName:V(),patientId:V(),date:V(),modalities:V(),accession:V(),series:Et(db)}),Np=_e({replayed:is(),answeredAt:V()}),hb=["found","none","unasked"],fb=us(hb).catch("unasked"),pb=_e({patientId:V(),server:V().optional(),patientName:V().optional(),status:fb,studyCount:pe(),seriesCount:pe(),queryId:pe().optional(),provenance:Np.optional(),error:V().optional()}),mb=_e({queryId:pe(),vfsPath:V(),pacsName:V(),expression:V(),studies:Et(ub),provenance:Np.optional(),patients:Et(pb).optional()}),Mb=_e({id:pe(),identifier:V(),active:is()}),gb=_e({servers:Et(Mb)}),bb="pacs.servers",zb="pacs.query";function _b(n){return`pacs:patient:${n.server??"-"}:${n.patientId}`}const wb=["patient","study","series","image","equipment","meta","private","other"],Cp=us(wb).catch("other"),Pp=KM(()=>_e({tag:V(),name:V(),vr:V(),value:V(),group:Cp,phi:is(),decoded:V().optional(),items:Et(Et(Pp)).optional()})),yb=_e({tag:V(),name:V(),vr:V(),group:Cp,phi:is(),distinct:pe(),first:V(),last:V(),values:Et(_e({path:V(),value:V().nullable()}))}),Nu=_e({path:V(),subject:us(["file","folder"]),read:pe(),of:pe(),refused:Et(V()),constant:Et(Pp),varying:Et(yb)}),vb=_e({rows:pe(),columns:pe(),pixelSpacing:YM([pe(),pe()]).optional(),sliceThickness:pe().optional(),spacingBetweenSlices:pe().optional()}),Cu=_e({path:V(),seriesInstanceUID:V().optional(),studyInstanceUID:V().optional(),modality:V(),seriesDescription:V(),seriesNumber:pe().optional(),instances:pe(),frames:pe(),order:us(["filename","unknown"]),geometry:vb.optional(),transferSyntax:_e({uid:V(),name:V().optional()}).optional(),bytes:pe(),header:V(),files:Et(V()),annotations:Et(V())}),Ga={tags:"dicom.tags",series:"dicom.series"},Ob=_e({path:V(),target:us(["series","volume"]),force:is().optional(),startAt:pe().int().positive().optional()}),xb={view:"image.view"},Sb=_e({state:us(["cold","warming","current"]),loaded:pe(),total:pe()});_e({user:V(),surface:V(),feeds:_e({total:pe(),own:pe(),shared:pe(),public:pe()}),jobs:_e({total:pe(),finished:pe(),errored:pe(),cancelled:pe(),running:pe(),scheduled:pe()}),failureRate:pe().nullable(),index:Sb,fortune:V()});const $d="185",Ab=0,Pu=1,Eb=2,So=1,Db=2,pa=3,yi=0,Us=1,Hn=2,Kn=0,ji=1,Ci=2,Wu=3,Lu=4,Ib=5,Pi=100,Tb=101,Gb=102,Rb=103,Bb=104,Nb=200,Cb=201,Pb=202,Wb=203,Wc=204,Lc=205,Lb=206,kb=207,Ub=208,Fb=209,jb=210,Vb=211,$b=212,Hb=213,qb=214,kc=0,Uc=1,Fc=2,Cr=3,jc=4,Vc=5,$c=6,Hc=7,Wp=0,Xb=1,Yb=2,En=0,Lp=1,kp=2,Up=3,Fp=4,jp=5,Vp=6,$p=7,Hp=300,Xi=301,Pr=302,Dl=303,Il=304,pl=306,qc=1e3,Xn=1001,Xc=1002,ws=1003,Kb=1004,Ra=1005,Es=1006,Tl=1007,Ui=1008,qs=1009,qp=1010,Xp=1011,xa=1012,Hd=1013,In=1014,Mn=1015,ei=1016,qd=1017,Xd=1018,Sa=1020,Yp=35902,Kp=35899,Zp=1021,Qp=1022,gn=1023,ti=1026,Fi=1027,Yd=1028,Kd=1029,Yi=1030,Zd=1031,Qd=1033,Ao=33776,Eo=33777,Do=33778,Io=33779,Yc=35840,Kc=35841,Zc=35842,Qc=35843,Jc=36196,ed=37492,td=37496,sd=37488,nd=37489,Yo=37490,id=37491,rd=37808,ad=37809,od=37810,ld=37811,cd=37812,dd=37813,ud=37814,hd=37815,fd=37816,pd=37817,md=37818,Md=37819,gd=37820,bd=37821,zd=36492,_d=36494,wd=36495,yd=36283,vd=36284,Ko=36285,Od=36286,Zb=3200,xd=0,Qb=1,mi="",en="srgb",Zo="srgb-linear",Qo="linear",Ut="srgb",ir=7680,ku=519,Jb=512,ez=513,tz=514,Jd=515,sz=516,nz=517,eu=518,iz=519,Sd=35044,Uu="300 es",Sn=2e3,Aa=2001;function rz(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Jo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function az(){const n=Jo("canvas");return n.style.display="block",n}const Fu={};function el(...n){const e="THREE."+n.shift();console.log(e,...n)}function Jp(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Qe(...n){n=Jp(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function Ot(...n){n=Jp(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Tr(...n){const e=n.join(" ");e in Fu||(Fu[e]=!0,Qe(...n))}function oz(n,e,t){return new Promise(function(s,i){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:s()}}setTimeout(r,t)})}const lz={[kc]:Uc,[Fc]:$c,[jc]:Hc,[Cr]:Vc,[Uc]:kc,[$c]:Fc,[Hc]:jc,[Vc]:Cr};class Zi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const i=s[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){e.target=this;const i=s.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const Os=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Gl=Math.PI/180,Ad=180/Math.PI;function zi(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Os[n&255]+Os[n>>8&255]+Os[n>>16&255]+Os[n>>24&255]+"-"+Os[e&255]+Os[e>>8&255]+"-"+Os[e>>16&15|64]+Os[e>>24&255]+"-"+Os[t&63|128]+Os[t>>8&255]+"-"+Os[t>>16&255]+Os[t>>24&255]+Os[s&255]+Os[s>>8&255]+Os[s>>16&255]+Os[s>>24&255]).toLowerCase()}function St(n,e,t){return Math.max(e,Math.min(t,n))}function cz(n,e){return(n%e+e)%e}function Rl(n,e,t){return(1-t)*n+t*e}function On(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Ft(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const zu=class zu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(St(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*s-a*i+e.x,this.y=r*i+a*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};zu.prototype.isVector2=!0;let Je=zu;class Qi{constructor(e=0,t=0,s=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=s,this._w=i}static slerpFlat(e,t,s,i,r,a,o){let l=s[i+0],c=s[i+1],d=s[i+2],h=s[i+3],u=r[a+0],p=r[a+1],M=r[a+2],_=r[a+3];if(h!==_||l!==u||c!==p||d!==M){let m=l*u+c*p+d*M+h*_;m<0&&(u=-u,p=-p,M=-M,_=-_,m=-m);let f=1-o;if(m<.9995){const S=Math.acos(m),v=Math.sin(S);f=Math.sin(f*S)/v,o=Math.sin(o*S)/v,l=l*f+u*o,c=c*f+p*o,d=d*f+M*o,h=h*f+_*o}else{l=l*f+u*o,c=c*f+p*o,d=d*f+M*o,h=h*f+_*o;const S=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=S,c*=S,d*=S,h*=S}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,s,i,r,a){const o=s[i],l=s[i+1],c=s[i+2],d=s[i+3],h=r[a],u=r[a+1],p=r[a+2],M=r[a+3];return e[t]=o*M+d*h+l*p-c*u,e[t+1]=l*M+d*u+c*h-o*p,e[t+2]=c*M+d*p+o*u-l*h,e[t+3]=d*M-o*h-l*u-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(s/2),d=o(i/2),h=o(r/2),u=l(s/2),p=l(i/2),M=l(r/2);switch(a){case"XYZ":this._x=u*d*h+c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h-u*p*M;break;case"YXZ":this._x=u*d*h+c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h+u*p*M;break;case"ZXY":this._x=u*d*h-c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h-u*p*M;break;case"ZYX":this._x=u*d*h-c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h+u*p*M;break;case"YZX":this._x=u*d*h+c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h-u*p*M;break;case"XZY":this._x=u*d*h-c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h+u*p*M;break;default:Qe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,i=Math.sin(s);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],u=s+o+h;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(d-l)*p,this._y=(r-c)*p,this._z=(a-i)*p}else if(s>o&&s>h){const p=2*Math.sqrt(1+s-o-h);this._w=(d-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(r+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-s-h);this._w=(r-c)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+d)/p}else{const p=2*Math.sqrt(1+h-s-o);this._w=(a-i)/p,this._x=(r+c)/p,this._y=(l+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<1e-8?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(St(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const i=Math.min(1,t/s);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=s*d+a*o+i*c-r*l,this._y=i*d+a*l+r*o-s*c,this._z=r*d+a*c+s*l-i*o,this._w=a*d-s*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){let s=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(s=-s,i=-i,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,t=Math.sin(t*c)/d,this._x=this._x*l+s*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+s*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const _u=class _u{constructor(e=0,t=0,s=0){this.x=e,this.y=t,this.z=s}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ju.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ju.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*s+r[6]*i,this.y=r[1]*t+r[4]*s+r[7]*i,this.z=r[2]*t+r[5]*s+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*s+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*s+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*s+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,s=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*s),d=2*(o*t-r*i),h=2*(r*s-a*t);return this.x=t+l*c+a*h-o*d,this.y=s+l*d+o*c-r*h,this.z=i+l*h+r*d-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*s+r[8]*i,this.y=r[1]*t+r[5]*s+r[9]*i,this.z=r[2]*t+r[6]*s+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-s*l,this.z=s*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Bl.copy(this).projectOnVector(e),this.sub(Bl)}reflect(e){return this.sub(Bl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(St(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return t*t+s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){const i=Math.sin(t)*e;return this.x=i*Math.sin(s),this.y=Math.cos(t)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};_u.prototype.isVector3=!0;let P=_u;const Bl=new P,ju=new Qi,wu=class wu{constructor(e,t,s,i,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,i,r,a,o,l,c)}set(e,t,s,i,r,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=r,d[5]=l,d[6]=s,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,a=s[0],o=s[3],l=s[6],c=s[1],d=s[4],h=s[7],u=s[2],p=s[5],M=s[8],_=i[0],m=i[3],f=i[6],S=i[1],v=i[4],z=i[7],O=i[2],x=i[5],G=i[8];return r[0]=a*_+o*S+l*O,r[3]=a*m+o*v+l*x,r[6]=a*f+o*z+l*G,r[1]=c*_+d*S+h*O,r[4]=c*m+d*v+h*x,r[7]=c*f+d*z+h*G,r[2]=u*_+p*S+M*O,r[5]=u*m+p*v+M*x,r[8]=u*f+p*z+M*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-s*r*d+s*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,u=o*l-d*r,p=c*r-a*l,M=t*h+s*u+i*p;if(M===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/M;return e[0]=h*_,e[1]=(i*c-d*s)*_,e[2]=(o*s-i*a)*_,e[3]=u*_,e[4]=(d*t-i*l)*_,e[5]=(i*r-o*t)*_,e[6]=p*_,e[7]=(s*l-c*t)*_,e[8]=(a*t-s*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(s*l,s*c,-s*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Tr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Nl.makeScale(e,t)),this}rotate(e){return Tr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Nl.makeRotation(-e)),this}translate(e,t){return Tr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Nl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<9;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};wu.prototype.isMatrix3=!0;let lt=wu;const Nl=new lt,Vu=new lt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$u=new lt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function dz(){const n={enabled:!0,workingColorSpace:Zo,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ut&&(i.r=Zn(i.r),i.g=Zn(i.g),i.b=Zn(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ut&&(i.r=Gr(i.r),i.g=Gr(i.g),i.b=Gr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===mi?Qo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Tr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Tr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],s=[.3127,.329];return n.define({[Zo]:{primaries:e,whitePoint:s,transfer:Qo,toXYZ:Vu,fromXYZ:$u,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:en},outputColorSpaceConfig:{drawingBufferColorSpace:en}},[en]:{primaries:e,whitePoint:s,transfer:Ut,toXYZ:Vu,fromXYZ:$u,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:en}}}),n}const xt=dz();function Zn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gr(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let rr;class uz{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{rr===void 0&&(rr=Jo("canvas")),rr.width=e.width,rr.height=e.height;const i=rr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),s=rr}return s.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Jo("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const i=s.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Zn(r[a]/255)*255;return s.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let s=0;s<t.length;s++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[s]=Math.floor(Zn(t[s]/255)*255):t[s]=Zn(t[s]);return{data:t,width:e.width,height:e.height}}else return Qe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hz=0;class tu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hz++}),this.uuid=zi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Cl(i[a].image)):r.push(Cl(i[a]))}else r=Cl(i);s.url=r}return t||(e.images[this.uuid]=s),s}}function Cl(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?uz.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Qe("Texture: Unable to serialize Texture."),{})}let fz=0;const Pl=new P;class Is extends Zi{constructor(e=Is.DEFAULT_IMAGE,t=Is.DEFAULT_MAPPING,s=Xn,i=Xn,r=Es,a=Ui,o=gn,l=qs,c=Is.DEFAULT_ANISOTROPY,d=mi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fz++}),this.uuid=zi(),this.name="",this.source=new tu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Je(0,0),this.repeat=new Je(1,1),this.center=new Je(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Pl).x}get height(){return this.source.getSize(Pl).y}get depth(){return this.source.getSize(Pl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const s=e[t];if(s===void 0){Qe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Qe(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[t]=s}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Hp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qc:e.x=e.x-Math.floor(e.x);break;case Xn:e.x=e.x<0?0:1;break;case Xc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qc:e.y=e.y-Math.floor(e.y);break;case Xn:e.y=e.y<0?0:1;break;case Xc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Is.DEFAULT_IMAGE=null;Is.DEFAULT_MAPPING=Hp;Is.DEFAULT_ANISOTROPY=1;const yu=class yu{constructor(e=0,t=0,s=0,i=1){this.x=e,this.y=t,this.z=s,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*s+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*s+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*s+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*s+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,i,r;const l=e.elements,c=l[0],d=l[4],h=l[8],u=l[1],p=l[5],M=l[9],_=l[2],m=l[6],f=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-_)<.01&&Math.abs(M-m)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+_)<.1&&Math.abs(M+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,z=(p+1)/2,O=(f+1)/2,x=(d+u)/4,G=(h+_)/4,b=(M+m)/4;return v>z&&v>O?v<.01?(s=0,i=.707106781,r=.707106781):(s=Math.sqrt(v),i=x/s,r=G/s):z>O?z<.01?(s=.707106781,i=0,r=.707106781):(i=Math.sqrt(z),s=x/i,r=b/i):O<.01?(s=.707106781,i=.707106781,r=0):(r=Math.sqrt(O),s=G/r,i=b/r),this.set(s,i,r,t),this}let S=Math.sqrt((m-M)*(m-M)+(h-_)*(h-_)+(u-d)*(u-d));return Math.abs(S)<.001&&(S=1),this.x=(m-M)/S,this.y=(h-_)/S,this.z=(u-d)/S,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this.w=St(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this.w=St(this.w,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this.w=e.w+(t.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};yu.prototype.isVector4=!0;let Jt=yu;class pz extends Zi{constructor(e=1,t=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Es,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},s),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=s.depth,this.scissor=new Jt(0,0,e,t),this.scissorTest=!1,this.viewport=new Jt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:s.depth},r=new Is(i),a=s.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview,this.useArrayDepthTexture=s.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Es,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,s=1){if(this.width!==e||this.height!==t||this.depth!==s){this.width=e,this.height=t,this.depth=s;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=s,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,s=e.textures.length;t<s;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new tu(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Dn extends pz{constructor(e=1,t=1,s={}){super(e,t,s),this.isWebGLRenderTarget=!0}}class em extends Is{constructor(e=null,t=1,s=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:s,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=Xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mz extends Is{constructor(e=null,t=1,s=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:s,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=Xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const fl=class fl{constructor(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m)}set(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=s,f[12]=i,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=d,f[10]=h,f[14]=u,f[3]=p,f[7]=M,f[11]=_,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new fl().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,s=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),a=1/ar.setFromMatrixColumn(e,2).length();return t[0]=s[0]*i,t[1]=s[1]*i,t[2]=s[2]*i,t[3]=0,t[4]=s[4]*r,t[5]=s[5]*r,t[6]=s[6]*r,t[7]=0,t[8]=s[8]*a,t[9]=s[9]*a,t[10]=s[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,s=e.x,i=e.y,r=e.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),c=Math.sin(i),d=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const u=a*d,p=a*h,M=o*d,_=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=p+M*c,t[5]=u-_*c,t[9]=-o*l,t[2]=_-u*c,t[6]=M+p*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*d,p=l*h,M=c*d,_=c*h;t[0]=u+_*o,t[4]=M*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=p*o-M,t[6]=_+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,p=l*h,M=c*d,_=c*h;t[0]=u-_*o,t[4]=-a*h,t[8]=M+p*o,t[1]=p+M*o,t[5]=a*d,t[9]=_-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*d,p=a*h,M=o*d,_=o*h;t[0]=l*d,t[4]=M*c-p,t[8]=u*c+_,t[1]=l*h,t[5]=_*c+u,t[9]=p*c-M,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*c,M=o*l,_=o*c;t[0]=l*d,t[4]=_-u*h,t[8]=M*h+p,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=p*h+M,t[10]=u-_*h}else if(e.order==="XZY"){const u=a*l,p=a*c,M=o*l,_=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+_,t[5]=a*d,t[9]=p*h-M,t[2]=M*h-p,t[6]=o*d,t[10]=_*h+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Mz,e,gz)}lookAt(e,t,s){const i=this.elements;return js.subVectors(e,t),js.lengthSq()===0&&(js.z=1),js.normalize(),ai.crossVectors(s,js),ai.lengthSq()===0&&(Math.abs(s.z)===1?js.x+=1e-4:js.z+=1e-4,js.normalize(),ai.crossVectors(s,js)),ai.normalize(),Ba.crossVectors(js,ai),i[0]=ai.x,i[4]=Ba.x,i[8]=js.x,i[1]=ai.y,i[5]=Ba.y,i[9]=js.y,i[2]=ai.z,i[6]=Ba.z,i[10]=js.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,a=s[0],o=s[4],l=s[8],c=s[12],d=s[1],h=s[5],u=s[9],p=s[13],M=s[2],_=s[6],m=s[10],f=s[14],S=s[3],v=s[7],z=s[11],O=s[15],x=i[0],G=i[4],b=i[8],T=i[12],N=i[1],C=i[5],W=i[9],Q=i[13],se=i[2],H=i[6],ee=i[10],J=i[14],ue=i[3],he=i[7],Se=i[11],be=i[15];return r[0]=a*x+o*N+l*se+c*ue,r[4]=a*G+o*C+l*H+c*he,r[8]=a*b+o*W+l*ee+c*Se,r[12]=a*T+o*Q+l*J+c*be,r[1]=d*x+h*N+u*se+p*ue,r[5]=d*G+h*C+u*H+p*he,r[9]=d*b+h*W+u*ee+p*Se,r[13]=d*T+h*Q+u*J+p*be,r[2]=M*x+_*N+m*se+f*ue,r[6]=M*G+_*C+m*H+f*he,r[10]=M*b+_*W+m*ee+f*Se,r[14]=M*T+_*Q+m*J+f*be,r[3]=S*x+v*N+z*se+O*ue,r[7]=S*G+v*C+z*H+O*he,r[11]=S*b+v*W+z*ee+O*Se,r[15]=S*T+v*Q+z*J+O*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],u=e[10],p=e[14],M=e[3],_=e[7],m=e[11],f=e[15],S=l*p-c*u,v=o*p-c*h,z=o*u-l*h,O=a*p-c*d,x=a*u-l*d,G=a*h-o*d;return t*(_*S-m*v+f*z)-s*(M*S-m*O+f*x)+i*(M*v-_*O+f*G)-r*(M*z-_*x+m*G)}determinantAffine(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],d=e[10];return t*(a*d-o*c)-s*(r*d-o*l)+i*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],u=e[10],p=e[11],M=e[12],_=e[13],m=e[14],f=e[15],S=t*o-s*a,v=t*l-i*a,z=t*c-r*a,O=s*l-i*o,x=s*c-r*o,G=i*c-r*l,b=d*_-h*M,T=d*m-u*M,N=d*f-p*M,C=h*m-u*_,W=h*f-p*_,Q=u*f-p*m,se=S*Q-v*W+z*C+O*N-x*T+G*b;if(se===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/se;return e[0]=(o*Q-l*W+c*C)*H,e[1]=(i*W-s*Q-r*C)*H,e[2]=(_*G-m*x+f*O)*H,e[3]=(u*x-h*G-p*O)*H,e[4]=(l*N-a*Q-c*T)*H,e[5]=(t*Q-i*N+r*T)*H,e[6]=(m*z-M*G-f*v)*H,e[7]=(d*G-u*z+p*v)*H,e[8]=(a*W-o*N+c*b)*H,e[9]=(s*N-t*W-r*b)*H,e[10]=(M*x-_*z+f*S)*H,e[11]=(h*z-d*x-p*S)*H,e[12]=(o*T-a*C-l*b)*H,e[13]=(t*C-s*T+i*b)*H,e[14]=(_*v-M*O-m*S)*H,e[15]=(d*O-h*v+u*S)*H,this}scale(e){const t=this.elements,s=e.x,i=e.y,r=e.z;return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,i))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),i=Math.sin(t),r=1-s,a=e.x,o=e.y,l=e.z,c=r*a,d=r*o;return this.set(c*a+s,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+s,d*l-i*a,0,c*l-i*o,d*l+i*a,r*l*l+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,i,r,a){return this.set(1,s,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,s){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,d=a+a,h=o+o,u=r*c,p=r*d,M=r*h,_=a*d,m=a*h,f=o*h,S=l*c,v=l*d,z=l*h,O=s.x,x=s.y,G=s.z;return i[0]=(1-(_+f))*O,i[1]=(p+z)*O,i[2]=(M-v)*O,i[3]=0,i[4]=(p-z)*x,i[5]=(1-(u+f))*x,i[6]=(m+S)*x,i[7]=0,i[8]=(M+v)*G,i[9]=(m-S)*G,i[10]=(1-(u+_))*G,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,s){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return s.set(1,1,1),t.identity(),this;let a=ar.set(i[0],i[1],i[2]).length();const o=ar.set(i[4],i[5],i[6]).length(),l=ar.set(i[8],i[9],i[10]).length();r<0&&(a=-a),dn.copy(this);const c=1/a,d=1/o,h=1/l;return dn.elements[0]*=c,dn.elements[1]*=c,dn.elements[2]*=c,dn.elements[4]*=d,dn.elements[5]*=d,dn.elements[6]*=d,dn.elements[8]*=h,dn.elements[9]*=h,dn.elements[10]*=h,t.setFromRotationMatrix(dn),s.x=a,s.y=o,s.z=l,this}makePerspective(e,t,s,i,r,a,o=Sn,l=!1){const c=this.elements,d=2*r/(t-e),h=2*r/(s-i),u=(t+e)/(t-e),p=(s+i)/(s-i);let M,_;if(l)M=r/(a-r),_=a*r/(a-r);else if(o===Sn)M=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===Aa)M=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=M,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,s,i,r,a,o=Sn,l=!1){const c=this.elements,d=2/(t-e),h=2/(s-i),u=-(t+e)/(t-e),p=-(s+i)/(s-i);let M,_;if(l)M=1/(a-r),_=a/(a-r);else if(o===Sn)M=-2/(a-r),_=-(a+r)/(a-r);else if(o===Aa)M=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=h,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=M,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<16;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}};fl.prototype.isMatrix4=!0;let Rt=fl;const ar=new P,dn=new Rt,Mz=new P(0,0,0),gz=new P(1,1,1),ai=new P,Ba=new P,js=new P,Hu=new Rt,qu=new Qi;class vi{constructor(e=0,t=0,s=0,i=vi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,i=this._order){return this._x=e,this._y=t,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],u=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-St(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(St(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-St(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(St(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-d,p),this._y=0);break;default:Qe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return Hu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Hu,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qu.setFromEuler(this),this.setFromQuaternion(qu,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}vi.DEFAULT_ORDER="XYZ";class su{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let bz=0;const Xu=new P,or=new Qi,Bn=new Rt,Na=new P,Kr=new P,zz=new P,_z=new Qi,Yu=new P(1,0,0),Ku=new P(0,1,0),Zu=new P(0,0,1),Qu={type:"added"},wz={type:"removed"},lr={type:"childadded",child:null},Wl={type:"childremoved",child:null};class es extends Zi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:bz++}),this.uuid=zi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=es.DEFAULT_UP.clone();const e=new P,t=new vi,s=new Qi,i=new P(1,1,1);function r(){s.setFromEuler(t,!1)}function a(){t.setFromQuaternion(s,void 0,!1)}t._onChange(r),s._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Rt},normalMatrix:{value:new lt}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=es.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new su,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(Yu,e)}rotateY(e){return this.rotateOnAxis(Ku,e)}rotateZ(e){return this.rotateOnAxis(Zu,e)}translateOnAxis(e,t){return Xu.copy(e).applyQuaternion(this.quaternion),this.position.add(Xu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yu,e)}translateY(e){return this.translateOnAxis(Ku,e)}translateZ(e){return this.translateOnAxis(Zu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Bn.copy(this.matrixWorld).invert())}lookAt(e,t,s){e.isVector3?Na.copy(e):Na.set(e,t,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Kr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Bn.lookAt(Kr,Na,this.up):Bn.lookAt(Na,Kr,this.up),this.quaternion.setFromRotationMatrix(Bn),i&&(Bn.extractRotation(i.matrixWorld),or.setFromRotationMatrix(Bn),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ot("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Qu),lr.child=e,this.dispatchEvent(lr),lr.child=null):Ot("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(wz),Wl.child=e,this.dispatchEvent(Wl),Wl.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Bn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Bn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Bn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Qu),lr.child=e,this.dispatchEvent(lr),lr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let s=0,i=this.children.length;s<i;s++){const a=this.children[s].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,s=[]){this[e]===t&&s.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,e,zz),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,_z,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,s=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*s-r[8]*i,r[13]+=s-r[1]*t-r[5]*s-r[9]*i,r[14]+=i-r[2]*t-r[6]*s-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].updateMatrixWorld(e)}updateWorldMatrix(e,t,s=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,s)}}toJSON(e){const t=e===void 0||typeof e=="string",s={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),u=a(e.skeletons),p=a(e.animations),M=a(e.nodes);o.length>0&&(s.geometries=o),l.length>0&&(s.materials=l),c.length>0&&(s.textures=c),d.length>0&&(s.images=d),h.length>0&&(s.shapes=h),u.length>0&&(s.skeletons=u),p.length>0&&(s.animations=p),M.length>0&&(s.nodes=M)}return s.object=i,s;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let s=0;s<e.children.length;s++){const i=e.children[s];this.add(i.clone())}return this}}es.DEFAULT_UP=new P(0,1,0);es.DEFAULT_MATRIX_AUTO_UPDATE=!0;es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ma extends es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const yz={type:"move"};class Ll{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ma,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ma,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ma,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const s of e.hand.values())this._getHandJoint(t,s)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,s){let i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,s),f=this._getHandJoint(c,_);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],u=d.position.distanceTo(h.position),p=.02,M=.005;c.inputState.pinching&&u>p+M?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-M&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,s),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(yz)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const s=new ma;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[t.jointName]=s,e.add(s)}return e.joints[t.jointName]}}const tm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},oi={h:0,s:0,l:0},Ca={h:0,s:0,l:0};function kl(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Ze{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=en){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xt.colorSpaceToWorking(this,t),this}setRGB(e,t,s,i=xt.workingColorSpace){return this.r=e,this.g=t,this.b=s,xt.colorSpaceToWorking(this,i),this}setHSL(e,t,s,i=xt.workingColorSpace){if(e=cz(e,1),t=St(t,0,1),s=St(s,0,1),t===0)this.r=this.g=this.b=s;else{const r=s<=.5?s*(1+t):s+t-s*t,a=2*s-r;this.r=kl(a,r,e+1/3),this.g=kl(a,r,e),this.b=kl(a,r,e-1/3)}return xt.colorSpaceToWorking(this,i),this}setStyle(e,t=en){function s(r){r!==void 0&&parseFloat(r)<1&&Qe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Qe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Qe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=en){const s=tm[e.toLowerCase()];return s!==void 0?this.setHex(s,t):Qe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=en){return xt.workingToColorSpace(xs.copy(this),e),Math.round(St(xs.r*255,0,255))*65536+Math.round(St(xs.g*255,0,255))*256+Math.round(St(xs.b*255,0,255))}getHexString(e=en){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xt.workingColorSpace){xt.workingToColorSpace(xs.copy(this),t);const s=xs.r,i=xs.g,r=xs.b,a=Math.max(s,i,r),o=Math.min(s,i,r);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case s:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-s)/h+2;break;case r:l=(s-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=xt.workingColorSpace){return xt.workingToColorSpace(xs.copy(this),t),e.r=xs.r,e.g=xs.g,e.b=xs.b,e}getStyle(e=en){xt.workingToColorSpace(xs.copy(this),e);const t=xs.r,s=xs.g,i=xs.b;return e!==en?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(e,t,s){return this.getHSL(oi),this.setHSL(oi.h+e,oi.s+t,oi.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(oi),e.getHSL(Ca);const s=Rl(oi.h,Ca.h,t),i=Rl(oi.s,Ca.s,t),r=Rl(oi.l,Ca.l,t);return this.setHSL(s,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,s=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*s+r[6]*i,this.g=r[1]*t+r[4]*s+r[7]*i,this.b=r[2]*t+r[5]*s+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xs=new Ze;Ze.NAMES=tm;class vz extends es{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new vi,this.environmentIntensity=1,this.environmentRotation=new vi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const un=new P,Nn=new P,Ul=new P,Cn=new P,cr=new P,dr=new P,Ju=new P,Fl=new P,jl=new P,Vl=new P,$l=new Jt,Hl=new Jt,ql=new Jt;class nn{constructor(e=new P,t=new P,s=new P){this.a=e,this.b=t,this.c=s}static getNormal(e,t,s,i){i.subVectors(s,t),un.subVectors(e,t),i.cross(un);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,s,i,r){un.subVectors(i,t),Nn.subVectors(s,t),Ul.subVectors(e,t);const a=un.dot(un),o=un.dot(Nn),l=un.dot(Ul),c=Nn.dot(Nn),d=Nn.dot(Ul),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const u=1/h,p=(c*l-o*d)*u,M=(a*d-o*l)*u;return r.set(1-p-M,M,p)}static containsPoint(e,t,s,i){return this.getBarycoord(e,t,s,i,Cn)===null?!1:Cn.x>=0&&Cn.y>=0&&Cn.x+Cn.y<=1}static getInterpolation(e,t,s,i,r,a,o,l){return this.getBarycoord(e,t,s,i,Cn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Cn.x),l.addScaledVector(a,Cn.y),l.addScaledVector(o,Cn.z),l)}static getInterpolatedAttribute(e,t,s,i,r,a){return $l.setScalar(0),Hl.setScalar(0),ql.setScalar(0),$l.fromBufferAttribute(e,t),Hl.fromBufferAttribute(e,s),ql.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector($l,r.x),a.addScaledVector(Hl,r.y),a.addScaledVector(ql,r.z),a}static isFrontFacing(e,t,s,i){return un.subVectors(s,t),Nn.subVectors(e,t),un.cross(Nn).dot(i)<0}set(e,t,s){return this.a.copy(e),this.b.copy(t),this.c.copy(s),this}setFromPointsAndIndices(e,t,s,i){return this.a.copy(e[t]),this.b.copy(e[s]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,s,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return un.subVectors(this.c,this.b),Nn.subVectors(this.a,this.b),un.cross(Nn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,s,i,r){return nn.getInterpolation(e,this.a,this.b,this.c,t,s,i,r)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const s=this.a,i=this.b,r=this.c;let a,o;cr.subVectors(i,s),dr.subVectors(r,s),Fl.subVectors(e,s);const l=cr.dot(Fl),c=dr.dot(Fl);if(l<=0&&c<=0)return t.copy(s);jl.subVectors(e,i);const d=cr.dot(jl),h=dr.dot(jl);if(d>=0&&h<=d)return t.copy(i);const u=l*h-d*c;if(u<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(s).addScaledVector(cr,a);Vl.subVectors(e,r);const p=cr.dot(Vl),M=dr.dot(Vl);if(M>=0&&p<=M)return t.copy(r);const _=p*c-l*M;if(_<=0&&c>=0&&M<=0)return o=c/(c-M),t.copy(s).addScaledVector(dr,o);const m=d*M-p*h;if(m<=0&&h-d>=0&&p-M>=0)return Ju.subVectors(r,i),o=(h-d)/(h-d+(p-M)),t.copy(i).addScaledVector(Ju,o);const f=1/(m+_+u);return a=_*f,o=u*f,t.copy(s).addScaledVector(cr,a).addScaledVector(dr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ji{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(hn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,s=e.count;t<s;t++)this.expandByPoint(hn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=hn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const s=e.geometry;if(s!==void 0){const r=s.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,hn):hn.fromBufferAttribute(r,a),hn.applyMatrix4(e.matrixWorld),this.expandByPoint(hn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Pa.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Pa.copy(s.boundingBox)),Pa.applyMatrix4(e.matrixWorld),this.union(Pa)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,hn),hn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Zr),Wa.subVectors(this.max,Zr),ur.subVectors(e.a,Zr),hr.subVectors(e.b,Zr),fr.subVectors(e.c,Zr),li.subVectors(hr,ur),ci.subVectors(fr,hr),Ai.subVectors(ur,fr);let t=[0,-li.z,li.y,0,-ci.z,ci.y,0,-Ai.z,Ai.y,li.z,0,-li.x,ci.z,0,-ci.x,Ai.z,0,-Ai.x,-li.y,li.x,0,-ci.y,ci.x,0,-Ai.y,Ai.x,0];return!Xl(t,ur,hr,fr,Wa)||(t=[1,0,0,0,1,0,0,0,1],!Xl(t,ur,hr,fr,Wa))?!1:(La.crossVectors(li,ci),t=[La.x,La.y,La.z],Xl(t,ur,hr,fr,Wa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Pn=[new P,new P,new P,new P,new P,new P,new P,new P],hn=new P,Pa=new Ji,ur=new P,hr=new P,fr=new P,li=new P,ci=new P,Ai=new P,Zr=new P,Wa=new P,La=new P,Ei=new P;function Xl(n,e,t,s,i){for(let r=0,a=n.length-3;r<=a;r+=3){Ei.fromArray(n,r);const o=i.x*Math.abs(Ei.x)+i.y*Math.abs(Ei.y)+i.z*Math.abs(Ei.z),l=e.dot(Ei),c=t.dot(Ei),d=s.dot(Ei);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const rs=new P,ka=new Je;let Oz=0;class Ds extends Zi{constructor(e,t,s=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Oz++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=s,this.usage=Sd,this.updateRanges=[],this.gpuType=Mn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[s+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,s=this.count;t<s;t++)ka.fromBufferAttribute(this,t),ka.applyMatrix3(e),this.setXY(t,ka.x,ka.y);else if(this.itemSize===3)for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyMatrix3(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}applyMatrix4(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyMatrix4(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyNormalMatrix(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.transformDirection(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let s=this.array[e*this.itemSize+t];return this.normalized&&(s=On(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=Ft(s,this.array)),this.array[e*this.itemSize+t]=s,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=On(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=On(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=On(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=On(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array)),this.array[e+0]=t,this.array[e+1]=s,this}setXYZ(e,t,s,i){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this}setXYZW(e,t,s,i,r){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array),r=Ft(r,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Sd&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class sm extends Ds{constructor(e,t,s){super(new Uint16Array(e),t,s)}}class nm extends Ds{constructor(e,t,s){super(new Uint32Array(e),t,s)}}class Ht extends Ds{constructor(e,t,s){super(new Float32Array(e),t,s)}}const xz=new Ji,Qr=new P,Yl=new P;class er{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const s=this.center;t!==void 0?s.copy(t):xz.setFromPoints(e).getCenter(s);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,s.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const s=this.center.distanceToSquared(e);return t.copy(e),s>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Qr.subVectors(e,this.center);const t=Qr.lengthSq();if(t>this.radius*this.radius){const s=Math.sqrt(t),i=(s-this.radius)*.5;this.center.addScaledVector(Qr,i/s),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Yl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qr.copy(e.center).add(Yl)),this.expandByPoint(Qr.copy(e.center).sub(Yl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Sz=0;const Zs=new Rt,Kl=new es,pr=new P,Vs=new Ji,Jr=new Ji,gs=new P;class os extends Zi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sz++}),this.uuid=zi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rz(e)?nm:sm)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,s=0){this.groups.push({start:e,count:t,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const r=new lt().getNormalMatrix(e);s.applyNormalMatrix(r),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Zs.makeRotationFromQuaternion(e),this.applyMatrix4(Zs),this}rotateX(e){return Zs.makeRotationX(e),this.applyMatrix4(Zs),this}rotateY(e){return Zs.makeRotationY(e),this.applyMatrix4(Zs),this}rotateZ(e){return Zs.makeRotationZ(e),this.applyMatrix4(Zs),this}translate(e,t,s){return Zs.makeTranslation(e,t,s),this.applyMatrix4(Zs),this}scale(e,t,s){return Zs.makeScale(e,t,s),this.applyMatrix4(Zs),this}lookAt(e){return Kl.lookAt(e),Kl.updateMatrix(),this.applyMatrix4(Kl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pr).negate(),this.translate(pr.x,pr.y,pr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const s=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];s.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ht(s,3))}else{const s=Math.min(e.length,t.count);for(let i=0;i<s;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&Qe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ot("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let s=0,i=t.length;s<i;s++){const r=t[s];Vs.setFromBufferAttribute(r),this.morphTargetsRelative?(gs.addVectors(this.boundingBox.min,Vs.min),this.boundingBox.expandByPoint(gs),gs.addVectors(this.boundingBox.max,Vs.max),this.boundingBox.expandByPoint(gs)):(this.boundingBox.expandByPoint(Vs.min),this.boundingBox.expandByPoint(Vs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ot('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new er);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ot("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const s=this.boundingSphere.center;if(Vs.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Jr.setFromBufferAttribute(o),this.morphTargetsRelative?(gs.addVectors(Vs.min,Jr.min),Vs.expandByPoint(gs),gs.addVectors(Vs.max,Jr.max),Vs.expandByPoint(gs)):(Vs.expandByPoint(Jr.min),Vs.expandByPoint(Jr.max))}Vs.getCenter(s);let i=0;for(let r=0,a=e.count;r<a;r++)gs.fromBufferAttribute(e,r),i=Math.max(i,s.distanceToSquared(gs));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)gs.fromBufferAttribute(o,c),l&&(pr.fromBufferAttribute(e,c),gs.add(pr)),i=Math.max(i,s.distanceToSquared(gs))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ot('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ot("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==s.count)&&(a=new Ds(new Float32Array(4*s.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let b=0;b<s.count;b++)o[b]=new P,l[b]=new P;const c=new P,d=new P,h=new P,u=new Je,p=new Je,M=new Je,_=new P,m=new P;function f(b,T,N){c.fromBufferAttribute(s,b),d.fromBufferAttribute(s,T),h.fromBufferAttribute(s,N),u.fromBufferAttribute(r,b),p.fromBufferAttribute(r,T),M.fromBufferAttribute(r,N),d.sub(c),h.sub(c),p.sub(u),M.sub(u);const C=1/(p.x*M.y-M.x*p.y);isFinite(C)&&(_.copy(d).multiplyScalar(M.y).addScaledVector(h,-p.y).multiplyScalar(C),m.copy(h).multiplyScalar(p.x).addScaledVector(d,-M.x).multiplyScalar(C),o[b].add(_),o[T].add(_),o[N].add(_),l[b].add(m),l[T].add(m),l[N].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let b=0,T=S.length;b<T;++b){const N=S[b],C=N.start,W=N.count;for(let Q=C,se=C+W;Q<se;Q+=3)f(e.getX(Q+0),e.getX(Q+1),e.getX(Q+2))}const v=new P,z=new P,O=new P,x=new P;function G(b){O.fromBufferAttribute(i,b),x.copy(O);const T=o[b];v.copy(T),v.sub(O.multiplyScalar(O.dot(T))).normalize(),z.crossVectors(x,T);const C=z.dot(l[b])<0?-1:1;a.setXYZW(b,v.x,v.y,v.z,C)}for(let b=0,T=S.length;b<T;++b){const N=S[b],C=N.start,W=N.count;for(let Q=C,se=C+W;Q<se;Q+=3)G(e.getX(Q+0)),G(e.getX(Q+1)),G(e.getX(Q+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==t.count)s=new Ds(new Float32Array(t.count*3),3),this.setAttribute("normal",s);else for(let u=0,p=s.count;u<p;u++)s.setXYZ(u,0,0,0);const i=new P,r=new P,a=new P,o=new P,l=new P,c=new P,d=new P,h=new P;if(e)for(let u=0,p=e.count;u<p;u+=3){const M=e.getX(u+0),_=e.getX(u+1),m=e.getX(u+2);i.fromBufferAttribute(t,M),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),d.subVectors(a,r),h.subVectors(i,r),d.cross(h),o.fromBufferAttribute(s,M),l.fromBufferAttribute(s,_),c.fromBufferAttribute(s,m),o.add(d),l.add(d),c.add(d),s.setXYZ(M,o.x,o.y,o.z),s.setXYZ(_,l.x,l.y,l.z),s.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,p=t.count;u<p;u+=3)i.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),d.subVectors(a,r),h.subVectors(i,r),d.cross(h),s.setXYZ(u+0,d.x,d.y,d.z),s.setXYZ(u+1,d.x,d.y,d.z),s.setXYZ(u+2,d.x,d.y,d.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,s=e.count;t<s;t++)gs.fromBufferAttribute(e,t),gs.normalize(),e.setXYZ(t,gs.x,gs.y,gs.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,u=new c.constructor(l.length*d);let p=0,M=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?p=l[_]*o.data.stride+o.offset:p=l[_]*d;for(let f=0;f<d;f++)u[M++]=c[p++]}return new Ds(u,d,h)}if(this.index===null)return Qe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new os,s=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,s);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let d=0,h=c.length;d<h;d++){const u=c[d],p=e(u,s);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const s=this.attributes;for(const l in s){const c=s[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,u=c.length;h<u;h++){const p=c[h];d.push(p.toJSON(e.data))}d.length>0&&(i[l]=d,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const s=e.index;s!==null&&this.setIndex(s.clone());const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const r=e.morphAttributes;for(const c in r){const d=[],h=r[c];for(let u=0,p=h.length;u<p;u++)d.push(h[u].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Az{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sd,this.updateRanges=[],this.version=0,this.uuid=zi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[s+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(t,this.stride);return s.setUsage(this.usage),s}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Rs=new P;class tl{constructor(e,t,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,s=this.data.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.applyMatrix4(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.applyNormalMatrix(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.transformDirection(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}getComponent(e,t){let s=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(s=On(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=Ft(s,this.array)),this.data.array[e*this.data.stride+this.offset+t]=s,this}setX(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=On(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=On(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=On(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=On(t,this.array)),t}setXY(e,t,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this}setXYZ(e,t,s,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=i,this}setXYZW(e,t,s,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array),r=Ft(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){el("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Ds(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new tl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){el("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Ez=0;class Tn extends Zi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ez++}),this.uuid=zi(),this.name="",this.type="Material",this.blending=ji,this.side=yi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wc,this.blendDst=Lc,this.blendEquation=Pi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ze(0,0,0),this.blendAlpha=0,this.depthFunc=Cr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ku,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ir,this.stencilZFail=ir,this.stencilZPass=ir,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const s=e[t];if(s===void 0){Qe(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Qe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector2&&s&&s.isVector2||i&&i.isEuler&&s&&s.isEuler||i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[t]=s}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==ji&&(s.blending=this.blending),this.side!==yi&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==Wc&&(s.blendSrc=this.blendSrc),this.blendDst!==Lc&&(s.blendDst=this.blendDst),this.blendEquation!==Pi&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==Cr&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ku&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ir&&(s.stencilFail=this.stencilFail),this.stencilZFail!==ir&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==ir&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.allowOverride===!1&&(s.allowOverride=!1),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(s.textures=r),a.length>0&&(s.images=a)}return s}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ze().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),this.normalScale=new Je().fromArray(s)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Je().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let s=null;if(t!==null){const i=t.length;s=new Array(i);for(let r=0;r!==i;++r)s[r]=t[r].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ed extends Tn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ze(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let mr;const ea=new P,Mr=new P,gr=new P,br=new Je,ta=new Je,im=new Rt,Ua=new P,sa=new P,Fa=new P,eh=new Je,Zl=new Je,th=new Je;class sh extends es{constructor(e=new Ed){if(super(),this.isSprite=!0,this.type="Sprite",mr===void 0){mr=new os;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),s=new Az(t,5);mr.setIndex([0,1,2,0,2,3]),mr.setAttribute("position",new tl(s,3,0,!1)),mr.setAttribute("uv",new tl(s,2,3,!1))}this.geometry=mr,this.material=e,this.center=new Je(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ot('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Mr.setFromMatrixScale(this.matrixWorld),im.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),gr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Mr.multiplyScalar(-gr.z);const s=this.material.rotation;let i,r;s!==0&&(r=Math.cos(s),i=Math.sin(s));const a=this.center;ja(Ua.set(-.5,-.5,0),gr,a,Mr,i,r),ja(sa.set(.5,-.5,0),gr,a,Mr,i,r),ja(Fa.set(.5,.5,0),gr,a,Mr,i,r),eh.set(0,0),Zl.set(1,0),th.set(1,1);let o=e.ray.intersectTriangle(Ua,sa,Fa,!1,ea);if(o===null&&(ja(sa.set(-.5,.5,0),gr,a,Mr,i,r),Zl.set(0,1),o=e.ray.intersectTriangle(Ua,Fa,sa,!1,ea),o===null))return;const l=e.ray.origin.distanceTo(ea);l<e.near||l>e.far||t.push({distance:l,point:ea.clone(),uv:nn.getInterpolation(ea,Ua,sa,Fa,eh,Zl,th,new Je),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ja(n,e,t,s,i,r){br.subVectors(n,t).addScalar(.5).multiply(s),i!==void 0?(ta.x=r*br.x-i*br.y,ta.y=i*br.x+r*br.y):ta.copy(br),n.copy(e),n.x+=ta.x,n.y+=ta.y,n.applyMatrix4(im)}const Wn=new P,Ql=new P,Va=new P,di=new P,Jl=new P,$a=new P,ec=new P;class ml{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const s=t.dot(this.direction);return s<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,s,i){Ql.copy(e).add(t).multiplyScalar(.5),Va.copy(t).sub(e).normalize(),di.copy(this.origin).sub(Ql);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Va),o=di.dot(this.direction),l=-di.dot(Va),c=di.lengthSq(),d=Math.abs(1-a*a);let h,u,p,M;if(d>0)if(h=a*l-o,u=a*o-l,M=r*d,h>=0)if(u>=-M)if(u<=M){const _=1/d;h*=_,u*=_,p=h*(h+a*u+2*o)+u*(a*h+u+2*l)+c}else u=r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;else u=-r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;else u<=-M?(h=Math.max(0,-(-a*r+o)),u=h>0?-r:Math.min(Math.max(-r,-l),r),p=-h*h+u*(u+2*l)+c):u<=M?(h=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(h=Math.max(0,-(a*r+o)),u=h>0?r:Math.min(Math.max(-r,-l),r),p=-h*h+u*(u+2*l)+c);else u=a>0?-r:r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;return s&&s.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Ql).addScaledVector(Va,u),p}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);const s=Wn.dot(this.direction),i=Wn.dot(Wn)-s*s,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=s-a,l=s+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/t;return s>=0?s:null}intersectPlane(e,t){const s=this.distanceToPlane(e);return s===null?null:this.at(s,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let s,i,r,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(s=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(s=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),d>=0?(r=(e.min.y-u.y)*d,a=(e.max.y-u.y)*d):(r=(e.max.y-u.y)*d,a=(e.min.y-u.y)*d),s>a||r>i||((r>s||isNaN(s))&&(s=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-u.z)*h,l=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,l=(e.min.z-u.z)*h),s>l||o>i)||((o>s||s!==s)&&(s=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(s>=0?s:i,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,s,i,r){Jl.subVectors(t,e),$a.subVectors(s,e),ec.crossVectors(Jl,$a);let a=this.direction.dot(ec),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;di.subVectors(this.origin,e);const l=o*this.direction.dot($a.crossVectors(di,$a));if(l<0)return null;const c=o*this.direction.dot(Jl.cross(di));if(c<0||l+c>a)return null;const d=-o*di.dot(ec);return d<0?null:this.at(d/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class nu extends Tn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vi,this.combine=Wp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const nh=new Rt,Di=new ml,Ha=new er,ih=new P,qa=new P,Xa=new P,Ya=new P,tc=new P,Ka=new P,rh=new P,Za=new P;class Ss extends es{constructor(e=new os,t=new nu){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const s=this.geometry,i=s.attributes.position,r=s.morphAttributes.position,a=s.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Ka.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const d=o[l],h=r[l];d!==0&&(tc.fromBufferAttribute(h,e),a?Ka.addScaledVector(tc,d):Ka.addScaledVector(tc.sub(t),d))}t.add(Ka)}return t}raycast(e,t){const s=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),Ha.copy(s.boundingSphere),Ha.applyMatrix4(r),Di.copy(e.ray).recast(e.near),!(Ha.containsPoint(Di.origin)===!1&&(Di.intersectSphere(Ha,ih)===null||Di.origin.distanceToSquared(ih)>(e.far-e.near)**2))&&(nh.copy(r).invert(),Di.copy(e.ray).applyMatrix4(nh),!(s.boundingBox!==null&&Di.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,t,Di)))}_computeIntersections(e,t,s){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,d=r.attributes.uv1,h=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let M=0,_=u.length;M<_;M++){const m=u[M],f=a[m.materialIndex],S=Math.max(m.start,p.start),v=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let z=S,O=v;z<O;z+=3){const x=o.getX(z),G=o.getX(z+1),b=o.getX(z+2);i=Qa(this,f,e,s,c,d,h,x,G,b),i&&(i.faceIndex=Math.floor(z/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const M=Math.max(0,p.start),_=Math.min(o.count,p.start+p.count);for(let m=M,f=_;m<f;m+=3){const S=o.getX(m),v=o.getX(m+1),z=o.getX(m+2);i=Qa(this,a,e,s,c,d,h,S,v,z),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let M=0,_=u.length;M<_;M++){const m=u[M],f=a[m.materialIndex],S=Math.max(m.start,p.start),v=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let z=S,O=v;z<O;z+=3){const x=z,G=z+1,b=z+2;i=Qa(this,f,e,s,c,d,h,x,G,b),i&&(i.faceIndex=Math.floor(z/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const M=Math.max(0,p.start),_=Math.min(l.count,p.start+p.count);for(let m=M,f=_;m<f;m+=3){const S=m,v=m+1,z=m+2;i=Qa(this,a,e,s,c,d,h,S,v,z),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function Dz(n,e,t,s,i,r,a,o){let l;if(e.side===Us?l=s.intersectTriangle(a,r,i,!0,o):l=s.intersectTriangle(i,r,a,e.side===yi,o),l===null)return null;Za.copy(o),Za.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Za);return c<t.near||c>t.far?null:{distance:c,point:Za.clone(),object:n}}function Qa(n,e,t,s,i,r,a,o,l,c){n.getVertexPosition(o,qa),n.getVertexPosition(l,Xa),n.getVertexPosition(c,Ya);const d=Dz(n,e,t,s,qa,Xa,Ya,rh);if(d){const h=new P;nn.getBarycoord(rh,qa,Xa,Ya,h),i&&(d.uv=nn.getInterpolatedAttribute(i,o,l,c,h,new Je)),r&&(d.uv1=nn.getInterpolatedAttribute(r,o,l,c,h,new Je)),a&&(d.normal=nn.getInterpolatedAttribute(a,o,l,c,h,new P),d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new P,materialIndex:0};nn.getNormal(qa,Xa,Ya,u.normal),d.face=u,d.barycoord=h}return d}class rm extends Is{constructor(e=null,t=1,s=1,i,r,a,o,l,c=ws,d=ws,h,u){super(null,a,o,l,c,d,i,r,h,u),this.isDataTexture=!0,this.image={data:e,width:t,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class _a extends Ds{constructor(e,t,s,i=1){super(e,t,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const zr=new Rt,ah=new Rt,Ja=[],oh=new Ji,Iz=new Rt,na=new Ss,ia=new er;class lh extends Ss{constructor(e,t,s){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new _a(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<s;i++)this.setMatrixAt(i,Iz)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ji),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,zr),oh.copy(e.boundingBox).applyMatrix4(zr),this.boundingBox.union(oh)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new er),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,zr),ia.copy(e.boundingSphere).applyMatrix4(zr),this.boundingSphere.union(ia)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const s=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=s.length+1,a=e*r+1;for(let o=0;o<s.length;o++)s[o]=i[a+o]}raycast(e,t){const s=this.matrixWorld,i=this.count;if(na.geometry=this.geometry,na.material=this.material,na.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ia.copy(this.boundingSphere),ia.applyMatrix4(s),e.ray.intersectsSphere(ia)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,zr),ah.multiplyMatrices(s,zr),na.matrixWorld=ah,na.raycast(e,Ja);for(let a=0,o=Ja.length;a<o;a++){const l=Ja[a];l.instanceId=r,l.object=this,t.push(l)}Ja.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new _a(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const s=t.morphTargetInfluences,i=s.length+1;this.morphTexture===null&&(this.morphTexture=new rm(new Float32Array(i*this.count),i,this.count,Yd,Mn));const r=this.morphTexture.source.data.data;let a=0;for(let c=0;c<s.length;c++)a+=s[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;return r[l]=o,r.set(s,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const sc=new P,Tz=new P,Gz=new lt;class fi{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,i){return this.normal.set(e,t,s),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){const i=sc.subVectors(s,t).cross(Tz.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,s=!0){const i=e.delta(sc),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return s===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return t<0&&s>0||s<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||Gz.getNormalMatrix(e),i=this.coplanarPoint(sc).applyMatrix4(e),r=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ii=new er,Rz=new Je(.5,.5),eo=new P;class iu{constructor(e=new fi,t=new fi,s=new fi,i=new fi,r=new fi,a=new fi){this.planes=[e,t,s,i,r,a]}set(e,t,s,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(s),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let s=0;s<6;s++)t[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,t=Sn,s=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],d=r[4],h=r[5],u=r[6],p=r[7],M=r[8],_=r[9],m=r[10],f=r[11],S=r[12],v=r[13],z=r[14],O=r[15];if(i[0].setComponents(c-a,p-d,f-M,O-S).normalize(),i[1].setComponents(c+a,p+d,f+M,O+S).normalize(),i[2].setComponents(c+o,p+h,f+_,O+v).normalize(),i[3].setComponents(c-o,p-h,f-_,O-v).normalize(),s)i[4].setComponents(l,u,m,z).normalize(),i[5].setComponents(c-l,p-u,f-m,O-z).normalize();else if(i[4].setComponents(c-l,p-u,f-m,O-z).normalize(),t===Sn)i[5].setComponents(c+l,p+u,f+m,O+z).normalize();else if(t===Aa)i[5].setComponents(l,u,m,z).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ii.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ii.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ii)}intersectsSprite(e){Ii.center.set(0,0,0);const t=Rz.distanceTo(e.center);return Ii.radius=.7071067811865476+t,Ii.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ii)}intersectsSphere(e){const t=this.planes,s=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(s)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let s=0;s<6;s++){const i=t[s];if(eo.x=i.normal.x>0?e.max.x:e.min.x,eo.y=i.normal.y>0?e.max.y:e.min.y,eo.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(eo)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let s=0;s<6;s++)if(t[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Wi extends Tn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const sl=new P,nl=new P,ch=new Rt,ra=new ml,to=new er,nc=new P,dh=new P;class Dd extends es{constructor(e=new os,t=new Wi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[0];for(let i=1,r=t.count;i<r;i++)sl.fromBufferAttribute(t,i-1),nl.fromBufferAttribute(t,i),s[i]=s[i-1],s[i]+=sl.distanceTo(nl);e.setAttribute("lineDistance",new Ht(s,1))}else Qe("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),to.copy(s.boundingSphere),to.applyMatrix4(i),to.radius+=r,e.ray.intersectsSphere(to)===!1)return;ch.copy(i).invert(),ra.copy(e.ray).applyMatrix4(ch);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=s.index,u=s.attributes.position;if(d!==null){const p=Math.max(0,a.start),M=Math.min(d.count,a.start+a.count);for(let _=p,m=M-1;_<m;_+=c){const f=d.getX(_),S=d.getX(_+1),v=so(this,e,ra,l,f,S,_);v&&t.push(v)}if(this.isLineLoop){const _=d.getX(M-1),m=d.getX(p),f=so(this,e,ra,l,_,m,M-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),M=Math.min(u.count,a.start+a.count);for(let _=p,m=M-1;_<m;_+=c){const f=so(this,e,ra,l,_,_+1,_);f&&t.push(f)}if(this.isLineLoop){const _=so(this,e,ra,l,M-1,p,M-1);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function so(n,e,t,s,i,r,a){const o=n.geometry.attributes.position;if(sl.fromBufferAttribute(o,i),nl.fromBufferAttribute(o,r),t.distanceSqToSegment(sl,nl,nc,dh)>s)return;nc.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(nc);if(!(c<e.near||c>e.far))return{distance:c,point:dh.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const uh=new P,hh=new P;class fh extends Dd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[];for(let i=0,r=t.count;i<r;i+=2)uh.fromBufferAttribute(t,i),hh.fromBufferAttribute(t,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+uh.distanceTo(hh);e.setAttribute("lineDistance",new Ht(s,1))}else Qe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Bz extends Tn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const ph=new Rt,Id=new ml,no=new er,io=new P;class Nz extends es{constructor(e=new os,t=new Bz){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),no.copy(s.boundingSphere),no.applyMatrix4(i),no.radius+=r,e.ray.intersectsSphere(no)===!1)return;ph.copy(i).invert(),Id.copy(e.ray).applyMatrix4(ph);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=s.index,h=s.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let M=u,_=p;M<_;M++){const m=c.getX(M);io.fromBufferAttribute(h,m),mh(io,m,l,i,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let M=u,_=p;M<_;M++)io.fromBufferAttribute(h,M),mh(io,M,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function mh(n,e,t,s,i,r,a){const o=Id.distanceSqToPoint(n);if(o<t){const l=new P;Id.closestPointToPoint(n,l),l.applyMatrix4(s);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class am extends Is{constructor(e=[],t=Xi,s,i,r,a,o,l,c,d){super(e,t,s,i,r,a,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cz extends Is{constructor(e,t,s,i,r,a,o,l,c){super(e,t,s,i,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Wr extends Is{constructor(e,t,s=In,i,r,a,o=ws,l=ws,c,d=ti,h=1){if(d!==ti&&d!==Fi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:h};super(u,i,r,a,o,l,d,s,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new tu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Pz extends Wr{constructor(e,t=In,s=Xi,i,r,a=ws,o=ws,l,c=ti){const d={width:e,height:e,depth:1},h=[d,d,d,d,d,d];super(e,e,t,s,i,r,a,o,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class om extends Is{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Da extends os{constructor(e=1,t=1,s=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:s,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],d=[],h=[];let u=0,p=0;M("z","y","x",-1,-1,s,t,e,a,r,0),M("z","y","x",1,-1,s,t,-e,a,r,1),M("x","z","y",1,1,e,s,t,i,a,2),M("x","z","y",1,-1,e,s,-t,i,a,3),M("x","y","z",1,-1,e,t,s,i,r,4),M("x","y","z",-1,-1,e,t,-s,i,r,5),this.setIndex(l),this.setAttribute("position",new Ht(c,3)),this.setAttribute("normal",new Ht(d,3)),this.setAttribute("uv",new Ht(h,2));function M(_,m,f,S,v,z,O,x,G,b,T){const N=z/G,C=O/b,W=z/2,Q=O/2,se=x/2,H=G+1,ee=b+1;let J=0,ue=0;const he=new P;for(let Se=0;Se<ee;Se++){const be=Se*C-Q;for(let Re=0;Re<H;Re++){const ht=Re*N-W;he[_]=ht*S,he[m]=be*v,he[f]=se,c.push(he.x,he.y,he.z),he[_]=0,he[m]=0,he[f]=x>0?1:-1,d.push(he.x,he.y,he.z),h.push(Re/G),h.push(1-Se/b),J+=1}}for(let Se=0;Se<b;Se++)for(let be=0;be<G;be++){const Re=u+be+H*Se,ht=u+be+H*(Se+1),ct=u+(be+1)+H*(Se+1),tt=u+(be+1)+H*Se;l.push(Re,ht,tt),l.push(ht,ct,tt),ue+=6}o.addGroup(p,ue,T),p+=ue,u+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Da(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ru extends os{constructor(e=1,t=32,s=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:s,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new P,d=new Je;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,u=3;h<=t;h++,u+=3){const p=s+h/t*i;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),d.x=(a[u]/e+1)/2,d.y=(a[u+1]/e+1)/2,l.push(d.x,d.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Ht(a,3)),this.setAttribute("normal",new Ht(o,3)),this.setAttribute("uv",new Ht(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ru(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class au extends os{constructor(e=1,t=1,s=1,i=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:s,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),r=Math.floor(r);const d=[],h=[],u=[],p=[];let M=0;const _=[],m=s/2;let f=0;S(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(d),this.setAttribute("position",new Ht(h,3)),this.setAttribute("normal",new Ht(u,3)),this.setAttribute("uv",new Ht(p,2));function S(){const z=new P,O=new P;let x=0;const G=(t-e)/s;for(let b=0;b<=r;b++){const T=[],N=b/r,C=N*(t-e)+e;for(let W=0;W<=i;W++){const Q=W/i,se=Q*l+o,H=Math.sin(se),ee=Math.cos(se);O.x=C*H,O.y=-N*s+m,O.z=C*ee,h.push(O.x,O.y,O.z),z.set(H,G,ee).normalize(),u.push(z.x,z.y,z.z),p.push(Q,1-N),T.push(M++)}_.push(T)}for(let b=0;b<i;b++)for(let T=0;T<r;T++){const N=_[T][b],C=_[T+1][b],W=_[T+1][b+1],Q=_[T][b+1];(e>0||T!==0)&&(d.push(N,C,Q),x+=3),(t>0||T!==r-1)&&(d.push(C,W,Q),x+=3)}c.addGroup(f,x,0),f+=x}function v(z){const O=M,x=new Je,G=new P;let b=0;const T=z===!0?e:t,N=z===!0?1:-1;for(let W=1;W<=i;W++)h.push(0,m*N,0),u.push(0,N,0),p.push(.5,.5),M++;const C=M;for(let W=0;W<=i;W++){const se=W/i*l+o,H=Math.cos(se),ee=Math.sin(se);G.x=T*ee,G.y=m*N,G.z=T*H,h.push(G.x,G.y,G.z),u.push(0,N,0),x.x=H*.5+.5,x.y=ee*.5*N+.5,p.push(x.x,x.y),M++}for(let W=0;W<i;W++){const Q=O+W,se=C+W;z===!0?d.push(se,se+1,Q):d.push(se+1,se,Q),b+=3}c.addGroup(f,b,z===!0?1:2),f+=b}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new au(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ou extends os{constructor(e=[],t=[],s=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:s,detail:i};const r=[],a=[];o(i),c(s),d(),this.setAttribute("position",new Ht(r,3)),this.setAttribute("normal",new Ht(r.slice(),3)),this.setAttribute("uv",new Ht(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(S){const v=new P,z=new P,O=new P;for(let x=0;x<t.length;x+=3)p(t[x+0],v),p(t[x+1],z),p(t[x+2],O),l(v,z,O,S)}function l(S,v,z,O){const x=O+1,G=[];for(let b=0;b<=x;b++){G[b]=[];const T=S.clone().lerp(z,b/x),N=v.clone().lerp(z,b/x),C=x-b;for(let W=0;W<=C;W++)W===0&&b===x?G[b][W]=T:G[b][W]=T.clone().lerp(N,W/C)}for(let b=0;b<x;b++)for(let T=0;T<2*(x-b)-1;T++){const N=Math.floor(T/2);T%2===0?(u(G[b][N+1]),u(G[b+1][N]),u(G[b][N])):(u(G[b][N+1]),u(G[b+1][N+1]),u(G[b+1][N]))}}function c(S){const v=new P;for(let z=0;z<r.length;z+=3)v.x=r[z+0],v.y=r[z+1],v.z=r[z+2],v.normalize().multiplyScalar(S),r[z+0]=v.x,r[z+1]=v.y,r[z+2]=v.z}function d(){const S=new P;for(let v=0;v<r.length;v+=3){S.x=r[v+0],S.y=r[v+1],S.z=r[v+2];const z=m(S)/2/Math.PI+.5,O=f(S)/Math.PI+.5;a.push(z,1-O)}M(),h()}function h(){for(let S=0;S<a.length;S+=6){const v=a[S+0],z=a[S+2],O=a[S+4],x=Math.max(v,z,O),G=Math.min(v,z,O);x>.9&&G<.1&&(v<.2&&(a[S+0]+=1),z<.2&&(a[S+2]+=1),O<.2&&(a[S+4]+=1))}}function u(S){r.push(S.x,S.y,S.z)}function p(S,v){const z=S*3;v.x=e[z+0],v.y=e[z+1],v.z=e[z+2]}function M(){const S=new P,v=new P,z=new P,O=new P,x=new Je,G=new Je,b=new Je;for(let T=0,N=0;T<r.length;T+=9,N+=6){S.set(r[T+0],r[T+1],r[T+2]),v.set(r[T+3],r[T+4],r[T+5]),z.set(r[T+6],r[T+7],r[T+8]),x.set(a[N+0],a[N+1]),G.set(a[N+2],a[N+3]),b.set(a[N+4],a[N+5]),O.copy(S).add(v).add(z).divideScalar(3);const C=m(O);_(x,N+0,S,C),_(G,N+2,v,C),_(b,N+4,z,C)}}function _(S,v,z,O){O<0&&S.x===1&&(a[v]=S.x-1),z.x===0&&z.z===0&&(a[v]=O/2/Math.PI+.5)}function m(S){return Math.atan2(S.z,-S.x)}function f(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ou(e.vertices,e.indices,e.radius,e.detail)}}class lu extends ou{constructor(e=1,t=0){const s=(1+Math.sqrt(5))/2,i=[-1,s,0,1,s,0,-1,-s,0,1,-s,0,0,-1,s,0,1,s,0,-1,-s,0,1,-s,s,0,-1,s,0,1,-s,0,-1,-s,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lu(e.radius,e.detail)}}class Ml extends os{constructor(e=1,t=1,s=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:s,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(s),l=Math.floor(i),c=o+1,d=l+1,h=e/o,u=t/l,p=[],M=[],_=[],m=[];for(let f=0;f<d;f++){const S=f*u-a;for(let v=0;v<c;v++){const z=v*h-r;M.push(z,-S,0),_.push(0,0,1),m.push(v/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let S=0;S<o;S++){const v=S+c*f,z=S+c*(f+1),O=S+1+c*(f+1),x=S+1+c*f;p.push(v,z,x),p.push(z,O,x)}this.setIndex(p),this.setAttribute("position",new Ht(M,3)),this.setAttribute("normal",new Ht(_,3)),this.setAttribute("uv",new Ht(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ml(e.width,e.height,e.widthSegments,e.heightSegments)}}class il extends os{constructor(e=1,t=32,s=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:s,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),s=Math.max(2,Math.floor(s));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new P,u=new P,p=[],M=[],_=[],m=[];for(let f=0;f<=s;f++){const S=[],v=f/s,z=a+v*o,O=e*Math.cos(z),x=Math.sqrt(e*e-O*O);let G=0;f===0&&a===0?G=.5/t:f===s&&l===Math.PI&&(G=-.5/t);for(let b=0;b<=t;b++){const T=b/t,N=i+T*r;h.x=-x*Math.cos(N),h.y=O,h.z=x*Math.sin(N),M.push(h.x,h.y,h.z),u.copy(h).normalize(),_.push(u.x,u.y,u.z),m.push(T+G,1-v),S.push(c++)}d.push(S)}for(let f=0;f<s;f++)for(let S=0;S<t;S++){const v=d[f][S+1],z=d[f][S],O=d[f+1][S],x=d[f+1][S+1];(f!==0||a>0)&&p.push(v,z,x),(f!==s-1||l<Math.PI)&&p.push(z,O,x)}this.setIndex(p),this.setAttribute("position",new Ht(M,3)),this.setAttribute("normal",new Ht(_,3)),this.setAttribute("uv",new Ht(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new il(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Lr(n){const e={};for(const t in n){e[t]={};for(const s in n[t]){const i=n[t][s];if(Mh(i))i.isRenderTargetTexture?(Qe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][s]=null):e[t][s]=i.clone();else if(Array.isArray(i))if(Mh(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][s]=r}else e[t][s]=i.slice();else e[t][s]=i}}return e}function Ns(n){const e={};for(let t=0;t<n.length;t++){const s=Lr(n[t]);for(const i in s)e[i]=s[i]}return e}function Mh(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function Wz(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function lm(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:xt.workingColorSpace}const Lz={clone:Lr,merge:Ns};var kz=`void main() {
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./cornerstoneEngine-DeIhrHvT.js","./_commonjsHelpers-CE1G-McA.js"])))=>i.map(i=>d[i]);
2
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();const gM=["cold","cached","failed"];function bM(n){return n.state??(n.restored===!0?"cached":"cold")}const zM=["upload","download","pull","workflow","pipeline","group","task"],_M=["transfer","retrieve","workflow","inspection"],wM=["scanning","transferring","watching","retrying","reading","working","complete","failed"],yM=["files","bytes","series","jobs","nodes"],vM=["running","done","unconfirmed","stalled","timeout","error","unknown"],Ec=1;var Tt;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{const r={};for(const a of i)r[a]=a;return r},n.getValidEnumValues=i=>{const r=n.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of r)a[o]=i[o];return n.objectValues(a)},n.objectValues=i=>n.objectKeys(i).map(function(r){return i[r]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const r=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&r.push(a);return r},n.find=(i,r)=>{for(const a of i)if(r(a))return a},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,r=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}n.joinValues=s,n.jsonStringifyReplacer=(i,r)=>typeof r=="bigint"?r.toString():r})(Tt||(Tt={}));var Su;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Su||(Su={}));const je=Tt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),fi=n=>{switch(typeof n){case"undefined":return je.undefined;case"string":return je.string;case"number":return Number.isNaN(n)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(n)?je.array:n===null?je.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?je.promise:typeof Map<"u"&&n instanceof Map?je.map:typeof Set<"u"&&n instanceof Set?je.set:typeof Date<"u"&&n instanceof Date?je.date:je.object;default:return je.unknown}},ze=Tt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Jn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(r){return r.message},s={_errors:[]},i=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)s._errors.push(t(a));else{let o=s,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),s}static assert(e){if(!(e instanceof Jn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Tt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const i of this.issues)if(i.path.length>0){const r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Jn.create=n=>new Jn(n);const Dc=(n,e)=>{let t;switch(n.code){case ze.invalid_type:n.received===je.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case ze.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,Tt.jsonStringifyReplacer)}`;break;case ze.unrecognized_keys:t=`Unrecognized key(s) in object: ${Tt.joinValues(n.keys,", ")}`;break;case ze.invalid_union:t="Invalid input";break;case ze.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Tt.joinValues(n.options)}`;break;case ze.invalid_enum_value:t=`Invalid enum value. Expected ${Tt.joinValues(n.options)}, received '${n.received}'`;break;case ze.invalid_arguments:t="Invalid function arguments";break;case ze.invalid_return_type:t="Invalid function return type";break;case ze.invalid_date:t="Invalid date";break;case ze.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:Tt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case ze.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case ze.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case ze.custom:t="Invalid input";break;case ze.invalid_intersection_types:t="Intersection results could not be merged";break;case ze.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case ze.not_finite:t="Number must be finite";break;default:t=e.defaultError,Tt.assertNever(n)}return{message:t}};let OM=Dc;function xM(){return OM}const SM=n=>{const{data:e,path:t,errorMaps:s,issueData:i}=n,r=[...t,...i.path||[]],a={...i,path:r};if(i.message!==void 0)return{...i,path:r,message:i.message};let o="";const l=s.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:e,defaultError:o}).message;return{...i,path:r,message:o}};function Ce(n,e){const t=xM(),s=SM({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Dc?void 0:Dc].filter(i=>!!i)});n.common.issues.push(s)}class Xs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const i of t){if(i.status==="aborted")return nt;i.status==="dirty"&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const i of t){const r=await i.key,a=await i.value;s.push({key:r,value:a})}return Xs.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:r,value:a}=i;if(r.status==="aborted"||a.status==="aborted")return nt;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(s[r.value]=a.value)}return{status:e.value,value:s}}}const nt=Object.freeze({status:"aborted"}),fa=n=>({status:"dirty",value:n}),rn=n=>({status:"valid",value:n}),Au=n=>n.status==="aborted",Eu=n=>n.status==="dirty",Br=n=>n.status==="valid",Lo=n=>typeof Promise<"u"&&n instanceof Promise;var He;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(He||(He={}));class wi{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Du=(n,e)=>{if(Br(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Jn(n.common.issues);return this._error=t,this._error}}};function zt(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:i}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{const{message:l}=n;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:l??t??o.defaultError}},description:i}}class Dt{get description(){return this._def.description}_getType(e){return fi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:fi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Xs,ctx:{common:e.parent.common,data:e.data,parsedType:fi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Lo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fi(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Du(s,i)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fi(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return Br(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>Br(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fi(e)},i=this._parse({data:e,path:s.path,parent:s}),r=await(Lo(i)?i:Promise.resolve(i));return Du(s,r)}refine(e,t){const s=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,r)=>{const a=e(i),o=()=>r.addIssue({code:ze.custom,...s(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,i)=>e(s)?!0:(i.addIssue(typeof t=="function"?t(s,i):t),!1))}_refinement(e){return new Hi({schema:this,typeName:at.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Yn.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return An.create(this)}promise(){return $o.create(this,this._def)}or(e){return Uo.create([this,e],this._def)}and(e){return Fo.create(this,e,this._def)}transform(e){return new Hi({...zt(this._def),schema:this,typeName:at.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ho({...zt(this._def),innerType:this,defaultValue:t,typeName:at.ZodDefault})}brand(){return new Op({typeName:at.ZodBranded,type:this,...zt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qo({...zt(this._def),innerType:this,catchValue:t,typeName:at.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return jd.create(this,e)}readonly(){return Xo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const AM=/^c[^\s-]{8,}$/i,EM=/^[0-9a-z]+$/,DM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,IM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,TM=/^[a-z0-9_-]{21}$/i,GM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,RM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))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/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,UM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wp="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",FM=new RegExp(`^${wp}$`);function yp(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function jM(n){return new RegExp(`^${yp(n)}$`)}function VM(n){let e=`${wp}T${yp(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function $M(n,e){return!!((e==="v4"||!e)&&CM.test(n)||(e==="v6"||!e)&&WM.test(n))}function HM(n,e){if(!GM.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function qM(n,e){return!!((e==="v4"||!e)&&PM.test(n)||(e==="v6"||!e)&&LM.test(n))}class gi extends Dt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.string,received:r.parsedType}),nt}const s=new Xs;let i;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,o=e.data.length<r.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?Ce(i,{code:ze.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&Ce(i,{code:ze.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")BM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"email",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")El||(El=new RegExp(NM,"u")),El.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"emoji",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")IM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"uuid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")TM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"nanoid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")AM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cuid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")EM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cuid2",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")DM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"ulid",code:ze.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Ce(i,{validation:"url",code:ze.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"regex",code:ze.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?VM(r).test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?FM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?jM(r).test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?RM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"duration",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?$M(e.data,r.version)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"ip",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?HM(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"jwt",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?qM(e.data,r.version)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"cidr",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?kM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"base64",code:ze.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?UM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ce(i,{validation:"base64url",code:ze.invalid_string,message:r.message}),s.dirty()):Tt.assertNever(r);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(i=>e.test(i),{validation:t,code:ze.invalid_string,...He.errToObj(s)})}_addCheck(e){return new gi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...He.errToObj(e)})}url(e){return this._addCheck({kind:"url",...He.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...He.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...He.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...He.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...He.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...He.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...He.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...He.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...He.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...He.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...He.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...He.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...He.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...He.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...He.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...He.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...He.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...He.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...He.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...He.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...He.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...He.errToObj(t)})}nonempty(e){return this.min(1,He.errToObj(e))}trim(){return new gi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new gi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new gi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}gi.create=n=>new gi({checks:[],typeName:at.ZodString,coerce:n?.coerce??!1,...zt(n)});function XM(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,r=Number.parseInt(n.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return r%a/10**i}class Nr extends Dt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==je.number){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.number,received:r.parsedType}),nt}let s;const i=new Xs;for(const r of this._def.checks)r.kind==="int"?Tt.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.invalid_type,expected:"integer",received:"float",message:r.message}),i.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="multipleOf"?XM(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_finite,message:r.message}),i.dirty()):Tt.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,He.toString(t))}gt(e,t){return this.setLimit("min",e,!1,He.toString(t))}lte(e,t){return this.setLimit("max",e,!0,He.toString(t))}lt(e,t){return this.setLimit("max",e,!1,He.toString(t))}setLimit(e,t,s,i){return new Nr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:He.toString(i)}]})}_addCheck(e){return new Nr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:He.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:He.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:He.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:He.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:He.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:He.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:He.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:He.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:He.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Tt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Nr.create=n=>new Nr({checks:[],typeName:at.ZodNumber,coerce:n?.coerce||!1,...zt(n)});class va extends Dt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==je.bigint)return this._getInvalidInput(e);let s;const i=new Xs;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),Ce(s,{code:ze.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):Tt.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Ce(t,{code:ze.invalid_type,expected:je.bigint,received:t.parsedType}),nt}gte(e,t){return this.setLimit("min",e,!0,He.toString(t))}gt(e,t){return this.setLimit("min",e,!1,He.toString(t))}lte(e,t){return this.setLimit("max",e,!0,He.toString(t))}lt(e,t){return this.setLimit("max",e,!1,He.toString(t))}setLimit(e,t,s,i){return new va({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:He.toString(i)}]})}_addCheck(e){return new va({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:He.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:He.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:He.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:He.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:He.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}va.create=n=>new va({checks:[],typeName:at.ZodBigInt,coerce:n?.coerce??!1,...zt(n)});class Ic extends Dt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==je.boolean){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.boolean,received:s.parsedType}),nt}return rn(e.data)}}Ic.create=n=>new Ic({typeName:at.ZodBoolean,coerce:n?.coerce||!1,...zt(n)});class ko extends Dt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_type,expected:je.date,received:r.parsedType}),nt}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return Ce(r,{code:ze.invalid_date}),nt}const s=new Xs;let i;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),Ce(i,{code:ze.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):Tt.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ko({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:He.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:He.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ko.create=n=>new ko({checks:[],coerce:n?.coerce||!1,typeName:at.ZodDate,...zt(n)});class Iu extends Dt{_parse(e){if(this._getType(e)!==je.symbol){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.symbol,received:s.parsedType}),nt}return rn(e.data)}}Iu.create=n=>new Iu({typeName:at.ZodSymbol,...zt(n)});class Tc extends Dt{_parse(e){if(this._getType(e)!==je.undefined){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.undefined,received:s.parsedType}),nt}return rn(e.data)}}Tc.create=n=>new Tc({typeName:at.ZodUndefined,...zt(n)});class Gc extends Dt{_parse(e){if(this._getType(e)!==je.null){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.null,received:s.parsedType}),nt}return rn(e.data)}}Gc.create=n=>new Gc({typeName:at.ZodNull,...zt(n)});class Tu extends Dt{constructor(){super(...arguments),this._any=!0}_parse(e){return rn(e.data)}}Tu.create=n=>new Tu({typeName:at.ZodAny,...zt(n)});class Rc extends Dt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return rn(e.data)}}Rc.create=n=>new Rc({typeName:at.ZodUnknown,...zt(n)});class yi extends Dt{_parse(e){const t=this._getOrReturnCtx(e);return Ce(t,{code:ze.invalid_type,expected:je.never,received:t.parsedType}),nt}}yi.create=n=>new yi({typeName:at.ZodNever,...zt(n)});class Gu extends Dt{_parse(e){if(this._getType(e)!==je.undefined){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.void,received:s.parsedType}),nt}return rn(e.data)}}Gu.create=n=>new Gu({typeName:at.ZodVoid,...zt(n)});class An extends Dt{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),i=this._def;if(t.parsedType!==je.array)return Ce(t,{code:ze.invalid_type,expected:je.array,received:t.parsedType}),nt;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(Ce(t,{code:a?ze.too_big:ze.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),s.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(Ce(t,{code:ze.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),s.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(Ce(t,{code:ze.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new wi(t,a,t.path,o)))).then(a=>Xs.mergeArray(s,a));const r=[...t.data].map((a,o)=>i.type._parseSync(new wi(t,a,t.path,o)));return Xs.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new An({...this._def,minLength:{value:e,message:He.toString(t)}})}max(e,t){return new An({...this._def,maxLength:{value:e,message:He.toString(t)}})}length(e,t){return new An({...this._def,exactLength:{value:e,message:He.toString(t)}})}nonempty(e){return this.min(1,e)}}An.create=(n,e)=>new An({type:n,minLength:null,maxLength:null,exactLength:null,typeName:at.ZodArray,...zt(e)});function Er(n){if(n instanceof as){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Yn.create(Er(s))}return new as({...n._def,shape:()=>e})}else return n instanceof An?new An({...n._def,type:Er(n.element)}):n instanceof Yn?Yn.create(Er(n.unwrap())):n instanceof qi?qi.create(Er(n.unwrap())):n instanceof Vi?Vi.create(n.items.map(e=>Er(e))):n}class as extends Dt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Tt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==je.object){const c=this._getOrReturnCtx(e);return Ce(c,{code:ze.invalid_type,expected:je.object,received:c.parsedType}),nt}const{status:s,ctx:i}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof yi&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const d=r[c],h=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new wi(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof yi){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")o.length>0&&(Ce(i,{code:ze.unrecognized_keys,keys:o}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const h=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new wi(i,h,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const h=await d.key,u=await d.value;c.push({key:h,value:u,alwaysSet:d.alwaysSet})}return c}).then(c=>Xs.mergeObjectSync(s,c)):Xs.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return He.errToObj,new as({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const i=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:He.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new as({...this._def,unknownKeys:"strip"})}passthrough(){return new as({...this._def,unknownKeys:"passthrough"})}extend(e){return new as({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new as({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:at.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new as({...this._def,catchall:e})}pick(e){const t={};for(const s of Tt.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new as({...this._def,shape:()=>t})}omit(e){const t={};for(const s of Tt.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new as({...this._def,shape:()=>t})}deepPartial(){return Er(this)}partial(e){const t={};for(const s of Tt.objectKeys(this.shape)){const i=this.shape[s];e&&!e[s]?t[s]=i:t[s]=i.optional()}return new as({...this._def,shape:()=>t})}required(e){const t={};for(const s of Tt.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof Yn;)r=r._def.innerType;t[s]=r}return new as({...this._def,shape:()=>t})}keyof(){return vp(Tt.objectKeys(this.shape))}}as.create=(n,e)=>new as({shape:()=>n,unknownKeys:"strip",catchall:yi.create(),typeName:at.ZodObject,...zt(e)});as.strictCreate=(n,e)=>new as({shape:()=>n,unknownKeys:"strict",catchall:yi.create(),typeName:at.ZodObject,...zt(e)});as.lazycreate=(n,e)=>new as({shape:n,unknownKeys:"strip",catchall:yi.create(),typeName:at.ZodObject,...zt(e)});class Uo extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function i(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new Jn(o.ctx.common.issues));return Ce(t,{code:ze.invalid_union,unionErrors:a}),nt}if(t.common.async)return Promise.all(s.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let r;const a=[];for(const l of s){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!r&&(r={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(l=>new Jn(l));return Ce(t,{code:ze.invalid_union,unionErrors:o}),nt}}get options(){return this._def.options}}Uo.create=(n,e)=>new Uo({options:n,typeName:at.ZodUnion,...zt(e)});const jn=n=>n instanceof jo?jn(n.schema):n instanceof Hi?jn(n.innerType()):n instanceof Vo?[n.value]:n instanceof $i?n.options:n instanceof Nc?Tt.objectValues(n.enum):n instanceof Ho?jn(n._def.innerType):n instanceof Tc?[void 0]:n instanceof Gc?[null]:n instanceof Yn?[void 0,...jn(n.unwrap())]:n instanceof qi?[null,...jn(n.unwrap())]:n instanceof Op||n instanceof Xo?jn(n.unwrap()):n instanceof qo?jn(n._def.innerType):[];class Fd extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.object)return Ce(t,{code:ze.invalid_type,expected:je.object,received:t.parsedType}),nt;const s=this.discriminator,i=t.data[s],r=this.optionsMap.get(i);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(Ce(t,{code:ze.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),nt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const r of t){const a=jn(r.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,r)}}return new Fd({typeName:at.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...zt(s)})}}function Bc(n,e){const t=fi(n),s=fi(e);if(n===e)return{valid:!0,data:n};if(t===je.object&&s===je.object){const i=Tt.objectKeys(e),r=Tt.objectKeys(n).filter(o=>i.indexOf(o)!==-1),a={...n,...e};for(const o of r){const l=Bc(n[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===je.array&&s===je.array){if(n.length!==e.length)return{valid:!1};const i=[];for(let r=0;r<n.length;r++){const a=n[r],o=e[r],l=Bc(a,o);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===je.date&&s===je.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Fo extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=(r,a)=>{if(Au(r)||Au(a))return nt;const o=Bc(r.value,a.value);return o.valid?((Eu(r)||Eu(a))&&t.dirty(),{status:t.value,value:o.data}):(Ce(s,{code:ze.invalid_intersection_types}),nt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,a])=>i(r,a)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Fo.create=(n,e,t)=>new Fo({left:n,right:e,typeName:at.ZodIntersection,...zt(t)});class Vi extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.array)return Ce(s,{code:ze.invalid_type,expected:je.array,received:s.parsedType}),nt;if(s.data.length<this._def.items.length)return Ce(s,{code:ze.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),nt;!this._def.rest&&s.data.length>this._def.items.length&&(Ce(s,{code:ze.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new wi(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(r).then(a=>Xs.mergeArray(t,a)):Xs.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Vi({...this._def,rest:e})}}Vi.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Vi({items:n,typeName:at.ZodTuple,rest:null,...zt(e)})};class Ru extends Dt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.map)return Ce(s,{code:ze.invalid_type,expected:je.map,received:s.parsedType}),nt;const i=this._def.keyType,r=this._def.valueType,a=[...s.data.entries()].map(([o,l],c)=>({key:i._parse(new wi(s,o,s.path,[c,"key"])),value:r._parse(new wi(s,l,s.path,[c,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return nt;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return nt;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}Ru.create=(n,e,t)=>new Ru({valueType:e,keyType:n,typeName:at.ZodMap,...zt(t)});class Oa extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==je.set)return Ce(s,{code:ze.invalid_type,expected:je.set,received:s.parsedType}),nt;const i=this._def;i.minSize!==null&&s.data.size<i.minSize.value&&(Ce(s,{code:ze.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&s.data.size>i.maxSize.value&&(Ce(s,{code:ze.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const r=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return nt;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...s.data.values()].map((l,c)=>r._parse(new wi(s,l,s.path,c)));return s.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Oa({...this._def,minSize:{value:e,message:He.toString(t)}})}max(e,t){return new Oa({...this._def,maxSize:{value:e,message:He.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Oa.create=(n,e)=>new Oa({valueType:n,minSize:null,maxSize:null,typeName:at.ZodSet,...zt(e)});class jo extends Dt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}jo.create=(n,e)=>new jo({getter:n,typeName:at.ZodLazy,...zt(e)});class Vo extends Dt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Ce(t,{received:t.data,code:ze.invalid_literal,expected:this._def.value}),nt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Vo.create=(n,e)=>new Vo({value:n,typeName:at.ZodLiteral,...zt(e)});function vp(n,e){return new $i({values:n,typeName:at.ZodEnum,...zt(e)})}class $i extends Dt{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return Ce(t,{expected:Tt.joinValues(s),received:t.parsedType,code:ze.invalid_type}),nt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return Ce(t,{received:t.data,code:ze.invalid_enum_value,options:s}),nt}return rn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return $i.create(e,{...this._def,...t})}exclude(e,t=this._def){return $i.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}$i.create=vp;class Nc extends Dt{_parse(e){const t=Tt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==je.string&&s.parsedType!==je.number){const i=Tt.objectValues(t);return Ce(s,{expected:Tt.joinValues(i),received:s.parsedType,code:ze.invalid_type}),nt}if(this._cache||(this._cache=new Set(Tt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Tt.objectValues(t);return Ce(s,{received:s.data,code:ze.invalid_enum_value,options:i}),nt}return rn(e.data)}get enum(){return this._def.values}}Nc.create=(n,e)=>new Nc({values:n,typeName:at.ZodNativeEnum,...zt(e)});class $o extends Dt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.promise&&t.common.async===!1)return Ce(t,{code:ze.invalid_type,expected:je.promise,received:t.parsedType}),nt;const s=t.parsedType===je.promise?t.data:Promise.resolve(t.data);return rn(s.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}$o.create=(n,e)=>new $o({type:n,typeName:at.ZodPromise,...zt(e)});class Hi extends Dt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===at.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=this._def.effect||null,r={addIssue:a=>{Ce(s,a),a.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),i.type==="preprocess"){const a=i.transform(s.data,r);if(s.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return nt;const l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?nt:l.status==="dirty"||t.value==="dirty"?fa(l.value):l});{if(t.value==="aborted")return nt;const o=this._def.schema._parseSync({data:a,path:s.path,parent:s});return o.status==="aborted"?nt:o.status==="dirty"||t.value==="dirty"?fa(o.value):o}}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,r);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?nt:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?nt:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Br(a))return nt;const o=i.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>Br(a)?Promise.resolve(i.transform(a.value,r)).then(o=>({status:t.value,value:o})):nt);Tt.assertNever(i)}}Hi.create=(n,e,t)=>new Hi({schema:n,typeName:at.ZodEffects,effect:e,...zt(t)});Hi.createWithPreprocess=(n,e,t)=>new Hi({schema:e,effect:{type:"preprocess",transform:n},typeName:at.ZodEffects,...zt(t)});class Yn extends Dt{_parse(e){return this._getType(e)===je.undefined?rn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(n,e)=>new Yn({innerType:n,typeName:at.ZodOptional,...zt(e)});class qi extends Dt{_parse(e){return this._getType(e)===je.null?rn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}qi.create=(n,e)=>new qi({innerType:n,typeName:at.ZodNullable,...zt(e)});class Ho extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===je.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ho.create=(n,e)=>new Ho({innerType:n,typeName:at.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...zt(e)});class qo extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Lo(i)?i.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Jn(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Jn(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}qo.create=(n,e)=>new qo({innerType:n,typeName:at.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...zt(e)});class Bu extends Dt{_parse(e){if(this._getType(e)!==je.nan){const s=this._getOrReturnCtx(e);return Ce(s,{code:ze.invalid_type,expected:je.nan,received:s.parsedType}),nt}return{status:"valid",value:e.data}}}Bu.create=n=>new Bu({typeName:at.ZodNaN,...zt(n)});class Op extends Dt{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class jd extends Dt{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?nt:r.status==="dirty"?(t.dirty(),fa(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?nt:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(e,t){return new jd({in:e,out:t,typeName:at.ZodPipeline})}}class Xo extends Dt{_parse(e){const t=this._def.innerType._parse(e),s=i=>(Br(i)&&(i.value=Object.freeze(i.value)),i);return Lo(t)?t.then(i=>s(i)):s(t)}unwrap(){return this._def.innerType}}Xo.create=(n,e)=>new Xo({innerType:n,typeName:at.ZodReadonly,...zt(e)});var at;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(at||(at={}));const V=gi.create,pe=Nr.create,is=Ic.create,Vd=Rc.create;yi.create;const Et=An.create,_e=as.create;Uo.create;const xp=Fd.create;Fo.create;const YM=Vi.create,KM=jo.create,Gt=Vo.create,us=$i.create;$o.create;Yn.create;qi.create;const ZM=us(["ok","error"]),QM=_e({type:us(["error","warning"]),message:V()}),JM=_e({kind:V(),data:Vd()}),eg=_e({input:V(),proposed:V(),validated:is(),executed:V().optional()}),Sp=_e({status:ZM,rendered:V(),renderedErr:V().optional(),model:JM.optional(),errors:Et(QM).optional(),trace:eg.optional()}),tg=us(["data","err","status"]),sg=_e({shellCommands:is(),hiddenInput:is().optional(),color:is().optional(),fileDelivery:is().optional(),localFilesystem:is().optional()}),ng=_e({type:Gt("attach"),protocolVersion:pe().int(),token:V(),session:V().optional(),capabilities:sg.optional()}),ig=_e({type:Gt("execute"),id:V(),line:V(),instrument:is().optional()}),rg=_e({type:Gt("cancel"),id:V()}),ag=_e({type:Gt("complete"),id:V(),prefix:V()}),og=_e({type:Gt("promptAnswer"),promptId:V(),answer:V()}),lg=_e({type:Gt("promptError"),promptId:V(),reason:V()}),cg=_e({type:Gt("pipeResult"),pipeId:V(),output:V()}),dg=_e({type:Gt("pipeError"),pipeId:V(),reason:V()}),ug=_e({type:Gt("shellResult"),shellId:V(),exitCode:pe().int()}),hg=_e({type:Gt("shellError"),shellId:V(),reason:V()}),fg=_e({type:Gt("editResult"),editId:V(),content:V(),changed:is()}),pg=_e({type:Gt("editError"),editId:V(),reason:V()}),mg=_e({type:Gt("deliverResult"),deliverId:V(),location:V(),bytes:pe().nonnegative()}),Mg=_e({type:Gt("deliverError"),deliverId:V(),reason:V()}),gg=_e({address:V(),modelKind:V().optional(),groupId:V(),paneId:V()}),Ap=_e({type:Gt("regard"),regard:gg}),bg=_e({type:Gt("watch"),subject:V()}),zg=_e({type:Gt("unwatch"),subject:V()}),_g=["live","settled","stale"],wg=us(_g),yg=_e({type:Gt("watched"),subject:V(),state:wg}),vg=_e({type:Gt("numbered"),id:pe(),source:V(),rows:pe(),handles:Et(_e({kind:V(),ordinal:pe(),address:V()}))});xp("type",[ng,ig,rg,ag,og,lg,cg,dg,ug,hg,fg,pg,mg,Mg,Ap,bg,zg]);const Og=_e({type:Gt("attached"),session:V(),protocolVersion:pe().int(),stack:_e({chell:V(),calypso:V(),build:V(),brasa:V().optional(),chili:V().optional(),salsa:V().optional(),cumin:V().optional()}).optional(),hostControl:Et(V()).optional()}),xg=_e({type:Gt("result"),id:V(),envelopes:Et(Sp)}),Sg=_e({type:Gt("complete"),id:V(),prefix:V(),candidates:Et(V())}),Ag=_e({type:Gt("output"),id:V(),channel:tg,chunk:V()}),Eg=us(zM).catch("task"),Dg=us(_M).catch(void 0),Ig=us(wM).catch("working"),Tg=us(yM).catch(void 0),Gg=us(vM).catch("unknown"),Rg=_e({type:Gt("progress"),id:V(),operation:Eg,kind:Dg.optional(),phase:Ig,label:V().optional(),itemId:V().optional(),current:pe().nonnegative().optional(),total:pe().nonnegative().optional(),percent:pe().min(0).max(100).optional(),unit:Tg.optional(),status:Gg.optional(),path:V().optional()}),Bg=_e({type:Gt("session"),surface:V(),envelope:Sp}),Ng=_e({type:Gt("error"),id:V().optional(),reason:V()}),Cg=["text","secret","confirm","path"],Pg=us(Cg).catch("text"),Wg=_e({anchor:V().optional(),wantsDirectory:is(),suggest:V().optional()}),Lg=_e({type:Gt("prompt"),promptId:V(),message:V(),hidden:is(),wants:Pg.optional(),path:Wg.optional(),commit:V().optional()});function kg(n){return n.wants!==void 0?n.wants:n.hidden===!0?"secret":"text"}const Ug=_e({user:V(),uri:V(),cwd:V(),pacsserver:V().nullable(),physicalMode:is(),lastExitCode:pe(),lastCommandDurationMs:pe(),procWarmup:_e({loaded:pe(),total:pe().optional(),restored:is().optional(),state:us(gM).optional(),sweeping:is().optional(),feed:_e({id:pe(),loaded:pe(),total:pe(),failed:V().optional()}).optional(),feeds:Et(_e({id:pe(),loaded:pe(),total:pe(),failed:V().optional()})).optional(),arrived:Et(pe()).optional(),landed:Et(_e({id:pe(),title:V().default(""),jobs:pe(),status:V(),chain:Et(V()),groups:Et(_e({plugin:V(),count:pe(),errored:pe().default(0),status:V(),parent:pe().nullable()})).default([])})).optional(),roster:us(["delta","full"]).optional()}).optional(),procIndex:_e({jobs:pe(),feeds:pe()}).optional(),warmupFailures:Et(_e({label:V(),message:V()})).optional()}),Fg=_e({type:Gt("promptline"),context:Ug}),jg=_e({type:Gt("pipe"),pipeId:V(),command:V(),input:V()}),Vg=_e({type:Gt("shell"),shellId:V(),command:V()}),$g=_e({type:Gt("edit"),editId:V(),content:V(),extension:V().optional()}),Hg=_e({type:Gt("deliver"),deliverId:V(),path:V(),filename:V(),destination:V().optional(),size:pe().nonnegative().optional(),contentType:V().optional()}),qg=_e({type:Gt("telemetry"),index:_e({jobs:pe(),feeds:pe()}),lane:_e({running:_e({line:V(),sinceMs:pe(),surface:V()}).nullable(),waiting:pe()}).optional(),cube:_e({msPerPage:pe(),samples:pe()}).optional(),state:_e({running:pe(),runningFeeds:pe(),scheduled:pe(),errored:pe(),erroredFeeds:pe()}).optional()}),Ep=xp("type",[Og,xg,Sg,Ag,Rg,Bg,Ng,Lg,Fg,qg,jg,Vg,$g,Hg,Ap,yg,vg]);new Set(Ep.options.map(n=>n.shape.type.value));function Xg(n){return n.issues.map(e=>{const t=e.path.join(".");return t?`${t}: ${e.message}`:e.message}).join("; ")}function Yg(n,e){const t=n.safeParse(e);return t.success?{ok:!0,value:t.data}:{ok:!1,error:Xg(t.error)}}function Kg(n){return Yg(Ep,n)}const Dp=_e({id:V(),label:V(),parentIds:Et(V()),joinParentIds:Et(V())}),Zg=_e({name:V(),value:Vd()}),Qg=Dp.extend({pluginName:V(),pluginVersion:V().optional(),arguments:Et(Zg).optional()}),Cc=_e({name:V(),pipelineId:pe().optional(),nodes:Et(Qg)}),Jg=["created","waiting","scheduled","started","registeringFiles","finishedSuccessfully","finishedWithError","cancelled","unknown"],Ip=us(Jg).catch("unknown"),eb=_e({count:pe(),done:pe(),error:pe(),running:pe(),other:pe(),anomalies:Et(_e({id:V(),status:Ip})).optional()}),tb=_e({computeSeconds:pe().optional(),dataBytes:pe().optional()}),sb=Dp.extend({instanceId:pe(),pluginName:V(),pluginVersion:V().optional(),status:Ip,vfsPath:V(),metrics:tb.optional(),tally:eb.optional(),computeResource:V().optional()}),Pc=_e({feedId:pe(),feedName:V(),nodes:Et(sb)}),nb=_e({feedId:pe(),loaded:pe(),total:pe(),failed:V().optional()}),bi={pipelineDiagram:"pipeline.diagram",feedDag:"feed.dag",feedIndexing:"feed.indexing"},ib=_e({id:pe(),title:V(),owner:V(),status:V(),createdAt:V(),sizeBytes:pe().optional(),wallSeconds:pe().optional(),jobsDone:pe().optional(),jobsTotal:pe().optional(),jobsErrored:pe().optional()}),Tp=_e({feeds:Et(ib)}),Gp="feed.list",rb=_e({plugin:V(),count:pe(),errored:pe().default(0),status:V(),parent:pe().nullable()}),ab=_e({id:pe(),title:V().default(""),jobs:pe(),status:V(),chain:Et(V()),groups:Et(rb).default([])}),Rp=_e({feeds:Et(ab),whole:is()}),Bp="proc.universe",ob=_e({name:V(),type:V(),optional:is(),default:Vd().optional(),help:V().optional(),flag:V()}),lb=_e({id:pe().optional(),name:V(),version:V(),type:V(),title:V().optional(),description:V().optional(),authors:V().optional(),documentation:V().optional(),category:V().optional(),parameters:Et(ob),command:V().optional()}),cb="plugin.info",db=_e({seriesUID:V(),description:V(),modality:V(),fileCount:pe().optional(),vfsPath:V().optional(),pulled:is().optional(),pulledFiles:pe().optional(),folderPath:V().optional()}),ub=_e({studyUID:V().optional(),server:V().optional(),vfsPath:V().optional(),description:V(),patientName:V(),patientId:V(),date:V(),modalities:V(),accession:V(),series:Et(db)}),Np=_e({replayed:is(),answeredAt:V()}),hb=["found","none","unasked"],fb=us(hb).catch("unasked"),pb=_e({patientId:V(),server:V().optional(),patientName:V().optional(),status:fb,studyCount:pe(),seriesCount:pe(),queryId:pe().optional(),provenance:Np.optional(),error:V().optional()}),mb=_e({queryId:pe(),vfsPath:V(),pacsName:V(),expression:V(),studies:Et(ub),provenance:Np.optional(),patients:Et(pb).optional()}),Mb=_e({id:pe(),identifier:V(),active:is()}),gb=_e({servers:Et(Mb)}),bb="pacs.servers",zb="pacs.query";function _b(n){return`pacs:patient:${n.server??"-"}:${n.patientId}`}const wb=["patient","study","series","image","equipment","meta","private","other"],Cp=us(wb).catch("other"),Pp=KM(()=>_e({tag:V(),name:V(),vr:V(),value:V(),group:Cp,phi:is(),decoded:V().optional(),items:Et(Et(Pp)).optional()})),yb=_e({tag:V(),name:V(),vr:V(),group:Cp,phi:is(),distinct:pe(),first:V(),last:V(),values:Et(_e({path:V(),value:V().nullable()}))}),Nu=_e({path:V(),subject:us(["file","folder"]),read:pe(),of:pe(),refused:Et(V()),constant:Et(Pp),varying:Et(yb)}),vb=_e({rows:pe(),columns:pe(),pixelSpacing:YM([pe(),pe()]).optional(),sliceThickness:pe().optional(),spacingBetweenSlices:pe().optional()}),Cu=_e({path:V(),seriesInstanceUID:V().optional(),studyInstanceUID:V().optional(),modality:V(),seriesDescription:V(),seriesNumber:pe().optional(),instances:pe(),frames:pe(),order:us(["filename","unknown"]),geometry:vb.optional(),transferSyntax:_e({uid:V(),name:V().optional()}).optional(),bytes:pe(),header:V(),files:Et(V()),annotations:Et(V())}),Ga={tags:"dicom.tags",series:"dicom.series"},Ob=_e({path:V(),target:us(["series","volume"]),force:is().optional(),startAt:pe().int().positive().optional()}),xb={view:"image.view"},Sb=_e({state:us(["cold","warming","current"]),loaded:pe(),total:pe()});_e({user:V(),surface:V(),feeds:_e({total:pe(),own:pe(),shared:pe(),public:pe()}),jobs:_e({total:pe(),finished:pe(),errored:pe(),cancelled:pe(),running:pe(),scheduled:pe()}),failureRate:pe().nullable(),index:Sb,fortune:V()});const $d="185",Ab=0,Pu=1,Eb=2,So=1,Db=2,pa=3,vi=0,Us=1,Hn=2,Kn=0,ji=1,Ci=2,Wu=3,Lu=4,Ib=5,Pi=100,Tb=101,Gb=102,Rb=103,Bb=104,Nb=200,Cb=201,Pb=202,Wb=203,Wc=204,Lc=205,Lb=206,kb=207,Ub=208,Fb=209,jb=210,Vb=211,$b=212,Hb=213,qb=214,kc=0,Uc=1,Fc=2,Cr=3,jc=4,Vc=5,$c=6,Hc=7,Wp=0,Xb=1,Yb=2,En=0,Lp=1,kp=2,Up=3,Fp=4,jp=5,Vp=6,$p=7,Hp=300,Xi=301,Pr=302,Dl=303,Il=304,pl=306,qc=1e3,Xn=1001,Xc=1002,ws=1003,Kb=1004,Ra=1005,Es=1006,Tl=1007,Ui=1008,qs=1009,qp=1010,Xp=1011,xa=1012,Hd=1013,In=1014,Mn=1015,ei=1016,qd=1017,Xd=1018,Sa=1020,Yp=35902,Kp=35899,Zp=1021,Qp=1022,gn=1023,ti=1026,Fi=1027,Yd=1028,Kd=1029,Yi=1030,Zd=1031,Qd=1033,Ao=33776,Eo=33777,Do=33778,Io=33779,Yc=35840,Kc=35841,Zc=35842,Qc=35843,Jc=36196,ed=37492,td=37496,sd=37488,nd=37489,Yo=37490,id=37491,rd=37808,ad=37809,od=37810,ld=37811,cd=37812,dd=37813,ud=37814,hd=37815,fd=37816,pd=37817,md=37818,Md=37819,gd=37820,bd=37821,zd=36492,_d=36494,wd=36495,yd=36283,vd=36284,Ko=36285,Od=36286,Zb=3200,xd=0,Qb=1,Mi="",en="srgb",Zo="srgb-linear",Qo="linear",Ut="srgb",ir=7680,ku=519,Jb=512,ez=513,tz=514,Jd=515,sz=516,nz=517,eu=518,iz=519,Sd=35044,Uu="300 es",Sn=2e3,Aa=2001;function rz(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Jo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function az(){const n=Jo("canvas");return n.style.display="block",n}const Fu={};function el(...n){const e="THREE."+n.shift();console.log(e,...n)}function Jp(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Qe(...n){n=Jp(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function Ot(...n){n=Jp(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Tr(...n){const e=n.join(" ");e in Fu||(Fu[e]=!0,Qe(...n))}function oz(n,e,t){return new Promise(function(s,i){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:s()}}setTimeout(r,t)})}const lz={[kc]:Uc,[Fc]:$c,[jc]:Hc,[Cr]:Vc,[Uc]:kc,[$c]:Fc,[Hc]:jc,[Vc]:Cr};class Zi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const i=s[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){e.target=this;const i=s.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const Os=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Gl=Math.PI/180,Ad=180/Math.PI;function _i(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Os[n&255]+Os[n>>8&255]+Os[n>>16&255]+Os[n>>24&255]+"-"+Os[e&255]+Os[e>>8&255]+"-"+Os[e>>16&15|64]+Os[e>>24&255]+"-"+Os[t&63|128]+Os[t>>8&255]+"-"+Os[t>>16&255]+Os[t>>24&255]+Os[s&255]+Os[s>>8&255]+Os[s>>16&255]+Os[s>>24&255]).toLowerCase()}function St(n,e,t){return Math.max(e,Math.min(t,n))}function cz(n,e){return(n%e+e)%e}function Rl(n,e,t){return(1-t)*n+t*e}function On(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Ft(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const zu=class zu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(St(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*s-a*i+e.x,this.y=r*i+a*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};zu.prototype.isVector2=!0;let Je=zu;class Qi{constructor(e=0,t=0,s=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=s,this._w=i}static slerpFlat(e,t,s,i,r,a,o){let l=s[i+0],c=s[i+1],d=s[i+2],h=s[i+3],u=r[a+0],p=r[a+1],M=r[a+2],_=r[a+3];if(h!==_||l!==u||c!==p||d!==M){let m=l*u+c*p+d*M+h*_;m<0&&(u=-u,p=-p,M=-M,_=-_,m=-m);let f=1-o;if(m<.9995){const S=Math.acos(m),v=Math.sin(S);f=Math.sin(f*S)/v,o=Math.sin(o*S)/v,l=l*f+u*o,c=c*f+p*o,d=d*f+M*o,h=h*f+_*o}else{l=l*f+u*o,c=c*f+p*o,d=d*f+M*o,h=h*f+_*o;const S=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=S,c*=S,d*=S,h*=S}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,s,i,r,a){const o=s[i],l=s[i+1],c=s[i+2],d=s[i+3],h=r[a],u=r[a+1],p=r[a+2],M=r[a+3];return e[t]=o*M+d*h+l*p-c*u,e[t+1]=l*M+d*u+c*h-o*p,e[t+2]=c*M+d*p+o*u-l*h,e[t+3]=d*M-o*h-l*u-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(s/2),d=o(i/2),h=o(r/2),u=l(s/2),p=l(i/2),M=l(r/2);switch(a){case"XYZ":this._x=u*d*h+c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h-u*p*M;break;case"YXZ":this._x=u*d*h+c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h+u*p*M;break;case"ZXY":this._x=u*d*h-c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h-u*p*M;break;case"ZYX":this._x=u*d*h-c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h+u*p*M;break;case"YZX":this._x=u*d*h+c*p*M,this._y=c*p*h+u*d*M,this._z=c*d*M-u*p*h,this._w=c*d*h-u*p*M;break;case"XZY":this._x=u*d*h-c*p*M,this._y=c*p*h-u*d*M,this._z=c*d*M+u*p*h,this._w=c*d*h+u*p*M;break;default:Qe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,i=Math.sin(s);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],u=s+o+h;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(d-l)*p,this._y=(r-c)*p,this._z=(a-i)*p}else if(s>o&&s>h){const p=2*Math.sqrt(1+s-o-h);this._w=(d-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(r+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-s-h);this._w=(r-c)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+d)/p}else{const p=2*Math.sqrt(1+h-s-o);this._w=(a-i)/p,this._x=(r+c)/p,this._y=(l+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<1e-8?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(St(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const i=Math.min(1,t/s);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=s*d+a*o+i*c-r*l,this._y=i*d+a*l+r*o-s*c,this._z=r*d+a*c+s*l-i*o,this._w=a*d-s*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){let s=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(s=-s,i=-i,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,t=Math.sin(t*c)/d,this._x=this._x*l+s*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+s*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const _u=class _u{constructor(e=0,t=0,s=0){this.x=e,this.y=t,this.z=s}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ju.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ju.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*s+r[6]*i,this.y=r[1]*t+r[4]*s+r[7]*i,this.z=r[2]*t+r[5]*s+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*s+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*s+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*s+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,s=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*s),d=2*(o*t-r*i),h=2*(r*s-a*t);return this.x=t+l*c+a*h-o*d,this.y=s+l*d+o*c-r*h,this.z=i+l*h+r*d-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*s+r[8]*i,this.y=r[1]*t+r[5]*s+r[9]*i,this.z=r[2]*t+r[6]*s+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-s*l,this.z=s*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Bl.copy(this).projectOnVector(e),this.sub(Bl)}reflect(e){return this.sub(Bl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(St(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return t*t+s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){const i=Math.sin(t)*e;return this.x=i*Math.sin(s),this.y=Math.cos(t)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};_u.prototype.isVector3=!0;let P=_u;const Bl=new P,ju=new Qi,wu=class wu{constructor(e,t,s,i,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,i,r,a,o,l,c)}set(e,t,s,i,r,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=r,d[5]=l,d[6]=s,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,a=s[0],o=s[3],l=s[6],c=s[1],d=s[4],h=s[7],u=s[2],p=s[5],M=s[8],_=i[0],m=i[3],f=i[6],S=i[1],v=i[4],z=i[7],O=i[2],x=i[5],G=i[8];return r[0]=a*_+o*S+l*O,r[3]=a*m+o*v+l*x,r[6]=a*f+o*z+l*G,r[1]=c*_+d*S+h*O,r[4]=c*m+d*v+h*x,r[7]=c*f+d*z+h*G,r[2]=u*_+p*S+M*O,r[5]=u*m+p*v+M*x,r[8]=u*f+p*z+M*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-s*r*d+s*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,u=o*l-d*r,p=c*r-a*l,M=t*h+s*u+i*p;if(M===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/M;return e[0]=h*_,e[1]=(i*c-d*s)*_,e[2]=(o*s-i*a)*_,e[3]=u*_,e[4]=(d*t-i*l)*_,e[5]=(i*r-o*t)*_,e[6]=p*_,e[7]=(s*l-c*t)*_,e[8]=(a*t-s*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(s*l,s*c,-s*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Tr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Nl.makeScale(e,t)),this}rotate(e){return Tr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Nl.makeRotation(-e)),this}translate(e,t){return Tr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Nl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<9;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};wu.prototype.isMatrix3=!0;let lt=wu;const Nl=new lt,Vu=new lt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$u=new lt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function dz(){const n={enabled:!0,workingColorSpace:Zo,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ut&&(i.r=Zn(i.r),i.g=Zn(i.g),i.b=Zn(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ut&&(i.r=Gr(i.r),i.g=Gr(i.g),i.b=Gr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Mi?Qo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Tr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Tr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],s=[.3127,.329];return n.define({[Zo]:{primaries:e,whitePoint:s,transfer:Qo,toXYZ:Vu,fromXYZ:$u,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:en},outputColorSpaceConfig:{drawingBufferColorSpace:en}},[en]:{primaries:e,whitePoint:s,transfer:Ut,toXYZ:Vu,fromXYZ:$u,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:en}}}),n}const xt=dz();function Zn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gr(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let rr;class uz{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{rr===void 0&&(rr=Jo("canvas")),rr.width=e.width,rr.height=e.height;const i=rr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),s=rr}return s.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Jo("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const i=s.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Zn(r[a]/255)*255;return s.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let s=0;s<t.length;s++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[s]=Math.floor(Zn(t[s]/255)*255):t[s]=Zn(t[s]);return{data:t,width:e.width,height:e.height}}else return Qe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hz=0;class tu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hz++}),this.uuid=_i(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Cl(i[a].image)):r.push(Cl(i[a]))}else r=Cl(i);s.url=r}return t||(e.images[this.uuid]=s),s}}function Cl(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?uz.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Qe("Texture: Unable to serialize Texture."),{})}let fz=0;const Pl=new P;class Is extends Zi{constructor(e=Is.DEFAULT_IMAGE,t=Is.DEFAULT_MAPPING,s=Xn,i=Xn,r=Es,a=Ui,o=gn,l=qs,c=Is.DEFAULT_ANISOTROPY,d=Mi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fz++}),this.uuid=_i(),this.name="",this.source=new tu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Je(0,0),this.repeat=new Je(1,1),this.center=new Je(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Pl).x}get height(){return this.source.getSize(Pl).y}get depth(){return this.source.getSize(Pl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const s=e[t];if(s===void 0){Qe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Qe(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[t]=s}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Hp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qc:e.x=e.x-Math.floor(e.x);break;case Xn:e.x=e.x<0?0:1;break;case Xc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qc:e.y=e.y-Math.floor(e.y);break;case Xn:e.y=e.y<0?0:1;break;case Xc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Is.DEFAULT_IMAGE=null;Is.DEFAULT_MAPPING=Hp;Is.DEFAULT_ANISOTROPY=1;const yu=class yu{constructor(e=0,t=0,s=0,i=1){this.x=e,this.y=t,this.z=s,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*s+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*s+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*s+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*s+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,i,r;const l=e.elements,c=l[0],d=l[4],h=l[8],u=l[1],p=l[5],M=l[9],_=l[2],m=l[6],f=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-_)<.01&&Math.abs(M-m)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+_)<.1&&Math.abs(M+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,z=(p+1)/2,O=(f+1)/2,x=(d+u)/4,G=(h+_)/4,b=(M+m)/4;return v>z&&v>O?v<.01?(s=0,i=.707106781,r=.707106781):(s=Math.sqrt(v),i=x/s,r=G/s):z>O?z<.01?(s=.707106781,i=0,r=.707106781):(i=Math.sqrt(z),s=x/i,r=b/i):O<.01?(s=.707106781,i=.707106781,r=0):(r=Math.sqrt(O),s=G/r,i=b/r),this.set(s,i,r,t),this}let S=Math.sqrt((m-M)*(m-M)+(h-_)*(h-_)+(u-d)*(u-d));return Math.abs(S)<.001&&(S=1),this.x=(m-M)/S,this.y=(h-_)/S,this.z=(u-d)/S,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this.w=St(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this.w=St(this.w,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(St(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this.w=e.w+(t.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};yu.prototype.isVector4=!0;let Jt=yu;class pz extends Zi{constructor(e=1,t=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Es,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},s),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=s.depth,this.scissor=new Jt(0,0,e,t),this.scissorTest=!1,this.viewport=new Jt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:s.depth},r=new Is(i),a=s.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview,this.useArrayDepthTexture=s.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Es,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,s=1){if(this.width!==e||this.height!==t||this.depth!==s){this.width=e,this.height=t,this.depth=s;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=s,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,s=e.textures.length;t<s;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new tu(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Dn extends pz{constructor(e=1,t=1,s={}){super(e,t,s),this.isWebGLRenderTarget=!0}}class em extends Is{constructor(e=null,t=1,s=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:s,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=Xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mz extends Is{constructor(e=null,t=1,s=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:s,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=Xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const fl=class fl{constructor(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m)}set(e,t,s,i,r,a,o,l,c,d,h,u,p,M,_,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=s,f[12]=i,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=d,f[10]=h,f[14]=u,f[3]=p,f[7]=M,f[11]=_,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new fl().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,s=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),a=1/ar.setFromMatrixColumn(e,2).length();return t[0]=s[0]*i,t[1]=s[1]*i,t[2]=s[2]*i,t[3]=0,t[4]=s[4]*r,t[5]=s[5]*r,t[6]=s[6]*r,t[7]=0,t[8]=s[8]*a,t[9]=s[9]*a,t[10]=s[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,s=e.x,i=e.y,r=e.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),c=Math.sin(i),d=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const u=a*d,p=a*h,M=o*d,_=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=p+M*c,t[5]=u-_*c,t[9]=-o*l,t[2]=_-u*c,t[6]=M+p*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*d,p=l*h,M=c*d,_=c*h;t[0]=u+_*o,t[4]=M*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=p*o-M,t[6]=_+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,p=l*h,M=c*d,_=c*h;t[0]=u-_*o,t[4]=-a*h,t[8]=M+p*o,t[1]=p+M*o,t[5]=a*d,t[9]=_-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*d,p=a*h,M=o*d,_=o*h;t[0]=l*d,t[4]=M*c-p,t[8]=u*c+_,t[1]=l*h,t[5]=_*c+u,t[9]=p*c-M,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*c,M=o*l,_=o*c;t[0]=l*d,t[4]=_-u*h,t[8]=M*h+p,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=p*h+M,t[10]=u-_*h}else if(e.order==="XZY"){const u=a*l,p=a*c,M=o*l,_=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+_,t[5]=a*d,t[9]=p*h-M,t[2]=M*h-p,t[6]=o*d,t[10]=_*h+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Mz,e,gz)}lookAt(e,t,s){const i=this.elements;return js.subVectors(e,t),js.lengthSq()===0&&(js.z=1),js.normalize(),ai.crossVectors(s,js),ai.lengthSq()===0&&(Math.abs(s.z)===1?js.x+=1e-4:js.z+=1e-4,js.normalize(),ai.crossVectors(s,js)),ai.normalize(),Ba.crossVectors(js,ai),i[0]=ai.x,i[4]=Ba.x,i[8]=js.x,i[1]=ai.y,i[5]=Ba.y,i[9]=js.y,i[2]=ai.z,i[6]=Ba.z,i[10]=js.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,a=s[0],o=s[4],l=s[8],c=s[12],d=s[1],h=s[5],u=s[9],p=s[13],M=s[2],_=s[6],m=s[10],f=s[14],S=s[3],v=s[7],z=s[11],O=s[15],x=i[0],G=i[4],b=i[8],T=i[12],N=i[1],C=i[5],W=i[9],Q=i[13],se=i[2],H=i[6],ee=i[10],J=i[14],ue=i[3],he=i[7],Se=i[11],be=i[15];return r[0]=a*x+o*N+l*se+c*ue,r[4]=a*G+o*C+l*H+c*he,r[8]=a*b+o*W+l*ee+c*Se,r[12]=a*T+o*Q+l*J+c*be,r[1]=d*x+h*N+u*se+p*ue,r[5]=d*G+h*C+u*H+p*he,r[9]=d*b+h*W+u*ee+p*Se,r[13]=d*T+h*Q+u*J+p*be,r[2]=M*x+_*N+m*se+f*ue,r[6]=M*G+_*C+m*H+f*he,r[10]=M*b+_*W+m*ee+f*Se,r[14]=M*T+_*Q+m*J+f*be,r[3]=S*x+v*N+z*se+O*ue,r[7]=S*G+v*C+z*H+O*he,r[11]=S*b+v*W+z*ee+O*Se,r[15]=S*T+v*Q+z*J+O*be,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],u=e[10],p=e[14],M=e[3],_=e[7],m=e[11],f=e[15],S=l*p-c*u,v=o*p-c*h,z=o*u-l*h,O=a*p-c*d,x=a*u-l*d,G=a*h-o*d;return t*(_*S-m*v+f*z)-s*(M*S-m*O+f*x)+i*(M*v-_*O+f*G)-r*(M*z-_*x+m*G)}determinantAffine(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],d=e[10];return t*(a*d-o*c)-s*(r*d-o*l)+i*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],u=e[10],p=e[11],M=e[12],_=e[13],m=e[14],f=e[15],S=t*o-s*a,v=t*l-i*a,z=t*c-r*a,O=s*l-i*o,x=s*c-r*o,G=i*c-r*l,b=d*_-h*M,T=d*m-u*M,N=d*f-p*M,C=h*m-u*_,W=h*f-p*_,Q=u*f-p*m,se=S*Q-v*W+z*C+O*N-x*T+G*b;if(se===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/se;return e[0]=(o*Q-l*W+c*C)*H,e[1]=(i*W-s*Q-r*C)*H,e[2]=(_*G-m*x+f*O)*H,e[3]=(u*x-h*G-p*O)*H,e[4]=(l*N-a*Q-c*T)*H,e[5]=(t*Q-i*N+r*T)*H,e[6]=(m*z-M*G-f*v)*H,e[7]=(d*G-u*z+p*v)*H,e[8]=(a*W-o*N+c*b)*H,e[9]=(s*N-t*W-r*b)*H,e[10]=(M*x-_*z+f*S)*H,e[11]=(h*z-d*x-p*S)*H,e[12]=(o*T-a*C-l*b)*H,e[13]=(t*C-s*T+i*b)*H,e[14]=(_*v-M*O-m*S)*H,e[15]=(d*O-h*v+u*S)*H,this}scale(e){const t=this.elements,s=e.x,i=e.y,r=e.z;return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,i))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),i=Math.sin(t),r=1-s,a=e.x,o=e.y,l=e.z,c=r*a,d=r*o;return this.set(c*a+s,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+s,d*l-i*a,0,c*l-i*o,d*l+i*a,r*l*l+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,i,r,a){return this.set(1,s,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,s){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,d=a+a,h=o+o,u=r*c,p=r*d,M=r*h,_=a*d,m=a*h,f=o*h,S=l*c,v=l*d,z=l*h,O=s.x,x=s.y,G=s.z;return i[0]=(1-(_+f))*O,i[1]=(p+z)*O,i[2]=(M-v)*O,i[3]=0,i[4]=(p-z)*x,i[5]=(1-(u+f))*x,i[6]=(m+S)*x,i[7]=0,i[8]=(M+v)*G,i[9]=(m-S)*G,i[10]=(1-(u+_))*G,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,s){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return s.set(1,1,1),t.identity(),this;let a=ar.set(i[0],i[1],i[2]).length();const o=ar.set(i[4],i[5],i[6]).length(),l=ar.set(i[8],i[9],i[10]).length();r<0&&(a=-a),dn.copy(this);const c=1/a,d=1/o,h=1/l;return dn.elements[0]*=c,dn.elements[1]*=c,dn.elements[2]*=c,dn.elements[4]*=d,dn.elements[5]*=d,dn.elements[6]*=d,dn.elements[8]*=h,dn.elements[9]*=h,dn.elements[10]*=h,t.setFromRotationMatrix(dn),s.x=a,s.y=o,s.z=l,this}makePerspective(e,t,s,i,r,a,o=Sn,l=!1){const c=this.elements,d=2*r/(t-e),h=2*r/(s-i),u=(t+e)/(t-e),p=(s+i)/(s-i);let M,_;if(l)M=r/(a-r),_=a*r/(a-r);else if(o===Sn)M=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===Aa)M=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=M,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,s,i,r,a,o=Sn,l=!1){const c=this.elements,d=2/(t-e),h=2/(s-i),u=-(t+e)/(t-e),p=-(s+i)/(s-i);let M,_;if(l)M=1/(a-r),_=a/(a-r);else if(o===Sn)M=-2/(a-r),_=-(a+r)/(a-r);else if(o===Aa)M=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=h,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=M,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<16;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}};fl.prototype.isMatrix4=!0;let Rt=fl;const ar=new P,dn=new Rt,Mz=new P(0,0,0),gz=new P(1,1,1),ai=new P,Ba=new P,js=new P,Hu=new Rt,qu=new Qi;class Oi{constructor(e=0,t=0,s=0,i=Oi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,i=this._order){return this._x=e,this._y=t,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],u=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-St(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(St(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-St(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(St(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-d,p),this._y=0);break;default:Qe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return Hu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Hu,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qu.setFromEuler(this),this.setFromQuaternion(qu,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Oi.DEFAULT_ORDER="XYZ";class su{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let bz=0;const Xu=new P,or=new Qi,Bn=new Rt,Na=new P,Kr=new P,zz=new P,_z=new Qi,Yu=new P(1,0,0),Ku=new P(0,1,0),Zu=new P(0,0,1),Qu={type:"added"},wz={type:"removed"},lr={type:"childadded",child:null},Wl={type:"childremoved",child:null};class es extends Zi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:bz++}),this.uuid=_i(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=es.DEFAULT_UP.clone();const e=new P,t=new Oi,s=new Qi,i=new P(1,1,1);function r(){s.setFromEuler(t,!1)}function a(){t.setFromQuaternion(s,void 0,!1)}t._onChange(r),s._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Rt},normalMatrix:{value:new lt}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=es.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new su,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(Yu,e)}rotateY(e){return this.rotateOnAxis(Ku,e)}rotateZ(e){return this.rotateOnAxis(Zu,e)}translateOnAxis(e,t){return Xu.copy(e).applyQuaternion(this.quaternion),this.position.add(Xu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yu,e)}translateY(e){return this.translateOnAxis(Ku,e)}translateZ(e){return this.translateOnAxis(Zu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Bn.copy(this.matrixWorld).invert())}lookAt(e,t,s){e.isVector3?Na.copy(e):Na.set(e,t,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Kr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Bn.lookAt(Kr,Na,this.up):Bn.lookAt(Na,Kr,this.up),this.quaternion.setFromRotationMatrix(Bn),i&&(Bn.extractRotation(i.matrixWorld),or.setFromRotationMatrix(Bn),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ot("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Qu),lr.child=e,this.dispatchEvent(lr),lr.child=null):Ot("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(wz),Wl.child=e,this.dispatchEvent(Wl),Wl.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Bn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Bn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Bn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Qu),lr.child=e,this.dispatchEvent(lr),lr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let s=0,i=this.children.length;s<i;s++){const a=this.children[s].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,s=[]){this[e]===t&&s.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,e,zz),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,_z,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,s=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*s-r[8]*i,r[13]+=s-r[1]*t-r[5]*s-r[9]*i,r[14]+=i-r[2]*t-r[6]*s-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].updateMatrixWorld(e)}updateWorldMatrix(e,t,s=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,s)}}toJSON(e){const t=e===void 0||typeof e=="string",s={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),u=a(e.skeletons),p=a(e.animations),M=a(e.nodes);o.length>0&&(s.geometries=o),l.length>0&&(s.materials=l),c.length>0&&(s.textures=c),d.length>0&&(s.images=d),h.length>0&&(s.shapes=h),u.length>0&&(s.skeletons=u),p.length>0&&(s.animations=p),M.length>0&&(s.nodes=M)}return s.object=i,s;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let s=0;s<e.children.length;s++){const i=e.children[s];this.add(i.clone())}return this}}es.DEFAULT_UP=new P(0,1,0);es.DEFAULT_MATRIX_AUTO_UPDATE=!0;es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ma extends es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const yz={type:"move"};class Ll{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ma,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ma,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ma,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const s of e.hand.values())this._getHandJoint(t,s)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,s){let i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,s),f=this._getHandJoint(c,_);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],u=d.position.distanceTo(h.position),p=.02,M=.005;c.inputState.pinching&&u>p+M?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-M&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,s),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(yz)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const s=new ma;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[t.jointName]=s,e.add(s)}return e.joints[t.jointName]}}const tm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},oi={h:0,s:0,l:0},Ca={h:0,s:0,l:0};function kl(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Ze{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=en){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xt.colorSpaceToWorking(this,t),this}setRGB(e,t,s,i=xt.workingColorSpace){return this.r=e,this.g=t,this.b=s,xt.colorSpaceToWorking(this,i),this}setHSL(e,t,s,i=xt.workingColorSpace){if(e=cz(e,1),t=St(t,0,1),s=St(s,0,1),t===0)this.r=this.g=this.b=s;else{const r=s<=.5?s*(1+t):s+t-s*t,a=2*s-r;this.r=kl(a,r,e+1/3),this.g=kl(a,r,e),this.b=kl(a,r,e-1/3)}return xt.colorSpaceToWorking(this,i),this}setStyle(e,t=en){function s(r){r!==void 0&&parseFloat(r)<1&&Qe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Qe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Qe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=en){const s=tm[e.toLowerCase()];return s!==void 0?this.setHex(s,t):Qe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=en){return xt.workingToColorSpace(xs.copy(this),e),Math.round(St(xs.r*255,0,255))*65536+Math.round(St(xs.g*255,0,255))*256+Math.round(St(xs.b*255,0,255))}getHexString(e=en){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xt.workingColorSpace){xt.workingToColorSpace(xs.copy(this),t);const s=xs.r,i=xs.g,r=xs.b,a=Math.max(s,i,r),o=Math.min(s,i,r);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case s:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-s)/h+2;break;case r:l=(s-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=xt.workingColorSpace){return xt.workingToColorSpace(xs.copy(this),t),e.r=xs.r,e.g=xs.g,e.b=xs.b,e}getStyle(e=en){xt.workingToColorSpace(xs.copy(this),e);const t=xs.r,s=xs.g,i=xs.b;return e!==en?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(e,t,s){return this.getHSL(oi),this.setHSL(oi.h+e,oi.s+t,oi.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(oi),e.getHSL(Ca);const s=Rl(oi.h,Ca.h,t),i=Rl(oi.s,Ca.s,t),r=Rl(oi.l,Ca.l,t);return this.setHSL(s,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,s=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*s+r[6]*i,this.g=r[1]*t+r[4]*s+r[7]*i,this.b=r[2]*t+r[5]*s+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xs=new Ze;Ze.NAMES=tm;class vz extends es{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Oi,this.environmentIntensity=1,this.environmentRotation=new Oi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const un=new P,Nn=new P,Ul=new P,Cn=new P,cr=new P,dr=new P,Ju=new P,Fl=new P,jl=new P,Vl=new P,$l=new Jt,Hl=new Jt,ql=new Jt;class nn{constructor(e=new P,t=new P,s=new P){this.a=e,this.b=t,this.c=s}static getNormal(e,t,s,i){i.subVectors(s,t),un.subVectors(e,t),i.cross(un);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,s,i,r){un.subVectors(i,t),Nn.subVectors(s,t),Ul.subVectors(e,t);const a=un.dot(un),o=un.dot(Nn),l=un.dot(Ul),c=Nn.dot(Nn),d=Nn.dot(Ul),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const u=1/h,p=(c*l-o*d)*u,M=(a*d-o*l)*u;return r.set(1-p-M,M,p)}static containsPoint(e,t,s,i){return this.getBarycoord(e,t,s,i,Cn)===null?!1:Cn.x>=0&&Cn.y>=0&&Cn.x+Cn.y<=1}static getInterpolation(e,t,s,i,r,a,o,l){return this.getBarycoord(e,t,s,i,Cn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Cn.x),l.addScaledVector(a,Cn.y),l.addScaledVector(o,Cn.z),l)}static getInterpolatedAttribute(e,t,s,i,r,a){return $l.setScalar(0),Hl.setScalar(0),ql.setScalar(0),$l.fromBufferAttribute(e,t),Hl.fromBufferAttribute(e,s),ql.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector($l,r.x),a.addScaledVector(Hl,r.y),a.addScaledVector(ql,r.z),a}static isFrontFacing(e,t,s,i){return un.subVectors(s,t),Nn.subVectors(e,t),un.cross(Nn).dot(i)<0}set(e,t,s){return this.a.copy(e),this.b.copy(t),this.c.copy(s),this}setFromPointsAndIndices(e,t,s,i){return this.a.copy(e[t]),this.b.copy(e[s]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,s,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return un.subVectors(this.c,this.b),Nn.subVectors(this.a,this.b),un.cross(Nn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,s,i,r){return nn.getInterpolation(e,this.a,this.b,this.c,t,s,i,r)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const s=this.a,i=this.b,r=this.c;let a,o;cr.subVectors(i,s),dr.subVectors(r,s),Fl.subVectors(e,s);const l=cr.dot(Fl),c=dr.dot(Fl);if(l<=0&&c<=0)return t.copy(s);jl.subVectors(e,i);const d=cr.dot(jl),h=dr.dot(jl);if(d>=0&&h<=d)return t.copy(i);const u=l*h-d*c;if(u<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(s).addScaledVector(cr,a);Vl.subVectors(e,r);const p=cr.dot(Vl),M=dr.dot(Vl);if(M>=0&&p<=M)return t.copy(r);const _=p*c-l*M;if(_<=0&&c>=0&&M<=0)return o=c/(c-M),t.copy(s).addScaledVector(dr,o);const m=d*M-p*h;if(m<=0&&h-d>=0&&p-M>=0)return Ju.subVectors(r,i),o=(h-d)/(h-d+(p-M)),t.copy(i).addScaledVector(Ju,o);const f=1/(m+_+u);return a=_*f,o=u*f,t.copy(s).addScaledVector(cr,a).addScaledVector(dr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ji{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(hn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,s=e.count;t<s;t++)this.expandByPoint(hn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=hn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const s=e.geometry;if(s!==void 0){const r=s.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,hn):hn.fromBufferAttribute(r,a),hn.applyMatrix4(e.matrixWorld),this.expandByPoint(hn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Pa.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Pa.copy(s.boundingBox)),Pa.applyMatrix4(e.matrixWorld),this.union(Pa)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,hn),hn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Zr),Wa.subVectors(this.max,Zr),ur.subVectors(e.a,Zr),hr.subVectors(e.b,Zr),fr.subVectors(e.c,Zr),li.subVectors(hr,ur),ci.subVectors(fr,hr),Ei.subVectors(ur,fr);let t=[0,-li.z,li.y,0,-ci.z,ci.y,0,-Ei.z,Ei.y,li.z,0,-li.x,ci.z,0,-ci.x,Ei.z,0,-Ei.x,-li.y,li.x,0,-ci.y,ci.x,0,-Ei.y,Ei.x,0];return!Xl(t,ur,hr,fr,Wa)||(t=[1,0,0,0,1,0,0,0,1],!Xl(t,ur,hr,fr,Wa))?!1:(La.crossVectors(li,ci),t=[La.x,La.y,La.z],Xl(t,ur,hr,fr,Wa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Pn=[new P,new P,new P,new P,new P,new P,new P,new P],hn=new P,Pa=new Ji,ur=new P,hr=new P,fr=new P,li=new P,ci=new P,Ei=new P,Zr=new P,Wa=new P,La=new P,Di=new P;function Xl(n,e,t,s,i){for(let r=0,a=n.length-3;r<=a;r+=3){Di.fromArray(n,r);const o=i.x*Math.abs(Di.x)+i.y*Math.abs(Di.y)+i.z*Math.abs(Di.z),l=e.dot(Di),c=t.dot(Di),d=s.dot(Di);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const rs=new P,ka=new Je;let Oz=0;class Ds extends Zi{constructor(e,t,s=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Oz++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=s,this.usage=Sd,this.updateRanges=[],this.gpuType=Mn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[s+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,s=this.count;t<s;t++)ka.fromBufferAttribute(this,t),ka.applyMatrix3(e),this.setXY(t,ka.x,ka.y);else if(this.itemSize===3)for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyMatrix3(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}applyMatrix4(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyMatrix4(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.applyNormalMatrix(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)rs.fromBufferAttribute(this,t),rs.transformDirection(e),this.setXYZ(t,rs.x,rs.y,rs.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let s=this.array[e*this.itemSize+t];return this.normalized&&(s=On(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=Ft(s,this.array)),this.array[e*this.itemSize+t]=s,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=On(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=On(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=On(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=On(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ft(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array)),this.array[e+0]=t,this.array[e+1]=s,this}setXYZ(e,t,s,i){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this}setXYZW(e,t,s,i,r){return e*=this.itemSize,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array),r=Ft(r,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Sd&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class sm extends Ds{constructor(e,t,s){super(new Uint16Array(e),t,s)}}class nm extends Ds{constructor(e,t,s){super(new Uint32Array(e),t,s)}}class Ht extends Ds{constructor(e,t,s){super(new Float32Array(e),t,s)}}const xz=new Ji,Qr=new P,Yl=new P;class er{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const s=this.center;t!==void 0?s.copy(t):xz.setFromPoints(e).getCenter(s);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,s.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const s=this.center.distanceToSquared(e);return t.copy(e),s>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Qr.subVectors(e,this.center);const t=Qr.lengthSq();if(t>this.radius*this.radius){const s=Math.sqrt(t),i=(s-this.radius)*.5;this.center.addScaledVector(Qr,i/s),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Yl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qr.copy(e.center).add(Yl)),this.expandByPoint(Qr.copy(e.center).sub(Yl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Sz=0;const Zs=new Rt,Kl=new es,pr=new P,Vs=new Ji,Jr=new Ji,gs=new P;class os extends Zi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sz++}),this.uuid=_i(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rz(e)?nm:sm)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,s=0){this.groups.push({start:e,count:t,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const r=new lt().getNormalMatrix(e);s.applyNormalMatrix(r),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Zs.makeRotationFromQuaternion(e),this.applyMatrix4(Zs),this}rotateX(e){return Zs.makeRotationX(e),this.applyMatrix4(Zs),this}rotateY(e){return Zs.makeRotationY(e),this.applyMatrix4(Zs),this}rotateZ(e){return Zs.makeRotationZ(e),this.applyMatrix4(Zs),this}translate(e,t,s){return Zs.makeTranslation(e,t,s),this.applyMatrix4(Zs),this}scale(e,t,s){return Zs.makeScale(e,t,s),this.applyMatrix4(Zs),this}lookAt(e){return Kl.lookAt(e),Kl.updateMatrix(),this.applyMatrix4(Kl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pr).negate(),this.translate(pr.x,pr.y,pr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const s=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];s.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ht(s,3))}else{const s=Math.min(e.length,t.count);for(let i=0;i<s;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&Qe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ot("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let s=0,i=t.length;s<i;s++){const r=t[s];Vs.setFromBufferAttribute(r),this.morphTargetsRelative?(gs.addVectors(this.boundingBox.min,Vs.min),this.boundingBox.expandByPoint(gs),gs.addVectors(this.boundingBox.max,Vs.max),this.boundingBox.expandByPoint(gs)):(this.boundingBox.expandByPoint(Vs.min),this.boundingBox.expandByPoint(Vs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ot('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new er);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ot("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const s=this.boundingSphere.center;if(Vs.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Jr.setFromBufferAttribute(o),this.morphTargetsRelative?(gs.addVectors(Vs.min,Jr.min),Vs.expandByPoint(gs),gs.addVectors(Vs.max,Jr.max),Vs.expandByPoint(gs)):(Vs.expandByPoint(Jr.min),Vs.expandByPoint(Jr.max))}Vs.getCenter(s);let i=0;for(let r=0,a=e.count;r<a;r++)gs.fromBufferAttribute(e,r),i=Math.max(i,s.distanceToSquared(gs));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)gs.fromBufferAttribute(o,c),l&&(pr.fromBufferAttribute(e,c),gs.add(pr)),i=Math.max(i,s.distanceToSquared(gs))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ot('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ot("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==s.count)&&(a=new Ds(new Float32Array(4*s.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let b=0;b<s.count;b++)o[b]=new P,l[b]=new P;const c=new P,d=new P,h=new P,u=new Je,p=new Je,M=new Je,_=new P,m=new P;function f(b,T,N){c.fromBufferAttribute(s,b),d.fromBufferAttribute(s,T),h.fromBufferAttribute(s,N),u.fromBufferAttribute(r,b),p.fromBufferAttribute(r,T),M.fromBufferAttribute(r,N),d.sub(c),h.sub(c),p.sub(u),M.sub(u);const C=1/(p.x*M.y-M.x*p.y);isFinite(C)&&(_.copy(d).multiplyScalar(M.y).addScaledVector(h,-p.y).multiplyScalar(C),m.copy(h).multiplyScalar(p.x).addScaledVector(d,-M.x).multiplyScalar(C),o[b].add(_),o[T].add(_),o[N].add(_),l[b].add(m),l[T].add(m),l[N].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let b=0,T=S.length;b<T;++b){const N=S[b],C=N.start,W=N.count;for(let Q=C,se=C+W;Q<se;Q+=3)f(e.getX(Q+0),e.getX(Q+1),e.getX(Q+2))}const v=new P,z=new P,O=new P,x=new P;function G(b){O.fromBufferAttribute(i,b),x.copy(O);const T=o[b];v.copy(T),v.sub(O.multiplyScalar(O.dot(T))).normalize(),z.crossVectors(x,T);const C=z.dot(l[b])<0?-1:1;a.setXYZW(b,v.x,v.y,v.z,C)}for(let b=0,T=S.length;b<T;++b){const N=S[b],C=N.start,W=N.count;for(let Q=C,se=C+W;Q<se;Q+=3)G(e.getX(Q+0)),G(e.getX(Q+1)),G(e.getX(Q+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==t.count)s=new Ds(new Float32Array(t.count*3),3),this.setAttribute("normal",s);else for(let u=0,p=s.count;u<p;u++)s.setXYZ(u,0,0,0);const i=new P,r=new P,a=new P,o=new P,l=new P,c=new P,d=new P,h=new P;if(e)for(let u=0,p=e.count;u<p;u+=3){const M=e.getX(u+0),_=e.getX(u+1),m=e.getX(u+2);i.fromBufferAttribute(t,M),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),d.subVectors(a,r),h.subVectors(i,r),d.cross(h),o.fromBufferAttribute(s,M),l.fromBufferAttribute(s,_),c.fromBufferAttribute(s,m),o.add(d),l.add(d),c.add(d),s.setXYZ(M,o.x,o.y,o.z),s.setXYZ(_,l.x,l.y,l.z),s.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,p=t.count;u<p;u+=3)i.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),d.subVectors(a,r),h.subVectors(i,r),d.cross(h),s.setXYZ(u+0,d.x,d.y,d.z),s.setXYZ(u+1,d.x,d.y,d.z),s.setXYZ(u+2,d.x,d.y,d.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,s=e.count;t<s;t++)gs.fromBufferAttribute(e,t),gs.normalize(),e.setXYZ(t,gs.x,gs.y,gs.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,u=new c.constructor(l.length*d);let p=0,M=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?p=l[_]*o.data.stride+o.offset:p=l[_]*d;for(let f=0;f<d;f++)u[M++]=c[p++]}return new Ds(u,d,h)}if(this.index===null)return Qe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new os,s=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,s);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let d=0,h=c.length;d<h;d++){const u=c[d],p=e(u,s);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const s=this.attributes;for(const l in s){const c=s[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,u=c.length;h<u;h++){const p=c[h];d.push(p.toJSON(e.data))}d.length>0&&(i[l]=d,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const s=e.index;s!==null&&this.setIndex(s.clone());const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const r=e.morphAttributes;for(const c in r){const d=[],h=r[c];for(let u=0,p=h.length;u<p;u++)d.push(h[u].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Az{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sd,this.updateRanges=[],this.version=0,this.uuid=_i()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[s+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=_i()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(t,this.stride);return s.setUsage(this.usage),s}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=_i()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Rs=new P;class tl{constructor(e,t,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,s=this.data.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.applyMatrix4(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.applyNormalMatrix(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)Rs.fromBufferAttribute(this,t),Rs.transformDirection(e),this.setXYZ(t,Rs.x,Rs.y,Rs.z);return this}getComponent(e,t){let s=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(s=On(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=Ft(s,this.array)),this.data.array[e*this.data.stride+this.offset+t]=s,this}setX(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ft(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=On(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=On(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=On(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=On(t,this.array)),t}setXY(e,t,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this}setXYZ(e,t,s,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=i,this}setXYZW(e,t,s,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ft(t,this.array),s=Ft(s,this.array),i=Ft(i,this.array),r=Ft(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){el("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Ds(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new tl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){el("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Ez=0;class Tn extends Zi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ez++}),this.uuid=_i(),this.name="",this.type="Material",this.blending=ji,this.side=vi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wc,this.blendDst=Lc,this.blendEquation=Pi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ze(0,0,0),this.blendAlpha=0,this.depthFunc=Cr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ku,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ir,this.stencilZFail=ir,this.stencilZPass=ir,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const s=e[t];if(s===void 0){Qe(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Qe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector2&&s&&s.isVector2||i&&i.isEuler&&s&&s.isEuler||i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[t]=s}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==ji&&(s.blending=this.blending),this.side!==vi&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==Wc&&(s.blendSrc=this.blendSrc),this.blendDst!==Lc&&(s.blendDst=this.blendDst),this.blendEquation!==Pi&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==Cr&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ku&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ir&&(s.stencilFail=this.stencilFail),this.stencilZFail!==ir&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==ir&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.allowOverride===!1&&(s.allowOverride=!1),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(s.textures=r),a.length>0&&(s.images=a)}return s}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ze().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),this.normalScale=new Je().fromArray(s)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Je().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let s=null;if(t!==null){const i=t.length;s=new Array(i);for(let r=0;r!==i;++r)s[r]=t[r].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ed extends Tn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ze(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let mr;const ea=new P,Mr=new P,gr=new P,br=new Je,ta=new Je,im=new Rt,Ua=new P,sa=new P,Fa=new P,eh=new Je,Zl=new Je,th=new Je;class sh extends es{constructor(e=new Ed){if(super(),this.isSprite=!0,this.type="Sprite",mr===void 0){mr=new os;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),s=new Az(t,5);mr.setIndex([0,1,2,0,2,3]),mr.setAttribute("position",new tl(s,3,0,!1)),mr.setAttribute("uv",new tl(s,2,3,!1))}this.geometry=mr,this.material=e,this.center=new Je(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ot('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Mr.setFromMatrixScale(this.matrixWorld),im.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),gr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Mr.multiplyScalar(-gr.z);const s=this.material.rotation;let i,r;s!==0&&(r=Math.cos(s),i=Math.sin(s));const a=this.center;ja(Ua.set(-.5,-.5,0),gr,a,Mr,i,r),ja(sa.set(.5,-.5,0),gr,a,Mr,i,r),ja(Fa.set(.5,.5,0),gr,a,Mr,i,r),eh.set(0,0),Zl.set(1,0),th.set(1,1);let o=e.ray.intersectTriangle(Ua,sa,Fa,!1,ea);if(o===null&&(ja(sa.set(-.5,.5,0),gr,a,Mr,i,r),Zl.set(0,1),o=e.ray.intersectTriangle(Ua,Fa,sa,!1,ea),o===null))return;const l=e.ray.origin.distanceTo(ea);l<e.near||l>e.far||t.push({distance:l,point:ea.clone(),uv:nn.getInterpolation(ea,Ua,sa,Fa,eh,Zl,th,new Je),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ja(n,e,t,s,i,r){br.subVectors(n,t).addScalar(.5).multiply(s),i!==void 0?(ta.x=r*br.x-i*br.y,ta.y=i*br.x+r*br.y):ta.copy(br),n.copy(e),n.x+=ta.x,n.y+=ta.y,n.applyMatrix4(im)}const Wn=new P,Ql=new P,Va=new P,di=new P,Jl=new P,$a=new P,ec=new P;class ml{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const s=t.dot(this.direction);return s<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,s,i){Ql.copy(e).add(t).multiplyScalar(.5),Va.copy(t).sub(e).normalize(),di.copy(this.origin).sub(Ql);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Va),o=di.dot(this.direction),l=-di.dot(Va),c=di.lengthSq(),d=Math.abs(1-a*a);let h,u,p,M;if(d>0)if(h=a*l-o,u=a*o-l,M=r*d,h>=0)if(u>=-M)if(u<=M){const _=1/d;h*=_,u*=_,p=h*(h+a*u+2*o)+u*(a*h+u+2*l)+c}else u=r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;else u=-r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;else u<=-M?(h=Math.max(0,-(-a*r+o)),u=h>0?-r:Math.min(Math.max(-r,-l),r),p=-h*h+u*(u+2*l)+c):u<=M?(h=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(h=Math.max(0,-(a*r+o)),u=h>0?r:Math.min(Math.max(-r,-l),r),p=-h*h+u*(u+2*l)+c);else u=a>0?-r:r,h=Math.max(0,-(a*u+o)),p=-h*h+u*(u+2*l)+c;return s&&s.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Ql).addScaledVector(Va,u),p}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);const s=Wn.dot(this.direction),i=Wn.dot(Wn)-s*s,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=s-a,l=s+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/t;return s>=0?s:null}intersectPlane(e,t){const s=this.distanceToPlane(e);return s===null?null:this.at(s,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let s,i,r,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(s=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(s=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),d>=0?(r=(e.min.y-u.y)*d,a=(e.max.y-u.y)*d):(r=(e.max.y-u.y)*d,a=(e.min.y-u.y)*d),s>a||r>i||((r>s||isNaN(s))&&(s=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-u.z)*h,l=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,l=(e.min.z-u.z)*h),s>l||o>i)||((o>s||s!==s)&&(s=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(s>=0?s:i,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,s,i,r){Jl.subVectors(t,e),$a.subVectors(s,e),ec.crossVectors(Jl,$a);let a=this.direction.dot(ec),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;di.subVectors(this.origin,e);const l=o*this.direction.dot($a.crossVectors(di,$a));if(l<0)return null;const c=o*this.direction.dot(Jl.cross(di));if(c<0||l+c>a)return null;const d=-o*di.dot(ec);return d<0?null:this.at(d/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class nu extends Tn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Oi,this.combine=Wp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const nh=new Rt,Ii=new ml,Ha=new er,ih=new P,qa=new P,Xa=new P,Ya=new P,tc=new P,Ka=new P,rh=new P,Za=new P;class Ss extends es{constructor(e=new os,t=new nu){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const s=this.geometry,i=s.attributes.position,r=s.morphAttributes.position,a=s.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Ka.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const d=o[l],h=r[l];d!==0&&(tc.fromBufferAttribute(h,e),a?Ka.addScaledVector(tc,d):Ka.addScaledVector(tc.sub(t),d))}t.add(Ka)}return t}raycast(e,t){const s=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),Ha.copy(s.boundingSphere),Ha.applyMatrix4(r),Ii.copy(e.ray).recast(e.near),!(Ha.containsPoint(Ii.origin)===!1&&(Ii.intersectSphere(Ha,ih)===null||Ii.origin.distanceToSquared(ih)>(e.far-e.near)**2))&&(nh.copy(r).invert(),Ii.copy(e.ray).applyMatrix4(nh),!(s.boundingBox!==null&&Ii.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,t,Ii)))}_computeIntersections(e,t,s){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,d=r.attributes.uv1,h=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let M=0,_=u.length;M<_;M++){const m=u[M],f=a[m.materialIndex],S=Math.max(m.start,p.start),v=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let z=S,O=v;z<O;z+=3){const x=o.getX(z),G=o.getX(z+1),b=o.getX(z+2);i=Qa(this,f,e,s,c,d,h,x,G,b),i&&(i.faceIndex=Math.floor(z/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const M=Math.max(0,p.start),_=Math.min(o.count,p.start+p.count);for(let m=M,f=_;m<f;m+=3){const S=o.getX(m),v=o.getX(m+1),z=o.getX(m+2);i=Qa(this,a,e,s,c,d,h,S,v,z),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let M=0,_=u.length;M<_;M++){const m=u[M],f=a[m.materialIndex],S=Math.max(m.start,p.start),v=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let z=S,O=v;z<O;z+=3){const x=z,G=z+1,b=z+2;i=Qa(this,f,e,s,c,d,h,x,G,b),i&&(i.faceIndex=Math.floor(z/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const M=Math.max(0,p.start),_=Math.min(l.count,p.start+p.count);for(let m=M,f=_;m<f;m+=3){const S=m,v=m+1,z=m+2;i=Qa(this,a,e,s,c,d,h,S,v,z),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function Dz(n,e,t,s,i,r,a,o){let l;if(e.side===Us?l=s.intersectTriangle(a,r,i,!0,o):l=s.intersectTriangle(i,r,a,e.side===vi,o),l===null)return null;Za.copy(o),Za.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Za);return c<t.near||c>t.far?null:{distance:c,point:Za.clone(),object:n}}function Qa(n,e,t,s,i,r,a,o,l,c){n.getVertexPosition(o,qa),n.getVertexPosition(l,Xa),n.getVertexPosition(c,Ya);const d=Dz(n,e,t,s,qa,Xa,Ya,rh);if(d){const h=new P;nn.getBarycoord(rh,qa,Xa,Ya,h),i&&(d.uv=nn.getInterpolatedAttribute(i,o,l,c,h,new Je)),r&&(d.uv1=nn.getInterpolatedAttribute(r,o,l,c,h,new Je)),a&&(d.normal=nn.getInterpolatedAttribute(a,o,l,c,h,new P),d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new P,materialIndex:0};nn.getNormal(qa,Xa,Ya,u.normal),d.face=u,d.barycoord=h}return d}class rm extends Is{constructor(e=null,t=1,s=1,i,r,a,o,l,c=ws,d=ws,h,u){super(null,a,o,l,c,d,i,r,h,u),this.isDataTexture=!0,this.image={data:e,width:t,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class _a extends Ds{constructor(e,t,s,i=1){super(e,t,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const zr=new Rt,ah=new Rt,Ja=[],oh=new Ji,Iz=new Rt,na=new Ss,ia=new er;class lh extends Ss{constructor(e,t,s){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new _a(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<s;i++)this.setMatrixAt(i,Iz)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ji),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,zr),oh.copy(e.boundingBox).applyMatrix4(zr),this.boundingBox.union(oh)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new er),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,zr),ia.copy(e.boundingSphere).applyMatrix4(zr),this.boundingSphere.union(ia)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const s=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=s.length+1,a=e*r+1;for(let o=0;o<s.length;o++)s[o]=i[a+o]}raycast(e,t){const s=this.matrixWorld,i=this.count;if(na.geometry=this.geometry,na.material=this.material,na.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ia.copy(this.boundingSphere),ia.applyMatrix4(s),e.ray.intersectsSphere(ia)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,zr),ah.multiplyMatrices(s,zr),na.matrixWorld=ah,na.raycast(e,Ja);for(let a=0,o=Ja.length;a<o;a++){const l=Ja[a];l.instanceId=r,l.object=this,t.push(l)}Ja.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new _a(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const s=t.morphTargetInfluences,i=s.length+1;this.morphTexture===null&&(this.morphTexture=new rm(new Float32Array(i*this.count),i,this.count,Yd,Mn));const r=this.morphTexture.source.data.data;let a=0;for(let c=0;c<s.length;c++)a+=s[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;return r[l]=o,r.set(s,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const sc=new P,Tz=new P,Gz=new lt;class pi{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,i){return this.normal.set(e,t,s),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){const i=sc.subVectors(s,t).cross(Tz.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,s=!0){const i=e.delta(sc),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return s===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return t<0&&s>0||s<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||Gz.getNormalMatrix(e),i=this.coplanarPoint(sc).applyMatrix4(e),r=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ti=new er,Rz=new Je(.5,.5),eo=new P;class iu{constructor(e=new pi,t=new pi,s=new pi,i=new pi,r=new pi,a=new pi){this.planes=[e,t,s,i,r,a]}set(e,t,s,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(s),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let s=0;s<6;s++)t[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,t=Sn,s=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],d=r[4],h=r[5],u=r[6],p=r[7],M=r[8],_=r[9],m=r[10],f=r[11],S=r[12],v=r[13],z=r[14],O=r[15];if(i[0].setComponents(c-a,p-d,f-M,O-S).normalize(),i[1].setComponents(c+a,p+d,f+M,O+S).normalize(),i[2].setComponents(c+o,p+h,f+_,O+v).normalize(),i[3].setComponents(c-o,p-h,f-_,O-v).normalize(),s)i[4].setComponents(l,u,m,z).normalize(),i[5].setComponents(c-l,p-u,f-m,O-z).normalize();else if(i[4].setComponents(c-l,p-u,f-m,O-z).normalize(),t===Sn)i[5].setComponents(c+l,p+u,f+m,O+z).normalize();else if(t===Aa)i[5].setComponents(l,u,m,z).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ti.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ti.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ti)}intersectsSprite(e){Ti.center.set(0,0,0);const t=Rz.distanceTo(e.center);return Ti.radius=.7071067811865476+t,Ti.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ti)}intersectsSphere(e){const t=this.planes,s=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(s)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let s=0;s<6;s++){const i=t[s];if(eo.x=i.normal.x>0?e.max.x:e.min.x,eo.y=i.normal.y>0?e.max.y:e.min.y,eo.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(eo)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let s=0;s<6;s++)if(t[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Wi extends Tn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const sl=new P,nl=new P,ch=new Rt,ra=new ml,to=new er,nc=new P,dh=new P;class Dd extends es{constructor(e=new os,t=new Wi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[0];for(let i=1,r=t.count;i<r;i++)sl.fromBufferAttribute(t,i-1),nl.fromBufferAttribute(t,i),s[i]=s[i-1],s[i]+=sl.distanceTo(nl);e.setAttribute("lineDistance",new Ht(s,1))}else Qe("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),to.copy(s.boundingSphere),to.applyMatrix4(i),to.radius+=r,e.ray.intersectsSphere(to)===!1)return;ch.copy(i).invert(),ra.copy(e.ray).applyMatrix4(ch);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=s.index,u=s.attributes.position;if(d!==null){const p=Math.max(0,a.start),M=Math.min(d.count,a.start+a.count);for(let _=p,m=M-1;_<m;_+=c){const f=d.getX(_),S=d.getX(_+1),v=so(this,e,ra,l,f,S,_);v&&t.push(v)}if(this.isLineLoop){const _=d.getX(M-1),m=d.getX(p),f=so(this,e,ra,l,_,m,M-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),M=Math.min(u.count,a.start+a.count);for(let _=p,m=M-1;_<m;_+=c){const f=so(this,e,ra,l,_,_+1,_);f&&t.push(f)}if(this.isLineLoop){const _=so(this,e,ra,l,M-1,p,M-1);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function so(n,e,t,s,i,r,a){const o=n.geometry.attributes.position;if(sl.fromBufferAttribute(o,i),nl.fromBufferAttribute(o,r),t.distanceSqToSegment(sl,nl,nc,dh)>s)return;nc.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(nc);if(!(c<e.near||c>e.far))return{distance:c,point:dh.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const uh=new P,hh=new P;class fh extends Dd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,s=[];for(let i=0,r=t.count;i<r;i+=2)uh.fromBufferAttribute(t,i),hh.fromBufferAttribute(t,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+uh.distanceTo(hh);e.setAttribute("lineDistance",new Ht(s,1))}else Qe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Bz extends Tn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const ph=new Rt,Id=new ml,no=new er,io=new P;class Nz extends es{constructor(e=new os,t=new Bz){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),no.copy(s.boundingSphere),no.applyMatrix4(i),no.radius+=r,e.ray.intersectsSphere(no)===!1)return;ph.copy(i).invert(),Id.copy(e.ray).applyMatrix4(ph);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=s.index,h=s.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let M=u,_=p;M<_;M++){const m=c.getX(M);io.fromBufferAttribute(h,m),mh(io,m,l,i,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let M=u,_=p;M<_;M++)io.fromBufferAttribute(h,M),mh(io,M,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function mh(n,e,t,s,i,r,a){const o=Id.distanceSqToPoint(n);if(o<t){const l=new P;Id.closestPointToPoint(n,l),l.applyMatrix4(s);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class am extends Is{constructor(e=[],t=Xi,s,i,r,a,o,l,c,d){super(e,t,s,i,r,a,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cz extends Is{constructor(e,t,s,i,r,a,o,l,c){super(e,t,s,i,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Wr extends Is{constructor(e,t,s=In,i,r,a,o=ws,l=ws,c,d=ti,h=1){if(d!==ti&&d!==Fi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:h};super(u,i,r,a,o,l,d,s,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new tu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Pz extends Wr{constructor(e,t=In,s=Xi,i,r,a=ws,o=ws,l,c=ti){const d={width:e,height:e,depth:1},h=[d,d,d,d,d,d];super(e,e,t,s,i,r,a,o,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class om extends Is{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Da extends os{constructor(e=1,t=1,s=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:s,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],d=[],h=[];let u=0,p=0;M("z","y","x",-1,-1,s,t,e,a,r,0),M("z","y","x",1,-1,s,t,-e,a,r,1),M("x","z","y",1,1,e,s,t,i,a,2),M("x","z","y",1,-1,e,s,-t,i,a,3),M("x","y","z",1,-1,e,t,s,i,r,4),M("x","y","z",-1,-1,e,t,-s,i,r,5),this.setIndex(l),this.setAttribute("position",new Ht(c,3)),this.setAttribute("normal",new Ht(d,3)),this.setAttribute("uv",new Ht(h,2));function M(_,m,f,S,v,z,O,x,G,b,T){const N=z/G,C=O/b,W=z/2,Q=O/2,se=x/2,H=G+1,ee=b+1;let J=0,ue=0;const he=new P;for(let Se=0;Se<ee;Se++){const be=Se*C-Q;for(let Re=0;Re<H;Re++){const ht=Re*N-W;he[_]=ht*S,he[m]=be*v,he[f]=se,c.push(he.x,he.y,he.z),he[_]=0,he[m]=0,he[f]=x>0?1:-1,d.push(he.x,he.y,he.z),h.push(Re/G),h.push(1-Se/b),J+=1}}for(let Se=0;Se<b;Se++)for(let be=0;be<G;be++){const Re=u+be+H*Se,ht=u+be+H*(Se+1),ct=u+(be+1)+H*(Se+1),tt=u+(be+1)+H*Se;l.push(Re,ht,tt),l.push(ht,ct,tt),ue+=6}o.addGroup(p,ue,T),p+=ue,u+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Da(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class ru extends os{constructor(e=1,t=32,s=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:s,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new P,d=new Je;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,u=3;h<=t;h++,u+=3){const p=s+h/t*i;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),d.x=(a[u]/e+1)/2,d.y=(a[u+1]/e+1)/2,l.push(d.x,d.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Ht(a,3)),this.setAttribute("normal",new Ht(o,3)),this.setAttribute("uv",new Ht(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ru(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class au extends os{constructor(e=1,t=1,s=1,i=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:s,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),r=Math.floor(r);const d=[],h=[],u=[],p=[];let M=0;const _=[],m=s/2;let f=0;S(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(d),this.setAttribute("position",new Ht(h,3)),this.setAttribute("normal",new Ht(u,3)),this.setAttribute("uv",new Ht(p,2));function S(){const z=new P,O=new P;let x=0;const G=(t-e)/s;for(let b=0;b<=r;b++){const T=[],N=b/r,C=N*(t-e)+e;for(let W=0;W<=i;W++){const Q=W/i,se=Q*l+o,H=Math.sin(se),ee=Math.cos(se);O.x=C*H,O.y=-N*s+m,O.z=C*ee,h.push(O.x,O.y,O.z),z.set(H,G,ee).normalize(),u.push(z.x,z.y,z.z),p.push(Q,1-N),T.push(M++)}_.push(T)}for(let b=0;b<i;b++)for(let T=0;T<r;T++){const N=_[T][b],C=_[T+1][b],W=_[T+1][b+1],Q=_[T][b+1];(e>0||T!==0)&&(d.push(N,C,Q),x+=3),(t>0||T!==r-1)&&(d.push(C,W,Q),x+=3)}c.addGroup(f,x,0),f+=x}function v(z){const O=M,x=new Je,G=new P;let b=0;const T=z===!0?e:t,N=z===!0?1:-1;for(let W=1;W<=i;W++)h.push(0,m*N,0),u.push(0,N,0),p.push(.5,.5),M++;const C=M;for(let W=0;W<=i;W++){const se=W/i*l+o,H=Math.cos(se),ee=Math.sin(se);G.x=T*ee,G.y=m*N,G.z=T*H,h.push(G.x,G.y,G.z),u.push(0,N,0),x.x=H*.5+.5,x.y=ee*.5*N+.5,p.push(x.x,x.y),M++}for(let W=0;W<i;W++){const Q=O+W,se=C+W;z===!0?d.push(se,se+1,Q):d.push(se+1,se,Q),b+=3}c.addGroup(f,b,z===!0?1:2),f+=b}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new au(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ou extends os{constructor(e=[],t=[],s=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:s,detail:i};const r=[],a=[];o(i),c(s),d(),this.setAttribute("position",new Ht(r,3)),this.setAttribute("normal",new Ht(r.slice(),3)),this.setAttribute("uv",new Ht(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(S){const v=new P,z=new P,O=new P;for(let x=0;x<t.length;x+=3)p(t[x+0],v),p(t[x+1],z),p(t[x+2],O),l(v,z,O,S)}function l(S,v,z,O){const x=O+1,G=[];for(let b=0;b<=x;b++){G[b]=[];const T=S.clone().lerp(z,b/x),N=v.clone().lerp(z,b/x),C=x-b;for(let W=0;W<=C;W++)W===0&&b===x?G[b][W]=T:G[b][W]=T.clone().lerp(N,W/C)}for(let b=0;b<x;b++)for(let T=0;T<2*(x-b)-1;T++){const N=Math.floor(T/2);T%2===0?(u(G[b][N+1]),u(G[b+1][N]),u(G[b][N])):(u(G[b][N+1]),u(G[b+1][N+1]),u(G[b+1][N]))}}function c(S){const v=new P;for(let z=0;z<r.length;z+=3)v.x=r[z+0],v.y=r[z+1],v.z=r[z+2],v.normalize().multiplyScalar(S),r[z+0]=v.x,r[z+1]=v.y,r[z+2]=v.z}function d(){const S=new P;for(let v=0;v<r.length;v+=3){S.x=r[v+0],S.y=r[v+1],S.z=r[v+2];const z=m(S)/2/Math.PI+.5,O=f(S)/Math.PI+.5;a.push(z,1-O)}M(),h()}function h(){for(let S=0;S<a.length;S+=6){const v=a[S+0],z=a[S+2],O=a[S+4],x=Math.max(v,z,O),G=Math.min(v,z,O);x>.9&&G<.1&&(v<.2&&(a[S+0]+=1),z<.2&&(a[S+2]+=1),O<.2&&(a[S+4]+=1))}}function u(S){r.push(S.x,S.y,S.z)}function p(S,v){const z=S*3;v.x=e[z+0],v.y=e[z+1],v.z=e[z+2]}function M(){const S=new P,v=new P,z=new P,O=new P,x=new Je,G=new Je,b=new Je;for(let T=0,N=0;T<r.length;T+=9,N+=6){S.set(r[T+0],r[T+1],r[T+2]),v.set(r[T+3],r[T+4],r[T+5]),z.set(r[T+6],r[T+7],r[T+8]),x.set(a[N+0],a[N+1]),G.set(a[N+2],a[N+3]),b.set(a[N+4],a[N+5]),O.copy(S).add(v).add(z).divideScalar(3);const C=m(O);_(x,N+0,S,C),_(G,N+2,v,C),_(b,N+4,z,C)}}function _(S,v,z,O){O<0&&S.x===1&&(a[v]=S.x-1),z.x===0&&z.z===0&&(a[v]=O/2/Math.PI+.5)}function m(S){return Math.atan2(S.z,-S.x)}function f(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ou(e.vertices,e.indices,e.radius,e.detail)}}class lu extends ou{constructor(e=1,t=0){const s=(1+Math.sqrt(5))/2,i=[-1,s,0,1,s,0,-1,-s,0,1,-s,0,0,-1,s,0,1,s,0,-1,-s,0,1,-s,s,0,-1,s,0,1,-s,0,-1,-s,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lu(e.radius,e.detail)}}class Ml extends os{constructor(e=1,t=1,s=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:s,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(s),l=Math.floor(i),c=o+1,d=l+1,h=e/o,u=t/l,p=[],M=[],_=[],m=[];for(let f=0;f<d;f++){const S=f*u-a;for(let v=0;v<c;v++){const z=v*h-r;M.push(z,-S,0),_.push(0,0,1),m.push(v/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let S=0;S<o;S++){const v=S+c*f,z=S+c*(f+1),O=S+1+c*(f+1),x=S+1+c*f;p.push(v,z,x),p.push(z,O,x)}this.setIndex(p),this.setAttribute("position",new Ht(M,3)),this.setAttribute("normal",new Ht(_,3)),this.setAttribute("uv",new Ht(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ml(e.width,e.height,e.widthSegments,e.heightSegments)}}class il extends os{constructor(e=1,t=32,s=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:s,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),s=Math.max(2,Math.floor(s));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new P,u=new P,p=[],M=[],_=[],m=[];for(let f=0;f<=s;f++){const S=[],v=f/s,z=a+v*o,O=e*Math.cos(z),x=Math.sqrt(e*e-O*O);let G=0;f===0&&a===0?G=.5/t:f===s&&l===Math.PI&&(G=-.5/t);for(let b=0;b<=t;b++){const T=b/t,N=i+T*r;h.x=-x*Math.cos(N),h.y=O,h.z=x*Math.sin(N),M.push(h.x,h.y,h.z),u.copy(h).normalize(),_.push(u.x,u.y,u.z),m.push(T+G,1-v),S.push(c++)}d.push(S)}for(let f=0;f<s;f++)for(let S=0;S<t;S++){const v=d[f][S+1],z=d[f][S],O=d[f+1][S],x=d[f+1][S+1];(f!==0||a>0)&&p.push(v,z,x),(f!==s-1||l<Math.PI)&&p.push(z,O,x)}this.setIndex(p),this.setAttribute("position",new Ht(M,3)),this.setAttribute("normal",new Ht(_,3)),this.setAttribute("uv",new Ht(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new il(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Lr(n){const e={};for(const t in n){e[t]={};for(const s in n[t]){const i=n[t][s];if(Mh(i))i.isRenderTargetTexture?(Qe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][s]=null):e[t][s]=i.clone();else if(Array.isArray(i))if(Mh(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][s]=r}else e[t][s]=i.slice();else e[t][s]=i}}return e}function Ns(n){const e={};for(let t=0;t<n.length;t++){const s=Lr(n[t]);for(const i in s)e[i]=s[i]}return e}function Mh(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function Wz(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function lm(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:xt.workingColorSpace}const Lz={clone:Lr,merge:Ns};var kz=`void main() {
3
3
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
4
4
  }`,Uz=`void main() {
5
5
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
6
- }`;class _s extends Tn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=kz,this.fragmentShader=Uz,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Lr(e.uniforms),this.uniformsGroups=Wz(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const s={};for(const i in this.extensions)this.extensions[i]===!0&&(s[i]=!0);return Object.keys(s).length>0&&(t.extensions=s),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const s in e.uniforms){const i=e.uniforms[s];switch(this.uniforms[s]={},i.type){case"t":this.uniforms[s].value=t[i.value]||null;break;case"c":this.uniforms[s].value=new Ze().setHex(i.value);break;case"v2":this.uniforms[s].value=new Je().fromArray(i.value);break;case"v3":this.uniforms[s].value=new P().fromArray(i.value);break;case"v4":this.uniforms[s].value=new Jt().fromArray(i.value);break;case"m3":this.uniforms[s].value=new lt().fromArray(i.value);break;case"m4":this.uniforms[s].value=new Rt().fromArray(i.value);break;default:this.uniforms[s].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)this.extensions[s]=e.extensions[s];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Fz extends _s{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ln extends Tn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xd,this.normalScale=new Je(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jz extends Tn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Zb,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Vz extends Tn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class $z extends Wi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class cm extends es{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ze(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const ic=new Rt,gh=new P,bh=new P;class Hz{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Je(512,512),this.mapType=qs,this.map=null,this.mapPass=null,this.matrix=new Rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new iu,this._frameExtents=new Je(1,1),this._viewportCount=1,this._viewports=[new Jt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,s=this.matrix;gh.setFromMatrixPosition(e.matrixWorld),t.position.copy(gh),bh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bh),t.updateMatrixWorld(),ic.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ic,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Aa||t.reversedDepth?s.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(ic)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const ro=new P,ao=new Qi,_n=new P;class dm extends es{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=Sn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ro,ao,_n),_n.x===1&&_n.y===1&&_n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,ao,_n.set(1,1,1)).invert()}updateWorldMatrix(e,t,s=!1){super.updateWorldMatrix(e,t,s),this.matrixWorld.decompose(ro,ao,_n),_n.x===1&&_n.y===1&&_n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,ao,_n.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ui=new P,zh=new Je,_h=new Je;class tn extends dm{constructor(e=50,t=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ad*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Gl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ad*2*Math.atan(Math.tan(Gl*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,s){ui.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ui.x,ui.y).multiplyScalar(-e/ui.z),ui.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(ui.x,ui.y).multiplyScalar(-e/ui.z)}getViewSize(e,t){return this.getViewBounds(e,zh,_h),t.subVectors(_h,zh)}setViewOffset(e,t,s,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Gl*.5*this.fov)/this.zoom,s=2*t,i=this.aspect*s,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*s/c,i*=a.width/l,s*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class cu extends dm{constructor(e=-1,t=1,s=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=s,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,s,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=s-e,a=s+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class qz extends Hz{constructor(){super(new cu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Xz extends cm{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(es.DEFAULT_UP),this.updateMatrix(),this.target=new es,this.shadow=new qz}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Yz extends cm{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const _r=-90,wr=1;class Kz extends es{constructor(e,t,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new tn(_r,wr,e,t);i.layers=this.layers,this.add(i);const r=new tn(_r,wr,e,t);r.layers=this.layers,this.add(r);const a=new tn(_r,wr,e,t);a.layers=this.layers,this.add(a);const o=new tn(_r,wr,e,t);o.layers=this.layers,this.add(o);const l=new tn(_r,wr,e,t);l.layers=this.layers,this.add(l);const c=new tn(_r,wr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[s,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Sn)s.up.set(0,1,0),s.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Aa)s.up.set(0,-1,0),s.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,d]=this.children,h=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),M=e.xr.enabled;e.xr.enabled=!1;const _=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(s,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(s,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(s,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(s,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(s,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),s.texture.generateMipmaps=_,e.setRenderTarget(s,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(h,u,p),e.xr.enabled=M,s.texture.needsPMREMUpdate=!0}}class Zz extends tn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const wh=new Rt;class Qz{constructor(e,t,s=0,i=1/0){this.ray=new ml(e,t),this.near=s,this.far=i,this.camera=null,this.layers=new su,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ot("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return wh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(wh),this}intersectObject(e,t=!0,s=[]){return Td(e,this,s,t),s.sort(yh),s}intersectObjects(e,t=!0,s=[]){for(let i=0,r=e.length;i<r;i++)Td(e[i],this,s,t);return s.sort(yh),s}}function yh(n,e){return n.distance-e.distance}function Td(n,e,t,s){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&s===!0){const r=n.children;for(let a=0,o=r.length;a<o;a++)Td(r[a],e,t,!0)}}const vu=class vu{constructor(e,t,s,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let s=0;s<4;s++)this.elements[s]=e[s+t];return this}set(e,t,s,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=s,r[3]=i,this}};vu.prototype.isMatrix2=!0;let vh=vu;function Oh(n,e,t,s){const i=Jz(s);switch(t){case Zp:return n*e;case Yd:return n*e/i.components*i.byteLength;case Kd:return n*e/i.components*i.byteLength;case Yi:return n*e*2/i.components*i.byteLength;case Zd:return n*e*2/i.components*i.byteLength;case Qp:return n*e*3/i.components*i.byteLength;case gn:return n*e*4/i.components*i.byteLength;case Qd:return n*e*4/i.components*i.byteLength;case Ao:case Eo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Do:case Io:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kc:case Qc:return Math.max(n,16)*Math.max(e,8)/4;case Yc:case Zc:return Math.max(n,8)*Math.max(e,8)/2;case Jc:case ed:case sd:case nd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case td:case Yo:case id:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case rd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ad:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case od:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case ld:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case cd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case dd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case ud:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case hd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case fd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case pd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case md:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Md:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case gd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case bd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case zd:case _d:case wd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yd:case vd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ko:case Od:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jz(n){switch(n){case qs:case qp:return{byteLength:1,components:1};case xa:case Xp:case ei:return{byteLength:2,components:1};case qd:case Xd:return{byteLength:2,components:4};case In:case Hd:case Mn:return{byteLength:4,components:1};case Yp:case Kp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$d}}));typeof window<"u"&&(window.__THREE__?Qe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$d);function um(){let n=null,e=!1,t=null,s=null;function i(r,a){t(r,a),s=n.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&n!==null&&(s=n.requestAnimationFrame(i),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(s),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function e0(n){const e=new WeakMap;function t(o,l){const c=o.array,d=o.usage,h=c.byteLength,u=n.createBuffer();n.bindBuffer(l,u),n.bufferData(l,c,d),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function s(o,l,c){const d=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,d);else{h.sort((p,M)=>p.start-M.start);let u=0;for(let p=1;p<h.length;p++){const M=h[u],_=h[p];_.start<=M.start+M.count+1?M.count=Math.max(M.count,_.start+_.count-M.start):(++u,h[u]=_)}h.length=u+1;for(let p=0,M=h.length;p<M;p++){const _=h[p];n.bufferSubData(c,_.start*d.BYTES_PER_ELEMENT,d,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var t0=`#ifdef USE_ALPHAHASH
6
+ }`;class _s extends Tn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=kz,this.fragmentShader=Uz,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Lr(e.uniforms),this.uniformsGroups=Wz(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const s={};for(const i in this.extensions)this.extensions[i]===!0&&(s[i]=!0);return Object.keys(s).length>0&&(t.extensions=s),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const s in e.uniforms){const i=e.uniforms[s];switch(this.uniforms[s]={},i.type){case"t":this.uniforms[s].value=t[i.value]||null;break;case"c":this.uniforms[s].value=new Ze().setHex(i.value);break;case"v2":this.uniforms[s].value=new Je().fromArray(i.value);break;case"v3":this.uniforms[s].value=new P().fromArray(i.value);break;case"v4":this.uniforms[s].value=new Jt().fromArray(i.value);break;case"m3":this.uniforms[s].value=new lt().fromArray(i.value);break;case"m4":this.uniforms[s].value=new Rt().fromArray(i.value);break;default:this.uniforms[s].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)this.extensions[s]=e.extensions[s];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Fz extends _s{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ln extends Tn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xd,this.normalScale=new Je(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Oi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jz extends Tn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Zb,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Vz extends Tn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class $z extends Wi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class cm extends es{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ze(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const ic=new Rt,gh=new P,bh=new P;class Hz{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Je(512,512),this.mapType=qs,this.map=null,this.mapPass=null,this.matrix=new Rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new iu,this._frameExtents=new Je(1,1),this._viewportCount=1,this._viewports=[new Jt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,s=this.matrix;gh.setFromMatrixPosition(e.matrixWorld),t.position.copy(gh),bh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bh),t.updateMatrixWorld(),ic.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ic,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Aa||t.reversedDepth?s.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(ic)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const ro=new P,ao=new Qi,_n=new P;class dm extends es{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=Sn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ro,ao,_n),_n.x===1&&_n.y===1&&_n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,ao,_n.set(1,1,1)).invert()}updateWorldMatrix(e,t,s=!1){super.updateWorldMatrix(e,t,s),this.matrixWorld.decompose(ro,ao,_n),_n.x===1&&_n.y===1&&_n.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,ao,_n.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ui=new P,zh=new Je,_h=new Je;class tn extends dm{constructor(e=50,t=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ad*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Gl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ad*2*Math.atan(Math.tan(Gl*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,s){ui.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ui.x,ui.y).multiplyScalar(-e/ui.z),ui.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(ui.x,ui.y).multiplyScalar(-e/ui.z)}getViewSize(e,t){return this.getViewBounds(e,zh,_h),t.subVectors(_h,zh)}setViewOffset(e,t,s,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Gl*.5*this.fov)/this.zoom,s=2*t,i=this.aspect*s,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*s/c,i*=a.width/l,s*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class cu extends dm{constructor(e=-1,t=1,s=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=s,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,s,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=s-e,a=s+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class qz extends Hz{constructor(){super(new cu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Xz extends cm{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(es.DEFAULT_UP),this.updateMatrix(),this.target=new es,this.shadow=new qz}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Yz extends cm{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const _r=-90,wr=1;class Kz extends es{constructor(e,t,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new tn(_r,wr,e,t);i.layers=this.layers,this.add(i);const r=new tn(_r,wr,e,t);r.layers=this.layers,this.add(r);const a=new tn(_r,wr,e,t);a.layers=this.layers,this.add(a);const o=new tn(_r,wr,e,t);o.layers=this.layers,this.add(o);const l=new tn(_r,wr,e,t);l.layers=this.layers,this.add(l);const c=new tn(_r,wr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[s,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Sn)s.up.set(0,1,0),s.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Aa)s.up.set(0,-1,0),s.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,d]=this.children,h=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),M=e.xr.enabled;e.xr.enabled=!1;const _=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(s,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(s,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(s,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(s,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(s,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),s.texture.generateMipmaps=_,e.setRenderTarget(s,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(h,u,p),e.xr.enabled=M,s.texture.needsPMREMUpdate=!0}}class Zz extends tn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const wh=new Rt;class Qz{constructor(e,t,s=0,i=1/0){this.ray=new ml(e,t),this.near=s,this.far=i,this.camera=null,this.layers=new su,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ot("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return wh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(wh),this}intersectObject(e,t=!0,s=[]){return Td(e,this,s,t),s.sort(yh),s}intersectObjects(e,t=!0,s=[]){for(let i=0,r=e.length;i<r;i++)Td(e[i],this,s,t);return s.sort(yh),s}}function yh(n,e){return n.distance-e.distance}function Td(n,e,t,s){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&s===!0){const r=n.children;for(let a=0,o=r.length;a<o;a++)Td(r[a],e,t,!0)}}const vu=class vu{constructor(e,t,s,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let s=0;s<4;s++)this.elements[s]=e[s+t];return this}set(e,t,s,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=s,r[3]=i,this}};vu.prototype.isMatrix2=!0;let vh=vu;function Oh(n,e,t,s){const i=Jz(s);switch(t){case Zp:return n*e;case Yd:return n*e/i.components*i.byteLength;case Kd:return n*e/i.components*i.byteLength;case Yi:return n*e*2/i.components*i.byteLength;case Zd:return n*e*2/i.components*i.byteLength;case Qp:return n*e*3/i.components*i.byteLength;case gn:return n*e*4/i.components*i.byteLength;case Qd:return n*e*4/i.components*i.byteLength;case Ao:case Eo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Do:case Io:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kc:case Qc:return Math.max(n,16)*Math.max(e,8)/4;case Yc:case Zc:return Math.max(n,8)*Math.max(e,8)/2;case Jc:case ed:case sd:case nd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case td:case Yo:case id:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case rd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ad:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case od:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case ld:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case cd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case dd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case ud:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case hd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case fd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case pd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case md:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Md:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case gd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case bd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case zd:case _d:case wd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yd:case vd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ko:case Od:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jz(n){switch(n){case qs:case qp:return{byteLength:1,components:1};case xa:case Xp:case ei:return{byteLength:2,components:1};case qd:case Xd:return{byteLength:2,components:4};case In:case Hd:case Mn:return{byteLength:4,components:1};case Yp:case Kp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$d}}));typeof window<"u"&&(window.__THREE__?Qe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$d);function um(){let n=null,e=!1,t=null,s=null;function i(r,a){t(r,a),s=n.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&n!==null&&(s=n.requestAnimationFrame(i),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(s),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function e0(n){const e=new WeakMap;function t(o,l){const c=o.array,d=o.usage,h=c.byteLength,u=n.createBuffer();n.bindBuffer(l,u),n.bufferData(l,c,d),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function s(o,l,c){const d=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,d);else{h.sort((p,M)=>p.start-M.start);let u=0;for(let p=1;p<h.length;p++){const M=h[u],_=h[p];_.start<=M.start+M.count+1?M.count=Math.max(M.count,_.start+_.count-M.start):(++u,h[u]=_)}h.length=u+1;for(let p=0,M=h.length;p<M;p++){const _=h[p];n.bufferSubData(c,_.start*d.BYTES_PER_ELEMENT,d,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var t0=`#ifdef USE_ALPHAHASH
7
7
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
8
8
  #endif`,s0=`#ifdef USE_ALPHAHASH
9
9
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3669,7 +3669,7 @@ void main() {
3669
3669
  #include <tonemapping_fragment>
3670
3670
  #include <colorspace_fragment>
3671
3671
  #include <fog_fragment>
3672
- }`,Mt={alphahash_fragment:t0,alphahash_pars_fragment:s0,alphamap_fragment:n0,alphamap_pars_fragment:i0,alphatest_fragment:r0,alphatest_pars_fragment:a0,aomap_fragment:o0,aomap_pars_fragment:l0,batching_pars_vertex:c0,batching_vertex:d0,begin_vertex:u0,beginnormal_vertex:h0,bsdfs:f0,iridescence_fragment:p0,bumpmap_pars_fragment:m0,clipping_planes_fragment:M0,clipping_planes_pars_fragment:g0,clipping_planes_pars_vertex:b0,clipping_planes_vertex:z0,color_fragment:_0,color_pars_fragment:w0,color_pars_vertex:y0,color_vertex:v0,common:O0,cube_uv_reflection_fragment:x0,defaultnormal_vertex:S0,displacementmap_pars_vertex:A0,displacementmap_vertex:E0,emissivemap_fragment:D0,emissivemap_pars_fragment:I0,colorspace_fragment:T0,colorspace_pars_fragment:G0,envmap_fragment:R0,envmap_common_pars_fragment:B0,envmap_pars_fragment:N0,envmap_pars_vertex:C0,envmap_physical_pars_fragment:q0,envmap_vertex:P0,fog_vertex:W0,fog_pars_vertex:L0,fog_fragment:k0,fog_pars_fragment:U0,gradientmap_pars_fragment:F0,lightmap_pars_fragment:j0,lights_lambert_fragment:V0,lights_lambert_pars_fragment:$0,lights_pars_begin:H0,lights_toon_fragment:X0,lights_toon_pars_fragment:Y0,lights_phong_fragment:K0,lights_phong_pars_fragment:Z0,lights_physical_fragment:Q0,lights_physical_pars_fragment:J0,lights_fragment_begin:e_,lights_fragment_maps:t_,lights_fragment_end:s_,lightprobes_pars_fragment:n_,logdepthbuf_fragment:i_,logdepthbuf_pars_fragment:r_,logdepthbuf_pars_vertex:a_,logdepthbuf_vertex:o_,map_fragment:l_,map_pars_fragment:c_,map_particle_fragment:d_,map_particle_pars_fragment:u_,metalnessmap_fragment:h_,metalnessmap_pars_fragment:f_,morphinstance_vertex:p_,morphcolor_vertex:m_,morphnormal_vertex:M_,morphtarget_pars_vertex:g_,morphtarget_vertex:b_,normal_fragment_begin:z_,normal_fragment_maps:__,normal_pars_fragment:w_,normal_pars_vertex:y_,normal_vertex:v_,normalmap_pars_fragment:O_,clearcoat_normal_fragment_begin:x_,clearcoat_normal_fragment_maps:S_,clearcoat_pars_fragment:A_,iridescence_pars_fragment:E_,opaque_fragment:D_,packing:I_,premultiplied_alpha_fragment:T_,project_vertex:G_,dithering_fragment:R_,dithering_pars_fragment:B_,roughnessmap_fragment:N_,roughnessmap_pars_fragment:C_,shadowmap_pars_fragment:P_,shadowmap_pars_vertex:W_,shadowmap_vertex:L_,shadowmask_pars_fragment:k_,skinbase_vertex:U_,skinning_pars_vertex:F_,skinning_vertex:j_,skinnormal_vertex:V_,specularmap_fragment:$_,specularmap_pars_fragment:H_,tonemapping_fragment:q_,tonemapping_pars_fragment:X_,transmission_fragment:Y_,transmission_pars_fragment:K_,uv_pars_fragment:Z_,uv_pars_vertex:Q_,uv_vertex:J_,worldpos_vertex:ew,background_vert:tw,background_frag:sw,backgroundCube_vert:nw,backgroundCube_frag:iw,cube_vert:rw,cube_frag:aw,depth_vert:ow,depth_frag:lw,distance_vert:cw,distance_frag:dw,equirect_vert:uw,equirect_frag:hw,linedashed_vert:fw,linedashed_frag:pw,meshbasic_vert:mw,meshbasic_frag:Mw,meshlambert_vert:gw,meshlambert_frag:bw,meshmatcap_vert:zw,meshmatcap_frag:_w,meshnormal_vert:ww,meshnormal_frag:yw,meshphong_vert:vw,meshphong_frag:Ow,meshphysical_vert:xw,meshphysical_frag:Sw,meshtoon_vert:Aw,meshtoon_frag:Ew,points_vert:Dw,points_frag:Iw,shadow_vert:Tw,shadow_frag:Gw,sprite_vert:Rw,sprite_frag:Bw},Be={common:{diffuse:{value:new Ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new lt},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new lt}},envmap:{envMap:{value:null},envMapRotation:{value:new lt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new lt},normalScale:{value:new Je(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new Ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0},uvTransform:{value:new lt}},sprite:{diffuse:{value:new Ze(16777215)},opacity:{value:1},center:{value:new Je(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new lt},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0}}},vn={basic:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.fog]),vertexShader:Mt.meshbasic_vert,fragmentShader:Mt.meshbasic_frag},lambert:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},envMapIntensity:{value:1}}]),vertexShader:Mt.meshlambert_vert,fragmentShader:Mt.meshlambert_frag},phong:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},specular:{value:new Ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphong_vert,fragmentShader:Mt.meshphong_frag},standard:{uniforms:Ns([Be.common,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.roughnessmap,Be.metalnessmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag},toon:{uniforms:Ns([Be.common,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.gradientmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)}}]),vertexShader:Mt.meshtoon_vert,fragmentShader:Mt.meshtoon_frag},matcap:{uniforms:Ns([Be.common,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,{matcap:{value:null}}]),vertexShader:Mt.meshmatcap_vert,fragmentShader:Mt.meshmatcap_frag},points:{uniforms:Ns([Be.points,Be.fog]),vertexShader:Mt.points_vert,fragmentShader:Mt.points_frag},dashed:{uniforms:Ns([Be.common,Be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mt.linedashed_vert,fragmentShader:Mt.linedashed_frag},depth:{uniforms:Ns([Be.common,Be.displacementmap]),vertexShader:Mt.depth_vert,fragmentShader:Mt.depth_frag},normal:{uniforms:Ns([Be.common,Be.bumpmap,Be.normalmap,Be.displacementmap,{opacity:{value:1}}]),vertexShader:Mt.meshnormal_vert,fragmentShader:Mt.meshnormal_frag},sprite:{uniforms:Ns([Be.sprite,Be.fog]),vertexShader:Mt.sprite_vert,fragmentShader:Mt.sprite_frag},background:{uniforms:{uvTransform:{value:new lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mt.background_vert,fragmentShader:Mt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new lt}},vertexShader:Mt.backgroundCube_vert,fragmentShader:Mt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mt.cube_vert,fragmentShader:Mt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mt.equirect_vert,fragmentShader:Mt.equirect_frag},distance:{uniforms:Ns([Be.common,Be.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mt.distance_vert,fragmentShader:Mt.distance_frag},shadow:{uniforms:Ns([Be.lights,Be.fog,{color:{value:new Ze(0)},opacity:{value:1}}]),vertexShader:Mt.shadow_vert,fragmentShader:Mt.shadow_frag}};vn.physical={uniforms:Ns([vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new lt},clearcoatNormalScale:{value:new Je(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new lt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new lt},sheen:{value:0},sheenColor:{value:new Ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new lt},transmissionSamplerSize:{value:new Je},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new lt},attenuationDistance:{value:0},attenuationColor:{value:new Ze(0)},specularColor:{value:new Ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new lt},anisotropyVector:{value:new Je},anisotropyMap:{value:null},anisotropyMapTransform:{value:new lt}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag};const oo={r:0,b:0,g:0},Nw=new Rt,hm=new lt;hm.set(-1,0,0,0,1,0,0,0,1);function Cw(n,e,t,s,i,r){const a=new Ze(0);let o=i===!0?0:1,l,c,d=null,h=0,u=null;function p(S){let v=S.isScene===!0?S.background:null;if(v&&v.isTexture){const z=S.backgroundBlurriness>0;v=e.get(v,z)}return v}function M(S){let v=!1;const z=p(S);z===null?m(a,o):z&&z.isColor&&(m(z,1),v=!0);const O=n.xr.getEnvironmentBlendMode();O==="additive"?t.buffers.color.setClear(0,0,0,1,r):O==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||v)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(S,v){const z=p(v);z&&(z.isCubeTexture||z.mapping===pl)?(c===void 0&&(c=new Ss(new Da(1,1,1),new _s({name:"BackgroundCubeMaterial",uniforms:Lr(vn.backgroundCube.uniforms),vertexShader:vn.backgroundCube.vertexShader,fragmentShader:vn.backgroundCube.fragmentShader,side:Us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(O,x,G){this.matrixWorld.copyPosition(G.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(c)),c.material.uniforms.envMap.value=z,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Nw.makeRotationFromEuler(v.backgroundRotation)).transpose(),z.isCubeTexture&&z.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(hm),c.material.toneMapped=xt.getTransfer(z.colorSpace)!==Ut,(d!==z||h!==z.version||u!==n.toneMapping)&&(c.material.needsUpdate=!0,d=z,h=z.version,u=n.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):z&&z.isTexture&&(l===void 0&&(l=new Ss(new Ml(2,2),new _s({name:"BackgroundMaterial",uniforms:Lr(vn.background.uniforms),vertexShader:vn.background.vertexShader,fragmentShader:vn.background.fragmentShader,side:yi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=z,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=xt.getTransfer(z.colorSpace)!==Ut,z.matrixAutoUpdate===!0&&z.updateMatrix(),l.material.uniforms.uvTransform.value.copy(z.matrix),(d!==z||h!==z.version||u!==n.toneMapping)&&(l.material.needsUpdate=!0,d=z,h=z.version,u=n.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function m(S,v){S.getRGB(oo,lm(n)),t.buffers.color.setClear(oo.r,oo.g,oo.b,v,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,v=1){a.set(S),o=v,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:M,addToRenderList:_,dispose:f}}function Pw(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),s={},i=u(null);let r=i,a=!1;function o(C,W,Q,se,H){let ee=!1;const J=h(C,se,Q,W);r!==J&&(r=J,c(r.object)),ee=p(C,se,Q,H),ee&&M(C,se,Q,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(ee||a)&&(a=!1,z(C,W,Q,se),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return n.createVertexArray()}function c(C){return n.bindVertexArray(C)}function d(C){return n.deleteVertexArray(C)}function h(C,W,Q,se){const H=se.wireframe===!0;let ee=s[W.id];ee===void 0&&(ee={},s[W.id]=ee);const J=C.isInstancedMesh===!0?C.id:0;let ue=ee[J];ue===void 0&&(ue={},ee[J]=ue);let he=ue[Q.id];he===void 0&&(he={},ue[Q.id]=he);let Se=he[H];return Se===void 0&&(Se=u(l()),he[H]=Se),Se}function u(C){const W=[],Q=[],se=[];for(let H=0;H<t;H++)W[H]=0,Q[H]=0,se[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:Q,attributeDivisors:se,object:C,attributes:{},index:null}}function p(C,W,Q,se){const H=r.attributes,ee=W.attributes;let J=0;const ue=Q.getAttributes();for(const he in ue)if(ue[he].location>=0){const be=H[he];let Re=ee[he];if(Re===void 0&&(he==="instanceMatrix"&&C.instanceMatrix&&(Re=C.instanceMatrix),he==="instanceColor"&&C.instanceColor&&(Re=C.instanceColor)),be===void 0||be.attribute!==Re||Re&&be.data!==Re.data)return!0;J++}return r.attributesNum!==J||r.index!==se}function M(C,W,Q,se){const H={},ee=W.attributes;let J=0;const ue=Q.getAttributes();for(const he in ue)if(ue[he].location>=0){let be=ee[he];be===void 0&&(he==="instanceMatrix"&&C.instanceMatrix&&(be=C.instanceMatrix),he==="instanceColor"&&C.instanceColor&&(be=C.instanceColor));const Re={};Re.attribute=be,be&&be.data&&(Re.data=be.data),H[he]=Re,J++}r.attributes=H,r.attributesNum=J,r.index=se}function _(){const C=r.newAttributes;for(let W=0,Q=C.length;W<Q;W++)C[W]=0}function m(C){f(C,0)}function f(C,W){const Q=r.newAttributes,se=r.enabledAttributes,H=r.attributeDivisors;Q[C]=1,se[C]===0&&(n.enableVertexAttribArray(C),se[C]=1),H[C]!==W&&(n.vertexAttribDivisor(C,W),H[C]=W)}function S(){const C=r.newAttributes,W=r.enabledAttributes;for(let Q=0,se=W.length;Q<se;Q++)W[Q]!==C[Q]&&(n.disableVertexAttribArray(Q),W[Q]=0)}function v(C,W,Q,se,H,ee,J){J===!0?n.vertexAttribIPointer(C,W,Q,H,ee):n.vertexAttribPointer(C,W,Q,se,H,ee)}function z(C,W,Q,se){_();const H=se.attributes,ee=Q.getAttributes(),J=W.defaultAttributeValues;for(const ue in ee){const he=ee[ue];if(he.location>=0){let Se=H[ue];if(Se===void 0&&(ue==="instanceMatrix"&&C.instanceMatrix&&(Se=C.instanceMatrix),ue==="instanceColor"&&C.instanceColor&&(Se=C.instanceColor)),Se!==void 0){const be=Se.normalized,Re=Se.itemSize,ht=e.get(Se);if(ht===void 0)continue;const ct=ht.buffer,tt=ht.type,oe=ht.bytesPerElement,ye=tt===n.INT||tt===n.UNSIGNED_INT||Se.gpuType===Hd;if(Se.isInterleavedBufferAttribute){const Me=Se.data,et=Me.stride,nt=Se.offset;if(Me.isInstancedInterleavedBuffer){for(let Ye=0;Ye<he.locationSize;Ye++)f(he.location+Ye,Me.meshPerAttribute);C.isInstancedMesh!==!0&&se._maxInstanceCount===void 0&&(se._maxInstanceCount=Me.meshPerAttribute*Me.count)}else for(let Ye=0;Ye<he.locationSize;Ye++)m(he.location+Ye);n.bindBuffer(n.ARRAY_BUFFER,ct);for(let Ye=0;Ye<he.locationSize;Ye++)v(he.location+Ye,Re/he.locationSize,tt,be,et*oe,(nt+Re/he.locationSize*Ye)*oe,ye)}else{if(Se.isInstancedBufferAttribute){for(let Me=0;Me<he.locationSize;Me++)f(he.location+Me,Se.meshPerAttribute);C.isInstancedMesh!==!0&&se._maxInstanceCount===void 0&&(se._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let Me=0;Me<he.locationSize;Me++)m(he.location+Me);n.bindBuffer(n.ARRAY_BUFFER,ct);for(let Me=0;Me<he.locationSize;Me++)v(he.location+Me,Re/he.locationSize,tt,be,Re*oe,Re/he.locationSize*Me*oe,ye)}}else if(J!==void 0){const be=J[ue];if(be!==void 0)switch(be.length){case 2:n.vertexAttrib2fv(he.location,be);break;case 3:n.vertexAttrib3fv(he.location,be);break;case 4:n.vertexAttrib4fv(he.location,be);break;default:n.vertexAttrib1fv(he.location,be)}}}}S()}function O(){T();for(const C in s){const W=s[C];for(const Q in W){const se=W[Q];for(const H in se){const ee=se[H];for(const J in ee)d(ee[J].object),delete ee[J];delete se[H]}}delete s[C]}}function x(C){if(s[C.id]===void 0)return;const W=s[C.id];for(const Q in W){const se=W[Q];for(const H in se){const ee=se[H];for(const J in ee)d(ee[J].object),delete ee[J];delete se[H]}}delete s[C.id]}function G(C){for(const W in s){const Q=s[W];for(const se in Q){const H=Q[se];if(H[C.id]===void 0)continue;const ee=H[C.id];for(const J in ee)d(ee[J].object),delete ee[J];delete H[C.id]}}}function b(C){for(const W in s){const Q=s[W],se=C.isInstancedMesh===!0?C.id:0,H=Q[se];if(H!==void 0){for(const ee in H){const J=H[ee];for(const ue in J)d(J[ue].object),delete J[ue];delete H[ee]}delete Q[se],Object.keys(Q).length===0&&delete s[W]}}}function T(){N(),a=!0,r!==i&&(r=i,c(r.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:N,dispose:O,releaseStatesOfGeometry:x,releaseStatesOfObject:b,releaseStatesOfProgram:G,initAttributes:_,enableAttribute:m,disableUnusedAttributes:S}}function Ww(n,e,t){let s;function i(l){s=l}function r(l,c){n.drawArrays(s,l,c),t.update(c,s,1)}function a(l,c,d){d!==0&&(n.drawArraysInstanced(s,l,c,d),t.update(c,s,d))}function o(l,c,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s,l,0,c,0,d);let u=0;for(let p=0;p<d;p++)u+=c[p];t.update(u,s,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Lw(n,e,t,s){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const G=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(G.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(G){return!(G!==gn&&s.convert(G)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(G){const b=G===ei&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(G!==qs&&s.convert(G)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&G!==Mn&&!b)}function l(G){if(G==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(Qe("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Qe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),S=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),v=n.getParameter(n.MAX_VARYING_VECTORS),z=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),O=n.getParameter(n.MAX_SAMPLES),x=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:M,maxTextureSize:_,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:S,maxVaryings:v,maxFragmentUniforms:z,maxSamples:O,samples:x}}function kw(n){const e=this;let t=null,s=0,i=!1,r=!1;const a=new fi,o=new lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,u){const p=h.length!==0||u||s!==0||i;return i=u,s=h.length,p},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,u){t=d(h,u,0)},this.setState=function(h,u,p){const M=h.clippingPlanes,_=h.clipIntersection,m=h.clipShadows,f=n.get(h);if(!i||M===null||M.length===0||r&&!m)r?d(null):c();else{const S=r?0:s,v=S*4;let z=f.clippingState||null;l.value=z,z=d(M,u,v,p);for(let O=0;O!==v;++O)z[O]=t[O];f.clippingState=z,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=s>0),e.numPlanes=s,e.numIntersection=0}function d(h,u,p,M){const _=h!==null?h.length:0;let m=null;if(_!==0){if(m=l.value,M!==!0||m===null){const f=p+_*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<f)&&(m=new Float32Array(f));for(let v=0,z=p;v!==_;++v,z+=4)a.copy(h[v]).applyMatrix4(S,o),a.normal.toArray(m,z),m[z+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}const bi=4,xh=[.125,.215,.35,.446,.526,.582],Li=20,Uw=256,aa=new cu,Sh=new Ze;let rc=null,ac=0,oc=0,lc=!1;const Fw=new P;class Ah{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,s=.1,i=100,r={}){const{size:a=256,position:o=Fw}=r;rc=this._renderer.getRenderTarget(),ac=this._renderer.getActiveCubeFace(),oc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,s,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ih(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Dh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(rc,ac,oc),this._renderer.xr.enabled=lc,e.scissorTest=!1,yr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Xi||e.mapping===Pr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),rc=this._renderer.getRenderTarget(),ac=this._renderer.getActiveCubeFace(),oc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const s=t||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,s={magFilter:Es,minFilter:Es,generateMipmaps:!1,type:ei,format:gn,colorSpace:Zo,depthBuffer:!1},i=Eh(e,t,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Eh(e,t,s);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=jw(r)),this._blurMaterial=$w(r,e,t),this._ggxMaterial=Vw(r,e,t)}return i}_compileMaterial(e){const t=new Ss(new os,e);this._renderer.compile(t,aa)}_sceneToCubeUV(e,t,s,i,r){const l=new tn(90,1,t,s),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,p=h.toneMapping;h.getClearColor(Sh),h.toneMapping=En,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ss(new Da,new nu({name:"PMREM.Background",side:Us,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,m=_.material;let f=!1;const S=e.background;S?S.isColor&&(m.color.copy(S),e.background=null,f=!0):(m.color.copy(Sh),f=!0);for(let v=0;v<6;v++){const z=v%3;z===0?(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+d[v],r.y,r.z)):z===1?(l.up.set(0,0,c[v]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+d[v],r.z)):(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+d[v]));const O=this._cubeSize;yr(i,z*O,v>2?O:0,O,O),h.setRenderTarget(i),f&&h.render(_,l),h.render(e,l)}h.toneMapping=p,h.autoClear=u,e.background=S}_textureToCubeUV(e,t){const s=this._renderer,i=e.mapping===Xi||e.mapping===Pr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ih()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Dh());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;yr(t,0,0,3*l,2*l),s.setRenderTarget(t),s.render(a,aa)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=s}_applyGGXFilter(e,t,s){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[s];o.material=a;const l=a.uniforms,c=s/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-d*d),u=0+c*1.25,p=h*u,{_lodMax:M}=this,_=this._sizeLods[s],m=3*_*(s>M-bi?s-M+bi:0),f=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=M-t,yr(r,m,f,3*_,2*_),i.setRenderTarget(r),i.render(o,aa),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=M-s,yr(e,m,f,3*_,2*_),i.setRenderTarget(e),i.render(o,aa)}_blur(e,t,s,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,s,i,"latitudinal",r),this._halfBlur(a,e,s,s,i,"longitudinal",r)}_halfBlur(e,t,s,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ot("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=c;const u=c.uniforms,p=this._sizeLods[s]-1,M=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Li-1),_=r/M,m=isFinite(r)?1+Math.floor(d*_):Li;m>Li&&Qe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Li}`);const f=[];let S=0;for(let G=0;G<Li;++G){const b=G/_,T=Math.exp(-b*b/2);f.push(T),G===0?S+=T:G<m&&(S+=2*T)}for(let G=0;G<f.length;G++)f[G]=f[G]/S;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:v}=this;u.dTheta.value=M,u.mipInt.value=v-s;const z=this._sizeLods[i],O=3*z*(i>v-bi?i-v+bi:0),x=4*(this._cubeSize-z);yr(t,O,x,3*z,2*z),l.setRenderTarget(t),l.render(h,aa)}}function jw(n){const e=[],t=[],s=[];let i=n;const r=n-bi+1+xh.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>n-bi?l=xh[a-n+bi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),d=-c,h=1+c,u=[d,d,h,d,h,h,d,d,h,h,d,h],p=6,M=6,_=3,m=2,f=1,S=new Float32Array(_*M*p),v=new Float32Array(m*M*p),z=new Float32Array(f*M*p);for(let x=0;x<p;x++){const G=x%3*2/3-1,b=x>2?0:-1,T=[G,b,0,G+2/3,b,0,G+2/3,b+1,0,G,b,0,G+2/3,b+1,0,G,b+1,0];S.set(T,_*M*x),v.set(u,m*M*x);const N=[x,x,x,x,x,x];z.set(N,f*M*x)}const O=new os;O.setAttribute("position",new Ds(S,_)),O.setAttribute("uv",new Ds(v,m)),O.setAttribute("faceIndex",new Ds(z,f)),s.push(new Ss(O,null)),i>bi&&i--}return{lodMeshes:s,sizeLods:e,sigmas:t}}function Eh(n,e,t){const s=new Dn(n,e,t);return s.texture.mapping=pl,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function yr(n,e,t,s,i){n.viewport.set(e,t,s,i),n.scissor.set(e,t,s,i)}function Vw(n,e,t){return new _s({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Uw,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
3672
+ }`,Mt={alphahash_fragment:t0,alphahash_pars_fragment:s0,alphamap_fragment:n0,alphamap_pars_fragment:i0,alphatest_fragment:r0,alphatest_pars_fragment:a0,aomap_fragment:o0,aomap_pars_fragment:l0,batching_pars_vertex:c0,batching_vertex:d0,begin_vertex:u0,beginnormal_vertex:h0,bsdfs:f0,iridescence_fragment:p0,bumpmap_pars_fragment:m0,clipping_planes_fragment:M0,clipping_planes_pars_fragment:g0,clipping_planes_pars_vertex:b0,clipping_planes_vertex:z0,color_fragment:_0,color_pars_fragment:w0,color_pars_vertex:y0,color_vertex:v0,common:O0,cube_uv_reflection_fragment:x0,defaultnormal_vertex:S0,displacementmap_pars_vertex:A0,displacementmap_vertex:E0,emissivemap_fragment:D0,emissivemap_pars_fragment:I0,colorspace_fragment:T0,colorspace_pars_fragment:G0,envmap_fragment:R0,envmap_common_pars_fragment:B0,envmap_pars_fragment:N0,envmap_pars_vertex:C0,envmap_physical_pars_fragment:q0,envmap_vertex:P0,fog_vertex:W0,fog_pars_vertex:L0,fog_fragment:k0,fog_pars_fragment:U0,gradientmap_pars_fragment:F0,lightmap_pars_fragment:j0,lights_lambert_fragment:V0,lights_lambert_pars_fragment:$0,lights_pars_begin:H0,lights_toon_fragment:X0,lights_toon_pars_fragment:Y0,lights_phong_fragment:K0,lights_phong_pars_fragment:Z0,lights_physical_fragment:Q0,lights_physical_pars_fragment:J0,lights_fragment_begin:e_,lights_fragment_maps:t_,lights_fragment_end:s_,lightprobes_pars_fragment:n_,logdepthbuf_fragment:i_,logdepthbuf_pars_fragment:r_,logdepthbuf_pars_vertex:a_,logdepthbuf_vertex:o_,map_fragment:l_,map_pars_fragment:c_,map_particle_fragment:d_,map_particle_pars_fragment:u_,metalnessmap_fragment:h_,metalnessmap_pars_fragment:f_,morphinstance_vertex:p_,morphcolor_vertex:m_,morphnormal_vertex:M_,morphtarget_pars_vertex:g_,morphtarget_vertex:b_,normal_fragment_begin:z_,normal_fragment_maps:__,normal_pars_fragment:w_,normal_pars_vertex:y_,normal_vertex:v_,normalmap_pars_fragment:O_,clearcoat_normal_fragment_begin:x_,clearcoat_normal_fragment_maps:S_,clearcoat_pars_fragment:A_,iridescence_pars_fragment:E_,opaque_fragment:D_,packing:I_,premultiplied_alpha_fragment:T_,project_vertex:G_,dithering_fragment:R_,dithering_pars_fragment:B_,roughnessmap_fragment:N_,roughnessmap_pars_fragment:C_,shadowmap_pars_fragment:P_,shadowmap_pars_vertex:W_,shadowmap_vertex:L_,shadowmask_pars_fragment:k_,skinbase_vertex:U_,skinning_pars_vertex:F_,skinning_vertex:j_,skinnormal_vertex:V_,specularmap_fragment:$_,specularmap_pars_fragment:H_,tonemapping_fragment:q_,tonemapping_pars_fragment:X_,transmission_fragment:Y_,transmission_pars_fragment:K_,uv_pars_fragment:Z_,uv_pars_vertex:Q_,uv_vertex:J_,worldpos_vertex:ew,background_vert:tw,background_frag:sw,backgroundCube_vert:nw,backgroundCube_frag:iw,cube_vert:rw,cube_frag:aw,depth_vert:ow,depth_frag:lw,distance_vert:cw,distance_frag:dw,equirect_vert:uw,equirect_frag:hw,linedashed_vert:fw,linedashed_frag:pw,meshbasic_vert:mw,meshbasic_frag:Mw,meshlambert_vert:gw,meshlambert_frag:bw,meshmatcap_vert:zw,meshmatcap_frag:_w,meshnormal_vert:ww,meshnormal_frag:yw,meshphong_vert:vw,meshphong_frag:Ow,meshphysical_vert:xw,meshphysical_frag:Sw,meshtoon_vert:Aw,meshtoon_frag:Ew,points_vert:Dw,points_frag:Iw,shadow_vert:Tw,shadow_frag:Gw,sprite_vert:Rw,sprite_frag:Bw},Be={common:{diffuse:{value:new Ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new lt},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new lt}},envmap:{envMap:{value:null},envMapRotation:{value:new lt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new lt},normalScale:{value:new Je(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new Ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0},uvTransform:{value:new lt}},sprite:{diffuse:{value:new Ze(16777215)},opacity:{value:1},center:{value:new Je(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new lt},alphaMap:{value:null},alphaMapTransform:{value:new lt},alphaTest:{value:0}}},vn={basic:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.fog]),vertexShader:Mt.meshbasic_vert,fragmentShader:Mt.meshbasic_frag},lambert:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},envMapIntensity:{value:1}}]),vertexShader:Mt.meshlambert_vert,fragmentShader:Mt.meshlambert_frag},phong:{uniforms:Ns([Be.common,Be.specularmap,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},specular:{value:new Ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphong_vert,fragmentShader:Mt.meshphong_frag},standard:{uniforms:Ns([Be.common,Be.envmap,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.roughnessmap,Be.metalnessmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag},toon:{uniforms:Ns([Be.common,Be.aomap,Be.lightmap,Be.emissivemap,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.gradientmap,Be.fog,Be.lights,{emissive:{value:new Ze(0)}}]),vertexShader:Mt.meshtoon_vert,fragmentShader:Mt.meshtoon_frag},matcap:{uniforms:Ns([Be.common,Be.bumpmap,Be.normalmap,Be.displacementmap,Be.fog,{matcap:{value:null}}]),vertexShader:Mt.meshmatcap_vert,fragmentShader:Mt.meshmatcap_frag},points:{uniforms:Ns([Be.points,Be.fog]),vertexShader:Mt.points_vert,fragmentShader:Mt.points_frag},dashed:{uniforms:Ns([Be.common,Be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mt.linedashed_vert,fragmentShader:Mt.linedashed_frag},depth:{uniforms:Ns([Be.common,Be.displacementmap]),vertexShader:Mt.depth_vert,fragmentShader:Mt.depth_frag},normal:{uniforms:Ns([Be.common,Be.bumpmap,Be.normalmap,Be.displacementmap,{opacity:{value:1}}]),vertexShader:Mt.meshnormal_vert,fragmentShader:Mt.meshnormal_frag},sprite:{uniforms:Ns([Be.sprite,Be.fog]),vertexShader:Mt.sprite_vert,fragmentShader:Mt.sprite_frag},background:{uniforms:{uvTransform:{value:new lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mt.background_vert,fragmentShader:Mt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new lt}},vertexShader:Mt.backgroundCube_vert,fragmentShader:Mt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mt.cube_vert,fragmentShader:Mt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mt.equirect_vert,fragmentShader:Mt.equirect_frag},distance:{uniforms:Ns([Be.common,Be.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mt.distance_vert,fragmentShader:Mt.distance_frag},shadow:{uniforms:Ns([Be.lights,Be.fog,{color:{value:new Ze(0)},opacity:{value:1}}]),vertexShader:Mt.shadow_vert,fragmentShader:Mt.shadow_frag}};vn.physical={uniforms:Ns([vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new lt},clearcoatNormalScale:{value:new Je(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new lt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new lt},sheen:{value:0},sheenColor:{value:new Ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new lt},transmissionSamplerSize:{value:new Je},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new lt},attenuationDistance:{value:0},attenuationColor:{value:new Ze(0)},specularColor:{value:new Ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new lt},anisotropyVector:{value:new Je},anisotropyMap:{value:null},anisotropyMapTransform:{value:new lt}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag};const oo={r:0,b:0,g:0},Nw=new Rt,hm=new lt;hm.set(-1,0,0,0,1,0,0,0,1);function Cw(n,e,t,s,i,r){const a=new Ze(0);let o=i===!0?0:1,l,c,d=null,h=0,u=null;function p(S){let v=S.isScene===!0?S.background:null;if(v&&v.isTexture){const z=S.backgroundBlurriness>0;v=e.get(v,z)}return v}function M(S){let v=!1;const z=p(S);z===null?m(a,o):z&&z.isColor&&(m(z,1),v=!0);const O=n.xr.getEnvironmentBlendMode();O==="additive"?t.buffers.color.setClear(0,0,0,1,r):O==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||v)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(S,v){const z=p(v);z&&(z.isCubeTexture||z.mapping===pl)?(c===void 0&&(c=new Ss(new Da(1,1,1),new _s({name:"BackgroundCubeMaterial",uniforms:Lr(vn.backgroundCube.uniforms),vertexShader:vn.backgroundCube.vertexShader,fragmentShader:vn.backgroundCube.fragmentShader,side:Us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(O,x,G){this.matrixWorld.copyPosition(G.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(c)),c.material.uniforms.envMap.value=z,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Nw.makeRotationFromEuler(v.backgroundRotation)).transpose(),z.isCubeTexture&&z.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(hm),c.material.toneMapped=xt.getTransfer(z.colorSpace)!==Ut,(d!==z||h!==z.version||u!==n.toneMapping)&&(c.material.needsUpdate=!0,d=z,h=z.version,u=n.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):z&&z.isTexture&&(l===void 0&&(l=new Ss(new Ml(2,2),new _s({name:"BackgroundMaterial",uniforms:Lr(vn.background.uniforms),vertexShader:vn.background.vertexShader,fragmentShader:vn.background.fragmentShader,side:vi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=z,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=xt.getTransfer(z.colorSpace)!==Ut,z.matrixAutoUpdate===!0&&z.updateMatrix(),l.material.uniforms.uvTransform.value.copy(z.matrix),(d!==z||h!==z.version||u!==n.toneMapping)&&(l.material.needsUpdate=!0,d=z,h=z.version,u=n.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function m(S,v){S.getRGB(oo,lm(n)),t.buffers.color.setClear(oo.r,oo.g,oo.b,v,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,v=1){a.set(S),o=v,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:M,addToRenderList:_,dispose:f}}function Pw(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),s={},i=u(null);let r=i,a=!1;function o(C,W,Q,se,H){let ee=!1;const J=h(C,se,Q,W);r!==J&&(r=J,c(r.object)),ee=p(C,se,Q,H),ee&&M(C,se,Q,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(ee||a)&&(a=!1,z(C,W,Q,se),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return n.createVertexArray()}function c(C){return n.bindVertexArray(C)}function d(C){return n.deleteVertexArray(C)}function h(C,W,Q,se){const H=se.wireframe===!0;let ee=s[W.id];ee===void 0&&(ee={},s[W.id]=ee);const J=C.isInstancedMesh===!0?C.id:0;let ue=ee[J];ue===void 0&&(ue={},ee[J]=ue);let he=ue[Q.id];he===void 0&&(he={},ue[Q.id]=he);let Se=he[H];return Se===void 0&&(Se=u(l()),he[H]=Se),Se}function u(C){const W=[],Q=[],se=[];for(let H=0;H<t;H++)W[H]=0,Q[H]=0,se[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:Q,attributeDivisors:se,object:C,attributes:{},index:null}}function p(C,W,Q,se){const H=r.attributes,ee=W.attributes;let J=0;const ue=Q.getAttributes();for(const he in ue)if(ue[he].location>=0){const be=H[he];let Re=ee[he];if(Re===void 0&&(he==="instanceMatrix"&&C.instanceMatrix&&(Re=C.instanceMatrix),he==="instanceColor"&&C.instanceColor&&(Re=C.instanceColor)),be===void 0||be.attribute!==Re||Re&&be.data!==Re.data)return!0;J++}return r.attributesNum!==J||r.index!==se}function M(C,W,Q,se){const H={},ee=W.attributes;let J=0;const ue=Q.getAttributes();for(const he in ue)if(ue[he].location>=0){let be=ee[he];be===void 0&&(he==="instanceMatrix"&&C.instanceMatrix&&(be=C.instanceMatrix),he==="instanceColor"&&C.instanceColor&&(be=C.instanceColor));const Re={};Re.attribute=be,be&&be.data&&(Re.data=be.data),H[he]=Re,J++}r.attributes=H,r.attributesNum=J,r.index=se}function _(){const C=r.newAttributes;for(let W=0,Q=C.length;W<Q;W++)C[W]=0}function m(C){f(C,0)}function f(C,W){const Q=r.newAttributes,se=r.enabledAttributes,H=r.attributeDivisors;Q[C]=1,se[C]===0&&(n.enableVertexAttribArray(C),se[C]=1),H[C]!==W&&(n.vertexAttribDivisor(C,W),H[C]=W)}function S(){const C=r.newAttributes,W=r.enabledAttributes;for(let Q=0,se=W.length;Q<se;Q++)W[Q]!==C[Q]&&(n.disableVertexAttribArray(Q),W[Q]=0)}function v(C,W,Q,se,H,ee,J){J===!0?n.vertexAttribIPointer(C,W,Q,H,ee):n.vertexAttribPointer(C,W,Q,se,H,ee)}function z(C,W,Q,se){_();const H=se.attributes,ee=Q.getAttributes(),J=W.defaultAttributeValues;for(const ue in ee){const he=ee[ue];if(he.location>=0){let Se=H[ue];if(Se===void 0&&(ue==="instanceMatrix"&&C.instanceMatrix&&(Se=C.instanceMatrix),ue==="instanceColor"&&C.instanceColor&&(Se=C.instanceColor)),Se!==void 0){const be=Se.normalized,Re=Se.itemSize,ht=e.get(Se);if(ht===void 0)continue;const ct=ht.buffer,tt=ht.type,oe=ht.bytesPerElement,ye=tt===n.INT||tt===n.UNSIGNED_INT||Se.gpuType===Hd;if(Se.isInterleavedBufferAttribute){const Me=Se.data,et=Me.stride,it=Se.offset;if(Me.isInstancedInterleavedBuffer){for(let Ye=0;Ye<he.locationSize;Ye++)f(he.location+Ye,Me.meshPerAttribute);C.isInstancedMesh!==!0&&se._maxInstanceCount===void 0&&(se._maxInstanceCount=Me.meshPerAttribute*Me.count)}else for(let Ye=0;Ye<he.locationSize;Ye++)m(he.location+Ye);n.bindBuffer(n.ARRAY_BUFFER,ct);for(let Ye=0;Ye<he.locationSize;Ye++)v(he.location+Ye,Re/he.locationSize,tt,be,et*oe,(it+Re/he.locationSize*Ye)*oe,ye)}else{if(Se.isInstancedBufferAttribute){for(let Me=0;Me<he.locationSize;Me++)f(he.location+Me,Se.meshPerAttribute);C.isInstancedMesh!==!0&&se._maxInstanceCount===void 0&&(se._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let Me=0;Me<he.locationSize;Me++)m(he.location+Me);n.bindBuffer(n.ARRAY_BUFFER,ct);for(let Me=0;Me<he.locationSize;Me++)v(he.location+Me,Re/he.locationSize,tt,be,Re*oe,Re/he.locationSize*Me*oe,ye)}}else if(J!==void 0){const be=J[ue];if(be!==void 0)switch(be.length){case 2:n.vertexAttrib2fv(he.location,be);break;case 3:n.vertexAttrib3fv(he.location,be);break;case 4:n.vertexAttrib4fv(he.location,be);break;default:n.vertexAttrib1fv(he.location,be)}}}}S()}function O(){T();for(const C in s){const W=s[C];for(const Q in W){const se=W[Q];for(const H in se){const ee=se[H];for(const J in ee)d(ee[J].object),delete ee[J];delete se[H]}}delete s[C]}}function x(C){if(s[C.id]===void 0)return;const W=s[C.id];for(const Q in W){const se=W[Q];for(const H in se){const ee=se[H];for(const J in ee)d(ee[J].object),delete ee[J];delete se[H]}}delete s[C.id]}function G(C){for(const W in s){const Q=s[W];for(const se in Q){const H=Q[se];if(H[C.id]===void 0)continue;const ee=H[C.id];for(const J in ee)d(ee[J].object),delete ee[J];delete H[C.id]}}}function b(C){for(const W in s){const Q=s[W],se=C.isInstancedMesh===!0?C.id:0,H=Q[se];if(H!==void 0){for(const ee in H){const J=H[ee];for(const ue in J)d(J[ue].object),delete J[ue];delete H[ee]}delete Q[se],Object.keys(Q).length===0&&delete s[W]}}}function T(){N(),a=!0,r!==i&&(r=i,c(r.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:N,dispose:O,releaseStatesOfGeometry:x,releaseStatesOfObject:b,releaseStatesOfProgram:G,initAttributes:_,enableAttribute:m,disableUnusedAttributes:S}}function Ww(n,e,t){let s;function i(l){s=l}function r(l,c){n.drawArrays(s,l,c),t.update(c,s,1)}function a(l,c,d){d!==0&&(n.drawArraysInstanced(s,l,c,d),t.update(c,s,d))}function o(l,c,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s,l,0,c,0,d);let u=0;for(let p=0;p<d;p++)u+=c[p];t.update(u,s,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Lw(n,e,t,s){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const G=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(G.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(G){return!(G!==gn&&s.convert(G)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(G){const b=G===ei&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(G!==qs&&s.convert(G)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&G!==Mn&&!b)}function l(G){if(G==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(Qe("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Qe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),S=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),v=n.getParameter(n.MAX_VARYING_VECTORS),z=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),O=n.getParameter(n.MAX_SAMPLES),x=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:M,maxTextureSize:_,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:S,maxVaryings:v,maxFragmentUniforms:z,maxSamples:O,samples:x}}function kw(n){const e=this;let t=null,s=0,i=!1,r=!1;const a=new pi,o=new lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,u){const p=h.length!==0||u||s!==0||i;return i=u,s=h.length,p},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,u){t=d(h,u,0)},this.setState=function(h,u,p){const M=h.clippingPlanes,_=h.clipIntersection,m=h.clipShadows,f=n.get(h);if(!i||M===null||M.length===0||r&&!m)r?d(null):c();else{const S=r?0:s,v=S*4;let z=f.clippingState||null;l.value=z,z=d(M,u,v,p);for(let O=0;O!==v;++O)z[O]=t[O];f.clippingState=z,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=s>0),e.numPlanes=s,e.numIntersection=0}function d(h,u,p,M){const _=h!==null?h.length:0;let m=null;if(_!==0){if(m=l.value,M!==!0||m===null){const f=p+_*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<f)&&(m=new Float32Array(f));for(let v=0,z=p;v!==_;++v,z+=4)a.copy(h[v]).applyMatrix4(S,o),a.normal.toArray(m,z),m[z+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}const zi=4,xh=[.125,.215,.35,.446,.526,.582],Li=20,Uw=256,aa=new cu,Sh=new Ze;let rc=null,ac=0,oc=0,lc=!1;const Fw=new P;class Ah{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,s=.1,i=100,r={}){const{size:a=256,position:o=Fw}=r;rc=this._renderer.getRenderTarget(),ac=this._renderer.getActiveCubeFace(),oc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,s,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ih(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Dh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(rc,ac,oc),this._renderer.xr.enabled=lc,e.scissorTest=!1,yr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Xi||e.mapping===Pr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),rc=this._renderer.getRenderTarget(),ac=this._renderer.getActiveCubeFace(),oc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const s=t||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,s={magFilter:Es,minFilter:Es,generateMipmaps:!1,type:ei,format:gn,colorSpace:Zo,depthBuffer:!1},i=Eh(e,t,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Eh(e,t,s);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=jw(r)),this._blurMaterial=$w(r,e,t),this._ggxMaterial=Vw(r,e,t)}return i}_compileMaterial(e){const t=new Ss(new os,e);this._renderer.compile(t,aa)}_sceneToCubeUV(e,t,s,i,r){const l=new tn(90,1,t,s),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,p=h.toneMapping;h.getClearColor(Sh),h.toneMapping=En,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ss(new Da,new nu({name:"PMREM.Background",side:Us,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,m=_.material;let f=!1;const S=e.background;S?S.isColor&&(m.color.copy(S),e.background=null,f=!0):(m.color.copy(Sh),f=!0);for(let v=0;v<6;v++){const z=v%3;z===0?(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+d[v],r.y,r.z)):z===1?(l.up.set(0,0,c[v]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+d[v],r.z)):(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+d[v]));const O=this._cubeSize;yr(i,z*O,v>2?O:0,O,O),h.setRenderTarget(i),f&&h.render(_,l),h.render(e,l)}h.toneMapping=p,h.autoClear=u,e.background=S}_textureToCubeUV(e,t){const s=this._renderer,i=e.mapping===Xi||e.mapping===Pr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ih()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Dh());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;yr(t,0,0,3*l,2*l),s.setRenderTarget(t),s.render(a,aa)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=s}_applyGGXFilter(e,t,s){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[s];o.material=a;const l=a.uniforms,c=s/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-d*d),u=0+c*1.25,p=h*u,{_lodMax:M}=this,_=this._sizeLods[s],m=3*_*(s>M-zi?s-M+zi:0),f=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=M-t,yr(r,m,f,3*_,2*_),i.setRenderTarget(r),i.render(o,aa),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=M-s,yr(e,m,f,3*_,2*_),i.setRenderTarget(e),i.render(o,aa)}_blur(e,t,s,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,s,i,"latitudinal",r),this._halfBlur(a,e,s,s,i,"longitudinal",r)}_halfBlur(e,t,s,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ot("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=c;const u=c.uniforms,p=this._sizeLods[s]-1,M=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Li-1),_=r/M,m=isFinite(r)?1+Math.floor(d*_):Li;m>Li&&Qe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Li}`);const f=[];let S=0;for(let G=0;G<Li;++G){const b=G/_,T=Math.exp(-b*b/2);f.push(T),G===0?S+=T:G<m&&(S+=2*T)}for(let G=0;G<f.length;G++)f[G]=f[G]/S;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:v}=this;u.dTheta.value=M,u.mipInt.value=v-s;const z=this._sizeLods[i],O=3*z*(i>v-zi?i-v+zi:0),x=4*(this._cubeSize-z);yr(t,O,x,3*z,2*z),l.setRenderTarget(t),l.render(h,aa)}}function jw(n){const e=[],t=[],s=[];let i=n;const r=n-zi+1+xh.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>n-zi?l=xh[a-n+zi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),d=-c,h=1+c,u=[d,d,h,d,h,h,d,d,h,h,d,h],p=6,M=6,_=3,m=2,f=1,S=new Float32Array(_*M*p),v=new Float32Array(m*M*p),z=new Float32Array(f*M*p);for(let x=0;x<p;x++){const G=x%3*2/3-1,b=x>2?0:-1,T=[G,b,0,G+2/3,b,0,G+2/3,b+1,0,G,b,0,G+2/3,b+1,0,G,b+1,0];S.set(T,_*M*x),v.set(u,m*M*x);const N=[x,x,x,x,x,x];z.set(N,f*M*x)}const O=new os;O.setAttribute("position",new Ds(S,_)),O.setAttribute("uv",new Ds(v,m)),O.setAttribute("faceIndex",new Ds(z,f)),s.push(new Ss(O,null)),i>zi&&i--}return{lodMeshes:s,sizeLods:e,sigmas:t}}function Eh(n,e,t){const s=new Dn(n,e,t);return s.texture.mapping=pl,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function yr(n,e,t,s,i){n.viewport.set(e,t,s,i),n.scissor.set(e,t,s,i)}function Vw(n,e,t){return new _s({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Uw,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:gl(),fragmentShader:`
3673
3673
 
3674
3674
  precision highp float;
3675
3675
  precision highp int;
@@ -4055,7 +4055,7 @@ Material Type: `+C.type+`
4055
4055
 
4056
4056
  Program Info Log: `+H+`
4057
4057
  `+Se+`
4058
- `+be)}else H!==""?Qe("WebGLProgram: Program Info Log:",H):(ee===""||J==="")&&(he=!1);he&&(C.diagnostics={runnable:ue,programLog:H,vertexShader:{log:ee,prefix:m},fragmentShader:{log:J,prefix:f}})}i.deleteShader(O),i.deleteShader(x),b=new To(i,_),T=tv(i,_)}let b;this.getUniforms=function(){return b===void 0&&G(this),b};let T;this.getAttributes=function(){return T===void 0&&G(this),T};let N=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return N===!1&&(N=i.getProgramParameter(_,$y)),N},this.destroy=function(){s.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Hy++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=O,this.fragmentShader=x,this}let gv=0;class bv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,s){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(s)===!1&&(i.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const s of t)s.usedTimes--,s.usedTimes===0&&this.shaderCache.delete(s.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let s=t.get(e);return s===void 0&&(s=new Set,t.set(e,s)),s}_getShaderStage(e){const t=this.shaderCache;let s=t.get(e);return s===void 0&&(s=new zv(e),t.set(e,s)),s}}class zv{constructor(e){this.id=gv++,this.code=e,this.usedTimes=0}}function _v(n){return n===Yi||n===Yo||n===Ko}function wv(n,e,t,s,i,r){const a=new su,o=new bv,l=new Set,c=[],d=new Map,h=s.logarithmicDepthBuffer;let u=s.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(b){return l.add(b),b===0?"uv":`uv${b}`}function _(b,T,N,C,W,Q){const se=C.fog,H=W.geometry,ee=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?C.environment:null,J=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap,ue=e.get(b.envMap||ee,J),he=ue&&ue.mapping===pl?ue.image.height:null,Se=p[b.type];b.precision!==null&&(u=s.getMaxPrecision(b.precision),u!==b.precision&&Qe("WebGLProgram.getParameters:",b.precision,"not supported, using",u,"instead."));const be=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Re=be!==void 0?be.length:0;let ht=0;H.morphAttributes.position!==void 0&&(ht=1),H.morphAttributes.normal!==void 0&&(ht=2),H.morphAttributes.color!==void 0&&(ht=3);let ct,tt,oe,ye;if(Se){const ke=vn[Se];ct=ke.vertexShader,tt=ke.fragmentShader}else{ct=b.vertexShader,tt=b.fragmentShader;const ke=o.getVertexShaderStage(b),Yt=o.getFragmentShaderStage(b);o.update(b,ke,Yt),oe=ke.id,ye=Yt.id}const Me=n.getRenderTarget(),et=n.state.buffers.depth.getReversed(),nt=W.isInstancedMesh===!0,Ye=W.isBatchedMesh===!0,qt=!!b.map,pt=!!b.matcap,dt=!!ue,At=!!b.aoMap,vt=!!b.lightMap,Pt=!!b.bumpMap&&b.wireframe===!1,ts=!!b.normalMap,ss=!!b.displacementMap,ls=!!b.emissiveMap,Xt=!!b.metalnessMap,Zt=!!b.roughnessMap,j=b.anisotropy>0,vs=b.clearcoat>0,gt=b.dispersion>0,R=b.iridescence>0,w=b.sheen>0,$=b.transmission>0,K=j&&!!b.anisotropyMap,te=vs&&!!b.clearcoatMap,we=vs&&!!b.clearcoatNormalMap,Ae=vs&&!!b.clearcoatRoughnessMap,ne=R&&!!b.iridescenceMap,ie=R&&!!b.iridescenceThicknessMap,Ee=w&&!!b.sheenColorMap,Ve=w&&!!b.sheenRoughnessMap,Ge=!!b.specularMap,xe=!!b.specularColorMap,Xe=!!b.specularIntensityMap,Ke=$&&!!b.transmissionMap,it=$&&!!b.thicknessMap,L=!!b.gradientMap,Oe=!!b.alphaMap,ae=b.alphaTest>0,Ie=!!b.alphaHash,Ne=!!b.extensions;let ce=En;b.toneMapped&&(Me===null||Me.isXRRenderTarget===!0)&&(ce=n.toneMapping);const $e={shaderID:Se,shaderType:b.type,shaderName:b.name,vertexShader:ct,fragmentShader:tt,defines:b.defines,customVertexShaderID:oe,customFragmentShaderID:ye,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:u,batching:Ye,batchingColor:Ye&&W._colorsTexture!==null,instancing:nt,instancingColor:nt&&W.instanceColor!==null,instancingMorph:nt&&W.morphTexture!==null,outputColorSpace:Me===null?n.outputColorSpace:Me.isXRRenderTarget===!0?Me.texture.colorSpace:xt.workingColorSpace,alphaToCoverage:!!b.alphaToCoverage,map:qt,matcap:pt,envMap:dt,envMapMode:dt&&ue.mapping,envMapCubeUVHeight:he,aoMap:At,lightMap:vt,bumpMap:Pt,normalMap:ts,displacementMap:ss,emissiveMap:ls,normalMapObjectSpace:ts&&b.normalMapType===Qb,normalMapTangentSpace:ts&&b.normalMapType===xd,packedNormalMap:ts&&b.normalMapType===xd&&_v(b.normalMap.format),metalnessMap:Xt,roughnessMap:Zt,anisotropy:j,anisotropyMap:K,clearcoat:vs,clearcoatMap:te,clearcoatNormalMap:we,clearcoatRoughnessMap:Ae,dispersion:gt,iridescence:R,iridescenceMap:ne,iridescenceThicknessMap:ie,sheen:w,sheenColorMap:Ee,sheenRoughnessMap:Ve,specularMap:Ge,specularColorMap:xe,specularIntensityMap:Xe,transmission:$,transmissionMap:Ke,thicknessMap:it,gradientMap:L,opaque:b.transparent===!1&&b.blending===ji&&b.alphaToCoverage===!1,alphaMap:Oe,alphaTest:ae,alphaHash:Ie,combine:b.combine,mapUv:qt&&M(b.map.channel),aoMapUv:At&&M(b.aoMap.channel),lightMapUv:vt&&M(b.lightMap.channel),bumpMapUv:Pt&&M(b.bumpMap.channel),normalMapUv:ts&&M(b.normalMap.channel),displacementMapUv:ss&&M(b.displacementMap.channel),emissiveMapUv:ls&&M(b.emissiveMap.channel),metalnessMapUv:Xt&&M(b.metalnessMap.channel),roughnessMapUv:Zt&&M(b.roughnessMap.channel),anisotropyMapUv:K&&M(b.anisotropyMap.channel),clearcoatMapUv:te&&M(b.clearcoatMap.channel),clearcoatNormalMapUv:we&&M(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&M(b.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&M(b.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&M(b.iridescenceThicknessMap.channel),sheenColorMapUv:Ee&&M(b.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&M(b.sheenRoughnessMap.channel),specularMapUv:Ge&&M(b.specularMap.channel),specularColorMapUv:xe&&M(b.specularColorMap.channel),specularIntensityMapUv:Xe&&M(b.specularIntensityMap.channel),transmissionMapUv:Ke&&M(b.transmissionMap.channel),thicknessMapUv:it&&M(b.thicknessMap.channel),alphaMapUv:Oe&&M(b.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ts||j),vertexNormals:!!H.attributes.normal,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!H.attributes.uv&&(qt||Oe),fog:!!se,useFog:b.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:b.wireframe===!1&&(b.flatShading===!0||H.attributes.normal===void 0&&ts===!1&&(b.isMeshLambertMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isMeshPhysicalMaterial)),sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:et,skinning:W.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Re,morphTextureStride:ht,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:Q.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&N.length>0,shadowMapType:n.shadowMap.type,toneMapping:ce,decodeVideoTexture:qt&&b.map.isVideoTexture===!0&&xt.getTransfer(b.map.colorSpace)===Ut,decodeVideoTextureEmissive:ls&&b.emissiveMap.isVideoTexture===!0&&xt.getTransfer(b.emissiveMap.colorSpace)===Ut,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Hn,flipSided:b.side===Us,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Ne&&b.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ne&&b.extensions.multiDraw===!0||Ye)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return $e.vertexUv1s=l.has(1),$e.vertexUv2s=l.has(2),$e.vertexUv3s=l.has(3),l.clear(),$e}function m(b){const T=[];if(b.shaderID?T.push(b.shaderID):(T.push(b.customVertexShaderID),T.push(b.customFragmentShaderID)),b.defines!==void 0)for(const N in b.defines)T.push(N),T.push(b.defines[N]);return b.isRawShaderMaterial===!1&&(f(T,b),S(T,b),T.push(n.outputColorSpace)),T.push(b.customProgramCacheKey),T.join()}function f(b,T){b.push(T.precision),b.push(T.outputColorSpace),b.push(T.envMapMode),b.push(T.envMapCubeUVHeight),b.push(T.mapUv),b.push(T.alphaMapUv),b.push(T.lightMapUv),b.push(T.aoMapUv),b.push(T.bumpMapUv),b.push(T.normalMapUv),b.push(T.displacementMapUv),b.push(T.emissiveMapUv),b.push(T.metalnessMapUv),b.push(T.roughnessMapUv),b.push(T.anisotropyMapUv),b.push(T.clearcoatMapUv),b.push(T.clearcoatNormalMapUv),b.push(T.clearcoatRoughnessMapUv),b.push(T.iridescenceMapUv),b.push(T.iridescenceThicknessMapUv),b.push(T.sheenColorMapUv),b.push(T.sheenRoughnessMapUv),b.push(T.specularMapUv),b.push(T.specularColorMapUv),b.push(T.specularIntensityMapUv),b.push(T.transmissionMapUv),b.push(T.thicknessMapUv),b.push(T.combine),b.push(T.fogExp2),b.push(T.sizeAttenuation),b.push(T.morphTargetsCount),b.push(T.morphAttributeCount),b.push(T.numDirLights),b.push(T.numPointLights),b.push(T.numSpotLights),b.push(T.numSpotLightMaps),b.push(T.numHemiLights),b.push(T.numRectAreaLights),b.push(T.numDirLightShadows),b.push(T.numPointLightShadows),b.push(T.numSpotLightShadows),b.push(T.numSpotLightShadowsWithMaps),b.push(T.numLightProbes),b.push(T.shadowMapType),b.push(T.toneMapping),b.push(T.numClippingPlanes),b.push(T.numClipIntersection),b.push(T.depthPacking)}function S(b,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),b.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),b.push(a.mask)}function v(b){const T=p[b.type];let N;if(T){const C=vn[T];N=Lz.clone(C.uniforms)}else N=b.uniforms;return N}function z(b,T){let N=d.get(T);return N!==void 0?++N.usedTimes:(N=new Mv(n,T,b,i),c.push(N),d.set(T,N)),N}function O(b){if(--b.usedTimes===0){const T=c.indexOf(b);c[T]=c[c.length-1],c.pop(),d.delete(b.cacheKey),b.destroy()}}function x(b){o.remove(b)}function G(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:v,acquireProgram:z,releaseProgram:O,releaseShaderCache:x,programs:c,dispose:G}}function yv(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function s(a){n.delete(a)}function i(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:s,update:i,dispose:r}}function vv(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Vh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function $h(){const n=[];let e=0;const t=[],s=[],i=[];function r(){e=0,t.length=0,s.length=0,i.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,M,_,m,f){let S=n[e];return S===void 0?(S={id:u.id,object:u,geometry:p,material:M,materialVariant:a(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:f},n[e]=S):(S.id=u.id,S.object=u,S.geometry=p,S.material=M,S.materialVariant=a(u),S.groupOrder=_,S.renderOrder=u.renderOrder,S.z=m,S.group=f),e++,S}function l(u,p,M,_,m,f){const S=o(u,p,M,_,m,f);M.transmission>0?s.push(S):M.transparent===!0?i.push(S):t.push(S)}function c(u,p,M,_,m,f){const S=o(u,p,M,_,m,f);M.transmission>0?s.unshift(S):M.transparent===!0?i.unshift(S):t.unshift(S)}function d(u,p,M){t.length>1&&t.sort(u||vv),s.length>1&&s.sort(p||Vh),i.length>1&&i.sort(p||Vh),M&&(t.reverse(),s.reverse(),i.reverse())}function h(){for(let u=e,p=n.length;u<p;u++){const M=n[u];if(M.id===null)break;M.id=null,M.object=null,M.geometry=null,M.material=null,M.group=null}}return{opaque:t,transmissive:s,transparent:i,init:r,push:l,unshift:c,finish:h,sort:d}}function Ov(){let n=new WeakMap;function e(s,i){const r=n.get(s);let a;return r===void 0?(a=new $h,n.set(s,[a])):i>=r.length?(a=new $h,r.push(a)):a=r[i],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function xv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new Ze};break;case"SpotLight":t={position:new P,direction:new P,color:new Ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new Ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new Ze,groundColor:new Ze};break;case"RectAreaLight":t={color:new Ze,position:new P,halfWidth:new P,halfHeight:new P};break}return n[e.id]=t,t}}}function Sv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Av=0;function Ev(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Dv(n){const e=new xv,t=Sv(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)s.probe.push(new P);const i=new P,r=new Rt,a=new Rt;function o(c){let d=0,h=0,u=0;for(let T=0;T<9;T++)s.probe[T].set(0,0,0);let p=0,M=0,_=0,m=0,f=0,S=0,v=0,z=0,O=0,x=0,G=0;c.sort(Ev);for(let T=0,N=c.length;T<N;T++){const C=c[T],W=C.color,Q=C.intensity,se=C.distance;let H=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Yi?H=C.shadow.map.texture:H=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)d+=W.r*Q,h+=W.g*Q,u+=W.b*Q;else if(C.isLightProbe){for(let ee=0;ee<9;ee++)s.probe[ee].addScaledVector(C.sh.coefficients[ee],Q);G++}else if(C.isDirectionalLight){const ee=e.get(C);if(ee.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const J=C.shadow,ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,s.directionalShadow[p]=ue,s.directionalShadowMap[p]=H,s.directionalShadowMatrix[p]=C.shadow.matrix,S++}s.directional[p]=ee,p++}else if(C.isSpotLight){const ee=e.get(C);ee.position.setFromMatrixPosition(C.matrixWorld),ee.color.copy(W).multiplyScalar(Q),ee.distance=se,ee.coneCos=Math.cos(C.angle),ee.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),ee.decay=C.decay,s.spot[_]=ee;const J=C.shadow;if(C.map&&(s.spotLightMap[O]=C.map,O++,J.updateMatrices(C),C.castShadow&&x++),s.spotLightMatrix[_]=J.matrix,C.castShadow){const ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,s.spotShadow[_]=ue,s.spotShadowMap[_]=H,z++}_++}else if(C.isRectAreaLight){const ee=e.get(C);ee.color.copy(W).multiplyScalar(Q),ee.halfWidth.set(C.width*.5,0,0),ee.halfHeight.set(0,C.height*.5,0),s.rectArea[m]=ee,m++}else if(C.isPointLight){const ee=e.get(C);if(ee.color.copy(C.color).multiplyScalar(C.intensity),ee.distance=C.distance,ee.decay=C.decay,C.castShadow){const J=C.shadow,ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,ue.shadowCameraNear=J.camera.near,ue.shadowCameraFar=J.camera.far,s.pointShadow[M]=ue,s.pointShadowMap[M]=H,s.pointShadowMatrix[M]=C.shadow.matrix,v++}s.point[M]=ee,M++}else if(C.isHemisphereLight){const ee=e.get(C);ee.skyColor.copy(C.color).multiplyScalar(Q),ee.groundColor.copy(C.groundColor).multiplyScalar(Q),s.hemi[f]=ee,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=Be.LTC_FLOAT_1,s.rectAreaLTC2=Be.LTC_FLOAT_2):(s.rectAreaLTC1=Be.LTC_HALF_1,s.rectAreaLTC2=Be.LTC_HALF_2)),s.ambient[0]=d,s.ambient[1]=h,s.ambient[2]=u;const b=s.hash;(b.directionalLength!==p||b.pointLength!==M||b.spotLength!==_||b.rectAreaLength!==m||b.hemiLength!==f||b.numDirectionalShadows!==S||b.numPointShadows!==v||b.numSpotShadows!==z||b.numSpotMaps!==O||b.numLightProbes!==G)&&(s.directional.length=p,s.spot.length=_,s.rectArea.length=m,s.point.length=M,s.hemi.length=f,s.directionalShadow.length=S,s.directionalShadowMap.length=S,s.pointShadow.length=v,s.pointShadowMap.length=v,s.spotShadow.length=z,s.spotShadowMap.length=z,s.directionalShadowMatrix.length=S,s.pointShadowMatrix.length=v,s.spotLightMatrix.length=z+O-x,s.spotLightMap.length=O,s.numSpotLightShadowsWithMaps=x,s.numLightProbes=G,b.directionalLength=p,b.pointLength=M,b.spotLength=_,b.rectAreaLength=m,b.hemiLength=f,b.numDirectionalShadows=S,b.numPointShadows=v,b.numSpotShadows=z,b.numSpotMaps=O,b.numLightProbes=G,s.version=Av++)}function l(c,d){let h=0,u=0,p=0,M=0,_=0;const m=d.matrixWorldInverse;for(let f=0,S=c.length;f<S;f++){const v=c[f];if(v.isDirectionalLight){const z=s.directional[h];z.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),z.direction.sub(i),z.direction.transformDirection(m),h++}else if(v.isSpotLight){const z=s.spot[p];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),z.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),z.direction.sub(i),z.direction.transformDirection(m),p++}else if(v.isRectAreaLight){const z=s.rectArea[M];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),a.identity(),r.copy(v.matrixWorld),r.premultiply(m),a.extractRotation(r),z.halfWidth.set(v.width*.5,0,0),z.halfHeight.set(0,v.height*.5,0),z.halfWidth.applyMatrix4(a),z.halfHeight.applyMatrix4(a),M++}else if(v.isPointLight){const z=s.point[u];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),u++}else if(v.isHemisphereLight){const z=s.hemi[_];z.direction.setFromMatrixPosition(v.matrixWorld),z.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:s}}function Hh(n){const e=new Dv(n),t=[],s=[],i=[];function r(u){h.camera=u,t.length=0,s.length=0,i.length=0}function a(u){t.push(u)}function o(u){s.push(u)}function l(u){i.push(u)}function c(){e.setup(t)}function d(u){e.setupView(t,u)}const h={lightsArray:t,shadowsArray:s,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:d,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Iv(n){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Hh(n),e.set(i,[o])):r>=a.length?(o=new Hh(n),a.push(o)):o=a[r],o}function s(){e=new WeakMap}return{get:t,dispose:s}}const Tv=`void main() {
4058
+ `+be)}else H!==""?Qe("WebGLProgram: Program Info Log:",H):(ee===""||J==="")&&(he=!1);he&&(C.diagnostics={runnable:ue,programLog:H,vertexShader:{log:ee,prefix:m},fragmentShader:{log:J,prefix:f}})}i.deleteShader(O),i.deleteShader(x),b=new To(i,_),T=tv(i,_)}let b;this.getUniforms=function(){return b===void 0&&G(this),b};let T;this.getAttributes=function(){return T===void 0&&G(this),T};let N=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return N===!1&&(N=i.getProgramParameter(_,$y)),N},this.destroy=function(){s.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Hy++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=O,this.fragmentShader=x,this}let gv=0;class bv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,s){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(s)===!1&&(i.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const s of t)s.usedTimes--,s.usedTimes===0&&this.shaderCache.delete(s.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let s=t.get(e);return s===void 0&&(s=new Set,t.set(e,s)),s}_getShaderStage(e){const t=this.shaderCache;let s=t.get(e);return s===void 0&&(s=new zv(e),t.set(e,s)),s}}class zv{constructor(e){this.id=gv++,this.code=e,this.usedTimes=0}}function _v(n){return n===Yi||n===Yo||n===Ko}function wv(n,e,t,s,i,r){const a=new su,o=new bv,l=new Set,c=[],d=new Map,h=s.logarithmicDepthBuffer;let u=s.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(b){return l.add(b),b===0?"uv":`uv${b}`}function _(b,T,N,C,W,Q){const se=C.fog,H=W.geometry,ee=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?C.environment:null,J=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap,ue=e.get(b.envMap||ee,J),he=ue&&ue.mapping===pl?ue.image.height:null,Se=p[b.type];b.precision!==null&&(u=s.getMaxPrecision(b.precision),u!==b.precision&&Qe("WebGLProgram.getParameters:",b.precision,"not supported, using",u,"instead."));const be=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Re=be!==void 0?be.length:0;let ht=0;H.morphAttributes.position!==void 0&&(ht=1),H.morphAttributes.normal!==void 0&&(ht=2),H.morphAttributes.color!==void 0&&(ht=3);let ct,tt,oe,ye;if(Se){const ke=vn[Se];ct=ke.vertexShader,tt=ke.fragmentShader}else{ct=b.vertexShader,tt=b.fragmentShader;const ke=o.getVertexShaderStage(b),Yt=o.getFragmentShaderStage(b);o.update(b,ke,Yt),oe=ke.id,ye=Yt.id}const Me=n.getRenderTarget(),et=n.state.buffers.depth.getReversed(),it=W.isInstancedMesh===!0,Ye=W.isBatchedMesh===!0,qt=!!b.map,pt=!!b.matcap,dt=!!ue,At=!!b.aoMap,vt=!!b.lightMap,Pt=!!b.bumpMap&&b.wireframe===!1,ts=!!b.normalMap,ss=!!b.displacementMap,ls=!!b.emissiveMap,Xt=!!b.metalnessMap,Zt=!!b.roughnessMap,j=b.anisotropy>0,vs=b.clearcoat>0,gt=b.dispersion>0,R=b.iridescence>0,w=b.sheen>0,$=b.transmission>0,K=j&&!!b.anisotropyMap,te=vs&&!!b.clearcoatMap,we=vs&&!!b.clearcoatNormalMap,Ae=vs&&!!b.clearcoatRoughnessMap,ne=R&&!!b.iridescenceMap,ie=R&&!!b.iridescenceThicknessMap,Ee=w&&!!b.sheenColorMap,Ve=w&&!!b.sheenRoughnessMap,Ge=!!b.specularMap,xe=!!b.specularColorMap,Xe=!!b.specularIntensityMap,Ke=$&&!!b.transmissionMap,rt=$&&!!b.thicknessMap,L=!!b.gradientMap,Oe=!!b.alphaMap,ae=b.alphaTest>0,Ie=!!b.alphaHash,Ne=!!b.extensions;let ce=En;b.toneMapped&&(Me===null||Me.isXRRenderTarget===!0)&&(ce=n.toneMapping);const $e={shaderID:Se,shaderType:b.type,shaderName:b.name,vertexShader:ct,fragmentShader:tt,defines:b.defines,customVertexShaderID:oe,customFragmentShaderID:ye,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:u,batching:Ye,batchingColor:Ye&&W._colorsTexture!==null,instancing:it,instancingColor:it&&W.instanceColor!==null,instancingMorph:it&&W.morphTexture!==null,outputColorSpace:Me===null?n.outputColorSpace:Me.isXRRenderTarget===!0?Me.texture.colorSpace:xt.workingColorSpace,alphaToCoverage:!!b.alphaToCoverage,map:qt,matcap:pt,envMap:dt,envMapMode:dt&&ue.mapping,envMapCubeUVHeight:he,aoMap:At,lightMap:vt,bumpMap:Pt,normalMap:ts,displacementMap:ss,emissiveMap:ls,normalMapObjectSpace:ts&&b.normalMapType===Qb,normalMapTangentSpace:ts&&b.normalMapType===xd,packedNormalMap:ts&&b.normalMapType===xd&&_v(b.normalMap.format),metalnessMap:Xt,roughnessMap:Zt,anisotropy:j,anisotropyMap:K,clearcoat:vs,clearcoatMap:te,clearcoatNormalMap:we,clearcoatRoughnessMap:Ae,dispersion:gt,iridescence:R,iridescenceMap:ne,iridescenceThicknessMap:ie,sheen:w,sheenColorMap:Ee,sheenRoughnessMap:Ve,specularMap:Ge,specularColorMap:xe,specularIntensityMap:Xe,transmission:$,transmissionMap:Ke,thicknessMap:rt,gradientMap:L,opaque:b.transparent===!1&&b.blending===ji&&b.alphaToCoverage===!1,alphaMap:Oe,alphaTest:ae,alphaHash:Ie,combine:b.combine,mapUv:qt&&M(b.map.channel),aoMapUv:At&&M(b.aoMap.channel),lightMapUv:vt&&M(b.lightMap.channel),bumpMapUv:Pt&&M(b.bumpMap.channel),normalMapUv:ts&&M(b.normalMap.channel),displacementMapUv:ss&&M(b.displacementMap.channel),emissiveMapUv:ls&&M(b.emissiveMap.channel),metalnessMapUv:Xt&&M(b.metalnessMap.channel),roughnessMapUv:Zt&&M(b.roughnessMap.channel),anisotropyMapUv:K&&M(b.anisotropyMap.channel),clearcoatMapUv:te&&M(b.clearcoatMap.channel),clearcoatNormalMapUv:we&&M(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&M(b.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&M(b.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&M(b.iridescenceThicknessMap.channel),sheenColorMapUv:Ee&&M(b.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&M(b.sheenRoughnessMap.channel),specularMapUv:Ge&&M(b.specularMap.channel),specularColorMapUv:xe&&M(b.specularColorMap.channel),specularIntensityMapUv:Xe&&M(b.specularIntensityMap.channel),transmissionMapUv:Ke&&M(b.transmissionMap.channel),thicknessMapUv:rt&&M(b.thicknessMap.channel),alphaMapUv:Oe&&M(b.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ts||j),vertexNormals:!!H.attributes.normal,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!H.attributes.uv&&(qt||Oe),fog:!!se,useFog:b.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:b.wireframe===!1&&(b.flatShading===!0||H.attributes.normal===void 0&&ts===!1&&(b.isMeshLambertMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isMeshPhysicalMaterial)),sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:et,skinning:W.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Re,morphTextureStride:ht,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:Q.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&N.length>0,shadowMapType:n.shadowMap.type,toneMapping:ce,decodeVideoTexture:qt&&b.map.isVideoTexture===!0&&xt.getTransfer(b.map.colorSpace)===Ut,decodeVideoTextureEmissive:ls&&b.emissiveMap.isVideoTexture===!0&&xt.getTransfer(b.emissiveMap.colorSpace)===Ut,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Hn,flipSided:b.side===Us,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Ne&&b.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ne&&b.extensions.multiDraw===!0||Ye)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return $e.vertexUv1s=l.has(1),$e.vertexUv2s=l.has(2),$e.vertexUv3s=l.has(3),l.clear(),$e}function m(b){const T=[];if(b.shaderID?T.push(b.shaderID):(T.push(b.customVertexShaderID),T.push(b.customFragmentShaderID)),b.defines!==void 0)for(const N in b.defines)T.push(N),T.push(b.defines[N]);return b.isRawShaderMaterial===!1&&(f(T,b),S(T,b),T.push(n.outputColorSpace)),T.push(b.customProgramCacheKey),T.join()}function f(b,T){b.push(T.precision),b.push(T.outputColorSpace),b.push(T.envMapMode),b.push(T.envMapCubeUVHeight),b.push(T.mapUv),b.push(T.alphaMapUv),b.push(T.lightMapUv),b.push(T.aoMapUv),b.push(T.bumpMapUv),b.push(T.normalMapUv),b.push(T.displacementMapUv),b.push(T.emissiveMapUv),b.push(T.metalnessMapUv),b.push(T.roughnessMapUv),b.push(T.anisotropyMapUv),b.push(T.clearcoatMapUv),b.push(T.clearcoatNormalMapUv),b.push(T.clearcoatRoughnessMapUv),b.push(T.iridescenceMapUv),b.push(T.iridescenceThicknessMapUv),b.push(T.sheenColorMapUv),b.push(T.sheenRoughnessMapUv),b.push(T.specularMapUv),b.push(T.specularColorMapUv),b.push(T.specularIntensityMapUv),b.push(T.transmissionMapUv),b.push(T.thicknessMapUv),b.push(T.combine),b.push(T.fogExp2),b.push(T.sizeAttenuation),b.push(T.morphTargetsCount),b.push(T.morphAttributeCount),b.push(T.numDirLights),b.push(T.numPointLights),b.push(T.numSpotLights),b.push(T.numSpotLightMaps),b.push(T.numHemiLights),b.push(T.numRectAreaLights),b.push(T.numDirLightShadows),b.push(T.numPointLightShadows),b.push(T.numSpotLightShadows),b.push(T.numSpotLightShadowsWithMaps),b.push(T.numLightProbes),b.push(T.shadowMapType),b.push(T.toneMapping),b.push(T.numClippingPlanes),b.push(T.numClipIntersection),b.push(T.depthPacking)}function S(b,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),b.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),b.push(a.mask)}function v(b){const T=p[b.type];let N;if(T){const C=vn[T];N=Lz.clone(C.uniforms)}else N=b.uniforms;return N}function z(b,T){let N=d.get(T);return N!==void 0?++N.usedTimes:(N=new Mv(n,T,b,i),c.push(N),d.set(T,N)),N}function O(b){if(--b.usedTimes===0){const T=c.indexOf(b);c[T]=c[c.length-1],c.pop(),d.delete(b.cacheKey),b.destroy()}}function x(b){o.remove(b)}function G(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:v,acquireProgram:z,releaseProgram:O,releaseShaderCache:x,programs:c,dispose:G}}function yv(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function s(a){n.delete(a)}function i(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:s,update:i,dispose:r}}function vv(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Vh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function $h(){const n=[];let e=0;const t=[],s=[],i=[];function r(){e=0,t.length=0,s.length=0,i.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,M,_,m,f){let S=n[e];return S===void 0?(S={id:u.id,object:u,geometry:p,material:M,materialVariant:a(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:f},n[e]=S):(S.id=u.id,S.object=u,S.geometry=p,S.material=M,S.materialVariant=a(u),S.groupOrder=_,S.renderOrder=u.renderOrder,S.z=m,S.group=f),e++,S}function l(u,p,M,_,m,f){const S=o(u,p,M,_,m,f);M.transmission>0?s.push(S):M.transparent===!0?i.push(S):t.push(S)}function c(u,p,M,_,m,f){const S=o(u,p,M,_,m,f);M.transmission>0?s.unshift(S):M.transparent===!0?i.unshift(S):t.unshift(S)}function d(u,p,M){t.length>1&&t.sort(u||vv),s.length>1&&s.sort(p||Vh),i.length>1&&i.sort(p||Vh),M&&(t.reverse(),s.reverse(),i.reverse())}function h(){for(let u=e,p=n.length;u<p;u++){const M=n[u];if(M.id===null)break;M.id=null,M.object=null,M.geometry=null,M.material=null,M.group=null}}return{opaque:t,transmissive:s,transparent:i,init:r,push:l,unshift:c,finish:h,sort:d}}function Ov(){let n=new WeakMap;function e(s,i){const r=n.get(s);let a;return r===void 0?(a=new $h,n.set(s,[a])):i>=r.length?(a=new $h,r.push(a)):a=r[i],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function xv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new Ze};break;case"SpotLight":t={position:new P,direction:new P,color:new Ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new Ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new Ze,groundColor:new Ze};break;case"RectAreaLight":t={color:new Ze,position:new P,halfWidth:new P,halfHeight:new P};break}return n[e.id]=t,t}}}function Sv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Av=0;function Ev(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Dv(n){const e=new xv,t=Sv(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)s.probe.push(new P);const i=new P,r=new Rt,a=new Rt;function o(c){let d=0,h=0,u=0;for(let T=0;T<9;T++)s.probe[T].set(0,0,0);let p=0,M=0,_=0,m=0,f=0,S=0,v=0,z=0,O=0,x=0,G=0;c.sort(Ev);for(let T=0,N=c.length;T<N;T++){const C=c[T],W=C.color,Q=C.intensity,se=C.distance;let H=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Yi?H=C.shadow.map.texture:H=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)d+=W.r*Q,h+=W.g*Q,u+=W.b*Q;else if(C.isLightProbe){for(let ee=0;ee<9;ee++)s.probe[ee].addScaledVector(C.sh.coefficients[ee],Q);G++}else if(C.isDirectionalLight){const ee=e.get(C);if(ee.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const J=C.shadow,ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,s.directionalShadow[p]=ue,s.directionalShadowMap[p]=H,s.directionalShadowMatrix[p]=C.shadow.matrix,S++}s.directional[p]=ee,p++}else if(C.isSpotLight){const ee=e.get(C);ee.position.setFromMatrixPosition(C.matrixWorld),ee.color.copy(W).multiplyScalar(Q),ee.distance=se,ee.coneCos=Math.cos(C.angle),ee.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),ee.decay=C.decay,s.spot[_]=ee;const J=C.shadow;if(C.map&&(s.spotLightMap[O]=C.map,O++,J.updateMatrices(C),C.castShadow&&x++),s.spotLightMatrix[_]=J.matrix,C.castShadow){const ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,s.spotShadow[_]=ue,s.spotShadowMap[_]=H,z++}_++}else if(C.isRectAreaLight){const ee=e.get(C);ee.color.copy(W).multiplyScalar(Q),ee.halfWidth.set(C.width*.5,0,0),ee.halfHeight.set(0,C.height*.5,0),s.rectArea[m]=ee,m++}else if(C.isPointLight){const ee=e.get(C);if(ee.color.copy(C.color).multiplyScalar(C.intensity),ee.distance=C.distance,ee.decay=C.decay,C.castShadow){const J=C.shadow,ue=t.get(C);ue.shadowIntensity=J.intensity,ue.shadowBias=J.bias,ue.shadowNormalBias=J.normalBias,ue.shadowRadius=J.radius,ue.shadowMapSize=J.mapSize,ue.shadowCameraNear=J.camera.near,ue.shadowCameraFar=J.camera.far,s.pointShadow[M]=ue,s.pointShadowMap[M]=H,s.pointShadowMatrix[M]=C.shadow.matrix,v++}s.point[M]=ee,M++}else if(C.isHemisphereLight){const ee=e.get(C);ee.skyColor.copy(C.color).multiplyScalar(Q),ee.groundColor.copy(C.groundColor).multiplyScalar(Q),s.hemi[f]=ee,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=Be.LTC_FLOAT_1,s.rectAreaLTC2=Be.LTC_FLOAT_2):(s.rectAreaLTC1=Be.LTC_HALF_1,s.rectAreaLTC2=Be.LTC_HALF_2)),s.ambient[0]=d,s.ambient[1]=h,s.ambient[2]=u;const b=s.hash;(b.directionalLength!==p||b.pointLength!==M||b.spotLength!==_||b.rectAreaLength!==m||b.hemiLength!==f||b.numDirectionalShadows!==S||b.numPointShadows!==v||b.numSpotShadows!==z||b.numSpotMaps!==O||b.numLightProbes!==G)&&(s.directional.length=p,s.spot.length=_,s.rectArea.length=m,s.point.length=M,s.hemi.length=f,s.directionalShadow.length=S,s.directionalShadowMap.length=S,s.pointShadow.length=v,s.pointShadowMap.length=v,s.spotShadow.length=z,s.spotShadowMap.length=z,s.directionalShadowMatrix.length=S,s.pointShadowMatrix.length=v,s.spotLightMatrix.length=z+O-x,s.spotLightMap.length=O,s.numSpotLightShadowsWithMaps=x,s.numLightProbes=G,b.directionalLength=p,b.pointLength=M,b.spotLength=_,b.rectAreaLength=m,b.hemiLength=f,b.numDirectionalShadows=S,b.numPointShadows=v,b.numSpotShadows=z,b.numSpotMaps=O,b.numLightProbes=G,s.version=Av++)}function l(c,d){let h=0,u=0,p=0,M=0,_=0;const m=d.matrixWorldInverse;for(let f=0,S=c.length;f<S;f++){const v=c[f];if(v.isDirectionalLight){const z=s.directional[h];z.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),z.direction.sub(i),z.direction.transformDirection(m),h++}else if(v.isSpotLight){const z=s.spot[p];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),z.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),z.direction.sub(i),z.direction.transformDirection(m),p++}else if(v.isRectAreaLight){const z=s.rectArea[M];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),a.identity(),r.copy(v.matrixWorld),r.premultiply(m),a.extractRotation(r),z.halfWidth.set(v.width*.5,0,0),z.halfHeight.set(0,v.height*.5,0),z.halfWidth.applyMatrix4(a),z.halfHeight.applyMatrix4(a),M++}else if(v.isPointLight){const z=s.point[u];z.position.setFromMatrixPosition(v.matrixWorld),z.position.applyMatrix4(m),u++}else if(v.isHemisphereLight){const z=s.hemi[_];z.direction.setFromMatrixPosition(v.matrixWorld),z.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:s}}function Hh(n){const e=new Dv(n),t=[],s=[],i=[];function r(u){h.camera=u,t.length=0,s.length=0,i.length=0}function a(u){t.push(u)}function o(u){s.push(u)}function l(u){i.push(u)}function c(){e.setup(t)}function d(u){e.setupView(t,u)}const h={lightsArray:t,shadowsArray:s,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:d,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Iv(n){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Hh(n),e.set(i,[o])):r>=a.length?(o=new Hh(n),a.push(o)):o=a[r],o}function s(){e=new WeakMap}return{get:t,dispose:s}}const Tv=`void main() {
4059
4059
  gl_Position = vec4( position, 1.0 );
4060
4060
  }`,Gv=`uniform sampler2D shadow_pass;
4061
4061
  uniform vec2 resolution;
@@ -4082,7 +4082,7 @@ void main() {
4082
4082
  squared_mean = squared_mean / samples;
4083
4083
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4084
4084
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4085
- }`,Rv=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],Bv=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],qh=new Rt,oa=new P,dc=new P;function Nv(n,e,t){let s=new iu;const i=new Je,r=new Je,a=new Jt,o=new jz,l=new Vz,c={},d=t.maxTextureSize,h={[yi]:Us,[Us]:yi,[Hn]:Hn},u=new _s({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Je},radius:{value:4}},vertexShader:Tv,fragmentShader:Gv}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const M=new os;M.setAttribute("position",new Ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ss(M,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=So;let f=this.type;this.render=function(x,G,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||x.length===0)return;this.type===Db&&(Qe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=So);const T=n.getRenderTarget(),N=n.getActiveCubeFace(),C=n.getActiveMipmapLevel(),W=n.state;W.setBlending(Kn),W.buffers.depth.getReversed()===!0?W.buffers.color.setClear(0,0,0,0):W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const Q=f!==this.type;Q&&G.traverse(function(se){se.material&&(Array.isArray(se.material)?se.material.forEach(H=>H.needsUpdate=!0):se.material.needsUpdate=!0)});for(let se=0,H=x.length;se<H;se++){const ee=x[se],J=ee.shadow;if(J===void 0){Qe("WebGLShadowMap:",ee,"has no shadow.");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const ue=J.getFrameExtents();i.multiply(ue),r.copy(J.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(r.x=Math.floor(d/ue.x),i.x=r.x*ue.x,J.mapSize.x=r.x),i.y>d&&(r.y=Math.floor(d/ue.y),i.y=r.y*ue.y,J.mapSize.y=r.y));const he=n.state.buffers.depth.getReversed();if(J.camera._reversedDepth=he,J.map===null||Q===!0){if(J.map!==null&&(J.map.depthTexture!==null&&(J.map.depthTexture.dispose(),J.map.depthTexture=null),J.map.dispose()),this.type===pa){if(ee.isPointLight){Qe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}J.map=new Dn(i.x,i.y,{format:Yi,type:ei,minFilter:Es,magFilter:Es,generateMipmaps:!1}),J.map.texture.name=ee.name+".shadowMap",J.map.depthTexture=new Wr(i.x,i.y,Mn),J.map.depthTexture.name=ee.name+".shadowMapDepth",J.map.depthTexture.format=ti,J.map.depthTexture.compareFunction=null,J.map.depthTexture.minFilter=ws,J.map.depthTexture.magFilter=ws}else ee.isPointLight?(J.map=new fm(i.x),J.map.depthTexture=new Pz(i.x,In)):(J.map=new Dn(i.x,i.y),J.map.depthTexture=new Wr(i.x,i.y,In)),J.map.depthTexture.name=ee.name+".shadowMap",J.map.depthTexture.format=ti,this.type===So?(J.map.depthTexture.compareFunction=he?eu:Jd,J.map.depthTexture.minFilter=Es,J.map.depthTexture.magFilter=Es):(J.map.depthTexture.compareFunction=null,J.map.depthTexture.minFilter=ws,J.map.depthTexture.magFilter=ws);J.camera.updateProjectionMatrix()}const Se=J.map.isWebGLCubeRenderTarget?6:1;for(let be=0;be<Se;be++){if(J.map.isWebGLCubeRenderTarget)n.setRenderTarget(J.map,be),n.clear();else{be===0&&(n.setRenderTarget(J.map),n.clear());const Re=J.getViewport(be);a.set(r.x*Re.x,r.y*Re.y,r.x*Re.z,r.y*Re.w),W.viewport(a)}if(ee.isPointLight){const Re=J.camera,ht=J.matrix,ct=ee.distance||Re.far;ct!==Re.far&&(Re.far=ct,Re.updateProjectionMatrix()),oa.setFromMatrixPosition(ee.matrixWorld),Re.position.copy(oa),dc.copy(Re.position),dc.add(Rv[be]),Re.up.copy(Bv[be]),Re.lookAt(dc),Re.updateMatrixWorld(),ht.makeTranslation(-oa.x,-oa.y,-oa.z),qh.multiplyMatrices(Re.projectionMatrix,Re.matrixWorldInverse),J._frustum.setFromProjectionMatrix(qh,Re.coordinateSystem,Re.reversedDepth)}else J.updateMatrices(ee);s=J.getFrustum(),z(G,b,J.camera,ee,this.type)}J.isPointLightShadow!==!0&&this.type===pa&&S(J,b),J.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(T,N,C)};function S(x,G){const b=e.update(_);u.defines.VSM_SAMPLES!==x.blurSamples&&(u.defines.VSM_SAMPLES=x.blurSamples,p.defines.VSM_SAMPLES=x.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),x.mapPass===null&&(x.mapPass=new Dn(i.x,i.y,{format:Yi,type:ei})),u.uniforms.shadow_pass.value=x.map.depthTexture,u.uniforms.resolution.value=x.mapSize,u.uniforms.radius.value=x.radius,n.setRenderTarget(x.mapPass),n.clear(),n.renderBufferDirect(G,null,b,u,_,null),p.uniforms.shadow_pass.value=x.mapPass.texture,p.uniforms.resolution.value=x.mapSize,p.uniforms.radius.value=x.radius,n.setRenderTarget(x.map),n.clear(),n.renderBufferDirect(G,null,b,p,_,null)}function v(x,G,b,T){let N=null;const C=b.isPointLight===!0?x.customDistanceMaterial:x.customDepthMaterial;if(C!==void 0)N=C;else if(N=b.isPointLight===!0?l:o,n.localClippingEnabled&&G.clipShadows===!0&&Array.isArray(G.clippingPlanes)&&G.clippingPlanes.length!==0||G.displacementMap&&G.displacementScale!==0||G.alphaMap&&G.alphaTest>0||G.map&&G.alphaTest>0||G.alphaToCoverage===!0){const W=N.uuid,Q=G.uuid;let se=c[W];se===void 0&&(se={},c[W]=se);let H=se[Q];H===void 0&&(H=N.clone(),se[Q]=H,G.addEventListener("dispose",O)),N=H}if(N.visible=G.visible,N.wireframe=G.wireframe,T===pa?N.side=G.shadowSide!==null?G.shadowSide:G.side:N.side=G.shadowSide!==null?G.shadowSide:h[G.side],N.alphaMap=G.alphaMap,N.alphaTest=G.alphaToCoverage===!0?.5:G.alphaTest,N.map=G.map,N.clipShadows=G.clipShadows,N.clippingPlanes=G.clippingPlanes,N.clipIntersection=G.clipIntersection,N.displacementMap=G.displacementMap,N.displacementScale=G.displacementScale,N.displacementBias=G.displacementBias,N.wireframeLinewidth=G.wireframeLinewidth,N.linewidth=G.linewidth,b.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const W=n.properties.get(N);W.light=b}return N}function z(x,G,b,T,N){if(x.visible===!1)return;if(x.layers.test(G.layers)&&(x.isMesh||x.isLine||x.isPoints)&&(x.castShadow||x.receiveShadow&&N===pa)&&(!x.frustumCulled||s.intersectsObject(x))){x.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,x.matrixWorld);const Q=e.update(x),se=x.material;if(Array.isArray(se)){const H=Q.groups;for(let ee=0,J=H.length;ee<J;ee++){const ue=H[ee],he=se[ue.materialIndex];if(he&&he.visible){const Se=v(x,he,T,N);x.onBeforeShadow(n,x,G,b,Q,Se,ue),n.renderBufferDirect(b,null,Q,Se,x,ue),x.onAfterShadow(n,x,G,b,Q,Se,ue)}}}else if(se.visible){const H=v(x,se,T,N);x.onBeforeShadow(n,x,G,b,Q,H,null),n.renderBufferDirect(b,null,Q,H,x,null),x.onAfterShadow(n,x,G,b,Q,H,null)}}const W=x.children;for(let Q=0,se=W.length;Q<se;Q++)z(W[Q],G,b,T,N)}function O(x){x.target.removeEventListener("dispose",O);for(const b in c){const T=c[b],N=x.target.uuid;N in T&&(T[N].dispose(),delete T[N])}}}function Cv(n,e){function t(){let L=!1;const Oe=new Jt;let ae=null;const Ie=new Jt(0,0,0,0);return{setMask:function(Ne){ae!==Ne&&!L&&(n.colorMask(Ne,Ne,Ne,Ne),ae=Ne)},setLocked:function(Ne){L=Ne},setClear:function(Ne,ce,$e,ke,Yt){Yt===!0&&(Ne*=ke,ce*=ke,$e*=ke),Oe.set(Ne,ce,$e,ke),Ie.equals(Oe)===!1&&(n.clearColor(Ne,ce,$e,ke),Ie.copy(Oe))},reset:function(){L=!1,ae=null,Ie.set(-1,0,0,0)}}}function s(){let L=!1,Oe=!1,ae=null,Ie=null,Ne=null;return{setReversed:function(ce){if(Oe!==ce){const $e=e.get("EXT_clip_control");ce?$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.ZERO_TO_ONE_EXT):$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.NEGATIVE_ONE_TO_ONE_EXT),Oe=ce;const ke=Ne;Ne=null,this.setClear(ke)}},getReversed:function(){return Oe},setTest:function(ce){ce?Me(n.DEPTH_TEST):et(n.DEPTH_TEST)},setMask:function(ce){ae!==ce&&!L&&(n.depthMask(ce),ae=ce)},setFunc:function(ce){if(Oe&&(ce=lz[ce]),Ie!==ce){switch(ce){case kc:n.depthFunc(n.NEVER);break;case Uc:n.depthFunc(n.ALWAYS);break;case Fc:n.depthFunc(n.LESS);break;case Cr:n.depthFunc(n.LEQUAL);break;case jc:n.depthFunc(n.EQUAL);break;case Vc:n.depthFunc(n.GEQUAL);break;case $c:n.depthFunc(n.GREATER);break;case Hc:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Ie=ce}},setLocked:function(ce){L=ce},setClear:function(ce){Ne!==ce&&(Ne=ce,Oe&&(ce=1-ce),n.clearDepth(ce))},reset:function(){L=!1,ae=null,Ie=null,Ne=null,Oe=!1}}}function i(){let L=!1,Oe=null,ae=null,Ie=null,Ne=null,ce=null,$e=null,ke=null,Yt=null;return{setTest:function(Wt){L||(Wt?Me(n.STENCIL_TEST):et(n.STENCIL_TEST))},setMask:function(Wt){Oe!==Wt&&!L&&(n.stencilMask(Wt),Oe=Wt)},setFunc:function(Wt,Ws,Ls){(ae!==Wt||Ie!==Ws||Ne!==Ls)&&(n.stencilFunc(Wt,Ws,Ls),ae=Wt,Ie=Ws,Ne=Ls)},setOp:function(Wt,Ws,Ls){(ce!==Wt||$e!==Ws||ke!==Ls)&&(n.stencilOp(Wt,Ws,Ls),ce=Wt,$e=Ws,ke=Ls)},setLocked:function(Wt){L=Wt},setClear:function(Wt){Yt!==Wt&&(n.clearStencil(Wt),Yt=Wt)},reset:function(){L=!1,Oe=null,ae=null,Ie=null,Ne=null,ce=null,$e=null,ke=null,Yt=null}}}const r=new t,a=new s,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},u={},p=new WeakMap,M=[],_=null,m=!1,f=null,S=null,v=null,z=null,O=null,x=null,G=null,b=new Ze(0,0,0),T=0,N=!1,C=null,W=null,Q=null,se=null,H=null;const ee=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ue=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?(ue=parseFloat(/^WebGL (\d)/.exec(he)[1]),J=ue>=1):he.indexOf("OpenGL ES")!==-1&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),J=ue>=2);let Se=null,be={};const Re=n.getParameter(n.SCISSOR_BOX),ht=n.getParameter(n.VIEWPORT),ct=new Jt().fromArray(Re),tt=new Jt().fromArray(ht);function oe(L,Oe,ae,Ie){const Ne=new Uint8Array(4),ce=n.createTexture();n.bindTexture(L,ce),n.texParameteri(L,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(L,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let $e=0;$e<ae;$e++)L===n.TEXTURE_3D||L===n.TEXTURE_2D_ARRAY?n.texImage3D(Oe,0,n.RGBA,1,1,Ie,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Oe+$e,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return ce}const ye={};ye[n.TEXTURE_2D]=oe(n.TEXTURE_2D,n.TEXTURE_2D,1),ye[n.TEXTURE_CUBE_MAP]=oe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ye[n.TEXTURE_2D_ARRAY]=oe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ye[n.TEXTURE_3D]=oe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Me(n.DEPTH_TEST),a.setFunc(Cr),Pt(!1),ts(Pu),Me(n.CULL_FACE),At(Kn);function Me(L){d[L]!==!0&&(n.enable(L),d[L]=!0)}function et(L){d[L]!==!1&&(n.disable(L),d[L]=!1)}function nt(L,Oe){return u[L]!==Oe?(n.bindFramebuffer(L,Oe),u[L]=Oe,L===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Oe),L===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Oe),!0):!1}function Ye(L,Oe){let ae=M,Ie=!1;if(L){ae=p.get(Oe),ae===void 0&&(ae=[],p.set(Oe,ae));const Ne=L.textures;if(ae.length!==Ne.length||ae[0]!==n.COLOR_ATTACHMENT0){for(let ce=0,$e=Ne.length;ce<$e;ce++)ae[ce]=n.COLOR_ATTACHMENT0+ce;ae.length=Ne.length,Ie=!0}}else ae[0]!==n.BACK&&(ae[0]=n.BACK,Ie=!0);Ie&&n.drawBuffers(ae)}function qt(L){return _!==L?(n.useProgram(L),_=L,!0):!1}const pt={[Pi]:n.FUNC_ADD,[Tb]:n.FUNC_SUBTRACT,[Gb]:n.FUNC_REVERSE_SUBTRACT};pt[Rb]=n.MIN,pt[Bb]=n.MAX;const dt={[Nb]:n.ZERO,[Cb]:n.ONE,[Pb]:n.SRC_COLOR,[Wc]:n.SRC_ALPHA,[jb]:n.SRC_ALPHA_SATURATE,[Ub]:n.DST_COLOR,[Lb]:n.DST_ALPHA,[Wb]:n.ONE_MINUS_SRC_COLOR,[Lc]:n.ONE_MINUS_SRC_ALPHA,[Fb]:n.ONE_MINUS_DST_COLOR,[kb]:n.ONE_MINUS_DST_ALPHA,[Vb]:n.CONSTANT_COLOR,[$b]:n.ONE_MINUS_CONSTANT_COLOR,[Hb]:n.CONSTANT_ALPHA,[qb]:n.ONE_MINUS_CONSTANT_ALPHA};function At(L,Oe,ae,Ie,Ne,ce,$e,ke,Yt,Wt){if(L===Kn){m===!0&&(et(n.BLEND),m=!1);return}if(m===!1&&(Me(n.BLEND),m=!0),L!==Ib){if(L!==f||Wt!==N){if((S!==Pi||O!==Pi)&&(n.blendEquation(n.FUNC_ADD),S=Pi,O=Pi),Wt)switch(L){case ji:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ci:n.blendFunc(n.ONE,n.ONE);break;case Wu:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Lu:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Ot("WebGLState: Invalid blending: ",L);break}else switch(L){case ji:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ci:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Wu:Ot("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Lu:Ot("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ot("WebGLState: Invalid blending: ",L);break}v=null,z=null,x=null,G=null,b.set(0,0,0),T=0,f=L,N=Wt}return}Ne=Ne||Oe,ce=ce||ae,$e=$e||Ie,(Oe!==S||Ne!==O)&&(n.blendEquationSeparate(pt[Oe],pt[Ne]),S=Oe,O=Ne),(ae!==v||Ie!==z||ce!==x||$e!==G)&&(n.blendFuncSeparate(dt[ae],dt[Ie],dt[ce],dt[$e]),v=ae,z=Ie,x=ce,G=$e),(ke.equals(b)===!1||Yt!==T)&&(n.blendColor(ke.r,ke.g,ke.b,Yt),b.copy(ke),T=Yt),f=L,N=!1}function vt(L,Oe){L.side===Hn?et(n.CULL_FACE):Me(n.CULL_FACE);let ae=L.side===Us;Oe&&(ae=!ae),Pt(ae),L.blending===ji&&L.transparent===!1?At(Kn):At(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const Ie=L.stencilWrite;o.setTest(Ie),Ie&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ls(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?Me(n.SAMPLE_ALPHA_TO_COVERAGE):et(n.SAMPLE_ALPHA_TO_COVERAGE)}function Pt(L){C!==L&&(L?n.frontFace(n.CW):n.frontFace(n.CCW),C=L)}function ts(L){L!==Ab?(Me(n.CULL_FACE),L!==W&&(L===Pu?n.cullFace(n.BACK):L===Eb?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):et(n.CULL_FACE),W=L}function ss(L){L!==Q&&(J&&n.lineWidth(L),Q=L)}function ls(L,Oe,ae){L?(Me(n.POLYGON_OFFSET_FILL),(se!==Oe||H!==ae)&&(se=Oe,H=ae,a.getReversed()&&(Oe=-Oe),n.polygonOffset(Oe,ae))):et(n.POLYGON_OFFSET_FILL)}function Xt(L){L?Me(n.SCISSOR_TEST):et(n.SCISSOR_TEST)}function Zt(L){L===void 0&&(L=n.TEXTURE0+ee-1),Se!==L&&(n.activeTexture(L),Se=L)}function j(L,Oe,ae){ae===void 0&&(Se===null?ae=n.TEXTURE0+ee-1:ae=Se);let Ie=be[ae];Ie===void 0&&(Ie={type:void 0,texture:void 0},be[ae]=Ie),(Ie.type!==L||Ie.texture!==Oe)&&(Se!==ae&&(n.activeTexture(ae),Se=ae),n.bindTexture(L,Oe||ye[L]),Ie.type=L,Ie.texture=Oe)}function vs(){const L=be[Se];L!==void 0&&L.type!==void 0&&(n.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function gt(){try{n.compressedTexImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function R(){try{n.compressedTexImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function w(){try{n.texSubImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function $(){try{n.texSubImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function K(){try{n.compressedTexSubImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function te(){try{n.compressedTexSubImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function we(){try{n.texStorage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function Ae(){try{n.texStorage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function ne(){try{n.texImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function ie(){try{n.texImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function Ee(L){return h[L]!==void 0?h[L]:n.getParameter(L)}function Ve(L,Oe){h[L]!==Oe&&(n.pixelStorei(L,Oe),h[L]=Oe)}function Ge(L){ct.equals(L)===!1&&(n.scissor(L.x,L.y,L.z,L.w),ct.copy(L))}function xe(L){tt.equals(L)===!1&&(n.viewport(L.x,L.y,L.z,L.w),tt.copy(L))}function Xe(L,Oe){let ae=c.get(Oe);ae===void 0&&(ae=new WeakMap,c.set(Oe,ae));let Ie=ae.get(L);Ie===void 0&&(Ie=n.getUniformBlockIndex(Oe,L.name),ae.set(L,Ie))}function Ke(L,Oe){const Ie=c.get(Oe).get(L);l.get(Oe)!==Ie&&(n.uniformBlockBinding(Oe,Ie,L.__bindingPointIndex),l.set(Oe,Ie))}function it(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},h={},Se=null,be={},u={},p=new WeakMap,M=[],_=null,m=!1,f=null,S=null,v=null,z=null,O=null,x=null,G=null,b=new Ze(0,0,0),T=0,N=!1,C=null,W=null,Q=null,se=null,H=null,ct.set(0,0,n.canvas.width,n.canvas.height),tt.set(0,0,n.canvas.width,n.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:Me,disable:et,bindFramebuffer:nt,drawBuffers:Ye,useProgram:qt,setBlending:At,setMaterial:vt,setFlipSided:Pt,setCullFace:ts,setLineWidth:ss,setPolygonOffset:ls,setScissorTest:Xt,activeTexture:Zt,bindTexture:j,unbindTexture:vs,compressedTexImage2D:gt,compressedTexImage3D:R,texImage2D:ne,texImage3D:ie,pixelStorei:Ve,getParameter:Ee,updateUBOMapping:Xe,uniformBlockBinding:Ke,texStorage2D:we,texStorage3D:Ae,texSubImage2D:w,texSubImage3D:$,compressedTexSubImage2D:K,compressedTexSubImage3D:te,scissor:Ge,viewport:xe,reset:it}}function Pv(n,e,t,s,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Je,d=new WeakMap,h=new Set;let u;const p=new WeakMap;let M=!1;try{M=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,w){return M?new OffscreenCanvas(R,w):Jo("canvas")}function m(R,w,$){let K=1;const te=gt(R);if((te.width>$||te.height>$)&&(K=$/Math.max(te.width,te.height)),K<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const we=Math.floor(K*te.width),Ae=Math.floor(K*te.height);u===void 0&&(u=_(we,Ae));const ne=w?_(we,Ae):u;return ne.width=we,ne.height=Ae,ne.getContext("2d").drawImage(R,0,0,we,Ae),Qe("WebGLRenderer: Texture has been resized from ("+te.width+"x"+te.height+") to ("+we+"x"+Ae+")."),ne}else return"data"in R&&Qe("WebGLRenderer: Image in DataTexture is too big ("+te.width+"x"+te.height+")."),R;return R}function f(R){return R.generateMipmaps}function S(R){n.generateMipmap(R)}function v(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function z(R,w,$,K,te,we=!1){if(R!==null){if(n[R]!==void 0)return n[R];Qe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ae;K&&(Ae=e.get("EXT_texture_norm16"),Ae||Qe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ne=w;if(w===n.RED&&($===n.FLOAT&&(ne=n.R32F),$===n.HALF_FLOAT&&(ne=n.R16F),$===n.UNSIGNED_BYTE&&(ne=n.R8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.R16_EXT),$===n.SHORT&&Ae&&(ne=Ae.R16_SNORM_EXT)),w===n.RED_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.R8UI),$===n.UNSIGNED_SHORT&&(ne=n.R16UI),$===n.UNSIGNED_INT&&(ne=n.R32UI),$===n.BYTE&&(ne=n.R8I),$===n.SHORT&&(ne=n.R16I),$===n.INT&&(ne=n.R32I)),w===n.RG&&($===n.FLOAT&&(ne=n.RG32F),$===n.HALF_FLOAT&&(ne=n.RG16F),$===n.UNSIGNED_BYTE&&(ne=n.RG8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RG16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RG16_SNORM_EXT)),w===n.RG_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RG8UI),$===n.UNSIGNED_SHORT&&(ne=n.RG16UI),$===n.UNSIGNED_INT&&(ne=n.RG32UI),$===n.BYTE&&(ne=n.RG8I),$===n.SHORT&&(ne=n.RG16I),$===n.INT&&(ne=n.RG32I)),w===n.RGB_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RGB8UI),$===n.UNSIGNED_SHORT&&(ne=n.RGB16UI),$===n.UNSIGNED_INT&&(ne=n.RGB32UI),$===n.BYTE&&(ne=n.RGB8I),$===n.SHORT&&(ne=n.RGB16I),$===n.INT&&(ne=n.RGB32I)),w===n.RGBA_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RGBA8UI),$===n.UNSIGNED_SHORT&&(ne=n.RGBA16UI),$===n.UNSIGNED_INT&&(ne=n.RGBA32UI),$===n.BYTE&&(ne=n.RGBA8I),$===n.SHORT&&(ne=n.RGBA16I),$===n.INT&&(ne=n.RGBA32I)),w===n.RGB&&($===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RGB16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RGB16_SNORM_EXT),$===n.UNSIGNED_INT_5_9_9_9_REV&&(ne=n.RGB9_E5),$===n.UNSIGNED_INT_10F_11F_11F_REV&&(ne=n.R11F_G11F_B10F)),w===n.RGBA){const ie=we?Qo:xt.getTransfer(te);$===n.FLOAT&&(ne=n.RGBA32F),$===n.HALF_FLOAT&&(ne=n.RGBA16F),$===n.UNSIGNED_BYTE&&(ne=ie===Ut?n.SRGB8_ALPHA8:n.RGBA8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RGBA16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RGBA16_SNORM_EXT),$===n.UNSIGNED_SHORT_4_4_4_4&&(ne=n.RGBA4),$===n.UNSIGNED_SHORT_5_5_5_1&&(ne=n.RGB5_A1)}return(ne===n.R16F||ne===n.R32F||ne===n.RG16F||ne===n.RG32F||ne===n.RGBA16F||ne===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function O(R,w){let $;return R?w===null||w===In||w===Sa?$=n.DEPTH24_STENCIL8:w===Mn?$=n.DEPTH32F_STENCIL8:w===xa&&($=n.DEPTH24_STENCIL8,Qe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===In||w===Sa?$=n.DEPTH_COMPONENT24:w===Mn?$=n.DEPTH_COMPONENT32F:w===xa&&($=n.DEPTH_COMPONENT16),$}function x(R,w){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==ws&&R.minFilter!==Es?Math.log2(Math.max(w.width,w.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?w.mipmaps.length:1}function G(R){const w=R.target;w.removeEventListener("dispose",G),T(w),w.isVideoTexture&&d.delete(w),w.isHTMLTexture&&h.delete(w)}function b(R){const w=R.target;w.removeEventListener("dispose",b),C(w)}function T(R){const w=s.get(R);if(w.__webglInit===void 0)return;const $=R.source,K=p.get($);if(K){const te=K[w.__cacheKey];te.usedTimes--,te.usedTimes===0&&N(R),Object.keys(K).length===0&&p.delete($)}s.remove(R)}function N(R){const w=s.get(R);n.deleteTexture(w.__webglTexture);const $=R.source,K=p.get($);delete K[w.__cacheKey],a.memory.textures--}function C(R){const w=s.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),s.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(w.__webglFramebuffer[K]))for(let te=0;te<w.__webglFramebuffer[K].length;te++)n.deleteFramebuffer(w.__webglFramebuffer[K][te]);else n.deleteFramebuffer(w.__webglFramebuffer[K]);w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer[K])}else{if(Array.isArray(w.__webglFramebuffer))for(let K=0;K<w.__webglFramebuffer.length;K++)n.deleteFramebuffer(w.__webglFramebuffer[K]);else n.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&n.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let K=0;K<w.__webglColorRenderbuffer.length;K++)w.__webglColorRenderbuffer[K]&&n.deleteRenderbuffer(w.__webglColorRenderbuffer[K]);w.__webglDepthRenderbuffer&&n.deleteRenderbuffer(w.__webglDepthRenderbuffer)}const $=R.textures;for(let K=0,te=$.length;K<te;K++){const we=s.get($[K]);we.__webglTexture&&(n.deleteTexture(we.__webglTexture),a.memory.textures--),s.remove($[K])}s.remove(R)}let W=0;function Q(){W=0}function se(){return W}function H(R){W=R}function ee(){const R=W;return R>=i.maxTextures&&Qe("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),W+=1,R}function J(R){const w=[];return w.push(R.wrapS),w.push(R.wrapT),w.push(R.wrapR||0),w.push(R.magFilter),w.push(R.minFilter),w.push(R.anisotropy),w.push(R.internalFormat),w.push(R.format),w.push(R.type),w.push(R.generateMipmaps),w.push(R.premultiplyAlpha),w.push(R.flipY),w.push(R.unpackAlignment),w.push(R.colorSpace),w.join()}function ue(R,w){const $=s.get(R);if(R.isVideoTexture&&j(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&$.__version!==R.version){const K=R.image;if(K===null)Qe("WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)Qe("WebGLRenderer: Texture marked for update but image is incomplete");else{et($,R,w);return}}else R.isExternalTexture&&($.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,$.__webglTexture,n.TEXTURE0+w)}function he(R,w){const $=s.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){et($,R,w);return}else R.isExternalTexture&&($.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,$.__webglTexture,n.TEXTURE0+w)}function Se(R,w){const $=s.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){et($,R,w);return}t.bindTexture(n.TEXTURE_3D,$.__webglTexture,n.TEXTURE0+w)}function be(R,w){const $=s.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&$.__version!==R.version){nt($,R,w);return}t.bindTexture(n.TEXTURE_CUBE_MAP,$.__webglTexture,n.TEXTURE0+w)}const Re={[qc]:n.REPEAT,[Xn]:n.CLAMP_TO_EDGE,[Xc]:n.MIRRORED_REPEAT},ht={[ws]:n.NEAREST,[Kb]:n.NEAREST_MIPMAP_NEAREST,[Ra]:n.NEAREST_MIPMAP_LINEAR,[Es]:n.LINEAR,[Tl]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},ct={[Jb]:n.NEVER,[iz]:n.ALWAYS,[ez]:n.LESS,[Jd]:n.LEQUAL,[tz]:n.EQUAL,[eu]:n.GEQUAL,[sz]:n.GREATER,[nz]:n.NOTEQUAL};function tt(R,w){if(w.type===Mn&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Es||w.magFilter===Tl||w.magFilter===Ra||w.magFilter===Ui||w.minFilter===Es||w.minFilter===Tl||w.minFilter===Ra||w.minFilter===Ui)&&Qe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Re[w.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Re[w.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Re[w.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ht[w.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ht[w.minFilter]),w.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,ct[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===ws||w.minFilter!==Ra&&w.minFilter!==Ui||w.type===Mn&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||s.get(w).__currentAnisotropy){const $=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,$.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,i.getMaxAnisotropy())),s.get(w).__currentAnisotropy=w.anisotropy}}}function oe(R,w){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,w.addEventListener("dispose",G));const K=w.source;let te=p.get(K);te===void 0&&(te={},p.set(K,te));const we=J(w);if(we!==R.__cacheKey){te[we]===void 0&&(te[we]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,$=!0),te[we].usedTimes++;const Ae=te[R.__cacheKey];Ae!==void 0&&(te[R.__cacheKey].usedTimes--,Ae.usedTimes===0&&N(w)),R.__cacheKey=we,R.__webglTexture=te[we].texture}return $}function ye(R,w,$){return Math.floor(Math.floor(R/$)/w)}function Me(R,w,$,K){const we=R.updateRanges;if(we.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,w.width,w.height,$,K,w.data);else{we.sort((Ve,Ge)=>Ve.start-Ge.start);let Ae=0;for(let Ve=1;Ve<we.length;Ve++){const Ge=we[Ae],xe=we[Ve],Xe=Ge.start+Ge.count,Ke=ye(xe.start,w.width,4),it=ye(Ge.start,w.width,4);xe.start<=Xe+1&&Ke===it&&ye(xe.start+xe.count-1,w.width,4)===Ke?Ge.count=Math.max(Ge.count,xe.start+xe.count-Ge.start):(++Ae,we[Ae]=xe)}we.length=Ae+1;const ne=t.getParameter(n.UNPACK_ROW_LENGTH),ie=t.getParameter(n.UNPACK_SKIP_PIXELS),Ee=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,w.width);for(let Ve=0,Ge=we.length;Ve<Ge;Ve++){const xe=we[Ve],Xe=Math.floor(xe.start/4),Ke=Math.ceil(xe.count/4),it=Xe%w.width,L=Math.floor(Xe/w.width),Oe=Ke,ae=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,it),t.pixelStorei(n.UNPACK_SKIP_ROWS,L),t.texSubImage2D(n.TEXTURE_2D,0,it,L,Oe,ae,$,K,w.data)}R.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,ne),t.pixelStorei(n.UNPACK_SKIP_PIXELS,ie),t.pixelStorei(n.UNPACK_SKIP_ROWS,Ee)}}function et(R,w,$){let K=n.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(K=n.TEXTURE_2D_ARRAY),w.isData3DTexture&&(K=n.TEXTURE_3D);const te=oe(R,w),we=w.source;t.bindTexture(K,R.__webglTexture,n.TEXTURE0+$);const Ae=s.get(we);if(we.version!==Ae.__version||te===!0){if(t.activeTexture(n.TEXTURE0+$),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){const ae=xt.getPrimaries(xt.workingColorSpace),Ie=w.colorSpace===mi?null:xt.getPrimaries(w.colorSpace),Ne=w.colorSpace===mi||ae===Ie?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ne)}t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment);let ie=m(w.image,!1,i.maxTextureSize);ie=vs(w,ie);const Ee=r.convert(w.format,w.colorSpace),Ve=r.convert(w.type);let Ge=z(w.internalFormat,Ee,Ve,w.normalized,w.colorSpace,w.isVideoTexture);tt(K,w);let xe;const Xe=w.mipmaps,Ke=w.isVideoTexture!==!0,it=Ae.__version===void 0||te===!0,L=we.dataReady,Oe=x(w,ie);if(w.isDepthTexture)Ge=O(w.format===Fi,w.type),it&&(Ke?t.texStorage2D(n.TEXTURE_2D,1,Ge,ie.width,ie.height):t.texImage2D(n.TEXTURE_2D,0,Ge,ie.width,ie.height,0,Ee,Ve,null));else if(w.isDataTexture)if(Xe.length>0){Ke&&it&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,Xe[0].width,Xe[0].height);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,Ve,xe.data):t.texImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,Ee,Ve,xe.data);w.generateMipmaps=!1}else Ke?(it&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ie.width,ie.height),L&&Me(w,ie,Ee,Ve)):t.texImage2D(n.TEXTURE_2D,0,Ge,ie.width,ie.height,0,Ee,Ve,ie.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Ke&&it&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ge,Xe[0].width,Xe[0].height,ie.depth);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)if(xe=Xe[ae],w.format!==gn)if(Ee!==null)if(Ke){if(L)if(w.layerUpdates.size>0){const Ne=Oh(xe.width,xe.height,w.format,w.type);for(const ce of w.layerUpdates){const $e=xe.data.subarray(ce*Ne/xe.data.BYTES_PER_ELEMENT,(ce+1)*Ne/xe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,ce,xe.width,xe.height,1,Ee,$e)}w.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,xe.width,xe.height,ie.depth,Ee,xe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ae,Ge,xe.width,xe.height,ie.depth,0,xe.data,0,0);else Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ke?L&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,xe.width,xe.height,ie.depth,Ee,Ve,xe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Ge,xe.width,xe.height,ie.depth,0,Ee,Ve,xe.data)}else{Ke&&it&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,Xe[0].width,Xe[0].height);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],w.format!==gn?Ee!==null?Ke?L&&t.compressedTexSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,xe.data):t.compressedTexImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,xe.data):Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,Ve,xe.data):t.texImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,Ee,Ve,xe.data)}else if(w.isDataArrayTexture)if(Ke){if(it&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ge,ie.width,ie.height,ie.depth),L)if(w.layerUpdates.size>0){const ae=Oh(ie.width,ie.height,w.format,w.type);for(const Ie of w.layerUpdates){const Ne=ie.data.subarray(Ie*ae/ie.data.BYTES_PER_ELEMENT,(Ie+1)*ae/ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Ie,ie.width,ie.height,1,Ee,Ve,Ne)}w.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ie.width,ie.height,ie.depth,Ee,Ve,ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ge,ie.width,ie.height,ie.depth,0,Ee,Ve,ie.data);else if(w.isData3DTexture)Ke?(it&&t.texStorage3D(n.TEXTURE_3D,Oe,Ge,ie.width,ie.height,ie.depth),L&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ie.width,ie.height,ie.depth,Ee,Ve,ie.data)):t.texImage3D(n.TEXTURE_3D,0,Ge,ie.width,ie.height,ie.depth,0,Ee,Ve,ie.data);else if(w.isFramebufferTexture){if(it)if(Ke)t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ie.width,ie.height);else{let ae=ie.width,Ie=ie.height;for(let Ne=0;Ne<Oe;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,Ge,ae,Ie,0,Ee,Ve,null),ae>>=1,Ie>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in n){const ae=n.canvas;if(ae.hasAttribute("layoutsubtree")||ae.setAttribute("layoutsubtree","true"),ie.parentNode!==ae){ae.appendChild(ie),h.add(w),ae.onpaint=Ie=>{const Ne=Ie.changedElements;for(const ce of h)Ne.includes(ce.image)&&(ce.needsUpdate=!0)},ae.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,ie);else{const Ne=n.RGBA,ce=n.RGBA,$e=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Ne,ce,$e,ie)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Xe.length>0){if(Ke&&it){const ae=gt(Xe[0]);t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ae.width,ae.height)}for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Ee,Ve,xe):t.texImage2D(n.TEXTURE_2D,ae,Ge,Ee,Ve,xe);w.generateMipmaps=!1}else if(Ke){if(it){const ae=gt(ie);t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ae.width,ae.height)}L&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ee,Ve,ie)}else t.texImage2D(n.TEXTURE_2D,0,Ge,Ee,Ve,ie);f(w)&&S(K),Ae.__version=we.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function nt(R,w,$){if(w.image.length!==6)return;const K=oe(R,w),te=w.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+$);const we=s.get(te);if(te.version!==we.__version||K===!0){t.activeTexture(n.TEXTURE0+$);const Ae=xt.getPrimaries(xt.workingColorSpace),ne=w.colorSpace===mi?null:xt.getPrimaries(w.colorSpace),ie=w.colorSpace===mi||Ae===ne?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ie);const Ee=w.isCompressedTexture||w.image[0].isCompressedTexture,Ve=w.image[0]&&w.image[0].isDataTexture,Ge=[];for(let ce=0;ce<6;ce++)!Ee&&!Ve?Ge[ce]=m(w.image[ce],!0,i.maxCubemapSize):Ge[ce]=Ve?w.image[ce].image:w.image[ce],Ge[ce]=vs(w,Ge[ce]);const xe=Ge[0],Xe=r.convert(w.format,w.colorSpace),Ke=r.convert(w.type),it=z(w.internalFormat,Xe,Ke,w.normalized,w.colorSpace),L=w.isVideoTexture!==!0,Oe=we.__version===void 0||K===!0,ae=te.dataReady;let Ie=x(w,xe);tt(n.TEXTURE_CUBE_MAP,w);let Ne;if(Ee){L&&Oe&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ie,it,xe.width,xe.height);for(let ce=0;ce<6;ce++){Ne=Ge[ce].mipmaps;for(let $e=0;$e<Ne.length;$e++){const ke=Ne[$e];w.format!==gn?Xe!==null?L?ae&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ke.width,ke.height,Xe,ke.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,it,ke.width,ke.height,0,ke.data):Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ke.width,ke.height,Xe,Ke,ke.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,it,ke.width,ke.height,0,Xe,Ke,ke.data)}}}else{if(Ne=w.mipmaps,L&&Oe){Ne.length>0&&Ie++;const ce=gt(Ge[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ie,it,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(Ve){L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Ge[ce].width,Ge[ce].height,Xe,Ke,Ge[ce].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,it,Ge[ce].width,Ge[ce].height,0,Xe,Ke,Ge[ce].data);for(let $e=0;$e<Ne.length;$e++){const Yt=Ne[$e].image[ce].image;L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Yt.width,Yt.height,Xe,Ke,Yt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,it,Yt.width,Yt.height,0,Xe,Ke,Yt.data)}}else{L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Xe,Ke,Ge[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,it,Xe,Ke,Ge[ce]);for(let $e=0;$e<Ne.length;$e++){const ke=Ne[$e];L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Xe,Ke,ke.image[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,it,Xe,Ke,ke.image[ce])}}}f(w)&&S(n.TEXTURE_CUBE_MAP),we.__version=te.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function Ye(R,w,$,K,te,we){const Ae=r.convert($.format,$.colorSpace),ne=r.convert($.type),ie=z($.internalFormat,Ae,ne,$.normalized,$.colorSpace),Ee=s.get(w),Ve=s.get($);if(Ve.__renderTarget=w,!Ee.__hasExternalTextures){const Ge=Math.max(1,w.width>>we),xe=Math.max(1,w.height>>we);te===n.TEXTURE_3D||te===n.TEXTURE_2D_ARRAY?t.texImage3D(te,we,ie,Ge,xe,w.depth,0,Ae,ne,null):t.texImage2D(te,we,ie,Ge,xe,0,Ae,ne,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,K,te,Ve.__webglTexture,0,Xt(w)):(te===n.TEXTURE_2D||te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,K,te,Ve.__webglTexture,we),t.bindFramebuffer(n.FRAMEBUFFER,null)}function qt(R,w,$){if(n.bindRenderbuffer(n.RENDERBUFFER,R),w.depthBuffer){const K=w.depthTexture,te=K&&K.isDepthTexture?K.type:null,we=O(w.stencilBuffer,te),Ae=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;Zt(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Xt(w),we,w.width,w.height):$?n.renderbufferStorageMultisample(n.RENDERBUFFER,Xt(w),we,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,we,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ae,n.RENDERBUFFER,R)}else{const K=w.textures;for(let te=0;te<K.length;te++){const we=K[te],Ae=r.convert(we.format,we.colorSpace),ne=r.convert(we.type),ie=z(we.internalFormat,Ae,ne,we.normalized,we.colorSpace);Zt(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Xt(w),ie,w.width,w.height):$?n.renderbufferStorageMultisample(n.RENDERBUFFER,Xt(w),ie,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,ie,w.width,w.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function pt(R,w,$){const K=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const te=s.get(w.depthTexture);if(te.__renderTarget=w,(!te.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),K){if(te.__webglInit===void 0&&(te.__webglInit=!0,w.depthTexture.addEventListener("dispose",G)),te.__webglTexture===void 0){te.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),tt(n.TEXTURE_CUBE_MAP,w.depthTexture);const Ee=r.convert(w.depthTexture.format),Ve=r.convert(w.depthTexture.type);let Ge;w.depthTexture.format===ti?Ge=n.DEPTH_COMPONENT24:w.depthTexture.format===Fi&&(Ge=n.DEPTH24_STENCIL8);for(let xe=0;xe<6;xe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,Ge,w.width,w.height,0,Ee,Ve,null)}}else ue(w.depthTexture,0);const we=te.__webglTexture,Ae=Xt(w),ne=K?n.TEXTURE_CUBE_MAP_POSITIVE_X+$:n.TEXTURE_2D,ie=w.depthTexture.format===Fi?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(w.depthTexture.format===ti)Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ie,ne,we,0,Ae):n.framebufferTexture2D(n.FRAMEBUFFER,ie,ne,we,0);else if(w.depthTexture.format===Fi)Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ie,ne,we,0,Ae):n.framebufferTexture2D(n.FRAMEBUFFER,ie,ne,we,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function dt(R){const w=s.get(R),$=R.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==R.depthTexture){const K=R.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),K){const te=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,K.removeEventListener("dispose",te)};K.addEventListener("dispose",te),w.__depthDisposeCallback=te}w.__boundDepthTexture=K}if(R.depthTexture&&!w.__autoAllocateDepthBuffer)if($)for(let K=0;K<6;K++)pt(w.__webglFramebuffer[K],R,K);else{const K=R.texture.mipmaps;K&&K.length>0?pt(w.__webglFramebuffer[0],R,0):pt(w.__webglFramebuffer,R,0)}else if($){w.__webglDepthbuffer=[];for(let K=0;K<6;K++)if(t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[K]),w.__webglDepthbuffer[K]===void 0)w.__webglDepthbuffer[K]=n.createRenderbuffer(),qt(w.__webglDepthbuffer[K],R,!1);else{const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=w.__webglDepthbuffer[K];n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,te,n.RENDERBUFFER,we)}}else{const K=R.texture.mipmaps;if(K&&K.length>0?t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=n.createRenderbuffer(),qt(w.__webglDepthbuffer,R,!1);else{const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=w.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,te,n.RENDERBUFFER,we)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function At(R,w,$){const K=s.get(R);w!==void 0&&Ye(K.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),$!==void 0&&dt(R)}function vt(R){const w=R.texture,$=s.get(R),K=s.get(w);R.addEventListener("dispose",b);const te=R.textures,we=R.isWebGLCubeRenderTarget===!0,Ae=te.length>1;if(Ae||(K.__webglTexture===void 0&&(K.__webglTexture=n.createTexture()),K.__version=w.version,a.memory.textures++),we){$.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0){$.__webglFramebuffer[ne]=[];for(let ie=0;ie<w.mipmaps.length;ie++)$.__webglFramebuffer[ne][ie]=n.createFramebuffer()}else $.__webglFramebuffer[ne]=n.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){$.__webglFramebuffer=[];for(let ne=0;ne<w.mipmaps.length;ne++)$.__webglFramebuffer[ne]=n.createFramebuffer()}else $.__webglFramebuffer=n.createFramebuffer();if(Ae)for(let ne=0,ie=te.length;ne<ie;ne++){const Ee=s.get(te[ne]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Zt(R)===!1){$.__webglMultisampledFramebuffer=n.createFramebuffer(),$.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,$.__webglMultisampledFramebuffer);for(let ne=0;ne<te.length;ne++){const ie=te[ne];$.__webglColorRenderbuffer[ne]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,$.__webglColorRenderbuffer[ne]);const Ee=r.convert(ie.format,ie.colorSpace),Ve=r.convert(ie.type),Ge=z(ie.internalFormat,Ee,Ve,ie.normalized,ie.colorSpace,R.isXRRenderTarget===!0),xe=Xt(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,xe,Ge,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ne,n.RENDERBUFFER,$.__webglColorRenderbuffer[ne])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&($.__webglDepthRenderbuffer=n.createRenderbuffer(),qt($.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(we){t.bindTexture(n.TEXTURE_CUBE_MAP,K.__webglTexture),tt(n.TEXTURE_CUBE_MAP,w);for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0)for(let ie=0;ie<w.mipmaps.length;ie++)Ye($.__webglFramebuffer[ne][ie],R,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ie);else Ye($.__webglFramebuffer[ne],R,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0);f(w)&&S(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ae){for(let ne=0,ie=te.length;ne<ie;ne++){const Ee=te[ne],Ve=s.get(Ee);let Ge=n.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ge=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ge,Ve.__webglTexture),tt(Ge,Ee),Ye($.__webglFramebuffer,R,Ee,n.COLOR_ATTACHMENT0+ne,Ge,0),f(Ee)&&S(Ge)}t.unbindTexture()}else{let ne=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(ne=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ne,K.__webglTexture),tt(ne,w),w.mipmaps&&w.mipmaps.length>0)for(let ie=0;ie<w.mipmaps.length;ie++)Ye($.__webglFramebuffer[ie],R,w,n.COLOR_ATTACHMENT0,ne,ie);else Ye($.__webglFramebuffer,R,w,n.COLOR_ATTACHMENT0,ne,0);f(w)&&S(ne),t.unbindTexture()}R.depthBuffer&&dt(R)}function Pt(R){const w=R.textures;for(let $=0,K=w.length;$<K;$++){const te=w[$];if(f(te)){const we=v(R),Ae=s.get(te).__webglTexture;t.bindTexture(we,Ae),S(we),t.unbindTexture()}}}const ts=[],ss=[];function ls(R){if(R.samples>0){if(Zt(R)===!1){const w=R.textures,$=R.width,K=R.height;let te=n.COLOR_BUFFER_BIT;const we=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=s.get(R),ne=w.length>1;if(ne)for(let Ee=0;Ee<w.length;Ee++)t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer);const ie=R.texture.mipmaps;ie&&ie.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let Ee=0;Ee<w.length;Ee++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(te|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(te|=n.STENCIL_BUFFER_BIT)),ne){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);const Ve=s.get(w[Ee]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ve,0)}n.blitFramebuffer(0,0,$,K,0,0,$,K,te,n.NEAREST),l===!0&&(ts.length=0,ss.length=0,ts.push(n.COLOR_ATTACHMENT0+Ee),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ts.push(we),ss.push(we),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,ss)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ts))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ne)for(let Ee=0;Ee<w.length;Ee++){t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);const Ve=s.get(w[Ee]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,Ve,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const w=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[w])}}}function Xt(R){return Math.min(i.maxSamples,R.samples)}function Zt(R){const w=s.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function j(R){const w=a.render.frame;d.get(R)!==w&&(d.set(R,w),R.update())}function vs(R,w){const $=R.colorSpace,K=R.format,te=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||$!==Zo&&$!==mi&&(xt.getTransfer($)===Ut?(K!==gn||te!==qs)&&Qe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ot("WebGLTextures: Unsupported texture color space:",$)),w}function gt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=ee,this.resetTextureUnits=Q,this.getTextureUnits=se,this.setTextureUnits=H,this.setTexture2D=ue,this.setTexture2DArray=he,this.setTexture3D=Se,this.setTextureCube=be,this.rebindTextures=At,this.setupRenderTarget=vt,this.updateRenderTargetMipmap=Pt,this.updateMultisampleRenderTarget=ls,this.setupDepthRenderbuffer=dt,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=Zt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Wv(n,e){function t(s,i=mi){let r;const a=xt.getTransfer(i);if(s===qs)return n.UNSIGNED_BYTE;if(s===qd)return n.UNSIGNED_SHORT_4_4_4_4;if(s===Xd)return n.UNSIGNED_SHORT_5_5_5_1;if(s===Yp)return n.UNSIGNED_INT_5_9_9_9_REV;if(s===Kp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(s===qp)return n.BYTE;if(s===Xp)return n.SHORT;if(s===xa)return n.UNSIGNED_SHORT;if(s===Hd)return n.INT;if(s===In)return n.UNSIGNED_INT;if(s===Mn)return n.FLOAT;if(s===ei)return n.HALF_FLOAT;if(s===Zp)return n.ALPHA;if(s===Qp)return n.RGB;if(s===gn)return n.RGBA;if(s===ti)return n.DEPTH_COMPONENT;if(s===Fi)return n.DEPTH_STENCIL;if(s===Yd)return n.RED;if(s===Kd)return n.RED_INTEGER;if(s===Yi)return n.RG;if(s===Zd)return n.RG_INTEGER;if(s===Qd)return n.RGBA_INTEGER;if(s===Ao||s===Eo||s===Do||s===Io)if(a===Ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(s===Ao)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Eo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Do)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Io)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(s===Ao)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Eo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Do)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Io)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Yc||s===Kc||s===Zc||s===Qc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(s===Yc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Kc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Zc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Qc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Jc||s===ed||s===td||s===sd||s===nd||s===Yo||s===id)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(s===Jc||s===ed)return a===Ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(s===td)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(s===sd)return r.COMPRESSED_R11_EAC;if(s===nd)return r.COMPRESSED_SIGNED_R11_EAC;if(s===Yo)return r.COMPRESSED_RG11_EAC;if(s===id)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(s===rd||s===ad||s===od||s===ld||s===cd||s===dd||s===ud||s===hd||s===fd||s===pd||s===md||s===Md||s===gd||s===bd)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(s===rd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===ad)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===od)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ld)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===cd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===dd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ud)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===hd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===fd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===pd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===md)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Md)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===bd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===zd||s===_d||s===wd)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(s===zd)return a===Ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===_d)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===wd)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===yd||s===vd||s===Ko||s===Od)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(s===yd)return r.COMPRESSED_RED_RGTC1_EXT;if(s===vd)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Ko)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Od)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Sa?n.UNSIGNED_INT_24_8:n[s]!==void 0?n[s]:null}return{convert:t}}const Lv=`
4085
+ }`,Rv=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],Bv=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],qh=new Rt,oa=new P,dc=new P;function Nv(n,e,t){let s=new iu;const i=new Je,r=new Je,a=new Jt,o=new jz,l=new Vz,c={},d=t.maxTextureSize,h={[vi]:Us,[Us]:vi,[Hn]:Hn},u=new _s({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Je},radius:{value:4}},vertexShader:Tv,fragmentShader:Gv}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const M=new os;M.setAttribute("position",new Ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ss(M,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=So;let f=this.type;this.render=function(x,G,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||x.length===0)return;this.type===Db&&(Qe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=So);const T=n.getRenderTarget(),N=n.getActiveCubeFace(),C=n.getActiveMipmapLevel(),W=n.state;W.setBlending(Kn),W.buffers.depth.getReversed()===!0?W.buffers.color.setClear(0,0,0,0):W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const Q=f!==this.type;Q&&G.traverse(function(se){se.material&&(Array.isArray(se.material)?se.material.forEach(H=>H.needsUpdate=!0):se.material.needsUpdate=!0)});for(let se=0,H=x.length;se<H;se++){const ee=x[se],J=ee.shadow;if(J===void 0){Qe("WebGLShadowMap:",ee,"has no shadow.");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const ue=J.getFrameExtents();i.multiply(ue),r.copy(J.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(r.x=Math.floor(d/ue.x),i.x=r.x*ue.x,J.mapSize.x=r.x),i.y>d&&(r.y=Math.floor(d/ue.y),i.y=r.y*ue.y,J.mapSize.y=r.y));const he=n.state.buffers.depth.getReversed();if(J.camera._reversedDepth=he,J.map===null||Q===!0){if(J.map!==null&&(J.map.depthTexture!==null&&(J.map.depthTexture.dispose(),J.map.depthTexture=null),J.map.dispose()),this.type===pa){if(ee.isPointLight){Qe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}J.map=new Dn(i.x,i.y,{format:Yi,type:ei,minFilter:Es,magFilter:Es,generateMipmaps:!1}),J.map.texture.name=ee.name+".shadowMap",J.map.depthTexture=new Wr(i.x,i.y,Mn),J.map.depthTexture.name=ee.name+".shadowMapDepth",J.map.depthTexture.format=ti,J.map.depthTexture.compareFunction=null,J.map.depthTexture.minFilter=ws,J.map.depthTexture.magFilter=ws}else ee.isPointLight?(J.map=new fm(i.x),J.map.depthTexture=new Pz(i.x,In)):(J.map=new Dn(i.x,i.y),J.map.depthTexture=new Wr(i.x,i.y,In)),J.map.depthTexture.name=ee.name+".shadowMap",J.map.depthTexture.format=ti,this.type===So?(J.map.depthTexture.compareFunction=he?eu:Jd,J.map.depthTexture.minFilter=Es,J.map.depthTexture.magFilter=Es):(J.map.depthTexture.compareFunction=null,J.map.depthTexture.minFilter=ws,J.map.depthTexture.magFilter=ws);J.camera.updateProjectionMatrix()}const Se=J.map.isWebGLCubeRenderTarget?6:1;for(let be=0;be<Se;be++){if(J.map.isWebGLCubeRenderTarget)n.setRenderTarget(J.map,be),n.clear();else{be===0&&(n.setRenderTarget(J.map),n.clear());const Re=J.getViewport(be);a.set(r.x*Re.x,r.y*Re.y,r.x*Re.z,r.y*Re.w),W.viewport(a)}if(ee.isPointLight){const Re=J.camera,ht=J.matrix,ct=ee.distance||Re.far;ct!==Re.far&&(Re.far=ct,Re.updateProjectionMatrix()),oa.setFromMatrixPosition(ee.matrixWorld),Re.position.copy(oa),dc.copy(Re.position),dc.add(Rv[be]),Re.up.copy(Bv[be]),Re.lookAt(dc),Re.updateMatrixWorld(),ht.makeTranslation(-oa.x,-oa.y,-oa.z),qh.multiplyMatrices(Re.projectionMatrix,Re.matrixWorldInverse),J._frustum.setFromProjectionMatrix(qh,Re.coordinateSystem,Re.reversedDepth)}else J.updateMatrices(ee);s=J.getFrustum(),z(G,b,J.camera,ee,this.type)}J.isPointLightShadow!==!0&&this.type===pa&&S(J,b),J.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(T,N,C)};function S(x,G){const b=e.update(_);u.defines.VSM_SAMPLES!==x.blurSamples&&(u.defines.VSM_SAMPLES=x.blurSamples,p.defines.VSM_SAMPLES=x.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),x.mapPass===null&&(x.mapPass=new Dn(i.x,i.y,{format:Yi,type:ei})),u.uniforms.shadow_pass.value=x.map.depthTexture,u.uniforms.resolution.value=x.mapSize,u.uniforms.radius.value=x.radius,n.setRenderTarget(x.mapPass),n.clear(),n.renderBufferDirect(G,null,b,u,_,null),p.uniforms.shadow_pass.value=x.mapPass.texture,p.uniforms.resolution.value=x.mapSize,p.uniforms.radius.value=x.radius,n.setRenderTarget(x.map),n.clear(),n.renderBufferDirect(G,null,b,p,_,null)}function v(x,G,b,T){let N=null;const C=b.isPointLight===!0?x.customDistanceMaterial:x.customDepthMaterial;if(C!==void 0)N=C;else if(N=b.isPointLight===!0?l:o,n.localClippingEnabled&&G.clipShadows===!0&&Array.isArray(G.clippingPlanes)&&G.clippingPlanes.length!==0||G.displacementMap&&G.displacementScale!==0||G.alphaMap&&G.alphaTest>0||G.map&&G.alphaTest>0||G.alphaToCoverage===!0){const W=N.uuid,Q=G.uuid;let se=c[W];se===void 0&&(se={},c[W]=se);let H=se[Q];H===void 0&&(H=N.clone(),se[Q]=H,G.addEventListener("dispose",O)),N=H}if(N.visible=G.visible,N.wireframe=G.wireframe,T===pa?N.side=G.shadowSide!==null?G.shadowSide:G.side:N.side=G.shadowSide!==null?G.shadowSide:h[G.side],N.alphaMap=G.alphaMap,N.alphaTest=G.alphaToCoverage===!0?.5:G.alphaTest,N.map=G.map,N.clipShadows=G.clipShadows,N.clippingPlanes=G.clippingPlanes,N.clipIntersection=G.clipIntersection,N.displacementMap=G.displacementMap,N.displacementScale=G.displacementScale,N.displacementBias=G.displacementBias,N.wireframeLinewidth=G.wireframeLinewidth,N.linewidth=G.linewidth,b.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const W=n.properties.get(N);W.light=b}return N}function z(x,G,b,T,N){if(x.visible===!1)return;if(x.layers.test(G.layers)&&(x.isMesh||x.isLine||x.isPoints)&&(x.castShadow||x.receiveShadow&&N===pa)&&(!x.frustumCulled||s.intersectsObject(x))){x.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,x.matrixWorld);const Q=e.update(x),se=x.material;if(Array.isArray(se)){const H=Q.groups;for(let ee=0,J=H.length;ee<J;ee++){const ue=H[ee],he=se[ue.materialIndex];if(he&&he.visible){const Se=v(x,he,T,N);x.onBeforeShadow(n,x,G,b,Q,Se,ue),n.renderBufferDirect(b,null,Q,Se,x,ue),x.onAfterShadow(n,x,G,b,Q,Se,ue)}}}else if(se.visible){const H=v(x,se,T,N);x.onBeforeShadow(n,x,G,b,Q,H,null),n.renderBufferDirect(b,null,Q,H,x,null),x.onAfterShadow(n,x,G,b,Q,H,null)}}const W=x.children;for(let Q=0,se=W.length;Q<se;Q++)z(W[Q],G,b,T,N)}function O(x){x.target.removeEventListener("dispose",O);for(const b in c){const T=c[b],N=x.target.uuid;N in T&&(T[N].dispose(),delete T[N])}}}function Cv(n,e){function t(){let L=!1;const Oe=new Jt;let ae=null;const Ie=new Jt(0,0,0,0);return{setMask:function(Ne){ae!==Ne&&!L&&(n.colorMask(Ne,Ne,Ne,Ne),ae=Ne)},setLocked:function(Ne){L=Ne},setClear:function(Ne,ce,$e,ke,Yt){Yt===!0&&(Ne*=ke,ce*=ke,$e*=ke),Oe.set(Ne,ce,$e,ke),Ie.equals(Oe)===!1&&(n.clearColor(Ne,ce,$e,ke),Ie.copy(Oe))},reset:function(){L=!1,ae=null,Ie.set(-1,0,0,0)}}}function s(){let L=!1,Oe=!1,ae=null,Ie=null,Ne=null;return{setReversed:function(ce){if(Oe!==ce){const $e=e.get("EXT_clip_control");ce?$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.ZERO_TO_ONE_EXT):$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.NEGATIVE_ONE_TO_ONE_EXT),Oe=ce;const ke=Ne;Ne=null,this.setClear(ke)}},getReversed:function(){return Oe},setTest:function(ce){ce?Me(n.DEPTH_TEST):et(n.DEPTH_TEST)},setMask:function(ce){ae!==ce&&!L&&(n.depthMask(ce),ae=ce)},setFunc:function(ce){if(Oe&&(ce=lz[ce]),Ie!==ce){switch(ce){case kc:n.depthFunc(n.NEVER);break;case Uc:n.depthFunc(n.ALWAYS);break;case Fc:n.depthFunc(n.LESS);break;case Cr:n.depthFunc(n.LEQUAL);break;case jc:n.depthFunc(n.EQUAL);break;case Vc:n.depthFunc(n.GEQUAL);break;case $c:n.depthFunc(n.GREATER);break;case Hc:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Ie=ce}},setLocked:function(ce){L=ce},setClear:function(ce){Ne!==ce&&(Ne=ce,Oe&&(ce=1-ce),n.clearDepth(ce))},reset:function(){L=!1,ae=null,Ie=null,Ne=null,Oe=!1}}}function i(){let L=!1,Oe=null,ae=null,Ie=null,Ne=null,ce=null,$e=null,ke=null,Yt=null;return{setTest:function(Wt){L||(Wt?Me(n.STENCIL_TEST):et(n.STENCIL_TEST))},setMask:function(Wt){Oe!==Wt&&!L&&(n.stencilMask(Wt),Oe=Wt)},setFunc:function(Wt,Ws,Ls){(ae!==Wt||Ie!==Ws||Ne!==Ls)&&(n.stencilFunc(Wt,Ws,Ls),ae=Wt,Ie=Ws,Ne=Ls)},setOp:function(Wt,Ws,Ls){(ce!==Wt||$e!==Ws||ke!==Ls)&&(n.stencilOp(Wt,Ws,Ls),ce=Wt,$e=Ws,ke=Ls)},setLocked:function(Wt){L=Wt},setClear:function(Wt){Yt!==Wt&&(n.clearStencil(Wt),Yt=Wt)},reset:function(){L=!1,Oe=null,ae=null,Ie=null,Ne=null,ce=null,$e=null,ke=null,Yt=null}}}const r=new t,a=new s,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},u={},p=new WeakMap,M=[],_=null,m=!1,f=null,S=null,v=null,z=null,O=null,x=null,G=null,b=new Ze(0,0,0),T=0,N=!1,C=null,W=null,Q=null,se=null,H=null;const ee=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ue=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?(ue=parseFloat(/^WebGL (\d)/.exec(he)[1]),J=ue>=1):he.indexOf("OpenGL ES")!==-1&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),J=ue>=2);let Se=null,be={};const Re=n.getParameter(n.SCISSOR_BOX),ht=n.getParameter(n.VIEWPORT),ct=new Jt().fromArray(Re),tt=new Jt().fromArray(ht);function oe(L,Oe,ae,Ie){const Ne=new Uint8Array(4),ce=n.createTexture();n.bindTexture(L,ce),n.texParameteri(L,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(L,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let $e=0;$e<ae;$e++)L===n.TEXTURE_3D||L===n.TEXTURE_2D_ARRAY?n.texImage3D(Oe,0,n.RGBA,1,1,Ie,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Oe+$e,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return ce}const ye={};ye[n.TEXTURE_2D]=oe(n.TEXTURE_2D,n.TEXTURE_2D,1),ye[n.TEXTURE_CUBE_MAP]=oe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ye[n.TEXTURE_2D_ARRAY]=oe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ye[n.TEXTURE_3D]=oe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Me(n.DEPTH_TEST),a.setFunc(Cr),Pt(!1),ts(Pu),Me(n.CULL_FACE),At(Kn);function Me(L){d[L]!==!0&&(n.enable(L),d[L]=!0)}function et(L){d[L]!==!1&&(n.disable(L),d[L]=!1)}function it(L,Oe){return u[L]!==Oe?(n.bindFramebuffer(L,Oe),u[L]=Oe,L===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Oe),L===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Oe),!0):!1}function Ye(L,Oe){let ae=M,Ie=!1;if(L){ae=p.get(Oe),ae===void 0&&(ae=[],p.set(Oe,ae));const Ne=L.textures;if(ae.length!==Ne.length||ae[0]!==n.COLOR_ATTACHMENT0){for(let ce=0,$e=Ne.length;ce<$e;ce++)ae[ce]=n.COLOR_ATTACHMENT0+ce;ae.length=Ne.length,Ie=!0}}else ae[0]!==n.BACK&&(ae[0]=n.BACK,Ie=!0);Ie&&n.drawBuffers(ae)}function qt(L){return _!==L?(n.useProgram(L),_=L,!0):!1}const pt={[Pi]:n.FUNC_ADD,[Tb]:n.FUNC_SUBTRACT,[Gb]:n.FUNC_REVERSE_SUBTRACT};pt[Rb]=n.MIN,pt[Bb]=n.MAX;const dt={[Nb]:n.ZERO,[Cb]:n.ONE,[Pb]:n.SRC_COLOR,[Wc]:n.SRC_ALPHA,[jb]:n.SRC_ALPHA_SATURATE,[Ub]:n.DST_COLOR,[Lb]:n.DST_ALPHA,[Wb]:n.ONE_MINUS_SRC_COLOR,[Lc]:n.ONE_MINUS_SRC_ALPHA,[Fb]:n.ONE_MINUS_DST_COLOR,[kb]:n.ONE_MINUS_DST_ALPHA,[Vb]:n.CONSTANT_COLOR,[$b]:n.ONE_MINUS_CONSTANT_COLOR,[Hb]:n.CONSTANT_ALPHA,[qb]:n.ONE_MINUS_CONSTANT_ALPHA};function At(L,Oe,ae,Ie,Ne,ce,$e,ke,Yt,Wt){if(L===Kn){m===!0&&(et(n.BLEND),m=!1);return}if(m===!1&&(Me(n.BLEND),m=!0),L!==Ib){if(L!==f||Wt!==N){if((S!==Pi||O!==Pi)&&(n.blendEquation(n.FUNC_ADD),S=Pi,O=Pi),Wt)switch(L){case ji:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ci:n.blendFunc(n.ONE,n.ONE);break;case Wu:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Lu:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Ot("WebGLState: Invalid blending: ",L);break}else switch(L){case ji:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ci:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Wu:Ot("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Lu:Ot("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ot("WebGLState: Invalid blending: ",L);break}v=null,z=null,x=null,G=null,b.set(0,0,0),T=0,f=L,N=Wt}return}Ne=Ne||Oe,ce=ce||ae,$e=$e||Ie,(Oe!==S||Ne!==O)&&(n.blendEquationSeparate(pt[Oe],pt[Ne]),S=Oe,O=Ne),(ae!==v||Ie!==z||ce!==x||$e!==G)&&(n.blendFuncSeparate(dt[ae],dt[Ie],dt[ce],dt[$e]),v=ae,z=Ie,x=ce,G=$e),(ke.equals(b)===!1||Yt!==T)&&(n.blendColor(ke.r,ke.g,ke.b,Yt),b.copy(ke),T=Yt),f=L,N=!1}function vt(L,Oe){L.side===Hn?et(n.CULL_FACE):Me(n.CULL_FACE);let ae=L.side===Us;Oe&&(ae=!ae),Pt(ae),L.blending===ji&&L.transparent===!1?At(Kn):At(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const Ie=L.stencilWrite;o.setTest(Ie),Ie&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ls(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?Me(n.SAMPLE_ALPHA_TO_COVERAGE):et(n.SAMPLE_ALPHA_TO_COVERAGE)}function Pt(L){C!==L&&(L?n.frontFace(n.CW):n.frontFace(n.CCW),C=L)}function ts(L){L!==Ab?(Me(n.CULL_FACE),L!==W&&(L===Pu?n.cullFace(n.BACK):L===Eb?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):et(n.CULL_FACE),W=L}function ss(L){L!==Q&&(J&&n.lineWidth(L),Q=L)}function ls(L,Oe,ae){L?(Me(n.POLYGON_OFFSET_FILL),(se!==Oe||H!==ae)&&(se=Oe,H=ae,a.getReversed()&&(Oe=-Oe),n.polygonOffset(Oe,ae))):et(n.POLYGON_OFFSET_FILL)}function Xt(L){L?Me(n.SCISSOR_TEST):et(n.SCISSOR_TEST)}function Zt(L){L===void 0&&(L=n.TEXTURE0+ee-1),Se!==L&&(n.activeTexture(L),Se=L)}function j(L,Oe,ae){ae===void 0&&(Se===null?ae=n.TEXTURE0+ee-1:ae=Se);let Ie=be[ae];Ie===void 0&&(Ie={type:void 0,texture:void 0},be[ae]=Ie),(Ie.type!==L||Ie.texture!==Oe)&&(Se!==ae&&(n.activeTexture(ae),Se=ae),n.bindTexture(L,Oe||ye[L]),Ie.type=L,Ie.texture=Oe)}function vs(){const L=be[Se];L!==void 0&&L.type!==void 0&&(n.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function gt(){try{n.compressedTexImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function R(){try{n.compressedTexImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function w(){try{n.texSubImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function $(){try{n.texSubImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function K(){try{n.compressedTexSubImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function te(){try{n.compressedTexSubImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function we(){try{n.texStorage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function Ae(){try{n.texStorage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function ne(){try{n.texImage2D(...arguments)}catch(L){Ot("WebGLState:",L)}}function ie(){try{n.texImage3D(...arguments)}catch(L){Ot("WebGLState:",L)}}function Ee(L){return h[L]!==void 0?h[L]:n.getParameter(L)}function Ve(L,Oe){h[L]!==Oe&&(n.pixelStorei(L,Oe),h[L]=Oe)}function Ge(L){ct.equals(L)===!1&&(n.scissor(L.x,L.y,L.z,L.w),ct.copy(L))}function xe(L){tt.equals(L)===!1&&(n.viewport(L.x,L.y,L.z,L.w),tt.copy(L))}function Xe(L,Oe){let ae=c.get(Oe);ae===void 0&&(ae=new WeakMap,c.set(Oe,ae));let Ie=ae.get(L);Ie===void 0&&(Ie=n.getUniformBlockIndex(Oe,L.name),ae.set(L,Ie))}function Ke(L,Oe){const Ie=c.get(Oe).get(L);l.get(Oe)!==Ie&&(n.uniformBlockBinding(Oe,Ie,L.__bindingPointIndex),l.set(Oe,Ie))}function rt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},h={},Se=null,be={},u={},p=new WeakMap,M=[],_=null,m=!1,f=null,S=null,v=null,z=null,O=null,x=null,G=null,b=new Ze(0,0,0),T=0,N=!1,C=null,W=null,Q=null,se=null,H=null,ct.set(0,0,n.canvas.width,n.canvas.height),tt.set(0,0,n.canvas.width,n.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:Me,disable:et,bindFramebuffer:it,drawBuffers:Ye,useProgram:qt,setBlending:At,setMaterial:vt,setFlipSided:Pt,setCullFace:ts,setLineWidth:ss,setPolygonOffset:ls,setScissorTest:Xt,activeTexture:Zt,bindTexture:j,unbindTexture:vs,compressedTexImage2D:gt,compressedTexImage3D:R,texImage2D:ne,texImage3D:ie,pixelStorei:Ve,getParameter:Ee,updateUBOMapping:Xe,uniformBlockBinding:Ke,texStorage2D:we,texStorage3D:Ae,texSubImage2D:w,texSubImage3D:$,compressedTexSubImage2D:K,compressedTexSubImage3D:te,scissor:Ge,viewport:xe,reset:rt}}function Pv(n,e,t,s,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Je,d=new WeakMap,h=new Set;let u;const p=new WeakMap;let M=!1;try{M=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,w){return M?new OffscreenCanvas(R,w):Jo("canvas")}function m(R,w,$){let K=1;const te=gt(R);if((te.width>$||te.height>$)&&(K=$/Math.max(te.width,te.height)),K<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const we=Math.floor(K*te.width),Ae=Math.floor(K*te.height);u===void 0&&(u=_(we,Ae));const ne=w?_(we,Ae):u;return ne.width=we,ne.height=Ae,ne.getContext("2d").drawImage(R,0,0,we,Ae),Qe("WebGLRenderer: Texture has been resized from ("+te.width+"x"+te.height+") to ("+we+"x"+Ae+")."),ne}else return"data"in R&&Qe("WebGLRenderer: Image in DataTexture is too big ("+te.width+"x"+te.height+")."),R;return R}function f(R){return R.generateMipmaps}function S(R){n.generateMipmap(R)}function v(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function z(R,w,$,K,te,we=!1){if(R!==null){if(n[R]!==void 0)return n[R];Qe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ae;K&&(Ae=e.get("EXT_texture_norm16"),Ae||Qe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ne=w;if(w===n.RED&&($===n.FLOAT&&(ne=n.R32F),$===n.HALF_FLOAT&&(ne=n.R16F),$===n.UNSIGNED_BYTE&&(ne=n.R8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.R16_EXT),$===n.SHORT&&Ae&&(ne=Ae.R16_SNORM_EXT)),w===n.RED_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.R8UI),$===n.UNSIGNED_SHORT&&(ne=n.R16UI),$===n.UNSIGNED_INT&&(ne=n.R32UI),$===n.BYTE&&(ne=n.R8I),$===n.SHORT&&(ne=n.R16I),$===n.INT&&(ne=n.R32I)),w===n.RG&&($===n.FLOAT&&(ne=n.RG32F),$===n.HALF_FLOAT&&(ne=n.RG16F),$===n.UNSIGNED_BYTE&&(ne=n.RG8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RG16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RG16_SNORM_EXT)),w===n.RG_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RG8UI),$===n.UNSIGNED_SHORT&&(ne=n.RG16UI),$===n.UNSIGNED_INT&&(ne=n.RG32UI),$===n.BYTE&&(ne=n.RG8I),$===n.SHORT&&(ne=n.RG16I),$===n.INT&&(ne=n.RG32I)),w===n.RGB_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RGB8UI),$===n.UNSIGNED_SHORT&&(ne=n.RGB16UI),$===n.UNSIGNED_INT&&(ne=n.RGB32UI),$===n.BYTE&&(ne=n.RGB8I),$===n.SHORT&&(ne=n.RGB16I),$===n.INT&&(ne=n.RGB32I)),w===n.RGBA_INTEGER&&($===n.UNSIGNED_BYTE&&(ne=n.RGBA8UI),$===n.UNSIGNED_SHORT&&(ne=n.RGBA16UI),$===n.UNSIGNED_INT&&(ne=n.RGBA32UI),$===n.BYTE&&(ne=n.RGBA8I),$===n.SHORT&&(ne=n.RGBA16I),$===n.INT&&(ne=n.RGBA32I)),w===n.RGB&&($===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RGB16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RGB16_SNORM_EXT),$===n.UNSIGNED_INT_5_9_9_9_REV&&(ne=n.RGB9_E5),$===n.UNSIGNED_INT_10F_11F_11F_REV&&(ne=n.R11F_G11F_B10F)),w===n.RGBA){const ie=we?Qo:xt.getTransfer(te);$===n.FLOAT&&(ne=n.RGBA32F),$===n.HALF_FLOAT&&(ne=n.RGBA16F),$===n.UNSIGNED_BYTE&&(ne=ie===Ut?n.SRGB8_ALPHA8:n.RGBA8),$===n.UNSIGNED_SHORT&&Ae&&(ne=Ae.RGBA16_EXT),$===n.SHORT&&Ae&&(ne=Ae.RGBA16_SNORM_EXT),$===n.UNSIGNED_SHORT_4_4_4_4&&(ne=n.RGBA4),$===n.UNSIGNED_SHORT_5_5_5_1&&(ne=n.RGB5_A1)}return(ne===n.R16F||ne===n.R32F||ne===n.RG16F||ne===n.RG32F||ne===n.RGBA16F||ne===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function O(R,w){let $;return R?w===null||w===In||w===Sa?$=n.DEPTH24_STENCIL8:w===Mn?$=n.DEPTH32F_STENCIL8:w===xa&&($=n.DEPTH24_STENCIL8,Qe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===In||w===Sa?$=n.DEPTH_COMPONENT24:w===Mn?$=n.DEPTH_COMPONENT32F:w===xa&&($=n.DEPTH_COMPONENT16),$}function x(R,w){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==ws&&R.minFilter!==Es?Math.log2(Math.max(w.width,w.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?w.mipmaps.length:1}function G(R){const w=R.target;w.removeEventListener("dispose",G),T(w),w.isVideoTexture&&d.delete(w),w.isHTMLTexture&&h.delete(w)}function b(R){const w=R.target;w.removeEventListener("dispose",b),C(w)}function T(R){const w=s.get(R);if(w.__webglInit===void 0)return;const $=R.source,K=p.get($);if(K){const te=K[w.__cacheKey];te.usedTimes--,te.usedTimes===0&&N(R),Object.keys(K).length===0&&p.delete($)}s.remove(R)}function N(R){const w=s.get(R);n.deleteTexture(w.__webglTexture);const $=R.source,K=p.get($);delete K[w.__cacheKey],a.memory.textures--}function C(R){const w=s.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),s.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(w.__webglFramebuffer[K]))for(let te=0;te<w.__webglFramebuffer[K].length;te++)n.deleteFramebuffer(w.__webglFramebuffer[K][te]);else n.deleteFramebuffer(w.__webglFramebuffer[K]);w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer[K])}else{if(Array.isArray(w.__webglFramebuffer))for(let K=0;K<w.__webglFramebuffer.length;K++)n.deleteFramebuffer(w.__webglFramebuffer[K]);else n.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&n.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let K=0;K<w.__webglColorRenderbuffer.length;K++)w.__webglColorRenderbuffer[K]&&n.deleteRenderbuffer(w.__webglColorRenderbuffer[K]);w.__webglDepthRenderbuffer&&n.deleteRenderbuffer(w.__webglDepthRenderbuffer)}const $=R.textures;for(let K=0,te=$.length;K<te;K++){const we=s.get($[K]);we.__webglTexture&&(n.deleteTexture(we.__webglTexture),a.memory.textures--),s.remove($[K])}s.remove(R)}let W=0;function Q(){W=0}function se(){return W}function H(R){W=R}function ee(){const R=W;return R>=i.maxTextures&&Qe("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),W+=1,R}function J(R){const w=[];return w.push(R.wrapS),w.push(R.wrapT),w.push(R.wrapR||0),w.push(R.magFilter),w.push(R.minFilter),w.push(R.anisotropy),w.push(R.internalFormat),w.push(R.format),w.push(R.type),w.push(R.generateMipmaps),w.push(R.premultiplyAlpha),w.push(R.flipY),w.push(R.unpackAlignment),w.push(R.colorSpace),w.join()}function ue(R,w){const $=s.get(R);if(R.isVideoTexture&&j(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&$.__version!==R.version){const K=R.image;if(K===null)Qe("WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)Qe("WebGLRenderer: Texture marked for update but image is incomplete");else{et($,R,w);return}}else R.isExternalTexture&&($.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,$.__webglTexture,n.TEXTURE0+w)}function he(R,w){const $=s.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){et($,R,w);return}else R.isExternalTexture&&($.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,$.__webglTexture,n.TEXTURE0+w)}function Se(R,w){const $=s.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){et($,R,w);return}t.bindTexture(n.TEXTURE_3D,$.__webglTexture,n.TEXTURE0+w)}function be(R,w){const $=s.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&$.__version!==R.version){it($,R,w);return}t.bindTexture(n.TEXTURE_CUBE_MAP,$.__webglTexture,n.TEXTURE0+w)}const Re={[qc]:n.REPEAT,[Xn]:n.CLAMP_TO_EDGE,[Xc]:n.MIRRORED_REPEAT},ht={[ws]:n.NEAREST,[Kb]:n.NEAREST_MIPMAP_NEAREST,[Ra]:n.NEAREST_MIPMAP_LINEAR,[Es]:n.LINEAR,[Tl]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},ct={[Jb]:n.NEVER,[iz]:n.ALWAYS,[ez]:n.LESS,[Jd]:n.LEQUAL,[tz]:n.EQUAL,[eu]:n.GEQUAL,[sz]:n.GREATER,[nz]:n.NOTEQUAL};function tt(R,w){if(w.type===Mn&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Es||w.magFilter===Tl||w.magFilter===Ra||w.magFilter===Ui||w.minFilter===Es||w.minFilter===Tl||w.minFilter===Ra||w.minFilter===Ui)&&Qe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Re[w.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Re[w.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Re[w.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ht[w.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ht[w.minFilter]),w.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,ct[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===ws||w.minFilter!==Ra&&w.minFilter!==Ui||w.type===Mn&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||s.get(w).__currentAnisotropy){const $=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,$.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,i.getMaxAnisotropy())),s.get(w).__currentAnisotropy=w.anisotropy}}}function oe(R,w){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,w.addEventListener("dispose",G));const K=w.source;let te=p.get(K);te===void 0&&(te={},p.set(K,te));const we=J(w);if(we!==R.__cacheKey){te[we]===void 0&&(te[we]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,$=!0),te[we].usedTimes++;const Ae=te[R.__cacheKey];Ae!==void 0&&(te[R.__cacheKey].usedTimes--,Ae.usedTimes===0&&N(w)),R.__cacheKey=we,R.__webglTexture=te[we].texture}return $}function ye(R,w,$){return Math.floor(Math.floor(R/$)/w)}function Me(R,w,$,K){const we=R.updateRanges;if(we.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,w.width,w.height,$,K,w.data);else{we.sort((Ve,Ge)=>Ve.start-Ge.start);let Ae=0;for(let Ve=1;Ve<we.length;Ve++){const Ge=we[Ae],xe=we[Ve],Xe=Ge.start+Ge.count,Ke=ye(xe.start,w.width,4),rt=ye(Ge.start,w.width,4);xe.start<=Xe+1&&Ke===rt&&ye(xe.start+xe.count-1,w.width,4)===Ke?Ge.count=Math.max(Ge.count,xe.start+xe.count-Ge.start):(++Ae,we[Ae]=xe)}we.length=Ae+1;const ne=t.getParameter(n.UNPACK_ROW_LENGTH),ie=t.getParameter(n.UNPACK_SKIP_PIXELS),Ee=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,w.width);for(let Ve=0,Ge=we.length;Ve<Ge;Ve++){const xe=we[Ve],Xe=Math.floor(xe.start/4),Ke=Math.ceil(xe.count/4),rt=Xe%w.width,L=Math.floor(Xe/w.width),Oe=Ke,ae=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,rt),t.pixelStorei(n.UNPACK_SKIP_ROWS,L),t.texSubImage2D(n.TEXTURE_2D,0,rt,L,Oe,ae,$,K,w.data)}R.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,ne),t.pixelStorei(n.UNPACK_SKIP_PIXELS,ie),t.pixelStorei(n.UNPACK_SKIP_ROWS,Ee)}}function et(R,w,$){let K=n.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(K=n.TEXTURE_2D_ARRAY),w.isData3DTexture&&(K=n.TEXTURE_3D);const te=oe(R,w),we=w.source;t.bindTexture(K,R.__webglTexture,n.TEXTURE0+$);const Ae=s.get(we);if(we.version!==Ae.__version||te===!0){if(t.activeTexture(n.TEXTURE0+$),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){const ae=xt.getPrimaries(xt.workingColorSpace),Ie=w.colorSpace===Mi?null:xt.getPrimaries(w.colorSpace),Ne=w.colorSpace===Mi||ae===Ie?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ne)}t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment);let ie=m(w.image,!1,i.maxTextureSize);ie=vs(w,ie);const Ee=r.convert(w.format,w.colorSpace),Ve=r.convert(w.type);let Ge=z(w.internalFormat,Ee,Ve,w.normalized,w.colorSpace,w.isVideoTexture);tt(K,w);let xe;const Xe=w.mipmaps,Ke=w.isVideoTexture!==!0,rt=Ae.__version===void 0||te===!0,L=we.dataReady,Oe=x(w,ie);if(w.isDepthTexture)Ge=O(w.format===Fi,w.type),rt&&(Ke?t.texStorage2D(n.TEXTURE_2D,1,Ge,ie.width,ie.height):t.texImage2D(n.TEXTURE_2D,0,Ge,ie.width,ie.height,0,Ee,Ve,null));else if(w.isDataTexture)if(Xe.length>0){Ke&&rt&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,Xe[0].width,Xe[0].height);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,Ve,xe.data):t.texImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,Ee,Ve,xe.data);w.generateMipmaps=!1}else Ke?(rt&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ie.width,ie.height),L&&Me(w,ie,Ee,Ve)):t.texImage2D(n.TEXTURE_2D,0,Ge,ie.width,ie.height,0,Ee,Ve,ie.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Ke&&rt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ge,Xe[0].width,Xe[0].height,ie.depth);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)if(xe=Xe[ae],w.format!==gn)if(Ee!==null)if(Ke){if(L)if(w.layerUpdates.size>0){const Ne=Oh(xe.width,xe.height,w.format,w.type);for(const ce of w.layerUpdates){const $e=xe.data.subarray(ce*Ne/xe.data.BYTES_PER_ELEMENT,(ce+1)*Ne/xe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,ce,xe.width,xe.height,1,Ee,$e)}w.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,xe.width,xe.height,ie.depth,Ee,xe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ae,Ge,xe.width,xe.height,ie.depth,0,xe.data,0,0);else Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ke?L&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,xe.width,xe.height,ie.depth,Ee,Ve,xe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Ge,xe.width,xe.height,ie.depth,0,Ee,Ve,xe.data)}else{Ke&&rt&&t.texStorage2D(n.TEXTURE_2D,Oe,Ge,Xe[0].width,Xe[0].height);for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],w.format!==gn?Ee!==null?Ke?L&&t.compressedTexSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,xe.data):t.compressedTexImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,xe.data):Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,xe.width,xe.height,Ee,Ve,xe.data):t.texImage2D(n.TEXTURE_2D,ae,Ge,xe.width,xe.height,0,Ee,Ve,xe.data)}else if(w.isDataArrayTexture)if(Ke){if(rt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ge,ie.width,ie.height,ie.depth),L)if(w.layerUpdates.size>0){const ae=Oh(ie.width,ie.height,w.format,w.type);for(const Ie of w.layerUpdates){const Ne=ie.data.subarray(Ie*ae/ie.data.BYTES_PER_ELEMENT,(Ie+1)*ae/ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Ie,ie.width,ie.height,1,Ee,Ve,Ne)}w.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ie.width,ie.height,ie.depth,Ee,Ve,ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ge,ie.width,ie.height,ie.depth,0,Ee,Ve,ie.data);else if(w.isData3DTexture)Ke?(rt&&t.texStorage3D(n.TEXTURE_3D,Oe,Ge,ie.width,ie.height,ie.depth),L&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ie.width,ie.height,ie.depth,Ee,Ve,ie.data)):t.texImage3D(n.TEXTURE_3D,0,Ge,ie.width,ie.height,ie.depth,0,Ee,Ve,ie.data);else if(w.isFramebufferTexture){if(rt)if(Ke)t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ie.width,ie.height);else{let ae=ie.width,Ie=ie.height;for(let Ne=0;Ne<Oe;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,Ge,ae,Ie,0,Ee,Ve,null),ae>>=1,Ie>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in n){const ae=n.canvas;if(ae.hasAttribute("layoutsubtree")||ae.setAttribute("layoutsubtree","true"),ie.parentNode!==ae){ae.appendChild(ie),h.add(w),ae.onpaint=Ie=>{const Ne=Ie.changedElements;for(const ce of h)Ne.includes(ce.image)&&(ce.needsUpdate=!0)},ae.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,ie);else{const Ne=n.RGBA,ce=n.RGBA,$e=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Ne,ce,$e,ie)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Xe.length>0){if(Ke&&rt){const ae=gt(Xe[0]);t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ae.width,ae.height)}for(let ae=0,Ie=Xe.length;ae<Ie;ae++)xe=Xe[ae],Ke?L&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,Ee,Ve,xe):t.texImage2D(n.TEXTURE_2D,ae,Ge,Ee,Ve,xe);w.generateMipmaps=!1}else if(Ke){if(rt){const ae=gt(ie);t.texStorage2D(n.TEXTURE_2D,Oe,Ge,ae.width,ae.height)}L&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ee,Ve,ie)}else t.texImage2D(n.TEXTURE_2D,0,Ge,Ee,Ve,ie);f(w)&&S(K),Ae.__version=we.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function it(R,w,$){if(w.image.length!==6)return;const K=oe(R,w),te=w.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+$);const we=s.get(te);if(te.version!==we.__version||K===!0){t.activeTexture(n.TEXTURE0+$);const Ae=xt.getPrimaries(xt.workingColorSpace),ne=w.colorSpace===Mi?null:xt.getPrimaries(w.colorSpace),ie=w.colorSpace===Mi||Ae===ne?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ie);const Ee=w.isCompressedTexture||w.image[0].isCompressedTexture,Ve=w.image[0]&&w.image[0].isDataTexture,Ge=[];for(let ce=0;ce<6;ce++)!Ee&&!Ve?Ge[ce]=m(w.image[ce],!0,i.maxCubemapSize):Ge[ce]=Ve?w.image[ce].image:w.image[ce],Ge[ce]=vs(w,Ge[ce]);const xe=Ge[0],Xe=r.convert(w.format,w.colorSpace),Ke=r.convert(w.type),rt=z(w.internalFormat,Xe,Ke,w.normalized,w.colorSpace),L=w.isVideoTexture!==!0,Oe=we.__version===void 0||K===!0,ae=te.dataReady;let Ie=x(w,xe);tt(n.TEXTURE_CUBE_MAP,w);let Ne;if(Ee){L&&Oe&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ie,rt,xe.width,xe.height);for(let ce=0;ce<6;ce++){Ne=Ge[ce].mipmaps;for(let $e=0;$e<Ne.length;$e++){const ke=Ne[$e];w.format!==gn?Xe!==null?L?ae&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ke.width,ke.height,Xe,ke.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,rt,ke.width,ke.height,0,ke.data):Qe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ke.width,ke.height,Xe,Ke,ke.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,rt,ke.width,ke.height,0,Xe,Ke,ke.data)}}}else{if(Ne=w.mipmaps,L&&Oe){Ne.length>0&&Ie++;const ce=gt(Ge[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ie,rt,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(Ve){L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Ge[ce].width,Ge[ce].height,Xe,Ke,Ge[ce].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,rt,Ge[ce].width,Ge[ce].height,0,Xe,Ke,Ge[ce].data);for(let $e=0;$e<Ne.length;$e++){const Yt=Ne[$e].image[ce].image;L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Yt.width,Yt.height,Xe,Ke,Yt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,rt,Yt.width,Yt.height,0,Xe,Ke,Yt.data)}}else{L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Xe,Ke,Ge[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,rt,Xe,Ke,Ge[ce]);for(let $e=0;$e<Ne.length;$e++){const ke=Ne[$e];L?ae&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Xe,Ke,ke.image[ce]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,rt,Xe,Ke,ke.image[ce])}}}f(w)&&S(n.TEXTURE_CUBE_MAP),we.__version=te.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function Ye(R,w,$,K,te,we){const Ae=r.convert($.format,$.colorSpace),ne=r.convert($.type),ie=z($.internalFormat,Ae,ne,$.normalized,$.colorSpace),Ee=s.get(w),Ve=s.get($);if(Ve.__renderTarget=w,!Ee.__hasExternalTextures){const Ge=Math.max(1,w.width>>we),xe=Math.max(1,w.height>>we);te===n.TEXTURE_3D||te===n.TEXTURE_2D_ARRAY?t.texImage3D(te,we,ie,Ge,xe,w.depth,0,Ae,ne,null):t.texImage2D(te,we,ie,Ge,xe,0,Ae,ne,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,K,te,Ve.__webglTexture,0,Xt(w)):(te===n.TEXTURE_2D||te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,K,te,Ve.__webglTexture,we),t.bindFramebuffer(n.FRAMEBUFFER,null)}function qt(R,w,$){if(n.bindRenderbuffer(n.RENDERBUFFER,R),w.depthBuffer){const K=w.depthTexture,te=K&&K.isDepthTexture?K.type:null,we=O(w.stencilBuffer,te),Ae=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;Zt(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Xt(w),we,w.width,w.height):$?n.renderbufferStorageMultisample(n.RENDERBUFFER,Xt(w),we,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,we,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ae,n.RENDERBUFFER,R)}else{const K=w.textures;for(let te=0;te<K.length;te++){const we=K[te],Ae=r.convert(we.format,we.colorSpace),ne=r.convert(we.type),ie=z(we.internalFormat,Ae,ne,we.normalized,we.colorSpace);Zt(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Xt(w),ie,w.width,w.height):$?n.renderbufferStorageMultisample(n.RENDERBUFFER,Xt(w),ie,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,ie,w.width,w.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function pt(R,w,$){const K=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const te=s.get(w.depthTexture);if(te.__renderTarget=w,(!te.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),K){if(te.__webglInit===void 0&&(te.__webglInit=!0,w.depthTexture.addEventListener("dispose",G)),te.__webglTexture===void 0){te.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture),tt(n.TEXTURE_CUBE_MAP,w.depthTexture);const Ee=r.convert(w.depthTexture.format),Ve=r.convert(w.depthTexture.type);let Ge;w.depthTexture.format===ti?Ge=n.DEPTH_COMPONENT24:w.depthTexture.format===Fi&&(Ge=n.DEPTH24_STENCIL8);for(let xe=0;xe<6;xe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,Ge,w.width,w.height,0,Ee,Ve,null)}}else ue(w.depthTexture,0);const we=te.__webglTexture,Ae=Xt(w),ne=K?n.TEXTURE_CUBE_MAP_POSITIVE_X+$:n.TEXTURE_2D,ie=w.depthTexture.format===Fi?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(w.depthTexture.format===ti)Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ie,ne,we,0,Ae):n.framebufferTexture2D(n.FRAMEBUFFER,ie,ne,we,0);else if(w.depthTexture.format===Fi)Zt(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ie,ne,we,0,Ae):n.framebufferTexture2D(n.FRAMEBUFFER,ie,ne,we,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function dt(R){const w=s.get(R),$=R.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==R.depthTexture){const K=R.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),K){const te=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,K.removeEventListener("dispose",te)};K.addEventListener("dispose",te),w.__depthDisposeCallback=te}w.__boundDepthTexture=K}if(R.depthTexture&&!w.__autoAllocateDepthBuffer)if($)for(let K=0;K<6;K++)pt(w.__webglFramebuffer[K],R,K);else{const K=R.texture.mipmaps;K&&K.length>0?pt(w.__webglFramebuffer[0],R,0):pt(w.__webglFramebuffer,R,0)}else if($){w.__webglDepthbuffer=[];for(let K=0;K<6;K++)if(t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[K]),w.__webglDepthbuffer[K]===void 0)w.__webglDepthbuffer[K]=n.createRenderbuffer(),qt(w.__webglDepthbuffer[K],R,!1);else{const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=w.__webglDepthbuffer[K];n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,te,n.RENDERBUFFER,we)}}else{const K=R.texture.mipmaps;if(K&&K.length>0?t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=n.createRenderbuffer(),qt(w.__webglDepthbuffer,R,!1);else{const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=w.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,te,n.RENDERBUFFER,we)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function At(R,w,$){const K=s.get(R);w!==void 0&&Ye(K.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),$!==void 0&&dt(R)}function vt(R){const w=R.texture,$=s.get(R),K=s.get(w);R.addEventListener("dispose",b);const te=R.textures,we=R.isWebGLCubeRenderTarget===!0,Ae=te.length>1;if(Ae||(K.__webglTexture===void 0&&(K.__webglTexture=n.createTexture()),K.__version=w.version,a.memory.textures++),we){$.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0){$.__webglFramebuffer[ne]=[];for(let ie=0;ie<w.mipmaps.length;ie++)$.__webglFramebuffer[ne][ie]=n.createFramebuffer()}else $.__webglFramebuffer[ne]=n.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){$.__webglFramebuffer=[];for(let ne=0;ne<w.mipmaps.length;ne++)$.__webglFramebuffer[ne]=n.createFramebuffer()}else $.__webglFramebuffer=n.createFramebuffer();if(Ae)for(let ne=0,ie=te.length;ne<ie;ne++){const Ee=s.get(te[ne]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Zt(R)===!1){$.__webglMultisampledFramebuffer=n.createFramebuffer(),$.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,$.__webglMultisampledFramebuffer);for(let ne=0;ne<te.length;ne++){const ie=te[ne];$.__webglColorRenderbuffer[ne]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,$.__webglColorRenderbuffer[ne]);const Ee=r.convert(ie.format,ie.colorSpace),Ve=r.convert(ie.type),Ge=z(ie.internalFormat,Ee,Ve,ie.normalized,ie.colorSpace,R.isXRRenderTarget===!0),xe=Xt(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,xe,Ge,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ne,n.RENDERBUFFER,$.__webglColorRenderbuffer[ne])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&($.__webglDepthRenderbuffer=n.createRenderbuffer(),qt($.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(we){t.bindTexture(n.TEXTURE_CUBE_MAP,K.__webglTexture),tt(n.TEXTURE_CUBE_MAP,w);for(let ne=0;ne<6;ne++)if(w.mipmaps&&w.mipmaps.length>0)for(let ie=0;ie<w.mipmaps.length;ie++)Ye($.__webglFramebuffer[ne][ie],R,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ie);else Ye($.__webglFramebuffer[ne],R,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0);f(w)&&S(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ae){for(let ne=0,ie=te.length;ne<ie;ne++){const Ee=te[ne],Ve=s.get(Ee);let Ge=n.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ge=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ge,Ve.__webglTexture),tt(Ge,Ee),Ye($.__webglFramebuffer,R,Ee,n.COLOR_ATTACHMENT0+ne,Ge,0),f(Ee)&&S(Ge)}t.unbindTexture()}else{let ne=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(ne=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ne,K.__webglTexture),tt(ne,w),w.mipmaps&&w.mipmaps.length>0)for(let ie=0;ie<w.mipmaps.length;ie++)Ye($.__webglFramebuffer[ie],R,w,n.COLOR_ATTACHMENT0,ne,ie);else Ye($.__webglFramebuffer,R,w,n.COLOR_ATTACHMENT0,ne,0);f(w)&&S(ne),t.unbindTexture()}R.depthBuffer&&dt(R)}function Pt(R){const w=R.textures;for(let $=0,K=w.length;$<K;$++){const te=w[$];if(f(te)){const we=v(R),Ae=s.get(te).__webglTexture;t.bindTexture(we,Ae),S(we),t.unbindTexture()}}}const ts=[],ss=[];function ls(R){if(R.samples>0){if(Zt(R)===!1){const w=R.textures,$=R.width,K=R.height;let te=n.COLOR_BUFFER_BIT;const we=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=s.get(R),ne=w.length>1;if(ne)for(let Ee=0;Ee<w.length;Ee++)t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer);const ie=R.texture.mipmaps;ie&&ie.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let Ee=0;Ee<w.length;Ee++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(te|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(te|=n.STENCIL_BUFFER_BIT)),ne){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);const Ve=s.get(w[Ee]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ve,0)}n.blitFramebuffer(0,0,$,K,0,0,$,K,te,n.NEAREST),l===!0&&(ts.length=0,ss.length=0,ts.push(n.COLOR_ATTACHMENT0+Ee),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ts.push(we),ss.push(we),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,ss)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ts))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ne)for(let Ee=0;Ee<w.length;Ee++){t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);const Ve=s.get(w[Ee]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,Ve,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const w=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[w])}}}function Xt(R){return Math.min(i.maxSamples,R.samples)}function Zt(R){const w=s.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function j(R){const w=a.render.frame;d.get(R)!==w&&(d.set(R,w),R.update())}function vs(R,w){const $=R.colorSpace,K=R.format,te=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||$!==Zo&&$!==Mi&&(xt.getTransfer($)===Ut?(K!==gn||te!==qs)&&Qe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ot("WebGLTextures: Unsupported texture color space:",$)),w}function gt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=ee,this.resetTextureUnits=Q,this.getTextureUnits=se,this.setTextureUnits=H,this.setTexture2D=ue,this.setTexture2DArray=he,this.setTexture3D=Se,this.setTextureCube=be,this.rebindTextures=At,this.setupRenderTarget=vt,this.updateRenderTargetMipmap=Pt,this.updateMultisampleRenderTarget=ls,this.setupDepthRenderbuffer=dt,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=Zt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Wv(n,e){function t(s,i=Mi){let r;const a=xt.getTransfer(i);if(s===qs)return n.UNSIGNED_BYTE;if(s===qd)return n.UNSIGNED_SHORT_4_4_4_4;if(s===Xd)return n.UNSIGNED_SHORT_5_5_5_1;if(s===Yp)return n.UNSIGNED_INT_5_9_9_9_REV;if(s===Kp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(s===qp)return n.BYTE;if(s===Xp)return n.SHORT;if(s===xa)return n.UNSIGNED_SHORT;if(s===Hd)return n.INT;if(s===In)return n.UNSIGNED_INT;if(s===Mn)return n.FLOAT;if(s===ei)return n.HALF_FLOAT;if(s===Zp)return n.ALPHA;if(s===Qp)return n.RGB;if(s===gn)return n.RGBA;if(s===ti)return n.DEPTH_COMPONENT;if(s===Fi)return n.DEPTH_STENCIL;if(s===Yd)return n.RED;if(s===Kd)return n.RED_INTEGER;if(s===Yi)return n.RG;if(s===Zd)return n.RG_INTEGER;if(s===Qd)return n.RGBA_INTEGER;if(s===Ao||s===Eo||s===Do||s===Io)if(a===Ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(s===Ao)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Eo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Do)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Io)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(s===Ao)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Eo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Do)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Io)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Yc||s===Kc||s===Zc||s===Qc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(s===Yc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Kc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Zc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Qc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Jc||s===ed||s===td||s===sd||s===nd||s===Yo||s===id)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(s===Jc||s===ed)return a===Ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(s===td)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(s===sd)return r.COMPRESSED_R11_EAC;if(s===nd)return r.COMPRESSED_SIGNED_R11_EAC;if(s===Yo)return r.COMPRESSED_RG11_EAC;if(s===id)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(s===rd||s===ad||s===od||s===ld||s===cd||s===dd||s===ud||s===hd||s===fd||s===pd||s===md||s===Md||s===gd||s===bd)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(s===rd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===ad)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===od)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ld)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===cd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===dd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ud)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===hd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===fd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===pd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===md)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Md)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===bd)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===zd||s===_d||s===wd)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(s===zd)return a===Ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===_d)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===wd)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===yd||s===vd||s===Ko||s===Od)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(s===yd)return r.COMPRESSED_RED_RGTC1_EXT;if(s===vd)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Ko)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Od)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Sa?n.UNSIGNED_INT_24_8:n[s]!==void 0?n[s]:null}return{convert:t}}const Lv=`
4086
4086
  void main() {
4087
4087
 
4088
4088
  gl_Position = vec4( position, 1.0 );
@@ -4106,7 +4106,7 @@ void main() {
4106
4106
 
4107
4107
  }
4108
4108
 
4109
- }`;class Uv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const s=new om(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,s=new _s({vertexShader:Lv,fragmentShader:kv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ss(new Ml(20,20),s)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fv extends Zi{constructor(e,t){super();const s=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,u=null,p=null,M=null;const _=typeof XRWebGLBinding<"u",m=new Uv,f={},S=t.getContextAttributes();let v=null,z=null;const O=[],x=[],G=new Je;let b=null;const T=new tn;T.viewport=new Jt;const N=new tn;N.viewport=new Jt;const C=[T,N],W=new Zz;let Q=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getTargetRaySpace()},this.getControllerGrip=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getGripSpace()},this.getHand=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getHandSpace()};function H(oe){const ye=x.indexOf(oe.inputSource);if(ye===-1)return;const Me=O[ye];Me!==void 0&&(Me.update(oe.inputSource,oe.frame,c||a),Me.dispatchEvent({type:oe.type,data:oe.inputSource}))}function ee(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",ee),i.removeEventListener("inputsourceschange",J);for(let oe=0;oe<O.length;oe++){const ye=x[oe];ye!==null&&(x[oe]=null,O[oe].disconnect(ye))}Q=null,se=null,m.reset();for(const oe in f)delete f[oe];e.setRenderTarget(v),p=null,u=null,h=null,i=null,z=null,tt.stop(),s.isPresenting=!1,e.setPixelRatio(b),e.setSize(G.width,G.height,!1),s.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){r=oe,s.isPresenting===!0&&Qe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){o=oe,s.isPresenting===!0&&Qe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(oe){c=oe},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return h===null&&_&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return M},this.getSession=function(){return i},this.setSession=async function(oe){if(i=oe,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",ee),i.addEventListener("inputsourceschange",J),S.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(G),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,et=null,nt=null;S.depth&&(nt=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Me=S.stencil?Fi:ti,et=S.stencil?Sa:In);const Ye={colorFormat:t.RGBA8,depthFormat:nt,scaleFactor:r};h=this.getBinding(),u=h.createProjectionLayer(Ye),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),z=new Dn(u.textureWidth,u.textureHeight,{format:gn,type:qs,depthTexture:new Wr(u.textureWidth,u.textureHeight,et,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const Me={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,t,Me),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),z=new Dn(p.framebufferWidth,p.framebufferHeight,{format:gn,type:qs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}z.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),tt.setContext(i),tt.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function J(oe){for(let ye=0;ye<oe.removed.length;ye++){const Me=oe.removed[ye],et=x.indexOf(Me);et>=0&&(x[et]=null,O[et].disconnect(Me))}for(let ye=0;ye<oe.added.length;ye++){const Me=oe.added[ye];let et=x.indexOf(Me);if(et===-1){for(let Ye=0;Ye<O.length;Ye++)if(Ye>=x.length){x.push(Me),et=Ye;break}else if(x[Ye]===null){x[Ye]=Me,et=Ye;break}if(et===-1)break}const nt=O[et];nt&&nt.connect(Me)}}const ue=new P,he=new P;function Se(oe,ye,Me){ue.setFromMatrixPosition(ye.matrixWorld),he.setFromMatrixPosition(Me.matrixWorld);const et=ue.distanceTo(he),nt=ye.projectionMatrix.elements,Ye=Me.projectionMatrix.elements,qt=nt[14]/(nt[10]-1),pt=nt[14]/(nt[10]+1),dt=(nt[9]+1)/nt[5],At=(nt[9]-1)/nt[5],vt=(nt[8]-1)/nt[0],Pt=(Ye[8]+1)/Ye[0],ts=qt*vt,ss=qt*Pt,ls=et/(-vt+Pt),Xt=ls*-vt;if(ye.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(Xt),oe.translateZ(ls),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),nt[10]===-1)oe.projectionMatrix.copy(ye.projectionMatrix),oe.projectionMatrixInverse.copy(ye.projectionMatrixInverse);else{const Zt=qt+ls,j=pt+ls,vs=ts-Xt,gt=ss+(et-Xt),R=dt*pt/j*Zt,w=At*pt/j*Zt;oe.projectionMatrix.makePerspective(vs,gt,R,w,Zt,j),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function be(oe,ye){ye===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(ye.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(i===null)return;let ye=oe.near,Me=oe.far;m.texture!==null&&(m.depthNear>0&&(ye=m.depthNear),m.depthFar>0&&(Me=m.depthFar)),W.near=N.near=T.near=ye,W.far=N.far=T.far=Me,(Q!==W.near||se!==W.far)&&(i.updateRenderState({depthNear:W.near,depthFar:W.far}),Q=W.near,se=W.far),W.layers.mask=oe.layers.mask|6,T.layers.mask=W.layers.mask&-5,N.layers.mask=W.layers.mask&-3;const et=oe.parent,nt=W.cameras;be(W,et);for(let Ye=0;Ye<nt.length;Ye++)be(nt[Ye],et);nt.length===2?Se(W,T,N):W.projectionMatrix.copy(T.projectionMatrix),Re(oe,W,et)};function Re(oe,ye,Me){Me===null?oe.matrix.copy(ye.matrixWorld):(oe.matrix.copy(Me.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(ye.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(ye.projectionMatrix),oe.projectionMatrixInverse.copy(ye.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=Ad*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return W},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(oe){l=oe,u!==null&&(u.fixedFoveation=oe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=oe)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(W)},this.getCameraTexture=function(oe){return f[oe]};let ht=null;function ct(oe,ye){if(d=ye.getViewerPose(c||a),M=ye,d!==null){const Me=d.views;p!==null&&(e.setRenderTargetFramebuffer(z,p.framebuffer),e.setRenderTarget(z));let et=!1;Me.length!==W.cameras.length&&(W.cameras.length=0,et=!0);for(let pt=0;pt<Me.length;pt++){const dt=Me[pt];let At=null;if(p!==null)At=p.getViewport(dt);else{const Pt=h.getViewSubImage(u,dt);At=Pt.viewport,pt===0&&(e.setRenderTargetTextures(z,Pt.colorTexture,Pt.depthStencilTexture),e.setRenderTarget(z))}let vt=C[pt];vt===void 0&&(vt=new tn,vt.layers.enable(pt),vt.viewport=new Jt,C[pt]=vt),vt.matrix.fromArray(dt.transform.matrix),vt.matrix.decompose(vt.position,vt.quaternion,vt.scale),vt.projectionMatrix.fromArray(dt.projectionMatrix),vt.projectionMatrixInverse.copy(vt.projectionMatrix).invert(),vt.viewport.set(At.x,At.y,At.width,At.height),pt===0&&(W.matrix.copy(vt.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale)),et===!0&&W.cameras.push(vt)}const nt=i.enabledFeatures;if(nt&&nt.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&_){h=s.getBinding();const pt=h.getDepthInformation(Me[0]);pt&&pt.isValid&&pt.texture&&m.init(pt,i.renderState)}if(nt&&nt.includes("camera-access")&&_){e.state.unbindTexture(),h=s.getBinding();for(let pt=0;pt<Me.length;pt++){const dt=Me[pt].camera;if(dt){let At=f[dt];At||(At=new om,f[dt]=At);const vt=h.getCameraImage(dt);At.sourceTexture=vt}}}}for(let Me=0;Me<O.length;Me++){const et=x[Me],nt=O[Me];et!==null&&nt!==void 0&&nt.update(et,ye,c||a)}ht&&ht(oe,ye),ye.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:ye}),M=null}const tt=new um;tt.setAnimationLoop(ct),this.setAnimationLoop=function(oe){ht=oe},this.dispose=function(){}}}const jv=new Rt,bm=new lt;bm.set(-1,0,0,0,1,0,0,0,1);function Vv(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function s(m,f){f.color.getRGB(m.fogColor.value,lm(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function i(m,f,S,v,z){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),h(m,f)):f.isMeshPhongMaterial?(r(m,f),d(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,z)):f.isMeshMatcapMaterial?(r(m,f),M(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),_(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,S,v):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Us&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Us&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const S=e.get(f),v=S.envMap,z=S.envMapRotation;v&&(m.envMap.value=v,m.envMapRotation.value.setFromMatrix4(jv.makeRotationFromEuler(z)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(bm),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,S,v){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*S,m.scale.value=v*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function d(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,S){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Us&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function M(m,f){f.matcap&&(m.matcap.value=f.matcap)}function _(m,f){const S=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:s,refreshMaterialUniforms:i}}function $v(n,e,t,s){let i={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(z,O){const x=O.program;s.uniformBlockBinding(z,x)}function c(z,O){let x=i[z.id];x===void 0&&(m(z),x=d(z),i[z.id]=x,z.addEventListener("dispose",S));const G=O.program;s.updateUBOMapping(z,G);const b=e.render.frame;r[z.id]!==b&&(u(z),r[z.id]=b)}function d(z){const O=h();z.__bindingPointIndex=O;const x=n.createBuffer(),G=z.__size,b=z.usage;return n.bindBuffer(n.UNIFORM_BUFFER,x),n.bufferData(n.UNIFORM_BUFFER,G,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,O,x),x}function h(){for(let z=0;z<o;z++)if(a.indexOf(z)===-1)return a.push(z),z;return Ot("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(z){const O=i[z.id],x=z.uniforms,G=z.__cache;n.bindBuffer(n.UNIFORM_BUFFER,O);for(let b=0,T=x.length;b<T;b++){const N=x[b];if(Array.isArray(N))for(let C=0,W=N.length;C<W;C++)p(N[C],b,C,G);else p(N,b,0,G)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(z,O,x,G){if(_(z,O,x,G)===!0){const b=z.__offset,T=z.value;if(Array.isArray(T)){let N=0;for(let C=0;C<T.length;C++){const W=T[C],Q=f(W);M(W,z.__data,N),typeof W!="number"&&typeof W!="boolean"&&!W.isMatrix3&&!ArrayBuffer.isView(W)&&(N+=Q.storage/Float32Array.BYTES_PER_ELEMENT)}}else M(T,z.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,b,z.__data)}}function M(z,O,x){typeof z=="number"||typeof z=="boolean"?O[0]=z:z.isMatrix3?(O[0]=z.elements[0],O[1]=z.elements[1],O[2]=z.elements[2],O[3]=0,O[4]=z.elements[3],O[5]=z.elements[4],O[6]=z.elements[5],O[7]=0,O[8]=z.elements[6],O[9]=z.elements[7],O[10]=z.elements[8],O[11]=0):ArrayBuffer.isView(z)?O.set(new z.constructor(z.buffer,z.byteOffset,O.length)):z.toArray(O,x)}function _(z,O,x,G){const b=z.value,T=O+"_"+x;if(G[T]===void 0)return typeof b=="number"||typeof b=="boolean"?G[T]=b:ArrayBuffer.isView(b)?G[T]=b.slice():G[T]=b.clone(),!0;{const N=G[T];if(typeof b=="number"||typeof b=="boolean"){if(N!==b)return G[T]=b,!0}else{if(ArrayBuffer.isView(b))return!0;if(N.equals(b)===!1)return N.copy(b),!0}}return!1}function m(z){const O=z.uniforms;let x=0;const G=16;for(let T=0,N=O.length;T<N;T++){const C=Array.isArray(O[T])?O[T]:[O[T]];for(let W=0,Q=C.length;W<Q;W++){const se=C[W],H=Array.isArray(se.value)?se.value:[se.value];for(let ee=0,J=H.length;ee<J;ee++){const ue=H[ee],he=f(ue),Se=x%G,be=Se%he.boundary,Re=Se+be;x+=be,Re!==0&&G-Re<he.storage&&(x+=G-Re),se.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),se.__offset=x,x+=he.storage}}}const b=x%G;return b>0&&(x+=G-b),z.__size=x,z.__cache={},this}function f(z){const O={boundary:0,storage:0};return typeof z=="number"||typeof z=="boolean"?(O.boundary=4,O.storage=4):z.isVector2?(O.boundary=8,O.storage=8):z.isVector3||z.isColor?(O.boundary=16,O.storage=12):z.isVector4?(O.boundary=16,O.storage=16):z.isMatrix3?(O.boundary=48,O.storage=48):z.isMatrix4?(O.boundary=64,O.storage=64):z.isTexture?Qe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(z)?(O.boundary=16,O.storage=z.byteLength):Qe("WebGLRenderer: Unsupported uniform value type.",z),O}function S(z){const O=z.target;O.removeEventListener("dispose",S);const x=a.indexOf(O.__bindingPointIndex);a.splice(x,1),n.deleteBuffer(i[O.id]),delete i[O.id],delete r[O.id]}function v(){for(const z in i)n.deleteBuffer(i[z]);a=[],i={},r={}}return{bind:l,update:c,dispose:v}}const Hv=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let wn=null;function qv(){return wn===null&&(wn=new rm(Hv,16,16,Yi,ei),wn.name="DFG_LUT",wn.minFilter=Es,wn.magFilter=Es,wn.wrapS=Xn,wn.wrapT=Xn,wn.generateMipmaps=!1,wn.needsUpdate=!0),wn}class Xv{constructor(e={}){const{canvas:t=az(),context:s=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:u=!1,outputBufferType:p=qs}=e;this.isWebGLRenderer=!0;let M;if(s!==null){if(typeof WebGLRenderingContext<"u"&&s instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");M=s.getContextAttributes().alpha}else M=a;const _=p,m=new Set([Qd,Zd,Kd]),f=new Set([qs,In,xa,Sa,qd,Xd]),S=new Uint32Array(4),v=new Int32Array(4),z=new P;let O=null,x=null;const G=[],b=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=En,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const N=this;let C=!1,W=null,Q=null,se=null,H=null;this._outputColorSpace=en;let ee=0,J=0,ue=null,he=-1,Se=null;const be=new Jt,Re=new Jt;let ht=null;const ct=new Ze(0);let tt=0,oe=t.width,ye=t.height,Me=1,et=null,nt=null;const Ye=new Jt(0,0,oe,ye),qt=new Jt(0,0,oe,ye);let pt=!1;const dt=new iu;let At=!1,vt=!1;const Pt=new Rt,ts=new P,ss=new Jt,ls={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Xt=!1;function Zt(){return ue===null?Me:1}let j=s;function vs(A,k){return t.getContext(A,k)}try{const A={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$d}`),t.addEventListener("webglcontextlost",Yt,!1),t.addEventListener("webglcontextrestored",Wt,!1),t.addEventListener("webglcontextcreationerror",Ws,!1),j===null){const k="webgl2";if(j=vs(k,A),j===null)throw vs(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(A){throw Ot("WebGLRenderer: "+A.message),A}let gt,R,w,$,K,te,we,Ae,ne,ie,Ee,Ve,Ge,xe,Xe,Ke,it,L,Oe,ae,Ie,Ne,ce;function $e(){gt=new qw(j),gt.init(),Ie=new Wv(j,gt),R=new Lw(j,gt,e,Ie),w=new Cv(j,gt),R.reversedDepthBuffer&&u&&w.buffers.depth.setReversed(!0),Q=j.createFramebuffer(),se=j.createFramebuffer(),H=j.createFramebuffer(),$=new Kw(j),K=new yv,te=new Pv(j,gt,w,K,R,Ie,$),we=new Hw(N),Ae=new e0(j),Ne=new Pw(j,Ae),ne=new Xw(j,Ae,$,Ne),ie=new Qw(j,ne,Ae,Ne,$),L=new Zw(j,R,te),Xe=new kw(K),Ee=new wv(N,we,gt,R,Ne,Xe),Ve=new Vv(N,K),Ge=new Ov,xe=new Iv(gt),it=new Cw(N,we,w,ie,M,l),Ke=new Nv(N,ie,R),ce=new $v(j,$,R,w),Oe=new Ww(j,gt,$),ae=new Yw(j,gt,$),$.programs=Ee.programs,N.capabilities=R,N.extensions=gt,N.properties=K,N.renderLists=Ge,N.shadowMap=Ke,N.state=w,N.info=$}$e(),_!==qs&&(T=new ey(_,t.width,t.height,o,i,r));const ke=new Fv(N,j);this.xr=ke,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){const A=gt.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=gt.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return Me},this.setPixelRatio=function(A){A!==void 0&&(Me=A,this.setSize(oe,ye,!1))},this.getSize=function(A){return A.set(oe,ye)},this.setSize=function(A,k,Z=!0){if(ke.isPresenting){Qe("WebGLRenderer: Can't change size while VR device is presenting.");return}oe=A,ye=k,t.width=Math.floor(A*Me),t.height=Math.floor(k*Me),Z===!0&&(t.style.width=A+"px",t.style.height=k+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,A,k)},this.getDrawingBufferSize=function(A){return A.set(oe*Me,ye*Me).floor()},this.setDrawingBufferSize=function(A,k,Z){oe=A,ye=k,Me=Z,t.width=Math.floor(A*Z),t.height=Math.floor(k*Z),this.setViewport(0,0,A,k)},this.setEffects=function(A){if(_===qs){Ot("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(A){for(let k=0;k<A.length;k++)if(A[k].isOutputPass===!0){Qe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(A||[])},this.getCurrentViewport=function(A){return A.copy(be)},this.getViewport=function(A){return A.copy(Ye)},this.setViewport=function(A,k,Z,Y){A.isVector4?Ye.set(A.x,A.y,A.z,A.w):Ye.set(A,k,Z,Y),w.viewport(be.copy(Ye).multiplyScalar(Me).round())},this.getScissor=function(A){return A.copy(qt)},this.setScissor=function(A,k,Z,Y){A.isVector4?qt.set(A.x,A.y,A.z,A.w):qt.set(A,k,Z,Y),w.scissor(Re.copy(qt).multiplyScalar(Me).round())},this.getScissorTest=function(){return pt},this.setScissorTest=function(A){w.setScissorTest(pt=A)},this.setOpaqueSort=function(A){et=A},this.setTransparentSort=function(A){nt=A},this.getClearColor=function(A){return A.copy(it.getClearColor())},this.setClearColor=function(){it.setClearColor(...arguments)},this.getClearAlpha=function(){return it.getClearAlpha()},this.setClearAlpha=function(){it.setClearAlpha(...arguments)},this.clear=function(A=!0,k=!0,Z=!0){let Y=0;if(A){let q=!1;if(ue!==null){const de=ue.texture.format;q=m.has(de)}if(q){const de=ue.texture.type,We=f.has(de),Te=it.getClearColor(),Pe=it.getClearAlpha(),Le=Te.r,ot=Te.g,ft=Te.b;We?(S[0]=Le,S[1]=ot,S[2]=ft,S[3]=Pe,j.clearBufferuiv(j.COLOR,0,S)):(v[0]=Le,v[1]=ot,v[2]=ft,v[3]=Pe,j.clearBufferiv(j.COLOR,0,v))}else Y|=j.COLOR_BUFFER_BIT}k&&(Y|=j.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Z&&(Y|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y!==0&&j.clear(Y)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(A){A.setRenderer(this),W=A},this.dispose=function(){t.removeEventListener("webglcontextlost",Yt,!1),t.removeEventListener("webglcontextrestored",Wt,!1),t.removeEventListener("webglcontextcreationerror",Ws,!1),it.dispose(),Ge.dispose(),xe.dispose(),K.dispose(),we.dispose(),ie.dispose(),Ne.dispose(),ce.dispose(),Ee.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",Hr),ke.removeEventListener("sessionend",an),Gn.stop()};function Yt(A){A.preventDefault(),el("WebGLRenderer: Context Lost."),C=!0}function Wt(){el("WebGLRenderer: Context Restored."),C=!1;const A=$.autoReset,k=Ke.enabled,Z=Ke.autoUpdate,Y=Ke.needsUpdate,q=Ke.type;$e(),$.autoReset=A,Ke.enabled=k,Ke.autoUpdate=Z,Ke.needsUpdate=Y,Ke.type=q}function Ws(A){Ot("WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ls(A){const k=A.target;k.removeEventListener("dispose",Ls),Vr(k)}function Vr(A){Oi(A),K.remove(A)}function Oi(A){const k=K.get(A).programs;k!==void 0&&(k.forEach(function(Z){Ee.releaseProgram(Z)}),A.isShaderMaterial&&Ee.releaseShaderCache(A))}this.renderBufferDirect=function(A,k,Z,Y,q,de){k===null&&(k=ls);const We=q.isMesh&&q.matrixWorld.determinantAffine()<0,Te=vl(A,k,Z,Y,q);w.setMaterial(Y,We);let Pe=Z.index,Le=1;if(Y.wireframe===!0){if(Pe=ne.getWireframeAttribute(Z),Pe===void 0)return;Le=2}const ot=Z.drawRange,ft=Z.attributes.position;let qe=ot.start*Le,It=(ot.start+ot.count)*Le;de!==null&&(qe=Math.max(qe,de.start*Le),It=Math.min(It,(de.start+de.count)*Le)),Pe!==null?(qe=Math.max(qe,0),It=Math.min(It,Pe.count)):ft!=null&&(qe=Math.max(qe,0),It=Math.min(It,ft.count));const Qt=It-qe;if(Qt<0||Qt===1/0)return;Ne.setup(q,Y,Te,Z,Pe);let jt,Ct=Oe;if(Pe!==null&&(jt=Ae.get(Pe),Ct=ae,Ct.setIndex(jt)),q.isMesh)Y.wireframe===!0?(w.setLineWidth(Y.wireframeLinewidth*Zt()),Ct.setMode(j.LINES)):Ct.setMode(j.TRIANGLES);else if(q.isLine){let ps=Y.linewidth;ps===void 0&&(ps=1),w.setLineWidth(ps*Zt()),q.isLineSegments?Ct.setMode(j.LINES):q.isLineLoop?Ct.setMode(j.LINE_LOOP):Ct.setMode(j.LINE_STRIP)}else q.isPoints?Ct.setMode(j.POINTS):q.isSprite&&Ct.setMode(j.TRIANGLES);if(q.isBatchedMesh)if(gt.get("WEBGL_multi_draw"))Ct.renderMultiDraw(q._multiDrawStarts,q._multiDrawCounts,q._multiDrawCount);else{const ps=q._multiDrawStarts,De=q._multiDrawCounts,ns=q._multiDrawCount,_t=Pe?Ae.get(Pe).bytesPerElement:1,cs=K.get(Y).currentProgram.getUniforms();for(let Ts=0;Ts<ns;Ts++)cs.setValue(j,"_gl_DrawID",Ts),Ct.render(ps[Ts]/_t,De[Ts])}else if(q.isInstancedMesh)Ct.renderInstances(qe,Qt,q.count);else if(Z.isInstancedBufferGeometry){const ps=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,De=Math.min(Z.instanceCount,ps);Ct.renderInstances(qe,Qt,De)}else Ct.render(qe,Qt)};function xi(A,k,Z){A.transparent===!0&&A.side===Hn&&A.forceSinglePass===!1?(A.side=Us,A.needsUpdate=!0,ks(A,k,Z),A.side=yi,A.needsUpdate=!0,ks(A,k,Z),A.side=Hn):ks(A,k,Z)}this.compile=function(A,k,Z=null){Z===null&&(Z=A),x=xe.get(Z),x.init(k),b.push(x),Z.traverseVisible(function(q){q.isLight&&q.layers.test(k.layers)&&(x.pushLight(q),q.castShadow&&x.pushShadow(q))}),A!==Z&&A.traverseVisible(function(q){q.isLight&&q.layers.test(k.layers)&&(x.pushLight(q),q.castShadow&&x.pushShadow(q))}),x.setupLights();const Y=new Set;return A.traverse(function(q){if(!(q.isMesh||q.isPoints||q.isLine||q.isSprite))return;const de=q.material;if(de)if(Array.isArray(de))for(let We=0;We<de.length;We++){const Te=de[We];xi(Te,Z,q),Y.add(Te)}else xi(de,Z,q),Y.add(de)}),x=b.pop(),Y},this.compileAsync=function(A,k,Z=null){const Y=this.compile(A,k,Z);return new Promise(q=>{function de(){if(Y.forEach(function(We){K.get(We).currentProgram.isReady()&&Y.delete(We)}),Y.size===0){q(A);return}setTimeout(de,10)}gt.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let $r=null;function Ys(A){$r&&$r(A)}function Hr(){Gn.stop()}function an(){Gn.start()}const Gn=new um;Gn.setAnimationLoop(Ys),typeof self<"u"&&Gn.setContext(self),this.setAnimationLoop=function(A){$r=A,ke.setAnimationLoop(A),A===null?Gn.stop():Gn.start()},ke.addEventListener("sessionstart",Hr),ke.addEventListener("sessionend",an),this.render=function(A,k){if(k!==void 0&&k.isCamera!==!0){Ot("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;W!==null&&W.renderStart(A,k);const Z=ke.enabled===!0&&ke.isPresenting===!0,Y=T!==null&&(ue===null||Z)&&T.begin(N,ue);if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(k),k=ke.getCamera()),A.isScene===!0&&A.onBeforeRender(N,A,k,ue),x=xe.get(A,b.length),x.init(k),x.state.textureUnits=te.getTextureUnits(),b.push(x),Pt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),dt.setFromProjectionMatrix(Pt,Sn,k.reversedDepth),vt=this.localClippingEnabled,At=Xe.init(this.clippingPlanes,vt),O=Ge.get(A,G.length),O.init(),G.push(O),ke.enabled===!0&&ke.isPresenting===!0){const We=N.xr.getDepthSensingMesh();We!==null&&si(We,k,-1/0,N.sortObjects)}si(A,k,0,N.sortObjects),O.finish(),N.sortObjects===!0&&O.sort(et,nt,k.reversedDepth),Xt=ke.enabled===!1||ke.isPresenting===!1||ke.hasDepthSensing()===!1,Xt&&it.addToRenderList(O,A),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),At===!0&&Xe.beginShadows();const q=x.state.shadowsArray;if(Ke.render(q,A,k),At===!0&&Xe.endShadows(),(Y&&T.hasRenderPass())===!1){const We=O.opaque,Te=O.transmissive;if(x.setupLights(),k.isArrayCamera){const Pe=k.cameras;if(Te.length>0)for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le];sr(We,Te,A,ft)}Xt&&it.render(A);for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le];tr(O,A,ft,ft.viewport)}}else Te.length>0&&sr(We,Te,A,k),Xt&&it.render(A),tr(O,A,k)}ue!==null&&J===0&&(te.updateMultisampleRenderTarget(ue),te.updateRenderTargetMipmap(ue)),Y&&T.end(N),A.isScene===!0&&A.onAfterRender(N,A,k),Ne.resetDefaultState(),he=-1,Se=null,b.pop(),b.length>0?(x=b[b.length-1],te.setTextureUnits(x.state.textureUnits),At===!0&&Xe.setGlobalState(N.clippingPlanes,x.state.camera)):x=null,G.pop(),G.length>0?O=G[G.length-1]:O=null,W!==null&&W.renderEnd()};function si(A,k,Z,Y){if(A.visible===!1)return;if(A.layers.test(k.layers)){if(A.isGroup)Z=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(k);else if(A.isLightProbeGrid)x.pushLightProbeGrid(A);else if(A.isLight)x.pushLight(A),A.castShadow&&x.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||dt.intersectsSprite(A)){Y&&ss.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Pt);const We=ie.update(A),Te=A.material;Te.visible&&O.push(A,We,Te,Z,ss.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||dt.intersectsObject(A))){const We=ie.update(A),Te=A.material;if(Y&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),ss.copy(A.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),ss.copy(We.boundingSphere.center)),ss.applyMatrix4(A.matrixWorld).applyMatrix4(Pt)),Array.isArray(Te)){const Pe=We.groups;for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le],qe=Te[ft.materialIndex];qe&&qe.visible&&O.push(A,We,qe,Z,ss.z,ft)}}else Te.visible&&O.push(A,We,Te,Z,ss.z,null)}}const de=A.children;for(let We=0,Te=de.length;We<Te;We++)si(de[We],k,Z,Y)}function tr(A,k,Z,Y){const{opaque:q,transmissive:de,transparent:We}=A;x.setupLightsView(Z),At===!0&&Xe.setGlobalState(N.clippingPlanes,Z),Y&&w.viewport(be.copy(Y)),q.length>0&&bn(q,k,Z),de.length>0&&bn(de,k,Z),We.length>0&&bn(We,k,Z),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function sr(A,k,Z,Y){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[Y.id]===void 0){const qe=gt.has("EXT_color_buffer_half_float")||gt.has("EXT_color_buffer_float");x.state.transmissionRenderTarget[Y.id]=new Dn(1,1,{generateMipmaps:!0,type:qe?ei:qs,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xt.workingColorSpace})}const de=x.state.transmissionRenderTarget[Y.id],We=Y.viewport||be;de.setSize(We.z*N.transmissionResolutionScale,We.w*N.transmissionResolutionScale);const Te=N.getRenderTarget(),Pe=N.getActiveCubeFace(),Le=N.getActiveMipmapLevel();N.setRenderTarget(de),N.getClearColor(ct),tt=N.getClearAlpha(),tt<1&&N.setClearColor(16777215,.5),N.clear(),Xt&&it.render(Z);const ot=N.toneMapping;N.toneMapping=En;const ft=Y.viewport;if(Y.viewport!==void 0&&(Y.viewport=void 0),x.setupLightsView(Y),At===!0&&Xe.setGlobalState(N.clippingPlanes,Y),bn(A,Z,Y),te.updateMultisampleRenderTarget(de),te.updateRenderTargetMipmap(de),gt.has("WEBGL_multisampled_render_to_texture")===!1){let qe=!1;for(let It=0,Qt=k.length;It<Qt;It++){const jt=k[It],{object:Ct,geometry:ps,material:De,group:ns}=jt;if(De.side===Hn&&Ct.layers.test(Y.layers)){const _t=De.side;De.side=Us,De.needsUpdate=!0,ni(Ct,Z,Y,ps,De,ns),De.side=_t,De.needsUpdate=!0,qe=!0}}qe===!0&&(te.updateMultisampleRenderTarget(de),te.updateRenderTargetMipmap(de))}N.setRenderTarget(Te,Pe,Le),N.setClearColor(ct,tt),ft!==void 0&&(Y.viewport=ft),N.toneMapping=ot}function bn(A,k,Z){const Y=k.isScene===!0?k.overrideMaterial:null;for(let q=0,de=A.length;q<de;q++){const We=A[q],{object:Te,geometry:Pe,group:Le}=We;let ot=We.material;ot.allowOverride===!0&&Y!==null&&(ot=Y),Te.layers.test(Z.layers)&&ni(Te,k,Z,Pe,ot,Le)}}function ni(A,k,Z,Y,q,de){A.onBeforeRender(N,k,Z,Y,q,de),A.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),q.onBeforeRender(N,k,Z,Y,A,de),q.transparent===!0&&q.side===Hn&&q.forceSinglePass===!1?(q.side=Us,q.needsUpdate=!0,N.renderBufferDirect(Z,k,Y,q,A,de),q.side=yi,q.needsUpdate=!0,N.renderBufferDirect(Z,k,Y,q,A,de),q.side=Hn):N.renderBufferDirect(Z,k,Y,q,A,de),A.onAfterRender(N,k,Z,Y,q,de)}function ks(A,k,Z){k.isScene!==!0&&(k=ls);const Y=K.get(A),q=x.state.lights,de=x.state.shadowsArray,We=q.state.version,Te=Ee.getParameters(A,q.state,de,k,Z,x.state.lightProbeGridArray),Pe=Ee.getProgramCacheKey(Te);let Le=Y.programs;Y.environment=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?k.environment:null,Y.fog=k.fog;const ot=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap;Y.envMap=we.get(A.envMap||Y.environment,ot),Y.envMapRotation=Y.environment!==null&&A.envMap===null?k.environmentRotation:A.envMapRotation,Le===void 0&&(A.addEventListener("dispose",Ls),Le=new Map,Y.programs=Le);let ft=Le.get(Pe);if(ft!==void 0){if(Y.currentProgram===ft&&Y.lightsStateVersion===We)return me(A,Te),ft}else Te.uniforms=Ee.getUniforms(A),W!==null&&A.isNodeMaterial&&W.build(A,Z,Te),A.onBeforeCompile(Te,N),ft=Ee.acquireProgram(Te,Pe),Le.set(Pe,ft),Y.uniforms=Te.uniforms;const qe=Y.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(qe.clippingPlanes=Xe.uniform),me(A,Te),Y.needsLights=ln(A),Y.lightsStateVersion=We,Y.needsLights&&(qe.ambientLightColor.value=q.state.ambient,qe.lightProbe.value=q.state.probe,qe.directionalLights.value=q.state.directional,qe.directionalLightShadows.value=q.state.directionalShadow,qe.spotLights.value=q.state.spot,qe.spotLightShadows.value=q.state.spotShadow,qe.rectAreaLights.value=q.state.rectArea,qe.ltc_1.value=q.state.rectAreaLTC1,qe.ltc_2.value=q.state.rectAreaLTC2,qe.pointLights.value=q.state.point,qe.pointLightShadows.value=q.state.pointShadow,qe.hemisphereLights.value=q.state.hemi,qe.directionalShadowMatrix.value=q.state.directionalShadowMatrix,qe.spotLightMatrix.value=q.state.spotLightMatrix,qe.spotLightMap.value=q.state.spotLightMap,qe.pointShadowMatrix.value=q.state.pointShadowMatrix),Y.lightProbeGrid=x.state.lightProbeGridArray.length>0,Y.currentProgram=ft,Y.uniformsList=null,ft}function zn(A){if(A.uniformsList===null){const k=A.currentProgram.getUniforms();A.uniformsList=To.seqWithValue(k.seq,A.uniforms)}return A.uniformsList}function me(A,k){const Z=K.get(A);Z.outputColorSpace=k.outputColorSpace,Z.batching=k.batching,Z.batchingColor=k.batchingColor,Z.instancing=k.instancing,Z.instancingColor=k.instancingColor,Z.instancingMorph=k.instancingMorph,Z.skinning=k.skinning,Z.morphTargets=k.morphTargets,Z.morphNormals=k.morphNormals,Z.morphColors=k.morphColors,Z.morphTargetsCount=k.morphTargetsCount,Z.numClippingPlanes=k.numClippingPlanes,Z.numIntersection=k.numClipIntersection,Z.vertexAlphas=k.vertexAlphas,Z.vertexTangents=k.vertexTangents,Z.toneMapping=k.toneMapping}function on(A,k){if(A.length===0)return null;if(A.length===1)return A[0].texture!==null?A[0]:null;z.setFromMatrixPosition(k.matrixWorld);for(let Z=0,Y=A.length;Z<Y;Z++){const q=A[Z];if(q.texture!==null&&q.boundingBox.containsPoint(z))return q}return null}function vl(A,k,Z,Y,q){k.isScene!==!0&&(k=ls),te.resetTextureUnits();const de=k.fog,We=Y.isMeshStandardMaterial||Y.isMeshLambertMaterial||Y.isMeshPhongMaterial?k.environment:null,Te=ue===null?N.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:xt.workingColorSpace,Pe=Y.isMeshStandardMaterial||Y.isMeshLambertMaterial&&!Y.envMap||Y.isMeshPhongMaterial&&!Y.envMap,Le=we.get(Y.envMap||We,Pe),ot=Y.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,ft=!!Z.attributes.tangent&&(!!Y.normalMap||Y.anisotropy>0),qe=!!Z.morphAttributes.position,It=!!Z.morphAttributes.normal,Qt=!!Z.morphAttributes.color;let jt=En;Y.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(jt=N.toneMapping);const Ct=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ps=Ct!==void 0?Ct.length:0,De=K.get(Y),ns=x.state.lights;if(At===!0&&(vt===!0||A!==Se)){const Lt=A===Se&&Y.id===he;Xe.setState(Y,A,Lt)}let _t=!1;Y.version===De.__version?(De.needsLights&&De.lightsStateVersion!==ns.state.version||De.outputColorSpace!==Te||q.isBatchedMesh&&De.batching===!1||!q.isBatchedMesh&&De.batching===!0||q.isBatchedMesh&&De.batchingColor===!0&&q.colorTexture===null||q.isBatchedMesh&&De.batchingColor===!1&&q.colorTexture!==null||q.isInstancedMesh&&De.instancing===!1||!q.isInstancedMesh&&De.instancing===!0||q.isSkinnedMesh&&De.skinning===!1||!q.isSkinnedMesh&&De.skinning===!0||q.isInstancedMesh&&De.instancingColor===!0&&q.instanceColor===null||q.isInstancedMesh&&De.instancingColor===!1&&q.instanceColor!==null||q.isInstancedMesh&&De.instancingMorph===!0&&q.morphTexture===null||q.isInstancedMesh&&De.instancingMorph===!1&&q.morphTexture!==null||De.envMap!==Le||Y.fog===!0&&De.fog!==de||De.numClippingPlanes!==void 0&&(De.numClippingPlanes!==Xe.numPlanes||De.numIntersection!==Xe.numIntersection)||De.vertexAlphas!==ot||De.vertexTangents!==ft||De.morphTargets!==qe||De.morphNormals!==It||De.morphColors!==Qt||De.toneMapping!==jt||De.morphTargetsCount!==ps||!!De.lightProbeGrid!=x.state.lightProbeGridArray.length>0)&&(_t=!0):(_t=!0,De.__version=Y.version);let cs=De.currentProgram;_t===!0&&(cs=ks(Y,k,q),W&&Y.isNodeMaterial&&W.onUpdateProgram(Y,cs,De));let Ts=!1,cn=!1,ii=!1;const Bt=cs.getUniforms(),Vt=De.uniforms;if(w.useProgram(cs.program)&&(Ts=!0,cn=!0,ii=!0),Y.id!==he&&(he=Y.id,cn=!0),De.needsLights){const Lt=on(x.state.lightProbeGridArray,q);De.lightProbeGrid!==Lt&&(De.lightProbeGrid=Lt,cn=!0)}if(Ts||Se!==A){w.buffers.depth.getReversed()&&A.reversedDepth!==!0&&(A._reversedDepth=!0,A.updateProjectionMatrix()),Bt.setValue(j,"projectionMatrix",A.projectionMatrix),Bt.setValue(j,"viewMatrix",A.matrixWorldInverse);const zs=Bt.map.cameraPosition;zs!==void 0&&zs.setValue(j,ts.setFromMatrixPosition(A.matrixWorld)),R.logarithmicDepthBuffer&&Bt.setValue(j,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(Y.isMeshPhongMaterial||Y.isMeshToonMaterial||Y.isMeshLambertMaterial||Y.isMeshBasicMaterial||Y.isMeshStandardMaterial||Y.isShaderMaterial)&&Bt.setValue(j,"isOrthographic",A.isOrthographicCamera===!0),Se!==A&&(Se=A,cn=!0,ii=!0)}if(De.needsLights&&(ns.state.directionalShadowMap.length>0&&Bt.setValue(j,"directionalShadowMap",ns.state.directionalShadowMap,te),ns.state.spotShadowMap.length>0&&Bt.setValue(j,"spotShadowMap",ns.state.spotShadowMap,te),ns.state.pointShadowMap.length>0&&Bt.setValue(j,"pointShadowMap",ns.state.pointShadowMap,te)),q.isSkinnedMesh){Bt.setOptional(j,q,"bindMatrix"),Bt.setOptional(j,q,"bindMatrixInverse");const Lt=q.skeleton;Lt&&(Lt.boneTexture===null&&Lt.computeBoneTexture(),Bt.setValue(j,"boneTexture",Lt.boneTexture,te))}q.isBatchedMesh&&(Bt.setOptional(j,q,"batchingTexture"),Bt.setValue(j,"batchingTexture",q._matricesTexture,te),Bt.setOptional(j,q,"batchingIdTexture"),Bt.setValue(j,"batchingIdTexture",q._indirectTexture,te),Bt.setOptional(j,q,"batchingColorTexture"),q._colorsTexture!==null&&Bt.setValue(j,"batchingColorTexture",q._colorsTexture,te));const Gs=Z.morphAttributes;if((Gs.position!==void 0||Gs.normal!==void 0||Gs.color!==void 0)&&L.update(q,Z,cs),(cn||De.receiveShadow!==q.receiveShadow)&&(De.receiveShadow=q.receiveShadow,Bt.setValue(j,"receiveShadow",q.receiveShadow)),(Y.isMeshStandardMaterial||Y.isMeshLambertMaterial||Y.isMeshPhongMaterial)&&Y.envMap===null&&k.environment!==null&&(Vt.envMapIntensity.value=k.environmentIntensity),Vt.dfgLUT!==void 0&&(Vt.dfgLUT.value=qv()),cn){if(Bt.setValue(j,"toneMappingExposure",N.toneMappingExposure),De.needsLights&&Ta(Vt,ii),de&&Y.fog===!0&&Ve.refreshFogUniforms(Vt,de),Ve.refreshMaterialUniforms(Vt,Y,Me,ye,x.state.transmissionRenderTarget[A.id]),De.needsLights&&De.lightProbeGrid){const Lt=De.lightProbeGrid;Vt.probesSH.value=Lt.texture,Vt.probesMin.value.copy(Lt.boundingBox.min),Vt.probesMax.value.copy(Lt.boundingBox.max),Vt.probesResolution.value.copy(Lt.resolution)}To.upload(j,zn(De),Vt,te)}if(Y.isShaderMaterial&&Y.uniformsNeedUpdate===!0&&(To.upload(j,zn(De),Vt,te),Y.uniformsNeedUpdate=!1),Y.isSpriteMaterial&&Bt.setValue(j,"center",q.center),Bt.setValue(j,"modelViewMatrix",q.modelViewMatrix),Bt.setValue(j,"normalMatrix",q.normalMatrix),Bt.setValue(j,"modelMatrix",q.matrixWorld),Y.uniformsGroups!==void 0){const Lt=Y.uniformsGroups;for(let zs=0,Rn=Lt.length;zs<Rn;zs++){const Si=Lt[zs];ce.update(Si,cs),ce.bind(Si,cs)}}return cs}function Ta(A,k){A.ambientLightColor.needsUpdate=k,A.lightProbe.needsUpdate=k,A.directionalLights.needsUpdate=k,A.directionalLightShadows.needsUpdate=k,A.pointLights.needsUpdate=k,A.pointLightShadows.needsUpdate=k,A.spotLights.needsUpdate=k,A.spotLightShadows.needsUpdate=k,A.rectAreaLights.needsUpdate=k,A.hemisphereLights.needsUpdate=k}function ln(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return ee},this.getActiveMipmapLevel=function(){return J},this.getRenderTarget=function(){return ue},this.setRenderTargetTextures=function(A,k,Z){const Y=K.get(A);Y.__autoAllocateDepthBuffer=A.resolveDepthBuffer===!1,Y.__autoAllocateDepthBuffer===!1&&(Y.__useRenderToTexture=!1),K.get(A.texture).__webglTexture=k,K.get(A.depthTexture).__webglTexture=Y.__autoAllocateDepthBuffer?void 0:Z,Y.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(A,k){const Z=K.get(A);Z.__webglFramebuffer=k,Z.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(A,k=0,Z=0){ue=A,ee=k,J=Z;let Y=null,q=!1,de=!1;if(A){const Te=K.get(A);if(Te.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(j.FRAMEBUFFER,Te.__webglFramebuffer),be.copy(A.viewport),Re.copy(A.scissor),ht=A.scissorTest,w.viewport(be),w.scissor(Re),w.setScissorTest(ht),he=-1;return}else if(Te.__webglFramebuffer===void 0)te.setupRenderTarget(A);else if(Te.__hasExternalTextures)te.rebindTextures(A,K.get(A.texture).__webglTexture,K.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const ot=A.depthTexture;if(Te.__boundDepthTexture!==ot){if(ot!==null&&K.has(ot)&&(A.width!==ot.image.width||A.height!==ot.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");te.setupDepthRenderbuffer(A)}}const Pe=A.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(de=!0);const Le=K.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Le[k])?Y=Le[k][Z]:Y=Le[k],q=!0):A.samples>0&&te.useMultisampledRTT(A)===!1?Y=K.get(A).__webglMultisampledFramebuffer:Array.isArray(Le)?Y=Le[Z]:Y=Le,be.copy(A.viewport),Re.copy(A.scissor),ht=A.scissorTest}else be.copy(Ye).multiplyScalar(Me).floor(),Re.copy(qt).multiplyScalar(Me).floor(),ht=pt;if(Z!==0&&(Y=Q),w.bindFramebuffer(j.FRAMEBUFFER,Y)&&w.drawBuffers(A,Y),w.viewport(be),w.scissor(Re),w.setScissorTest(ht),q){const Te=K.get(A.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+k,Te.__webglTexture,Z)}else if(de){const Te=k;for(let Pe=0;Pe<A.textures.length;Pe++){const Le=K.get(A.textures[Pe]);j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0+Pe,Le.__webglTexture,Z,Te)}}else if(A!==null&&Z!==0){const Te=K.get(A.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Te.__webglTexture,Z)}he=-1},this.readRenderTargetPixels=function(A,k,Z,Y,q,de,We,Te=0){if(!(A&&A.isWebGLRenderTarget)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=K.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&We!==void 0&&(Pe=Pe[We]),Pe){w.bindFramebuffer(j.FRAMEBUFFER,Pe);try{const Le=A.textures[Te],ot=Le.format,ft=Le.type;if(A.textures.length>1&&j.readBuffer(j.COLOR_ATTACHMENT0+Te),!R.textureFormatReadable(ot)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(ft)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=A.width-Y&&Z>=0&&Z<=A.height-q&&j.readPixels(k,Z,Y,q,Ie.convert(ot),Ie.convert(ft),de)}finally{const Le=ue!==null?K.get(ue).__webglFramebuffer:null;w.bindFramebuffer(j.FRAMEBUFFER,Le)}}},this.readRenderTargetPixelsAsync=async function(A,k,Z,Y,q,de,We,Te=0){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=K.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&We!==void 0&&(Pe=Pe[We]),Pe)if(k>=0&&k<=A.width-Y&&Z>=0&&Z<=A.height-q){w.bindFramebuffer(j.FRAMEBUFFER,Pe);const Le=A.textures[Te],ot=Le.format,ft=Le.type;if(A.textures.length>1&&j.readBuffer(j.COLOR_ATTACHMENT0+Te),!R.textureFormatReadable(ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qe=j.createBuffer();j.bindBuffer(j.PIXEL_PACK_BUFFER,qe),j.bufferData(j.PIXEL_PACK_BUFFER,de.byteLength,j.STREAM_READ),j.readPixels(k,Z,Y,q,Ie.convert(ot),Ie.convert(ft),0);const It=ue!==null?K.get(ue).__webglFramebuffer:null;w.bindFramebuffer(j.FRAMEBUFFER,It);const Qt=j.fenceSync(j.SYNC_GPU_COMMANDS_COMPLETE,0);return j.flush(),await oz(j,Qt,4),j.bindBuffer(j.PIXEL_PACK_BUFFER,qe),j.getBufferSubData(j.PIXEL_PACK_BUFFER,0,de),j.deleteBuffer(qe),j.deleteSync(Qt),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(A,k=null,Z=0){const Y=Math.pow(2,-Z),q=Math.floor(A.image.width*Y),de=Math.floor(A.image.height*Y),We=k!==null?k.x:0,Te=k!==null?k.y:0;te.setTexture2D(A,0),j.copyTexSubImage2D(j.TEXTURE_2D,Z,0,0,We,Te,q,de),w.unbindTexture()},this.copyTextureToTexture=function(A,k,Z=null,Y=null,q=0,de=0){let We,Te,Pe,Le,ot,ft,qe,It,Qt;const jt=A.isCompressedTexture?A.mipmaps[de]:A.image;if(Z!==null)We=Z.max.x-Z.min.x,Te=Z.max.y-Z.min.y,Pe=Z.isBox3?Z.max.z-Z.min.z:1,Le=Z.min.x,ot=Z.min.y,ft=Z.isBox3?Z.min.z:0;else{const Vt=Math.pow(2,-q);We=Math.floor(jt.width*Vt),Te=Math.floor(jt.height*Vt),A.isDataArrayTexture?Pe=jt.depth:A.isData3DTexture?Pe=Math.floor(jt.depth*Vt):Pe=1,Le=0,ot=0,ft=0}Y!==null?(qe=Y.x,It=Y.y,Qt=Y.z):(qe=0,It=0,Qt=0);const Ct=Ie.convert(k.format),ps=Ie.convert(k.type);let De;k.isData3DTexture?(te.setTexture3D(k,0),De=j.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(te.setTexture2DArray(k,0),De=j.TEXTURE_2D_ARRAY):(te.setTexture2D(k,0),De=j.TEXTURE_2D),w.activeTexture(j.TEXTURE0),w.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,k.flipY),w.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),w.pixelStorei(j.UNPACK_ALIGNMENT,k.unpackAlignment);const ns=w.getParameter(j.UNPACK_ROW_LENGTH),_t=w.getParameter(j.UNPACK_IMAGE_HEIGHT),cs=w.getParameter(j.UNPACK_SKIP_PIXELS),Ts=w.getParameter(j.UNPACK_SKIP_ROWS),cn=w.getParameter(j.UNPACK_SKIP_IMAGES);w.pixelStorei(j.UNPACK_ROW_LENGTH,jt.width),w.pixelStorei(j.UNPACK_IMAGE_HEIGHT,jt.height),w.pixelStorei(j.UNPACK_SKIP_PIXELS,Le),w.pixelStorei(j.UNPACK_SKIP_ROWS,ot),w.pixelStorei(j.UNPACK_SKIP_IMAGES,ft);const ii=A.isDataArrayTexture||A.isData3DTexture,Bt=k.isDataArrayTexture||k.isData3DTexture;if(A.isDepthTexture){const Vt=K.get(A),Gs=K.get(k),Lt=K.get(Vt.__renderTarget),zs=K.get(Gs.__renderTarget);w.bindFramebuffer(j.READ_FRAMEBUFFER,Lt.__webglFramebuffer),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,zs.__webglFramebuffer);for(let Rn=0;Rn<Pe;Rn++)ii&&(j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,K.get(A).__webglTexture,q,ft+Rn),j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,K.get(k).__webglTexture,de,Qt+Rn)),j.blitFramebuffer(Le,ot,We,Te,qe,It,We,Te,j.DEPTH_BUFFER_BIT,j.NEAREST);w.bindFramebuffer(j.READ_FRAMEBUFFER,null),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else if(q!==0||A.isRenderTargetTexture||K.has(A)){const Vt=K.get(A),Gs=K.get(k);w.bindFramebuffer(j.READ_FRAMEBUFFER,se),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,H);for(let Lt=0;Lt<Pe;Lt++)ii?j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Vt.__webglTexture,q,ft+Lt):j.framebufferTexture2D(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Vt.__webglTexture,q),Bt?j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Gs.__webglTexture,de,Qt+Lt):j.framebufferTexture2D(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Gs.__webglTexture,de),q!==0?j.blitFramebuffer(Le,ot,We,Te,qe,It,We,Te,j.COLOR_BUFFER_BIT,j.NEAREST):Bt?j.copyTexSubImage3D(De,de,qe,It,Qt+Lt,Le,ot,We,Te):j.copyTexSubImage2D(De,de,qe,It,Le,ot,We,Te);w.bindFramebuffer(j.READ_FRAMEBUFFER,null),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else Bt?A.isDataTexture||A.isData3DTexture?j.texSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,ps,jt.data):k.isCompressedArrayTexture?j.compressedTexSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,jt.data):j.texSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,ps,jt):A.isDataTexture?j.texSubImage2D(j.TEXTURE_2D,de,qe,It,We,Te,Ct,ps,jt.data):A.isCompressedTexture?j.compressedTexSubImage2D(j.TEXTURE_2D,de,qe,It,jt.width,jt.height,Ct,jt.data):j.texSubImage2D(j.TEXTURE_2D,de,qe,It,We,Te,Ct,ps,jt);w.pixelStorei(j.UNPACK_ROW_LENGTH,ns),w.pixelStorei(j.UNPACK_IMAGE_HEIGHT,_t),w.pixelStorei(j.UNPACK_SKIP_PIXELS,cs),w.pixelStorei(j.UNPACK_SKIP_ROWS,Ts),w.pixelStorei(j.UNPACK_SKIP_IMAGES,cn),de===0&&k.generateMipmaps&&j.generateMipmap(De),w.unbindTexture()},this.initRenderTarget=function(A){K.get(A).__webglFramebuffer===void 0&&te.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?te.setTextureCube(A,0):A.isData3DTexture?te.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?te.setTexture2DArray(A,0):te.setTexture2D(A,0),w.unbindTexture()},this.resetState=function(){ee=0,J=0,ue=null,w.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=xt._getDrawingBufferColorSpace(e),t.unpackColorSpace=xt._getUnpackColorSpace()}}function zm(n){const e=new Map(n.map(M=>[M.id,M])),t=new Map,s=(M,_)=>{const m=t.get(M.id);if(m!==void 0)return m;if(_.has(M.id)||M.parentIds.length===0)return t.set(M.id,0),0;_.add(M.id);let f=0;for(const S of M.parentIds){const v=e.get(S);v&&(f=Math.max(f,s(v,_)+1))}return t.set(M.id,f),f};for(const M of n)s(M,new Set);const i=new Map,r=[],a=(M,_)=>M.id.localeCompare(_.id,void 0,{numeric:!0});for(const M of n){const _=M.parentIds.find(f=>e.has(f));if(_===void 0){r.push(M);continue}const m=i.get(_)??[];m.push(M),i.set(_,m)}r.sort(a);for(const M of i.values())M.sort(a);const o=new Map;let l=0;const c=new Set,d=M=>{c.add(M.id);const _=(i.get(M.id)??[]).filter(v=>!c.has(v.id));if(_.length===0){const v=l++;return o.set(M.id,v),[v,v]}let m=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(const v of _){const[z,O]=d(v);m=Math.min(m,z),f=Math.max(f,O)}const S=(m+f)/2;return o.set(M.id,S),[m,f]};for(const M of r)d(M);for(const M of n)o.has(M.id)||d(M);const h=Math.max(...Array.from(t.values()),0)+1,u=Math.max(l-1,0);return{placements:n.map(M=>({id:M.id,x:o.get(M.id)??0,tier:t.get(M.id)??0})),width:u,tierCount:h}}function Xh(n,e,t){var s,i=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function r(){var a,o=s.length,l,c=0,d=0,h=0;for(a=0;a<o;++a)l=s[a],c+=l.x||0,d+=l.y||0,h+=l.z||0;for(c=(c/o-n)*i,d=(d/o-e)*i,h=(h/o-t)*i,a=0;a<o;++a)l=s[a],c&&(l.x-=c),d&&(l.y-=d),h&&(l.z-=h)}return r.initialize=function(a){s=a},r.x=function(a){return arguments.length?(n=+a,r):n},r.y=function(a){return arguments.length?(e=+a,r):e},r.z=function(a){return arguments.length?(t=+a,r):t},r.strength=function(a){return arguments.length?(i=+a,r):i},r}function Yv(n){const e=+this._x.call(null,n);return _m(this.cover(e),e,n)}function _m(n,e,t){if(isNaN(e))return n;var s,i=n._root,r={data:t},a=n._x0,o=n._x1,l,c,d,h,u;if(!i)return n._root=r,n;for(;i.length;)if((d=e>=(l=(a+o)/2))?a=l:o=l,s=i,!(i=i[h=+d]))return s[h]=r,n;if(c=+n._x.call(null,i.data),e===c)return r.next=i,s?s[h]=r:n._root=r,n;do s=s?s[h]=new Array(2):n._root=new Array(2),(d=e>=(l=(a+o)/2))?a=l:o=l;while((h=+d)==(u=+(c>=l)));return s[u]=i,s[h]=r,n}function Kv(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);let s=1/0,i=-1/0;for(let r=0,a;r<e;++r)isNaN(a=+this._x.call(null,n[r]))||(t[r]=a,a<s&&(s=a),a>i&&(i=a));if(s>i)return this;this.cover(s).cover(i);for(let r=0;r<e;++r)_m(this,t[r],n[r]);return this}function Zv(n){if(isNaN(n=+n))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(n))+1;else{for(var s=t-e||1,i=this._root,r,a;e>n||n>=t;)switch(a=+(n<e),r=new Array(2),r[a]=i,i=r,s*=2,a){case 0:t=e+s;break;case 1:e=t-s;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=t,this}function Qv(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function Jv(n){return arguments.length?this.cover(+n[0][0]).cover(+n[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function Qn(n,e,t){this.node=n,this.x0=e,this.x1=t}function eO(n,e){var t,s=this._x0,i,r,a=this._x1,o=[],l=this._root,c,d;for(l&&o.push(new Qn(l,s,a)),e==null?e=1/0:(s=n-e,a=n+e);c=o.pop();)if(!(!(l=c.node)||(i=c.x0)>a||(r=c.x1)<s))if(l.length){var h=(i+r)/2;o.push(new Qn(l[1],h,r),new Qn(l[0],i,h)),(d=+(n>=h))&&(c=o[o.length-1],o[o.length-1]=o[o.length-1-d],o[o.length-1-d]=c)}else{var u=Math.abs(n-+this._x.call(null,l.data));u<e&&(e=u,s=n-u,a=n+u,t=l.data)}return t}function tO(n){if(isNaN(l=+this._x.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._x1,l,c,d,h,u;if(!t)return this;if(t.length)for(;;){if((d=l>=(c=(a+o)/2))?a=c:o=c,e=t,!(t=t[h=+d]))return this;if(!t.length)break;e[h+1&1]&&(s=e,u=h)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[h]=r:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(s?s[u]=t:this._root=t),this):(this._root=r,this)}function sO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function nO(){return this._root}function iO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function rO(n){var e=[],t,s=this._root,i,r,a;for(s&&e.push(new Qn(s,this._x0,this._x1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.x1)&&s.length){var o=(r+a)/2;(i=s[1])&&e.push(new Qn(i,o,a)),(i=s[0])&&e.push(new Qn(i,r,o))}return this}function aO(n){var e=[],t=[],s;for(this._root&&e.push(new Qn(this._root,this._x0,this._x1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.x1,l=(a+o)/2;(r=i[0])&&e.push(new Qn(r,a,l)),(r=i[1])&&e.push(new Qn(r,l,o))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.x1);return this}function oO(n){return n[0]}function lO(n){return arguments.length?(this._x=n,this):this._x}function du(n,e){var t=new uu(e??oO,NaN,NaN);return n==null?t:t.addAll(n)}function uu(n,e,t){this._x=n,this._x0=e,this._x1=t,this._root=void 0}function Yh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Fs=du.prototype=uu.prototype;Fs.copy=function(){var n=new uu(this._x,this._x0,this._x1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Yh(e),n;for(t=[{source:e,target:n._root=new Array(2)}];e=t.pop();)for(var i=0;i<2;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(2)}):e.target[i]=Yh(s));return n};Fs.add=Yv;Fs.addAll=Kv;Fs.cover=Zv;Fs.data=Qv;Fs.extent=Jv;Fs.find=eO;Fs.remove=tO;Fs.removeAll=sO;Fs.root=nO;Fs.size=iO;Fs.visit=rO;Fs.visitAfter=aO;Fs.x=lO;function cO(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return wm(this.cover(e,t),e,t,n)}function wm(n,e,t,s){if(isNaN(e)||isNaN(t))return n;var i,r=n._root,a={data:s},o=n._x0,l=n._y0,c=n._x1,d=n._y1,h,u,p,M,_,m,f,S;if(!r)return n._root=a,n;for(;r.length;)if((_=e>=(h=(o+c)/2))?o=h:c=h,(m=t>=(u=(l+d)/2))?l=u:d=u,i=r,!(r=r[f=m<<1|_]))return i[f]=a,n;if(p=+n._x.call(null,r.data),M=+n._y.call(null,r.data),e===p&&t===M)return a.next=r,i?i[f]=a:n._root=a,n;do i=i?i[f]=new Array(4):n._root=new Array(4),(_=e>=(h=(o+c)/2))?o=h:c=h,(m=t>=(u=(l+d)/2))?l=u:d=u;while((f=m<<1|_)===(S=(M>=u)<<1|p>=h));return i[S]=r,i[f]=a,n}function dO(n){var e,t,s=n.length,i,r,a=new Array(s),o=new Array(s),l=1/0,c=1/0,d=-1/0,h=-1/0;for(t=0;t<s;++t)isNaN(i=+this._x.call(null,e=n[t]))||isNaN(r=+this._y.call(null,e))||(a[t]=i,o[t]=r,i<l&&(l=i),i>d&&(d=i),r<c&&(c=r),r>h&&(h=r));if(l>d||c>h)return this;for(this.cover(l,c).cover(d,h),t=0;t<s;++t)wm(this,a[t],o[t],n[t]);return this}function uO(n,e){if(isNaN(n=+n)||isNaN(e=+e))return this;var t=this._x0,s=this._y0,i=this._x1,r=this._y1;if(isNaN(t))i=(t=Math.floor(n))+1,r=(s=Math.floor(e))+1;else{for(var a=i-t||1,o=this._root,l,c;t>n||n>=i||s>e||e>=r;)switch(c=(e<s)<<1|n<t,l=new Array(4),l[c]=o,o=l,a*=2,c){case 0:i=t+a,r=s+a;break;case 1:t=i-a,r=s+a;break;case 2:i=t+a,s=r-a;break;case 3:t=i-a,s=r-a;break}this._root&&this._root.length&&(this._root=o)}return this._x0=t,this._y0=s,this._x1=i,this._y1=r,this}function hO(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function fO(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Cs(n,e,t,s,i){this.node=n,this.x0=e,this.y0=t,this.x1=s,this.y1=i}function pO(n,e,t){var s,i=this._x0,r=this._y0,a,o,l,c,d=this._x1,h=this._y1,u=[],p=this._root,M,_;for(p&&u.push(new Cs(p,i,r,d,h)),t==null?t=1/0:(i=n-t,r=e-t,d=n+t,h=e+t,t*=t);M=u.pop();)if(!(!(p=M.node)||(a=M.x0)>d||(o=M.y0)>h||(l=M.x1)<i||(c=M.y1)<r))if(p.length){var m=(a+l)/2,f=(o+c)/2;u.push(new Cs(p[3],m,f,l,c),new Cs(p[2],a,f,m,c),new Cs(p[1],m,o,l,f),new Cs(p[0],a,o,m,f)),(_=(e>=f)<<1|n>=m)&&(M=u[u.length-1],u[u.length-1]=u[u.length-1-_],u[u.length-1-_]=M)}else{var S=n-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),z=S*S+v*v;if(z<t){var O=Math.sqrt(t=z);i=n-O,r=e-O,d=n+O,h=e+O,s=p.data}}return s}function mO(n){if(isNaN(d=+this._x.call(null,n))||isNaN(h=+this._y.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._y0,l=this._x1,c=this._y1,d,h,u,p,M,_,m,f;if(!t)return this;if(t.length)for(;;){if((M=d>=(u=(a+l)/2))?a=u:l=u,(_=h>=(p=(o+c)/2))?o=p:c=p,e=t,!(t=t[m=_<<1|M]))return this;if(!t.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(s=e,f=m)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[m]=r:delete e[m],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(s?s[f]=t:this._root=t),this):(this._root=r,this)}function MO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function gO(){return this._root}function bO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function zO(n){var e=[],t,s=this._root,i,r,a,o,l;for(s&&e.push(new Cs(s,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.y0,o=t.x1,l=t.y1)&&s.length){var c=(r+o)/2,d=(a+l)/2;(i=s[3])&&e.push(new Cs(i,c,d,o,l)),(i=s[2])&&e.push(new Cs(i,r,d,c,l)),(i=s[1])&&e.push(new Cs(i,c,a,o,d)),(i=s[0])&&e.push(new Cs(i,r,a,c,d))}return this}function _O(n){var e=[],t=[],s;for(this._root&&e.push(new Cs(this._root,this._x0,this._y0,this._x1,this._y1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.y0,l=s.x1,c=s.y1,d=(a+l)/2,h=(o+c)/2;(r=i[0])&&e.push(new Cs(r,a,o,d,h)),(r=i[1])&&e.push(new Cs(r,d,o,l,h)),(r=i[2])&&e.push(new Cs(r,a,h,d,c)),(r=i[3])&&e.push(new Cs(r,d,h,l,c))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.y0,s.x1,s.y1);return this}function wO(n){return n[0]}function yO(n){return arguments.length?(this._x=n,this):this._x}function vO(n){return n[1]}function OO(n){return arguments.length?(this._y=n,this):this._y}function hu(n,e,t){var s=new fu(e??wO,t??vO,NaN,NaN,NaN,NaN);return n==null?s:s.addAll(n)}function fu(n,e,t,s,i,r){this._x=n,this._y=e,this._x0=t,this._y0=s,this._x1=i,this._y1=r,this._root=void 0}function Kh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Ps=hu.prototype=fu.prototype;Ps.copy=function(){var n=new fu(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Kh(e),n;for(t=[{source:e,target:n._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(4)}):e.target[i]=Kh(s));return n};Ps.add=cO;Ps.addAll=dO;Ps.cover=uO;Ps.data=hO;Ps.extent=fO;Ps.find=pO;Ps.remove=mO;Ps.removeAll=MO;Ps.root=gO;Ps.size=bO;Ps.visit=zO;Ps.visitAfter=_O;Ps.x=yO;Ps.y=OO;function xO(n){const e=+this._x.call(null,n),t=+this._y.call(null,n),s=+this._z.call(null,n);return ym(this.cover(e,t,s),e,t,s,n)}function ym(n,e,t,s,i){if(isNaN(e)||isNaN(t)||isNaN(s))return n;var r,a=n._root,o={data:i},l=n._x0,c=n._y0,d=n._z0,h=n._x1,u=n._y1,p=n._z1,M,_,m,f,S,v,z,O,x,G,b;if(!a)return n._root=o,n;for(;a.length;)if((z=e>=(M=(l+h)/2))?l=M:h=M,(O=t>=(_=(c+u)/2))?c=_:u=_,(x=s>=(m=(d+p)/2))?d=m:p=m,r=a,!(a=a[G=x<<2|O<<1|z]))return r[G]=o,n;if(f=+n._x.call(null,a.data),S=+n._y.call(null,a.data),v=+n._z.call(null,a.data),e===f&&t===S&&s===v)return o.next=a,r?r[G]=o:n._root=o,n;do r=r?r[G]=new Array(8):n._root=new Array(8),(z=e>=(M=(l+h)/2))?l=M:h=M,(O=t>=(_=(c+u)/2))?c=_:u=_,(x=s>=(m=(d+p)/2))?d=m:p=m;while((G=x<<2|O<<1|z)===(b=(v>=m)<<2|(S>=_)<<1|f>=M));return r[b]=a,r[G]=o,n}function SO(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),s=new Float64Array(e),i=new Float64Array(e);let r=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,d=-1/0;for(let h=0,u,p,M,_;h<e;++h)isNaN(p=+this._x.call(null,u=n[h]))||isNaN(M=+this._y.call(null,u))||isNaN(_=+this._z.call(null,u))||(t[h]=p,s[h]=M,i[h]=_,p<r&&(r=p),p>l&&(l=p),M<a&&(a=M),M>c&&(c=M),_<o&&(o=_),_>d&&(d=_));if(r>l||a>c||o>d)return this;this.cover(r,a,o).cover(l,c,d);for(let h=0;h<e;++h)ym(this,t[h],s[h],i[h],n[h]);return this}function AO(n,e,t){if(isNaN(n=+n)||isNaN(e=+e)||isNaN(t=+t))return this;var s=this._x0,i=this._y0,r=this._z0,a=this._x1,o=this._y1,l=this._z1;if(isNaN(s))a=(s=Math.floor(n))+1,o=(i=Math.floor(e))+1,l=(r=Math.floor(t))+1;else{for(var c=a-s||1,d=this._root,h,u;s>n||n>=a||i>e||e>=o||r>t||t>=l;)switch(u=(t<r)<<2|(e<i)<<1|n<s,h=new Array(8),h[u]=d,d=h,c*=2,u){case 0:a=s+c,o=i+c,l=r+c;break;case 1:s=a-c,o=i+c,l=r+c;break;case 2:a=s+c,i=o-c,l=r+c;break;case 3:s=a-c,i=o-c,l=r+c;break;case 4:a=s+c,o=i+c,r=l-c;break;case 5:s=a-c,o=i+c,r=l-c;break;case 6:a=s+c,i=o-c,r=l-c;break;case 7:s=a-c,i=o-c,r=l-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=s,this._y0=i,this._z0=r,this._x1=a,this._y1=o,this._z1=l,this}function EO(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function DO(n){return arguments.length?this.cover(+n[0][0],+n[0][1],+n[0][2]).cover(+n[1][0],+n[1][1],+n[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function $t(n,e,t,s,i,r,a){this.node=n,this.x0=e,this.y0=t,this.z0=s,this.x1=i,this.y1=r,this.z1=a}function IO(n,e,t,s){var i,r=this._x0,a=this._y0,o=this._z0,l,c,d,h,u,p,M=this._x1,_=this._y1,m=this._z1,f=[],S=this._root,v,z;for(S&&f.push(new $t(S,r,a,o,M,_,m)),s==null?s=1/0:(r=n-s,a=e-s,o=t-s,M=n+s,_=e+s,m=t+s,s*=s);v=f.pop();)if(!(!(S=v.node)||(l=v.x0)>M||(c=v.y0)>_||(d=v.z0)>m||(h=v.x1)<r||(u=v.y1)<a||(p=v.z1)<o))if(S.length){var O=(l+h)/2,x=(c+u)/2,G=(d+p)/2;f.push(new $t(S[7],O,x,G,h,u,p),new $t(S[6],l,x,G,O,u,p),new $t(S[5],O,c,G,h,x,p),new $t(S[4],l,c,G,O,x,p),new $t(S[3],O,x,d,h,u,G),new $t(S[2],l,x,d,O,u,G),new $t(S[1],O,c,d,h,x,G),new $t(S[0],l,c,d,O,x,G)),(z=(t>=G)<<2|(e>=x)<<1|n>=O)&&(v=f[f.length-1],f[f.length-1]=f[f.length-1-z],f[f.length-1-z]=v)}else{var b=n-+this._x.call(null,S.data),T=e-+this._y.call(null,S.data),N=t-+this._z.call(null,S.data),C=b*b+T*T+N*N;if(C<s){var W=Math.sqrt(s=C);r=n-W,a=e-W,o=t-W,M=n+W,_=e+W,m=t+W,i=S.data}}return i}const TO=(n,e,t,s,i,r)=>Math.sqrt((n-s)**2+(e-i)**2+(t-r)**2);function GO(n,e,t,s){const i=[],r=n-s,a=e-s,o=t-s,l=n+s,c=e+s,d=t+s;return this.visit((h,u,p,M,_,m,f)=>{if(!h.length)do{const S=h.data;TO(n,e,t,this._x(S),this._y(S),this._z(S))<=s&&i.push(S)}while(h=h.next);return u>l||p>c||M>d||_<r||m<a||f<o}),i}function RO(n){if(isNaN(u=+this._x.call(null,n))||isNaN(p=+this._y.call(null,n))||isNaN(M=+this._z.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._y0,l=this._z0,c=this._x1,d=this._y1,h=this._z1,u,p,M,_,m,f,S,v,z,O,x;if(!t)return this;if(t.length)for(;;){if((S=u>=(_=(a+c)/2))?a=_:c=_,(v=p>=(m=(o+d)/2))?o=m:d=m,(z=M>=(f=(l+h)/2))?l=f:h=f,e=t,!(t=t[O=z<<2|v<<1|S]))return this;if(!t.length)break;(e[O+1&7]||e[O+2&7]||e[O+3&7]||e[O+4&7]||e[O+5&7]||e[O+6&7]||e[O+7&7])&&(s=e,x=O)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[O]=r:delete e[O],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(s?s[x]=t:this._root=t),this):(this._root=r,this)}function BO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function NO(){return this._root}function CO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function PO(n){var e=[],t,s=this._root,i,r,a,o,l,c,d;for(s&&e.push(new $t(s,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.y0,o=t.z0,l=t.x1,c=t.y1,d=t.z1)&&s.length){var h=(r+l)/2,u=(a+c)/2,p=(o+d)/2;(i=s[7])&&e.push(new $t(i,h,u,p,l,c,d)),(i=s[6])&&e.push(new $t(i,r,u,p,h,c,d)),(i=s[5])&&e.push(new $t(i,h,a,p,l,u,d)),(i=s[4])&&e.push(new $t(i,r,a,p,h,u,d)),(i=s[3])&&e.push(new $t(i,h,u,o,l,c,p)),(i=s[2])&&e.push(new $t(i,r,u,o,h,c,p)),(i=s[1])&&e.push(new $t(i,h,a,o,l,u,p)),(i=s[0])&&e.push(new $t(i,r,a,o,h,u,p))}return this}function WO(n){var e=[],t=[],s;for(this._root&&e.push(new $t(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.y0,l=s.z0,c=s.x1,d=s.y1,h=s.z1,u=(a+c)/2,p=(o+d)/2,M=(l+h)/2;(r=i[0])&&e.push(new $t(r,a,o,l,u,p,M)),(r=i[1])&&e.push(new $t(r,u,o,l,c,p,M)),(r=i[2])&&e.push(new $t(r,a,p,l,u,d,M)),(r=i[3])&&e.push(new $t(r,u,p,l,c,d,M)),(r=i[4])&&e.push(new $t(r,a,o,M,u,p,h)),(r=i[5])&&e.push(new $t(r,u,o,M,c,p,h)),(r=i[6])&&e.push(new $t(r,a,p,M,u,d,h)),(r=i[7])&&e.push(new $t(r,u,p,M,c,d,h))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.y0,s.z0,s.x1,s.y1,s.z1);return this}function LO(n){return n[0]}function kO(n){return arguments.length?(this._x=n,this):this._x}function UO(n){return n[1]}function FO(n){return arguments.length?(this._y=n,this):this._y}function jO(n){return n[2]}function VO(n){return arguments.length?(this._z=n,this):this._z}function pu(n,e,t,s){var i=new mu(e??LO,t??UO,s??jO,NaN,NaN,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function mu(n,e,t,s,i,r,a,o,l){this._x=n,this._y=e,this._z=t,this._x0=s,this._y0=i,this._z0=r,this._x1=a,this._y1=o,this._z1=l,this._root=void 0}function Zh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var ys=pu.prototype=mu.prototype;ys.copy=function(){var n=new mu(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Zh(e),n;for(t=[{source:e,target:n._root=new Array(8)}];e=t.pop();)for(var i=0;i<8;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(8)}):e.target[i]=Zh(s));return n};ys.add=xO;ys.addAll=SO;ys.cover=AO;ys.data=EO;ys.extent=DO;ys.find=IO;ys.findAllWithinRadius=GO;ys.remove=RO;ys.removeAll=BO;ys.root=NO;ys.size=CO;ys.visit=PO;ys.visitAfter=WO;ys.x=kO;ys.y=FO;ys.z=VO;function ds(n){return function(){return n}}function sn(n){return(n()-.5)*1e-6}function uc(n){return n.x+n.vx}function Qh(n){return n.y+n.vy}function $O(n){return n.z+n.vz}function vm(n){var e,t,s,i,r=1,a=1;typeof n!="function"&&(n=ds(n==null?1:+n));function o(){for(var d,h=e.length,u,p,M,_,m,f,S,v=0;v<a;++v)for(u=(t===1?du(e,uc):t===2?hu(e,uc,Qh):t===3?pu(e,uc,Qh,$O):null).visitAfter(l),d=0;d<h;++d)p=e[d],f=s[p.index],S=f*f,M=p.x+p.vx,t>1&&(_=p.y+p.vy),t>2&&(m=p.z+p.vz),u.visit(z);function z(O,x,G,b,T,N,C){var W=[x,G,b,T,N,C],Q=W[0],se=W[1],H=W[2],ee=W[t],J=W[t+1],ue=W[t+2],he=O.data,Se=O.r,be=f+Se;if(he){if(he.index>p.index){var Re=M-he.x-he.vx,ht=t>1?_-he.y-he.vy:0,ct=t>2?m-he.z-he.vz:0,tt=Re*Re+ht*ht+ct*ct;tt<be*be&&(Re===0&&(Re=sn(i),tt+=Re*Re),t>1&&ht===0&&(ht=sn(i),tt+=ht*ht),t>2&&ct===0&&(ct=sn(i),tt+=ct*ct),tt=(be-(tt=Math.sqrt(tt)))/tt*r,p.vx+=(Re*=tt)*(be=(Se*=Se)/(S+Se)),t>1&&(p.vy+=(ht*=tt)*be),t>2&&(p.vz+=(ct*=tt)*be),he.vx-=Re*(be=1-be),t>1&&(he.vy-=ht*be),t>2&&(he.vz-=ct*be))}return}return Q>M+be||ee<M-be||t>1&&(se>_+be||J<_-be)||t>2&&(H>m+be||ue<m-be)}}function l(d){if(d.data)return d.r=s[d.data.index];for(var h=d.r=0;h<Math.pow(2,t);++h)d[h]&&d[h].r>d.r&&(d.r=d[h].r)}function c(){if(e){var d,h=e.length,u;for(s=new Array(h),d=0;d<h;++d)u=e[d],s[u.index]=+n(u,d,e)}}return o.initialize=function(d,...h){e=d,i=h.find(u=>typeof u=="function")||Math.random,t=h.find(u=>[1,2,3].includes(u))||2,c()},o.iterations=function(d){return arguments.length?(a=+d,o):a},o.strength=function(d){return arguments.length?(r=+d,o):r},o.radius=function(d){return arguments.length?(n=typeof d=="function"?d:ds(+d),c(),o):n},o}function HO(n){return n.index}function Jh(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function Om(n){var e=HO,t=u,s,i=ds(30),r,a,o,l,c,d,h=1;n==null&&(n=[]);function u(f){return 1/Math.min(l[f.source.index],l[f.target.index])}function p(f){for(var S=0,v=n.length;S<h;++S)for(var z=0,O,x,G,b=0,T=0,N=0,C,W;z<v;++z)O=n[z],x=O.source,G=O.target,b=G.x+G.vx-x.x-x.vx||sn(d),o>1&&(T=G.y+G.vy-x.y-x.vy||sn(d)),o>2&&(N=G.z+G.vz-x.z-x.vz||sn(d)),C=Math.sqrt(b*b+T*T+N*N),C=(C-r[z])/C*f*s[z],b*=C,T*=C,N*=C,G.vx-=b*(W=c[z]),o>1&&(G.vy-=T*W),o>2&&(G.vz-=N*W),x.vx+=b*(W=1-W),o>1&&(x.vy+=T*W),o>2&&(x.vz+=N*W)}function M(){if(a){var f,S=a.length,v=n.length,z=new Map(a.map((x,G)=>[e(x,G,a),x])),O;for(f=0,l=new Array(S);f<v;++f)O=n[f],O.index=f,typeof O.source!="object"&&(O.source=Jh(z,O.source)),typeof O.target!="object"&&(O.target=Jh(z,O.target)),l[O.source.index]=(l[O.source.index]||0)+1,l[O.target.index]=(l[O.target.index]||0)+1;for(f=0,c=new Array(v);f<v;++f)O=n[f],c[f]=l[O.source.index]/(l[O.source.index]+l[O.target.index]);s=new Array(v),_(),r=new Array(v),m()}}function _(){if(a)for(var f=0,S=n.length;f<S;++f)s[f]=+t(n[f],f,n)}function m(){if(a)for(var f=0,S=n.length;f<S;++f)r[f]=+i(n[f],f,n)}return p.initialize=function(f,...S){a=f,d=S.find(v=>typeof v=="function")||Math.random,o=S.find(v=>[1,2,3].includes(v))||2,M()},p.links=function(f){return arguments.length?(n=f,M(),p):n},p.id=function(f){return arguments.length?(e=f,p):e},p.iterations=function(f){return arguments.length?(h=+f,p):h},p.strength=function(f){return arguments.length?(t=typeof f=="function"?f:ds(+f),_(),p):t},p.distance=function(f){return arguments.length?(i=typeof f=="function"?f:ds(+f),m(),p):i},p}var qO={value:()=>{}};function xm(){for(var n=0,e=arguments.length,t={},s;n<e;++n){if(!(s=arguments[n]+"")||s in t||/[\s.]/.test(s))throw new Error("illegal type: "+s);t[s]=[]}return new Go(t)}function Go(n){this._=n}function XO(n,e){return n.trim().split(/^|\s+/).map(function(t){var s="",i=t.indexOf(".");if(i>=0&&(s=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:s}})}Go.prototype=xm.prototype={constructor:Go,on:function(n,e){var t=this._,s=XO(n+"",t),i,r=-1,a=s.length;if(arguments.length<2){for(;++r<a;)if((i=(n=s[r]).type)&&(i=YO(t[i],n.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<a;)if(i=(n=s[r]).type)t[i]=ef(t[i],n.name,e);else if(e==null)for(i in t)t[i]=ef(t[i],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new Go(n)},call:function(n,e){if((i=arguments.length-2)>0)for(var t=new Array(i),s=0,i,r;s<i;++s)t[s]=arguments[s+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(r=this._[n],s=0,i=r.length;s<i;++s)r[s].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)}};function YO(n,e){for(var t=0,s=n.length,i;t<s;++t)if((i=n[t]).name===e)return i.value}function ef(n,e,t){for(var s=0,i=n.length;s<i;++s)if(n[s].name===e){n[s]=qO,n=n.slice(0,s).concat(n.slice(s+1));break}return t!=null&&n.push({name:e,value:t}),n}var kr=0,ga=0,la=0,Sm=1e3,rl,ba,al=0,Ki=0,zl=0,Ea=typeof performance=="object"&&performance.now?performance:Date,Am=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Em(){return Ki||(Am(KO),Ki=Ea.now()+zl)}function KO(){Ki=0}function Bd(){this._call=this._time=this._next=null}Bd.prototype=Dm.prototype={constructor:Bd,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Em():+t)+(e==null?0:+e),!this._next&&ba!==this&&(ba?ba._next=this:rl=this,ba=this),this._call=n,this._time=t,Nd()},stop:function(){this._call&&(this._call=null,this._time=1/0,Nd())}};function Dm(n,e,t){var s=new Bd;return s.restart(n,e,t),s}function ZO(){Em(),++kr;for(var n=rl,e;n;)(e=Ki-n._time)>=0&&n._call.call(void 0,e),n=n._next;--kr}function tf(){Ki=(al=Ea.now())+zl,kr=ga=0;try{ZO()}finally{kr=0,JO(),Ki=0}}function QO(){var n=Ea.now(),e=n-al;e>Sm&&(zl-=e,al=n)}function JO(){for(var n,e=rl,t,s=1/0;e;)e._call?(s>e._time&&(s=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:rl=t);ba=n,Nd(s)}function Nd(n){if(!kr){ga&&(ga=clearTimeout(ga));var e=n-Ki;e>24?(n<1/0&&(ga=setTimeout(tf,n-Ea.now()-zl)),la&&(la=clearInterval(la))):(la||(al=Ea.now(),la=setInterval(QO,Sm)),kr=1,Am(tf))}}const ex=1664525,tx=1013904223,sf=4294967296;function sx(){let n=1;return()=>(n=(ex*n+tx)%sf)/sf}var nf=3;function hc(n){return n.x}function rf(n){return n.y}function nx(n){return n.z}var ix=10,rx=Math.PI*(3-Math.sqrt(5)),ax=Math.PI*20/(9+Math.sqrt(221));function Im(n,e){e=e||2;var t=Math.min(nf,Math.max(1,Math.round(e))),s,i=1,r=.001,a=1-Math.pow(r,1/300),o=0,l=.6,c=new Map,d=Dm(p),h=xm("tick","end"),u=sx();n==null&&(n=[]);function p(){M(),h.call("tick",s),i<r&&(d.stop(),h.call("end",s))}function M(f){var S,v=n.length,z;f===void 0&&(f=1);for(var O=0;O<f;++O)for(i+=(o-i)*a,c.forEach(function(x){x(i)}),S=0;S<v;++S)z=n[S],z.fx==null?z.x+=z.vx*=l:(z.x=z.fx,z.vx=0),t>1&&(z.fy==null?z.y+=z.vy*=l:(z.y=z.fy,z.vy=0)),t>2&&(z.fz==null?z.z+=z.vz*=l:(z.z=z.fz,z.vz=0));return s}function _(){for(var f=0,S=n.length,v;f<S;++f){if(v=n[f],v.index=f,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),v.fz!=null&&(v.z=v.fz),isNaN(v.x)||t>1&&isNaN(v.y)||t>2&&isNaN(v.z)){var z=ix*(t>2?Math.cbrt(.5+f):t>1?Math.sqrt(.5+f):f),O=f*rx,x=f*ax;t===1?v.x=z:t===2?(v.x=z*Math.cos(O),v.y=z*Math.sin(O)):(v.x=z*Math.sin(O)*Math.cos(x),v.y=z*Math.cos(O),v.z=z*Math.sin(O)*Math.sin(x))}(isNaN(v.vx)||t>1&&isNaN(v.vy)||t>2&&isNaN(v.vz))&&(v.vx=0,t>1&&(v.vy=0),t>2&&(v.vz=0))}}function m(f){return f.initialize&&f.initialize(n,u,t),f}return _(),s={tick:M,restart:function(){return d.restart(p),s},stop:function(){return d.stop(),s},numDimensions:function(f){return arguments.length?(t=Math.min(nf,Math.max(1,Math.round(f))),c.forEach(m),s):t},nodes:function(f){return arguments.length?(n=f,_(),c.forEach(m),s):n},alpha:function(f){return arguments.length?(i=+f,s):i},alphaMin:function(f){return arguments.length?(r=+f,s):r},alphaDecay:function(f){return arguments.length?(a=+f,s):+a},alphaTarget:function(f){return arguments.length?(o=+f,s):o},velocityDecay:function(f){return arguments.length?(l=1-f,s):1-l},randomSource:function(f){return arguments.length?(u=f,c.forEach(m),s):u},force:function(f,S){return arguments.length>1?(S==null?c.delete(f):c.set(f,m(S)),s):c.get(f)},find:function(){var f=Array.prototype.slice.call(arguments),S=f.shift()||0,v=(t>1?f.shift():null)||0,z=(t>2?f.shift():null)||0,O=f.shift()||1/0,x=0,G=n.length,b,T,N,C,W,Q;for(O*=O,x=0;x<G;++x)W=n[x],b=S-W.x,T=v-(W.y||0),N=z-(W.z||0),C=b*b+T*T+N*N,C<O&&(Q=W,O=C);return Q},on:function(f,S){return arguments.length>1?(h.on(f,S),s):h.on(f)}}}function Tm(){var n,e,t,s,i,r=ds(-30),a,o=1,l=1/0,c=.81;function d(M){var _,m=n.length,f=(e===1?du(n,hc):e===2?hu(n,hc,rf):e===3?pu(n,hc,rf,nx):null).visitAfter(u);for(i=M,_=0;_<m;++_)t=n[_],f.visit(p)}function h(){if(n){var M,_=n.length,m;for(a=new Array(_),M=0;M<_;++M)m=n[M],a[m.index]=+r(m,M,n)}}function u(M){var _=0,m,f,S=0,v,z,O,x,G=M.length;if(G){for(v=z=O=x=0;x<G;++x)(m=M[x])&&(f=Math.abs(m.value))&&(_+=m.value,S+=f,v+=f*(m.x||0),z+=f*(m.y||0),O+=f*(m.z||0));_*=Math.sqrt(4/G),M.x=v/S,e>1&&(M.y=z/S),e>2&&(M.z=O/S)}else{m=M,m.x=m.data.x,e>1&&(m.y=m.data.y),e>2&&(m.z=m.data.z);do _+=a[m.data.index];while(m=m.next)}M.value=_}function p(M,_,m,f,S){if(!M.value)return!0;var v=[m,f,S][e-1],z=M.x-t.x,O=e>1?M.y-t.y:0,x=e>2?M.z-t.z:0,G=v-_,b=z*z+O*O+x*x;if(G*G/c<b)return b<l&&(z===0&&(z=sn(s),b+=z*z),e>1&&O===0&&(O=sn(s),b+=O*O),e>2&&x===0&&(x=sn(s),b+=x*x),b<o&&(b=Math.sqrt(o*b)),t.vx+=z*M.value*i/b,e>1&&(t.vy+=O*M.value*i/b),e>2&&(t.vz+=x*M.value*i/b)),!0;if(M.length||b>=l)return;(M.data!==t||M.next)&&(z===0&&(z=sn(s),b+=z*z),e>1&&O===0&&(O=sn(s),b+=O*O),e>2&&x===0&&(x=sn(s),b+=x*x),b<o&&(b=Math.sqrt(o*b)));do M.data!==t&&(G=a[M.data.index]*i/b,t.vx+=z*G,e>1&&(t.vy+=O*G),e>2&&(t.vz+=x*G));while(M=M.next)}return d.initialize=function(M,..._){n=M,s=_.find(m=>typeof m=="function")||Math.random,e=_.find(m=>[1,2,3].includes(m))||2,h()},d.strength=function(M){return arguments.length?(r=typeof M=="function"?M:ds(+M),h(),d):r},d.distanceMin=function(M){return arguments.length?(o=M*M,d):Math.sqrt(o)},d.distanceMax=function(M){return arguments.length?(l=M*M,d):Math.sqrt(l)},d.theta=function(M){return arguments.length?(c=M*M,d):Math.sqrt(c)},d}function ox(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vx+=(i[l]-d.x)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.x=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}function lx(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vy+=(i[l]-d.y)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.y=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}function cx(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vz+=(i[l]-d.z)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.z=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}const ol={charge:!0,link:!0,collide:!0,gravity:!1},bs=.55,co=.16,af=.09;function of(n){return 1.6+.45*Math.sqrt(Math.max(1,n))}const dx=2.6,ux=2,hx=.0022,lf=new P(0,1,0),fx=.006,px=.0035,Ti=1e4,uo=450,vr=700,cf=2500,df=4,Cd=new Set(["created","waiting","scheduled","started","registeringFiles"]);function ho(){const n=getComputedStyle(document.documentElement),e=(t,s)=>new Ze(n.getPropertyValue(t).trim()||s);return{running:e("--orange","#f70"),done:e("--butter","#fec"),error:new Ze("#f22"),template:e("--harvestgold","#fa4"),unknown:new Ze("#555"),edge:e("--pumpkin-pie","#c50"),join:e("--honey","#fc9"),root:e("--dag-root","#6fbfae"),pulse:e("--dag-pulse","#48d8f0")}}const uf=new Map;function mx(n){let e=uf.get(n);return e===void 0&&(e=new Ze(n),uf.set(n,e)),e}function Or(n,e,t){return n.share!==void 0&&n.status!=="cancelled"?n.share>=1?e.error:e.done.clone().lerp(e.error,Math.sqrt(Math.max(0,n.share))):n.status==="finishedWithError"||n.status==="cancelled"?e.error:n.hue!==void 0?mx(n.hue):t?e.root:n.status===void 0?e.template:n.status==="finishedSuccessfully"?e.done:Cd.has(n.status)?e.running:e.unknown}function Mx(n,e,t){const s=Math.PI*(3-Math.sqrt(5)),i=e===1?0:1-2*n/(e-1),r=Math.sqrt(Math.max(0,1-i*i)),a=s*n;return new P(Math.cos(a)*r*t,i*t,Math.sin(a)*r*t)}function gx(n){const e=n.map(a=>a.metric??0),t=Math.max(...e,0),s=zm(n),i=new Map(s.placements.map(a=>[a.id,a])),r=[];for(const a of n){const o=i.get(a.id),l=((o?.x??0)-s.width/2)*ux,c=((s.tierCount-1)/2-(o?.tier??0))*dx,d=a.metric??0,h=t>0?.55+d/t*1:1;r.push({node:a,position:new P(l,c,0),radius:bs*h})}return r}function hf(n){const e=new Map;for(const i of n)for(const r of[...i.parentIds,...i.joinParentIds])e.set(r,(e.get(r)??0)+1),e.set(i.id,(e.get(i.id)??0)+1);const t=n.map(i=>i.metric??e.get(i.id)??1),s=Math.max(...t,1);return new Map(n.map((i,r)=>[i.id,bs*(.5+(t[r]??1)/s*1.2)]))}function bx(n,e=3,t=new Map,s=ol,i=new Set){const r=new Map,a=[];for(const v of n)for(const z of[...v.parentIds,...v.joinParentIds])a.push({source:z,target:v.id}),r.set(z,(r.get(z)??0)+1),r.set(v.id,(r.get(v.id)??0)+1);const o=n.map(v=>v.metric??r.get(v.id)??1),l=Math.max(...o,1),c=o.map(v=>bs*(.5+v/l*1.2)),d=new Map(n.map((v,z)=>[v.id,c[z]??bs])),h=n.map(v=>{const z=t.get(v.id);return z===void 0?{id:v.id}:i.has(v.id)?{id:v.id,x:z.x,y:z.y,z:z.z,fx:z.x,fy:z.y,fz:z.z}:{id:v.id,x:z.x,y:z.y,z:z.z}}),u=v=>i.has(v.id)&&v.fx!==void 0;let p=h,M=a;if(i.size>0){const v=new Set(h.filter(x=>!u(x)).map(x=>x.id));M=a.filter(x=>v.has(x.source)||v.has(x.target));const z=new Set(v);for(const x of M)z.add(x.source),z.add(x.target);p=h.filter(x=>z.has(x.id));const O=new Set(p.map(x=>x.id));M=M.filter(x=>O.has(x.source)&&O.has(x.target))}const _=Tm().strength(s.charge?v=>i.has(v.id)?0:-6*((d.get(v.id)??bs)/bs)**2:v=>i.has(v.id)?0:-6);s.reach!==void 0&&_.distanceMax(s.reach);const m=Im(p,e).force("link",Om(M).id(v=>v.id).distance(s.link?v=>(d.get(v.source.id)??bs)+(d.get(v.target.id)??bs)+1.4:2.2)).force("charge",_).stop();if(i.size===0&&m.force("center",e===2?Xh(0,0):Xh(0,0,0)),s.collide&&m.force("collide",vm().radius(v=>(d.get(v.id)??bs)*1.2)),s.gravity){const v=z=>((d.get(z.id)??bs)/bs)**2*.08;m.force("gx",ox(0).strength(v)).force("gy",lx(0).strength(v)),e===3&&m.force("gz",cx(0).strength(v))}const f=p.length===0?0:t.size>0?90:150;let S=0;return{total:f,moving:p.length,step:v=>{for(let z=0;z<v&&S<f;z++,S++)m.tick()},place:()=>n.map((v,z)=>{const O=h[z];return{node:v,position:new P(O?.x??0,O?.y??0,O?.z??0),radius:c[z]??bs}})}}const zx=90*400,_x=12,wx=2,yx=28,Gm=1.8,ff=.1,pf=.2,vx=`
4109
+ }`;class Uv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const s=new om(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,s=new _s({vertexShader:Lv,fragmentShader:kv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ss(new Ml(20,20),s)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fv extends Zi{constructor(e,t){super();const s=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,u=null,p=null,M=null;const _=typeof XRWebGLBinding<"u",m=new Uv,f={},S=t.getContextAttributes();let v=null,z=null;const O=[],x=[],G=new Je;let b=null;const T=new tn;T.viewport=new Jt;const N=new tn;N.viewport=new Jt;const C=[T,N],W=new Zz;let Q=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getTargetRaySpace()},this.getControllerGrip=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getGripSpace()},this.getHand=function(oe){let ye=O[oe];return ye===void 0&&(ye=new Ll,O[oe]=ye),ye.getHandSpace()};function H(oe){const ye=x.indexOf(oe.inputSource);if(ye===-1)return;const Me=O[ye];Me!==void 0&&(Me.update(oe.inputSource,oe.frame,c||a),Me.dispatchEvent({type:oe.type,data:oe.inputSource}))}function ee(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",ee),i.removeEventListener("inputsourceschange",J);for(let oe=0;oe<O.length;oe++){const ye=x[oe];ye!==null&&(x[oe]=null,O[oe].disconnect(ye))}Q=null,se=null,m.reset();for(const oe in f)delete f[oe];e.setRenderTarget(v),p=null,u=null,h=null,i=null,z=null,tt.stop(),s.isPresenting=!1,e.setPixelRatio(b),e.setSize(G.width,G.height,!1),s.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){r=oe,s.isPresenting===!0&&Qe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){o=oe,s.isPresenting===!0&&Qe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(oe){c=oe},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return h===null&&_&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return M},this.getSession=function(){return i},this.setSession=async function(oe){if(i=oe,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",ee),i.addEventListener("inputsourceschange",J),S.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(G),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,et=null,it=null;S.depth&&(it=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Me=S.stencil?Fi:ti,et=S.stencil?Sa:In);const Ye={colorFormat:t.RGBA8,depthFormat:it,scaleFactor:r};h=this.getBinding(),u=h.createProjectionLayer(Ye),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),z=new Dn(u.textureWidth,u.textureHeight,{format:gn,type:qs,depthTexture:new Wr(u.textureWidth,u.textureHeight,et,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const Me={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,t,Me),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),z=new Dn(p.framebufferWidth,p.framebufferHeight,{format:gn,type:qs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}z.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),tt.setContext(i),tt.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function J(oe){for(let ye=0;ye<oe.removed.length;ye++){const Me=oe.removed[ye],et=x.indexOf(Me);et>=0&&(x[et]=null,O[et].disconnect(Me))}for(let ye=0;ye<oe.added.length;ye++){const Me=oe.added[ye];let et=x.indexOf(Me);if(et===-1){for(let Ye=0;Ye<O.length;Ye++)if(Ye>=x.length){x.push(Me),et=Ye;break}else if(x[Ye]===null){x[Ye]=Me,et=Ye;break}if(et===-1)break}const it=O[et];it&&it.connect(Me)}}const ue=new P,he=new P;function Se(oe,ye,Me){ue.setFromMatrixPosition(ye.matrixWorld),he.setFromMatrixPosition(Me.matrixWorld);const et=ue.distanceTo(he),it=ye.projectionMatrix.elements,Ye=Me.projectionMatrix.elements,qt=it[14]/(it[10]-1),pt=it[14]/(it[10]+1),dt=(it[9]+1)/it[5],At=(it[9]-1)/it[5],vt=(it[8]-1)/it[0],Pt=(Ye[8]+1)/Ye[0],ts=qt*vt,ss=qt*Pt,ls=et/(-vt+Pt),Xt=ls*-vt;if(ye.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(Xt),oe.translateZ(ls),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),it[10]===-1)oe.projectionMatrix.copy(ye.projectionMatrix),oe.projectionMatrixInverse.copy(ye.projectionMatrixInverse);else{const Zt=qt+ls,j=pt+ls,vs=ts-Xt,gt=ss+(et-Xt),R=dt*pt/j*Zt,w=At*pt/j*Zt;oe.projectionMatrix.makePerspective(vs,gt,R,w,Zt,j),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function be(oe,ye){ye===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(ye.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(i===null)return;let ye=oe.near,Me=oe.far;m.texture!==null&&(m.depthNear>0&&(ye=m.depthNear),m.depthFar>0&&(Me=m.depthFar)),W.near=N.near=T.near=ye,W.far=N.far=T.far=Me,(Q!==W.near||se!==W.far)&&(i.updateRenderState({depthNear:W.near,depthFar:W.far}),Q=W.near,se=W.far),W.layers.mask=oe.layers.mask|6,T.layers.mask=W.layers.mask&-5,N.layers.mask=W.layers.mask&-3;const et=oe.parent,it=W.cameras;be(W,et);for(let Ye=0;Ye<it.length;Ye++)be(it[Ye],et);it.length===2?Se(W,T,N):W.projectionMatrix.copy(T.projectionMatrix),Re(oe,W,et)};function Re(oe,ye,Me){Me===null?oe.matrix.copy(ye.matrixWorld):(oe.matrix.copy(Me.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(ye.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(ye.projectionMatrix),oe.projectionMatrixInverse.copy(ye.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=Ad*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return W},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(oe){l=oe,u!==null&&(u.fixedFoveation=oe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=oe)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(W)},this.getCameraTexture=function(oe){return f[oe]};let ht=null;function ct(oe,ye){if(d=ye.getViewerPose(c||a),M=ye,d!==null){const Me=d.views;p!==null&&(e.setRenderTargetFramebuffer(z,p.framebuffer),e.setRenderTarget(z));let et=!1;Me.length!==W.cameras.length&&(W.cameras.length=0,et=!0);for(let pt=0;pt<Me.length;pt++){const dt=Me[pt];let At=null;if(p!==null)At=p.getViewport(dt);else{const Pt=h.getViewSubImage(u,dt);At=Pt.viewport,pt===0&&(e.setRenderTargetTextures(z,Pt.colorTexture,Pt.depthStencilTexture),e.setRenderTarget(z))}let vt=C[pt];vt===void 0&&(vt=new tn,vt.layers.enable(pt),vt.viewport=new Jt,C[pt]=vt),vt.matrix.fromArray(dt.transform.matrix),vt.matrix.decompose(vt.position,vt.quaternion,vt.scale),vt.projectionMatrix.fromArray(dt.projectionMatrix),vt.projectionMatrixInverse.copy(vt.projectionMatrix).invert(),vt.viewport.set(At.x,At.y,At.width,At.height),pt===0&&(W.matrix.copy(vt.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale)),et===!0&&W.cameras.push(vt)}const it=i.enabledFeatures;if(it&&it.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&_){h=s.getBinding();const pt=h.getDepthInformation(Me[0]);pt&&pt.isValid&&pt.texture&&m.init(pt,i.renderState)}if(it&&it.includes("camera-access")&&_){e.state.unbindTexture(),h=s.getBinding();for(let pt=0;pt<Me.length;pt++){const dt=Me[pt].camera;if(dt){let At=f[dt];At||(At=new om,f[dt]=At);const vt=h.getCameraImage(dt);At.sourceTexture=vt}}}}for(let Me=0;Me<O.length;Me++){const et=x[Me],it=O[Me];et!==null&&it!==void 0&&it.update(et,ye,c||a)}ht&&ht(oe,ye),ye.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:ye}),M=null}const tt=new um;tt.setAnimationLoop(ct),this.setAnimationLoop=function(oe){ht=oe},this.dispose=function(){}}}const jv=new Rt,bm=new lt;bm.set(-1,0,0,0,1,0,0,0,1);function Vv(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function s(m,f){f.color.getRGB(m.fogColor.value,lm(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function i(m,f,S,v,z){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),h(m,f)):f.isMeshPhongMaterial?(r(m,f),d(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,z)):f.isMeshMatcapMaterial?(r(m,f),M(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),_(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,S,v):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Us&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Us&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const S=e.get(f),v=S.envMap,z=S.envMapRotation;v&&(m.envMap.value=v,m.envMapRotation.value.setFromMatrix4(jv.makeRotationFromEuler(z)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(bm),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,S,v){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*S,m.scale.value=v*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function d(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,S){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Us&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function M(m,f){f.matcap&&(m.matcap.value=f.matcap)}function _(m,f){const S=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:s,refreshMaterialUniforms:i}}function $v(n,e,t,s){let i={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(z,O){const x=O.program;s.uniformBlockBinding(z,x)}function c(z,O){let x=i[z.id];x===void 0&&(m(z),x=d(z),i[z.id]=x,z.addEventListener("dispose",S));const G=O.program;s.updateUBOMapping(z,G);const b=e.render.frame;r[z.id]!==b&&(u(z),r[z.id]=b)}function d(z){const O=h();z.__bindingPointIndex=O;const x=n.createBuffer(),G=z.__size,b=z.usage;return n.bindBuffer(n.UNIFORM_BUFFER,x),n.bufferData(n.UNIFORM_BUFFER,G,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,O,x),x}function h(){for(let z=0;z<o;z++)if(a.indexOf(z)===-1)return a.push(z),z;return Ot("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(z){const O=i[z.id],x=z.uniforms,G=z.__cache;n.bindBuffer(n.UNIFORM_BUFFER,O);for(let b=0,T=x.length;b<T;b++){const N=x[b];if(Array.isArray(N))for(let C=0,W=N.length;C<W;C++)p(N[C],b,C,G);else p(N,b,0,G)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(z,O,x,G){if(_(z,O,x,G)===!0){const b=z.__offset,T=z.value;if(Array.isArray(T)){let N=0;for(let C=0;C<T.length;C++){const W=T[C],Q=f(W);M(W,z.__data,N),typeof W!="number"&&typeof W!="boolean"&&!W.isMatrix3&&!ArrayBuffer.isView(W)&&(N+=Q.storage/Float32Array.BYTES_PER_ELEMENT)}}else M(T,z.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,b,z.__data)}}function M(z,O,x){typeof z=="number"||typeof z=="boolean"?O[0]=z:z.isMatrix3?(O[0]=z.elements[0],O[1]=z.elements[1],O[2]=z.elements[2],O[3]=0,O[4]=z.elements[3],O[5]=z.elements[4],O[6]=z.elements[5],O[7]=0,O[8]=z.elements[6],O[9]=z.elements[7],O[10]=z.elements[8],O[11]=0):ArrayBuffer.isView(z)?O.set(new z.constructor(z.buffer,z.byteOffset,O.length)):z.toArray(O,x)}function _(z,O,x,G){const b=z.value,T=O+"_"+x;if(G[T]===void 0)return typeof b=="number"||typeof b=="boolean"?G[T]=b:ArrayBuffer.isView(b)?G[T]=b.slice():G[T]=b.clone(),!0;{const N=G[T];if(typeof b=="number"||typeof b=="boolean"){if(N!==b)return G[T]=b,!0}else{if(ArrayBuffer.isView(b))return!0;if(N.equals(b)===!1)return N.copy(b),!0}}return!1}function m(z){const O=z.uniforms;let x=0;const G=16;for(let T=0,N=O.length;T<N;T++){const C=Array.isArray(O[T])?O[T]:[O[T]];for(let W=0,Q=C.length;W<Q;W++){const se=C[W],H=Array.isArray(se.value)?se.value:[se.value];for(let ee=0,J=H.length;ee<J;ee++){const ue=H[ee],he=f(ue),Se=x%G,be=Se%he.boundary,Re=Se+be;x+=be,Re!==0&&G-Re<he.storage&&(x+=G-Re),se.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),se.__offset=x,x+=he.storage}}}const b=x%G;return b>0&&(x+=G-b),z.__size=x,z.__cache={},this}function f(z){const O={boundary:0,storage:0};return typeof z=="number"||typeof z=="boolean"?(O.boundary=4,O.storage=4):z.isVector2?(O.boundary=8,O.storage=8):z.isVector3||z.isColor?(O.boundary=16,O.storage=12):z.isVector4?(O.boundary=16,O.storage=16):z.isMatrix3?(O.boundary=48,O.storage=48):z.isMatrix4?(O.boundary=64,O.storage=64):z.isTexture?Qe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(z)?(O.boundary=16,O.storage=z.byteLength):Qe("WebGLRenderer: Unsupported uniform value type.",z),O}function S(z){const O=z.target;O.removeEventListener("dispose",S);const x=a.indexOf(O.__bindingPointIndex);a.splice(x,1),n.deleteBuffer(i[O.id]),delete i[O.id],delete r[O.id]}function v(){for(const z in i)n.deleteBuffer(i[z]);a=[],i={},r={}}return{bind:l,update:c,dispose:v}}const Hv=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let wn=null;function qv(){return wn===null&&(wn=new rm(Hv,16,16,Yi,ei),wn.name="DFG_LUT",wn.minFilter=Es,wn.magFilter=Es,wn.wrapS=Xn,wn.wrapT=Xn,wn.generateMipmaps=!1,wn.needsUpdate=!0),wn}class Xv{constructor(e={}){const{canvas:t=az(),context:s=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:u=!1,outputBufferType:p=qs}=e;this.isWebGLRenderer=!0;let M;if(s!==null){if(typeof WebGLRenderingContext<"u"&&s instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");M=s.getContextAttributes().alpha}else M=a;const _=p,m=new Set([Qd,Zd,Kd]),f=new Set([qs,In,xa,Sa,qd,Xd]),S=new Uint32Array(4),v=new Int32Array(4),z=new P;let O=null,x=null;const G=[],b=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=En,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const N=this;let C=!1,W=null,Q=null,se=null,H=null;this._outputColorSpace=en;let ee=0,J=0,ue=null,he=-1,Se=null;const be=new Jt,Re=new Jt;let ht=null;const ct=new Ze(0);let tt=0,oe=t.width,ye=t.height,Me=1,et=null,it=null;const Ye=new Jt(0,0,oe,ye),qt=new Jt(0,0,oe,ye);let pt=!1;const dt=new iu;let At=!1,vt=!1;const Pt=new Rt,ts=new P,ss=new Jt,ls={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Xt=!1;function Zt(){return ue===null?Me:1}let j=s;function vs(A,k){return t.getContext(A,k)}try{const A={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$d}`),t.addEventListener("webglcontextlost",Yt,!1),t.addEventListener("webglcontextrestored",Wt,!1),t.addEventListener("webglcontextcreationerror",Ws,!1),j===null){const k="webgl2";if(j=vs(k,A),j===null)throw vs(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(A){throw Ot("WebGLRenderer: "+A.message),A}let gt,R,w,$,K,te,we,Ae,ne,ie,Ee,Ve,Ge,xe,Xe,Ke,rt,L,Oe,ae,Ie,Ne,ce;function $e(){gt=new qw(j),gt.init(),Ie=new Wv(j,gt),R=new Lw(j,gt,e,Ie),w=new Cv(j,gt),R.reversedDepthBuffer&&u&&w.buffers.depth.setReversed(!0),Q=j.createFramebuffer(),se=j.createFramebuffer(),H=j.createFramebuffer(),$=new Kw(j),K=new yv,te=new Pv(j,gt,w,K,R,Ie,$),we=new Hw(N),Ae=new e0(j),Ne=new Pw(j,Ae),ne=new Xw(j,Ae,$,Ne),ie=new Qw(j,ne,Ae,Ne,$),L=new Zw(j,R,te),Xe=new kw(K),Ee=new wv(N,we,gt,R,Ne,Xe),Ve=new Vv(N,K),Ge=new Ov,xe=new Iv(gt),rt=new Cw(N,we,w,ie,M,l),Ke=new Nv(N,ie,R),ce=new $v(j,$,R,w),Oe=new Ww(j,gt,$),ae=new Yw(j,gt,$),$.programs=Ee.programs,N.capabilities=R,N.extensions=gt,N.properties=K,N.renderLists=Ge,N.shadowMap=Ke,N.state=w,N.info=$}$e(),_!==qs&&(T=new ey(_,t.width,t.height,o,i,r));const ke=new Fv(N,j);this.xr=ke,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){const A=gt.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=gt.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return Me},this.setPixelRatio=function(A){A!==void 0&&(Me=A,this.setSize(oe,ye,!1))},this.getSize=function(A){return A.set(oe,ye)},this.setSize=function(A,k,Z=!0){if(ke.isPresenting){Qe("WebGLRenderer: Can't change size while VR device is presenting.");return}oe=A,ye=k,t.width=Math.floor(A*Me),t.height=Math.floor(k*Me),Z===!0&&(t.style.width=A+"px",t.style.height=k+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,A,k)},this.getDrawingBufferSize=function(A){return A.set(oe*Me,ye*Me).floor()},this.setDrawingBufferSize=function(A,k,Z){oe=A,ye=k,Me=Z,t.width=Math.floor(A*Z),t.height=Math.floor(k*Z),this.setViewport(0,0,A,k)},this.setEffects=function(A){if(_===qs){Ot("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(A){for(let k=0;k<A.length;k++)if(A[k].isOutputPass===!0){Qe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(A||[])},this.getCurrentViewport=function(A){return A.copy(be)},this.getViewport=function(A){return A.copy(Ye)},this.setViewport=function(A,k,Z,Y){A.isVector4?Ye.set(A.x,A.y,A.z,A.w):Ye.set(A,k,Z,Y),w.viewport(be.copy(Ye).multiplyScalar(Me).round())},this.getScissor=function(A){return A.copy(qt)},this.setScissor=function(A,k,Z,Y){A.isVector4?qt.set(A.x,A.y,A.z,A.w):qt.set(A,k,Z,Y),w.scissor(Re.copy(qt).multiplyScalar(Me).round())},this.getScissorTest=function(){return pt},this.setScissorTest=function(A){w.setScissorTest(pt=A)},this.setOpaqueSort=function(A){et=A},this.setTransparentSort=function(A){it=A},this.getClearColor=function(A){return A.copy(rt.getClearColor())},this.setClearColor=function(){rt.setClearColor(...arguments)},this.getClearAlpha=function(){return rt.getClearAlpha()},this.setClearAlpha=function(){rt.setClearAlpha(...arguments)},this.clear=function(A=!0,k=!0,Z=!0){let Y=0;if(A){let q=!1;if(ue!==null){const de=ue.texture.format;q=m.has(de)}if(q){const de=ue.texture.type,We=f.has(de),Te=rt.getClearColor(),Pe=rt.getClearAlpha(),Le=Te.r,ot=Te.g,ft=Te.b;We?(S[0]=Le,S[1]=ot,S[2]=ft,S[3]=Pe,j.clearBufferuiv(j.COLOR,0,S)):(v[0]=Le,v[1]=ot,v[2]=ft,v[3]=Pe,j.clearBufferiv(j.COLOR,0,v))}else Y|=j.COLOR_BUFFER_BIT}k&&(Y|=j.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Z&&(Y|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y!==0&&j.clear(Y)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(A){A.setRenderer(this),W=A},this.dispose=function(){t.removeEventListener("webglcontextlost",Yt,!1),t.removeEventListener("webglcontextrestored",Wt,!1),t.removeEventListener("webglcontextcreationerror",Ws,!1),rt.dispose(),Ge.dispose(),xe.dispose(),K.dispose(),we.dispose(),ie.dispose(),Ne.dispose(),ce.dispose(),Ee.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",Hr),ke.removeEventListener("sessionend",an),Gn.stop()};function Yt(A){A.preventDefault(),el("WebGLRenderer: Context Lost."),C=!0}function Wt(){el("WebGLRenderer: Context Restored."),C=!1;const A=$.autoReset,k=Ke.enabled,Z=Ke.autoUpdate,Y=Ke.needsUpdate,q=Ke.type;$e(),$.autoReset=A,Ke.enabled=k,Ke.autoUpdate=Z,Ke.needsUpdate=Y,Ke.type=q}function Ws(A){Ot("WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ls(A){const k=A.target;k.removeEventListener("dispose",Ls),Vr(k)}function Vr(A){xi(A),K.remove(A)}function xi(A){const k=K.get(A).programs;k!==void 0&&(k.forEach(function(Z){Ee.releaseProgram(Z)}),A.isShaderMaterial&&Ee.releaseShaderCache(A))}this.renderBufferDirect=function(A,k,Z,Y,q,de){k===null&&(k=ls);const We=q.isMesh&&q.matrixWorld.determinantAffine()<0,Te=vl(A,k,Z,Y,q);w.setMaterial(Y,We);let Pe=Z.index,Le=1;if(Y.wireframe===!0){if(Pe=ne.getWireframeAttribute(Z),Pe===void 0)return;Le=2}const ot=Z.drawRange,ft=Z.attributes.position;let qe=ot.start*Le,It=(ot.start+ot.count)*Le;de!==null&&(qe=Math.max(qe,de.start*Le),It=Math.min(It,(de.start+de.count)*Le)),Pe!==null?(qe=Math.max(qe,0),It=Math.min(It,Pe.count)):ft!=null&&(qe=Math.max(qe,0),It=Math.min(It,ft.count));const Qt=It-qe;if(Qt<0||Qt===1/0)return;Ne.setup(q,Y,Te,Z,Pe);let jt,Ct=Oe;if(Pe!==null&&(jt=Ae.get(Pe),Ct=ae,Ct.setIndex(jt)),q.isMesh)Y.wireframe===!0?(w.setLineWidth(Y.wireframeLinewidth*Zt()),Ct.setMode(j.LINES)):Ct.setMode(j.TRIANGLES);else if(q.isLine){let ps=Y.linewidth;ps===void 0&&(ps=1),w.setLineWidth(ps*Zt()),q.isLineSegments?Ct.setMode(j.LINES):q.isLineLoop?Ct.setMode(j.LINE_LOOP):Ct.setMode(j.LINE_STRIP)}else q.isPoints?Ct.setMode(j.POINTS):q.isSprite&&Ct.setMode(j.TRIANGLES);if(q.isBatchedMesh)if(gt.get("WEBGL_multi_draw"))Ct.renderMultiDraw(q._multiDrawStarts,q._multiDrawCounts,q._multiDrawCount);else{const ps=q._multiDrawStarts,De=q._multiDrawCounts,ns=q._multiDrawCount,_t=Pe?Ae.get(Pe).bytesPerElement:1,cs=K.get(Y).currentProgram.getUniforms();for(let Ts=0;Ts<ns;Ts++)cs.setValue(j,"_gl_DrawID",Ts),Ct.render(ps[Ts]/_t,De[Ts])}else if(q.isInstancedMesh)Ct.renderInstances(qe,Qt,q.count);else if(Z.isInstancedBufferGeometry){const ps=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,De=Math.min(Z.instanceCount,ps);Ct.renderInstances(qe,Qt,De)}else Ct.render(qe,Qt)};function Si(A,k,Z){A.transparent===!0&&A.side===Hn&&A.forceSinglePass===!1?(A.side=Us,A.needsUpdate=!0,ks(A,k,Z),A.side=vi,A.needsUpdate=!0,ks(A,k,Z),A.side=Hn):ks(A,k,Z)}this.compile=function(A,k,Z=null){Z===null&&(Z=A),x=xe.get(Z),x.init(k),b.push(x),Z.traverseVisible(function(q){q.isLight&&q.layers.test(k.layers)&&(x.pushLight(q),q.castShadow&&x.pushShadow(q))}),A!==Z&&A.traverseVisible(function(q){q.isLight&&q.layers.test(k.layers)&&(x.pushLight(q),q.castShadow&&x.pushShadow(q))}),x.setupLights();const Y=new Set;return A.traverse(function(q){if(!(q.isMesh||q.isPoints||q.isLine||q.isSprite))return;const de=q.material;if(de)if(Array.isArray(de))for(let We=0;We<de.length;We++){const Te=de[We];Si(Te,Z,q),Y.add(Te)}else Si(de,Z,q),Y.add(de)}),x=b.pop(),Y},this.compileAsync=function(A,k,Z=null){const Y=this.compile(A,k,Z);return new Promise(q=>{function de(){if(Y.forEach(function(We){K.get(We).currentProgram.isReady()&&Y.delete(We)}),Y.size===0){q(A);return}setTimeout(de,10)}gt.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let $r=null;function Ys(A){$r&&$r(A)}function Hr(){Gn.stop()}function an(){Gn.start()}const Gn=new um;Gn.setAnimationLoop(Ys),typeof self<"u"&&Gn.setContext(self),this.setAnimationLoop=function(A){$r=A,ke.setAnimationLoop(A),A===null?Gn.stop():Gn.start()},ke.addEventListener("sessionstart",Hr),ke.addEventListener("sessionend",an),this.render=function(A,k){if(k!==void 0&&k.isCamera!==!0){Ot("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;W!==null&&W.renderStart(A,k);const Z=ke.enabled===!0&&ke.isPresenting===!0,Y=T!==null&&(ue===null||Z)&&T.begin(N,ue);if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(k),k=ke.getCamera()),A.isScene===!0&&A.onBeforeRender(N,A,k,ue),x=xe.get(A,b.length),x.init(k),x.state.textureUnits=te.getTextureUnits(),b.push(x),Pt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),dt.setFromProjectionMatrix(Pt,Sn,k.reversedDepth),vt=this.localClippingEnabled,At=Xe.init(this.clippingPlanes,vt),O=Ge.get(A,G.length),O.init(),G.push(O),ke.enabled===!0&&ke.isPresenting===!0){const We=N.xr.getDepthSensingMesh();We!==null&&si(We,k,-1/0,N.sortObjects)}si(A,k,0,N.sortObjects),O.finish(),N.sortObjects===!0&&O.sort(et,it,k.reversedDepth),Xt=ke.enabled===!1||ke.isPresenting===!1||ke.hasDepthSensing()===!1,Xt&&rt.addToRenderList(O,A),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),At===!0&&Xe.beginShadows();const q=x.state.shadowsArray;if(Ke.render(q,A,k),At===!0&&Xe.endShadows(),(Y&&T.hasRenderPass())===!1){const We=O.opaque,Te=O.transmissive;if(x.setupLights(),k.isArrayCamera){const Pe=k.cameras;if(Te.length>0)for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le];sr(We,Te,A,ft)}Xt&&rt.render(A);for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le];tr(O,A,ft,ft.viewport)}}else Te.length>0&&sr(We,Te,A,k),Xt&&rt.render(A),tr(O,A,k)}ue!==null&&J===0&&(te.updateMultisampleRenderTarget(ue),te.updateRenderTargetMipmap(ue)),Y&&T.end(N),A.isScene===!0&&A.onAfterRender(N,A,k),Ne.resetDefaultState(),he=-1,Se=null,b.pop(),b.length>0?(x=b[b.length-1],te.setTextureUnits(x.state.textureUnits),At===!0&&Xe.setGlobalState(N.clippingPlanes,x.state.camera)):x=null,G.pop(),G.length>0?O=G[G.length-1]:O=null,W!==null&&W.renderEnd()};function si(A,k,Z,Y){if(A.visible===!1)return;if(A.layers.test(k.layers)){if(A.isGroup)Z=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(k);else if(A.isLightProbeGrid)x.pushLightProbeGrid(A);else if(A.isLight)x.pushLight(A),A.castShadow&&x.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||dt.intersectsSprite(A)){Y&&ss.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Pt);const We=ie.update(A),Te=A.material;Te.visible&&O.push(A,We,Te,Z,ss.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||dt.intersectsObject(A))){const We=ie.update(A),Te=A.material;if(Y&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),ss.copy(A.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),ss.copy(We.boundingSphere.center)),ss.applyMatrix4(A.matrixWorld).applyMatrix4(Pt)),Array.isArray(Te)){const Pe=We.groups;for(let Le=0,ot=Pe.length;Le<ot;Le++){const ft=Pe[Le],qe=Te[ft.materialIndex];qe&&qe.visible&&O.push(A,We,qe,Z,ss.z,ft)}}else Te.visible&&O.push(A,We,Te,Z,ss.z,null)}}const de=A.children;for(let We=0,Te=de.length;We<Te;We++)si(de[We],k,Z,Y)}function tr(A,k,Z,Y){const{opaque:q,transmissive:de,transparent:We}=A;x.setupLightsView(Z),At===!0&&Xe.setGlobalState(N.clippingPlanes,Z),Y&&w.viewport(be.copy(Y)),q.length>0&&bn(q,k,Z),de.length>0&&bn(de,k,Z),We.length>0&&bn(We,k,Z),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function sr(A,k,Z,Y){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[Y.id]===void 0){const qe=gt.has("EXT_color_buffer_half_float")||gt.has("EXT_color_buffer_float");x.state.transmissionRenderTarget[Y.id]=new Dn(1,1,{generateMipmaps:!0,type:qe?ei:qs,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xt.workingColorSpace})}const de=x.state.transmissionRenderTarget[Y.id],We=Y.viewport||be;de.setSize(We.z*N.transmissionResolutionScale,We.w*N.transmissionResolutionScale);const Te=N.getRenderTarget(),Pe=N.getActiveCubeFace(),Le=N.getActiveMipmapLevel();N.setRenderTarget(de),N.getClearColor(ct),tt=N.getClearAlpha(),tt<1&&N.setClearColor(16777215,.5),N.clear(),Xt&&rt.render(Z);const ot=N.toneMapping;N.toneMapping=En;const ft=Y.viewport;if(Y.viewport!==void 0&&(Y.viewport=void 0),x.setupLightsView(Y),At===!0&&Xe.setGlobalState(N.clippingPlanes,Y),bn(A,Z,Y),te.updateMultisampleRenderTarget(de),te.updateRenderTargetMipmap(de),gt.has("WEBGL_multisampled_render_to_texture")===!1){let qe=!1;for(let It=0,Qt=k.length;It<Qt;It++){const jt=k[It],{object:Ct,geometry:ps,material:De,group:ns}=jt;if(De.side===Hn&&Ct.layers.test(Y.layers)){const _t=De.side;De.side=Us,De.needsUpdate=!0,ni(Ct,Z,Y,ps,De,ns),De.side=_t,De.needsUpdate=!0,qe=!0}}qe===!0&&(te.updateMultisampleRenderTarget(de),te.updateRenderTargetMipmap(de))}N.setRenderTarget(Te,Pe,Le),N.setClearColor(ct,tt),ft!==void 0&&(Y.viewport=ft),N.toneMapping=ot}function bn(A,k,Z){const Y=k.isScene===!0?k.overrideMaterial:null;for(let q=0,de=A.length;q<de;q++){const We=A[q],{object:Te,geometry:Pe,group:Le}=We;let ot=We.material;ot.allowOverride===!0&&Y!==null&&(ot=Y),Te.layers.test(Z.layers)&&ni(Te,k,Z,Pe,ot,Le)}}function ni(A,k,Z,Y,q,de){A.onBeforeRender(N,k,Z,Y,q,de),A.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),q.onBeforeRender(N,k,Z,Y,A,de),q.transparent===!0&&q.side===Hn&&q.forceSinglePass===!1?(q.side=Us,q.needsUpdate=!0,N.renderBufferDirect(Z,k,Y,q,A,de),q.side=vi,q.needsUpdate=!0,N.renderBufferDirect(Z,k,Y,q,A,de),q.side=Hn):N.renderBufferDirect(Z,k,Y,q,A,de),A.onAfterRender(N,k,Z,Y,q,de)}function ks(A,k,Z){k.isScene!==!0&&(k=ls);const Y=K.get(A),q=x.state.lights,de=x.state.shadowsArray,We=q.state.version,Te=Ee.getParameters(A,q.state,de,k,Z,x.state.lightProbeGridArray),Pe=Ee.getProgramCacheKey(Te);let Le=Y.programs;Y.environment=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?k.environment:null,Y.fog=k.fog;const ot=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap;Y.envMap=we.get(A.envMap||Y.environment,ot),Y.envMapRotation=Y.environment!==null&&A.envMap===null?k.environmentRotation:A.envMapRotation,Le===void 0&&(A.addEventListener("dispose",Ls),Le=new Map,Y.programs=Le);let ft=Le.get(Pe);if(ft!==void 0){if(Y.currentProgram===ft&&Y.lightsStateVersion===We)return me(A,Te),ft}else Te.uniforms=Ee.getUniforms(A),W!==null&&A.isNodeMaterial&&W.build(A,Z,Te),A.onBeforeCompile(Te,N),ft=Ee.acquireProgram(Te,Pe),Le.set(Pe,ft),Y.uniforms=Te.uniforms;const qe=Y.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(qe.clippingPlanes=Xe.uniform),me(A,Te),Y.needsLights=ln(A),Y.lightsStateVersion=We,Y.needsLights&&(qe.ambientLightColor.value=q.state.ambient,qe.lightProbe.value=q.state.probe,qe.directionalLights.value=q.state.directional,qe.directionalLightShadows.value=q.state.directionalShadow,qe.spotLights.value=q.state.spot,qe.spotLightShadows.value=q.state.spotShadow,qe.rectAreaLights.value=q.state.rectArea,qe.ltc_1.value=q.state.rectAreaLTC1,qe.ltc_2.value=q.state.rectAreaLTC2,qe.pointLights.value=q.state.point,qe.pointLightShadows.value=q.state.pointShadow,qe.hemisphereLights.value=q.state.hemi,qe.directionalShadowMatrix.value=q.state.directionalShadowMatrix,qe.spotLightMatrix.value=q.state.spotLightMatrix,qe.spotLightMap.value=q.state.spotLightMap,qe.pointShadowMatrix.value=q.state.pointShadowMatrix),Y.lightProbeGrid=x.state.lightProbeGridArray.length>0,Y.currentProgram=ft,Y.uniformsList=null,ft}function zn(A){if(A.uniformsList===null){const k=A.currentProgram.getUniforms();A.uniformsList=To.seqWithValue(k.seq,A.uniforms)}return A.uniformsList}function me(A,k){const Z=K.get(A);Z.outputColorSpace=k.outputColorSpace,Z.batching=k.batching,Z.batchingColor=k.batchingColor,Z.instancing=k.instancing,Z.instancingColor=k.instancingColor,Z.instancingMorph=k.instancingMorph,Z.skinning=k.skinning,Z.morphTargets=k.morphTargets,Z.morphNormals=k.morphNormals,Z.morphColors=k.morphColors,Z.morphTargetsCount=k.morphTargetsCount,Z.numClippingPlanes=k.numClippingPlanes,Z.numIntersection=k.numClipIntersection,Z.vertexAlphas=k.vertexAlphas,Z.vertexTangents=k.vertexTangents,Z.toneMapping=k.toneMapping}function on(A,k){if(A.length===0)return null;if(A.length===1)return A[0].texture!==null?A[0]:null;z.setFromMatrixPosition(k.matrixWorld);for(let Z=0,Y=A.length;Z<Y;Z++){const q=A[Z];if(q.texture!==null&&q.boundingBox.containsPoint(z))return q}return null}function vl(A,k,Z,Y,q){k.isScene!==!0&&(k=ls),te.resetTextureUnits();const de=k.fog,We=Y.isMeshStandardMaterial||Y.isMeshLambertMaterial||Y.isMeshPhongMaterial?k.environment:null,Te=ue===null?N.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:xt.workingColorSpace,Pe=Y.isMeshStandardMaterial||Y.isMeshLambertMaterial&&!Y.envMap||Y.isMeshPhongMaterial&&!Y.envMap,Le=we.get(Y.envMap||We,Pe),ot=Y.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,ft=!!Z.attributes.tangent&&(!!Y.normalMap||Y.anisotropy>0),qe=!!Z.morphAttributes.position,It=!!Z.morphAttributes.normal,Qt=!!Z.morphAttributes.color;let jt=En;Y.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(jt=N.toneMapping);const Ct=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ps=Ct!==void 0?Ct.length:0,De=K.get(Y),ns=x.state.lights;if(At===!0&&(vt===!0||A!==Se)){const Lt=A===Se&&Y.id===he;Xe.setState(Y,A,Lt)}let _t=!1;Y.version===De.__version?(De.needsLights&&De.lightsStateVersion!==ns.state.version||De.outputColorSpace!==Te||q.isBatchedMesh&&De.batching===!1||!q.isBatchedMesh&&De.batching===!0||q.isBatchedMesh&&De.batchingColor===!0&&q.colorTexture===null||q.isBatchedMesh&&De.batchingColor===!1&&q.colorTexture!==null||q.isInstancedMesh&&De.instancing===!1||!q.isInstancedMesh&&De.instancing===!0||q.isSkinnedMesh&&De.skinning===!1||!q.isSkinnedMesh&&De.skinning===!0||q.isInstancedMesh&&De.instancingColor===!0&&q.instanceColor===null||q.isInstancedMesh&&De.instancingColor===!1&&q.instanceColor!==null||q.isInstancedMesh&&De.instancingMorph===!0&&q.morphTexture===null||q.isInstancedMesh&&De.instancingMorph===!1&&q.morphTexture!==null||De.envMap!==Le||Y.fog===!0&&De.fog!==de||De.numClippingPlanes!==void 0&&(De.numClippingPlanes!==Xe.numPlanes||De.numIntersection!==Xe.numIntersection)||De.vertexAlphas!==ot||De.vertexTangents!==ft||De.morphTargets!==qe||De.morphNormals!==It||De.morphColors!==Qt||De.toneMapping!==jt||De.morphTargetsCount!==ps||!!De.lightProbeGrid!=x.state.lightProbeGridArray.length>0)&&(_t=!0):(_t=!0,De.__version=Y.version);let cs=De.currentProgram;_t===!0&&(cs=ks(Y,k,q),W&&Y.isNodeMaterial&&W.onUpdateProgram(Y,cs,De));let Ts=!1,cn=!1,ii=!1;const Bt=cs.getUniforms(),Vt=De.uniforms;if(w.useProgram(cs.program)&&(Ts=!0,cn=!0,ii=!0),Y.id!==he&&(he=Y.id,cn=!0),De.needsLights){const Lt=on(x.state.lightProbeGridArray,q);De.lightProbeGrid!==Lt&&(De.lightProbeGrid=Lt,cn=!0)}if(Ts||Se!==A){w.buffers.depth.getReversed()&&A.reversedDepth!==!0&&(A._reversedDepth=!0,A.updateProjectionMatrix()),Bt.setValue(j,"projectionMatrix",A.projectionMatrix),Bt.setValue(j,"viewMatrix",A.matrixWorldInverse);const zs=Bt.map.cameraPosition;zs!==void 0&&zs.setValue(j,ts.setFromMatrixPosition(A.matrixWorld)),R.logarithmicDepthBuffer&&Bt.setValue(j,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(Y.isMeshPhongMaterial||Y.isMeshToonMaterial||Y.isMeshLambertMaterial||Y.isMeshBasicMaterial||Y.isMeshStandardMaterial||Y.isShaderMaterial)&&Bt.setValue(j,"isOrthographic",A.isOrthographicCamera===!0),Se!==A&&(Se=A,cn=!0,ii=!0)}if(De.needsLights&&(ns.state.directionalShadowMap.length>0&&Bt.setValue(j,"directionalShadowMap",ns.state.directionalShadowMap,te),ns.state.spotShadowMap.length>0&&Bt.setValue(j,"spotShadowMap",ns.state.spotShadowMap,te),ns.state.pointShadowMap.length>0&&Bt.setValue(j,"pointShadowMap",ns.state.pointShadowMap,te)),q.isSkinnedMesh){Bt.setOptional(j,q,"bindMatrix"),Bt.setOptional(j,q,"bindMatrixInverse");const Lt=q.skeleton;Lt&&(Lt.boneTexture===null&&Lt.computeBoneTexture(),Bt.setValue(j,"boneTexture",Lt.boneTexture,te))}q.isBatchedMesh&&(Bt.setOptional(j,q,"batchingTexture"),Bt.setValue(j,"batchingTexture",q._matricesTexture,te),Bt.setOptional(j,q,"batchingIdTexture"),Bt.setValue(j,"batchingIdTexture",q._indirectTexture,te),Bt.setOptional(j,q,"batchingColorTexture"),q._colorsTexture!==null&&Bt.setValue(j,"batchingColorTexture",q._colorsTexture,te));const Gs=Z.morphAttributes;if((Gs.position!==void 0||Gs.normal!==void 0||Gs.color!==void 0)&&L.update(q,Z,cs),(cn||De.receiveShadow!==q.receiveShadow)&&(De.receiveShadow=q.receiveShadow,Bt.setValue(j,"receiveShadow",q.receiveShadow)),(Y.isMeshStandardMaterial||Y.isMeshLambertMaterial||Y.isMeshPhongMaterial)&&Y.envMap===null&&k.environment!==null&&(Vt.envMapIntensity.value=k.environmentIntensity),Vt.dfgLUT!==void 0&&(Vt.dfgLUT.value=qv()),cn){if(Bt.setValue(j,"toneMappingExposure",N.toneMappingExposure),De.needsLights&&Ta(Vt,ii),de&&Y.fog===!0&&Ve.refreshFogUniforms(Vt,de),Ve.refreshMaterialUniforms(Vt,Y,Me,ye,x.state.transmissionRenderTarget[A.id]),De.needsLights&&De.lightProbeGrid){const Lt=De.lightProbeGrid;Vt.probesSH.value=Lt.texture,Vt.probesMin.value.copy(Lt.boundingBox.min),Vt.probesMax.value.copy(Lt.boundingBox.max),Vt.probesResolution.value.copy(Lt.resolution)}To.upload(j,zn(De),Vt,te)}if(Y.isShaderMaterial&&Y.uniformsNeedUpdate===!0&&(To.upload(j,zn(De),Vt,te),Y.uniformsNeedUpdate=!1),Y.isSpriteMaterial&&Bt.setValue(j,"center",q.center),Bt.setValue(j,"modelViewMatrix",q.modelViewMatrix),Bt.setValue(j,"normalMatrix",q.normalMatrix),Bt.setValue(j,"modelMatrix",q.matrixWorld),Y.uniformsGroups!==void 0){const Lt=Y.uniformsGroups;for(let zs=0,Rn=Lt.length;zs<Rn;zs++){const Ai=Lt[zs];ce.update(Ai,cs),ce.bind(Ai,cs)}}return cs}function Ta(A,k){A.ambientLightColor.needsUpdate=k,A.lightProbe.needsUpdate=k,A.directionalLights.needsUpdate=k,A.directionalLightShadows.needsUpdate=k,A.pointLights.needsUpdate=k,A.pointLightShadows.needsUpdate=k,A.spotLights.needsUpdate=k,A.spotLightShadows.needsUpdate=k,A.rectAreaLights.needsUpdate=k,A.hemisphereLights.needsUpdate=k}function ln(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return ee},this.getActiveMipmapLevel=function(){return J},this.getRenderTarget=function(){return ue},this.setRenderTargetTextures=function(A,k,Z){const Y=K.get(A);Y.__autoAllocateDepthBuffer=A.resolveDepthBuffer===!1,Y.__autoAllocateDepthBuffer===!1&&(Y.__useRenderToTexture=!1),K.get(A.texture).__webglTexture=k,K.get(A.depthTexture).__webglTexture=Y.__autoAllocateDepthBuffer?void 0:Z,Y.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(A,k){const Z=K.get(A);Z.__webglFramebuffer=k,Z.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(A,k=0,Z=0){ue=A,ee=k,J=Z;let Y=null,q=!1,de=!1;if(A){const Te=K.get(A);if(Te.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(j.FRAMEBUFFER,Te.__webglFramebuffer),be.copy(A.viewport),Re.copy(A.scissor),ht=A.scissorTest,w.viewport(be),w.scissor(Re),w.setScissorTest(ht),he=-1;return}else if(Te.__webglFramebuffer===void 0)te.setupRenderTarget(A);else if(Te.__hasExternalTextures)te.rebindTextures(A,K.get(A.texture).__webglTexture,K.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const ot=A.depthTexture;if(Te.__boundDepthTexture!==ot){if(ot!==null&&K.has(ot)&&(A.width!==ot.image.width||A.height!==ot.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");te.setupDepthRenderbuffer(A)}}const Pe=A.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(de=!0);const Le=K.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Le[k])?Y=Le[k][Z]:Y=Le[k],q=!0):A.samples>0&&te.useMultisampledRTT(A)===!1?Y=K.get(A).__webglMultisampledFramebuffer:Array.isArray(Le)?Y=Le[Z]:Y=Le,be.copy(A.viewport),Re.copy(A.scissor),ht=A.scissorTest}else be.copy(Ye).multiplyScalar(Me).floor(),Re.copy(qt).multiplyScalar(Me).floor(),ht=pt;if(Z!==0&&(Y=Q),w.bindFramebuffer(j.FRAMEBUFFER,Y)&&w.drawBuffers(A,Y),w.viewport(be),w.scissor(Re),w.setScissorTest(ht),q){const Te=K.get(A.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+k,Te.__webglTexture,Z)}else if(de){const Te=k;for(let Pe=0;Pe<A.textures.length;Pe++){const Le=K.get(A.textures[Pe]);j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0+Pe,Le.__webglTexture,Z,Te)}}else if(A!==null&&Z!==0){const Te=K.get(A.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Te.__webglTexture,Z)}he=-1},this.readRenderTargetPixels=function(A,k,Z,Y,q,de,We,Te=0){if(!(A&&A.isWebGLRenderTarget)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=K.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&We!==void 0&&(Pe=Pe[We]),Pe){w.bindFramebuffer(j.FRAMEBUFFER,Pe);try{const Le=A.textures[Te],ot=Le.format,ft=Le.type;if(A.textures.length>1&&j.readBuffer(j.COLOR_ATTACHMENT0+Te),!R.textureFormatReadable(ot)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(ft)){Ot("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=A.width-Y&&Z>=0&&Z<=A.height-q&&j.readPixels(k,Z,Y,q,Ie.convert(ot),Ie.convert(ft),de)}finally{const Le=ue!==null?K.get(ue).__webglFramebuffer:null;w.bindFramebuffer(j.FRAMEBUFFER,Le)}}},this.readRenderTargetPixelsAsync=async function(A,k,Z,Y,q,de,We,Te=0){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=K.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&We!==void 0&&(Pe=Pe[We]),Pe)if(k>=0&&k<=A.width-Y&&Z>=0&&Z<=A.height-q){w.bindFramebuffer(j.FRAMEBUFFER,Pe);const Le=A.textures[Te],ot=Le.format,ft=Le.type;if(A.textures.length>1&&j.readBuffer(j.COLOR_ATTACHMENT0+Te),!R.textureFormatReadable(ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qe=j.createBuffer();j.bindBuffer(j.PIXEL_PACK_BUFFER,qe),j.bufferData(j.PIXEL_PACK_BUFFER,de.byteLength,j.STREAM_READ),j.readPixels(k,Z,Y,q,Ie.convert(ot),Ie.convert(ft),0);const It=ue!==null?K.get(ue).__webglFramebuffer:null;w.bindFramebuffer(j.FRAMEBUFFER,It);const Qt=j.fenceSync(j.SYNC_GPU_COMMANDS_COMPLETE,0);return j.flush(),await oz(j,Qt,4),j.bindBuffer(j.PIXEL_PACK_BUFFER,qe),j.getBufferSubData(j.PIXEL_PACK_BUFFER,0,de),j.deleteBuffer(qe),j.deleteSync(Qt),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(A,k=null,Z=0){const Y=Math.pow(2,-Z),q=Math.floor(A.image.width*Y),de=Math.floor(A.image.height*Y),We=k!==null?k.x:0,Te=k!==null?k.y:0;te.setTexture2D(A,0),j.copyTexSubImage2D(j.TEXTURE_2D,Z,0,0,We,Te,q,de),w.unbindTexture()},this.copyTextureToTexture=function(A,k,Z=null,Y=null,q=0,de=0){let We,Te,Pe,Le,ot,ft,qe,It,Qt;const jt=A.isCompressedTexture?A.mipmaps[de]:A.image;if(Z!==null)We=Z.max.x-Z.min.x,Te=Z.max.y-Z.min.y,Pe=Z.isBox3?Z.max.z-Z.min.z:1,Le=Z.min.x,ot=Z.min.y,ft=Z.isBox3?Z.min.z:0;else{const Vt=Math.pow(2,-q);We=Math.floor(jt.width*Vt),Te=Math.floor(jt.height*Vt),A.isDataArrayTexture?Pe=jt.depth:A.isData3DTexture?Pe=Math.floor(jt.depth*Vt):Pe=1,Le=0,ot=0,ft=0}Y!==null?(qe=Y.x,It=Y.y,Qt=Y.z):(qe=0,It=0,Qt=0);const Ct=Ie.convert(k.format),ps=Ie.convert(k.type);let De;k.isData3DTexture?(te.setTexture3D(k,0),De=j.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(te.setTexture2DArray(k,0),De=j.TEXTURE_2D_ARRAY):(te.setTexture2D(k,0),De=j.TEXTURE_2D),w.activeTexture(j.TEXTURE0),w.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,k.flipY),w.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),w.pixelStorei(j.UNPACK_ALIGNMENT,k.unpackAlignment);const ns=w.getParameter(j.UNPACK_ROW_LENGTH),_t=w.getParameter(j.UNPACK_IMAGE_HEIGHT),cs=w.getParameter(j.UNPACK_SKIP_PIXELS),Ts=w.getParameter(j.UNPACK_SKIP_ROWS),cn=w.getParameter(j.UNPACK_SKIP_IMAGES);w.pixelStorei(j.UNPACK_ROW_LENGTH,jt.width),w.pixelStorei(j.UNPACK_IMAGE_HEIGHT,jt.height),w.pixelStorei(j.UNPACK_SKIP_PIXELS,Le),w.pixelStorei(j.UNPACK_SKIP_ROWS,ot),w.pixelStorei(j.UNPACK_SKIP_IMAGES,ft);const ii=A.isDataArrayTexture||A.isData3DTexture,Bt=k.isDataArrayTexture||k.isData3DTexture;if(A.isDepthTexture){const Vt=K.get(A),Gs=K.get(k),Lt=K.get(Vt.__renderTarget),zs=K.get(Gs.__renderTarget);w.bindFramebuffer(j.READ_FRAMEBUFFER,Lt.__webglFramebuffer),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,zs.__webglFramebuffer);for(let Rn=0;Rn<Pe;Rn++)ii&&(j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,K.get(A).__webglTexture,q,ft+Rn),j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,K.get(k).__webglTexture,de,Qt+Rn)),j.blitFramebuffer(Le,ot,We,Te,qe,It,We,Te,j.DEPTH_BUFFER_BIT,j.NEAREST);w.bindFramebuffer(j.READ_FRAMEBUFFER,null),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else if(q!==0||A.isRenderTargetTexture||K.has(A)){const Vt=K.get(A),Gs=K.get(k);w.bindFramebuffer(j.READ_FRAMEBUFFER,se),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,H);for(let Lt=0;Lt<Pe;Lt++)ii?j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Vt.__webglTexture,q,ft+Lt):j.framebufferTexture2D(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Vt.__webglTexture,q),Bt?j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Gs.__webglTexture,de,Qt+Lt):j.framebufferTexture2D(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Gs.__webglTexture,de),q!==0?j.blitFramebuffer(Le,ot,We,Te,qe,It,We,Te,j.COLOR_BUFFER_BIT,j.NEAREST):Bt?j.copyTexSubImage3D(De,de,qe,It,Qt+Lt,Le,ot,We,Te):j.copyTexSubImage2D(De,de,qe,It,Le,ot,We,Te);w.bindFramebuffer(j.READ_FRAMEBUFFER,null),w.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else Bt?A.isDataTexture||A.isData3DTexture?j.texSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,ps,jt.data):k.isCompressedArrayTexture?j.compressedTexSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,jt.data):j.texSubImage3D(De,de,qe,It,Qt,We,Te,Pe,Ct,ps,jt):A.isDataTexture?j.texSubImage2D(j.TEXTURE_2D,de,qe,It,We,Te,Ct,ps,jt.data):A.isCompressedTexture?j.compressedTexSubImage2D(j.TEXTURE_2D,de,qe,It,jt.width,jt.height,Ct,jt.data):j.texSubImage2D(j.TEXTURE_2D,de,qe,It,We,Te,Ct,ps,jt);w.pixelStorei(j.UNPACK_ROW_LENGTH,ns),w.pixelStorei(j.UNPACK_IMAGE_HEIGHT,_t),w.pixelStorei(j.UNPACK_SKIP_PIXELS,cs),w.pixelStorei(j.UNPACK_SKIP_ROWS,Ts),w.pixelStorei(j.UNPACK_SKIP_IMAGES,cn),de===0&&k.generateMipmaps&&j.generateMipmap(De),w.unbindTexture()},this.initRenderTarget=function(A){K.get(A).__webglFramebuffer===void 0&&te.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?te.setTextureCube(A,0):A.isData3DTexture?te.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?te.setTexture2DArray(A,0):te.setTexture2D(A,0),w.unbindTexture()},this.resetState=function(){ee=0,J=0,ue=null,w.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=xt._getDrawingBufferColorSpace(e),t.unpackColorSpace=xt._getUnpackColorSpace()}}function zm(n){const e=new Map(n.map(M=>[M.id,M])),t=new Map,s=(M,_)=>{const m=t.get(M.id);if(m!==void 0)return m;if(_.has(M.id)||M.parentIds.length===0)return t.set(M.id,0),0;_.add(M.id);let f=0;for(const S of M.parentIds){const v=e.get(S);v&&(f=Math.max(f,s(v,_)+1))}return t.set(M.id,f),f};for(const M of n)s(M,new Set);const i=new Map,r=[],a=(M,_)=>M.id.localeCompare(_.id,void 0,{numeric:!0});for(const M of n){const _=M.parentIds.find(f=>e.has(f));if(_===void 0){r.push(M);continue}const m=i.get(_)??[];m.push(M),i.set(_,m)}r.sort(a);for(const M of i.values())M.sort(a);const o=new Map;let l=0;const c=new Set,d=M=>{c.add(M.id);const _=(i.get(M.id)??[]).filter(v=>!c.has(v.id));if(_.length===0){const v=l++;return o.set(M.id,v),[v,v]}let m=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(const v of _){const[z,O]=d(v);m=Math.min(m,z),f=Math.max(f,O)}const S=(m+f)/2;return o.set(M.id,S),[m,f]};for(const M of r)d(M);for(const M of n)o.has(M.id)||d(M);const h=Math.max(...Array.from(t.values()),0)+1,u=Math.max(l-1,0);return{placements:n.map(M=>({id:M.id,x:o.get(M.id)??0,tier:t.get(M.id)??0})),width:u,tierCount:h}}function Xh(n,e,t){var s,i=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function r(){var a,o=s.length,l,c=0,d=0,h=0;for(a=0;a<o;++a)l=s[a],c+=l.x||0,d+=l.y||0,h+=l.z||0;for(c=(c/o-n)*i,d=(d/o-e)*i,h=(h/o-t)*i,a=0;a<o;++a)l=s[a],c&&(l.x-=c),d&&(l.y-=d),h&&(l.z-=h)}return r.initialize=function(a){s=a},r.x=function(a){return arguments.length?(n=+a,r):n},r.y=function(a){return arguments.length?(e=+a,r):e},r.z=function(a){return arguments.length?(t=+a,r):t},r.strength=function(a){return arguments.length?(i=+a,r):i},r}function Yv(n){const e=+this._x.call(null,n);return _m(this.cover(e),e,n)}function _m(n,e,t){if(isNaN(e))return n;var s,i=n._root,r={data:t},a=n._x0,o=n._x1,l,c,d,h,u;if(!i)return n._root=r,n;for(;i.length;)if((d=e>=(l=(a+o)/2))?a=l:o=l,s=i,!(i=i[h=+d]))return s[h]=r,n;if(c=+n._x.call(null,i.data),e===c)return r.next=i,s?s[h]=r:n._root=r,n;do s=s?s[h]=new Array(2):n._root=new Array(2),(d=e>=(l=(a+o)/2))?a=l:o=l;while((h=+d)==(u=+(c>=l)));return s[u]=i,s[h]=r,n}function Kv(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);let s=1/0,i=-1/0;for(let r=0,a;r<e;++r)isNaN(a=+this._x.call(null,n[r]))||(t[r]=a,a<s&&(s=a),a>i&&(i=a));if(s>i)return this;this.cover(s).cover(i);for(let r=0;r<e;++r)_m(this,t[r],n[r]);return this}function Zv(n){if(isNaN(n=+n))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(n))+1;else{for(var s=t-e||1,i=this._root,r,a;e>n||n>=t;)switch(a=+(n<e),r=new Array(2),r[a]=i,i=r,s*=2,a){case 0:t=e+s;break;case 1:e=t-s;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=t,this}function Qv(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function Jv(n){return arguments.length?this.cover(+n[0][0]).cover(+n[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function Qn(n,e,t){this.node=n,this.x0=e,this.x1=t}function eO(n,e){var t,s=this._x0,i,r,a=this._x1,o=[],l=this._root,c,d;for(l&&o.push(new Qn(l,s,a)),e==null?e=1/0:(s=n-e,a=n+e);c=o.pop();)if(!(!(l=c.node)||(i=c.x0)>a||(r=c.x1)<s))if(l.length){var h=(i+r)/2;o.push(new Qn(l[1],h,r),new Qn(l[0],i,h)),(d=+(n>=h))&&(c=o[o.length-1],o[o.length-1]=o[o.length-1-d],o[o.length-1-d]=c)}else{var u=Math.abs(n-+this._x.call(null,l.data));u<e&&(e=u,s=n-u,a=n+u,t=l.data)}return t}function tO(n){if(isNaN(l=+this._x.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._x1,l,c,d,h,u;if(!t)return this;if(t.length)for(;;){if((d=l>=(c=(a+o)/2))?a=c:o=c,e=t,!(t=t[h=+d]))return this;if(!t.length)break;e[h+1&1]&&(s=e,u=h)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[h]=r:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(s?s[u]=t:this._root=t),this):(this._root=r,this)}function sO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function nO(){return this._root}function iO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function rO(n){var e=[],t,s=this._root,i,r,a;for(s&&e.push(new Qn(s,this._x0,this._x1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.x1)&&s.length){var o=(r+a)/2;(i=s[1])&&e.push(new Qn(i,o,a)),(i=s[0])&&e.push(new Qn(i,r,o))}return this}function aO(n){var e=[],t=[],s;for(this._root&&e.push(new Qn(this._root,this._x0,this._x1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.x1,l=(a+o)/2;(r=i[0])&&e.push(new Qn(r,a,l)),(r=i[1])&&e.push(new Qn(r,l,o))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.x1);return this}function oO(n){return n[0]}function lO(n){return arguments.length?(this._x=n,this):this._x}function du(n,e){var t=new uu(e??oO,NaN,NaN);return n==null?t:t.addAll(n)}function uu(n,e,t){this._x=n,this._x0=e,this._x1=t,this._root=void 0}function Yh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Fs=du.prototype=uu.prototype;Fs.copy=function(){var n=new uu(this._x,this._x0,this._x1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Yh(e),n;for(t=[{source:e,target:n._root=new Array(2)}];e=t.pop();)for(var i=0;i<2;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(2)}):e.target[i]=Yh(s));return n};Fs.add=Yv;Fs.addAll=Kv;Fs.cover=Zv;Fs.data=Qv;Fs.extent=Jv;Fs.find=eO;Fs.remove=tO;Fs.removeAll=sO;Fs.root=nO;Fs.size=iO;Fs.visit=rO;Fs.visitAfter=aO;Fs.x=lO;function cO(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return wm(this.cover(e,t),e,t,n)}function wm(n,e,t,s){if(isNaN(e)||isNaN(t))return n;var i,r=n._root,a={data:s},o=n._x0,l=n._y0,c=n._x1,d=n._y1,h,u,p,M,_,m,f,S;if(!r)return n._root=a,n;for(;r.length;)if((_=e>=(h=(o+c)/2))?o=h:c=h,(m=t>=(u=(l+d)/2))?l=u:d=u,i=r,!(r=r[f=m<<1|_]))return i[f]=a,n;if(p=+n._x.call(null,r.data),M=+n._y.call(null,r.data),e===p&&t===M)return a.next=r,i?i[f]=a:n._root=a,n;do i=i?i[f]=new Array(4):n._root=new Array(4),(_=e>=(h=(o+c)/2))?o=h:c=h,(m=t>=(u=(l+d)/2))?l=u:d=u;while((f=m<<1|_)===(S=(M>=u)<<1|p>=h));return i[S]=r,i[f]=a,n}function dO(n){var e,t,s=n.length,i,r,a=new Array(s),o=new Array(s),l=1/0,c=1/0,d=-1/0,h=-1/0;for(t=0;t<s;++t)isNaN(i=+this._x.call(null,e=n[t]))||isNaN(r=+this._y.call(null,e))||(a[t]=i,o[t]=r,i<l&&(l=i),i>d&&(d=i),r<c&&(c=r),r>h&&(h=r));if(l>d||c>h)return this;for(this.cover(l,c).cover(d,h),t=0;t<s;++t)wm(this,a[t],o[t],n[t]);return this}function uO(n,e){if(isNaN(n=+n)||isNaN(e=+e))return this;var t=this._x0,s=this._y0,i=this._x1,r=this._y1;if(isNaN(t))i=(t=Math.floor(n))+1,r=(s=Math.floor(e))+1;else{for(var a=i-t||1,o=this._root,l,c;t>n||n>=i||s>e||e>=r;)switch(c=(e<s)<<1|n<t,l=new Array(4),l[c]=o,o=l,a*=2,c){case 0:i=t+a,r=s+a;break;case 1:t=i-a,r=s+a;break;case 2:i=t+a,s=r-a;break;case 3:t=i-a,s=r-a;break}this._root&&this._root.length&&(this._root=o)}return this._x0=t,this._y0=s,this._x1=i,this._y1=r,this}function hO(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function fO(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Cs(n,e,t,s,i){this.node=n,this.x0=e,this.y0=t,this.x1=s,this.y1=i}function pO(n,e,t){var s,i=this._x0,r=this._y0,a,o,l,c,d=this._x1,h=this._y1,u=[],p=this._root,M,_;for(p&&u.push(new Cs(p,i,r,d,h)),t==null?t=1/0:(i=n-t,r=e-t,d=n+t,h=e+t,t*=t);M=u.pop();)if(!(!(p=M.node)||(a=M.x0)>d||(o=M.y0)>h||(l=M.x1)<i||(c=M.y1)<r))if(p.length){var m=(a+l)/2,f=(o+c)/2;u.push(new Cs(p[3],m,f,l,c),new Cs(p[2],a,f,m,c),new Cs(p[1],m,o,l,f),new Cs(p[0],a,o,m,f)),(_=(e>=f)<<1|n>=m)&&(M=u[u.length-1],u[u.length-1]=u[u.length-1-_],u[u.length-1-_]=M)}else{var S=n-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),z=S*S+v*v;if(z<t){var O=Math.sqrt(t=z);i=n-O,r=e-O,d=n+O,h=e+O,s=p.data}}return s}function mO(n){if(isNaN(d=+this._x.call(null,n))||isNaN(h=+this._y.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._y0,l=this._x1,c=this._y1,d,h,u,p,M,_,m,f;if(!t)return this;if(t.length)for(;;){if((M=d>=(u=(a+l)/2))?a=u:l=u,(_=h>=(p=(o+c)/2))?o=p:c=p,e=t,!(t=t[m=_<<1|M]))return this;if(!t.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(s=e,f=m)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[m]=r:delete e[m],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(s?s[f]=t:this._root=t),this):(this._root=r,this)}function MO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function gO(){return this._root}function bO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function zO(n){var e=[],t,s=this._root,i,r,a,o,l;for(s&&e.push(new Cs(s,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.y0,o=t.x1,l=t.y1)&&s.length){var c=(r+o)/2,d=(a+l)/2;(i=s[3])&&e.push(new Cs(i,c,d,o,l)),(i=s[2])&&e.push(new Cs(i,r,d,c,l)),(i=s[1])&&e.push(new Cs(i,c,a,o,d)),(i=s[0])&&e.push(new Cs(i,r,a,c,d))}return this}function _O(n){var e=[],t=[],s;for(this._root&&e.push(new Cs(this._root,this._x0,this._y0,this._x1,this._y1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.y0,l=s.x1,c=s.y1,d=(a+l)/2,h=(o+c)/2;(r=i[0])&&e.push(new Cs(r,a,o,d,h)),(r=i[1])&&e.push(new Cs(r,d,o,l,h)),(r=i[2])&&e.push(new Cs(r,a,h,d,c)),(r=i[3])&&e.push(new Cs(r,d,h,l,c))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.y0,s.x1,s.y1);return this}function wO(n){return n[0]}function yO(n){return arguments.length?(this._x=n,this):this._x}function vO(n){return n[1]}function OO(n){return arguments.length?(this._y=n,this):this._y}function hu(n,e,t){var s=new fu(e??wO,t??vO,NaN,NaN,NaN,NaN);return n==null?s:s.addAll(n)}function fu(n,e,t,s,i,r){this._x=n,this._y=e,this._x0=t,this._y0=s,this._x1=i,this._y1=r,this._root=void 0}function Kh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Ps=hu.prototype=fu.prototype;Ps.copy=function(){var n=new fu(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Kh(e),n;for(t=[{source:e,target:n._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(4)}):e.target[i]=Kh(s));return n};Ps.add=cO;Ps.addAll=dO;Ps.cover=uO;Ps.data=hO;Ps.extent=fO;Ps.find=pO;Ps.remove=mO;Ps.removeAll=MO;Ps.root=gO;Ps.size=bO;Ps.visit=zO;Ps.visitAfter=_O;Ps.x=yO;Ps.y=OO;function xO(n){const e=+this._x.call(null,n),t=+this._y.call(null,n),s=+this._z.call(null,n);return ym(this.cover(e,t,s),e,t,s,n)}function ym(n,e,t,s,i){if(isNaN(e)||isNaN(t)||isNaN(s))return n;var r,a=n._root,o={data:i},l=n._x0,c=n._y0,d=n._z0,h=n._x1,u=n._y1,p=n._z1,M,_,m,f,S,v,z,O,x,G,b;if(!a)return n._root=o,n;for(;a.length;)if((z=e>=(M=(l+h)/2))?l=M:h=M,(O=t>=(_=(c+u)/2))?c=_:u=_,(x=s>=(m=(d+p)/2))?d=m:p=m,r=a,!(a=a[G=x<<2|O<<1|z]))return r[G]=o,n;if(f=+n._x.call(null,a.data),S=+n._y.call(null,a.data),v=+n._z.call(null,a.data),e===f&&t===S&&s===v)return o.next=a,r?r[G]=o:n._root=o,n;do r=r?r[G]=new Array(8):n._root=new Array(8),(z=e>=(M=(l+h)/2))?l=M:h=M,(O=t>=(_=(c+u)/2))?c=_:u=_,(x=s>=(m=(d+p)/2))?d=m:p=m;while((G=x<<2|O<<1|z)===(b=(v>=m)<<2|(S>=_)<<1|f>=M));return r[b]=a,r[G]=o,n}function SO(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),s=new Float64Array(e),i=new Float64Array(e);let r=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,d=-1/0;for(let h=0,u,p,M,_;h<e;++h)isNaN(p=+this._x.call(null,u=n[h]))||isNaN(M=+this._y.call(null,u))||isNaN(_=+this._z.call(null,u))||(t[h]=p,s[h]=M,i[h]=_,p<r&&(r=p),p>l&&(l=p),M<a&&(a=M),M>c&&(c=M),_<o&&(o=_),_>d&&(d=_));if(r>l||a>c||o>d)return this;this.cover(r,a,o).cover(l,c,d);for(let h=0;h<e;++h)ym(this,t[h],s[h],i[h],n[h]);return this}function AO(n,e,t){if(isNaN(n=+n)||isNaN(e=+e)||isNaN(t=+t))return this;var s=this._x0,i=this._y0,r=this._z0,a=this._x1,o=this._y1,l=this._z1;if(isNaN(s))a=(s=Math.floor(n))+1,o=(i=Math.floor(e))+1,l=(r=Math.floor(t))+1;else{for(var c=a-s||1,d=this._root,h,u;s>n||n>=a||i>e||e>=o||r>t||t>=l;)switch(u=(t<r)<<2|(e<i)<<1|n<s,h=new Array(8),h[u]=d,d=h,c*=2,u){case 0:a=s+c,o=i+c,l=r+c;break;case 1:s=a-c,o=i+c,l=r+c;break;case 2:a=s+c,i=o-c,l=r+c;break;case 3:s=a-c,i=o-c,l=r+c;break;case 4:a=s+c,o=i+c,r=l-c;break;case 5:s=a-c,o=i+c,r=l-c;break;case 6:a=s+c,i=o-c,r=l-c;break;case 7:s=a-c,i=o-c,r=l-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=s,this._y0=i,this._z0=r,this._x1=a,this._y1=o,this._z1=l,this}function EO(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function DO(n){return arguments.length?this.cover(+n[0][0],+n[0][1],+n[0][2]).cover(+n[1][0],+n[1][1],+n[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function $t(n,e,t,s,i,r,a){this.node=n,this.x0=e,this.y0=t,this.z0=s,this.x1=i,this.y1=r,this.z1=a}function IO(n,e,t,s){var i,r=this._x0,a=this._y0,o=this._z0,l,c,d,h,u,p,M=this._x1,_=this._y1,m=this._z1,f=[],S=this._root,v,z;for(S&&f.push(new $t(S,r,a,o,M,_,m)),s==null?s=1/0:(r=n-s,a=e-s,o=t-s,M=n+s,_=e+s,m=t+s,s*=s);v=f.pop();)if(!(!(S=v.node)||(l=v.x0)>M||(c=v.y0)>_||(d=v.z0)>m||(h=v.x1)<r||(u=v.y1)<a||(p=v.z1)<o))if(S.length){var O=(l+h)/2,x=(c+u)/2,G=(d+p)/2;f.push(new $t(S[7],O,x,G,h,u,p),new $t(S[6],l,x,G,O,u,p),new $t(S[5],O,c,G,h,x,p),new $t(S[4],l,c,G,O,x,p),new $t(S[3],O,x,d,h,u,G),new $t(S[2],l,x,d,O,u,G),new $t(S[1],O,c,d,h,x,G),new $t(S[0],l,c,d,O,x,G)),(z=(t>=G)<<2|(e>=x)<<1|n>=O)&&(v=f[f.length-1],f[f.length-1]=f[f.length-1-z],f[f.length-1-z]=v)}else{var b=n-+this._x.call(null,S.data),T=e-+this._y.call(null,S.data),N=t-+this._z.call(null,S.data),C=b*b+T*T+N*N;if(C<s){var W=Math.sqrt(s=C);r=n-W,a=e-W,o=t-W,M=n+W,_=e+W,m=t+W,i=S.data}}return i}const TO=(n,e,t,s,i,r)=>Math.sqrt((n-s)**2+(e-i)**2+(t-r)**2);function GO(n,e,t,s){const i=[],r=n-s,a=e-s,o=t-s,l=n+s,c=e+s,d=t+s;return this.visit((h,u,p,M,_,m,f)=>{if(!h.length)do{const S=h.data;TO(n,e,t,this._x(S),this._y(S),this._z(S))<=s&&i.push(S)}while(h=h.next);return u>l||p>c||M>d||_<r||m<a||f<o}),i}function RO(n){if(isNaN(u=+this._x.call(null,n))||isNaN(p=+this._y.call(null,n))||isNaN(M=+this._z.call(null,n)))return this;var e,t=this._root,s,i,r,a=this._x0,o=this._y0,l=this._z0,c=this._x1,d=this._y1,h=this._z1,u,p,M,_,m,f,S,v,z,O,x;if(!t)return this;if(t.length)for(;;){if((S=u>=(_=(a+c)/2))?a=_:c=_,(v=p>=(m=(o+d)/2))?o=m:d=m,(z=M>=(f=(l+h)/2))?l=f:h=f,e=t,!(t=t[O=z<<2|v<<1|S]))return this;if(!t.length)break;(e[O+1&7]||e[O+2&7]||e[O+3&7]||e[O+4&7]||e[O+5&7]||e[O+6&7]||e[O+7&7])&&(s=e,x=O)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,i?(r?i.next=r:delete i.next,this):e?(r?e[O]=r:delete e[O],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(s?s[x]=t:this._root=t),this):(this._root=r,this)}function BO(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function NO(){return this._root}function CO(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function PO(n){var e=[],t,s=this._root,i,r,a,o,l,c,d;for(s&&e.push(new $t(s,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!n(s=t.node,r=t.x0,a=t.y0,o=t.z0,l=t.x1,c=t.y1,d=t.z1)&&s.length){var h=(r+l)/2,u=(a+c)/2,p=(o+d)/2;(i=s[7])&&e.push(new $t(i,h,u,p,l,c,d)),(i=s[6])&&e.push(new $t(i,r,u,p,h,c,d)),(i=s[5])&&e.push(new $t(i,h,a,p,l,u,d)),(i=s[4])&&e.push(new $t(i,r,a,p,h,u,d)),(i=s[3])&&e.push(new $t(i,h,u,o,l,c,p)),(i=s[2])&&e.push(new $t(i,r,u,o,h,c,p)),(i=s[1])&&e.push(new $t(i,h,a,o,l,u,p)),(i=s[0])&&e.push(new $t(i,r,a,o,h,u,p))}return this}function WO(n){var e=[],t=[],s;for(this._root&&e.push(new $t(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));s=e.pop();){var i=s.node;if(i.length){var r,a=s.x0,o=s.y0,l=s.z0,c=s.x1,d=s.y1,h=s.z1,u=(a+c)/2,p=(o+d)/2,M=(l+h)/2;(r=i[0])&&e.push(new $t(r,a,o,l,u,p,M)),(r=i[1])&&e.push(new $t(r,u,o,l,c,p,M)),(r=i[2])&&e.push(new $t(r,a,p,l,u,d,M)),(r=i[3])&&e.push(new $t(r,u,p,l,c,d,M)),(r=i[4])&&e.push(new $t(r,a,o,M,u,p,h)),(r=i[5])&&e.push(new $t(r,u,o,M,c,p,h)),(r=i[6])&&e.push(new $t(r,a,p,M,u,d,h)),(r=i[7])&&e.push(new $t(r,u,p,M,c,d,h))}t.push(s)}for(;s=t.pop();)n(s.node,s.x0,s.y0,s.z0,s.x1,s.y1,s.z1);return this}function LO(n){return n[0]}function kO(n){return arguments.length?(this._x=n,this):this._x}function UO(n){return n[1]}function FO(n){return arguments.length?(this._y=n,this):this._y}function jO(n){return n[2]}function VO(n){return arguments.length?(this._z=n,this):this._z}function pu(n,e,t,s){var i=new mu(e??LO,t??UO,s??jO,NaN,NaN,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function mu(n,e,t,s,i,r,a,o,l){this._x=n,this._y=e,this._z=t,this._x0=s,this._y0=i,this._z0=r,this._x1=a,this._y1=o,this._z1=l,this._root=void 0}function Zh(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var ys=pu.prototype=mu.prototype;ys.copy=function(){var n=new mu(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,s;if(!e)return n;if(!e.length)return n._root=Zh(e),n;for(t=[{source:e,target:n._root=new Array(8)}];e=t.pop();)for(var i=0;i<8;++i)(s=e.source[i])&&(s.length?t.push({source:s,target:e.target[i]=new Array(8)}):e.target[i]=Zh(s));return n};ys.add=xO;ys.addAll=SO;ys.cover=AO;ys.data=EO;ys.extent=DO;ys.find=IO;ys.findAllWithinRadius=GO;ys.remove=RO;ys.removeAll=BO;ys.root=NO;ys.size=CO;ys.visit=PO;ys.visitAfter=WO;ys.x=kO;ys.y=FO;ys.z=VO;function ds(n){return function(){return n}}function sn(n){return(n()-.5)*1e-6}function uc(n){return n.x+n.vx}function Qh(n){return n.y+n.vy}function $O(n){return n.z+n.vz}function vm(n){var e,t,s,i,r=1,a=1;typeof n!="function"&&(n=ds(n==null?1:+n));function o(){for(var d,h=e.length,u,p,M,_,m,f,S,v=0;v<a;++v)for(u=(t===1?du(e,uc):t===2?hu(e,uc,Qh):t===3?pu(e,uc,Qh,$O):null).visitAfter(l),d=0;d<h;++d)p=e[d],f=s[p.index],S=f*f,M=p.x+p.vx,t>1&&(_=p.y+p.vy),t>2&&(m=p.z+p.vz),u.visit(z);function z(O,x,G,b,T,N,C){var W=[x,G,b,T,N,C],Q=W[0],se=W[1],H=W[2],ee=W[t],J=W[t+1],ue=W[t+2],he=O.data,Se=O.r,be=f+Se;if(he){if(he.index>p.index){var Re=M-he.x-he.vx,ht=t>1?_-he.y-he.vy:0,ct=t>2?m-he.z-he.vz:0,tt=Re*Re+ht*ht+ct*ct;tt<be*be&&(Re===0&&(Re=sn(i),tt+=Re*Re),t>1&&ht===0&&(ht=sn(i),tt+=ht*ht),t>2&&ct===0&&(ct=sn(i),tt+=ct*ct),tt=(be-(tt=Math.sqrt(tt)))/tt*r,p.vx+=(Re*=tt)*(be=(Se*=Se)/(S+Se)),t>1&&(p.vy+=(ht*=tt)*be),t>2&&(p.vz+=(ct*=tt)*be),he.vx-=Re*(be=1-be),t>1&&(he.vy-=ht*be),t>2&&(he.vz-=ct*be))}return}return Q>M+be||ee<M-be||t>1&&(se>_+be||J<_-be)||t>2&&(H>m+be||ue<m-be)}}function l(d){if(d.data)return d.r=s[d.data.index];for(var h=d.r=0;h<Math.pow(2,t);++h)d[h]&&d[h].r>d.r&&(d.r=d[h].r)}function c(){if(e){var d,h=e.length,u;for(s=new Array(h),d=0;d<h;++d)u=e[d],s[u.index]=+n(u,d,e)}}return o.initialize=function(d,...h){e=d,i=h.find(u=>typeof u=="function")||Math.random,t=h.find(u=>[1,2,3].includes(u))||2,c()},o.iterations=function(d){return arguments.length?(a=+d,o):a},o.strength=function(d){return arguments.length?(r=+d,o):r},o.radius=function(d){return arguments.length?(n=typeof d=="function"?d:ds(+d),c(),o):n},o}function HO(n){return n.index}function Jh(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function Om(n){var e=HO,t=u,s,i=ds(30),r,a,o,l,c,d,h=1;n==null&&(n=[]);function u(f){return 1/Math.min(l[f.source.index],l[f.target.index])}function p(f){for(var S=0,v=n.length;S<h;++S)for(var z=0,O,x,G,b=0,T=0,N=0,C,W;z<v;++z)O=n[z],x=O.source,G=O.target,b=G.x+G.vx-x.x-x.vx||sn(d),o>1&&(T=G.y+G.vy-x.y-x.vy||sn(d)),o>2&&(N=G.z+G.vz-x.z-x.vz||sn(d)),C=Math.sqrt(b*b+T*T+N*N),C=(C-r[z])/C*f*s[z],b*=C,T*=C,N*=C,G.vx-=b*(W=c[z]),o>1&&(G.vy-=T*W),o>2&&(G.vz-=N*W),x.vx+=b*(W=1-W),o>1&&(x.vy+=T*W),o>2&&(x.vz+=N*W)}function M(){if(a){var f,S=a.length,v=n.length,z=new Map(a.map((x,G)=>[e(x,G,a),x])),O;for(f=0,l=new Array(S);f<v;++f)O=n[f],O.index=f,typeof O.source!="object"&&(O.source=Jh(z,O.source)),typeof O.target!="object"&&(O.target=Jh(z,O.target)),l[O.source.index]=(l[O.source.index]||0)+1,l[O.target.index]=(l[O.target.index]||0)+1;for(f=0,c=new Array(v);f<v;++f)O=n[f],c[f]=l[O.source.index]/(l[O.source.index]+l[O.target.index]);s=new Array(v),_(),r=new Array(v),m()}}function _(){if(a)for(var f=0,S=n.length;f<S;++f)s[f]=+t(n[f],f,n)}function m(){if(a)for(var f=0,S=n.length;f<S;++f)r[f]=+i(n[f],f,n)}return p.initialize=function(f,...S){a=f,d=S.find(v=>typeof v=="function")||Math.random,o=S.find(v=>[1,2,3].includes(v))||2,M()},p.links=function(f){return arguments.length?(n=f,M(),p):n},p.id=function(f){return arguments.length?(e=f,p):e},p.iterations=function(f){return arguments.length?(h=+f,p):h},p.strength=function(f){return arguments.length?(t=typeof f=="function"?f:ds(+f),_(),p):t},p.distance=function(f){return arguments.length?(i=typeof f=="function"?f:ds(+f),m(),p):i},p}var qO={value:()=>{}};function xm(){for(var n=0,e=arguments.length,t={},s;n<e;++n){if(!(s=arguments[n]+"")||s in t||/[\s.]/.test(s))throw new Error("illegal type: "+s);t[s]=[]}return new Go(t)}function Go(n){this._=n}function XO(n,e){return n.trim().split(/^|\s+/).map(function(t){var s="",i=t.indexOf(".");if(i>=0&&(s=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:s}})}Go.prototype=xm.prototype={constructor:Go,on:function(n,e){var t=this._,s=XO(n+"",t),i,r=-1,a=s.length;if(arguments.length<2){for(;++r<a;)if((i=(n=s[r]).type)&&(i=YO(t[i],n.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<a;)if(i=(n=s[r]).type)t[i]=ef(t[i],n.name,e);else if(e==null)for(i in t)t[i]=ef(t[i],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new Go(n)},call:function(n,e){if((i=arguments.length-2)>0)for(var t=new Array(i),s=0,i,r;s<i;++s)t[s]=arguments[s+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(r=this._[n],s=0,i=r.length;s<i;++s)r[s].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)}};function YO(n,e){for(var t=0,s=n.length,i;t<s;++t)if((i=n[t]).name===e)return i.value}function ef(n,e,t){for(var s=0,i=n.length;s<i;++s)if(n[s].name===e){n[s]=qO,n=n.slice(0,s).concat(n.slice(s+1));break}return t!=null&&n.push({name:e,value:t}),n}var kr=0,ga=0,la=0,Sm=1e3,rl,ba,al=0,Ki=0,zl=0,Ea=typeof performance=="object"&&performance.now?performance:Date,Am=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Em(){return Ki||(Am(KO),Ki=Ea.now()+zl)}function KO(){Ki=0}function Bd(){this._call=this._time=this._next=null}Bd.prototype=Dm.prototype={constructor:Bd,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Em():+t)+(e==null?0:+e),!this._next&&ba!==this&&(ba?ba._next=this:rl=this,ba=this),this._call=n,this._time=t,Nd()},stop:function(){this._call&&(this._call=null,this._time=1/0,Nd())}};function Dm(n,e,t){var s=new Bd;return s.restart(n,e,t),s}function ZO(){Em(),++kr;for(var n=rl,e;n;)(e=Ki-n._time)>=0&&n._call.call(void 0,e),n=n._next;--kr}function tf(){Ki=(al=Ea.now())+zl,kr=ga=0;try{ZO()}finally{kr=0,JO(),Ki=0}}function QO(){var n=Ea.now(),e=n-al;e>Sm&&(zl-=e,al=n)}function JO(){for(var n,e=rl,t,s=1/0;e;)e._call?(s>e._time&&(s=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:rl=t);ba=n,Nd(s)}function Nd(n){if(!kr){ga&&(ga=clearTimeout(ga));var e=n-Ki;e>24?(n<1/0&&(ga=setTimeout(tf,n-Ea.now()-zl)),la&&(la=clearInterval(la))):(la||(al=Ea.now(),la=setInterval(QO,Sm)),kr=1,Am(tf))}}const ex=1664525,tx=1013904223,sf=4294967296;function sx(){let n=1;return()=>(n=(ex*n+tx)%sf)/sf}var nf=3;function hc(n){return n.x}function rf(n){return n.y}function nx(n){return n.z}var ix=10,rx=Math.PI*(3-Math.sqrt(5)),ax=Math.PI*20/(9+Math.sqrt(221));function Im(n,e){e=e||2;var t=Math.min(nf,Math.max(1,Math.round(e))),s,i=1,r=.001,a=1-Math.pow(r,1/300),o=0,l=.6,c=new Map,d=Dm(p),h=xm("tick","end"),u=sx();n==null&&(n=[]);function p(){M(),h.call("tick",s),i<r&&(d.stop(),h.call("end",s))}function M(f){var S,v=n.length,z;f===void 0&&(f=1);for(var O=0;O<f;++O)for(i+=(o-i)*a,c.forEach(function(x){x(i)}),S=0;S<v;++S)z=n[S],z.fx==null?z.x+=z.vx*=l:(z.x=z.fx,z.vx=0),t>1&&(z.fy==null?z.y+=z.vy*=l:(z.y=z.fy,z.vy=0)),t>2&&(z.fz==null?z.z+=z.vz*=l:(z.z=z.fz,z.vz=0));return s}function _(){for(var f=0,S=n.length,v;f<S;++f){if(v=n[f],v.index=f,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),v.fz!=null&&(v.z=v.fz),isNaN(v.x)||t>1&&isNaN(v.y)||t>2&&isNaN(v.z)){var z=ix*(t>2?Math.cbrt(.5+f):t>1?Math.sqrt(.5+f):f),O=f*rx,x=f*ax;t===1?v.x=z:t===2?(v.x=z*Math.cos(O),v.y=z*Math.sin(O)):(v.x=z*Math.sin(O)*Math.cos(x),v.y=z*Math.cos(O),v.z=z*Math.sin(O)*Math.sin(x))}(isNaN(v.vx)||t>1&&isNaN(v.vy)||t>2&&isNaN(v.vz))&&(v.vx=0,t>1&&(v.vy=0),t>2&&(v.vz=0))}}function m(f){return f.initialize&&f.initialize(n,u,t),f}return _(),s={tick:M,restart:function(){return d.restart(p),s},stop:function(){return d.stop(),s},numDimensions:function(f){return arguments.length?(t=Math.min(nf,Math.max(1,Math.round(f))),c.forEach(m),s):t},nodes:function(f){return arguments.length?(n=f,_(),c.forEach(m),s):n},alpha:function(f){return arguments.length?(i=+f,s):i},alphaMin:function(f){return arguments.length?(r=+f,s):r},alphaDecay:function(f){return arguments.length?(a=+f,s):+a},alphaTarget:function(f){return arguments.length?(o=+f,s):o},velocityDecay:function(f){return arguments.length?(l=1-f,s):1-l},randomSource:function(f){return arguments.length?(u=f,c.forEach(m),s):u},force:function(f,S){return arguments.length>1?(S==null?c.delete(f):c.set(f,m(S)),s):c.get(f)},find:function(){var f=Array.prototype.slice.call(arguments),S=f.shift()||0,v=(t>1?f.shift():null)||0,z=(t>2?f.shift():null)||0,O=f.shift()||1/0,x=0,G=n.length,b,T,N,C,W,Q;for(O*=O,x=0;x<G;++x)W=n[x],b=S-W.x,T=v-(W.y||0),N=z-(W.z||0),C=b*b+T*T+N*N,C<O&&(Q=W,O=C);return Q},on:function(f,S){return arguments.length>1?(h.on(f,S),s):h.on(f)}}}function Tm(){var n,e,t,s,i,r=ds(-30),a,o=1,l=1/0,c=.81;function d(M){var _,m=n.length,f=(e===1?du(n,hc):e===2?hu(n,hc,rf):e===3?pu(n,hc,rf,nx):null).visitAfter(u);for(i=M,_=0;_<m;++_)t=n[_],f.visit(p)}function h(){if(n){var M,_=n.length,m;for(a=new Array(_),M=0;M<_;++M)m=n[M],a[m.index]=+r(m,M,n)}}function u(M){var _=0,m,f,S=0,v,z,O,x,G=M.length;if(G){for(v=z=O=x=0;x<G;++x)(m=M[x])&&(f=Math.abs(m.value))&&(_+=m.value,S+=f,v+=f*(m.x||0),z+=f*(m.y||0),O+=f*(m.z||0));_*=Math.sqrt(4/G),M.x=v/S,e>1&&(M.y=z/S),e>2&&(M.z=O/S)}else{m=M,m.x=m.data.x,e>1&&(m.y=m.data.y),e>2&&(m.z=m.data.z);do _+=a[m.data.index];while(m=m.next)}M.value=_}function p(M,_,m,f,S){if(!M.value)return!0;var v=[m,f,S][e-1],z=M.x-t.x,O=e>1?M.y-t.y:0,x=e>2?M.z-t.z:0,G=v-_,b=z*z+O*O+x*x;if(G*G/c<b)return b<l&&(z===0&&(z=sn(s),b+=z*z),e>1&&O===0&&(O=sn(s),b+=O*O),e>2&&x===0&&(x=sn(s),b+=x*x),b<o&&(b=Math.sqrt(o*b)),t.vx+=z*M.value*i/b,e>1&&(t.vy+=O*M.value*i/b),e>2&&(t.vz+=x*M.value*i/b)),!0;if(M.length||b>=l)return;(M.data!==t||M.next)&&(z===0&&(z=sn(s),b+=z*z),e>1&&O===0&&(O=sn(s),b+=O*O),e>2&&x===0&&(x=sn(s),b+=x*x),b<o&&(b=Math.sqrt(o*b)));do M.data!==t&&(G=a[M.data.index]*i/b,t.vx+=z*G,e>1&&(t.vy+=O*G),e>2&&(t.vz+=x*G));while(M=M.next)}return d.initialize=function(M,..._){n=M,s=_.find(m=>typeof m=="function")||Math.random,e=_.find(m=>[1,2,3].includes(m))||2,h()},d.strength=function(M){return arguments.length?(r=typeof M=="function"?M:ds(+M),h(),d):r},d.distanceMin=function(M){return arguments.length?(o=M*M,d):Math.sqrt(o)},d.distanceMax=function(M){return arguments.length?(l=M*M,d):Math.sqrt(l)},d.theta=function(M){return arguments.length?(c=M*M,d):Math.sqrt(c)},d}function ox(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vx+=(i[l]-d.x)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.x=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}function lx(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vy+=(i[l]-d.y)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.y=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}function cx(n){var e=ds(.1),t,s,i;typeof n!="function"&&(n=ds(n==null?0:+n));function r(o){for(var l=0,c=t.length,d;l<c;++l)d=t[l],d.vz+=(i[l]-d.z)*s[l]*o}function a(){if(t){var o,l=t.length;for(s=new Array(l),i=new Array(l),o=0;o<l;++o)s[o]=isNaN(i[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return r.initialize=function(o){t=o,a()},r.strength=function(o){return arguments.length?(e=typeof o=="function"?o:ds(+o),a(),r):e},r.z=function(o){return arguments.length?(n=typeof o=="function"?o:ds(+o),a(),r):n},r}const ol={charge:!0,link:!0,collide:!0,gravity:!1},bs=.55,co=.16,af=.09;function of(n){return 1.6+.45*Math.sqrt(Math.max(1,n))}const dx=2.6,ux=2,hx=.0022,lf=new P(0,1,0),fx=.006,px=.0035,hi=1e4,uo=450,vr=700,cf=2500,df=4,mx=350,Mx=30,gx=1500,bx=14,Cd=new Set(["created","waiting","scheduled","started","registeringFiles"]);function ho(){const n=getComputedStyle(document.documentElement),e=(t,s)=>new Ze(n.getPropertyValue(t).trim()||s);return{running:e("--orange","#f70"),done:e("--butter","#fec"),error:new Ze("#f22"),template:e("--harvestgold","#fa4"),unknown:new Ze("#555"),edge:e("--pumpkin-pie","#c50"),join:e("--honey","#fc9"),root:e("--dag-root","#6fbfae"),pulse:e("--dag-pulse","#48d8f0")}}const uf=new Map;function zx(n){let e=uf.get(n);return e===void 0&&(e=new Ze(n),uf.set(n,e)),e}function Or(n,e,t){return n.share!==void 0&&n.status!=="cancelled"?n.share>=1?e.error:e.done.clone().lerp(e.error,Math.sqrt(Math.max(0,n.share))):n.status==="finishedWithError"||n.status==="cancelled"?e.error:n.hue!==void 0?zx(n.hue):t?e.root:n.status===void 0?e.template:n.status==="finishedSuccessfully"?e.done:Cd.has(n.status)?e.running:e.unknown}function _x(n,e,t){const s=Math.PI*(3-Math.sqrt(5)),i=e===1?0:1-2*n/(e-1),r=Math.sqrt(Math.max(0,1-i*i)),a=s*n;return new P(Math.cos(a)*r*t,i*t,Math.sin(a)*r*t)}function wx(n){const e=n.map(a=>a.metric??0),t=Math.max(...e,0),s=zm(n),i=new Map(s.placements.map(a=>[a.id,a])),r=[];for(const a of n){const o=i.get(a.id),l=((o?.x??0)-s.width/2)*ux,c=((s.tierCount-1)/2-(o?.tier??0))*dx,d=a.metric??0,h=t>0?.55+d/t*1:1;r.push({node:a,position:new P(l,c,0),radius:bs*h})}return r}function hf(n){const e=new Map;for(const i of n)for(const r of[...i.parentIds,...i.joinParentIds])e.set(r,(e.get(r)??0)+1),e.set(i.id,(e.get(i.id)??0)+1);const t=n.map(i=>i.metric??e.get(i.id)??1),s=Math.max(...t,1);return new Map(n.map((i,r)=>[i.id,bs*(.5+(t[r]??1)/s*1.2)]))}function yx(n,e=3,t=new Map,s=ol,i=new Set){const r=new Map,a=[];for(const v of n)for(const z of[...v.parentIds,...v.joinParentIds])a.push({source:z,target:v.id}),r.set(z,(r.get(z)??0)+1),r.set(v.id,(r.get(v.id)??0)+1);const o=n.map(v=>v.metric??r.get(v.id)??1),l=Math.max(...o,1),c=o.map(v=>bs*(.5+v/l*1.2)),d=new Map(n.map((v,z)=>[v.id,c[z]??bs])),h=n.map(v=>{const z=t.get(v.id);return z===void 0?{id:v.id}:i.has(v.id)?{id:v.id,x:z.x,y:z.y,z:z.z,fx:z.x,fy:z.y,fz:z.z}:{id:v.id,x:z.x,y:z.y,z:z.z}}),u=v=>i.has(v.id)&&v.fx!==void 0;let p=h,M=a;if(i.size>0){const v=new Set(h.filter(x=>!u(x)).map(x=>x.id));M=a.filter(x=>v.has(x.source)||v.has(x.target));const z=new Set(v);for(const x of M)z.add(x.source),z.add(x.target);p=h.filter(x=>z.has(x.id));const O=new Set(p.map(x=>x.id));M=M.filter(x=>O.has(x.source)&&O.has(x.target))}const _=Tm().strength(s.charge?v=>i.has(v.id)?0:-6*((d.get(v.id)??bs)/bs)**2:v=>i.has(v.id)?0:-6);s.reach!==void 0&&_.distanceMax(s.reach);const m=Im(p,e).force("link",Om(M).id(v=>v.id).distance(s.link?v=>(d.get(v.source.id)??bs)+(d.get(v.target.id)??bs)+1.4:2.2)).force("charge",_).stop();if(i.size===0&&m.force("center",e===2?Xh(0,0):Xh(0,0,0)),s.collide&&m.force("collide",vm().radius(v=>(d.get(v.id)??bs)*1.2)),s.gravity){const v=z=>((d.get(z.id)??bs)/bs)**2*.08;m.force("gx",ox(0).strength(v)).force("gy",lx(0).strength(v)),e===3&&m.force("gz",cx(0).strength(v))}const f=p.length===0?0:t.size>0?90:150;let S=0;return{total:f,moving:p.length,step:v=>{for(let z=0;z<v&&S<f;z++,S++)m.tick()},place:()=>n.map((v,z)=>{const O=h[z];return{node:v,position:new P(O?.x??0,O?.y??0,O?.z??0),radius:c[z]??bs}})}}const vx=90*400,Ox=12,xx=2,Sx=28,Gm=1.8,ff=.1,pf=.2,Ax=`
4110
4110
  attribute float radius;
4111
4111
  attribute float alpha;
4112
4112
  attribute vec3 tint;
@@ -4122,7 +4122,7 @@ void main() {
4122
4122
  gl_PointSize = min(max(px, floorPx), capPx);
4123
4123
  vTint = tint;
4124
4124
  vAlpha = alpha;
4125
- }`,Ox=`
4125
+ }`,Ex=`
4126
4126
  varying vec3 vTint;
4127
4127
  varying float vAlpha;
4128
4128
  void main() {
@@ -4132,7 +4132,7 @@ void main() {
4132
4132
  float halo = pow(1.0 - d, 2.2) * 0.55;
4133
4133
  float a = clamp(core + halo, 0.0, 1.0) * vAlpha;
4134
4134
  gl_FragColor = vec4(vTint * a, a);
4135
- }`,xx=`
4135
+ }`,Dx=`
4136
4136
  varying vec3 vTint;
4137
4137
  varying float vAlpha;
4138
4138
  void main() {
@@ -4140,7 +4140,7 @@ void main() {
4140
4140
  if (d > 1.0) discard;
4141
4141
  float a = smoothstep(1.0, 0.35, d) * vAlpha;
4142
4142
  gl_FragColor = vec4(vTint, a);
4143
- }`,Sx=7,Ax=5,Ex=300,pi=1200,Dx=1800,mf=.18,fo=1e3,Ix=9,Tx=500,Mf=new Ze("#ffffff"),Gx=`
4143
+ }`,Ix=7,Tx=5,Gx=300,mi=1200,Rx=1800,mf=.18,fo=1e3,Bx=9,Nx=500,Mf=new Ze("#ffffff"),Cx=`
4144
4144
  attribute vec3 aColor;
4145
4145
  attribute float aMode;
4146
4146
  attribute float aStart;
@@ -4159,7 +4159,7 @@ void main() {
4159
4159
  vMode = aMode;
4160
4160
  vStart = aStart;
4161
4161
  gl_Position = projectionMatrix * mv;
4162
- }`,Rx=`
4162
+ }`,Px=`
4163
4163
  uniform float time;
4164
4164
  uniform float opacity;
4165
4165
  uniform float born;
@@ -4175,18 +4175,18 @@ void main() {
4175
4175
  vec3 base = vColor * (0.35 + 0.65 * facing);
4176
4176
  float pulse = 0.0;
4177
4177
  if (vMode > 0.5 && vMode < 1.5) {
4178
- float head = fract(time / ${pi.toFixed(1)});
4178
+ float head = fract(time / ${mi.toFixed(1)});
4179
4179
  pulse = smoothstep(0.14, 0.0, abs(vAlong - head));
4180
4180
  } else if (vMode > 1.5) {
4181
4181
  // A finished feed replays its run: the wave goes stage by stage in the
4182
4182
  // order the stages ran, rests, and goes again.
4183
4183
  float local = mod(time - born, cycle) - vStart;
4184
- float head = local / ${(pi/2).toFixed(1)};
4184
+ float head = local / ${(mi/2).toFixed(1)};
4185
4185
  if (head > -0.1 && head < 1.2) pulse = smoothstep(0.14, 0.0, abs(vAlong - head));
4186
4186
  }
4187
4187
  gl_FragColor = vec4(base + vec3(1.0, 0.95, 0.8) * pulse * 1.3, opacity);
4188
- }`;let fc=null;function pc(){return fc===null&&(fc=new au(1,1,1,10,1,!0)),fc}let po=null;function gf(){if(po!==null)return po;const n=document.createElement("canvas");n.width=128,n.height=128;const e=n.getContext("2d");if(e!==null){const t=e.createRadialGradient(64,64,0,64,64,64);t.addColorStop(0,"rgba(255,255,255,1)"),t.addColorStop(.35,"rgba(255,255,255,0.45)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,128,128)}return po=new Cz(n),po}class _l{container;handlers;ambient;renderer;scene;camera;group=new ma;raycaster=new Qz;meshes=new Map;lastPositions=new Map;frozen=new Set;physicsOnce=void 0;census=!1;physics={...ol};physics_set(e,t=!0){this.physics={...this.physics,...e},t&&this.rebuild()}physics_get(){return{...this.physics}}censusMesh=null;censusIds=[];censusPositions=[];censusBase=null;census_set(e){this.census!==e&&(this.census=e,this.rebuild(!0,"hold"))}census_get(){return this.census}edges=[];graph={nodes:[]};spinIdleUntil=0;drag=null;dragSim=null;dragSimNodes=[];suppressClick=!1;waveTimes=new Map;waveStartAt=null;flight=null;flightHome=null;holding=!1;touched=!1;focus=new P;turn_about(e,t){const s=new Qi().setFromAxisAngle(e,t);this.group.position.sub(this.focus).applyQuaternion(s).add(this.focus),this.group.quaternion.premultiply(s)}drawMode="spheres";stars=[];starIndex=new Map;nebulae=[];starMaterials=[];starLayers=[];threadColor=null;handoff=new Map;placedById=new Map;handoffAt=0;tubeMaterials=[];tubeSets=[];tubesStale=!1;lampGlows=new Map;pointerInside=!1;hovered=null;fits=0;strategy="ranked";selectedId=null;frameHandle=null;disposed=!1;tip=null;tumbleAxis=new P(0,1,0);tumblePhase=Math.random()*Math.PI*2;pulseColor=new Ze("#48d8f0");constructor(e,t={},s={}){this.container=e,this.handlers=t,this.ambient=s.ambient===!0,this.renderer=new Xv({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("dag-scene-canvas"),this.scene=new vz,this.camera=new tn(50,1,.1,200),this.camera.position.set(0,0,14),this.scene.add(new Yz(16777215,.9));const i=new Xz(16777215,1.2);i.position.set(4,6,8),this.scene.add(i),this.scene.add(this.group),e.appendChild(this.renderer.domElement),this.size_fit(),this.ambient||(this.renderer.domElement.addEventListener("click",a=>{if(this.suppressClick){this.suppressClick=!1;return}this.pick_handle(a,"select")}),this.renderer.domElement.addEventListener("dblclick",a=>this.pick_handle(a,"activate")),this.renderer.domElement.addEventListener("pointerdown",a=>this.press_handle(a)),this.renderer.domElement.addEventListener("pointerup",()=>this.drag_end()),this.renderer.domElement.addEventListener("pointercancel",()=>this.drag_end()),this.tip=document.createElement("div"),this.tip.className="dag-node-tip",this.tip.hidden=!0,e.appendChild(this.tip),this.renderer.domElement.addEventListener("pointermove",a=>{this.drag!==null?this.drag_move(a):this.viewDrag!==null?this.view_move(a):this.hover_handle(a)}),this.renderer.domElement.addEventListener("pointerleave",()=>{this.tip&&(this.tip.hidden=!0),this.pointerInside=!1,this.hovered=null}),this.renderer.domElement.addEventListener("wheel",a=>{a.preventDefault(),this.spinIdleUntil=Date.now()+Ti,this.touched=!0;const o=this.camera.position.length();if(this.census){const u=this.camera.getWorldDirection(new P),p=Math.max(4,o)*.0012;this.camera.position.addScaledVector(u,-a.deltaY*p);return}const l=this.camera.position.clone().sub(this.focus),c=l.length(),d=Math.exp(a.deltaY*.001),h=Math.min(Math.max(c*d,1.5),Math.max(40,this.camera.far*.45));this.camera.position.copy(this.focus).addScaledVector(l,h/Math.max(1e-4,c))},{passive:!1}),this.renderer.domElement.addEventListener("contextmenu",a=>a.preventDefault())),new ResizeObserver(()=>this.size_fit()).observe(e);const r=()=>{if(!this.disposed){if(this.ambient)this.tumblePhase+=px,this.tumbleAxis.set(Math.sin(this.tumblePhase*.7),Math.cos(this.tumblePhase*.4)+.6,Math.sin(this.tumblePhase*.3)*.8).normalize(),this.group.rotateOnWorldAxis(this.tumbleAxis,fx),this.wave_animate();else{if(Date.now()>=this.spinIdleUntil&&!this.pointerInside&&!this.holding&&this.flight===null&&this.projection==="3d"&&this.turn_about(lf,hx),this.dragSim!==null&&(this.drag!==null||this.dragSim.alpha()>.02?(this.dragSim.tick(),this.positions_sync()):(this.dragSim=null,this.dragSimNodes=[])),this.dragReturns.length>0){const a=Date.now();this.dragReturns=this.dragReturns.filter(o=>{const l=Math.min(1,(a-o.startedAt)/300),c=l*l*(3-2*l);return o.mesh.position.lerpVectors(o.from,o.to,c),l<1}),this.positions_sync()}this.wave_animate(),this.flight_animate()}if(this.starScale_update(),this.handoff_step(),this.tubeMaterials.length>0){const a=performance.now();for(const o of this.tubeMaterials){const l=o.uniforms.time;l!==void 0&&(l.value=a)}this.tubesStale&&this.tubes_restatus(),this.lamps_animate(a)}this.renderer.render(this.scene,this.camera),this.frameHandle=window.requestAnimationFrame(r)}};r()}graph_set(e,t={}){this.graph=e,this.frozen=new Set(t.frozen??[]),this.physicsOnce=t.physics,this.rebuild(t.fit!==!1,t.settle??"full"),t.wave!==!1&&this.wave_start()}waveLooping=!1;waveLoop_set(e){this.waveLooping=e,e&&this.wave_start()}waveLoop_get(){return this.waveLooping}positions_get(){const e={};for(const[t,s]of this.lastPositions)e[t]=[Math.round(s.x*100)/100,Math.round(s.y*100)/100,Math.round(s.z*100)/100];return e}positions_seed(e){this.lastPositions=new Map(Object.entries(e).map(([t,[s,i,r]])=>[t,new P(s,i,r)]))}wave_start(){this.waveTimes=this.waveSchedule_compute(),this.waveStartAt=this.waveTimes.size>0?Date.now():null}flight_into(e,t){const s=this.meshes.get(e),i=s===void 0?this.censusIds.indexOf(e):-1;if(s===void 0&&i<0||this.flight!==null||this.holding)return;this.holding=!0,this.flightHome={position:this.camera.position.clone(),quaternion:this.camera.quaternion.clone()},this.group.updateMatrixWorld(!0);const r=s!==void 0?s.getWorldPosition(new P):this.group.localToWorld((this.censusPositions[i]??new P).clone()),a=r.clone().add(this.camera.position.clone().sub(r).normalize().multiplyScalar(.4)),o=this.camera.clone();o.position.copy(this.camera.position),o.lookAt(r),this.flight={fromPos:this.camera.position.clone(),toPos:a,fromQuat:this.camera.quaternion.clone(),toQuat:o.quaternion.clone(),startedAt:Date.now(),durationMs:700,onDone:t}}camera_flyToFit(e,t,s,i=1,r=1.15){const a=new Set(e),o=[];let l=0;this.group.updateMatrixWorld(!0);for(const z of this.drawnIds()){if(a.size>0&&!a.has(z))continue;const O=this.nodeWorld_of(z);O!==null&&(o.push(O.position),l=Math.max(l,O.radius))}if(o.length===0){s();return}const c=new P;for(const z of o)c.add(z);c.divideScalar(o.length);const d=o.map(z=>c.distanceTo(z)).sort((z,O)=>z-O),h=Math.max(1,Math.min(d.length,Math.ceil(d.length*Math.min(1,Math.max(.1,i))))),u=Math.max(1,(d[h-1]??1)+l),p=this.camera.fov*Math.PI/180,M=u/Math.tan(p/2),_=u/(Math.tan(p/2)*Math.max(.1,this.camera.aspect)),m=Math.max(3,Math.max(M,_)*r),f=this.camera.position.clone().sub(c);f.lengthSq()<1e-4&&f.set(0,0,1),f.normalize();const S=c.clone().add(f.multiplyScalar(m)),v=this.camera.clone();v.position.copy(S),v.lookAt(c),this.focus.copy(c),this.camera.far=Math.max(this.camera.far,(m+u)*2),this.camera.updateProjectionMatrix(),this.flight={fromPos:this.camera.position.clone(),toPos:S,fromQuat:this.camera.quaternion.clone(),toQuat:v.quaternion.clone(),startedAt:Date.now(),durationMs:t,onDone:s}}camera_touched(){return this.touched}draw_set(e){e!==this.drawMode&&(this.drawMode=e,this.rebuild(!1,"hold"))}draw_get(){return this.drawMode}state_get(){const e=this.graph.nodes.filter(i=>i.solid===!0).map(i=>i.id),t=e.filter(i=>this.meshes.has(i)).length;let s=0;for(const i of this.handoff.values())i.mix>0&&(s+=1);return{draw:this.drawMode,arrangement:this.arrangement,census:this.census,nodes:this.graph.nodes.length,meshes:this.meshes.size,stars:this.stars.length,solidMarked:e.length,solidDrawn:t,tubes:this.tubeMaterials.length,handoffGroups:this.handoff.size,handoffSolid:s,camera:this.camera.position.distanceTo(this.focus).toFixed(1),settling:this.slicing}}camera_flyToward(e,t,s,i){const r=this.nodeWorld_of(e);if(r===null){i();return}const a=r.position,o=this.camera.position.clone().sub(a);o.lengthSq()<1e-4&&o.set(0,0,1),o.normalize();const l=a.clone().add(o.multiplyScalar(Math.max(t,r.radius*4))),c=this.camera.clone();c.position.copy(l),c.lookAt(a),this.focus.copy(a),this.flight={fromPos:this.camera.position.clone(),toPos:l,fromQuat:this.camera.quaternion.clone(),toQuat:c.quaternion.clone(),startedAt:Date.now(),durationMs:s,onDone:i}}holding_get(){return this.holding}flight_back(e){if(this.flightHome===null){this.holding=!1,e();return}const t=this.flightHome;this.flight={fromPos:this.camera.position.clone(),toPos:t.position.clone(),fromQuat:this.camera.quaternion.clone(),toQuat:t.quaternion.clone(),startedAt:Date.now(),durationMs:700,onDone:()=>{this.flightHome=null,this.holding=!1,this.spinIdleUntil=Date.now()+Ti,e()}}}flight_animate(){if(this.flight===null)return;const e=(Date.now()-this.flight.startedAt)/this.flight.durationMs,t=Math.min(1,e),s=t*t*(3-2*t);if(this.camera.position.lerpVectors(this.flight.fromPos,this.flight.toPos,s),this.camera.quaternion.slerpQuaternions(this.flight.fromQuat,this.flight.toQuat,s),t>=1){const i=this.flight.onDone;this.flight=null,i()}}waveSchedule_compute(){const e=new Map,t=new Set(this.graph.nodes.map(r=>r.id)),s=r=>r.status===void 0||r.status==="finishedSuccessfully"||r.status==="finishedWithError";let i=!1;for(;!i;){i=!0;for(const r of this.graph.nodes){if(e.has(r.id)||!s(r))continue;const a=[...r.parentIds,...r.joinParentIds].filter(l=>t.has(l));if(!a.every(l=>e.has(l)))continue;const o=a.reduce((l,c)=>Math.max(l,e.get(c)??0),-uo);e.set(r.id,o+uo),i=!1}}return e}wave_animate(){if(this.waveStartAt===null)return;const e=Date.now()-this.waveStartAt;let t=0;if(this.census&&this.censusMesh!==null&&this.censusBase!==null&&this.censusMesh.instanceColor){const s=this.censusMesh.instanceColor.array,i=this.censusBase,r=this.pulseColor;for(let a=0;a<this.censusIds.length;a++){const o=this.waveTimes.get(this.censusIds[a]??"");if(o===void 0)continue;t=Math.max(t,o);const l=e-o,c=l>=0&&l<=vr?Math.sin(l/vr*Math.PI):0,d=a*3;s[d]=i[d]+(r.r-i[d])*c,s[d+1]=i[d+1]+(r.g-i[d+1])*c,s[d+2]=i[d+2]+(r.b-i[d+2])*c}this.censusMesh.instanceColor.needsUpdate=!0,e>t+vr&&(this.waveStartAt=this.ambient||this.waveLooping?Date.now()+cf:null);return}for(const[s,i]of this.waveTimes){t=Math.max(t,i);const r=this.meshes.get(s);if(r===void 0||!(r.material instanceof Ln))continue;const a=e-i,o=a>=0&&a<=vr?Math.sin(a/vr*Math.PI):0;r.scale.setScalar(1+o*.45),o>0?(r.material.emissive.copy(this.pulseColor),r.material.emissiveIntensity=o*1.2):(r.material.emissive.setScalar(s===this.selectedId?1:0),r.material.emissiveIntensity=s===this.selectedId?.35:0)}e>t+vr&&(this.waveStartAt=this.ambient||this.waveLooping?Date.now()+cf:null)}strategy_set(e){this.strategy=e,this.rebuild()}selection_clear(){this.selectedId=null,this.selection_paint()}selection_paint(){for(const[e,t]of this.meshes){if(!(t.material instanceof Ln))continue;const s=e===this.selectedId;t.material.emissive.set(s?"#ffffff":"#000000"),t.material.emissiveIntensity=s?.35:0}}strategy_get(){return this.strategy}projection="3d";projection_set(e){this.projection=e,e==="2d"&&this.group.quaternion.identity(),this.rebuild()}projection_get(){return this.projection}status_update(e,t){const s=this.graph.nodes.find(r=>r.id===e);if(!s||s.status===t)return;s.status=t;const i=this.meshes.get(e);if(i&&i.material instanceof Ln){const r=s.parentIds.length===0&&s.joinParentIds.length===0;i.material.color=Or(s,ho(),r),delete i.userData.lampBase}this.tubeSets.some(r=>r.members.has(e))&&(this.tubesStale=!0)}palette_refresh(){this.rebuild(!0,"hold")}size_fit(){const e=Math.max(1,this.container.clientWidth),t=Math.max(1,this.container.clientHeight);this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix()}dispose(){this.disposed=!0,this.layoutWorker?.terminate(),this.layoutWorker=null,this.frameHandle!==null&&window.cancelAnimationFrame(this.frameHandle),this.renderer.dispose(),this.renderer.domElement.remove()}censusBuild(e,t,s=!0){let i=0;for(const f of e)f.node.ghost!==!0&&(i+=Math.max(1,f.node.count??1));const r=new lu(1,1),a=new Ln({color:"#ffffff",roughness:.5,metalness:.1}),o=this.drawMode==="stars",l=[],c=new lh(r,a,o?1:i),d=new Ze,h=new es,u=new Map;let p=0,M=1;const _=new P;for(const f of e)_.add(f.position);_.divideScalar(Math.max(1,e.length));for(const{node:f,position:S,radius:v}of e){if(f.ghost===!0)continue;const z=Math.max(1,f.count??1),O=z===1?0:v*(1.6+.55*Math.cbrt(z)),x=z===1?v:Math.max(.06,Math.min(v*.5,2.2*O/Math.sqrt(z))),G=[];for(let b=0;b<z;b++){const T=z===1?S.clone():Mx(b,z,O).add(S);G.push(T);const N=f.parentIds.length===0&&f.joinParentIds.length===0;d.set(Or(f,t,N)),o?l.push({id:f.id,position:T,radius:x,color:d.clone(),dim:f.dim===!0,ember:f.share!==void 0&&f.share>0||f.status==="finishedWithError"}):(h.position.copy(T),h.scale.setScalar(x),h.updateMatrix(),c.setMatrixAt(p,h.matrix),c.setColorAt(p,d)),this.censusIds.push(f.id),this.censusPositions.push(T),p+=1,M=Math.max(M,_.distanceTo(T)+x)}u.set(f.id,G)}o?this.stars_draw(l):(c.instanceColor&&(c.instanceColor.needsUpdate=!0),this.group.add(c),this.censusMesh=c,this.censusBase=c.instanceColor?Float32Array.from(c.instanceColor.array):null);const m=[];for(const{node:f}of e){const S=u.get(f.id)??[];for(const v of f.parentIds){const z=u.get(v);if(!(!z||z.length===0))for(let O=0;O<S.length;O++){const x=S[O],G=z.length===S.length?z[O]:z[O%z.length];x===void 0||G===void 0||m.push(x.x,x.y,x.z,G.x,G.y,G.z)}}}if(m.length>0){const f=new os;f.setAttribute("position",new Ht(m,3));const S=new fh(f,o?new Wi({color:t.edge,transparent:!0,opacity:ff,blending:Ci,depthWrite:!1}):new Wi({color:t.edge,transparent:!0,opacity:.35}));this.group.add(S)}if(!this.ambient&&s){const f=this.camera.fov*Math.PI/180,S=M/Math.tan(f/2),v=M/(Math.tan(f/2)*Math.max(.1,this.camera.aspect)),z=Math.max(8,Math.max(S,v)*1.15);this.group.position.copy(_).applyQuaternion(this.group.quaternion).negate(),this.focus.set(0,0,0),this.camera.position.set(z*.5,z*.4,z*.85),this.camera.far=Math.max(200,(z+M)*2.5),this.camera.updateProjectionMatrix(),this.camera.lookAt(0,0,0)}}camera_fit(e){if(e.length===0)return;this.touched=!1,this.fits+=1,this.renderer.domElement.dataset.fits=String(this.fits);const t=new P;for(const d of e)t.add(d.position);t.divideScalar(e.length);const s=e.map(d=>t.distanceTo(d.position)+d.radius).sort((d,h)=>d-h),i=this.handlers.handoffKey!==void 0?.95:1,r=Math.max(1,s[Math.max(0,Math.ceil(s.length*i)-1)]??1),a=this.camera.fov*Math.PI/180,o=r/Math.tan(a/2),l=r/(Math.tan(a/2)*Math.max(.1,this.camera.aspect)),c=Math.max(8,Math.max(o,l)*1.15);this.group.position.copy(t).applyQuaternion(this.group.quaternion).negate(),this.focus.set(0,0,0),this.camera.position.set(0,0,c),this.camera.far=Math.max(200,(c+r)*2),this.camera.updateProjectionMatrix(),this.camera.lookAt(0,0,0)}spheres=new Map;sphere_of(e){const t=Math.round(e*1e3);let s=this.spheres.get(t);return s===void 0&&(s=new il(t/1e3,24,18),s.computeBoundingSphere(),this.spheres.set(t,s)),s}rebuildGen=0;slicing=!1;rebuild(e=!0,t="full"){const s=++this.rebuildGen;if(this.slicing&&(this.slicing=!1,this.handlers.progress?.(1,1,0)),this.strategy!=="molecule"){this.draw(gx(this.graph.nodes),e);return}let i=this.frozen;if(t!=="full"&&i.size===0){const h=this.graph.nodes.map(u=>u.id).filter(u=>this.lastPositions.has(u));h.length>0&&(i=new Set(h))}const r=bx(this.graph.nodes,this.projection==="2d"?2:3,this.lastPositions,this.physicsOnce!==void 0?{...this.physics,...this.physicsOnce}:this.physics,i),a=this.graph.nodes.length,o=this.handlers.progress,l=r.total*r.moving<zx;if((!l||this.arrangement!=="galaxy")&&o!==void 0&&this.handlers.handoffKey!==void 0&&this.frozen.size===0){this.hierarchy_run(s,e,i,o);return}if(o===void 0||l){r.step(r.total),this.draw(r.place(),e);return}let c=0;this.slicing=!0,o(0,r.total,a);const d=()=>{if(s!==this.rebuildGen||this.disposed)return;const h=performance.now();for(;c<r.total&&performance.now()-h<_x;)r.step(1),c+=1;if(c<r.total){o(c,r.total,a),window.requestAnimationFrame(d);return}this.slicing=!1,this.draw(r.place(),e),o(r.total,r.total,a)};window.requestAnimationFrame(d)}layoutWorker=null;arrangement="galaxy";arrangementMemory=new Map;arrangement_set(e,t){if(e===this.arrangement)return;this.arrangementMemory.set(this.arrangement,new Map(this.lastPositions)),this.arrangement=e;let s=this.arrangementMemory.get(e);s===void 0&&t!==void 0&&Object.keys(t).length>0&&(s=new Map(Object.entries(t).map(([i,[r,a,o]])=>[i,new P(r,a,o)]))),this.lastPositions=s??new Map,this.rebuild(!0,s===void 0?"full":"hold")}arrangement_get(){return this.arrangement}hierarchy_run(e,t,s,i){const r=this.handlers.handoffKey;if(r===void 0)return;const a=hf(this.graph.nodes),o=this.graph.nodes.map(u=>{const p=this.lastPositions.get(u.id);return{id:u.id,parents:[...u.parentIds,...u.joinParentIds],radius:a.get(u.id)??bs,group:u.ghost===!0?null:r(u),...p===void 0?{}:{seed:[p.x,p.y,p.z]},...s.has(u.id)?{frozen:!0}:{}}}),l=1e3,c=o.length;this.slicing=!0,i(0,l,c),this.layoutWorker===null&&(this.layoutWorker=new Worker(new URL(""+new URL("layoutWorker-DqMRqv-I.js",import.meta.url).href,import.meta.url),{type:"module"}));const d=this.layoutWorker,h=this.physicsOnce!==void 0?{...this.physics,...this.physicsOnce}:this.physics;d.onmessage=u=>{const p=u.data;if(p.generation!==this.rebuildGen||this.disposed)return;if(p.type==="progress"){i(Math.min(l-1,Math.floor((p.fraction??0)*l)),l,c);return}const M=p.positions??{},_=this.graph.nodes.map(m=>{const f=M[m.id]??[0,0,0];return{node:m,position:new P(f[0],f[1],f[2]),radius:a.get(m.id)??bs}});this.slicing=!1,this.draw(_,t),i(l,l,c)},d.postMessage({generation:e,nodes:o,physics:h,arrangement:this.arrangement})}draw(e,t){this.group.clear(),this.meshes=new Map,this.edges=[],this.censusMesh=null,this.censusIds=[],this.censusPositions=[],this.censusBase=null,this.dragSim=null,this.dragSimNodes=[],this.drag=null,this.stars=[],this.starIndex=new Map,this.nebulae=[],this.starMaterials=[],this.starLayers=[],this.threadColor=null,this.handoff=new Map,this.placedById=new Map,this.tubeMaterials=[],this.tubeSets=[];for(const u of this.lampGlows.values())u.material.dispose();this.lampGlows=new Map;const s=ho();if(this.pulseColor=s.pulse,this.lastPositions=new Map(e.map(u=>[u.node.id,u.position.clone()])),this.projection==="2d")for(const u of e)u.position.z=0;if(this.census){const u=e.filter(p=>p.node.solid===!0&&p.node.ghost!==!0);this.censusBuild(e.filter(p=>p.node.solid!==!0),s,t),u.length>0&&this.solid_draw(u,s);return}!this.ambient&&t&&this.camera_fit(e);const i=new Map(e.map(u=>[u.node.id,u])),r=this.drawMode==="stars",a=[],o=r?this.handlers.handoffKey:void 0;for(const{node:u,position:p,radius:M}of e){if(u.ghost===!0&&u.halo!==!0)continue;if(r&&u.solid!==!0){if(u.halo===!0){this.nebula_add(u,p,s);continue}const v=u.parentIds.length===0&&u.joinParentIds.length===0;a.push({id:u.id,position:p.clone(),radius:M,color:Or(u,s,v).clone(),dim:u.dim===!0,ember:u.share!==void 0&&u.share>0||u.status==="finishedWithError"});continue}if(u.halo===!0){const v=new il(of(u.count??1),24,18),z=new nu({color:s.edge,transparent:!0,opacity:u.dim===!0?af*.4:af,depthWrite:!1}),O=new Ss(v,z);O.position.copy(p),O.renderOrder=1,O.userData.nodeId=u.id,O.userData.halo=!0,O.userData.dim=u.dim===!0,this.group.add(O),this.meshes.set(u.id,O);continue}const _=u.parentIds.length===0&&u.joinParentIds.length===0,m=this.projection==="2d"?new ru(M,36):this.sphere_of(M),f=new Ln({color:Or(u,s,_),roughness:.35,metalness:.15,emissive:u.id===this.selectedId?new Ze("#ffffff"):new Ze("#000000"),emissiveIntensity:u.id===this.selectedId?.35:0,...u.dim===!0?{transparent:!0,opacity:co}:{}}),S=new Ss(m,f);S.position.copy(p),S.userData.nodeId=u.id,S.userData.dim=u.dim===!0,this.group.add(S),this.meshes.set(u.id,S)}a.length>0&&this.stars_draw(a);for(const u of e)this.placedById.set(u.node.id,u);o!==void 0&&this.handoff_gather(a,o);const l=[],c=[],d=u=>!r||u.node.solid===!0,h=(u,p,M,_,m)=>{const f=_?.35:1,S=l.length/6;l.push(u.x,u.y,u.z,p.x,p.y,p.z),c.push(M.r*f,M.g*f,M.b*f,M.r*f,M.g*f,M.b*f);const v=_||o===void 0?null:o(m);v!==null&&this.handoff.get(v)?.threadSegments.push(S)};for(const u of e){const{node:p,position:M}=u;if(p.ghost!==!0){for(const _ of p.parentIds){const m=i.get(_);if(!m||m.node.ghost===!0)continue;const f=p.dim===!0||m.node.dim===!0;d(u)&&d(m)?!r&&f&&this.edge_add(_,p.id,m.position,M,s.edge,!1,f):h(m.position,M,s.edge,f,p)}for(const _ of p.joinParentIds){const m=i.get(_);if(!m)continue;const f=p.dim===!0||m.node.dim===!0;d(u)&&d(m)?!r&&f&&this.edge_add(_,p.id,m.position,M,s.join,!0,f):h(m.position,M,s.join,f,p)}}}{const u=e.filter(p=>p.node.ghost!==!0&&p.node.halo!==!0&&(r?p.node.solid===!0:p.node.dim!==!0)).map(p=>p.node.id);if(u.length>0){const p={entries:u.map(M=>({id:M,position:new P,radius:0,color:new Ze,dim:!1,ember:!1})),center:new P,maxRadius:0,mix:1,target:1,meshes:[],lines:[],tubes:null,threadSegments:[]};this.tubes_build(p,new Set(u),s)}}if(l.length>0){const u=new os;u.setAttribute("position",new Ht(l,3));const p=new Ht(c,3);u.setAttribute("color",p),this.threadColor={attribute:p,base:Float32Array.from(c)},this.group.add(new fh(u,new Wi({vertexColors:!0,transparent:!0,opacity:ff,blending:Ci,depthWrite:!1})))}}handoff_gather(e,t){const s=new Map(this.graph.nodes.map(i=>[i.id,i]));for(const i of e){if(i.dim)continue;const r=s.get(i.id),a=r===void 0?null:t(r);if(a===null)continue;let o=this.handoff.get(a);o===void 0&&(o={entries:[],center:new P,maxRadius:0,mix:0,target:0,meshes:[],lines:[],tubes:null,threadSegments:[]},this.handoff.set(a,o)),o.entries.push(i),o.maxRadius=Math.max(o.maxRadius,i.radius)}for(const i of this.handoff.values()){for(const r of i.entries)i.center.add(r.position);i.center.divideScalar(Math.max(1,i.entries.length))}}handoff_step(){if(this.handoff.size===0)return;const e=performance.now(),t=this.handoffAt===0?0:Math.min(100,e-this.handoffAt);this.handoffAt=e;const i=(this.renderer.domElement.clientHeight||1)/(2*Math.tan(this.camera.fov*Math.PI/360));this.group.updateMatrixWorld(!0),this.camera.updateMatrixWorld();const a=new Rt().multiplyMatrices(this.camera.matrixWorldInverse,this.group.matrixWorld).elements;let o=!1,l=!1;for(const c of this.handoff.values()){let d=1/0;for(const p of c.entries){const M=p.position,_=-(a[2]*M.x+a[6]*M.y+a[10]*M.z+a[14]);_>0&&_<d&&(d=_)}const h=d===1/0?0:2*c.maxRadius*i/d;if(c.target===0&&h>Sx?c.target=1:c.target===1&&h<Ax&&(c.target=0),c.mix===c.target)continue;const u=t===0?1:t/Ex;c.mix=c.target>c.mix?Math.min(1,c.mix+u):Math.max(0,c.mix-u),c.mix>0&&c.meshes.length===0&&this.handoffSolid_build(c);for(const p of c.meshes)p.material instanceof Ln&&(p.material.opacity=c.mix);for(const p of c.lines)p.material instanceof Wi&&(p.material.opacity=.75*c.mix);if(c.tubes!==null&&c.tubes.material instanceof _s){const p=c.tubes.material.uniforms.opacity;p!==void 0&&(p.value=c.mix)}for(const p of c.entries){const M=p.layer===void 0?void 0:this.starLayers[p.layer];M===void 0||p.slot===void 0||(M.alpha.setX(p.slot,(M.base[p.slot]??1)*(1-c.mix)),o=!0)}if(this.threadColor!==null&&c.threadSegments.length>0){const p=this.threadColor.attribute.array,M=this.threadColor.base;for(const _ of c.threadSegments)for(let m=_*6;m<_*6+6;m++)p[m]=(M[m]??0)*(1-c.mix);l=!0}c.mix===0&&this.handoffSolid_release(c)}if(o)for(const c of this.starLayers)c.alpha.needsUpdate=!0;l&&this.threadColor!==null&&(this.threadColor.attribute.needsUpdate=!0)}handoffSolid_build(e){const t=ho(),s=new Set(e.entries.map(i=>i.id));for(const i of e.entries){const r=this.placedById.get(i.id);if(r===void 0)continue;const a=r.node,o=a.parentIds.length===0&&a.joinParentIds.length===0,l=new Ss(this.sphere_of(r.radius),new Ln({color:Or(a,t,o),roughness:.35,metalness:.15,transparent:!0,opacity:e.mix}));l.position.copy(r.position),l.userData.nodeId=a.id,l.userData.dim=!1,this.group.add(l),this.meshes.set(a.id,l),e.meshes.push(l)}this.tubes_build(e,s,t)}tubes_build(e,t,s){const i=[];for(const O of e.entries){const x=this.placedById.get(O.id);if(x!==void 0){for(const G of x.node.parentIds){const b=this.placedById.get(G);b!==void 0&&t.has(G)&&i.push({from:b,to:x,join:!1})}for(const G of x.node.joinParentIds){const b=this.placedById.get(G);b!==void 0&&t.has(G)&&i.push({from:b,to:x,join:!0})}}}if(i.length===0)return;const r=new Map,a=(O,x=new Set)=>{const G=r.get(O);if(G!==void 0)return G;if(x.has(O))return 0;x.add(O);const b=this.placedById.get(O),T=b===void 0?[]:[...b.node.parentIds,...b.node.joinParentIds].filter(C=>t.has(C)),N=T.length===0?0:1+Math.max(...T.map(C=>a(C,x)));return r.set(O,N),N},o=O=>O.status==="finishedSuccessfully"||O.status==="finishedWithError"||O.share!==void 0&&O.status!==void 0&&!Cd.has(O.status),l=performance.now(),c=new Float32Array(i.length*3),d=new Float32Array(i.length),h=new Float32Array(i.length),u=s.edge.clone().lerp(new Ze("#ffffff"),.45),p=new lh(pc(),new _s({uniforms:{time:{value:l},opacity:{value:e.mix},born:{value:l},cycle:{value:1}},vertexShader:Gx,fragmentShader:Rx,transparent:!0}),i.length),M=new P(0,1,0),_=new es;let m=0;const f=[],S=new Map,v=new Set;i.forEach(({from:O,to:x,join:G},b)=>{const T=x.position.clone().sub(O.position),N=T.length(),C=Math.max(.06,Math.min(O.radius,x.radius)*.34);_.position.copy(O.position).addScaledVector(T,.5),_.quaternion.setFromUnitVectors(M,N>0?T.clone().divideScalar(N):M),_.scale.set(C,N,C),_.updateMatrix(),p.setMatrixAt(b,_.matrix),f.push({from:O.node.id,to:x.node.id,width:C});const Q=x.node.status==="finishedWithError"||x.node.share!==void 0&&x.node.share>=1?s.error:G?s.join:u;c.set([Q.r,Q.g,Q.b],b*3);const se=x.node.status!==void 0&&Cd.has(x.node.status);d[b]=se?1:o(x.node)?2:0;const H=a(O.node.id);if(m=Math.max(m,H),h[b]=H*uo,d[b]===1&&v.add(x.node.id),d[b]===2){const ee=h[b]+pi/2;S.set(x.node.id,Math.min(S.get(x.node.id)??1/0,ee)),H===0&&S.set(O.node.id,0)}}),p.geometry=pc(),p.instanceMatrix.needsUpdate=!0;const z=pc().clone();if(z.setAttribute("aColor",new _a(c,3)),z.setAttribute("aMode",new _a(d,1)),z.setAttribute("aStart",new _a(h,1)),p.geometry=z,p.frustumCulled=!1,this.group.add(p),e.tubes=p,p.material instanceof _s){this.tubeMaterials.push(p.material);const O=p.material.uniforms.cycle;O!==void 0&&(O.value=(m+1)*uo+pi/2+Dx)}this.tubeSets.push({mesh:p,edges:f,lamps:S,blinks:v,group:e,members:t})}lamps_animate(e){const t=new Set;for(const{mesh:s,lamps:i,blinks:r}of this.tubeSets){if(i.size===0&&r.size===0||!(s.material instanceof _s))continue;const a=Number(s.material.uniforms.born?.value??e),o=Number(s.material.uniforms.cycle?.value??1),l=((e-a)%o+o)%o,c=Math.min(1,Math.max(0,(o-l)/Tx));for(const[h,u]of i){const p=l-u;this.lamp_paint(h,p<0?0:c,p>=0&&p<fo?p/fo:-1,t)}const d=(e%pi+pi)%pi;for(const h of r){if(i.has(h))continue;const u=Math.max(0,1-d/(pi*.8));this.lamp_paint(h,u*u,d<fo?d/fo:-1,t)}}for(const[s,i]of this.lampGlows)t.has(s)||(i.visible=!1,this.meshes.has(s)||(this.group.remove(i),i.material.dispose(),this.lampGlows.delete(s)))}lamp_paint(e,t,s,i){const r=this.meshes.get(e);if(r===void 0||!(r.material instanceof Ln))return;let a=r.userData.lampBase;a instanceof Ze||(a=r.material.color.clone(),r.userData.lampBase=a);const o=s<0?0:(1-s)**2;if(r.material.color.copy(a).multiplyScalar(mf+(1-mf)*Math.max(t,o)).lerp(Mf,Math.min(1,.22*t+.7*o)),s<0)return;let l=this.lampGlows.get(e);l===void 0&&(l=new sh(new Ed({map:gf(),color:a.clone().lerp(Mf,.35),transparent:!0,blending:Ci,depthWrite:!1})),this.lampGlows.set(e,l),this.group.add(l));const c=r.geometry.parameters?.radius??bs,d=1-(1-s)**3;l.position.copy(r.position),l.scale.setScalar(c*(2+Ix*d)*r.scale.x),l.material.opacity=.9*(1-s)**1.5,l.visible=!0,i.add(e)}tubes_restatus(){this.tubesStale=!1;const e=ho(),t=this.tubeSets;this.tubeSets=[];for(const s of t){if(this.group.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material instanceof _s){const i=s.mesh.material;this.tubeMaterials=this.tubeMaterials.filter(r=>r!==i),i.dispose()}s.group.tubes=null,this.tubes_build(s.group,s.members,e)}this.tubes_follow()}tubes_follow(){const e=new P(0,1,0),t=new es;for(const{mesh:s,edges:i}of this.tubeSets)i.forEach(({from:r,to:a,width:o},l)=>{const c=this.meshes.get(r),d=this.meshes.get(a);if(c===void 0||d===void 0)return;const h=d.position.clone().sub(c.position),u=h.length();t.position.copy(c.position).addScaledVector(h,.5),t.quaternion.setFromUnitVectors(e,u>0?h.clone().divideScalar(u):e),t.scale.set(o,u,o),t.updateMatrix(),s.setMatrixAt(l,t.matrix)}),s.instanceMatrix.needsUpdate=!0}handoffSolid_release(e){for(const t of e.meshes){this.group.remove(t),t.material instanceof Tn&&t.material.dispose();const s=t.userData.nodeId;typeof s=="string"&&this.meshes.get(s)===t&&this.meshes.delete(s)}for(const t of e.lines)this.group.remove(t),t.geometry.dispose(),t.material instanceof Tn&&t.material.dispose();if(e.tubes!==null){this.group.remove(e.tubes);const t=e.tubes;if(this.tubeSets=this.tubeSets.filter(s=>s.mesh!==t),e.tubes.geometry.dispose(),e.tubes.material instanceof _s){const s=e.tubes.material;this.tubeMaterials=this.tubeMaterials.filter(i=>i!==s),s.dispose()}e.tubes=null}e.meshes=[],e.lines=[]}stars_draw(e){for(const t of e)this.starIndex.has(t.id)||this.starIndex.set(t.id,this.stars.length),this.stars.push(t);for(const t of[!1,!0]){const s=e.filter(u=>u.ember===t);if(s.length===0)continue;const i=new Float32Array(s.length*3),r=new Float32Array(s.length*3),a=new Float32Array(s.length),o=new Float32Array(s.length);s.forEach((u,p)=>{u.layer=this.starLayers.length,u.slot=p,i.set([u.position.x,u.position.y,u.position.z],p*3),r.set([u.color.r,u.color.g,u.color.b],p*3),a[p]=u.radius,o[p]=u.dim?co*1.5:1});const l=new os;l.setAttribute("position",new Ds(i,3)),l.setAttribute("tint",new Ds(r,3)),l.setAttribute("radius",new Ds(a,1));const c=new Ds(o,1);l.setAttribute("alpha",c),this.starLayers.push({alpha:c,base:Float32Array.from(o)});const d=new _s({uniforms:{scale:{value:1},floorPx:{value:wx*window.devicePixelRatio},capPx:{value:yx*window.devicePixelRatio}},vertexShader:vx,fragmentShader:t?xx:Ox,transparent:!0,depthWrite:!1,blending:t?ji:Ci}),h=new Nz(l,d);h.renderOrder=t?2:1,h.frustumCulled=!1,this.group.add(h),this.starMaterials.push(d)}this.starScale_update()}starScale_update(){if(this.starMaterials.length===0)return;const t=this.renderer.domElement.height/(2*Math.tan(this.camera.fov*Math.PI/360));for(const s of this.starMaterials){const i=s.uniforms.scale;i!==void 0&&(i.value=t)}}nebula_add(e,t,s){const i=of(e.count??1),r=new sh(new Ed({map:gf(),color:s.edge,transparent:!0,opacity:e.dim===!0?pf/3:pf,blending:Ci,depthWrite:!1}));r.position.copy(t),r.scale.setScalar(i*2),r.renderOrder=0,this.group.add(r),this.nebulae.push({id:e.id,position:t.clone(),radius:i})}starNode_under(e){if(this.stars.length===0&&this.nebulae.length===0)return null;const t=this.renderer.domElement.getBoundingClientRect(),s=e.clientX-t.left,i=e.clientY-t.top;this.group.updateMatrixWorld(!0),this.camera.updateMatrixWorld();const r=t.height/(2*Math.tan(this.camera.fov*Math.PI/360)),a=new Rt().multiplyMatrices(this.camera.matrixWorldInverse,this.group.matrixWorld),l=new Rt().multiplyMatrices(this.camera.projectionMatrix,a).elements,c=a.elements,d=p=>{const M=-(c[2]*p.x+c[6]*p.y+c[10]*p.z+c[14]);if(M<=0)return null;const _=l[3]*p.x+l[7]*p.y+l[11]*p.z+l[15],m=(l[0]*p.x+l[4]*p.y+l[8]*p.z+l[12])/_,f=(l[1]*p.x+l[5]*p.y+l[9]*p.z+l[13])/_;return{x:(m+1)/2*t.width,y:(1-f)/2*t.height,depth:M}};let h=null,u=1/0;for(const p of this.stars){if(p.dim)continue;const M=d(p.position);if(M===null)continue;const _=Math.max(4,Gm*p.radius*r/M.depth),m=Math.hypot(M.x-s,M.y-i);if(m>_)continue;const f=m/_;f<u&&(u=f,h=p.id)}if(h!==null)return h;for(const p of this.nebulae){const M=d(p.position);if(M!==null&&Math.hypot(M.x-s,M.y-i)<=p.radius*r/M.depth)return p.id}return null}nodeWorld_of(e){const t=this.meshes.get(e);if(t!==void 0){const r=t.geometry;return r.boundingSphere===null&&r.computeBoundingSphere(),{position:t.getWorldPosition(new P),radius:r.boundingSphere?.radius??bs}}const s=this.starIndex.get(e),i=s===void 0?void 0:this.stars[s];return i!==void 0?{position:this.group.localToWorld(i.position.clone()),radius:i.radius}:null}drawnIds(){return[...this.meshes.keys(),...this.starIndex.keys()]}edge_add(e,t,s,i,r,a,o=!1){const l=new os().setFromPoints([s,i]);let c;if(a){const d=new $z({color:r,dashSize:.25,gapSize:.18,transparent:!0,opacity:o?co:.9});c=new Dd(l,d),c.computeLineDistances()}else{const d=new Wi({color:r,transparent:!0,opacity:o?co:.75});c=new Dd(l,d)}this.group.add(c),this.edges.push({line:c,fromId:e,toId:t,dashed:a})}positions_sync(){for(const e of this.dragSimNodes)this.meshes.get(e.id)?.position.set(e.x,e.y,e.z),this.lastPositions.set(e.id,new P(e.x,e.y,e.z));this.tubeSets.length>0&&this.tubes_follow();for(const e of this.edges){const t=this.meshes.get(e.fromId),s=this.meshes.get(e.toId);t===void 0||s===void 0||(e.line.geometry.setFromPoints([t.position,s.position]),e.dashed&&e.line.computeLineDistances())}}viewDrag=null;press_handle(e){if(this.holding||this.flight!==null)return;this.spinIdleUntil=Date.now()+Ti;const t=this.mesh_under(e),s=t?.userData.nodeId;if(t===null||typeof s!="string"){this.viewDrag={lastX:e.clientX,lastY:e.clientY,startX:e.clientX,startY:e.clientY,pan:e.shiftKey||e.button===2||e.button===1,moved:!1};try{this.renderer.domElement.setPointerCapture(e.pointerId)}catch{}this.tip&&(this.tip.hidden=!0);return}const i=this.camera.getWorldDirection(new P).negate();this.group.updateMatrixWorld(!0);const r=new fi().setFromNormalAndCoplanarPoint(i,t.getWorldPosition(new P));this.drag={nodeId:s,plane:r,startX:e.clientX,startY:e.clientY,moved:!1,solo:this.strategy==="ranked",home:t.position.clone()};try{this.renderer.domElement.setPointerCapture(e.pointerId)}catch{}this.tip&&(this.tip.hidden=!0)}dragSim_begin(e){const t=u=>this.meshes.get(u)?.userData.halo===!0,s=u=>this.meshes.get(u)?.userData.dim===!0,i=[],r=new Map;for(const u of this.graph.nodes)for(const p of[...u.parentIds,...u.joinParentIds])!this.meshes.has(p)||!this.meshes.has(u.id)||t(p)||t(u.id)||(i.push({source:p,target:u.id}),r.set(p,[...r.get(p)??[],u.id]),r.set(u.id,[...r.get(u.id)??[],p]));const a=new Set([e]),o=[e];for(;o.length>0;){const u=o.pop();for(const p of r.get(u)??[])a.has(p)||s(p)||(a.add(p),o.push(p))}const l=i.filter(u=>a.has(u.source)&&a.has(u.target));this.dragSimNodes=[...a].map(u=>{const p=this.meshes.get(u);return{id:u,x:p.position.x,y:p.position.y,z:p.position.z}});const c=hf(this.graph.nodes),d=u=>c.get(u)??bs;this.dragSim=Im(this.dragSimNodes,this.projection==="2d"?2:3).force("link",Om(l).id(u=>u.id).distance(u=>d(u.source.id)+d(u.target.id)+1.4)).force("charge",Tm().strength(u=>-6*(d(u.id)/bs)**2).distanceMax(12)).force("collide",vm().radius(u=>d(u.id)*1.2)).alpha(.25).alphaTarget(.08).stop();const h=this.dragSimNodes.find(u=>u.id===e);h&&(h.fx=h.x,h.fy=h.y,h.fz=h.z)}drag_move(e){if(this.drag===null||(this.spinIdleUntil=Date.now()+Ti,!this.drag.moved&&Math.abs(e.clientX-this.drag.startX)+Math.abs(e.clientY-this.drag.startY)>df&&(this.drag.moved=!0,this.drag.solo||this.dragSim_begin(this.drag.nodeId)),!this.drag.moved))return;const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.raycaster.setFromCamera(s,this.camera);const i=new P;if(this.raycaster.ray.intersectPlane(this.drag.plane,i)===null)return;if(this.group.worldToLocal(i),this.drag.solo){const a=this.meshes.get(this.drag.nodeId);a!==void 0&&(a.position.copy(i),this.positions_sync());return}const r=this.dragSimNodes.find(a=>a.id===this.drag?.nodeId);r&&(r.fx=i.x,r.fy=i.y,r.fz=i.z)}view_move(e){if(this.viewDrag===null)return;this.spinIdleUntil=Date.now()+Ti;const t=e.clientX-this.viewDrag.lastX,s=e.clientY-this.viewDrag.lastY;if(this.viewDrag.lastX=e.clientX,this.viewDrag.lastY=e.clientY,!this.viewDrag.moved&&Math.abs(e.clientX-this.viewDrag.startX)+Math.abs(e.clientY-this.viewDrag.startY)>df&&(this.viewDrag.moved=!0,this.touched=!0),!!this.viewDrag.moved)if(this.viewDrag.pan||this.projection==="2d"){const i=this.camera.position.distanceTo(this.focus)*.0016,r=new P().setFromMatrixColumn(this.camera.matrixWorld,0).multiplyScalar(-t*i).add(new P().setFromMatrixColumn(this.camera.matrixWorld,1).multiplyScalar(s*i));this.camera.position.add(r),this.focus.add(r)}else this.turn_about(lf,t*.005),this.turn_about(new P().setFromMatrixColumn(this.camera.matrixWorld,0).normalize(),s*.005)}dragReturns=[];drag_end(){if(this.viewDrag!==null&&(this.viewDrag.moved&&(this.suppressClick=!0),this.viewDrag=null,this.spinIdleUntil=Date.now()+Ti),this.drag===null)return;if(this.spinIdleUntil=Date.now()+Ti,this.drag.moved&&(this.suppressClick=!0),this.drag.solo&&this.drag.moved){const t=this.meshes.get(this.drag.nodeId);t!==void 0&&this.dragReturns.push({mesh:t,from:t.position.clone(),to:this.drag.home.clone(),startedAt:Date.now()})}const e=this.dragSimNodes.find(t=>t.id===this.drag?.nodeId);e&&(e.fx=null,e.fy=null,e.fz=null),this.dragSim?.alphaTarget(0),this.drag=null}mesh_under(e){const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.group.updateMatrixWorld(!0),this.raycaster.setFromCamera(s,this.camera);const i=this.raycaster.intersectObjects([...this.meshes.values()]).filter(o=>o.object.userData.dim!==!0),a=(i.find(o=>o.object.userData.halo!==!0)??i[0])?.object;return a instanceof Ss?a:null}node_under(e){const t=this.meshNode_under(e);return t!==null?t:this.census&&this.censusMesh!==null?this.censusNode_under(e):this.starNode_under(e)}solid_draw(e,t){for(const r of e){this.placedById.set(r.node.id,r);const a=r.node.parentIds.length===0&&r.node.joinParentIds.length===0,o=new Ss(this.sphere_of(r.radius),new Ln({color:Or(r.node,t,a),roughness:.35,metalness:.15}));o.position.copy(r.position),o.userData.nodeId=r.node.id,o.userData.dim=!1,this.group.add(o),this.meshes.set(r.node.id,o)}const s=e.map(r=>r.node.id),i={entries:s.map(r=>({id:r,position:new P,radius:0,color:new Ze,dim:!1,ember:!1})),center:new P,maxRadius:0,mix:1,target:1,meshes:[],lines:[],tubes:null,threadSegments:[]};this.tubes_build(i,new Set(s),t)}meshNode_under(e){const t=this.mesh_under(e)?.userData.nodeId;return typeof t=="string"?t:null}censusNode_under(e){if(this.censusMesh===null)return null;const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.group.updateMatrixWorld(!0),this.raycaster.setFromCamera(s,this.camera);const i=this.raycaster.intersectObject(this.censusMesh)[0];return i===void 0||i.instanceId===void 0?null:(this.censusMesh.setColorAt(i.instanceId,new Ze("#ffffff")),this.censusMesh.instanceColor&&(this.censusMesh.instanceColor.needsUpdate=!0),this.censusIds[i.instanceId]??null)}hover_handle(e){if(this.pointerInside=!0,this.tip===null)return;const t=this.node_under(e),s=typeof t=="string"?this.graph.nodes.find(r=>r.id===t):void 0;if(s===void 0){this.tip.hidden=!0,this.renderer.domElement.style.cursor="",this.hovered=null;return}this.hovered={id:s.id,x:e.clientX,y:e.clientY};const i=this.renderer.domElement.getBoundingClientRect();this.tip.textContent=this.handlers.tip?.(s)??s.label,this.tip.style.left=`${e.clientX-i.left+14}px`,this.tip.style.top=`${e.clientY-i.top+10}px`,this.tip.hidden=!1,this.renderer.domElement.style.cursor="pointer"}pick_handle(e,t){const s=this.hovered,i=s!==null&&Math.hypot(e.clientX-s.x,e.clientY-s.y)<=6?s.id:this.node_under(e);if(i===null){t==="select"&&this.selectedId!==null&&(this.selection_clear(),this.handlers.deselect?.());return}const r=this.graph.nodes.find(a=>a.id===i);r&&(t==="select"?(this.selectedId=i,this.census||this.selection_paint(),this.handlers.select?.(r)):this.handlers.activate?.(r))}}const Rm=24,Pd="argus.dormant";class Bx{constructor(e=Rm,t){this.cap=e,this.store=t,this.rehydrate()}cap;store;groups=new Map;add(e){for(this.groups.delete(e.id),this.groups.set(e.id,e);this.groups.size>this.cap;){const t=this.oldest_id();if(t===void 0)break;this.groups.delete(t)}this.persist()}list(){return[...this.groups.values()].sort((e,t)=>t.lastTouched-e.lastTouched)}get(e){return this.groups.get(e)}has(e){return this.groups.has(e)}dismiss(e){const t=this.groups.delete(e);return t&&this.persist(),t}oldest_id(){let e;for(const t of this.groups.values())(e===void 0||t.lastTouched<e.lastTouched)&&(e=t);return e?.id}persist(){if(this.store!==void 0)try{this.store.setItem(Pd,JSON.stringify([...this.groups.values()]))}catch{}}rehydrate(){if(this.store!==void 0)try{const e=this.store.getItem(Pd);if(e===null)return;const t=JSON.parse(e);if(!Array.isArray(t))return;for(const s of t)s!==null&&typeof s=="object"&&typeof s.id=="string"&&this.groups.set(s.id,s)}catch{}}}function bf(){try{const n=globalThis.localStorage;return n===void 0?void 0:(n.getItem(Pd),n)}catch{return}}class Nx{constructor(e,t){this.host=t,this.grid=e.querySelector(".panes-grid"),this.empty=e.querySelector(".panes-empty"),this.grid.addEventListener("click",this.click_handle)}host;grid;empty;render(){const e=this.host.list();this.empty.hidden=e.length>0,this.grid.replaceChildren(...e.map(t=>this.card_build(t)))}card_build(e){const t=document.createElement("button");t.className="panes-card",t.dataset.restore=e.id,t.title=`restore ${e.label}`;const s=document.createElement("span");if(s.className="panes-card-figure",e.thumbnail!==void 0){const o=document.createElement("img");o.src=e.thumbnail,o.alt="",s.appendChild(o)}else s.classList.add("panes-card-glyph"),s.textContent=e.members.includes("files")&&!e.members.includes("viewer")?"▤":"▣";t.appendChild(s);const i=document.createElement("span");i.className="panes-card-label",i.textContent=e.label,t.appendChild(i);const r=document.createElement("span");r.className="panes-card-badges";for(const o of Cx(e.members)){const l=document.createElement("span");l.className="panes-card-badge",l.textContent=o.toUpperCase(),r.appendChild(l)}t.appendChild(r);const a=document.createElement("button");return a.className="panes-card-dismiss",a.dataset.dismiss=e.id,a.title=`forget ${e.label}`,a.textContent="DISMISS",t.appendChild(a),t}click_handle=e=>{const t=e.target,s=t.closest("[data-dismiss]");if(s!==null){e.stopPropagation();const r=s.dataset.dismiss??"";this.host.dismiss(r),this.render();return}const i=t.closest("[data-restore]");i!==null&&this.host.restore(i.dataset.restore??"")}}function Cx(n){return[...new Set(n)]}const xn=["#000000","#f24444","#33cc66","#ffaa44","#5599ff","#cc88ff","#44cccc","#ffeecc","#777777","#ff6666","#66ee99","#ffcc66","#77bbff","#dd99ff","#66dddd","#ffffff"],Px={yellow:xn[3],white:xn[7],cyan:xn[6],green:xn[2],magenta:xn[5]};function Bm(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,inverse:!1,underline:!1}}function Wx(n){if(n<16)return xn[n]??"#ffeecc";if(n<232){const t=n-16,s=[0,95,135,175,215,255],i=s[Math.floor(t/36)%6]??0,r=s[Math.floor(t/6)%6]??0,a=s[t%6]??0;return`#${(i<<16|r<<8|a).toString(16).padStart(6,"0")}`}const e=8+(n-232)*10;return`#${(e<<16|e<<8|e).toString(16).padStart(6,"0")}`}function Lx(n,e){for(let t=0;t<e.length;t++){const s=e[t]??0;if(s===0)Object.assign(n,Bm());else if(s===1)n.bold=!0;else if(s===2)n.dim=!0;else if(s===3)n.italic=!0;else if(s===4)n.underline=!0;else if(s===7)n.inverse=!0;else if(s===27)n.inverse=!1;else if(s===22)n.bold=!1,n.dim=!1;else if(s===23)n.italic=!1;else if(s===24)n.underline=!1;else if(s>=30&&s<=37)n.fg=xn[s-30]??null;else if(s>=90&&s<=97)n.fg=xn[s-90+8]??null;else if(s===39)n.fg=null;else if(s>=40&&s<=47)n.bg=xn[s-40]??null;else if(s>=100&&s<=107)n.bg=xn[s-100+8]??null;else if(s===49)n.bg=null;else if(s===38||s===48){const i=e[t+1]??0;let r=null;if(i===5)r=Wx(e[t+2]??0),t+=2;else if(i===2){const a=e[t+2]??0,o=e[t+3]??0,l=e[t+4]??0;r=`#${(a<<16|o<<8|l).toString(16).padStart(6,"0")}`,t+=4}s===38?n.fg=r:n.bg=r}}}function kx(n){const e=[],t=n.inverse?n.bg??"#000":n.fg,s=n.inverse?n.fg??"var(--daybreak)":n.bg;return t!==null&&e.push(`color:${t}`),s!==null&&e.push(`background-color:${s}`),n.bold&&e.push("font-weight:bold"),n.dim&&e.push("opacity:0.55"),n.italic&&e.push("font-style:italic"),n.underline&&e.push("text-decoration:underline"),e.join(";")}function Hs(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const mc=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;function Vn(n){const e=Bm();let t="",s=0;const i=a=>{if(a.length===0)return;const o=kx(e),l=Hs(a.replace(/\r/g,""));t+=o.length>0?`<span style="${o}">${l}</span>`:l};mc.lastIndex=0;let r=mc.exec(n);for(;r!==null;){if(i(n.slice(s,r.index)),s=r.index+r[0].length,r[2]==="m"){const a=(r[1]??"").split(/[;:]/).map(o=>o.length>0?Number(o):0);Lx(e,a)}r=mc.exec(n)}return i(n.slice(s)),t}function Ux(n){for(const[e,t]of Object.entries(Px))n.style.setProperty(`--console-${e}`,t)}const Fx="G1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7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1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzk7MTc7MjRtIBtbMG0bWzM4OzI7MjM7NDU7NjJtLhtbMG0bWzM4OzI7NDE7Nzk7MTA5bTobWzBtG1szODsyOzU5OzExMzsxNTVtPRtbMG0bWzM4OzI7NzU7MTQ0OzE5NW0rG1swbRtbMzg7Mjs3NjsxNDQ7MTkzbSsbWzBtG1szODsyOzE0OzI3OzM3bSAbWzBtG1szODsyOzc1OzE0MjsxODltKxtbMG0bWzM4OzI7Nzc7MTQ1OzE5Mm0rG1swbRtbMzg7Mjs2NzsxMjY7MTY1bT0bWzBtG1szODsyOzU1OzEwMjsxMzRtLRtbMG0bWzM4OzI7NDE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sxODE7MjI0bSobWzBtG1szODsyOzEwMTsxODM7MjI0bSobWzBtG1szODsyOzkzOzE2ODsyMDVtKxtbMG0bWzM4OzI7ODE7MTQ4OzE3OW0rG1swbRtbMzg7Mjs2ODsxMjM7MTQ4bT0bWzBtG1szODsyOzUxOzkzOzExMm0tG1swbRtbMzg7MjszNDs2MTs3M206G1swbRtbMzg7MjsyMjs0MDs0N20uG1swbRtbMzg7Mjs5OzE2OzE5bSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7Mjsw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tbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swb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swOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtCg==",jx=/\x1b\[[0-9;]*m/g,zf="\x1B[0m",_f="\x1B[7m",Nm=atob(Fx).trimEnd().split(`
4189
- `);Nm.map(n=>n.replace(jx,""));function Vx(n){const e=n.replace(/\x1b\[0m/g,`${zf}${_f}`);return`${_f}${e}${zf}`}function $x(n,e=!1){const t=Nm;return e?t.map(Vx):t}function Cm(n){const e=n.lastIndexOf("/");return e<=0?"/":n.slice(0,e+1)}function Hx(n){const e=new URLSearchParams(n.search).get("ws");return e!==null&&e.length>0?e:`${n.protocol==="https:"?"wss":"ws"}://${n.host}${Cm(n.pathname)}`}function qE(n,e){return new URL(n,e).href}function Mu(n,e){const t=`path=${encodeURIComponent(n)}`;return e.length>0?`vfs?${t}&token=${encodeURIComponent(e)}`:`vfs?${t}`}function qx(n,e){return`${Mu(n,e)}&download=1`}function Pm(n){return new URLSearchParams(n).has("door")}function wf(n,e){const s=Cm(n).split("/").filter(i=>i.length>0).slice(0,-2);return`/${s.length>0?`${s.join("/")}/`:""}${e}`}const Xx="daemon";class gu{socket;handlers;token;pending=new Map;pendingCompletions=new Map;silentIds=new Set;nextId=0;constructor(e,t,s){this.socket=e,this.handlers=t,this.token=s,this.socket.onmessage=i=>this.message_handle(String(i.data)),this.socket.onclose=()=>this.handlers.close_handle?.()}static session_attach(e,t,s){return new Promise((i,r)=>{const a=new WebSocket(e);a.onerror=()=>r(new Error(`cannot reach the daemon at ${e}`)),a.onopen=()=>{a.send(JSON.stringify({type:"attach",protocolVersion:Ec,token:t,capabilities:{shellCommands:!1,color:!0,hiddenInput:!0,fileDelivery:!0,localFilesystem:!1}}))},a.onmessage=o=>{const l=yf(String(o.data));if(!l){r(new Error("invalid attach response")),a.close();return}if(l.type==="error"){r(new Error(l.reason)),a.close();return}if(l.type!=="attached"){r(new Error(`unexpected attach response: ${l.type}`)),a.close();return}const c=new gu(a,s,t);i({client:c,attach:{session:l.session,protocolVersion:l.protocolVersion,...l.stack!==void 0?{stack:l.stack}:{},...l.hostControl!==void 0?{hostControl:l.hostControl}:{}}})}})}line_execute(e,t){const s=`argus-${this.nextId++}`;return t?.silent===!0&&this.silentIds.add(s),new Promise((i,r)=>{this.pending.set(s,{resolve:i,reject:r,liveChannels:new Set,observed:t?.observe!==!1}),this.socket.send(JSON.stringify({type:"execute",id:s,line:e,...t?.silent===!0?{instrument:!0}:{}}))})}line_complete(e){const t=`argus-c-${this.nextId++}`;return new Promise((s,i)=>{this.pendingCompletions.set(t,{resolve:s,reject:i}),this.socket.send(JSON.stringify({type:"complete",id:t,prefix:e}))})}regard_send(e){this.socket.send(JSON.stringify({type:"regard",regard:e}))}watch_send(e){this.socket.send(JSON.stringify({type:"watch",subject:e}))}unwatch_send(e){this.socket.send(JSON.stringify({type:"unwatch",subject:e}))}connection_close(){this.socket.close()}message_handle(e){const t=yf(e);if(t)switch(t.type){case"result":{this.silentIds.delete(t.id);const s=this.pending.get(t.id);if(s&&(this.pending.delete(t.id),s.resolve({envelopes:t.envelopes,liveChannels:s.liveChannels})),s===void 0||s.observed)for(const i of t.envelopes)this.handlers.envelope_observe?.(i);break}case"complete":{const s=this.pendingCompletions.get(t.id);s&&(this.pendingCompletions.delete(t.id),s.resolve({candidates:t.candidates,prefix:t.prefix}));break}case"output":{(t.channel==="data"||t.channel==="err")&&this.pending.get(t.id)?.liveChannels.add(t.channel),this.silentIds.has(t.id)||this.handlers.output_receive?.(t.channel,t.chunk);break}case"progress":{this.handlers.progress_receive?.(t);break}case"session":{if(t.surface===Xx){this.handlers.ambient_receive?.(t.envelope);break}this.handlers.session_receive?.(t.surface,t.envelope),this.handlers.envelope_observe?.(t.envelope);break}case"watched":{this.handlers.watched_receive?.(t.subject,t.state);break}case"numbered":{this.handlers.numbered_receive?.({id:t.id,source:t.source,rows:t.rows,handles:t.handles});break}case"promptline":{this.handlers.promptline_receive?.(t.context);break}case"telemetry":{this.handlers.telemetry_receive?.(t.index,{lane:t.lane,cube:t.cube,state:t.state});break}case"regard":{this.handlers.regard_receive?.(t.regard);break}case"error":{if(t.id!==void 0){const s=this.pending.get(t.id);s&&(this.pending.delete(t.id),s.reject(new Error(t.reason)));const i=this.pendingCompletions.get(t.id);i&&(this.pendingCompletions.delete(t.id),i.reject(new Error(t.reason)))}break}case"prompt":{const s=this.handlers.ask_receive;if(s===void 0){this.reply_send({type:"promptError",promptId:t.promptId,reason:"this surface has no way to ask"});break}const i=t.promptId;s({message:t.message,kind:kg(t),...t.path?.suggest===void 0?{}:{suggest:t.path.suggest},...t.path===void 0?{}:{path:t.path},...t.commit===void 0?{}:{commit:t.commit}}).then(r=>{if(r===null){this.reply_send({type:"promptError",promptId:i,reason:"the operator abandoned the question"});return}this.reply_send({type:"promptAnswer",promptId:i,answer:r})}).catch(r=>{const a=r instanceof Error?r.message:"the question could not be answered";this.reply_send({type:"promptError",promptId:i,reason:a})});break}case"pipe":{this.reply_send({type:"pipeError",pipeId:t.pipeId,reason:"the argus surface cannot run pipeline segments"});break}case"shell":{this.reply_send({type:"shellError",shellId:t.shellId,reason:"the argus surface cannot run shell commands"});break}case"edit":{this.reply_send({type:"editError",editId:t.editId,reason:"the argus surface cannot open an editor"});break}case"deliver":{this.deliver_run(t);break}}}async deliver_run(e){try{const t=Mu(e.path,this.token),s=await fetch(t);if(!s.ok)throw new Error(`calypso refused to serve this file (HTTP ${s.status})`);const i=await s.blob(),r=URL.createObjectURL(i),a=document.createElement("a");a.href=r,a.download=e.filename,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),this.reply_send({type:"deliverResult",deliverId:e.deliverId,location:e.filename,bytes:i.size})}catch(t){const s=t instanceof Error?t.message:String(t);this.reply_send({type:"deliverError",deliverId:e.deliverId,reason:s})}}reply_send(e){this.socket.send(JSON.stringify(e))}}function yf(n){try{const e=Kg(JSON.parse(n));return e.ok&&e.value!==void 0?e.value:null}catch{return null}}const Gi={pacs:{bg:"#875FFF",fg:"#FFFFFF"},host:{bg:"#00AFFF",fg:"#001018"},user:{bg:"#00D787",fg:"#00140C"},dir:{bg:"#FFD75F",fg:"#201800"},physical:{bg:"#FF5F5F",fg:"#1B0000"},duration:{bg:"#FF8700",fg:"#201000"},status:{bg:"#FF005F",fg:"#FFFFFF"}},Yx={cold:{icon:"",label:"proc cold",color:{bg:"#FF8700",fg:"#201000"}},cached:{icon:"",label:"proc cached, refreshing",color:{bg:"#5F5F87",fg:"#FFFFFF"}},failed:{icon:"",label:"proc failed",color:{bg:"#FF005F",fg:"#FFFFFF"}}},kn={powerline:"",cube:"",database:"",user:"",folder:"",microscope:"",bolt:"",error:""},Kx=3e3,Zx=200;class Qx{output;splashGreeting=null;progressRegion;promptBar;inputGlyph;input;submit;complete;promptContext=null;busy=!0;pendingAsk=null;queuedLines=[];questionOpen=!1;history=[];historyIndex=0;streamBlock=null;streamPendingElement=null;streamPendingText="";streamPendingChannel="data";constructor(e,t,s){this.submit=t,this.complete=s,e.innerHTML=`
4188
+ }`;let fc=null;function pc(){return fc===null&&(fc=new au(1,1,1,10,1,!0)),fc}let po=null;function gf(){if(po!==null)return po;const n=document.createElement("canvas");n.width=128,n.height=128;const e=n.getContext("2d");if(e!==null){const t=e.createRadialGradient(64,64,0,64,64,64);t.addColorStop(0,"rgba(255,255,255,1)"),t.addColorStop(.35,"rgba(255,255,255,0.45)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,128,128)}return po=new Cz(n),po}class _l{container;handlers;ambient;renderer;scene;camera;group=new ma;raycaster=new Qz;meshes=new Map;lastPositions=new Map;frozen=new Set;physicsOnce=void 0;census=!1;physics={...ol};physics_set(e,t=!0){this.physics={...this.physics,...e},t&&this.rebuild()}physics_get(){return{...this.physics}}censusMesh=null;censusIds=[];censusPositions=[];censusBase=null;census_set(e){this.census!==e&&(this.census=e,this.rebuild(!0,"hold"))}census_get(){return this.census}edges=[];graph={nodes:[]};spinIdleUntil=0;drag=null;dragSim=null;dragSimNodes=[];suppressClick=!1;waveTimes=new Map;waveStartAt=null;flight=null;flightHome=null;holding=!1;touched=!1;focus=new P;turn_about(e,t){const s=new Qi().setFromAxisAngle(e,t);this.group.position.sub(this.focus).applyQuaternion(s).add(this.focus),this.group.quaternion.premultiply(s)}drawMode="spheres";stars=[];starIndex=new Map;nebulae=[];starMaterials=[];starLayers=[];threadColor=null;handoff=new Map;placedById=new Map;handoffAt=0;tubeMaterials=[];tubeSets=[];tubesStale=!1;lampGlows=new Map;pointerInside=!1;touches=new Map;pinch=null;gestureHeld=!1;lastTap=null;pressKind="mouse";tapActivatedAt=0;tapTipTimer=null;hovered=null;fits=0;strategy="ranked";selectedId=null;frameHandle=null;disposed=!1;tip=null;tumbleAxis=new P(0,1,0);tumblePhase=Math.random()*Math.PI*2;pulseColor=new Ze("#48d8f0");constructor(e,t={},s={}){this.container=e,this.handlers=t,this.ambient=s.ambient===!0,this.renderer=new Xv({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("dag-scene-canvas"),this.scene=new vz,this.camera=new tn(50,1,.1,200),this.camera.position.set(0,0,14),this.scene.add(new Yz(16777215,.9));const i=new Xz(16777215,1.2);if(i.position.set(4,6,8),this.scene.add(i),this.scene.add(this.group),e.appendChild(this.renderer.domElement),this.size_fit(),!this.ambient){this.renderer.domElement.style.touchAction="none",this.renderer.domElement.addEventListener("click",o=>{if(this.suppressClick){this.suppressClick=!1;return}if(this.pressKind==="touch"){const l=Date.now(),c=this.lastTap;if(c!==null&&l-c.at<=mx&&Math.hypot(o.clientX-c.x,o.clientY-c.y)<=Mx){this.lastTap=null,this.tapActivatedAt=l,this.pick_handle(o,"activate");return}this.lastTap={at:l,x:o.clientX,y:o.clientY}}this.pick_handle(o,"select")}),this.renderer.domElement.addEventListener("dblclick",o=>{Date.now()-this.tapActivatedAt<600||this.pick_handle(o,"activate")}),this.renderer.domElement.addEventListener("pointerdown",o=>{if(this.pressKind=o.pointerType,o.pointerType==="touch"){if(o.isPrimary&&(this.touches.clear(),this.pinch=null,this.gestureHeld=!1),this.touches.set(o.pointerId,{x:o.clientX,y:o.clientY}),this.touches.size===2){this.gesture_begin();return}if(this.touches.size>2||this.gestureHeld)return;this.press_handle(o),this.hover_handle(o);return}this.press_handle(o)});const a=o=>{o.pointerType==="touch"&&(this.touches.delete(o.pointerId),this.touches.size<2&&(this.pinch=null),this.touches.size===0&&this.gestureHeld&&(this.gestureHeld=!1,this.suppressClick=!0,window.setTimeout(()=>{this.suppressClick=!1},400))),this.drag_end()};this.renderer.domElement.addEventListener("pointerup",a),this.renderer.domElement.addEventListener("pointercancel",a),this.tip=document.createElement("div"),this.tip.className="dag-node-tip",this.tip.hidden=!0,e.appendChild(this.tip),this.renderer.domElement.addEventListener("pointermove",o=>{if(o.pointerType==="touch"&&this.touches.has(o.pointerId)){if(this.touches.set(o.pointerId,{x:o.clientX,y:o.clientY}),this.pinch!==null){this.gesture_move();return}if(this.gestureHeld)return}this.drag!==null?this.drag_move(o):this.viewDrag!==null?this.view_move(o):this.hover_handle(o)}),this.renderer.domElement.addEventListener("pointerleave",o=>{if(this.pointerInside=!1,this.hovered=null,o.pointerType==="touch"&&this.tip!==null&&!this.tip.hidden){this.tapTipTimer!==null&&window.clearTimeout(this.tapTipTimer),this.tapTipTimer=window.setTimeout(()=>{this.tapTipTimer=null,this.tip!==null&&this.touches.size===0&&(this.tip.hidden=!0)},gx);return}this.tip&&(this.tip.hidden=!0)}),this.renderer.domElement.addEventListener("wheel",o=>{o.preventDefault(),this.camera_dolly(o.deltaY)},{passive:!1}),this.renderer.domElement.addEventListener("contextmenu",o=>o.preventDefault())}new ResizeObserver(()=>this.size_fit()).observe(e);const r=()=>{if(!this.disposed){if(this.ambient)this.tumblePhase+=px,this.tumbleAxis.set(Math.sin(this.tumblePhase*.7),Math.cos(this.tumblePhase*.4)+.6,Math.sin(this.tumblePhase*.3)*.8).normalize(),this.group.rotateOnWorldAxis(this.tumbleAxis,fx),this.wave_animate();else{if(Date.now()>=this.spinIdleUntil&&!this.pointerInside&&!this.holding&&this.flight===null&&this.projection==="3d"&&this.turn_about(lf,hx),this.dragSim!==null&&(this.drag!==null||this.dragSim.alpha()>.02?(this.dragSim.tick(),this.positions_sync()):(this.dragSim=null,this.dragSimNodes=[])),this.dragReturns.length>0){const a=Date.now();this.dragReturns=this.dragReturns.filter(o=>{const l=Math.min(1,(a-o.startedAt)/300),c=l*l*(3-2*l);return o.mesh.position.lerpVectors(o.from,o.to,c),l<1}),this.positions_sync()}this.wave_animate(),this.flight_animate()}if(this.starScale_update(),this.handoff_step(),this.tubeMaterials.length>0){const a=performance.now();for(const o of this.tubeMaterials){const l=o.uniforms.time;l!==void 0&&(l.value=a)}this.tubesStale&&this.tubes_restatus(),this.lamps_animate(a)}this.renderer.render(this.scene,this.camera),this.frameHandle=window.requestAnimationFrame(r)}};r()}graph_set(e,t={}){this.graph=e,this.frozen=new Set(t.frozen??[]),this.physicsOnce=t.physics,this.rebuild(t.fit!==!1,t.settle??"full"),t.wave!==!1&&this.wave_start()}waveLooping=!1;waveLoop_set(e){this.waveLooping=e,e&&this.wave_start()}waveLoop_get(){return this.waveLooping}positions_get(){const e={};for(const[t,s]of this.lastPositions)e[t]=[Math.round(s.x*100)/100,Math.round(s.y*100)/100,Math.round(s.z*100)/100];return e}positions_seed(e){this.lastPositions=new Map(Object.entries(e).map(([t,[s,i,r]])=>[t,new P(s,i,r)]))}wave_start(){this.waveTimes=this.waveSchedule_compute(),this.waveStartAt=this.waveTimes.size>0?Date.now():null}flight_into(e,t){const s=this.meshes.get(e),i=s===void 0?this.censusIds.indexOf(e):-1;if(s===void 0&&i<0||this.flight!==null||this.holding)return;this.holding=!0,this.flightHome={position:this.camera.position.clone(),quaternion:this.camera.quaternion.clone()},this.group.updateMatrixWorld(!0);const r=s!==void 0?s.getWorldPosition(new P):this.group.localToWorld((this.censusPositions[i]??new P).clone()),a=r.clone().add(this.camera.position.clone().sub(r).normalize().multiplyScalar(.4)),o=this.camera.clone();o.position.copy(this.camera.position),o.lookAt(r),this.flight={fromPos:this.camera.position.clone(),toPos:a,fromQuat:this.camera.quaternion.clone(),toQuat:o.quaternion.clone(),startedAt:Date.now(),durationMs:700,onDone:t}}camera_flyToFit(e,t,s,i=1,r=1.15){const a=new Set(e),o=[];let l=0;this.group.updateMatrixWorld(!0);for(const z of this.drawnIds()){if(a.size>0&&!a.has(z))continue;const O=this.nodeWorld_of(z);O!==null&&(o.push(O.position),l=Math.max(l,O.radius))}if(o.length===0){s();return}const c=new P;for(const z of o)c.add(z);c.divideScalar(o.length);const d=o.map(z=>c.distanceTo(z)).sort((z,O)=>z-O),h=Math.max(1,Math.min(d.length,Math.ceil(d.length*Math.min(1,Math.max(.1,i))))),u=Math.max(1,(d[h-1]??1)+l),p=this.camera.fov*Math.PI/180,M=u/Math.tan(p/2),_=u/(Math.tan(p/2)*Math.max(.1,this.camera.aspect)),m=Math.max(3,Math.max(M,_)*r),f=this.camera.position.clone().sub(c);f.lengthSq()<1e-4&&f.set(0,0,1),f.normalize();const S=c.clone().add(f.multiplyScalar(m)),v=this.camera.clone();v.position.copy(S),v.lookAt(c),this.focus.copy(c),this.camera.far=Math.max(this.camera.far,(m+u)*2),this.camera.updateProjectionMatrix(),this.flight={fromPos:this.camera.position.clone(),toPos:S,fromQuat:this.camera.quaternion.clone(),toQuat:v.quaternion.clone(),startedAt:Date.now(),durationMs:t,onDone:s}}camera_touched(){return this.touched}draw_set(e){e!==this.drawMode&&(this.drawMode=e,this.rebuild(!1,"hold"))}draw_get(){return this.drawMode}state_get(){const e=this.graph.nodes.filter(i=>i.solid===!0).map(i=>i.id),t=e.filter(i=>this.meshes.has(i)).length;let s=0;for(const i of this.handoff.values())i.mix>0&&(s+=1);return{draw:this.drawMode,arrangement:this.arrangement,census:this.census,nodes:this.graph.nodes.length,meshes:this.meshes.size,stars:this.stars.length,solidMarked:e.length,solidDrawn:t,tubes:this.tubeMaterials.length,handoffGroups:this.handoff.size,handoffSolid:s,camera:this.camera.position.distanceTo(this.focus).toFixed(1),settling:this.slicing}}camera_flyToward(e,t,s,i){const r=this.nodeWorld_of(e);if(r===null){i();return}const a=r.position,o=this.camera.position.clone().sub(a);o.lengthSq()<1e-4&&o.set(0,0,1),o.normalize();const l=a.clone().add(o.multiplyScalar(Math.max(t,r.radius*4))),c=this.camera.clone();c.position.copy(l),c.lookAt(a),this.focus.copy(a),this.flight={fromPos:this.camera.position.clone(),toPos:l,fromQuat:this.camera.quaternion.clone(),toQuat:c.quaternion.clone(),startedAt:Date.now(),durationMs:s,onDone:i}}holding_get(){return this.holding}flight_back(e){if(this.flightHome===null){this.holding=!1,e();return}const t=this.flightHome;this.flight={fromPos:this.camera.position.clone(),toPos:t.position.clone(),fromQuat:this.camera.quaternion.clone(),toQuat:t.quaternion.clone(),startedAt:Date.now(),durationMs:700,onDone:()=>{this.flightHome=null,this.holding=!1,this.spinIdleUntil=Date.now()+hi,e()}}}flight_animate(){if(this.flight===null)return;const e=(Date.now()-this.flight.startedAt)/this.flight.durationMs,t=Math.min(1,e),s=t*t*(3-2*t);if(this.camera.position.lerpVectors(this.flight.fromPos,this.flight.toPos,s),this.camera.quaternion.slerpQuaternions(this.flight.fromQuat,this.flight.toQuat,s),t>=1){const i=this.flight.onDone;this.flight=null,i()}}waveSchedule_compute(){const e=new Map,t=new Set(this.graph.nodes.map(r=>r.id)),s=r=>r.status===void 0||r.status==="finishedSuccessfully"||r.status==="finishedWithError";let i=!1;for(;!i;){i=!0;for(const r of this.graph.nodes){if(e.has(r.id)||!s(r))continue;const a=[...r.parentIds,...r.joinParentIds].filter(l=>t.has(l));if(!a.every(l=>e.has(l)))continue;const o=a.reduce((l,c)=>Math.max(l,e.get(c)??0),-uo);e.set(r.id,o+uo),i=!1}}return e}wave_animate(){if(this.waveStartAt===null)return;const e=Date.now()-this.waveStartAt;let t=0;if(this.census&&this.censusMesh!==null&&this.censusBase!==null&&this.censusMesh.instanceColor){const s=this.censusMesh.instanceColor.array,i=this.censusBase,r=this.pulseColor;for(let a=0;a<this.censusIds.length;a++){const o=this.waveTimes.get(this.censusIds[a]??"");if(o===void 0)continue;t=Math.max(t,o);const l=e-o,c=l>=0&&l<=vr?Math.sin(l/vr*Math.PI):0,d=a*3;s[d]=i[d]+(r.r-i[d])*c,s[d+1]=i[d+1]+(r.g-i[d+1])*c,s[d+2]=i[d+2]+(r.b-i[d+2])*c}this.censusMesh.instanceColor.needsUpdate=!0,e>t+vr&&(this.waveStartAt=this.ambient||this.waveLooping?Date.now()+cf:null);return}for(const[s,i]of this.waveTimes){t=Math.max(t,i);const r=this.meshes.get(s);if(r===void 0||!(r.material instanceof Ln))continue;const a=e-i,o=a>=0&&a<=vr?Math.sin(a/vr*Math.PI):0;r.scale.setScalar(1+o*.45),o>0?(r.material.emissive.copy(this.pulseColor),r.material.emissiveIntensity=o*1.2):(r.material.emissive.setScalar(s===this.selectedId?1:0),r.material.emissiveIntensity=s===this.selectedId?.35:0)}e>t+vr&&(this.waveStartAt=this.ambient||this.waveLooping?Date.now()+cf:null)}strategy_set(e){this.strategy=e,this.rebuild()}selection_clear(){this.selectedId=null,this.selection_paint()}selection_paint(){for(const[e,t]of this.meshes){if(!(t.material instanceof Ln))continue;const s=e===this.selectedId;t.material.emissive.set(s?"#ffffff":"#000000"),t.material.emissiveIntensity=s?.35:0}}strategy_get(){return this.strategy}projection="3d";projection_set(e){this.projection=e,e==="2d"&&this.group.quaternion.identity(),this.rebuild()}projection_get(){return this.projection}status_update(e,t){const s=this.graph.nodes.find(r=>r.id===e);if(!s||s.status===t)return;s.status=t;const i=this.meshes.get(e);if(i&&i.material instanceof Ln){const r=s.parentIds.length===0&&s.joinParentIds.length===0;i.material.color=Or(s,ho(),r),delete i.userData.lampBase}this.tubeSets.some(r=>r.members.has(e))&&(this.tubesStale=!0)}palette_refresh(){this.rebuild(!0,"hold")}size_fit(){const e=Math.max(1,this.container.clientWidth),t=Math.max(1,this.container.clientHeight);this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix()}dispose(){this.disposed=!0,this.layoutWorker?.terminate(),this.layoutWorker=null,this.frameHandle!==null&&window.cancelAnimationFrame(this.frameHandle),this.renderer.dispose(),this.renderer.domElement.remove()}censusBuild(e,t,s=!0){let i=0;for(const f of e)f.node.ghost!==!0&&(i+=Math.max(1,f.node.count??1));const r=new lu(1,1),a=new Ln({color:"#ffffff",roughness:.5,metalness:.1}),o=this.drawMode==="stars",l=[],c=new lh(r,a,o?1:i),d=new Ze,h=new es,u=new Map;let p=0,M=1;const _=new P;for(const f of e)_.add(f.position);_.divideScalar(Math.max(1,e.length));for(const{node:f,position:S,radius:v}of e){if(f.ghost===!0)continue;const z=Math.max(1,f.count??1),O=z===1?0:v*(1.6+.55*Math.cbrt(z)),x=z===1?v:Math.max(.06,Math.min(v*.5,2.2*O/Math.sqrt(z))),G=[];for(let b=0;b<z;b++){const T=z===1?S.clone():_x(b,z,O).add(S);G.push(T);const N=f.parentIds.length===0&&f.joinParentIds.length===0;d.set(Or(f,t,N)),o?l.push({id:f.id,position:T,radius:x,color:d.clone(),dim:f.dim===!0,ember:f.share!==void 0&&f.share>0||f.status==="finishedWithError"}):(h.position.copy(T),h.scale.setScalar(x),h.updateMatrix(),c.setMatrixAt(p,h.matrix),c.setColorAt(p,d)),this.censusIds.push(f.id),this.censusPositions.push(T),p+=1,M=Math.max(M,_.distanceTo(T)+x)}u.set(f.id,G)}o?this.stars_draw(l):(c.instanceColor&&(c.instanceColor.needsUpdate=!0),this.group.add(c),this.censusMesh=c,this.censusBase=c.instanceColor?Float32Array.from(c.instanceColor.array):null);const m=[];for(const{node:f}of e){const S=u.get(f.id)??[];for(const v of f.parentIds){const z=u.get(v);if(!(!z||z.length===0))for(let O=0;O<S.length;O++){const x=S[O],G=z.length===S.length?z[O]:z[O%z.length];x===void 0||G===void 0||m.push(x.x,x.y,x.z,G.x,G.y,G.z)}}}if(m.length>0){const f=new os;f.setAttribute("position",new Ht(m,3));const S=new fh(f,o?new Wi({color:t.edge,transparent:!0,opacity:ff,blending:Ci,depthWrite:!1}):new Wi({color:t.edge,transparent:!0,opacity:.35}));this.group.add(S)}if(!this.ambient&&s){const f=this.camera.fov*Math.PI/180,S=M/Math.tan(f/2),v=M/(Math.tan(f/2)*Math.max(.1,this.camera.aspect)),z=Math.max(8,Math.max(S,v)*1.15);this.group.position.copy(_).applyQuaternion(this.group.quaternion).negate(),this.focus.set(0,0,0),this.camera.position.set(z*.5,z*.4,z*.85),this.camera.far=Math.max(200,(z+M)*2.5),this.camera.updateProjectionMatrix(),this.camera.lookAt(0,0,0)}}camera_fit(e){if(e.length===0)return;this.touched=!1,this.fits+=1,this.renderer.domElement.dataset.fits=String(this.fits);const t=new P;for(const d of e)t.add(d.position);t.divideScalar(e.length);const s=e.map(d=>t.distanceTo(d.position)+d.radius).sort((d,h)=>d-h),i=this.handlers.handoffKey!==void 0?.95:1,r=Math.max(1,s[Math.max(0,Math.ceil(s.length*i)-1)]??1),a=this.camera.fov*Math.PI/180,o=r/Math.tan(a/2),l=r/(Math.tan(a/2)*Math.max(.1,this.camera.aspect)),c=Math.max(8,Math.max(o,l)*1.15);this.group.position.copy(t).applyQuaternion(this.group.quaternion).negate(),this.focus.set(0,0,0),this.camera.position.set(0,0,c),this.camera.far=Math.max(200,(c+r)*2),this.camera.updateProjectionMatrix(),this.camera.lookAt(0,0,0)}spheres=new Map;sphere_of(e){const t=Math.round(e*1e3);let s=this.spheres.get(t);return s===void 0&&(s=new il(t/1e3,24,18),s.computeBoundingSphere(),this.spheres.set(t,s)),s}rebuildGen=0;slicing=!1;rebuild(e=!0,t="full"){const s=++this.rebuildGen;if(this.slicing&&(this.slicing=!1,this.handlers.progress?.(1,1,0)),this.strategy!=="molecule"){this.draw(wx(this.graph.nodes),e);return}let i=this.frozen;if(t!=="full"&&i.size===0){const h=this.graph.nodes.map(u=>u.id).filter(u=>this.lastPositions.has(u));h.length>0&&(i=new Set(h))}const r=yx(this.graph.nodes,this.projection==="2d"?2:3,this.lastPositions,this.physicsOnce!==void 0?{...this.physics,...this.physicsOnce}:this.physics,i),a=this.graph.nodes.length,o=this.handlers.progress,l=r.total*r.moving<vx;if((!l||this.arrangement!=="galaxy")&&o!==void 0&&this.handlers.handoffKey!==void 0&&this.frozen.size===0){this.hierarchy_run(s,e,i,o);return}if(o===void 0||l){r.step(r.total),this.draw(r.place(),e);return}let c=0;this.slicing=!0,o(0,r.total,a);const d=()=>{if(s!==this.rebuildGen||this.disposed)return;const h=performance.now();for(;c<r.total&&performance.now()-h<Ox;)r.step(1),c+=1;if(c<r.total){o(c,r.total,a),window.requestAnimationFrame(d);return}this.slicing=!1,this.draw(r.place(),e),o(r.total,r.total,a)};window.requestAnimationFrame(d)}layoutWorker=null;arrangement="galaxy";arrangementMemory=new Map;arrangement_set(e,t){if(e===this.arrangement)return;this.arrangementMemory.set(this.arrangement,new Map(this.lastPositions)),this.arrangement=e;let s=this.arrangementMemory.get(e);s===void 0&&t!==void 0&&Object.keys(t).length>0&&(s=new Map(Object.entries(t).map(([i,[r,a,o]])=>[i,new P(r,a,o)]))),this.lastPositions=s??new Map,this.rebuild(!0,s===void 0?"full":"hold")}arrangement_get(){return this.arrangement}hierarchy_run(e,t,s,i){const r=this.handlers.handoffKey;if(r===void 0)return;const a=hf(this.graph.nodes),o=this.graph.nodes.map(u=>{const p=this.lastPositions.get(u.id);return{id:u.id,parents:[...u.parentIds,...u.joinParentIds],radius:a.get(u.id)??bs,group:u.ghost===!0?null:r(u),...p===void 0?{}:{seed:[p.x,p.y,p.z]},...s.has(u.id)?{frozen:!0}:{}}}),l=1e3,c=o.length;this.slicing=!0,i(0,l,c),this.layoutWorker===null&&(this.layoutWorker=new Worker(new URL(""+new URL("layoutWorker-DqMRqv-I.js",import.meta.url).href,import.meta.url),{type:"module"}));const d=this.layoutWorker,h=this.physicsOnce!==void 0?{...this.physics,...this.physicsOnce}:this.physics;d.onmessage=u=>{const p=u.data;if(p.generation!==this.rebuildGen||this.disposed)return;if(p.type==="progress"){i(Math.min(l-1,Math.floor((p.fraction??0)*l)),l,c);return}const M=p.positions??{},_=this.graph.nodes.map(m=>{const f=M[m.id]??[0,0,0];return{node:m,position:new P(f[0],f[1],f[2]),radius:a.get(m.id)??bs}});this.slicing=!1,this.draw(_,t),i(l,l,c)},d.postMessage({generation:e,nodes:o,physics:h,arrangement:this.arrangement})}draw(e,t){this.group.clear(),this.meshes=new Map,this.edges=[],this.censusMesh=null,this.censusIds=[],this.censusPositions=[],this.censusBase=null,this.dragSim=null,this.dragSimNodes=[],this.drag=null,this.stars=[],this.starIndex=new Map,this.nebulae=[],this.starMaterials=[],this.starLayers=[],this.threadColor=null,this.handoff=new Map,this.placedById=new Map,this.tubeMaterials=[],this.tubeSets=[];for(const u of this.lampGlows.values())u.material.dispose();this.lampGlows=new Map;const s=ho();if(this.pulseColor=s.pulse,this.lastPositions=new Map(e.map(u=>[u.node.id,u.position.clone()])),this.projection==="2d")for(const u of e)u.position.z=0;if(this.census){const u=e.filter(p=>p.node.solid===!0&&p.node.ghost!==!0);this.censusBuild(e.filter(p=>p.node.solid!==!0),s,t),u.length>0&&this.solid_draw(u,s);return}!this.ambient&&t&&this.camera_fit(e);const i=new Map(e.map(u=>[u.node.id,u])),r=this.drawMode==="stars",a=[],o=r?this.handlers.handoffKey:void 0;for(const{node:u,position:p,radius:M}of e){if(u.ghost===!0&&u.halo!==!0)continue;if(r&&u.solid!==!0){if(u.halo===!0){this.nebula_add(u,p,s);continue}const v=u.parentIds.length===0&&u.joinParentIds.length===0;a.push({id:u.id,position:p.clone(),radius:M,color:Or(u,s,v).clone(),dim:u.dim===!0,ember:u.share!==void 0&&u.share>0||u.status==="finishedWithError"});continue}if(u.halo===!0){const v=new il(of(u.count??1),24,18),z=new nu({color:s.edge,transparent:!0,opacity:u.dim===!0?af*.4:af,depthWrite:!1}),O=new Ss(v,z);O.position.copy(p),O.renderOrder=1,O.userData.nodeId=u.id,O.userData.halo=!0,O.userData.dim=u.dim===!0,this.group.add(O),this.meshes.set(u.id,O);continue}const _=u.parentIds.length===0&&u.joinParentIds.length===0,m=this.projection==="2d"?new ru(M,36):this.sphere_of(M),f=new Ln({color:Or(u,s,_),roughness:.35,metalness:.15,emissive:u.id===this.selectedId?new Ze("#ffffff"):new Ze("#000000"),emissiveIntensity:u.id===this.selectedId?.35:0,...u.dim===!0?{transparent:!0,opacity:co}:{}}),S=new Ss(m,f);S.position.copy(p),S.userData.nodeId=u.id,S.userData.dim=u.dim===!0,this.group.add(S),this.meshes.set(u.id,S)}a.length>0&&this.stars_draw(a);for(const u of e)this.placedById.set(u.node.id,u);o!==void 0&&this.handoff_gather(a,o);const l=[],c=[],d=u=>!r||u.node.solid===!0,h=(u,p,M,_,m)=>{const f=_?.35:1,S=l.length/6;l.push(u.x,u.y,u.z,p.x,p.y,p.z),c.push(M.r*f,M.g*f,M.b*f,M.r*f,M.g*f,M.b*f);const v=_||o===void 0?null:o(m);v!==null&&this.handoff.get(v)?.threadSegments.push(S)};for(const u of e){const{node:p,position:M}=u;if(p.ghost!==!0){for(const _ of p.parentIds){const m=i.get(_);if(!m||m.node.ghost===!0)continue;const f=p.dim===!0||m.node.dim===!0;d(u)&&d(m)?!r&&f&&this.edge_add(_,p.id,m.position,M,s.edge,!1,f):h(m.position,M,s.edge,f,p)}for(const _ of p.joinParentIds){const m=i.get(_);if(!m)continue;const f=p.dim===!0||m.node.dim===!0;d(u)&&d(m)?!r&&f&&this.edge_add(_,p.id,m.position,M,s.join,!0,f):h(m.position,M,s.join,f,p)}}}{const u=e.filter(p=>p.node.ghost!==!0&&p.node.halo!==!0&&(r?p.node.solid===!0:p.node.dim!==!0)).map(p=>p.node.id);if(u.length>0){const p={entries:u.map(M=>({id:M,position:new P,radius:0,color:new Ze,dim:!1,ember:!1})),center:new P,maxRadius:0,mix:1,target:1,meshes:[],lines:[],tubes:null,threadSegments:[]};this.tubes_build(p,new Set(u),s)}}if(l.length>0){const u=new os;u.setAttribute("position",new Ht(l,3));const p=new Ht(c,3);u.setAttribute("color",p),this.threadColor={attribute:p,base:Float32Array.from(c)},this.group.add(new fh(u,new Wi({vertexColors:!0,transparent:!0,opacity:ff,blending:Ci,depthWrite:!1})))}}handoff_gather(e,t){const s=new Map(this.graph.nodes.map(i=>[i.id,i]));for(const i of e){if(i.dim)continue;const r=s.get(i.id),a=r===void 0?null:t(r);if(a===null)continue;let o=this.handoff.get(a);o===void 0&&(o={entries:[],center:new P,maxRadius:0,mix:0,target:0,meshes:[],lines:[],tubes:null,threadSegments:[]},this.handoff.set(a,o)),o.entries.push(i),o.maxRadius=Math.max(o.maxRadius,i.radius)}for(const i of this.handoff.values()){for(const r of i.entries)i.center.add(r.position);i.center.divideScalar(Math.max(1,i.entries.length))}}handoff_step(){if(this.handoff.size===0)return;const e=performance.now(),t=this.handoffAt===0?0:Math.min(100,e-this.handoffAt);this.handoffAt=e;const i=(this.renderer.domElement.clientHeight||1)/(2*Math.tan(this.camera.fov*Math.PI/360));this.group.updateMatrixWorld(!0),this.camera.updateMatrixWorld();const a=new Rt().multiplyMatrices(this.camera.matrixWorldInverse,this.group.matrixWorld).elements;let o=!1,l=!1;for(const c of this.handoff.values()){let d=1/0;for(const p of c.entries){const M=p.position,_=-(a[2]*M.x+a[6]*M.y+a[10]*M.z+a[14]);_>0&&_<d&&(d=_)}const h=d===1/0?0:2*c.maxRadius*i/d;if(c.target===0&&h>Ix?c.target=1:c.target===1&&h<Tx&&(c.target=0),c.mix===c.target)continue;const u=t===0?1:t/Gx;c.mix=c.target>c.mix?Math.min(1,c.mix+u):Math.max(0,c.mix-u),c.mix>0&&c.meshes.length===0&&this.handoffSolid_build(c);for(const p of c.meshes)p.material instanceof Ln&&(p.material.opacity=c.mix);for(const p of c.lines)p.material instanceof Wi&&(p.material.opacity=.75*c.mix);if(c.tubes!==null&&c.tubes.material instanceof _s){const p=c.tubes.material.uniforms.opacity;p!==void 0&&(p.value=c.mix)}for(const p of c.entries){const M=p.layer===void 0?void 0:this.starLayers[p.layer];M===void 0||p.slot===void 0||(M.alpha.setX(p.slot,(M.base[p.slot]??1)*(1-c.mix)),o=!0)}if(this.threadColor!==null&&c.threadSegments.length>0){const p=this.threadColor.attribute.array,M=this.threadColor.base;for(const _ of c.threadSegments)for(let m=_*6;m<_*6+6;m++)p[m]=(M[m]??0)*(1-c.mix);l=!0}c.mix===0&&this.handoffSolid_release(c)}if(o)for(const c of this.starLayers)c.alpha.needsUpdate=!0;l&&this.threadColor!==null&&(this.threadColor.attribute.needsUpdate=!0)}handoffSolid_build(e){const t=ho(),s=new Set(e.entries.map(i=>i.id));for(const i of e.entries){const r=this.placedById.get(i.id);if(r===void 0)continue;const a=r.node,o=a.parentIds.length===0&&a.joinParentIds.length===0,l=new Ss(this.sphere_of(r.radius),new Ln({color:Or(a,t,o),roughness:.35,metalness:.15,transparent:!0,opacity:e.mix}));l.position.copy(r.position),l.userData.nodeId=a.id,l.userData.dim=!1,this.group.add(l),this.meshes.set(a.id,l),e.meshes.push(l)}this.tubes_build(e,s,t)}tubes_build(e,t,s){const i=[];for(const O of e.entries){const x=this.placedById.get(O.id);if(x!==void 0){for(const G of x.node.parentIds){const b=this.placedById.get(G);b!==void 0&&t.has(G)&&i.push({from:b,to:x,join:!1})}for(const G of x.node.joinParentIds){const b=this.placedById.get(G);b!==void 0&&t.has(G)&&i.push({from:b,to:x,join:!0})}}}if(i.length===0)return;const r=new Map,a=(O,x=new Set)=>{const G=r.get(O);if(G!==void 0)return G;if(x.has(O))return 0;x.add(O);const b=this.placedById.get(O),T=b===void 0?[]:[...b.node.parentIds,...b.node.joinParentIds].filter(C=>t.has(C)),N=T.length===0?0:1+Math.max(...T.map(C=>a(C,x)));return r.set(O,N),N},o=O=>O.status==="finishedSuccessfully"||O.status==="finishedWithError"||O.share!==void 0&&O.status!==void 0&&!Cd.has(O.status),l=performance.now(),c=new Float32Array(i.length*3),d=new Float32Array(i.length),h=new Float32Array(i.length),u=s.edge.clone().lerp(new Ze("#ffffff"),.45),p=new lh(pc(),new _s({uniforms:{time:{value:l},opacity:{value:e.mix},born:{value:l},cycle:{value:1}},vertexShader:Cx,fragmentShader:Px,transparent:!0}),i.length),M=new P(0,1,0),_=new es;let m=0;const f=[],S=new Map,v=new Set;i.forEach(({from:O,to:x,join:G},b)=>{const T=x.position.clone().sub(O.position),N=T.length(),C=Math.max(.06,Math.min(O.radius,x.radius)*.34);_.position.copy(O.position).addScaledVector(T,.5),_.quaternion.setFromUnitVectors(M,N>0?T.clone().divideScalar(N):M),_.scale.set(C,N,C),_.updateMatrix(),p.setMatrixAt(b,_.matrix),f.push({from:O.node.id,to:x.node.id,width:C});const Q=x.node.status==="finishedWithError"||x.node.share!==void 0&&x.node.share>=1?s.error:G?s.join:u;c.set([Q.r,Q.g,Q.b],b*3);const se=x.node.status!==void 0&&Cd.has(x.node.status);d[b]=se?1:o(x.node)?2:0;const H=a(O.node.id);if(m=Math.max(m,H),h[b]=H*uo,d[b]===1&&v.add(x.node.id),d[b]===2){const ee=h[b]+mi/2;S.set(x.node.id,Math.min(S.get(x.node.id)??1/0,ee)),H===0&&S.set(O.node.id,0)}}),p.geometry=pc(),p.instanceMatrix.needsUpdate=!0;const z=pc().clone();if(z.setAttribute("aColor",new _a(c,3)),z.setAttribute("aMode",new _a(d,1)),z.setAttribute("aStart",new _a(h,1)),p.geometry=z,p.frustumCulled=!1,this.group.add(p),e.tubes=p,p.material instanceof _s){this.tubeMaterials.push(p.material);const O=p.material.uniforms.cycle;O!==void 0&&(O.value=(m+1)*uo+mi/2+Rx)}this.tubeSets.push({mesh:p,edges:f,lamps:S,blinks:v,group:e,members:t})}lamps_animate(e){const t=new Set;for(const{mesh:s,lamps:i,blinks:r}of this.tubeSets){if(i.size===0&&r.size===0||!(s.material instanceof _s))continue;const a=Number(s.material.uniforms.born?.value??e),o=Number(s.material.uniforms.cycle?.value??1),l=((e-a)%o+o)%o,c=Math.min(1,Math.max(0,(o-l)/Nx));for(const[h,u]of i){const p=l-u;this.lamp_paint(h,p<0?0:c,p>=0&&p<fo?p/fo:-1,t)}const d=(e%mi+mi)%mi;for(const h of r){if(i.has(h))continue;const u=Math.max(0,1-d/(mi*.8));this.lamp_paint(h,u*u,d<fo?d/fo:-1,t)}}for(const[s,i]of this.lampGlows)t.has(s)||(i.visible=!1,this.meshes.has(s)||(this.group.remove(i),i.material.dispose(),this.lampGlows.delete(s)))}lamp_paint(e,t,s,i){const r=this.meshes.get(e);if(r===void 0||!(r.material instanceof Ln))return;let a=r.userData.lampBase;a instanceof Ze||(a=r.material.color.clone(),r.userData.lampBase=a);const o=s<0?0:(1-s)**2;if(r.material.color.copy(a).multiplyScalar(mf+(1-mf)*Math.max(t,o)).lerp(Mf,Math.min(1,.22*t+.7*o)),s<0)return;let l=this.lampGlows.get(e);l===void 0&&(l=new sh(new Ed({map:gf(),color:a.clone().lerp(Mf,.35),transparent:!0,blending:Ci,depthWrite:!1})),this.lampGlows.set(e,l),this.group.add(l));const c=r.geometry.parameters?.radius??bs,d=1-(1-s)**3;l.position.copy(r.position),l.scale.setScalar(c*(2+Bx*d)*r.scale.x),l.material.opacity=.9*(1-s)**1.5,l.visible=!0,i.add(e)}tubes_restatus(){this.tubesStale=!1;const e=ho(),t=this.tubeSets;this.tubeSets=[];for(const s of t){if(this.group.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material instanceof _s){const i=s.mesh.material;this.tubeMaterials=this.tubeMaterials.filter(r=>r!==i),i.dispose()}s.group.tubes=null,this.tubes_build(s.group,s.members,e)}this.tubes_follow()}tubes_follow(){const e=new P(0,1,0),t=new es;for(const{mesh:s,edges:i}of this.tubeSets)i.forEach(({from:r,to:a,width:o},l)=>{const c=this.meshes.get(r),d=this.meshes.get(a);if(c===void 0||d===void 0)return;const h=d.position.clone().sub(c.position),u=h.length();t.position.copy(c.position).addScaledVector(h,.5),t.quaternion.setFromUnitVectors(e,u>0?h.clone().divideScalar(u):e),t.scale.set(o,u,o),t.updateMatrix(),s.setMatrixAt(l,t.matrix)}),s.instanceMatrix.needsUpdate=!0}handoffSolid_release(e){for(const t of e.meshes){this.group.remove(t),t.material instanceof Tn&&t.material.dispose();const s=t.userData.nodeId;typeof s=="string"&&this.meshes.get(s)===t&&this.meshes.delete(s)}for(const t of e.lines)this.group.remove(t),t.geometry.dispose(),t.material instanceof Tn&&t.material.dispose();if(e.tubes!==null){this.group.remove(e.tubes);const t=e.tubes;if(this.tubeSets=this.tubeSets.filter(s=>s.mesh!==t),e.tubes.geometry.dispose(),e.tubes.material instanceof _s){const s=e.tubes.material;this.tubeMaterials=this.tubeMaterials.filter(i=>i!==s),s.dispose()}e.tubes=null}e.meshes=[],e.lines=[]}stars_draw(e){for(const t of e)this.starIndex.has(t.id)||this.starIndex.set(t.id,this.stars.length),this.stars.push(t);for(const t of[!1,!0]){const s=e.filter(u=>u.ember===t);if(s.length===0)continue;const i=new Float32Array(s.length*3),r=new Float32Array(s.length*3),a=new Float32Array(s.length),o=new Float32Array(s.length);s.forEach((u,p)=>{u.layer=this.starLayers.length,u.slot=p,i.set([u.position.x,u.position.y,u.position.z],p*3),r.set([u.color.r,u.color.g,u.color.b],p*3),a[p]=u.radius,o[p]=u.dim?co*1.5:1});const l=new os;l.setAttribute("position",new Ds(i,3)),l.setAttribute("tint",new Ds(r,3)),l.setAttribute("radius",new Ds(a,1));const c=new Ds(o,1);l.setAttribute("alpha",c),this.starLayers.push({alpha:c,base:Float32Array.from(o)});const d=new _s({uniforms:{scale:{value:1},floorPx:{value:xx*window.devicePixelRatio},capPx:{value:Sx*window.devicePixelRatio}},vertexShader:Ax,fragmentShader:t?Dx:Ex,transparent:!0,depthWrite:!1,blending:t?ji:Ci}),h=new Nz(l,d);h.renderOrder=t?2:1,h.frustumCulled=!1,this.group.add(h),this.starMaterials.push(d)}this.starScale_update()}starScale_update(){if(this.starMaterials.length===0)return;const t=this.renderer.domElement.height/(2*Math.tan(this.camera.fov*Math.PI/360));for(const s of this.starMaterials){const i=s.uniforms.scale;i!==void 0&&(i.value=t)}}nebula_add(e,t,s){const i=of(e.count??1),r=new sh(new Ed({map:gf(),color:s.edge,transparent:!0,opacity:e.dim===!0?pf/3:pf,blending:Ci,depthWrite:!1}));r.position.copy(t),r.scale.setScalar(i*2),r.renderOrder=0,this.group.add(r),this.nebulae.push({id:e.id,position:t.clone(),radius:i})}starNode_under(e){if(this.stars.length===0&&this.nebulae.length===0)return null;const t=this.renderer.domElement.getBoundingClientRect(),s=e.clientX-t.left,i=e.clientY-t.top;this.group.updateMatrixWorld(!0),this.camera.updateMatrixWorld();const r=t.height/(2*Math.tan(this.camera.fov*Math.PI/360)),a=new Rt().multiplyMatrices(this.camera.matrixWorldInverse,this.group.matrixWorld),l=new Rt().multiplyMatrices(this.camera.projectionMatrix,a).elements,c=a.elements,d=p=>{const M=-(c[2]*p.x+c[6]*p.y+c[10]*p.z+c[14]);if(M<=0)return null;const _=l[3]*p.x+l[7]*p.y+l[11]*p.z+l[15],m=(l[0]*p.x+l[4]*p.y+l[8]*p.z+l[12])/_,f=(l[1]*p.x+l[5]*p.y+l[9]*p.z+l[13])/_;return{x:(m+1)/2*t.width,y:(1-f)/2*t.height,depth:M}};let h=null,u=1/0;for(const p of this.stars){if(p.dim)continue;const M=d(p.position);if(M===null)continue;const _=Math.max(this.pressKind==="touch"?bx:4,Gm*p.radius*r/M.depth),m=Math.hypot(M.x-s,M.y-i);if(m>_)continue;const f=m/_;f<u&&(u=f,h=p.id)}if(h!==null)return h;for(const p of this.nebulae){const M=d(p.position);if(M!==null&&Math.hypot(M.x-s,M.y-i)<=p.radius*r/M.depth)return p.id}return null}nodeWorld_of(e){const t=this.meshes.get(e);if(t!==void 0){const r=t.geometry;return r.boundingSphere===null&&r.computeBoundingSphere(),{position:t.getWorldPosition(new P),radius:r.boundingSphere?.radius??bs}}const s=this.starIndex.get(e),i=s===void 0?void 0:this.stars[s];return i!==void 0?{position:this.group.localToWorld(i.position.clone()),radius:i.radius}:null}drawnIds(){return[...this.meshes.keys(),...this.starIndex.keys()]}edge_add(e,t,s,i,r,a,o=!1){const l=new os().setFromPoints([s,i]);let c;if(a){const d=new $z({color:r,dashSize:.25,gapSize:.18,transparent:!0,opacity:o?co:.9});c=new Dd(l,d),c.computeLineDistances()}else{const d=new Wi({color:r,transparent:!0,opacity:o?co:.75});c=new Dd(l,d)}this.group.add(c),this.edges.push({line:c,fromId:e,toId:t,dashed:a})}positions_sync(){for(const e of this.dragSimNodes)this.meshes.get(e.id)?.position.set(e.x,e.y,e.z),this.lastPositions.set(e.id,new P(e.x,e.y,e.z));this.tubeSets.length>0&&this.tubes_follow();for(const e of this.edges){const t=this.meshes.get(e.fromId),s=this.meshes.get(e.toId);t===void 0||s===void 0||(e.line.geometry.setFromPoints([t.position,s.position]),e.dashed&&e.line.computeLineDistances())}}viewDrag=null;press_handle(e){if(this.holding||this.flight!==null)return;this.spinIdleUntil=Date.now()+hi;const t=this.mesh_under(e),s=t?.userData.nodeId;if(t===null||typeof s!="string"){this.viewDrag={lastX:e.clientX,lastY:e.clientY,startX:e.clientX,startY:e.clientY,pan:e.shiftKey||e.button===2||e.button===1,moved:!1};try{this.renderer.domElement.setPointerCapture(e.pointerId)}catch{}this.tip&&(this.tip.hidden=!0);return}const i=this.camera.getWorldDirection(new P).negate();this.group.updateMatrixWorld(!0);const r=new pi().setFromNormalAndCoplanarPoint(i,t.getWorldPosition(new P));this.drag={nodeId:s,plane:r,startX:e.clientX,startY:e.clientY,moved:!1,solo:this.strategy==="ranked",home:t.position.clone()};try{this.renderer.domElement.setPointerCapture(e.pointerId)}catch{}this.tip&&(this.tip.hidden=!0)}dragSim_begin(e){const t=u=>this.meshes.get(u)?.userData.halo===!0,s=u=>this.meshes.get(u)?.userData.dim===!0,i=[],r=new Map;for(const u of this.graph.nodes)for(const p of[...u.parentIds,...u.joinParentIds])!this.meshes.has(p)||!this.meshes.has(u.id)||t(p)||t(u.id)||(i.push({source:p,target:u.id}),r.set(p,[...r.get(p)??[],u.id]),r.set(u.id,[...r.get(u.id)??[],p]));const a=new Set([e]),o=[e];for(;o.length>0;){const u=o.pop();for(const p of r.get(u)??[])a.has(p)||s(p)||(a.add(p),o.push(p))}const l=i.filter(u=>a.has(u.source)&&a.has(u.target));this.dragSimNodes=[...a].map(u=>{const p=this.meshes.get(u);return{id:u,x:p.position.x,y:p.position.y,z:p.position.z}});const c=hf(this.graph.nodes),d=u=>c.get(u)??bs;this.dragSim=Im(this.dragSimNodes,this.projection==="2d"?2:3).force("link",Om(l).id(u=>u.id).distance(u=>d(u.source.id)+d(u.target.id)+1.4)).force("charge",Tm().strength(u=>-6*(d(u.id)/bs)**2).distanceMax(12)).force("collide",vm().radius(u=>d(u.id)*1.2)).alpha(.25).alphaTarget(.08).stop();const h=this.dragSimNodes.find(u=>u.id===e);h&&(h.fx=h.x,h.fy=h.y,h.fz=h.z)}drag_move(e){if(this.drag===null||(this.spinIdleUntil=Date.now()+hi,!this.drag.moved&&Math.abs(e.clientX-this.drag.startX)+Math.abs(e.clientY-this.drag.startY)>df&&(this.drag.moved=!0,this.drag.solo||this.dragSim_begin(this.drag.nodeId)),!this.drag.moved))return;const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.raycaster.setFromCamera(s,this.camera);const i=new P;if(this.raycaster.ray.intersectPlane(this.drag.plane,i)===null)return;if(this.group.worldToLocal(i),this.drag.solo){const a=this.meshes.get(this.drag.nodeId);a!==void 0&&(a.position.copy(i),this.positions_sync());return}const r=this.dragSimNodes.find(a=>a.id===this.drag?.nodeId);r&&(r.fx=i.x,r.fy=i.y,r.fz=i.z)}camera_dolly(e){if(this.spinIdleUntil=Date.now()+hi,this.touched=!0,this.census){const r=this.camera.getWorldDirection(new P),a=Math.max(4,this.camera.position.length())*.0012;this.camera.position.addScaledVector(r,-e*a);return}const t=this.camera.position.clone().sub(this.focus),s=t.length(),i=Math.min(Math.max(s*Math.exp(e*.001),1.5),Math.max(40,this.camera.far*.45));this.camera.position.copy(this.focus).addScaledVector(t,i/Math.max(1e-4,s))}camera_pan(e,t){const s=this.camera.position.distanceTo(this.focus)*.0016,i=new P().setFromMatrixColumn(this.camera.matrixWorld,0).multiplyScalar(-e*s).add(new P().setFromMatrixColumn(this.camera.matrixWorld,1).multiplyScalar(t*s));this.camera.position.add(i),this.focus.add(i)}fingers_read(){const[e,t]=[...this.touches.values()];return e===void 0||t===void 0?null:{spread:Math.hypot(e.x-t.x,e.y-t.y),midX:(e.x+t.x)/2,midY:(e.y+t.y)/2}}gesture_begin(){this.drag_end(),this.viewDrag=null,this.gestureHeld=!0,this.pinch=this.fingers_read(),this.spinIdleUntil=Date.now()+hi,this.tip&&(this.tip.hidden=!0)}gesture_move(){const e=this.fingers_read();e===null||this.pinch===null||(e.spread>0&&this.pinch.spread>0&&this.camera_dolly(Math.log(this.pinch.spread/e.spread)/.001),(this.projection==="2d"||!this.census)&&this.camera_pan(e.midX-this.pinch.midX,e.midY-this.pinch.midY),this.pinch=e)}view_move(e){if(this.viewDrag===null)return;this.spinIdleUntil=Date.now()+hi;const t=e.clientX-this.viewDrag.lastX,s=e.clientY-this.viewDrag.lastY;this.viewDrag.lastX=e.clientX,this.viewDrag.lastY=e.clientY,!this.viewDrag.moved&&Math.abs(e.clientX-this.viewDrag.startX)+Math.abs(e.clientY-this.viewDrag.startY)>df&&(this.viewDrag.moved=!0,this.touched=!0),this.viewDrag.moved&&(this.viewDrag.pan||this.projection==="2d"?this.camera_pan(t,s):(this.turn_about(lf,t*.005),this.turn_about(new P().setFromMatrixColumn(this.camera.matrixWorld,0).normalize(),s*.005)))}dragReturns=[];drag_end(){if(this.viewDrag!==null&&(this.viewDrag.moved&&(this.suppressClick=!0),this.viewDrag=null,this.spinIdleUntil=Date.now()+hi),this.drag===null)return;if(this.spinIdleUntil=Date.now()+hi,this.drag.moved&&(this.suppressClick=!0),this.drag.solo&&this.drag.moved){const t=this.meshes.get(this.drag.nodeId);t!==void 0&&this.dragReturns.push({mesh:t,from:t.position.clone(),to:this.drag.home.clone(),startedAt:Date.now()})}const e=this.dragSimNodes.find(t=>t.id===this.drag?.nodeId);e&&(e.fx=null,e.fy=null,e.fz=null),this.dragSim?.alphaTarget(0),this.drag=null}mesh_under(e){const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.group.updateMatrixWorld(!0),this.raycaster.setFromCamera(s,this.camera);const i=this.raycaster.intersectObjects([...this.meshes.values()]).filter(o=>o.object.userData.dim!==!0),a=(i.find(o=>o.object.userData.halo!==!0)??i[0])?.object;return a instanceof Ss?a:null}node_under(e){const t=this.meshNode_under(e);return t!==null?t:this.census&&this.censusMesh!==null?this.censusNode_under(e):this.starNode_under(e)}solid_draw(e,t){for(const r of e){this.placedById.set(r.node.id,r);const a=r.node.parentIds.length===0&&r.node.joinParentIds.length===0,o=new Ss(this.sphere_of(r.radius),new Ln({color:Or(r.node,t,a),roughness:.35,metalness:.15}));o.position.copy(r.position),o.userData.nodeId=r.node.id,o.userData.dim=!1,this.group.add(o),this.meshes.set(r.node.id,o)}const s=e.map(r=>r.node.id),i={entries:s.map(r=>({id:r,position:new P,radius:0,color:new Ze,dim:!1,ember:!1})),center:new P,maxRadius:0,mix:1,target:1,meshes:[],lines:[],tubes:null,threadSegments:[]};this.tubes_build(i,new Set(s),t)}meshNode_under(e){const t=this.mesh_under(e)?.userData.nodeId;return typeof t=="string"?t:null}censusNode_under(e){if(this.censusMesh===null)return null;const t=this.renderer.domElement.getBoundingClientRect(),s=new Je((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1);this.group.updateMatrixWorld(!0),this.raycaster.setFromCamera(s,this.camera);const i=this.raycaster.intersectObject(this.censusMesh)[0];return i===void 0||i.instanceId===void 0?null:(this.censusMesh.setColorAt(i.instanceId,new Ze("#ffffff")),this.censusMesh.instanceColor&&(this.censusMesh.instanceColor.needsUpdate=!0),this.censusIds[i.instanceId]??null)}hover_handle(e){if(this.pointerInside=!0,this.tip===null)return;const t=this.node_under(e),s=typeof t=="string"?this.graph.nodes.find(r=>r.id===t):void 0;if(s===void 0){this.tip.hidden=!0,this.renderer.domElement.style.cursor="",this.hovered=null;return}this.hovered={id:s.id,x:e.clientX,y:e.clientY};const i=this.renderer.domElement.getBoundingClientRect();this.tip.textContent=this.handlers.tip?.(s)??s.label,this.tip.style.left=`${e.clientX-i.left+14}px`,this.tip.style.top=`${e.clientY-i.top+10}px`,this.tip.hidden=!1,this.renderer.domElement.style.cursor="pointer"}pick_handle(e,t){const s=this.hovered,i=s!==null&&Math.hypot(e.clientX-s.x,e.clientY-s.y)<=6?s.id:this.node_under(e);if(i===null){t==="select"&&this.selectedId!==null&&(this.selection_clear(),this.handlers.deselect?.());return}const r=this.graph.nodes.find(a=>a.id===i);r&&(t==="select"?(this.selectedId=i,this.census||this.selection_paint(),this.handlers.select?.(r)):this.handlers.activate?.(r))}}const Rm=24,Pd="argus.dormant";class Wx{constructor(e=Rm,t){this.cap=e,this.store=t,this.rehydrate()}cap;store;groups=new Map;add(e){for(this.groups.delete(e.id),this.groups.set(e.id,e);this.groups.size>this.cap;){const t=this.oldest_id();if(t===void 0)break;this.groups.delete(t)}this.persist()}list(){return[...this.groups.values()].sort((e,t)=>t.lastTouched-e.lastTouched)}get(e){return this.groups.get(e)}has(e){return this.groups.has(e)}dismiss(e){const t=this.groups.delete(e);return t&&this.persist(),t}oldest_id(){let e;for(const t of this.groups.values())(e===void 0||t.lastTouched<e.lastTouched)&&(e=t);return e?.id}persist(){if(this.store!==void 0)try{this.store.setItem(Pd,JSON.stringify([...this.groups.values()]))}catch{}}rehydrate(){if(this.store!==void 0)try{const e=this.store.getItem(Pd);if(e===null)return;const t=JSON.parse(e);if(!Array.isArray(t))return;for(const s of t)s!==null&&typeof s=="object"&&typeof s.id=="string"&&this.groups.set(s.id,s)}catch{}}}function bf(){try{const n=globalThis.localStorage;return n===void 0?void 0:(n.getItem(Pd),n)}catch{return}}class Lx{constructor(e,t){this.host=t,this.grid=e.querySelector(".panes-grid"),this.empty=e.querySelector(".panes-empty"),this.grid.addEventListener("click",this.click_handle)}host;grid;empty;render(){const e=this.host.list();this.empty.hidden=e.length>0,this.grid.replaceChildren(...e.map(t=>this.card_build(t)))}card_build(e){const t=document.createElement("button");t.className="panes-card",t.dataset.restore=e.id,t.title=`restore ${e.label}`;const s=document.createElement("span");if(s.className="panes-card-figure",e.thumbnail!==void 0){const o=document.createElement("img");o.src=e.thumbnail,o.alt="",s.appendChild(o)}else s.classList.add("panes-card-glyph"),s.textContent=e.members.includes("files")&&!e.members.includes("viewer")?"▤":"▣";t.appendChild(s);const i=document.createElement("span");i.className="panes-card-label",i.textContent=e.label,t.appendChild(i);const r=document.createElement("span");r.className="panes-card-badges";for(const o of kx(e.members)){const l=document.createElement("span");l.className="panes-card-badge",l.textContent=o.toUpperCase(),r.appendChild(l)}t.appendChild(r);const a=document.createElement("button");return a.className="panes-card-dismiss",a.dataset.dismiss=e.id,a.title=`forget ${e.label}`,a.textContent="DISMISS",t.appendChild(a),t}click_handle=e=>{const t=e.target,s=t.closest("[data-dismiss]");if(s!==null){e.stopPropagation();const r=s.dataset.dismiss??"";this.host.dismiss(r),this.render();return}const i=t.closest("[data-restore]");i!==null&&this.host.restore(i.dataset.restore??"")}}function kx(n){return[...new Set(n)]}const xn=["#000000","#f24444","#33cc66","#ffaa44","#5599ff","#cc88ff","#44cccc","#ffeecc","#777777","#ff6666","#66ee99","#ffcc66","#77bbff","#dd99ff","#66dddd","#ffffff"],Ux={yellow:xn[3],white:xn[7],cyan:xn[6],green:xn[2],magenta:xn[5]};function Bm(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,inverse:!1,underline:!1}}function Fx(n){if(n<16)return xn[n]??"#ffeecc";if(n<232){const t=n-16,s=[0,95,135,175,215,255],i=s[Math.floor(t/36)%6]??0,r=s[Math.floor(t/6)%6]??0,a=s[t%6]??0;return`#${(i<<16|r<<8|a).toString(16).padStart(6,"0")}`}const e=8+(n-232)*10;return`#${(e<<16|e<<8|e).toString(16).padStart(6,"0")}`}function jx(n,e){for(let t=0;t<e.length;t++){const s=e[t]??0;if(s===0)Object.assign(n,Bm());else if(s===1)n.bold=!0;else if(s===2)n.dim=!0;else if(s===3)n.italic=!0;else if(s===4)n.underline=!0;else if(s===7)n.inverse=!0;else if(s===27)n.inverse=!1;else if(s===22)n.bold=!1,n.dim=!1;else if(s===23)n.italic=!1;else if(s===24)n.underline=!1;else if(s>=30&&s<=37)n.fg=xn[s-30]??null;else if(s>=90&&s<=97)n.fg=xn[s-90+8]??null;else if(s===39)n.fg=null;else if(s>=40&&s<=47)n.bg=xn[s-40]??null;else if(s>=100&&s<=107)n.bg=xn[s-100+8]??null;else if(s===49)n.bg=null;else if(s===38||s===48){const i=e[t+1]??0;let r=null;if(i===5)r=Fx(e[t+2]??0),t+=2;else if(i===2){const a=e[t+2]??0,o=e[t+3]??0,l=e[t+4]??0;r=`#${(a<<16|o<<8|l).toString(16).padStart(6,"0")}`,t+=4}s===38?n.fg=r:n.bg=r}}}function Vx(n){const e=[],t=n.inverse?n.bg??"#000":n.fg,s=n.inverse?n.fg??"var(--daybreak)":n.bg;return t!==null&&e.push(`color:${t}`),s!==null&&e.push(`background-color:${s}`),n.bold&&e.push("font-weight:bold"),n.dim&&e.push("opacity:0.55"),n.italic&&e.push("font-style:italic"),n.underline&&e.push("text-decoration:underline"),e.join(";")}function Hs(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const mc=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;function Vn(n){const e=Bm();let t="",s=0;const i=a=>{if(a.length===0)return;const o=Vx(e),l=Hs(a.replace(/\r/g,""));t+=o.length>0?`<span style="${o}">${l}</span>`:l};mc.lastIndex=0;let r=mc.exec(n);for(;r!==null;){if(i(n.slice(s,r.index)),s=r.index+r[0].length,r[2]==="m"){const a=(r[1]??"").split(/[;:]/).map(o=>o.length>0?Number(o):0);jx(e,a)}r=mc.exec(n)}return i(n.slice(s)),t}function $x(n){for(const[e,t]of Object.entries(Ux))n.style.setProperty(`--console-${e}`,t)}const Hx="G1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtChtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswOzA7MG0gG1swbRtbMzg7MjswO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tbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0bWzM4OzI7MDswOzBtIBtbMG0KG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MTsybSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzA7MTsxbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzk7MTc7MjRtIBtbMG0bW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szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjszbSAbWzBtG1szODsyOzE7MjsybSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbW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ODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtG1szODsyOzA7MDswbSAbWzBtCg==",qx=/\x1b\[[0-9;]*m/g,zf="\x1B[0m",_f="\x1B[7m",Nm=atob(Hx).trimEnd().split(`
4189
+ `);Nm.map(n=>n.replace(qx,""));function Xx(n){const e=n.replace(/\x1b\[0m/g,`${zf}${_f}`);return`${_f}${e}${zf}`}function Yx(n,e=!1){const t=Nm;return e?t.map(Xx):t}function Cm(n){const e=n.lastIndexOf("/");return e<=0?"/":n.slice(0,e+1)}function Kx(n){const e=new URLSearchParams(n.search).get("ws");return e!==null&&e.length>0?e:`${n.protocol==="https:"?"wss":"ws"}://${n.host}${Cm(n.pathname)}`}function QE(n,e){return new URL(n,e).href}function Mu(n,e){const t=`path=${encodeURIComponent(n)}`;return e.length>0?`vfs?${t}&token=${encodeURIComponent(e)}`:`vfs?${t}`}function Zx(n,e){return`${Mu(n,e)}&download=1`}function Pm(n){return new URLSearchParams(n).has("door")}function wf(n,e){const s=Cm(n).split("/").filter(i=>i.length>0).slice(0,-2);return`/${s.length>0?`${s.join("/")}/`:""}${e}`}const Qx="daemon";class gu{socket;handlers;token;pending=new Map;pendingCompletions=new Map;silentIds=new Set;nextId=0;constructor(e,t,s){this.socket=e,this.handlers=t,this.token=s,this.socket.onmessage=i=>this.message_handle(String(i.data)),this.socket.onclose=()=>this.handlers.close_handle?.()}static session_attach(e,t,s){return new Promise((i,r)=>{const a=new WebSocket(e);a.onerror=()=>r(new Error(`cannot reach the daemon at ${e}`)),a.onopen=()=>{a.send(JSON.stringify({type:"attach",protocolVersion:Ec,token:t,capabilities:{shellCommands:!1,color:!0,hiddenInput:!0,fileDelivery:!0,localFilesystem:!1}}))},a.onmessage=o=>{const l=yf(String(o.data));if(!l){r(new Error("invalid attach response")),a.close();return}if(l.type==="error"){r(new Error(l.reason)),a.close();return}if(l.type!=="attached"){r(new Error(`unexpected attach response: ${l.type}`)),a.close();return}const c=new gu(a,s,t);i({client:c,attach:{session:l.session,protocolVersion:l.protocolVersion,...l.stack!==void 0?{stack:l.stack}:{},...l.hostControl!==void 0?{hostControl:l.hostControl}:{}}})}})}line_execute(e,t){const s=`argus-${this.nextId++}`;return t?.silent===!0&&this.silentIds.add(s),new Promise((i,r)=>{this.pending.set(s,{resolve:i,reject:r,liveChannels:new Set,observed:t?.observe!==!1}),this.socket.send(JSON.stringify({type:"execute",id:s,line:e,...t?.silent===!0?{instrument:!0}:{}}))})}line_complete(e){const t=`argus-c-${this.nextId++}`;return new Promise((s,i)=>{this.pendingCompletions.set(t,{resolve:s,reject:i}),this.socket.send(JSON.stringify({type:"complete",id:t,prefix:e}))})}regard_send(e){this.socket.send(JSON.stringify({type:"regard",regard:e}))}watch_send(e){this.socket.send(JSON.stringify({type:"watch",subject:e}))}unwatch_send(e){this.socket.send(JSON.stringify({type:"unwatch",subject:e}))}connection_close(){this.socket.close()}message_handle(e){const t=yf(e);if(t)switch(t.type){case"result":{this.silentIds.delete(t.id);const s=this.pending.get(t.id);if(s&&(this.pending.delete(t.id),s.resolve({envelopes:t.envelopes,liveChannels:s.liveChannels})),s===void 0||s.observed)for(const i of t.envelopes)this.handlers.envelope_observe?.(i);break}case"complete":{const s=this.pendingCompletions.get(t.id);s&&(this.pendingCompletions.delete(t.id),s.resolve({candidates:t.candidates,prefix:t.prefix}));break}case"output":{(t.channel==="data"||t.channel==="err")&&this.pending.get(t.id)?.liveChannels.add(t.channel),this.silentIds.has(t.id)||this.handlers.output_receive?.(t.channel,t.chunk);break}case"progress":{this.handlers.progress_receive?.(t);break}case"session":{if(t.surface===Qx){this.handlers.ambient_receive?.(t.envelope);break}this.handlers.session_receive?.(t.surface,t.envelope),this.handlers.envelope_observe?.(t.envelope);break}case"watched":{this.handlers.watched_receive?.(t.subject,t.state);break}case"numbered":{this.handlers.numbered_receive?.({id:t.id,source:t.source,rows:t.rows,handles:t.handles});break}case"promptline":{this.handlers.promptline_receive?.(t.context);break}case"telemetry":{this.handlers.telemetry_receive?.(t.index,{lane:t.lane,cube:t.cube,state:t.state});break}case"regard":{this.handlers.regard_receive?.(t.regard);break}case"error":{if(t.id!==void 0){const s=this.pending.get(t.id);s&&(this.pending.delete(t.id),s.reject(new Error(t.reason)));const i=this.pendingCompletions.get(t.id);i&&(this.pendingCompletions.delete(t.id),i.reject(new Error(t.reason)))}break}case"prompt":{const s=this.handlers.ask_receive;if(s===void 0){this.reply_send({type:"promptError",promptId:t.promptId,reason:"this surface has no way to ask"});break}const i=t.promptId;s({message:t.message,kind:kg(t),...t.path?.suggest===void 0?{}:{suggest:t.path.suggest},...t.path===void 0?{}:{path:t.path},...t.commit===void 0?{}:{commit:t.commit}}).then(r=>{if(r===null){this.reply_send({type:"promptError",promptId:i,reason:"the operator abandoned the question"});return}this.reply_send({type:"promptAnswer",promptId:i,answer:r})}).catch(r=>{const a=r instanceof Error?r.message:"the question could not be answered";this.reply_send({type:"promptError",promptId:i,reason:a})});break}case"pipe":{this.reply_send({type:"pipeError",pipeId:t.pipeId,reason:"the argus surface cannot run pipeline segments"});break}case"shell":{this.reply_send({type:"shellError",shellId:t.shellId,reason:"the argus surface cannot run shell commands"});break}case"edit":{this.reply_send({type:"editError",editId:t.editId,reason:"the argus surface cannot open an editor"});break}case"deliver":{this.deliver_run(t);break}}}async deliver_run(e){try{const t=Mu(e.path,this.token),s=await fetch(t);if(!s.ok)throw new Error(`calypso refused to serve this file (HTTP ${s.status})`);const i=await s.blob(),r=URL.createObjectURL(i),a=document.createElement("a");a.href=r,a.download=e.filename,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),this.reply_send({type:"deliverResult",deliverId:e.deliverId,location:e.filename,bytes:i.size})}catch(t){const s=t instanceof Error?t.message:String(t);this.reply_send({type:"deliverError",deliverId:e.deliverId,reason:s})}}reply_send(e){this.socket.send(JSON.stringify(e))}}function yf(n){try{const e=Kg(JSON.parse(n));return e.ok&&e.value!==void 0?e.value:null}catch{return null}}const Gi={pacs:{bg:"#875FFF",fg:"#FFFFFF"},host:{bg:"#00AFFF",fg:"#001018"},user:{bg:"#00D787",fg:"#00140C"},dir:{bg:"#FFD75F",fg:"#201800"},physical:{bg:"#FF5F5F",fg:"#1B0000"},duration:{bg:"#FF8700",fg:"#201000"},status:{bg:"#FF005F",fg:"#FFFFFF"}},Jx={cold:{icon:"",label:"proc cold",color:{bg:"#FF8700",fg:"#201000"}},cached:{icon:"",label:"proc cached, refreshing",color:{bg:"#5F5F87",fg:"#FFFFFF"}},failed:{icon:"",label:"proc failed",color:{bg:"#FF005F",fg:"#FFFFFF"}}},kn={powerline:"",cube:"",database:"",user:"",folder:"",microscope:"",bolt:"",error:""},eS=3e3,tS=200;class sS{output;splashGreeting=null;progressRegion;promptBar;inputGlyph;input;submit;complete;promptContext=null;busy=!0;pendingAsk=null;queuedLines=[];questionOpen=!1;history=[];historyIndex=0;streamBlock=null;streamPendingElement=null;streamPendingText="";streamPendingChannel="data";constructor(e,t,s){this.submit=t,this.complete=s,e.innerHTML=`
4190
4190
  <div class="argus-screen">
4191
4191
  <div class="argus-output"></div>
4192
4192
  <div class="argus-progress"></div>
@@ -4199,38 +4199,38 @@ void main() {
4199
4199
  `);const i=document.createElement("div");i.className="argus-splash-greeting",t.append(s,i),this.output.appendChild(t),this.splashGreeting=i}greeting_write(e){const t=this.splashGreeting;if(t===null)for(const s of e)this.block_append("argus-banner-line argus-greeting-line",Vn(s));else for(const s of e){const i=document.createElement("div");i.className="argus-greeting-line",i.innerHTML=Vn(s),t.appendChild(i)}this.size_fit()}output_write(e,t){this.stream_ensure();let s=t;for(;s.length>0;){const i=s.search(/[\r\n]/);if(i===-1){this.pending_extend(e,s);break}this.pending_extend(e,s.slice(0,i));const r=s[i]==="\r"&&s[i+1]===`
4200
4200
  `;s[i]===`
4201
4201
  `||r?this.pending_commit():this.streamPendingText="",s=s.slice(i+(r?2:1))}this.pending_paint(),this.size_fit()}pending_extend(e,t){this.streamPendingText.length===0&&(this.streamPendingChannel=e),this.streamPendingText+=t}pending_commit(){this.streamPendingElement?.insertAdjacentHTML("beforebegin",`${this.pending_toHtml()}
4202
- `),this.streamPendingText=""}pending_paint(){this.streamPendingElement!==null&&(this.streamPendingElement.innerHTML=this.pending_toHtml())}pending_toHtml(){if(this.streamPendingText.length===0)return"";const e=Vn(this.streamPendingText);return this.streamPendingChannel==="status"?`<span class="dim">${e}</span>`:e}outcome_write(e){for(const t of e.envelopes){!e.liveChannels.has("data")&&t.rendered.length>0&&this.block_append("argus-result",Vn(t.rendered));const s=t.renderedErr??"";!e.liveChannels.has("err")&&s.length>0&&this.block_append("argus-result error",Vn(s))}}session_write(e,t){t.rendered.length!==0&&(this.block_append("dim",`[surface ${Hs(e.slice(0,6))}]`),this.block_append("argus-result",Vn(t.rendered)),this.size_fit())}line_note(e){this.block_append("argus-result",Hs(e)),this.size_fit()}line_echo(e){this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit()}line_offer(e){this.input.value=e,this.focus_take(),this.input.setSelectionRange(e.length,e.length)}question_set(e){this.questionOpen=e}line_run(e){if(this.busy&&!this.questionOpen){this.queuedLines.push(e);return}if(this.questionOpen){this.history_push(e),this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit(),this.submit(e);return}this.busy=!0,this.history_push(e),this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit(),this.submit(e)}ask_abandon(){const e=this.pendingAsk;return e===null?!1:(e.settle(null),!0)}ask_isOpen(){return this.pendingAsk!==null}ask_open(e){if(this.pendingAsk!==null)return Promise.resolve(null);const t=e.kind;this.block_append("argus-ask",`<span class="ask-glyph">?</span> ${Hs(e.message)}`);const s=this.output.lastElementChild;return new Promise(i=>{const r=a=>{if(this.pendingAsk===null)return;this.pendingAsk=null,this.questionOpen=!1,this.input.type="text",this.input.value="",this.inputGlyph.textContent="❯",s.classList.add("argus-ask-answered");const o=a===null?"abandoned":t==="secret"?"••••••":a;s.insertAdjacentHTML("beforeend",` <span class="ask-answer">${Hs(o)}</span>`),this.size_fit(),i(a)};if(this.pendingAsk={settle:r,kind:t},this.questionOpen=!0,this.inputGlyph.textContent="?",t==="secret"&&(this.input.type="password"),(t==="path"||t==="text")&&e.suggest!==void 0&&(this.input.value=e.suggest),t==="confirm"){const a=document.createElement("button");a.className="ask-capsule",a.textContent="YES",a.addEventListener("click",()=>r("y"));const o=document.createElement("button");o.className="ask-capsule ask-capsule-no",o.textContent="NO",o.addEventListener("click",()=>r("n")),s.append(" ",a," ",o)}this.input.focus(),this.size_fit()})}ask_note(e){this.block_append("argus-ask",`<span class="ask-glyph">?</span> ${Hs(e)}`);const t=this.output.lastElementChild;return this.size_fit(),s=>{t.classList.add("argus-ask-answered"),t.insertAdjacentHTML("beforeend",` <span class="ask-answer">${Hs(s??"abandoned")}</span>`),this.size_fit()}}askKey_handle(e){const t=this.pendingAsk;return t===null?!1:e.key==="Enter"?(e.preventDefault(),t.settle(this.input.value),!0):(e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),t.settle(null)),!0)}key_handle(e){if(!this.askKey_handle(e)){if(e.key==="Enter"){const t=this.input.value;this.input.value="",t.trim().length>0?this.line_run(t):this.busy||this.block_append("argus-echo",'<span class="prompt-glyph">❯</span>');return}if(e.key==="ArrowUp"){e.preventDefault(),this.historyIndex>0&&(this.historyIndex-=1,this.input.value=this.history[this.historyIndex]??"");return}if(e.key==="ArrowDown"){e.preventDefault(),this.historyIndex<this.history.length&&(this.historyIndex+=1,this.input.value=this.history[this.historyIndex]??"");return}e.key==="Tab"&&(e.preventDefault(),this.completion_apply())}}async completion_apply(){const e=this.input.value;if(e.length===0)return;let t;try{t=await this.complete(e)}catch{return}if(t.candidates.length===1){const s=t.candidates[0]??"";this.input.value=e.slice(0,e.length-t.prefix.length)+s;return}if(t.candidates.length>1){const s=Jx(t.candidates);s.length>t.prefix.length&&(this.input.value=e.slice(0,e.length-t.prefix.length)+s),this.block_append("dim",Hs(t.candidates.join(" "))),this.size_fit()}}history_push(e){this.history[this.history.length-1]!==e&&(this.history.push(e),this.history.length>Zx&&this.history.shift()),this.historyIndex=this.history.length}block_append(e,t){const s=document.createElement("div");s.className=`argus-line ${e}`,s.innerHTML=t,this.output.appendChild(s)}stream_ensure(){if(this.streamBlock===null){const e=document.createElement("div");e.className="argus-line argus-stream";const t=document.createElement("span");t.className="argus-stream-pending",e.appendChild(t),this.output.appendChild(e),this.streamBlock=e,this.streamPendingElement=t,this.streamPendingText="",this.streamPendingChannel="data"}return this.streamBlock}stream_close(){this.streamPendingText.length>0&&this.pending_commit(),this.streamPendingElement?.remove(),this.streamPendingElement=null,this.streamPendingText="",this.streamBlock=null}promptSegments_render(){const e=this.promptContext;if(e===null)return'<span class="dim">argus</span>';const t=e.uri.replace(/^https?:\/\//,"").replace(/\/api\/v1\/?$/,""),s=`/home/${e.user}`,i=e.cwd.startsWith(s)?`~${e.cwd.slice(s.length)}`:e.cwd,r=[];if(e.pacsserver!==null&&e.pacsserver.length>0&&r.push({text:`${kn.database} ${e.pacsserver}`,color:Gi.pacs}),r.push({text:`${kn.cube} ${t}`,color:Gi.host},{text:`${kn.user} ${e.user}`,color:Gi.user},{text:`${kn.folder} ${i}`,color:Gi.dir}),e.physicalMode&&r.push({text:`${kn.microscope} PHYSICAL`,color:Gi.physical}),e.procWarmup!==void 0){const o=bM(e.procWarmup),l=Yx[o];r.push({text:`${l.icon} ${l.label}: ${eS(e.procWarmup.loaded,e.procWarmup.total??0)}`,color:l.color})}if(e.lastCommandDurationMs>=Kx){const o=Math.floor(e.lastCommandDurationMs/1e3);r.push({text:`${kn.bolt} ${o}s`,color:Gi.duration})}e.lastExitCode!==0&&r.push({text:`${kn.error} ${e.lastExitCode}`,color:Gi.status});let a="";for(let o=0;o<r.length;o++){const l=r[o];if(l===void 0)continue;a+=`<span style="color:${l.color.fg};background-color:${l.color.bg}"> ${Hs(l.text)} </span>`;const c=r[o+1];a+=c!==void 0?`<span style="color:${l.color.bg};background-color:${c.color.bg}">${kn.powerline}</span>`:`<span style="color:${l.color.bg}">${kn.powerline}</span>`}return a}}function ca(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`console structure is missing '${e}'`);return t}function Jx(n){let e=n[0]??"";for(const t of n){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s++;if(e=e.slice(0,s),e.length===0)break}return e}function eS(n,e){if(e<=0)return`${n}/?`;const t=Math.min(99,Math.floor(n/e*100));return`${n}/${e} ${t}%`}const tS=100;function vf(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Of(n,e){if(e!=="bytes")return String(n);const t=["B","KB","MB","GB","TB"];let s=n,i=0;for(;s>=1024&&i<t.length-1;)s/=1024,i+=1;return`${i===0?s:s.toFixed(1)}${t[i]}`}class sS{region;line_commit;rows=new Map;elapsedTimer=null;constructor(e,t){this.region=e,this.line_commit=t}write(e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){if(e.phase==="failed"){const i=e.label??e.operation;this.line_commit(`\x1B[31m${i} — failed\x1B[0m
4202
+ `),this.streamPendingText=""}pending_paint(){this.streamPendingElement!==null&&(this.streamPendingElement.innerHTML=this.pending_toHtml())}pending_toHtml(){if(this.streamPendingText.length===0)return"";const e=Vn(this.streamPendingText);return this.streamPendingChannel==="status"?`<span class="dim">${e}</span>`:e}outcome_write(e){for(const t of e.envelopes){!e.liveChannels.has("data")&&t.rendered.length>0&&this.block_append("argus-result",Vn(t.rendered));const s=t.renderedErr??"";!e.liveChannels.has("err")&&s.length>0&&this.block_append("argus-result error",Vn(s))}}session_write(e,t){t.rendered.length!==0&&(this.block_append("dim",`[surface ${Hs(e.slice(0,6))}]`),this.block_append("argus-result",Vn(t.rendered)),this.size_fit())}line_note(e){this.block_append("argus-result",Hs(e)),this.size_fit()}line_echo(e){this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit()}line_offer(e){this.input.value=e,this.focus_take(),this.input.setSelectionRange(e.length,e.length)}question_set(e){this.questionOpen=e}line_run(e){if(this.busy&&!this.questionOpen){this.queuedLines.push(e);return}if(this.questionOpen){this.history_push(e),this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit(),this.submit(e);return}this.busy=!0,this.history_push(e),this.block_append("argus-echo",`<span class="prompt-glyph">❯</span> <span class="user-input">${Hs(e)}</span>`),this.size_fit(),this.submit(e)}ask_abandon(){const e=this.pendingAsk;return e===null?!1:(e.settle(null),!0)}ask_isOpen(){return this.pendingAsk!==null}ask_open(e){if(this.pendingAsk!==null)return Promise.resolve(null);const t=e.kind;this.block_append("argus-ask",`<span class="ask-glyph">?</span> ${Hs(e.message)}`);const s=this.output.lastElementChild;return new Promise(i=>{const r=a=>{if(this.pendingAsk===null)return;this.pendingAsk=null,this.questionOpen=!1,this.input.type="text",this.input.value="",this.inputGlyph.textContent="❯",s.classList.add("argus-ask-answered");const o=a===null?"abandoned":t==="secret"?"••••••":a;s.insertAdjacentHTML("beforeend",` <span class="ask-answer">${Hs(o)}</span>`),this.size_fit(),i(a)};if(this.pendingAsk={settle:r,kind:t},this.questionOpen=!0,this.inputGlyph.textContent="?",t==="secret"&&(this.input.type="password"),(t==="path"||t==="text")&&e.suggest!==void 0&&(this.input.value=e.suggest),t==="confirm"){const a=document.createElement("button");a.className="ask-capsule",a.textContent="YES",a.addEventListener("click",()=>r("y"));const o=document.createElement("button");o.className="ask-capsule ask-capsule-no",o.textContent="NO",o.addEventListener("click",()=>r("n")),s.append(" ",a," ",o)}this.input.focus(),this.size_fit()})}ask_note(e){this.block_append("argus-ask",`<span class="ask-glyph">?</span> ${Hs(e)}`);const t=this.output.lastElementChild;return this.size_fit(),s=>{t.classList.add("argus-ask-answered"),t.insertAdjacentHTML("beforeend",` <span class="ask-answer">${Hs(s??"abandoned")}</span>`),this.size_fit()}}askKey_handle(e){const t=this.pendingAsk;return t===null?!1:e.key==="Enter"?(e.preventDefault(),t.settle(this.input.value),!0):(e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),t.settle(null)),!0)}key_handle(e){if(!this.askKey_handle(e)){if(e.key==="Enter"){const t=this.input.value;this.input.value="",t.trim().length>0?this.line_run(t):this.busy||this.block_append("argus-echo",'<span class="prompt-glyph">❯</span>');return}if(e.key==="ArrowUp"){e.preventDefault(),this.historyIndex>0&&(this.historyIndex-=1,this.input.value=this.history[this.historyIndex]??"");return}if(e.key==="ArrowDown"){e.preventDefault(),this.historyIndex<this.history.length&&(this.historyIndex+=1,this.input.value=this.history[this.historyIndex]??"");return}e.key==="Tab"&&(e.preventDefault(),this.completion_apply())}}async completion_apply(){const e=this.input.value;if(e.length===0)return;let t;try{t=await this.complete(e)}catch{return}if(t.candidates.length===1){const s=t.candidates[0]??"";this.input.value=e.slice(0,e.length-t.prefix.length)+s;return}if(t.candidates.length>1){const s=nS(t.candidates);s.length>t.prefix.length&&(this.input.value=e.slice(0,e.length-t.prefix.length)+s),this.block_append("dim",Hs(t.candidates.join(" "))),this.size_fit()}}history_push(e){this.history[this.history.length-1]!==e&&(this.history.push(e),this.history.length>tS&&this.history.shift()),this.historyIndex=this.history.length}block_append(e,t){const s=document.createElement("div");s.className=`argus-line ${e}`,s.innerHTML=t,this.output.appendChild(s)}stream_ensure(){if(this.streamBlock===null){const e=document.createElement("div");e.className="argus-line argus-stream";const t=document.createElement("span");t.className="argus-stream-pending",e.appendChild(t),this.output.appendChild(e),this.streamBlock=e,this.streamPendingElement=t,this.streamPendingText="",this.streamPendingChannel="data"}return this.streamBlock}stream_close(){this.streamPendingText.length>0&&this.pending_commit(),this.streamPendingElement?.remove(),this.streamPendingElement=null,this.streamPendingText="",this.streamBlock=null}promptSegments_render(){const e=this.promptContext;if(e===null)return'<span class="dim">argus</span>';const t=e.uri.replace(/^https?:\/\//,"").replace(/\/api\/v1\/?$/,""),s=`/home/${e.user}`,i=e.cwd.startsWith(s)?`~${e.cwd.slice(s.length)}`:e.cwd,r=[];if(e.pacsserver!==null&&e.pacsserver.length>0&&r.push({text:`${kn.database} ${e.pacsserver}`,color:Gi.pacs}),r.push({text:`${kn.cube} ${t}`,color:Gi.host},{text:`${kn.user} ${e.user}`,color:Gi.user},{text:`${kn.folder} ${i}`,color:Gi.dir}),e.physicalMode&&r.push({text:`${kn.microscope} PHYSICAL`,color:Gi.physical}),e.procWarmup!==void 0){const o=bM(e.procWarmup),l=Jx[o];r.push({text:`${l.icon} ${l.label}: ${iS(e.procWarmup.loaded,e.procWarmup.total??0)}`,color:l.color})}if(e.lastCommandDurationMs>=eS){const o=Math.floor(e.lastCommandDurationMs/1e3);r.push({text:`${kn.bolt} ${o}s`,color:Gi.duration})}e.lastExitCode!==0&&r.push({text:`${kn.error} ${e.lastExitCode}`,color:Gi.status});let a="";for(let o=0;o<r.length;o++){const l=r[o];if(l===void 0)continue;a+=`<span style="color:${l.color.fg};background-color:${l.color.bg}"> ${Hs(l.text)} </span>`;const c=r[o+1];a+=c!==void 0?`<span style="color:${l.color.bg};background-color:${c.color.bg}">${kn.powerline}</span>`:`<span style="color:${l.color.bg}">${kn.powerline}</span>`}return a}}function ca(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`console structure is missing '${e}'`);return t}function nS(n){let e=n[0]??"";for(const t of n){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s++;if(e=e.slice(0,s),e.length===0)break}return e}function iS(n,e){if(e<=0)return`${n}/?`;const t=Math.min(99,Math.floor(n/e*100));return`${n}/${e} ${t}%`}const rS=100;function vf(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Of(n,e){if(e!=="bytes")return String(n);const t=["B","KB","MB","GB","TB"];let s=n,i=0;for(;s>=1024&&i<t.length-1;)s/=1024,i+=1;return`${i===0?s:s.toFixed(1)}${t[i]}`}class aS{region;line_commit;rows=new Map;elapsedTimer=null;constructor(e,t){this.region=e,this.line_commit=t}write(e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){if(e.phase==="failed"){const i=e.label??e.operation;this.line_commit(`\x1B[31m${i} — failed\x1B[0m
4203
4203
  `)}this.row_remove(t);return}const s=this.rows.get(t)??this.row_create(t,e);this.row_paint(s,e),this.elapsed_ensure()}clear(){for(const e of[...this.rows.keys()])this.row_remove(e)}row_create(e,t){const s=t.total!==void 0&&t.total>0,i=document.createElement("div");i.className="argus-progress-row",i.innerHTML=s?`<span class="argus-progress-label"></span>
4204
4204
  <span class="argus-progress-bar"><span class="argus-progress-fill"></span></span>
4205
4205
  <span class="argus-progress-elapsed"></span>`:`<span class="argus-progress-spin" aria-hidden="true"></span>
4206
4206
  <span class="argus-progress-label"></span>
4207
- <span class="argus-progress-elapsed"></span>`,this.region.appendChild(i);const r={element:i,labelElement:i.querySelector(".argus-progress-label"),barFill:i.querySelector(".argus-progress-fill"),startedAt:performance.now()};return this.rows.set(e,r),r}row_paint(e,t){const s=t.label??t.operation,i=t.current!==void 0&&t.total!==void 0&&t.total>0?` ${Of(t.current,t.unit)}/${Of(t.total,t.unit)}`:"";if(e.labelElement.innerHTML=`${vf(s)}<span class="argus-progress-counts">${vf(i)}</span>`,e.barFill!==null){const r=t.percent??(t.current!==void 0&&t.total!==void 0&&t.total>0?t.current/t.total*100:0);e.barFill.style.width=`${Math.max(0,Math.min(100,r))}%`}}row_remove(e){const t=this.rows.get(e);t!==void 0&&(t.element.remove(),this.rows.delete(e),this.rows.size===0&&this.elapsedTimer!==null&&(clearInterval(this.elapsedTimer),this.elapsedTimer=null))}elapsed_ensure(){this.elapsedTimer===null&&(this.elapsed_paint(),this.elapsedTimer=window.setInterval(()=>this.elapsed_paint(),tS))}elapsed_paint(){const e=performance.now();for(const t of this.rows.values()){const s=t.element.querySelector(".argus-progress-elapsed");s!==null&&(s.textContent=`${((e-t.startedAt)/1e3).toFixed(1)}s`)}}}class nS{root;capsRows=[];strip;input;columns;value_of;onChange;leadingCells;state={sortKey:null,sortDir:"asc",filter:""};changeQueued=!1;change_emit(){this.changeQueued||(this.changeQueued=!0,window.requestAnimationFrame(()=>{this.changeQueued=!1,this.onChange()}))}host_prepare(e){this.root.parentElement!==e&&e.prepend(this.root);for(const t of[...e.children])t!==this.root&&t.remove()}shown=0;total=0;constructor(e,t,s,i,r=0,a=!0){this.columns=e,this.value_of=t,this.onChange=s,i!==void 0&&(this.state={...this.state,sortKey:i.key,sortDir:i.dir}),this.leadingCells=r,this.root=document.createElement("div"),this.root.className="roster-order",this.strip=document.createElement("div"),this.strip.className="roster-filter",this.strip.hidden=!0;const o=document.createElement("span");o.className="roster-filter-glyph",o.textContent="FILTER :",this.input=document.createElement("input"),this.input.className="roster-filter-input",this.input.placeholder="text, or column:text (e.g. owner:<user> status:error)",this.input.setAttribute("autocomplete","off"),this.input.addEventListener("input",()=>this.filter_set(this.input.value,!1)),this.input.addEventListener("keydown",l=>{l.key==="Escape"&&(l.stopPropagation(),this.strip_toggle(!1))}),this.strip.append(o,this.input),a&&this.root.appendChild(this.caps_mint()),this.root.appendChild(this.strip),this.caps_paint()}caps_mint(){const e=document.createElement("div");e.className="roster-caps";for(let t=0;t<this.leadingCells;t++)e.appendChild(document.createElement("span"));for(const t of this.columns){const s=document.createElement("button");s.className="roster-cap",s.dataset.key=t.key,s.title=`sort by ${t.label.toLowerCase()} (again to reverse)`,s.addEventListener("click",()=>this.sort_toggle(t.key)),e.appendChild(s)}return this.capsRows.push(e),this.caps_paint(),e}state_get(){return{...this.state}}sort_toggle(e){this.state.sortKey===e?this.sort_set(e,this.state.sortDir==="asc"?"desc":"asc"):this.sort_set(e,"asc")}sort_set(e,t){this.columns.some(s=>s.key===e)&&(this.state={...this.state,sortKey:e,sortDir:t},this.caps_paint(),this.change_emit())}onFilter=null;filterChange_observe(e){this.onFilter=e}filterText_get(){return this.state.filter}filter_set(e,t=!0){this.state={...this.state,filter:e},this.onFilter?.(e),t&&(this.input.value=e),e.length>0&&this.strip.hidden&&(this.strip.hidden=!1,this.onStrip?.()),this.change_emit()}strip_toggle(e){const t=e??this.strip.hidden;this.strip.hidden=!t,t?this.input.focus():this.state.filter.length>0&&this.filter_set(""),this.onStrip?.()}strip_isOpen(){return!this.strip.hidden}onStrip=null;stripChange_observe(e){this.onStrip=e}matches(e){return this.terms_parse().every(t=>(t.key!==null?String(this.value_of(e,t.key)).toLowerCase():this.columns.map(i=>String(this.value_of(e,i.key))).join(" ").toLowerCase()).includes(t.text))}sorted(e){const t=[...e],s=this.state.sortKey;if(s===null)return t;const i=this.state.sortDir==="asc"?1:-1;return t.sort((r,a)=>{const o=this.value_of(r,s),l=this.value_of(a,s);return typeof o=="number"&&typeof l=="number"?(o-l)*i:String(o).localeCompare(String(l),void 0,{numeric:!0,sensitivity:"base"})*i}),t}counts_set(e,t){this.shown=e,this.total=t}terms_parse(){return this.state.filter.toLowerCase().split(/\s+/).filter(e=>e.length>0).map(e=>{const t=e.indexOf(":");if(t>0){const s=e.slice(0,t);if(this.columns.some(i=>i.key===s))return{key:s,text:e.slice(t+1)}}return{key:null,text:e}})}apply(e){const t=this.sorted(e.filter(s=>this.matches(s)));return this.shown=t.length,this.total=e.length,t}summary(){const e=[];return this.state.filter.length>0&&e.push(`FILTERED ${this.shown}/${this.total}`),e.join(" · ")}caps_paint(){const e=this.capsRows.filter(t=>t.parentElement===null||t.isConnected);this.capsRows.length=0,this.capsRows.push(...e);for(const t of this.capsRows)for(const s of t.querySelectorAll(".roster-cap")){const i=s.dataset.key??"",r=this.columns.find(o=>o.key===i),a=i===this.state.sortKey;s.classList.toggle("roster-active",a),s.textContent=`${r?.label??i}${a?this.state.sortDir==="asc"?" ▲":" ▼":""}`}}}class iS{container;order;field=null;constructor(e,t){this.container=e,this.order=t}field_open(){this.order.host_prepare(this.container);const e=document.createElement("div");return e.className="listing-field",this.container.appendChild(e),this.field=e,e}field_get(){return this.field}}function rS(n){return n.map(e=>({key:e.key,label:e.label}))}function aS(n){const e=new Map(n.map(t=>[t.key,t]));return(t,s)=>{const i=e.get(s);if(i===void 0)return"";if(i.compare!==void 0)return i.compare(t);const r=i.cell(t);return typeof r=="string"?r:r.textContent??""}}function oS(n,e,t){const s=document.createElement("div");s.className=t.className(n);for(const i of t.leading?.(n)??[])s.appendChild(i);for(const i of e){const r=i.cell(n);if(typeof r!="string"){s.appendChild(r);continue}const a=document.createElement("span");a.className=i.className,a.textContent=r,s.appendChild(a)}return t.decorate?.(s,n),s}function mo(n){let e=0,t=0,s=!1;for(const i of n)e+=i.done,t+=i.total,s=s||i.failed===!0;return{done:e,total:t,...s?{failed:!0}:{}}}function Ro(n){const e=document.createElement("span");if(e.className="listing-progress",n===null||n.total===0)return e.classList.add("listing-progress-idle"),e.title=n===null?"no work":"nothing scheduled yet",e;const t=n.failed===!0,s=n.done>=n.total,i=t&&n.succeeded!==void 0?n.succeeded:n.done,r=Math.min(1,Math.max(0,i/n.total));e.classList.add(t?"listing-progress-failed":s?"listing-progress-done":"listing-progress-running"),e.title=t&&n.succeeded!==void 0?`${n.succeeded}/${n.total} succeeded — errored`:`${n.done}/${n.total}`;const a=document.createElement("span");return a.className="listing-progress-fill",a.style.width=`${Math.round(r*100)}%`,e.appendChild(a),e}function Bo(n,e){const t=document.createElement("span");t.className="listing-actions";for(const s of e){if(s.offered!==void 0&&!s.offered(n))continue;const i=document.createElement("button");i.className="listing-action",i.textContent=s.label,s.disabled?.(n)===!0&&(i.disabled=!0),s.selected?.(n)===!0&&i.classList.add("listing-action-selected"),i.addEventListener("click",r=>{r.stopPropagation(),s.run(n)}),t.appendChild(i)}return t}function lS(n,e){return n.mode==="fold"&&n.open.has(e)}function cS(n,e){return n.mode!=="fold"||n.open.delete(e)?!1:(n.open.add(e),!0)}function Rr(n,e){return{level_visit(t){return t(n,e)}}}function xf(n,e){const t=[];let s=!1;for(const i of n){if(i.width===void 0||i.width.trim()==="")throw new Error(`listing trait '${i.key}' declares no width`);if(!Sf(i.width))throw new Error(`listing trait '${i.key}' declares a content-sized track '${i.width.trim()}': a row is its own grid, so a track sized to its content sizes per row and jogs every column after it`);if(i.capped===!1){if(s)throw new Error(`uncapped listing trait '${i.key}' must lead the traits`)}else s=!0;t.push(i.width.trim())}if(e!==void 0){if(e.width===void 0||e.width.trim()==="")throw new Error("listing actions on the row declare no track; declare a width, or a row zone for the verbs to ride");if(!Sf(e.width))throw new Error(`listing actions declare a content-sized track '${e.width.trim()}'`);t.push(e.width.trim())}return t.join(" ")}function Sf(n){const e=n.trim();if(/^(auto|min-content|max-content)$/.test(e)||/^fit-content\(/.test(e))return!1;const t=/^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(e);if(t!==null){const s=t[1]??"";return/^(?:[1-9]\d*|0*\.\d*[1-9]\d*|[1-9]\d*\.\d+)(px|em|rem|ch|vw|vh|%)$/.test(s)}return/^(?:\d+\.?\d*|\.\d+)(px|em|rem|ch|vw|vh|%|fr)$/.test(e)}function dS(n){let e=0;for(const t of n){if(t.capped!==!1)break;e+=1}return e}let wa=new Map,No=new Map;function uS(n){if(wa=new Map,No=new Map,n!==null)for(const e of n.handles)wa.has(e.address)||wa.set(e.address,e),No.set(e.kind,Math.max(No.get(e.kind)??0,`${e.ordinal}`.length));Lm()}function Wm(n){const e=Math.max(3,No.get(n.kind)??0);return`${n.kind}${`${n.ordinal}`.padStart(e,"0")}`}function Lm(){const n=new Map;for(const e of document.querySelectorAll(".listing-index")){const t=e.closest(".listing-row"),s=t?.parentElement??null;if(t===null||s===null)continue;if(t.classList.contains("listing-lead")){e.textContent="",e.classList.remove("numbered");continue}const i=n.get(s);i===void 0?n.set(s,[t]):i.push(t)}for(const e of n.values()){const t=`${Math.max(e.length,1)}`.length;e.forEach((s,i)=>{const r=s.querySelector(".listing-index");if(r===null)return;const a=r.dataset.address,o=a===void 0?void 0:wa.get(a);r.textContent=o===void 0?`${i+1}`.padStart(t,"0"):Wm(o),r.classList.toggle("numbered",o!==void 0)})}}function hS(n){return{key:"index",label:"",className:"listing-index-cell",width:"5.2rem",capped:!1,cell:e=>{const t=document.createElement("span");t.className="listing-index";const s=n?.(e);s!==void 0&&(t.dataset.address=s);const i=s===void 0?void 0:wa.get(s);return i!==void 0&&(t.textContent=Wm(i),t.classList.add("numbered")),t}}}class bu{declaration;host;select;order;template;child;expansion;rowsByKey=new Map;dataByKey=new Map;cellsByKey=new Map;leadKeys=new Set;indicated=null;depth;constructor(e,t,s,i,r=0){e={...e,traits:[hS(e.address),...e.traits]},this.declaration=e,this.host=t,this.select=i,this.depth=r,this.template=xf(e.traits,this.trackActions_get());const a=e.traits.filter(o=>o.capped!==!1);if(this.order=new nS(rS(a),aS(e.traits),()=>this.host.repaint(),e.defaultSort,dS(e.traits),s),this.expansion={mode:e.child===void 0?"replace":"fold",open:new Set},this.child=e.child===void 0?null:this.childSeat_build(e.child),this.child!==null){const o=this.child;this.order.filterChange_observe(l=>o.filter_set(l))}}childSeat_build(e){return e.level_visit((t,s)=>{const i=new bu(s,this.host,!1,null,this.depth+1);return{filter_set:r=>i.filter_set(r),sort_set:(r,a)=>i.sort_set(r,a),survives:r=>i.anyMatch(t(r)),render:(r,a,o)=>{const l=document.createElement("div");l.className="listing-level",l.dataset.depth=String(this.depth+1),l.style.setProperty("--roster-cols",i.template),l.appendChild(i.order.caps_mint()),i.rows_draw(t(r),[],l,o),a.appendChild(l)},forget:()=>i.forget(),open_set:(r,a)=>i.open_set(r,a),open_clear:()=>i.open_clear(),template_at:r=>i.template_at(r)}})}actions_set(e){this.declaration={...this.declaration,...e===null?{actions:void 0}:{actions:e}},this.template=xf(this.declaration.traits,this.trackActions_get())}trackActions_get(){return this.host.framed()?void 0:this.declaration.actions}filter_set(e){this.order.filter_set(e,!1)}sort_set(e,t){this.order.sort_set(e,t),this.child?.sort_set(e,t)}open_set(e,t){if(e===0){if(this.expansion.open.clear(),this.expansion.mode==="fold")for(const s of t)this.expansion.open.add(s);return}this.child?.open_set(e-1,t)}open_clear(){this.expansion.open.clear(),this.child?.open_clear()}template_at(e){if(e===0)return this.template;if(this.child===null)throw new Error(`no listing level at depth ${this.depth+e}`);return this.child.template_at(e-1)}anyMatch(e){return e.some(t=>this.order.matches(t)||(this.child?.survives(t)??!1))}filter_isEmpty(){return this.order.state_get().filter.length===0}rows_keep(e,t){const s=t?[...e]:e.filter(i=>this.order.matches(i)||(this.child?.survives(i)??!1));return this.order.sorted(s)}forget(){this.rowsByKey.clear(),this.dataByKey.clear(),this.cellsByKey.clear(),this.leadKeys.clear(),this.indicated=null,this.child?.forget()}rows_draw(e,t,s,i){for(const a of t)s.appendChild(this.row_build(a,!0));const r=this.rows_keep(e,i);for(const a of r){const o=this.row_build(a,!1);if(this.child===null){s.appendChild(o);continue}const l=this.declaration.key(a),c=this.order.filterText_get()!==""&&!this.order.matches(a)&&(this.child?.survives(a)??!1),d=lS(this.expansion,l)||c,h=document.createElement("div"),u=this.declaration.row?.groupClassName?.(a);h.className=`listing-group${d?" listing-open":""}${u===void 0||u===""?"":` ${u}`}`,h.appendChild(o),d&&(o.classList.add("listing-open"),this.child.render(a,h,i||this.order.matches(a))),s.appendChild(h)}return r.length}row_build(e,t){const s=this.declaration,i=s.key(e),r=this.host.framed(),a=oS(e,s.traits,{className:d=>{const h=s.row?.className?.(d);return h===void 0||h===""?"listing-row":`listing-row ${h}`},decorate:(d,h)=>{if(d.dataset.key=i,s.actions!==void 0&&!r){const u=document.createElement("span");u.className="listing-actions",!t&&s.actions.always===!0&&u.replaceChildren(...Bo(h,s.actions.of(h)).childNodes),d.appendChild(u),this.cellsByKey.set(i,u)}s.row?.decorate?.(d,h)}});if(this.rowsByKey.set(i,a),this.dataByKey.set(i,e),t&&(this.leadKeys.add(i),a.classList.add("listing-lead")),s.activatable?.(e)===!1)return a;a.classList.add("listing-activatable");const o=s.actions!==void 0&&s.actions.always!==!0&&s.actions.of(e).length>0,l=!t&&this.child!==null,c=this.controlCell_of(a);return a.addEventListener("click",d=>{if(!(!t&&this.select!==null&&this.select(i,e))){if(c!==null&&d.target instanceof Node&&c.contains(d.target)){l||this.row_indicate(null),this.row_activate(e,i,t);return}if(!o){this.row_activate(e,i,t);return}this.row_indicate(i),l&&c===null&&this.row_activate(e,i,!1)}}),o&&!l&&a.addEventListener("dblclick",()=>{this.row_indicate(null),this.row_activate(e,i,t)}),a}controlCell_of(e){const t=this.declaration.control;if(t===void 0)return null;const s=this.declaration.traits.findIndex(r=>r.key===t);if(s<0)throw new Error(`listing level declares control '${t}', which names no trait`);const i=e.children[s];return i instanceof HTMLElement?(i.classList.add("listing-control"),i):null}row_activate(e,t,s){!s&&this.child!==null&&(cS(this.expansion,t),this.host.repaint()),this.declaration.activate?.(e)}row_indicate(e,t=!1){const s=this.host.framed();if(this.indication_drop(),e===null){this.host.indication_release(this);return}const i=this.dataByKey.get(e),r=this.rowsByKey.get(e);if(i===void 0||r===void 0){this.host.indication_release(this);return}this.indicated=e,r.classList.add("listing-indicated");const a=this.declaration.actions?.of(i)??[];if(this.host.indication_claim({level:this,key:e,drop:()=>this.indication_drop(),restore:()=>this.rowsByKey.has(e)?(this.row_indicate(e,!0),!0):!1}),s)this.host.zoneVerbs_set([...Bo(i,a).childNodes]);else{const o=this.cellsByKey.get(e);o!==void 0&&a.length>0&&o.replaceChildren(...Bo(i,a).childNodes)}t||this.declaration.indicated?.(i)}indication_drop(){this.indicated!==null&&(this.cellsByKey.get(this.indicated)?.replaceChildren(),this.rowsByKey.get(this.indicated)?.classList.remove("listing-indicated"),this.indicated=null)}indicated_get(){return this.indicated}readout_show(e,t){if(this.indicated!==e)return;if(this.host.framed()){this.host.zoneReadout_set(t);return}const s=this.cellsByKey.get(e);if(s===void 0)return;const i=document.createElement("span");i.className="listing-readout",i.textContent=t,s.querySelector(".listing-readout")?.remove(),s.appendChild(i)}row_element(e){return this.rowsByKey.get(e)??null}keys_onStage(){return[...this.rowsByKey.keys()].filter(e=>!this.leadKeys.has(e))}}class Ur{declaration;level;host;gridHost;stateSpan;filterBlock;selectBlock;zone;wired=!1;zonePane_get(){return this.zone?.closest(".workspace-pane, [data-frame-host]")??null}zoneOpened=!1;claim=null;blocks=[];field=null;painter=null;selecting=!1;selection=new Map;repaintQueued=!1;constructor(e){if(this.declaration=e,this.gridHost=e.gridHost??e.mount,this.zone=e.rowZone??fS(e.mount,e.chrome?.prefix),e.selection!==void 0&&this.zone===null)throw new Error("a listing that selects declares a row zone: a selection's verbs ride the frame");this.level=new bu(e,{repaint:()=>this.repaint_queue(),framed:()=>this.zone!==null,zoneVerbs_set:s=>this.zoneVerbs_set(s),zoneReadout_set:s=>this.zoneReadout_set(s),indication_claim:s=>{this.claim!==null&&this.claim.level!==s.level&&this.claim.drop(),this.claim=s},indication_release:s=>{this.claim===null||this.claim.level!==s||(this.claim=null,this.zoneVerbs_set([]))}},e.caps!=="each",e.selection===void 0?null:(s,i)=>this.selection_gather(s,i)),this.host=new iS(e.mount,this.level.order),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.zone!==null&&(this.zone.classList.add("listing-zone"),this.zone.hidden=!0,e.mount.classList.add("listing-framed"),this.zone_wire());const t=e.chrome;this.stateSpan=t?.root.querySelector(".pane-state")??null,this.filterBlock=t?.root.querySelector(`.${t.prefix}-filter`)??null,this.selectBlock=t?.root.querySelector(`.${t.prefix}-select`)??null,this.filterBlock?.classList.add("rail-off"),this.filterBlock?.addEventListener("click",()=>this.filter_toggle()),this.level.order.stripChange_observe(()=>this.filterBlock_sync()),this.selectBlock?.addEventListener("click",()=>this.select_toggle()),t?.root.addEventListener("argus:roster",s=>{const i=s.detail;i.op==="sort"?this.level.sort_set(i.key,i.dir??"asc"):i.text===""?this.level.order.strip_toggle(!1):this.level.order.filter_set(i.text)}),this.filterBlock_sync()}rows_set(e,t){this.field!==null&&t.field!==this.field&&(this.selection.clear(),this.claim?.drop(),this.claim=null),this.field=t.field,this.blocks=e,this.render()}repaint_queue(){this.repaintQueued||(this.repaintQueued=!0,window.requestAnimationFrame(()=>{this.repaintQueued=!1,this.render()}))}render(){this.level.forget();const e=this.host.field_open(),t=this.level.filter_isEmpty();let s=0,i=0;const r=this.blocks.reduce((a,o)=>a+o.rows.length,0);this.blocks.length>0&&r===0&&this.declaration.empty!==void 0&&e.appendChild(this.declaration.empty());for(const a of this.blocks){const o=document.createElement("section");if(o.className="listing-block",o.dataset.key=a.key,a.header!==void 0&&o.appendChild(a.header),this.declaration.caps==="each"&&o.appendChild(this.level.order.caps_mint()),i+=a.rows.length,this.painter!==null){const l=this.level.rows_keep(a.rows,t);s+=l.length,this.painter({...a,rows:l},o)}else{const l=document.createElement("div");l.className="listing-rows",s+=this.level.rows_draw(a.rows,a.lead??[],l,t),o.appendChild(l)}e.appendChild(o)}this.level.order.counts_set(s,i),Lm(),this.claim!==null&&!this.claim.restore()&&(this.claim=null,this.zoneVerbs_set([])),this.selection_render(),this.state_render()}row_indicate(e){if(e===null){this.claim?.drop();const t=this.claim;this.claim=null,t!==null&&this.zoneVerbs_set([]);return}this.level.row_indicate(e)}indicated_get(){return this.claim?.key??null}indication_refresh(){this.claim!==null&&(this.claim.restore()||(this.claim=null,this.zoneVerbs_set([])))}readout_show(e,t){this.level.readout_show(e,t)}row_element(e){return this.level.row_element(e)}template_get(e=0){return this.level.template_at(e)}field_get(){return this.host.field_get()}open_set(e,t){this.level.open_set(e,t),this.field!==null&&this.render()}open_clear(){this.level.open_clear()}painter_set(e){this.painter=e}actions_declare(e){this.level.actions_set(e),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.field!==null&&this.render()}filter_toggle(e){this.level.order.strip_toggle(e)}filter_set(e){this.level.order.filter_set(e)}filterText_get(){return this.level.order.filterText_get()}filterBlock_sync(){if(this.filterBlock===null)return;const e=this.level.order.strip_isOpen();this.filterBlock.textContent=e?"FILTER ON":"FILTER OFF",this.filterBlock.classList.toggle("rail-off",!e)}select_toggle(e){this.declaration.selection!==void 0&&(this.selecting=e??!this.selecting,this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null),this.declaration.mount.classList.toggle("listing-selecting",this.selecting),this.selectBlock?.classList.toggle("rail-off",!this.selecting),this.selectBlock!==null&&(this.selectBlock.textContent=this.selecting?"SELECT ON":"SELECT OFF"),this.selection_render(),this.state_render())}select_isOn(){return this.selecting}selection_get(){return[...this.selection.keys()]}selection_gather(e,t){return this.selecting?(this.selection.has(e)?this.selection.delete(e):this.selection.set(e,t),this.selection_render(),this.state_render(),!0):!1}selection_render(){for(const s of this.level.keys_onStage())this.level.row_element(s)?.classList.toggle("listing-selected",this.selection.has(s));if(this.zone===null)return;if(!this.selecting){this.claim===null&&this.zoneVerbs_set([]);return}const e=[...this.selection.entries()],t=e.length>0?this.declaration.selection?.verbs(e)??[]:[];this.zoneVerbs_set(t.length===0?[]:[...Bo(void 0,t).childNodes])}zone_wire(){const e=this.zone,t=this.zonePane_get();if(e===null||t===null||this.wired)return;this.wired=!0,e.closest(".mode-frame")?.addEventListener("click",i=>{i.target instanceof Node&&e.contains(i.target)||(this.zoneOpened=!1)},!0),new MutationObserver(()=>{t.dataset.modes!=="open"&&(this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null))}).observe(t,{attributes:!0,attributeFilter:["data-modes"]})}zoneVerbs_set(e){const t=this.zone;if(t===null)return;t.replaceChildren(...e),t.hidden=e.length===0,this.wired||this.zone_wire();const s=this.zonePane_get();if(s!==null){if(e.length>0){s.dataset.modes!=="open"&&(s.dataset.modes="open",this.zoneOpened=!0);return}this.zoneOpened&&(this.zoneOpened=!1,delete s.dataset.modes)}}zoneReadout_set(e){const t=this.zone;if(t===null)return;t.querySelector(".listing-readout")?.remove();const s=document.createElement("span");s.className="listing-readout",s.textContent=e,t.appendChild(s),t.hidden=!1}selectionShown_count(){let e=0;for(const t of this.selection.keys())this.level.row_element(t)!==null&&(e+=1);return e}state_refresh(){this.state_render()}state_render(){if(this.stateSpan===null)return;const e={filter:this.level.order.summary(),selecting:this.selecting,selected:this.selection.size,shown:this.selectionShown_count()},t=this.declaration.state!==void 0?this.declaration.state(e):pS(e);t!==null&&(this.stateSpan.textContent=t)}}function fS(n,e){const t=n.parentElement?.querySelector(":scope > .mode-frame")??null;if(t===null)return null;const s=document.createElement("span");s.className=e===void 0?"listing-zone":`listing-zone ${e}-row-zone`,s.hidden=!0;const i=t.querySelector(":scope > .mode-fill");return i!==null?t.insertBefore(s,i):t.appendChild(s),s}function pS(n){const e=[];return n.selecting&&e.push("SELECT"),n.filter!==""&&e.push(n.filter),n.selected>0&&e.push(n.shown===n.selected?`${n.selected} SELECTED`:`${n.selected} SELECTED · ${n.shown} SHOWN`),e.join(" · ")}const mS=["single","mpr","3d","slab"],Af=["wl","zoom","pan","length","angle","probe"],Co=["gray","hot","jet","cool"],km=[{name:"brain",lower:0,upper:80,modalities:["CT"]},{name:"bone",lower:-500,upper:1300,modalities:["CT"]},{name:"lung",lower:-1400,upper:200,modalities:["CT"]},{name:"soft",lower:-160,upper:240,modalities:["CT"]},{name:"liver",lower:-10,upper:140,modalities:["CT"]}],Mc=/\.(nii|nii\.gz|mgz|mgh)$/i,Po=/\.dcm$/i,Um=/^\d+-.*-[0-9a-f]{7}$/,Ef="/SERVICES/PACS/",MS=4;function gc(n,e){if(Um.test(e))return!0;if(!n.startsWith(Ef))return!1;const t=n.slice(Ef.length).replace(/\/+$/,"");return t!==""&&t.split("/").length===MS}function gS(n,e){const t=n.toLowerCase();return km.find(s=>s.name===t&&(s.modalities.length===0||s.modalities.includes(e.toUpperCase())))}function bS(n,e){const t=[];let s="",i=[],r=!1,a=0,o=!1;const l=()=>{i.push(s),s="",o=!0},c=()=>{t.push(i),i=[],o=!1};for(;a<n.length;){const d=n[a];if(r){if(d==='"'){if(n[a+1]==='"'){s+='"',a+=2;continue}r=!1,a+=1;continue}s+=d,a+=1;continue}if(d==='"'&&s===""){r=!0,a+=1;continue}if(d===e){l(),a+=1;continue}if(d==="\r"&&n[a+1]===`
4207
+ <span class="argus-progress-elapsed"></span>`,this.region.appendChild(i);const r={element:i,labelElement:i.querySelector(".argus-progress-label"),barFill:i.querySelector(".argus-progress-fill"),startedAt:performance.now()};return this.rows.set(e,r),r}row_paint(e,t){const s=t.label??t.operation,i=t.current!==void 0&&t.total!==void 0&&t.total>0?` ${Of(t.current,t.unit)}/${Of(t.total,t.unit)}`:"";if(e.labelElement.innerHTML=`${vf(s)}<span class="argus-progress-counts">${vf(i)}</span>`,e.barFill!==null){const r=t.percent??(t.current!==void 0&&t.total!==void 0&&t.total>0?t.current/t.total*100:0);e.barFill.style.width=`${Math.max(0,Math.min(100,r))}%`}}row_remove(e){const t=this.rows.get(e);t!==void 0&&(t.element.remove(),this.rows.delete(e),this.rows.size===0&&this.elapsedTimer!==null&&(clearInterval(this.elapsedTimer),this.elapsedTimer=null))}elapsed_ensure(){this.elapsedTimer===null&&(this.elapsed_paint(),this.elapsedTimer=window.setInterval(()=>this.elapsed_paint(),rS))}elapsed_paint(){const e=performance.now();for(const t of this.rows.values()){const s=t.element.querySelector(".argus-progress-elapsed");s!==null&&(s.textContent=`${((e-t.startedAt)/1e3).toFixed(1)}s`)}}}class oS{root;capsRows=[];strip;input;columns;value_of;onChange;leadingCells;state={sortKey:null,sortDir:"asc",filter:""};changeQueued=!1;change_emit(){this.changeQueued||(this.changeQueued=!0,window.requestAnimationFrame(()=>{this.changeQueued=!1,this.onChange()}))}host_prepare(e){this.root.parentElement!==e&&e.prepend(this.root);for(const t of[...e.children])t!==this.root&&t.remove()}shown=0;total=0;constructor(e,t,s,i,r=0,a=!0){this.columns=e,this.value_of=t,this.onChange=s,i!==void 0&&(this.state={...this.state,sortKey:i.key,sortDir:i.dir}),this.leadingCells=r,this.root=document.createElement("div"),this.root.className="roster-order",this.strip=document.createElement("div"),this.strip.className="roster-filter",this.strip.hidden=!0;const o=document.createElement("span");o.className="roster-filter-glyph",o.textContent="FILTER :",this.input=document.createElement("input"),this.input.className="roster-filter-input",this.input.placeholder="text, or column:text (e.g. owner:<user> status:error)",this.input.setAttribute("autocomplete","off"),this.input.addEventListener("input",()=>this.filter_set(this.input.value,!1)),this.input.addEventListener("keydown",l=>{l.key==="Escape"&&(l.stopPropagation(),this.strip_toggle(!1))}),this.strip.append(o,this.input),a&&this.root.appendChild(this.caps_mint()),this.root.appendChild(this.strip),this.caps_paint()}caps_mint(){const e=document.createElement("div");e.className="roster-caps";for(let t=0;t<this.leadingCells;t++)e.appendChild(document.createElement("span"));for(const t of this.columns){const s=document.createElement("button");s.className="roster-cap",s.dataset.key=t.key,s.title=`sort by ${t.label.toLowerCase()} (again to reverse)`,s.addEventListener("click",()=>this.sort_toggle(t.key)),e.appendChild(s)}return this.capsRows.push(e),this.caps_paint(),e}state_get(){return{...this.state}}sort_toggle(e){this.state.sortKey===e?this.sort_set(e,this.state.sortDir==="asc"?"desc":"asc"):this.sort_set(e,"asc")}sort_set(e,t){this.columns.some(s=>s.key===e)&&(this.state={...this.state,sortKey:e,sortDir:t},this.caps_paint(),this.change_emit())}onFilter=null;filterChange_observe(e){this.onFilter=e}filterText_get(){return this.state.filter}filter_set(e,t=!0){this.state={...this.state,filter:e},this.onFilter?.(e),t&&(this.input.value=e),e.length>0&&this.strip.hidden&&(this.strip.hidden=!1,this.onStrip?.()),this.change_emit()}strip_toggle(e){const t=e??this.strip.hidden;this.strip.hidden=!t,t?this.input.focus():this.state.filter.length>0&&this.filter_set(""),this.onStrip?.()}strip_isOpen(){return!this.strip.hidden}onStrip=null;stripChange_observe(e){this.onStrip=e}matches(e){return this.terms_parse().every(t=>(t.key!==null?String(this.value_of(e,t.key)).toLowerCase():this.columns.map(i=>String(this.value_of(e,i.key))).join(" ").toLowerCase()).includes(t.text))}sorted(e){const t=[...e],s=this.state.sortKey;if(s===null)return t;const i=this.state.sortDir==="asc"?1:-1;return t.sort((r,a)=>{const o=this.value_of(r,s),l=this.value_of(a,s);return typeof o=="number"&&typeof l=="number"?(o-l)*i:String(o).localeCompare(String(l),void 0,{numeric:!0,sensitivity:"base"})*i}),t}counts_set(e,t){this.shown=e,this.total=t}terms_parse(){return this.state.filter.toLowerCase().split(/\s+/).filter(e=>e.length>0).map(e=>{const t=e.indexOf(":");if(t>0){const s=e.slice(0,t);if(this.columns.some(i=>i.key===s))return{key:s,text:e.slice(t+1)}}return{key:null,text:e}})}apply(e){const t=this.sorted(e.filter(s=>this.matches(s)));return this.shown=t.length,this.total=e.length,t}summary(){const e=[];return this.state.filter.length>0&&e.push(`FILTERED ${this.shown}/${this.total}`),e.join(" · ")}caps_paint(){const e=this.capsRows.filter(t=>t.parentElement===null||t.isConnected);this.capsRows.length=0,this.capsRows.push(...e);for(const t of this.capsRows)for(const s of t.querySelectorAll(".roster-cap")){const i=s.dataset.key??"",r=this.columns.find(o=>o.key===i),a=i===this.state.sortKey;s.classList.toggle("roster-active",a),s.textContent=`${r?.label??i}${a?this.state.sortDir==="asc"?" ▲":" ▼":""}`}}}class lS{container;order;field=null;constructor(e,t){this.container=e,this.order=t}field_open(){this.order.host_prepare(this.container);const e=document.createElement("div");return e.className="listing-field",this.container.appendChild(e),this.field=e,e}field_get(){return this.field}}function cS(n){return n.map(e=>({key:e.key,label:e.label}))}function dS(n){const e=new Map(n.map(t=>[t.key,t]));return(t,s)=>{const i=e.get(s);if(i===void 0)return"";if(i.compare!==void 0)return i.compare(t);const r=i.cell(t);return typeof r=="string"?r:r.textContent??""}}function uS(n,e,t){const s=document.createElement("div");s.className=t.className(n);for(const i of t.leading?.(n)??[])s.appendChild(i);for(const i of e){const r=i.cell(n);if(typeof r!="string"){s.appendChild(r);continue}const a=document.createElement("span");a.className=i.className,a.textContent=r,s.appendChild(a)}return t.decorate?.(s,n),s}function mo(n){let e=0,t=0,s=!1;for(const i of n)e+=i.done,t+=i.total,s=s||i.failed===!0;return{done:e,total:t,...s?{failed:!0}:{}}}function Ro(n){const e=document.createElement("span");if(e.className="listing-progress",n===null||n.total===0)return e.classList.add("listing-progress-idle"),e.title=n===null?"no work":"nothing scheduled yet",e;const t=n.failed===!0,s=n.done>=n.total,i=t&&n.succeeded!==void 0?n.succeeded:n.done,r=Math.min(1,Math.max(0,i/n.total));e.classList.add(t?"listing-progress-failed":s?"listing-progress-done":"listing-progress-running"),e.title=t&&n.succeeded!==void 0?`${n.succeeded}/${n.total} succeeded — errored`:`${n.done}/${n.total}`;const a=document.createElement("span");return a.className="listing-progress-fill",a.style.width=`${Math.round(r*100)}%`,e.appendChild(a),e}function Bo(n,e){const t=document.createElement("span");t.className="listing-actions";for(const s of e){if(s.offered!==void 0&&!s.offered(n))continue;const i=document.createElement("button");i.className="listing-action",i.textContent=s.label,s.disabled?.(n)===!0&&(i.disabled=!0),s.selected?.(n)===!0&&i.classList.add("listing-action-selected"),i.addEventListener("click",r=>{r.stopPropagation(),s.run(n)}),t.appendChild(i)}return t}function hS(n,e){return n.mode==="fold"&&n.open.has(e)}function fS(n,e){return n.mode!=="fold"||n.open.delete(e)?!1:(n.open.add(e),!0)}function Rr(n,e){return{level_visit(t){return t(n,e)}}}function xf(n,e){const t=[];let s=!1;for(const i of n){if(i.width===void 0||i.width.trim()==="")throw new Error(`listing trait '${i.key}' declares no width`);if(!Sf(i.width))throw new Error(`listing trait '${i.key}' declares a content-sized track '${i.width.trim()}': a row is its own grid, so a track sized to its content sizes per row and jogs every column after it`);if(i.capped===!1){if(s)throw new Error(`uncapped listing trait '${i.key}' must lead the traits`)}else s=!0;t.push(i.width.trim())}if(e!==void 0){if(e.width===void 0||e.width.trim()==="")throw new Error("listing actions on the row declare no track; declare a width, or a row zone for the verbs to ride");if(!Sf(e.width))throw new Error(`listing actions declare a content-sized track '${e.width.trim()}'`);t.push(e.width.trim())}return t.join(" ")}function Sf(n){const e=n.trim();if(/^(auto|min-content|max-content)$/.test(e)||/^fit-content\(/.test(e))return!1;const t=/^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(e);if(t!==null){const s=t[1]??"";return/^(?:[1-9]\d*|0*\.\d*[1-9]\d*|[1-9]\d*\.\d+)(px|em|rem|ch|vw|vh|%)$/.test(s)}return/^(?:\d+\.?\d*|\.\d+)(px|em|rem|ch|vw|vh|%|fr)$/.test(e)}function pS(n){let e=0;for(const t of n){if(t.capped!==!1)break;e+=1}return e}let wa=new Map,No=new Map;function mS(n){if(wa=new Map,No=new Map,n!==null)for(const e of n.handles)wa.has(e.address)||wa.set(e.address,e),No.set(e.kind,Math.max(No.get(e.kind)??0,`${e.ordinal}`.length));Lm()}function Wm(n){const e=Math.max(3,No.get(n.kind)??0);return`${n.kind}${`${n.ordinal}`.padStart(e,"0")}`}function Lm(){const n=new Map;for(const e of document.querySelectorAll(".listing-index")){const t=e.closest(".listing-row"),s=t?.parentElement??null;if(t===null||s===null)continue;if(t.classList.contains("listing-lead")){e.textContent="",e.classList.remove("numbered");continue}const i=n.get(s);i===void 0?n.set(s,[t]):i.push(t)}for(const e of n.values()){const t=`${Math.max(e.length,1)}`.length;e.forEach((s,i)=>{const r=s.querySelector(".listing-index");if(r===null)return;const a=r.dataset.address,o=a===void 0?void 0:wa.get(a);r.textContent=o===void 0?`${i+1}`.padStart(t,"0"):Wm(o),r.classList.toggle("numbered",o!==void 0)})}}function MS(n){return{key:"index",label:"",className:"listing-index-cell",width:"5.2rem",capped:!1,cell:e=>{const t=document.createElement("span");t.className="listing-index";const s=n?.(e);s!==void 0&&(t.dataset.address=s);const i=s===void 0?void 0:wa.get(s);return i!==void 0&&(t.textContent=Wm(i),t.classList.add("numbered")),t}}}class bu{declaration;host;select;order;template;child;expansion;rowsByKey=new Map;dataByKey=new Map;cellsByKey=new Map;leadKeys=new Set;indicated=null;depth;constructor(e,t,s,i,r=0){e={...e,traits:[MS(e.address),...e.traits]},this.declaration=e,this.host=t,this.select=i,this.depth=r,this.template=xf(e.traits,this.trackActions_get());const a=e.traits.filter(o=>o.capped!==!1);if(this.order=new oS(cS(a),dS(e.traits),()=>this.host.repaint(),e.defaultSort,pS(e.traits),s),this.expansion={mode:e.child===void 0?"replace":"fold",open:new Set},this.child=e.child===void 0?null:this.childSeat_build(e.child),this.child!==null){const o=this.child;this.order.filterChange_observe(l=>o.filter_set(l))}}childSeat_build(e){return e.level_visit((t,s)=>{const i=new bu(s,this.host,!1,null,this.depth+1);return{filter_set:r=>i.filter_set(r),sort_set:(r,a)=>i.sort_set(r,a),survives:r=>i.anyMatch(t(r)),render:(r,a,o)=>{const l=document.createElement("div");l.className="listing-level",l.dataset.depth=String(this.depth+1),l.style.setProperty("--roster-cols",i.template),l.appendChild(i.order.caps_mint()),i.rows_draw(t(r),[],l,o),a.appendChild(l)},forget:()=>i.forget(),open_set:(r,a)=>i.open_set(r,a),open_clear:()=>i.open_clear(),template_at:r=>i.template_at(r)}})}actions_set(e){this.declaration={...this.declaration,...e===null?{actions:void 0}:{actions:e}},this.template=xf(this.declaration.traits,this.trackActions_get())}trackActions_get(){return this.host.framed()?void 0:this.declaration.actions}filter_set(e){this.order.filter_set(e,!1)}sort_set(e,t){this.order.sort_set(e,t),this.child?.sort_set(e,t)}open_set(e,t){if(e===0){if(this.expansion.open.clear(),this.expansion.mode==="fold")for(const s of t)this.expansion.open.add(s);return}this.child?.open_set(e-1,t)}open_clear(){this.expansion.open.clear(),this.child?.open_clear()}template_at(e){if(e===0)return this.template;if(this.child===null)throw new Error(`no listing level at depth ${this.depth+e}`);return this.child.template_at(e-1)}anyMatch(e){return e.some(t=>this.order.matches(t)||(this.child?.survives(t)??!1))}filter_isEmpty(){return this.order.state_get().filter.length===0}rows_keep(e,t){const s=t?[...e]:e.filter(i=>this.order.matches(i)||(this.child?.survives(i)??!1));return this.order.sorted(s)}forget(){this.rowsByKey.clear(),this.dataByKey.clear(),this.cellsByKey.clear(),this.leadKeys.clear(),this.indicated=null,this.child?.forget()}rows_draw(e,t,s,i){for(const a of t)s.appendChild(this.row_build(a,!0));const r=this.rows_keep(e,i);for(const a of r){const o=this.row_build(a,!1);if(this.child===null){s.appendChild(o);continue}const l=this.declaration.key(a),c=this.order.filterText_get()!==""&&!this.order.matches(a)&&(this.child?.survives(a)??!1),d=hS(this.expansion,l)||c,h=document.createElement("div"),u=this.declaration.row?.groupClassName?.(a);h.className=`listing-group${d?" listing-open":""}${u===void 0||u===""?"":` ${u}`}`,h.appendChild(o),d&&(o.classList.add("listing-open"),this.child.render(a,h,i||this.order.matches(a))),s.appendChild(h)}return r.length}row_build(e,t){const s=this.declaration,i=s.key(e),r=this.host.framed(),a=uS(e,s.traits,{className:d=>{const h=s.row?.className?.(d);return h===void 0||h===""?"listing-row":`listing-row ${h}`},decorate:(d,h)=>{if(d.dataset.key=i,s.actions!==void 0&&!r){const u=document.createElement("span");u.className="listing-actions",!t&&s.actions.always===!0&&u.replaceChildren(...Bo(h,s.actions.of(h)).childNodes),d.appendChild(u),this.cellsByKey.set(i,u)}s.row?.decorate?.(d,h)}});if(this.rowsByKey.set(i,a),this.dataByKey.set(i,e),t&&(this.leadKeys.add(i),a.classList.add("listing-lead")),s.activatable?.(e)===!1)return a;a.classList.add("listing-activatable");const o=s.actions!==void 0&&s.actions.always!==!0&&s.actions.of(e).length>0,l=!t&&this.child!==null,c=this.controlCell_of(a);return a.addEventListener("click",d=>{if(!(!t&&this.select!==null&&this.select(i,e))){if(c!==null&&d.target instanceof Node&&c.contains(d.target)){l||this.row_indicate(null),this.row_activate(e,i,t);return}if(!o){this.row_activate(e,i,t);return}this.row_indicate(i),l&&c===null&&this.row_activate(e,i,!1)}}),o&&!l&&a.addEventListener("dblclick",()=>{this.row_indicate(null),this.row_activate(e,i,t)}),a}controlCell_of(e){const t=this.declaration.control;if(t===void 0)return null;const s=this.declaration.traits.findIndex(r=>r.key===t);if(s<0)throw new Error(`listing level declares control '${t}', which names no trait`);const i=e.children[s];return i instanceof HTMLElement?(i.classList.add("listing-control"),i):null}row_activate(e,t,s){!s&&this.child!==null&&(fS(this.expansion,t),this.host.repaint()),this.declaration.activate?.(e)}row_indicate(e,t=!1){const s=this.host.framed();if(this.indication_drop(),e===null){this.host.indication_release(this);return}const i=this.dataByKey.get(e),r=this.rowsByKey.get(e);if(i===void 0||r===void 0){this.host.indication_release(this);return}this.indicated=e,r.classList.add("listing-indicated");const a=this.declaration.actions?.of(i)??[];if(this.host.indication_claim({level:this,key:e,drop:()=>this.indication_drop(),restore:()=>this.rowsByKey.has(e)?(this.row_indicate(e,!0),!0):!1}),s)this.host.zoneVerbs_set([...Bo(i,a).childNodes]);else{const o=this.cellsByKey.get(e);o!==void 0&&a.length>0&&o.replaceChildren(...Bo(i,a).childNodes)}t||this.declaration.indicated?.(i)}indication_drop(){this.indicated!==null&&(this.cellsByKey.get(this.indicated)?.replaceChildren(),this.rowsByKey.get(this.indicated)?.classList.remove("listing-indicated"),this.indicated=null)}indicated_get(){return this.indicated}readout_show(e,t){if(this.indicated!==e)return;if(this.host.framed()){this.host.zoneReadout_set(t);return}const s=this.cellsByKey.get(e);if(s===void 0)return;const i=document.createElement("span");i.className="listing-readout",i.textContent=t,s.querySelector(".listing-readout")?.remove(),s.appendChild(i)}row_element(e){return this.rowsByKey.get(e)??null}keys_onStage(){return[...this.rowsByKey.keys()].filter(e=>!this.leadKeys.has(e))}}class Ur{declaration;level;host;gridHost;stateSpan;filterBlock;selectBlock;zone;wired=!1;zonePane_get(){return this.zone?.closest(".workspace-pane, [data-frame-host]")??null}zoneOpened=!1;claim=null;blocks=[];field=null;painter=null;selecting=!1;selection=new Map;repaintQueued=!1;constructor(e){if(this.declaration=e,this.gridHost=e.gridHost??e.mount,this.zone=e.rowZone??gS(e.mount,e.chrome?.prefix),e.selection!==void 0&&this.zone===null)throw new Error("a listing that selects declares a row zone: a selection's verbs ride the frame");this.level=new bu(e,{repaint:()=>this.repaint_queue(),framed:()=>this.zone!==null,zoneVerbs_set:s=>this.zoneVerbs_set(s),zoneReadout_set:s=>this.zoneReadout_set(s),indication_claim:s=>{this.claim!==null&&this.claim.level!==s.level&&this.claim.drop(),this.claim=s},indication_release:s=>{this.claim===null||this.claim.level!==s||(this.claim=null,this.zoneVerbs_set([]))}},e.caps!=="each",e.selection===void 0?null:(s,i)=>this.selection_gather(s,i)),this.host=new lS(e.mount,this.level.order),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.zone!==null&&(this.zone.classList.add("listing-zone"),this.zone.hidden=!0,e.mount.classList.add("listing-framed"),this.zone_wire());const t=e.chrome;this.stateSpan=t?.root.querySelector(".pane-state")??null,this.filterBlock=t?.root.querySelector(`.${t.prefix}-filter`)??null,this.selectBlock=t?.root.querySelector(`.${t.prefix}-select`)??null,this.filterBlock?.classList.add("rail-off"),this.filterBlock?.addEventListener("click",()=>this.filter_toggle()),this.level.order.stripChange_observe(()=>this.filterBlock_sync()),this.selectBlock?.addEventListener("click",()=>this.select_toggle()),t?.root.addEventListener("argus:roster",s=>{const i=s.detail;i.op==="sort"?this.level.sort_set(i.key,i.dir??"asc"):i.text===""?this.level.order.strip_toggle(!1):this.level.order.filter_set(i.text)}),this.filterBlock_sync()}rows_set(e,t){this.field!==null&&t.field!==this.field&&(this.selection.clear(),this.claim?.drop(),this.claim=null),this.field=t.field,this.blocks=e,this.render()}repaint_queue(){this.repaintQueued||(this.repaintQueued=!0,window.requestAnimationFrame(()=>{this.repaintQueued=!1,this.render()}))}render(){this.level.forget();const e=this.host.field_open(),t=this.level.filter_isEmpty();let s=0,i=0;const r=this.blocks.reduce((a,o)=>a+o.rows.length,0);this.blocks.length>0&&r===0&&this.declaration.empty!==void 0&&e.appendChild(this.declaration.empty());for(const a of this.blocks){const o=document.createElement("section");if(o.className="listing-block",o.dataset.key=a.key,a.header!==void 0&&o.appendChild(a.header),this.declaration.caps==="each"&&o.appendChild(this.level.order.caps_mint()),i+=a.rows.length,this.painter!==null){const l=this.level.rows_keep(a.rows,t);s+=l.length,this.painter({...a,rows:l},o)}else{const l=document.createElement("div");l.className="listing-rows",s+=this.level.rows_draw(a.rows,a.lead??[],l,t),o.appendChild(l)}e.appendChild(o)}this.level.order.counts_set(s,i),Lm(),this.claim!==null&&!this.claim.restore()&&(this.claim=null,this.zoneVerbs_set([])),this.selection_render(),this.state_render()}row_indicate(e){if(e===null){this.claim?.drop();const t=this.claim;this.claim=null,t!==null&&this.zoneVerbs_set([]);return}this.level.row_indicate(e)}indicated_get(){return this.claim?.key??null}indication_refresh(){this.claim!==null&&(this.claim.restore()||(this.claim=null,this.zoneVerbs_set([])))}readout_show(e,t){this.level.readout_show(e,t)}row_element(e){return this.level.row_element(e)}template_get(e=0){return this.level.template_at(e)}field_get(){return this.host.field_get()}open_set(e,t){this.level.open_set(e,t),this.field!==null&&this.render()}open_clear(){this.level.open_clear()}painter_set(e){this.painter=e}actions_declare(e){this.level.actions_set(e),this.gridHost.style.setProperty("--roster-cols",this.level.template),this.field!==null&&this.render()}filter_toggle(e){this.level.order.strip_toggle(e)}filter_set(e){this.level.order.filter_set(e)}filterText_get(){return this.level.order.filterText_get()}filterBlock_sync(){if(this.filterBlock===null)return;const e=this.level.order.strip_isOpen();this.filterBlock.textContent=e?"FILTER ON":"FILTER OFF",this.filterBlock.classList.toggle("rail-off",!e)}select_toggle(e){this.declaration.selection!==void 0&&(this.selecting=e??!this.selecting,this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null),this.declaration.mount.classList.toggle("listing-selecting",this.selecting),this.selectBlock?.classList.toggle("rail-off",!this.selecting),this.selectBlock!==null&&(this.selectBlock.textContent=this.selecting?"SELECT ON":"SELECT OFF"),this.selection_render(),this.state_render())}select_isOn(){return this.selecting}selection_get(){return[...this.selection.keys()]}selection_gather(e,t){return this.selecting?(this.selection.has(e)?this.selection.delete(e):this.selection.set(e,t),this.selection_render(),this.state_render(),!0):!1}selection_render(){for(const s of this.level.keys_onStage())this.level.row_element(s)?.classList.toggle("listing-selected",this.selection.has(s));if(this.zone===null)return;if(!this.selecting){this.claim===null&&this.zoneVerbs_set([]);return}const e=[...this.selection.entries()],t=e.length>0?this.declaration.selection?.verbs(e)??[]:[];this.zoneVerbs_set(t.length===0?[]:[...Bo(void 0,t).childNodes])}zone_wire(){const e=this.zone,t=this.zonePane_get();if(e===null||t===null||this.wired)return;this.wired=!0,e.closest(".mode-frame")?.addEventListener("click",i=>{i.target instanceof Node&&e.contains(i.target)||(this.zoneOpened=!1)},!0),new MutationObserver(()=>{t.dataset.modes!=="open"&&(this.zoneOpened=!1,this.claim!==null&&this.row_indicate(null))}).observe(t,{attributes:!0,attributeFilter:["data-modes"]})}zoneVerbs_set(e){const t=this.zone;if(t===null)return;t.replaceChildren(...e),t.hidden=e.length===0,this.wired||this.zone_wire();const s=this.zonePane_get();if(s!==null){if(e.length>0){s.dataset.modes!=="open"&&(s.dataset.modes="open",this.zoneOpened=!0);return}this.zoneOpened&&(this.zoneOpened=!1,delete s.dataset.modes)}}zoneReadout_set(e){const t=this.zone;if(t===null)return;t.querySelector(".listing-readout")?.remove();const s=document.createElement("span");s.className="listing-readout",s.textContent=e,t.appendChild(s),t.hidden=!1}selectionShown_count(){let e=0;for(const t of this.selection.keys())this.level.row_element(t)!==null&&(e+=1);return e}state_refresh(){this.state_render()}state_render(){if(this.stateSpan===null)return;const e={filter:this.level.order.summary(),selecting:this.selecting,selected:this.selection.size,shown:this.selectionShown_count()},t=this.declaration.state!==void 0?this.declaration.state(e):bS(e);t!==null&&(this.stateSpan.textContent=t)}}function gS(n,e){const t=n.parentElement?.querySelector(":scope > .mode-frame")??null;if(t===null)return null;const s=document.createElement("span");s.className=e===void 0?"listing-zone":`listing-zone ${e}-row-zone`,s.hidden=!0;const i=t.querySelector(":scope > .mode-fill");return i!==null?t.insertBefore(s,i):t.appendChild(s),s}function bS(n){const e=[];return n.selecting&&e.push("SELECT"),n.filter!==""&&e.push(n.filter),n.selected>0&&e.push(n.shown===n.selected?`${n.selected} SELECTED`:`${n.selected} SELECTED · ${n.shown} SHOWN`),e.join(" · ")}const zS=["single","mpr","3d","slab"],Af=["wl","zoom","pan","length","angle","probe"],Co=["gray","hot","jet","cool"],km=[{name:"brain",lower:0,upper:80,modalities:["CT"]},{name:"bone",lower:-500,upper:1300,modalities:["CT"]},{name:"lung",lower:-1400,upper:200,modalities:["CT"]},{name:"soft",lower:-160,upper:240,modalities:["CT"]},{name:"liver",lower:-10,upper:140,modalities:["CT"]}],Mc=/\.(nii|nii\.gz|mgz|mgh)$/i,Po=/\.dcm$/i,Um=/^\d+-.*-[0-9a-f]{7}$/,Ef="/SERVICES/PACS/",_S=4;function gc(n,e){if(Um.test(e))return!0;if(!n.startsWith(Ef))return!1;const t=n.slice(Ef.length).replace(/\/+$/,"");return t!==""&&t.split("/").length===_S}function wS(n,e){const t=n.toLowerCase();return km.find(s=>s.name===t&&(s.modalities.length===0||s.modalities.includes(e.toUpperCase())))}function yS(n,e){const t=[];let s="",i=[],r=!1,a=0,o=!1;const l=()=>{i.push(s),s="",o=!0},c=()=>{t.push(i),i=[],o=!1};for(;a<n.length;){const d=n[a];if(r){if(d==='"'){if(n[a+1]==='"'){s+='"',a+=2;continue}r=!1,a+=1;continue}s+=d,a+=1;continue}if(d==='"'&&s===""){r=!0,a+=1;continue}if(d===e){l(),a+=1;continue}if(d==="\r"&&n[a+1]===`
4208
4208
  `){l(),c(),a+=2;continue}if(d===`
4209
- `||d==="\r"){l(),c(),a+=1;continue}s+=d,a+=1}return(s!==""||o||i.length>0)&&(l(),c()),t}function zS(n){if(n.length===0)return!1;const e=new Set;for(const t of n){const s=t.trim();if(s===""||e.has(s.toLowerCase())||s!==""&&Number.isFinite(Number(s)))return!1;e.add(s.toLowerCase())}return!0}function _S(n,e){const t=/\.tsv$/i.test(e)?" ":",",s=bS(n,t);if(s.length===0)return{caps:[],rows:[],headed:!1};const i=s[0],r=zS(i),a=r?s.slice(1):s,o=s.reduce((d,h)=>Math.max(d,h.length),0),l=r?Array.from({length:o},(d,h)=>(i[h]??`COLUMN ${h+1}`).trim()):Array.from({length:o},(d,h)=>`COLUMN ${h+1}`),c=a.map(d=>Array.from({length:o},(h,u)=>d[u]??""));return{caps:l,rows:c,headed:r}}function Df(n){return/-v(\d+(?:\.\d+)*)$/.exec(n)?.[1]??""}const If="",wS="/bin",Tf="/bin/recent",Mo={dir:"",file:"",link:"",plugin:"",pipeline:"",vfs:"",job:""},bc=["list","cards","preview"],yS=5e3,vS=new Set(["png","jpg","jpeg","gif","svg","webp","bmp"]),OS=new Set(["txt","md","adoc","rst","json","csv","tsv","log","yaml","yml","toml","ini","cfg","xml","html","py","sh","ts","js","mjs","r","c","h","cpp","java","go","rs","sql","tex","bib"]),Gf=160,Rf=100,go=10,xS=30,SS=256*1024,AS=4e3,ES=12*1024*1024,DS=400;function Wo(n){return vS.has(Fm(n))}function Fm(n){const e=n.split("/").pop()??"",t=e.lastIndexOf(".");return t>0?e.slice(t+1).toLowerCase():""}function IS(n){if(n.includes("\0"))return!0;const e=(n.match(/\uFFFD/g)??[]).length;return e>0&&e/n.length>.02}const TS=80;function ll(n){const e=document.createElement("a");e.href=n,e.download="",e.rel="noopener",document.body.append(e),e.click(),e.remove()}function Bf(n,e){if(n===null)return[];const t=document.createElement("button");return t.className="files-close-pill files-download-pill",t.textContent="DOWNLOAD",t.title="save this file to your disk",t.addEventListener("click",()=>ll(n.downloadUrl(e))),[t]}function Nf(n){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("viewBox",`0 0 ${Gf} ${Rf}`),t.setAttribute("preserveAspectRatio","xMidYMid meet");const s=zm(n),i=Math.max(s.width,1),r=Math.max(s.tierCount-1,1),a=new Map;for(const o of s.placements)a.set(o.id,{x:go+o.x/i*(Gf-2*go),y:go+o.tier/r*(Rf-2*go)});for(const o of n){const l=a.get(o.id);if(l)for(const c of o.parentIds){const d=a.get(c);if(!d)continue;const h=document.createElementNS(e,"line");h.setAttribute("x1",String(d.x)),h.setAttribute("y1",String(d.y)),h.setAttribute("x2",String(l.x)),h.setAttribute("y2",String(l.y)),h.setAttribute("stroke","currentColor"),h.setAttribute("stroke-width","1"),h.setAttribute("opacity","0.6"),t.appendChild(h)}}for(const[,o]of a){const l=document.createElementNS(e,"circle");l.setAttribute("cx",String(o.x)),l.setAttribute("cy",String(o.y)),l.setAttribute("r",n.length>xS?"2.2":"4"),l.setAttribute("fill","currentColor"),t.appendChild(l)}return t}function bo(n){return n.type==="dir"||n.type==="vfs"||n.type==="link"||n.type==="job"?"dir":n.type==="file"?"file":n.type==="plugin"||n.type==="pipeline"?n.type:null}class Cf{container;recent=null;activate;listing;lastListings=[];contentShown=!1;denied=new Set;following=!1;viewMode="list";viewPill;modeSpan;preview;catalogue;runStrip=null;feedOpen=null;headCache=new Map;thumbObserver=null;frameTopObserver=null;stale=!1;home=null;stateSpan;indicate=null;selectionVerbs=null;constructor(e,t,s=null,i={}){this.container=e,this.activate=t,this.preview=s,this.catalogue=i.catalogue===!0,this.catalogue&&e.parentElement?.classList.add("files-catalogue");const r=e.closest(".pane-files")??e.parentElement;this.viewPill=e.parentElement?.querySelector(".files-view")??null,this.modeSpan=e.closest(".pane-files")?.querySelector(".pane-mode")??null,this.stateSpan=r?.querySelector(".pane-state")??null,this.viewPill?.addEventListener("click",()=>{this.view_set(bc[(bc.indexOf(this.viewMode)+1)%bc.length]??"list")});const a=e.parentElement?.querySelector(":scope > .mode-frame")!==null;this.listing=new Ur({mount:e,traits:this.traits_declare(),key:o=>o.home===!0?"~":o.path,address:o=>o.path,chrome:r===null?void 0:{root:r,prefix:"files"},control:"control",activate:o=>this.row_activate(o),activatable:o=>o.updir||bo(o.entry)!==null,indicated:o=>this.indicate?.(o.entry,o.path),row:{className:o=>`files-row files-type-${o.entry.type}${o.home===!0?" files-lead-home":o.updir?" files-lead-up":""}${!o.updir&&this.denied.has(o.path)?" files-denied":""}`,decorate:(o,l)=>{o.dataset.path=l.path,!l.updir&&this.denied.has(l.path)&&(o.title="listed but not readable — CUBE refused this identity access to the contents")}},...a?{selection:{verbs:o=>this.selectionVerbs?.(o.map(([l,c])=>[l,c.entry]))??[]}}:{},state:o=>this.stateLine_compose(o),defaultSort:{key:"name",dir:"asc"}}),this.empty_render()}traits_declare(){return this.catalogue?this.catalogueTraits_declare():this.browserTraits_declare()}browserTraits_declare(){return[{key:"control",label:"",className:"files-control",capped:!1,width:"2.4em",cell:e=>{const t=document.createElement("span"),s=e.updir?"dir":e.entry.type,i=e.updir||bo(e.entry)!==null;return t.className=`files-control files-glyph files-glyph-${s}${i?" files-capsule":""}`,t.textContent=e.home===!0?If:!e.updir&&this.denied.has(e.path)?"⃠":Mo[s],t}},{key:"name",label:"NAME",className:"files-name",width:"minmax(12em, 1fr)",cell:e=>{const t=document.createElement("span");if(t.className="files-name",t.textContent=e.home===!0?"~":e.updir?"..":e.entry.name,e.home===!0){const s=document.createElement("span");s.className="files-target",s.textContent=e.path,t.appendChild(s),t.title=`home: ${e.path}`}if(!e.updir&&e.entry.type==="link"&&e.entry.target!==void 0){const s=document.createElement("span");s.className="files-target",s.textContent=`→ ${e.entry.target}`,t.appendChild(s),t.title=e.entry.target}return t},compare:e=>e.entry.name},{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:e=>e.updir?"":e.entry.type},{key:"size",label:"SIZE",className:"files-size",width:"6em",cell:e=>e.updir||e.entry.type==="dir"?"":Wf(e.entry.size),compare:e=>e.entry.size},{key:"date",label:"DATE",className:"files-date",width:"7em",cell:e=>e.updir?"":e.entry.date.slice(0,10),compare:e=>e.entry.date},{key:"owner",label:"OWNER",className:"files-owner",width:"10em",cell:e=>e.updir?"":e.entry.owner}]}row_activate(e){if(e.updir){this.activate({kind:"dir",path:e.path});return}const t=bo(e.entry);t!==null&&this.activate({kind:t,path:e.path})}envelope_observe(e){if(e.model?.kind!=="fs.listing")return;const t=Pf(e.model.data);if(t===null||t.length===0)return;this.lastListings=t;const s=t[0]?.path??"";this.container.closest(".workspace-pane")?.classList.toggle("files-projection",/^\/(proc|net|etc|usr)(\/|$)/.test(s)),!this.contentShown&&this.listings_render(t)}ambient_observe(e){if(e.model?.kind!=="fs.listing")return;const t=Pf(e.model.data);if(t===null||this.lastListings.length===0)return;let s=!1;const i=this.lastListings.map(r=>{const a=t.find(o=>o.path===r.path);return a===void 0?r:(s=!0,a)});if(s){if(this.contentShown){this.lastListings=i;return}this.listings_render(i)}}contentTable_show(e,t){const s=_S(t,e);if(s.caps.length===0){this.content_show(e,t);return}const i=s.rows.slice(0,yS),r=s.rows.length>i.length;this.contentRelease?.(),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren(),this.diagram_declare(!1);const a=document.createElement("section");a.className="files-content-view files-table-view";const o=document.createElement("header");o.className="files-path files-content-header";const l=document.createElement("span");l.textContent=e;const c=document.createElement("span");c.className="pane-state",o.append(l,c);const d=document.createElement("div");d.className="files-table-field";const h=document.createElement("span");h.className="field-rule";const u=document.createElement("button");u.className="mode-strip",u.title="display modes";const p=document.createElement("span");p.className="mode-elbow";const M=document.createElement("aside");M.className="mode-frame";const _=document.createElement("button");_.className="strategy-pill csv-filter rail-off",_.textContent="FILTER OFF",_.title="filter the table";const m=document.createElement("button");m.className="strategy-pill csv-raw",m.textContent="RAW",m.title="the bytes as written",m.addEventListener("click",()=>this.content_show(e,t));const f=document.createElement("button");f.className="strategy-pill csv-close",f.textContent="CLOSE",f.title="leave the table; the listing beneath returns",f.addEventListener("click",()=>this.listing_restore());const S=document.createElement("span");S.className="mode-fill",M.append(_,m,S);const v=this.preview;if(v!==null){const G=document.createElement("button");G.className="strategy-pill csv-download",G.textContent="DOWNLOAD",G.title="save this file to your disk",G.addEventListener("click",()=>ll(v.downloadUrl(e))),M.append(G)}M.append(f);const z=document.createElement("div");z.className="files-table-rows",d.append(h,u,p,M,z),a.append(o,d),this.container.appendChild(a);const O=s.caps.map((G,b)=>({key:`c${b}`,label:G.toUpperCase(),className:"files-table-cell",cell:T=>T.cells[b]??"",width:"minmax(6em, 1fr)"}));new Ur({mount:z,traits:O,key:G=>String(G.index),chrome:{root:a,prefix:"csv"},state:G=>{const b=[];return G.filter!==""?b.push(`${G.filter} ROWS`):b.push(r?`SHOWING ${i.length} OF ${s.rows.length} ROWS`:`${s.rows.length} ROWS`),s.headed||b.push("NO HEADER: COLUMNS NUMBERED"),b.join(" · ")},empty:()=>{const G=document.createElement("div");return G.className="files-note",G.textContent="NO ROWS",G}}).rows_set([{key:e,rows:i.map((G,b)=>({index:b,cells:G}))}],{field:e}),this.contentRelease=()=>{z.replaceChildren()}}content_show(e,t){this.diagram_declare(!1),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,...Bf(this.preview,e),r);const a=document.createElement("pre");a.className="files-content",a.textContent=t,this.container.append(s,a)}contentRefused_show(e,t){this.diagram_declare(!1),this.denied.add(e),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header files-content-refused";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,r);const a=document.createElement("div");a.className="files-refused";const o=document.createElement("p");o.className="files-refused-lede",o.textContent="READ REFUSED";const l=document.createElement("pre");l.className="files-refused-said",l.textContent=t,a.append(o,l),this.container.append(s,a)}contentImage_show(e,t){this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,...Bf(this.preview,e),r);const a=document.createElement("img");a.className="files-image",a.src=t,a.alt=e,this.container.append(s,a)}rowVerbs_declare(e,t){this.indicate=t??null,this.listing.actions_declare({of:s=>s.updir?[]:e(s.entry,s.path).map(i=>({label:i.label,run:()=>i.run(s.entry),...i.offered!==void 0?{offered:()=>i.offered(s.entry)}:{},...i.disabled!==void 0?{disabled:()=>i.disabled(s.entry)}:{}}))})}catalogueTraits_declare(){return[...this.browserTraits_declare().filter(s=>s.key==="control"||s.key==="name"),{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:s=>s.updir?"":s.entry.type},{key:"version",label:"VERSION",className:"files-version",width:"7em",cell:s=>s.updir?"":Df(s.entry.name),compare:s=>Df(s.entry.name)}]}catalogue_is(){return this.catalogue}binding_set(e){if(this.runStrip===null){const s=document.createElement("div");s.className="files-run-strip";const i=document.createElement("span");i.className="files-binding";const r=document.createElement("input");r.className="files-command",r.spellcheck=!1,r.autocomplete="off",r.placeholder="the line RUN will run",s.append(i,r),this.container.parentElement?.insertBefore(s,this.container),this.runStrip=s;const a=this.container.closest(".pane-files")?.querySelector(".pane-title");a!=null&&(a.textContent="CATALOGUE")}const t=this.runStrip.querySelector(".files-binding");t!==null&&(t.textContent=`INPUT ${e.input} → ${e.place}`),this.frameTop_track()}commandLine_get(){return this.runStrip?.querySelector(".files-command")?.value.trim()??""}commandLine_set(e){const t=this.runStrip?.querySelector(".files-command")??null;t!==null&&(t.value=e)}indicated_get(){return this.listing.indicated_get()}feedOpen_declare(e){this.feedOpen=e}run_show(e){if(this.runStrip===null)return;this.runStrip.querySelector(".files-feed")?.remove();const t=document.createElement("button");t.className="files-feed listing-capsule listing-action-selected",t.textContent=`FEED ${e}`,t.title="open this run's graph beside the catalogue",t.addEventListener("click",()=>this.feedOpen?.(e)),this.runStrip.appendChild(t)}row_indicate(e){this.listing.row_indicate(e)}rowReadout_show(e,t){this.listing.readout_show(e,t)}selectionVerbs_declare(e){this.selectionVerbs=e}select_toggle(e){this.listing.select_toggle(e)}select_isOn(){return this.listing.select_isOn()}selection_get(){return this.listing.selection_get()}path_current(){return this.lastListings[0]?.path??null}content_isShown(){return this.contentShown}contentRelease=null;contentHtml_show(e,t,s={}){this.contentRelease?.(),this.contentRelease=s.release??null,this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("section");i.className="files-content-view";const r=document.createElement("header");r.className="files-path files-content-header";const a=document.createElement("span");a.textContent=e;const o=document.createElement("button");if(o.className="files-close-pill",o.textContent="CLOSE",o.addEventListener("click",()=>this.listing_restore()),r.append(a,o),i.appendChild(r),t!==""){const c=document.createElement("pre");c.className="files-content",c.innerHTML=t,i.appendChild(c)}let l=null;return s.diagram===!0&&(l=document.createElement("div"),l.className="files-diagram",i.appendChild(l)),this.diagram_declare(s.diagram===!0),this.container.appendChild(i),l}contentText_set(e){const t=this.container.querySelector(".files-content-view");if(t===null)return;const s=t.querySelector(".files-content"),i=s??document.createElement("pre");i.className="files-content",i.innerHTML=e,s===null&&t.querySelector(".files-content-header")?.after(i)}recent_set(e){this.recent=e===null?null:[...e],this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}listing_restore(){this.contentRelease?.(),this.contentRelease=null,this.lastListings.length>0?this.listings_render(this.lastListings):this.empty_render()}empty_render(){this.diagram_declare(!1),this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="AWAITING LISTING — TYPE ls IN THE CONSOLE",this.container.appendChild(e)}listings_render(e){this.diagram_declare(!1),this.contentShown=!1,this.container.parentElement?.classList.remove("content-view"),this.lastListings=e,this.thumbObserver?.disconnect(),this.thumbObserver=null,this.stale=e.some(i=>i.fresh===!1),this.stateSpan?.classList.toggle("state-stale",this.stale),this.listing.painter_set(this.viewMode==="list"?null:(i,r)=>this.cards_paint(i,r));const t=e.map(i=>this.block_of(i)),s=e.find(i=>i.path===wS);if(this.recent!==null&&this.recent.length>0&&s!==void 0){const i=this.recentBlock_of(s);i!==null&&t.unshift(i)}this.listing.rows_set(t,{field:e[0]?.path??""}),this.frameTop_track()}crumbs_build(e){const t=document.createElement("header");t.className="files-path files-crumbs";const s=[],i=this.home;let r;i!==null&&(e===i||e.startsWith(`${i}/`))?(s.push({label:"~",path:i}),r=e.slice(i.length)):(s.push({label:"/",path:"/"}),r=e);let a=s[0]?.path??"/";for(const o of r.split("/").filter(l=>l.length>0))a=a==="/"?`/${o}`:`${a}/${o}`,s.push({label:o,path:a});return s.forEach((o,l)=>{l>0&&s[l-1]?.label!=="/"&&t.append("/");const c=l===s.length-1,d=document.createElement(c?"span":"button");d.className=c?"files-crumb files-crumb-here":"files-crumb",d.textContent=o.label,d.dataset.path=o.path,c||(d.title=`go to ${o.path}`,d.addEventListener("click",h=>{h.stopPropagation(),this.activate({kind:"dir",path:o.path})})),t.appendChild(d)}),t}home_set(e){e!==this.home&&(this.home=e,!this.contentShown&&this.lastListings.length>0&&this.listings_render(this.lastListings))}block_of(e){const t=this.crumbs_build(e.path),s=e.items.map(r=>({entry:r,path:zo(e.path,r.name),updir:!1})),i=[];return!this.catalogue&&this.home!==null&&e.path!==this.home&&i.push({entry:{name:"~",type:"dir",size:0,owner:"",date:""},path:this.home,updir:!0,home:!0}),e.path!=="/"&&i.push({entry:{name:"..",type:"dir",size:0,owner:"",date:""},path:GS(e.path),updir:!0}),{key:e.path,header:t,lead:i,rows:s}}recentBlock_of(e){const t=new Map(e.items.map(r=>[r.name,r])),s=[];for(const r of this.recent??[]){const a=t.get(r);a!==void 0&&s.push({entry:a,path:zo(Tf,r),updir:!1})}if(s.length===0)return null;const i=document.createElement("header");return i.className="files-path files-recent",i.textContent="RECENT",{key:Tf,header:i,lead:[],rows:s}}cards_paint(e,t){const s=this.viewMode==="preview",i=document.createElement("div");i.className=s?"files-cards files-previews":"files-cards";for(const a of e.lead??[]){const o=document.createElement("article");o.className=a.home===!0?"files-card files-card-up files-card-home files-activatable":"files-card files-card-up files-activatable",o.textContent=a.home===!0?`${If} ~`:"▴ ..",o.addEventListener("click",()=>this.activate({kind:"dir",path:a.path})),i.appendChild(o)}const r=e.key;for(const a of e.rows)i.appendChild(this.card_build(r,a.entry,s));t.appendChild(i)}frameTop_track(){const e=this.container.parentElement,t=this.container.querySelector(".roster-order"),s=this.container.querySelector(".files-path");if(this.frameTopObserver?.disconnect(),this.frameTopObserver=null,e===null)return;if(t===null||s===null){e.style.removeProperty("--mode-frame-top"),e.style.removeProperty("--roster-frame-h");return}const i=()=>{const r=e.getBoundingClientRect().top,a=Math.ceil(t.getBoundingClientRect().bottom-r);e.style.setProperty("--roster-frame-h",`${a}px`),e.style.setProperty("--mode-frame-top",`${Math.ceil(s.getBoundingClientRect().bottom-r)}px`)};i(),this.frameTopObserver=new ResizeObserver(i),this.frameTopObserver.observe(t),this.frameTopObserver.observe(s)}follow_set(e){this.following=e,this.listing.state_refresh()}follow_get(){return this.following}view_set(e){this.viewMode=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.modeSpan!==null&&(this.modeSpan.textContent=e==="list"?"":e.toUpperCase()),this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}view_get(){return this.viewMode}body_get(){return this.container.closest(".files-body")}diagram_declare(e){this.body_get()?.classList.toggle("diagram-shown",e),e||this.mode_annunciate(this.viewMode==="list"?"":this.viewMode.toUpperCase())}mode_annunciate(e){this.modeSpan!==null&&(this.modeSpan.textContent=e)}stateLine_compose(e){const t=[];return this.following&&t.push("CWD"),e.selecting&&t.push("SELECT"),t.push(this.stale?"STALE":e.filter),e.selected>0&&t.push(e.shown===e.selected?`${e.selected} SELECTED`:`${e.selected} SELECTED · ${e.shown} SHOWN`),t.filter(s=>s!=="").join(" · ")}card_build(e,t,s=!1){const i=document.createElement("article");i.className=`files-card files-type-${t.type}`,s&&i.appendChild(this.thumb_build(zo(e,t.name),t));const r=document.createElement("div");r.className="files-card-head";const a=document.createElement("span");a.className="files-card-badge",a.textContent=t.type.toUpperCase();const o=document.createElement("span");o.className="files-card-size",o.textContent=t.type==="dir"||t.size===0?"":Wf(t.size),r.append(a,o);const l=document.createElement("div");l.className="files-card-title",l.textContent=t.name;const c=document.createElement("div");c.className="files-card-meta";const d=document.createElement("span");d.textContent=t.owner;const h=document.createElement("span");if(h.textContent=t.date.slice(0,10),c.append(d,h),i.append(r,l,c),t.type==="link"&&t.target!==void 0){const M=document.createElement("div");M.className="files-card-target",M.textContent=`→ ${t.target}`,M.title=t.target,i.appendChild(M)}const u=zo(e,t.name),p=bo(t);return p!==null&&(i.classList.add("files-activatable"),i.addEventListener("click",()=>this.activate({kind:p,path:u}))),i}thumb_build(e,t){const s=document.createElement("div");s.className="files-card-thumb";const i=()=>{s.textContent=Mo[t.type]};if(Um.test(t.name)||Po.test(t.name)){s.classList.add("thumb-series");const h=document.createElement("span");h.className="thumb-series-mark",h.textContent="DCM";const u=/^\d+-(.*)-[0-9a-f]{7}$/.exec(t.name)?.[1];if(s.replaceChildren(h),u!==void 0){const p=document.createElement("span");p.className="thumb-series-text",p.textContent=u.replace(/_/g," "),s.appendChild(p)}return s}if(this.preview===null||!(t.type==="file"||t.type==="plugin"||t.type==="pipeline"))return i(),s;if(t.type==="plugin")return s.replaceChildren(Nf([{id:e,parentIds:[]}])),s;if(t.type==="pipeline"){const h=this.preview;s.classList.add("thumb-wait"),s.textContent=Mo[t.type];const u=()=>{h.pipelineGlimpse(e).then(p=>{if(s.classList.remove("thumb-wait"),p===null||p.length===0){i();return}if(p.length>TS){s.textContent=`${p.length} NODES`,s.classList.add("thumb-count");return}s.replaceChildren(Nf(p))}).catch(()=>{s.classList.remove("thumb-wait"),i()})};return this.thumbObserver_get().observe(s),s.addEventListener("files:thumb-seen",u,{once:!0}),s}const r=this.headCache.get(e);if(r!==void 0){const h=document.createElement("pre");return h.textContent=r,s.appendChild(h),s}const a=Wo(e)&&t.size<=ES,o=Fm(e),l=(o===""||OS.has(o))&&t.size<=SS;if(!a&&!l)return i(),s;s.classList.add("thumb-wait"),s.textContent=Mo.file;const c=this.preview,d=()=>{if(a){const h=document.createElement("img");h.alt=t.name,h.addEventListener("load",()=>{s.classList.remove("thumb-wait")}),h.addEventListener("error",()=>{s.classList.remove("thumb-wait"),i()}),h.src=c.imageUrl(e),s.replaceChildren(h);return}c.textHead(e,AS).then(h=>{if(this.headCache.size>=DS&&this.headCache.clear(),this.headCache.set(e,h),s.classList.remove("thumb-wait"),h.trim()===""||IS(h)){i();return}const u=document.createElement("pre");u.textContent=h,s.replaceChildren(u)}).catch(()=>{s.classList.remove("thumb-wait"),i()})};return this.thumbObserver_get().observe(s),s.addEventListener("files:thumb-seen",d,{once:!0}),s}thumbObserver_get(){return this.thumbObserver===null&&(this.thumbObserver=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(this.thumbObserver?.unobserve(t.target),t.target.dispatchEvent(new CustomEvent("files:thumb-seen")))},{root:this.container,rootMargin:"25%"})),this.thumbObserver}filter_toggle(e){this.listing.filter_toggle(e)}}function Pf(n){if(!Array.isArray(n))return null;for(const e of n){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.path!="string"||!Array.isArray(t.items))return null}return n}function zo(n,e){return n.endsWith("/")?`${n}${e}`:`${n}/${e}`}function GS(n){const e=n.endsWith("/")?n.slice(0,-1):n,t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Wf(n){if(n<1024)return String(n);const e=["K","M","G","T"];let t=n,s=-1;for(;t>=1024&&s<e.length-1;)t=t/1024,s=s+1;return`${t<10?t.toFixed(1):Math.round(t)}${e[s]}`}const jm={listing:"files.row",rules:[{name:"image",label:()=>"IMAGE",offered:n=>n.kind==="seriesFolder"},{name:"gather",label:()=>"GATHER",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"process",label:()=>"PROCESS",offered:n=>(n.kind==="directory"||n.kind==="seriesFolder")&&(n.feed===null||(n.node??null)!==null)},{name:"run",label:()=>"RUN",offered:n=>n.kind==="catalogue"&&n.bound===!0},{name:"download",label:()=>"DOWNLOAD",offered:n=>n.kind==="file"},{name:"move",label:()=>"MOVE",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"copy",label:()=>"COPY",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"delete",label:()=>"DELETE",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"share",label:n=>`SHARE FEED ${n.feed??""}`,offered:n=>n.kind!=="catalogue"&&n.feed!==null&&n.projection!==!0}],states:[{name:"a plain file outside a feed",facts:{kind:"file",feed:null}},{name:"a file inside a feed",facts:{kind:"file",feed:12}},{name:"a directory",facts:{kind:"directory",feed:null}},{name:"a directory inside a feed that is not a node",facts:{kind:"directory",feed:12,node:null}},{name:"a node's data inside a feed",facts:{kind:"directory",feed:12,node:456}},{name:"a DICOM series folder",facts:{kind:"seriesFolder",feed:null}},{name:"a catalogue entry",facts:{kind:"catalogue",feed:null}},{name:"a catalogue entry in a bound catalogue",facts:{kind:"catalogue",feed:null,bound:!0}},{name:"a node's data seen through /proc",facts:{kind:"directory",feed:12,node:456,projection:!0}},{name:"a file seen through /proc",facts:{kind:"file",feed:12,projection:!0}}]},Vm={listing:"files.selection",rules:[{name:"delete",label:n=>`DELETE ${n.count}`,offered:()=>!0},{name:"move",label:n=>`MOVE ${n.count}`,offered:()=>!0},{name:"copy",label:n=>`COPY ${n.count}`,offered:()=>!0},{name:"share",label:n=>n.feeds.length===1?`SHARE FEED ${n.feeds[0]}`:`SHARE ${n.feeds.length} FEEDS`,offered:n=>n.feeds.length>0}],states:[{name:"a selection outside any feed",facts:{count:3,feeds:[]}},{name:"a selection in one feed",facts:{count:2,feeds:[12]}},{name:"a selection spanning feeds",facts:{count:5,feeds:[12,13]}}]},$m={listing:"runs.row",rules:[{name:"share",label:()=>"SHARE",offered:()=>!0},{name:"delete",label:()=>"DELETE",offered:()=>!0}],states:[{name:"any feed",facts:{feedId:12}}]},za={listing:"pacs.study",rules:[{name:"pullStudy",label:()=>"PULL STUDY",offered:n=>n.addressable},{name:"gather",label:()=>"GATHER",offered:n=>n.addressable},{name:"process",label:()=>"PROCESS",offered:n=>n.allInCube}],states:[{name:"a study with a path",facts:{addressable:!0,allInCube:!1}},{name:"a study with none",facts:{addressable:!1,allInCube:!1}},{name:"a study wholly home",facts:{addressable:!0,allInCube:!0,anyInCube:!0}},{name:"a study partly home",facts:{addressable:!0,allInCube:!1,anyInCube:!0}}]},ki={listing:"pacs.series",rules:[{name:"gather",label:()=>"GATHER",offered:n=>n.addressable||n.inCube},{name:"image",label:()=>"IMAGE",offered:n=>n.inCube&&n.folderKnown},{name:"dir",label:()=>"DIR",offered:n=>n.inCube&&n.folderKnown},{name:"process",label:()=>"PROCESS",offered:n=>n.inCube&&n.folderKnown},{name:"pull",label:()=>"PULL",offered:n=>!n.inCube}],states:[{name:"not yet retrieved",facts:{inCube:!1,folderKnown:!1,addressable:!0}},{name:"not retrieved and unaddressable",facts:{inCube:!1,folderKnown:!1,addressable:!1}},{name:"home, folder not yet named",facts:{inCube:!0,folderKnown:!1,addressable:!0}},{name:"home, folder named",facts:{inCube:!0,folderKnown:!0,addressable:!0}}]},Hm={listing:"gather.series",rules:[{name:"remove",label:()=>"REMOVE",offered:()=>!0},{name:"pull",label:()=>"PULL",offered:n=>n.pullable===!0},{name:"image",label:()=>"IMAGE",offered:n=>n.folderKnown&&n.imagery!==!1},{name:"process",label:()=>"PROCESS",offered:()=>!0}],states:[{name:"folder named",facts:{folderKnown:!0}},{name:"a place that is not imagery",facts:{folderKnown:!0,imagery:!1}},{name:"folder not yet named",facts:{folderKnown:!1}},{name:"not retrieved yet",facts:{folderKnown:!1,pullable:!0}}]},qm={listing:"gather.cohort",rules:[{name:"save",label:()=>"SAVE",offered:n=>n.count>0},{name:"export",label:()=>"EXPORT CSV",offered:n=>n.count>0},{name:"feed",label:()=>"CREATE FEED",offered:n=>n.count>0&&n.feed===null},{name:"process",label:()=>"PROCESS",offered:n=>n.count>0},{name:"dismiss",label:()=>"DISMISS",offered:()=>!0}],states:[{name:"holding series",facts:{count:2,feed:null}},{name:"holding series, rooted in a feed",facts:{count:2,feed:4501}},{name:"emptied",facts:{count:0,feed:null}}]};function Ri(n){return{listing:n.listing,visit(e){return e(n)}}}Ri(jm),Ri(Vm),Ri($m),Ri(za),Ri(ki),Ri(qm),Ri(Hm);function yn(n,e){const t=n.rules.find(s=>s.name===e);if(t===void 0)throw new Error(`${n.listing} declares no verb '${e}'`);return t}function RS(n){return{inCube:n.pulled===!0,folderKnown:n.folderPath!==void 0,addressable:n.vfsPath!==void 0}}function Lf(n){if(n.series.length===0)return null;const e=[];for(const s of n.series){if(s.pulled!==!0||s.folderPath===void 0)return null;e.push(s.folderPath.replace(/\/[^/]+\/?$/,""))}const t=e[0]??"";return e.every(s=>s===t)&&t!==""?t:null}function Un(n){const e=RS(n),t=s=>yn(ki,s).offered(e);return{gather:t("gather"),image:t("image"),dir:t("dir"),pull:t("pull")}}function BS(n,e,t,s){let i=!1;for(const r of n.studies)for(const a of r.series)a.seriesUID===e&&(s!==void 0&&a.folderPath!==s&&(a.folderPath=s,i=!0),a.pulled!==!0&&(a.pulled=!0,t!==void 0&&t>0&&(a.pulledFiles=t),i=!0));return i}const kf=[{id:"pacs-f-name",term:"PatientName"},{id:"pacs-f-mrn",term:"PatientID"},{id:"pacs-f-date",term:"StudyDate"},{id:"pacs-f-accession",term:"AccessionNumber"},{id:"pacs-f-modality",term:"Modality"}],_o={running:"RETRIEVING",done:"✓ PULLED",error:"✗ ERROR",unconfirmed:"? UNCONFIRMED",stalled:"STALLED",queued:"QUEUED",idle:"NOT RETRIEVED"},NS="--fresh",Uf="--anon",CS=/\s*--anon\b/,PS=["pacs-f-name","pacs-f-mrn","pacs-f-accession","pacs-f-date"],Ff=/\s*--fresh\b/;function jf(n){const e=Date.parse(n);if(Number.isNaN(e))return null;const t=Math.max(0,Math.round((Date.now()-e)/1e3)),s=[{limit:60,size:1,name:"SECOND"},{limit:3600,size:60,name:"MINUTE"},{limit:86400,size:3600,name:"HOUR"},{limit:2592e3,size:86400,name:"DAY"},{limit:31536e3,size:2592e3,name:"MONTH"},{limit:1/0,size:31536e3,name:"YEAR"}];for(const i of s){if(t>=i.limit)continue;const r=Math.max(1,Math.floor(t/i.size));return`${r} ${i.name}${r===1?"":"S"} AGO`}return null}const cl=new Map;function Xm(n,e){const t=cl.get(n)??new Set;t.add(e),cl.set(n,t)}function WS(n,e){const t=cl.get(n);if(t!==void 0){for(const s of[...t]){if(!s.isConnected){t.delete(s);continue}e(s)}t.size===0&&cl.delete(n)}}function LS(n){const e=document.createElement("span");if(e.className="pacs-badge",n.pulled===!0){const i=document.createElement("span");i.className="pacs-bar-full";const r=document.createElement("span");return r.className="pacs-badge-note",r.textContent=n.pulledFiles!==void 0?`✓ ${n.pulledFiles} IN CUBE`:"✓ IN CUBE",e.append(i,r),e.dataset.state="done",e}const t=document.createElement("span");t.className="pacs-bar";const s=document.createElement("span");return s.className="pacs-badge-note",s.textContent="NOT RETRIEVED",e.append(t,s),e.dataset.state="idle",Xm(n.seriesUID,e),e}function Ym(n,e){return[{key:"series",label:"SERIES",className:"pacs-series-desc",width:"35.5em",cell:t=>n(t).description},{key:"state",label:"STATE",className:"pacs-badge",width:"1fr",cell:t=>e(n(t)),compare:t=>n(t).pulled===!0?"done":"idle"},{key:"modality",label:"MODALITY",className:"pacs-series-modality",width:"4em",cell:t=>n(t).modality},{key:"files",label:"FILES",className:"pacs-series-files",width:"6em",cell:t=>{const s=n(t).fileCount;return s!==void 0?`${s} FILES`:""},compare:t=>n(t).fileCount??-1}]}class kS{root;command;results;handlers;litFolders=new Map;badgeStates=new Map;seriesProgress=new Map;studyTracks=new Map;traits;actions;studyTraits;studyActions;patientTraits;listing;patientTracks=new Map;provenance;run;model=null;anon=!1;revealed=!1;anonPill;revealPill;replayed=!1;serverCell;serverStrip;servers=[];chosen=new Set;constructor(e,t){this.root=e,this.handlers=t,this.command=wo(e,"#pacs-command"),this.results=pn(e,"#pacs-results"),this.traits=this.traits_declare(),this.actions=this.actions_declare(),this.studyTraits=this.studyTraits_declare(),this.studyActions=this.studyActions_declare(),this.patientTraits=this.patientTraits_declare(),this.listing=new Ur({mount:this.results,traits:this.patientTraits,key:s=>s.key,chrome:{root:e,prefix:"pacs"},activatable:s=>s.studies.length>0,address:s=>s.studies.length>0?_b(s.patient):void 0,control:"fold",row:{className:()=>"pacs-patient-row",groupClassName:s=>s.patient.status==="unasked"?"pacs-patient pacs-patient-unasked":"pacs-patient",decorate:(s,i)=>{i.studies.length>0&&(s.title="unfold this patient's studies (the patient keeps its place)")}},child:Rr(s=>s.studies.map((i,r)=>({study:i,key:Vf(i,r)})),{traits:this.studyTraits,key:s=>s.key,address:s=>s.study.vfsPath,control:"fold",actions:{of:()=>this.studyActions},row:{className:()=>"pacs-study-row",groupClassName:()=>"pacs-study",decorate:s=>{s.title="unfold this study's series (the study keeps its place)"}},child:Rr(s=>s.study.series.map(i=>({study:s.study,studyKey:s.key,series:i})),{traits:this.traits,key:s=>s.series.seriesUID,address:s=>s.series.vfsPath,actions:{of:()=>this.actions},row:{className:()=>"pacs-series",decorate:(s,i)=>{s.dataset.seriesuid=i.series.seriesUID}}})}),state:s=>this.stateLine_compose(s),empty:()=>Hf("NO STUDIES FOUND")}),e.style.setProperty("--roster-cols",this.listing.template_get(1)),this.listing.rows_set([],{field:"pacs"});for(const{id:s}of kf){const i=wo(e,`#${s}`);i.addEventListener("input",()=>this.command_regenerate()),i.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.query_run())})}this.serverCell=pn(e,"#pacs-f-server"),this.serverStrip=pn(e,"#pacs-server-strip"),this.serverCell.addEventListener("click",()=>this.serverStrip_toggle()),this.serverCell_sync(),this.provenance=pn(e,"#pacs-provenance"),this.anonPill=pn(e,"#pacs-anon"),this.revealPill=pn(e,"#pacs-reveal"),this.anonPill.addEventListener("click",()=>this.anon_set(!this.anon)),this.revealPill.addEventListener("click",()=>this.reveal_set(!this.revealed)),this.run=pn(e,"#pacs-run"),this.run.addEventListener("click",()=>this.query_run(this.replayed)),this.command.addEventListener("keydown",s=>{s.key==="Enter"&&this.query_run()}),pn(e,"#pacs-export").addEventListener("click",()=>this.answer_export()),pn(e,"#pacs-gather-shown").addEventListener("click",()=>this.shown_gather()),pn(e,"#pacs-pull-shown").addEventListener("click",()=>this.shown_pull())}patientTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:e=>{const t=document.createElement("span");return t.className=e.studies.length===0?"pacs-fold pacs-fold-none":"pacs-fold",t}},{key:"patient",label:"PATIENT",className:"pacs-patient-name",width:"13em",cell:e=>e.patient.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-patient-mrn",width:"7.5em",cell:e=>e.patient.patientId||"—"},{key:"answered",label:"ANSWERED",className:"pacs-patient-answered",width:"12em",cell:e=>{const t=document.createElement("span");if(t.className=e.patient.status==="unasked"?"pacs-patient-answered pacs-unasked":"pacs-patient-answered",e.patient.status==="unasked")return t.textContent="UNASKED",e.patient.error!==void 0&&(t.title=e.patient.error),t;const s=e.patient.provenance?.answeredAt;return t.textContent=s===void 0?"—":jf(s)??"—",s!==void 0&&(t.title=s),t},compare:e=>{const t=e.patient.provenance?.answeredAt;if(t===void 0)return Number.MAX_SAFE_INTEGER;const s=Date.parse(t);return Number.isNaN(s)?Number.MAX_SAFE_INTEGER:s}},{key:"progress",label:"PROGRESS",className:"pacs-patient-progress",width:"1fr",cell:e=>{const t=document.createElement("span");return t.className="pacs-patient-progress",this.patientTracks.set(e.key,{mount:t,uids:e.studies.flatMap(s=>s.series.map(i=>i.seriesUID))}),this.patientTrack_paint(e.key),t},compare:e=>{const t=this.patientProgress_of(e);return t.total===0?-1:t.done/t.total}},{key:"studies",label:"STUDIES",className:"pacs-patient-count",width:"6em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.studyCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.studyCount},{key:"series",label:"SERIES",className:"pacs-patient-count",width:"5em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.seriesCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.seriesCount},{key:"server",label:"SERVER",className:"pacs-patient-server",width:"9em",cell:e=>e.patient.server??this.model?.pacsName??"—"}]}patientProgress_of(e){return mo(e.studies.flatMap(t=>t.series.map(s=>this.seriesProgress.get(s.seriesUID)??{done:0,total:0})))}patientTrack_paint(e){const t=this.patientTracks.get(e);if(t===void 0)return;const s=t.uids.map(i=>this.seriesProgress.get(i)??{done:0,total:0});t.mount.replaceChildren(Ro(mo(s)))}patientRows_build(e){const t=(r,a)=>e.studies.filter(o=>o.patientId===r&&(a===void 0||o.server===void 0||o.server===a));if(e.patients!==void 0&&e.patients.length>0)return e.patients.map((r,a)=>({patient:r,key:`${r.patientId}::${r.server??""}::${a}`,studies:t(r.patientId,r.server)}));const s=[],i=new Map;for(const r of e.studies){const a=r.patientId;i.has(a)||(i.set(a,[]),s.push(a)),i.get(a).push(r)}return s.map((r,a)=>{const o=i.get(r)??[];return{key:`${r}::${a}`,studies:o,patient:{patientId:r,...o[0]?.patientName?{patientName:o[0].patientName}:{},status:"found",studyCount:o.length,seriesCount:o.reduce((l,c)=>l+c.series.length,0),...e.provenance===void 0?{}:{provenance:e.provenance}}}})}studyTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"patient",label:"PATIENT",className:"pacs-study-patient",width:"13em",cell:e=>e.study.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-study-mrn",width:"7.5em",cell:e=>e.study.patientId||"—"},{key:"study",label:"STUDY",className:"pacs-study-desc",width:"12em",cell:e=>e.study.description||"(no description)"},{key:"progress",label:"PROGRESS",className:"pacs-study-progress",width:"1fr",cell:e=>{const t=document.createElement("span");return t.className="pacs-study-progress",this.studyTracks.set(e.key,{mount:t,uids:e.study.series.map(s=>s.seriesUID)}),this.studyTrack_paint(e.key),t},compare:e=>{const t=this.studyProgress_of(e);return t.total===0?-1:t.done/t.total}},{key:"date",label:"DATE",className:"pacs-study-date",width:"7.5em",cell:e=>e.study.date},{key:"accession",label:"ACCESSION",className:"pacs-study-accession",width:"9em",cell:e=>e.study.accession||"—"},{key:"modality",label:"MODALITY",className:"pacs-study-modalities",width:"6.5em",cell:e=>e.study.modalities},{key:"server",label:"SERVER",className:"pacs-study-server",width:"9em",cell:e=>e.study.server??this.model?.pacsName??"—"},{key:"series",label:"SERIES",className:"pacs-study-count",width:"6.5em",cell:e=>String(e.study.series.length),compare:e=>e.study.series.length}]}studyActions_declare(){return[{label:yn(za,"pullStudy").label({addressable:!0,allInCube:!1}),offered:e=>yn(za,"pullStudy").offered({addressable:e.study.vfsPath!==void 0,allInCube:!1}),run:e=>{const t=e.study.vfsPath;if(t!==void 0){this.handlers.command_run(`pull ${t}`);for(const s of e.study.series)s.vfsPath!==void 0&&s.pulled!==!0&&this.badgeState_set(s.seriesUID,{status:"queued"})}}},{label:yn(za,"gather").label({addressable:!0,allInCube:!1,anyInCube:!0}),offered:e=>e.study.series.some(t=>Un(t).gather),run:e=>{const t=e.study.series.filter(i=>Un(i).gather);for(const i of t)this.gather_note(e.study,i);const s=e.study.series.length-t.length;this.handlers.note(`gather: ${t.length} series gathered${s>0?`, ${s} not in CUBE (pull them first)`:""}`)}},{label:yn(za,"process").label({addressable:!0,allInCube:!0}),offered:e=>Lf(e.study)!==null,run:e=>{const t=Lf(e.study);t!==null&&this.handlers.process_open(t)}}]}studyProgress_of(e){return mo(e.study.series.map(t=>this.seriesProgress.get(t.seriesUID)??{done:0,total:0}))}traits_declare(){return Ym(e=>e.series,e=>this.badge_build(e))}actions_declare(){return[{label:yn(ki,"gather").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).gather,selected:e=>this.handlers.gathered_is(e.series.seriesUID),run:e=>this.gather_note(e.study,e.series)},{label:yn(ki,"image").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).image,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get($f(e.series.folderPath))?.viewer??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.image_open(e.series.folderPath)}},{label:yn(ki,"dir").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).dir,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get($f(e.series.folderPath))?.browser??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.dir_open(e.series.folderPath)}},{label:yn(ki,"process").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).image,run:e=>{e.series.folderPath!==void 0&&this.handlers.process_open(e.series.folderPath)}},{label:yn(ki,"pull").label({inCube:!1,folderKnown:!1,addressable:!0}),offered:e=>Un(e.series).pull,disabled:e=>e.series.vfsPath===void 0,run:e=>{const t=e.series.vfsPath;t!==void 0&&(this.handlers.command_run(`pull ${t}`),this.badgeState_set(e.series.seriesUID,{status:"queued"}))}}]}state_name(e){return e.pulled===!0?"pulled":this.badgeStates.get(e.seriesUID)?.status??"idle"}command_regenerate(){const e=[];for(const{id:i,term:r}of kf){const a=wo(this.root,`#${i}`).value.trim();a.length>0&&e.push(`${r}:${a}`)}const t=this.chosen.size>1?` --pacsserver ${[...this.chosen].join(",")}`:"",s=this.anon?` ${Uf}`:"";this.command.value=e.length>0||t!==""?`pacs query ${e.join(",")}${t}${s}`:""}anon_set(e){e!==this.anon&&(this.anon=e,this.revealed=!1,this.anonPill.textContent=e?"ANON ON":"ANON OFF",this.anonPill.classList.toggle("pacs-capsule-off",!e),this.revealPill.hidden=!e,this.model=null,this.listing.rows_set([],{field:"pending"}),this.provenance_show(void 0),this.command.value=e?`${this.command.value.trim()} ${Uf}`.trim():this.command.value.replace(CS,"").trimEnd(),this.masking_apply())}reveal_set(e){this.revealed=e,this.revealPill.textContent=e?"HIDE":"REVEAL",this.revealPill.classList.toggle("pacs-capsule-off",!e),this.masking_apply()}masking_apply(){const e=this.anon&&!this.revealed;for(const t of PS)wo(this.root,`#${t}`).type=e?"password":"text";this.command.type=e?"password":"text"}serverStrip_toggle(e){const t=e??this.serverStrip.hidden;this.serverStrip.hidden=!t,this.serverCell.classList.toggle("pacs-server-open",t),t&&this.servers.length===0&&this.servers_ask(),t&&this.serverStrip_paint()}query_get(){return this.model===null?null:`pacs query ${this.model.expression}`}serverStrip_isOpen(){return!this.serverStrip.hidden}serverStrip_close(){this.serverStrip_toggle(!1)}servers_ask(){this.handlers.command_run("pacs list")}servers_take(e){this.servers=e,this.serverStrip_paint(),this.serverCell_sync()}serverStrip_paint(){if(this.serverStrip.replaceChildren(),this.servers.length===0){this.serverStrip.appendChild(Hf("ASKING THE SESSION FOR REGISTERED SERVERS"));return}for(const e of this.servers){const t=document.createElement("button");t.className=this.chosen.has(e.identifier)?"pacs-server-segment pacs-server-chosen":"pacs-server-segment",t.dataset.server=e.identifier,t.textContent=e.identifier,e.active&&(t.title="the session is connected to this server"),t.addEventListener("click",()=>this.server_choose(e.identifier)),this.serverStrip.appendChild(t)}}server_choose(e){if(this.chosen.has(e)?this.chosen.delete(e):this.chosen.add(e),this.chosen.size===1){const t=[...this.chosen][0];this.handlers.command_show(`pacs connect ${t}`)}this.serverStrip_paint(),this.serverCell_sync(),this.command_regenerate()}serverCell_sync(){const e=[...this.chosen];if(e.length===0){const t=this.servers.find(s=>s.active);this.serverCell.textContent=t?.identifier??"—",this.serverCell.classList.remove("pacs-server-many");return}this.serverCell.textContent=e.length===1?e[0]:`${e[0]} +${e.length-1}`,this.serverCell.classList.toggle("pacs-server-many",e.length>1)}wrote_show(e){const t=this.root.querySelector("#pacs-wrote");t!==null&&(t.textContent=`WROTE ${e}`,t.title="open the folder this landed in",t.classList.add("pacs-wrote-opens"),t.onclick=()=>{const s=e.lastIndexOf("/");this.handlers.dir_open(s<=0?e:e.slice(0,s))},t.hidden=!1)}answer_export(){if(this.model===null)return;const e=this.command.value.trim(),t=e===""?`pacs query ${this.model.expression}`:e;this.handlers.command_show(`${t} --csv-to`)}query_run(e=!1){e&&!Ff.test(this.command.value)&&(this.command.value=`${this.command.value.trim()} ${NS}`);const t=this.command.value.trim();t.length!==0&&(this.model=null,this.listing.rows_set([],{field:"pending"}),this.listing.field_get()?.appendChild(this.waiting_build()),this.handlers.command_run(t))}provenance_show(e){if(this.replayed=e?.replayed===!0,this.run.textContent=this.replayed?"RE-QUERY":"QUERY",this.run.classList.toggle("pacs-capsule-requery",this.replayed),this.provenance.hidden=!this.replayed,!this.replayed){this.provenance.textContent="",this.command.value=this.command.value.replace(Ff,"").trimEnd();return}const t=e?.answeredAt??"",s=jf(t),i=t.slice(0,10);this.provenance.textContent=s===null?`RESULTS ${i}`:`RESULTS ${i} · ${s}`,this.provenance.title=t}waiting_build(){const e=document.createElement("div");e.className="pacs-waiting";const t=document.createElement("span");t.className="pacs-bar pacs-bar-pacing";const s=document.createElement("span");s.className="pacs-bar-fill",t.appendChild(s);const i=document.createElement("span");return i.className="pacs-waiting-note",i.textContent="QUERYING THE PACS…",e.append(t,i),e}envelope_observe(e){const t=/✓ wrote (\S+)/.exec((e.rendered??"").replace(/\x1b\[[0-9;]*m/g,""));if(t!==null&&this.wrote_show(t[1]),e.model?.kind===bb){const i=gb.safeParse(e.model.data);i.success&&this.servers_take(i.data.servers);return}if(e.model?.kind!==zb)return;const s=mb.safeParse(e.model.data);s.success&&this.results_render(s.data)}progress_observe(e){if(e.operation!=="pull"||e.itemId===void 0)return;const t=e.status??"running",s={status:t};e.current!==void 0&&(s.current=e.current),e.total!==void 0&&(s.total=e.total),this.badgeState_set(e.itemId,s),t==="done"&&this.model!==null&&BS(this.model,e.itemId,e.current??e.total,e.path)&&this.results_repaint()}badgeState_set(e,t){this.badgeStates.set(e,t),this.seriesProgress.set(e,FS(t,this.seriesProgress.get(e))),WS(e,s=>this.badge_paint(s,t));for(const[s,i]of this.studyTracks)i.uids.includes(e)&&this.studyTrack_paint(s);for(const[s,i]of this.patientTracks)i.uids.includes(e)&&this.patientTrack_paint(s)}badge_build(e){const t=document.createElement("span");if(t.className="pacs-badge",e.pulled===!0){const s=document.createElement("span");s.className="pacs-bar-full";const i=document.createElement("span");return i.className="pacs-badge-note",i.textContent=e.pulledFiles!==void 0?`✓ ${e.pulledFiles} IN CUBE`:"✓ IN CUBE",t.append(s,i),t.dataset.state="done",t}return Xm(e.seriesUID,t),this.badge_paint(t,this.badgeStates.get(e.seriesUID)??{status:"idle"}),t}badge_paint(e,t){e.replaceChildren(),e.dataset.state=t.status;const s=document.createElement("span");if(s.className="pacs-badge-note",t.status==="idle"){s.textContent=_o.idle,e.append(Ro({done:0,total:0}),s);return}if(t.status!=="running"&&t.status!=="queued"){e.textContent=_o[t.status]??t.status.toUpperCase();return}const i=t.total!==void 0?` ${t.current??0}/${t.total}`:"",r=t.status==="queued"||t.total===void 0||t.total===0?null:Math.min(1,(t.current??0)/t.total),a=document.createElement("span");a.className=r===null?"pacs-bar pacs-bar-pacing":"pacs-bar";const o=document.createElement("span");o.className="pacs-bar-fill",r!==null&&(o.style.width=`${Math.round(r*100)}%`),a.appendChild(o),s.textContent=t.status==="queued"?_o.queued:`${_o.running}${i}`,e.append(a,s)}results_render(e){const t=this.model!==null&&this.model.queryId===e.queryId;if(this.model=e,this.provenance_show(e.provenance),!t){this.listing.open_clear(),this.badgeStates.clear();const s=this.patientRows_build(e),i=s.length===1?s[0]:void 0;i!==void 0&&i.studies.length>0&&this.listing.open_set(0,[i.key]),e.studies.length===1&&this.listing.open_set(1,[Vf(e.studies[0],0)])}for(const s of e.studies)for(const i of s.series)t&&this.badgeStates.has(i.seriesUID)||this.seriesProgress.set(i.seriesUID,US(i));this.results_repaint()}results_repaint(){const e=this.model;if(this.studyTracks.clear(),this.patientTracks.clear(),e===null){this.listing.rows_set([],{field:"pacs"});return}this.listing.rows_set([{key:String(e.queryId),rows:this.patientRows_build(e)}],{field:String(e.queryId)})}studyTrack_paint(e){const t=this.studyTracks.get(e);if(t===void 0)return;const s=t.uids.map(i=>this.seriesProgress.get(i)??{done:0,total:0});t.mount.replaceChildren(Ro(mo(s)))}stateLine_compose(e){queueMicrotask(()=>{this.shownGather_render(),this.shownPull_render()});const t=[],s=this.model?.patients??[];if(s.length>0){const i=r=>s.filter(a=>a.status===r).length;t.push(`FOUND ${i("found")} · NONE ${i("none")} · UNASKED ${i("unasked")}`)}return e.filter!==""&&t.push(e.filter),t.join(" · ")}filter_toggle(e){this.listing.filter_toggle(e)}shown_candidates(){const e=[];if(!this.filtering()){for(const t of this.model?.studies??[])for(const s of t.series)e.push({study:t,series:s});return e}for(const t of this.root.querySelectorAll("#pacs-results .pacs-series")){const s=t.dataset.seriesuid;if(s!==void 0)for(const i of this.model?.studies??[]){const r=i.series.find(a=>a.seriesUID===s);r!==void 0&&e.push({study:i,series:r})}}return e}filtering(){return this.listing.filterText_get()!==""}shown_gatherable(){return this.shown_candidates().filter(({series:e})=>Un(e).gather&&!this.handlers.gathered_is(e.seriesUID))}shownGather_render(){const e=this.root.querySelector("#pacs-gather-shown");if(e===null)return;const t=this.shown_gatherable().length;e.hidden=t===0,e.textContent=this.filtering()?`GATHER ${t} SHOWN`:`GATHER ${t}`}shown_pullable(){return this.shown_candidates().map(({series:e})=>e).filter(e=>Un(e).pull&&e.vfsPath!==void 0)}shownPull_render(){const e=this.root.querySelector("#pacs-pull-shown");if(e===null)return;const t=this.shown_pullable().length;e.hidden=t===0,e.textContent=this.filtering()?`PULL ${t} SHOWN`:`PULL ${t}`}shown_pull(){const e=this.shown_pullable();if(e.length===0)return;const t=e.map(s=>`"${s.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${t}`);for(const s of e)this.badgeState_set(s.seriesUID,{status:"queued"});this.handlers.note(`pull: ${e.length} series asked for`),this.shownPull_render()}shown_gather(){const e=this.shown_gatherable();if(e.length!==0){for(const{study:t,series:s}of e)this.gather_note(t,s);this.handlers.note(this.filtering()?`gather: ${e.length} series gathered from what the filter left showing`:`gather: ${e.length} series gathered from the whole answer`),this.shownGather_render()}}gather_note(e,t){t.vfsPath!==void 0&&(this.handlers.gather_add({seriesUID:t.seriesUID,description:t.description,modality:t.modality,series:t,patient:e.patientId||e.patientName,...e.description===void 0||e.description===""?{}:{study:e.description},vfsPath:t.vfsPath,...t.folderPath!==void 0?{folderPath:t.folderPath}:{},...t.fileCount!==void 0?{files:t.fileCount}:{}}),this.selected_refresh())}stage_lit(e){this.litFolders=e,this.selected_refresh()}selected_refresh(){this.listing.indication_refresh()}}function Vf(n,e){return n.studyUID??`study-${e}`}function $f(n){return n.replace(/\/$/,"")}function US(n){const e=n.pulledFiles??0,t=Math.max(n.fileCount??0,e);return n.pulled===!0?{done:t,total:t}:{done:e,total:t}}function FS(n,e){const t=n.total??e?.total??0;return n.status==="error"?{done:n.current??e?.done??0,total:t,failed:!0}:n.status==="done"?{done:t,total:t}:{done:n.current??e?.done??0,total:t}}function pn(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`PACS workspace is missing '${e}'`);return t}function wo(n,e){const t=pn(n,e);if(!(t instanceof HTMLInputElement))throw new Error(`'${e}' is not an input`);return t}function Hf(n){const e=document.createElement("p");return e.className="files-empty",e.textContent=n,e}function qf(n){return(n.kind??"series")==="series"?void 0:n.vfsPath}const zc="cohort";function jS(n){return/[",\n\r]/.test(n)?`"${n.split('"').join('""')}"`:n}function VS(n){const e=document.createElement("p");return e.className="files-empty",e.textContent=n,e}class Xf{handlers;title;cohort;greeted=!1;listing;cohortActions;seriesActions;constructor(e,t,s,i){this.handlers=s,this.cohort=i,i.watch(()=>{this.unsaved=!0,this.render()}),this.title=e.querySelector(".gather-title"),this.cohortActions=this.cohortActions_declare(),this.seriesActions=this.seriesActions_declare(),this.listing=new Ur({mount:t,traits:this.cohortTraits_declare(),key:r=>r.key,chrome:{root:e,prefix:"gather"},control:"fold",actions:{of:()=>this.cohortActions},row:{className:()=>"gather-cohort-row",groupClassName:()=>"gather-cohort",decorate:r=>{r.title="the cohort: click for its verbs, the fold cell folds its series"}},child:Rr(()=>[...this.cohort.members_get()].map(r=>({entry:r})),{traits:this.seriesTraits_declare(),key:r=>r.entry.seriesUID,address:r=>r.entry.vfsPath,actions:{of:()=>this.seriesActions},row:{className:()=>"gather-series",decorate:(r,a)=>{r.dataset.seriesuid=a.entry.seriesUID}}}),state:r=>this.stateLine_compose(r),empty:()=>VS("NOTHING GATHERED")}),this.pullBlock=e.querySelector(".gather-pull"),this.pullBlock?.addEventListener("click",()=>this.cohort_pull()),this.emptyBlock=e.querySelector(".gather-remove"),this.emptyBlock?.addEventListener("click",()=>{this.cohort_clear()}),this.processBlock=e.querySelector(".gather-process"),this.processBlock?.addEventListener("click",()=>{this.cohort_process()}),this.render()}pullBlock=null;emptyBlock=null;unsaved=!1;processBlock=null;cohort_empty(){this.cohort.size()!==0&&(this.cohort.clear(),this.handlers.changed(),this.render())}async cohort_clear(){if(this.cohort.size()!==0){if(this.unsaved){const e=await this.handlers.confirm_ask(`Save the cohort first? (${this.cohort.size()} ${this.cohort.size()===1?"member":"members"}, unsaved)`);if(e===null||e==="y"&&!await this.manifest_save())return}this.handlers.command_show("gather clear"),this.cohort_empty()}}away(){return[...this.cohort.members_get()].filter(e=>e.folderPath===void 0&&e.series?.pulled!==!0)}cohort_pull(){const e=this.away();if(e.length===0)return;const t=e.map(s=>`"${s.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${t}`)}render_now(){this.render()}has(e){return this.cohort.has(e)}entries_get(){return[...this.cohort.members_get()]}name_get(){return this.cohort.name_get()}feed_get(){return this.cohort.feed_get()}feed_set(e){e!==null&&this.cohort.feed_set(e),this.render()}name_set(e){e!==null&&this.cohort.name_set(e),this.render()}series_add(e){this.cohort.take(e),this.render(),this.handlers.changed()}series_remove(e){this.cohort.drop(e)&&(this.render(),this.handlers.changed())}render(){if(this.title!==null&&(this.title.textContent=this.cohort.name_get()===null?"GATHER":`GATHER · ${this.cohort.name_get()??""}`.toUpperCase()),this.listing.rows_set([{key:"gather",rows:[{key:zc}]}],{field:"gather"}),this.cohort.size()>0&&this.listing.open_set(0,[zc]),this.pullBlock!==null){const e=this.away().length;this.pullBlock.hidden=e===0,this.pullBlock.textContent=`PULL ${e}`}this.emptyBlock!==null&&(this.emptyBlock.hidden=this.cohort.size()===0,this.emptyBlock.textContent=`CLEAR ${this.cohort.size()}`),this.processBlock!==null&&(this.processBlock.hidden=this.cohort.size()===0),this.greeted||(this.greeted=!0,this.listing.row_indicate(zc))}cohortTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"name",label:"COHORT",className:"gather-cohort-name",width:"1fr",cell:()=>this.cohort.name_get()??"(unnamed — SAVE names it)"},{key:"series",label:"SERIES",className:"gather-cohort-count",width:"6em",cell:()=>String(this.series_count()),compare:()=>this.series_count()},{key:"patients",label:"PATIENTS",className:"gather-cohort-patients",width:"7em",cell:()=>String(this.patients_count()),compare:()=>this.patients_count()},{key:"feed",label:"FEED",className:"gather-cohort-feed",width:"7em",cell:()=>{if(this.cohort.feed_get()===null)return"—";const e=document.createElement("button");e.className="gather-feed listing-capsule listing-action-selected",e.textContent=`FEED ${this.cohort.feed_get()?.feedId??0}`,e.title="open the feed's graph beside the cohort";const t=this.cohort.feed_get()?.feedId??0;return e.addEventListener("click",s=>{s.stopPropagation(),this.handlers.feed_open(t)}),e},compare:()=>this.cohort.feed_get()?.feedId??-1}]}seriesTraits_declare(){const e=Ym(i=>i.entry.series??{seriesUID:i.entry.seriesUID,description:i.entry.description,modality:i.entry.modality,...i.entry.files===void 0?{}:{fileCount:i.entry.files},...i.entry.folderPath===void 0?{}:{pulled:!0,folderPath:i.entry.folderPath}},LS),t={key:"patient",label:"MRN",className:"gather-series-patient",width:"8em",cell:i=>i.entry.patient||"—"},s={key:"study",label:"STUDY",className:"gather-series-study",width:"14em",cell:i=>i.entry.study??"—"};return[...e.slice(0,1),s,t,...e.slice(1)]}cohortActions_declare(){const e=()=>({count:this.cohort.size(),feed:this.cohort.feed_get()?.feedId??null}),t={save:()=>{this.manifest_save()},export:()=>{this.cohort_export()},feed:()=>{this.feed_ensure()},process:()=>{this.cohort_process()},dismiss:()=>this.handlers.dismiss()};return qm.rules.map(s=>({label:s.label(e()),offered:()=>s.offered(e()),run:()=>t[s.name]?.()}))}seriesActions_declare(){const e=s=>({folderKnown:(s.entry.kind??"series")!=="series"||s.entry.folderPath!==void 0,imagery:(s.entry.kind??"series")==="series"||s.entry.imagery===!0,pullable:(s.entry.kind??"series")==="series"&&s.entry.folderPath===void 0&&s.entry.series?.pulled!==!0&&s.entry.vfsPath!==""}),t={remove:s=>this.series_remove(s.entry.seriesUID),pull:s=>this.handlers.command_show(`pull "${s.entry.vfsPath}"`),image:s=>{const i=s.entry.folderPath??qf(s.entry);i!==void 0&&this.handlers.image_open(i)},process:s=>{const i=s.entry.folderPath??qf(s.entry);if(i!==void 0){this.handlers.process_open(i);return}this.handlers.note(`gather: ${s.entry.description||s.entry.seriesUID} is not in CUBE yet — PULL it first, then PROCESS it.`)}};return Hm.rules.map(s=>({label:s.label({folderKnown:!0,pullable:!0}),offered:i=>s.offered(e(i)),run:i=>t[s.name]?.(i)}))}patients_count(){return new Set(this.cohort.members_get().filter(e=>(e.kind??"series")==="series").map(e=>e.patient)).size}series_count(){return this.cohort.members_get().filter(e=>(e.kind??"series")==="series").length}stateLine_compose(e){const t=this.cohort.members_get(),s=t.filter(o=>(o.kind??"series")!=="series").length,i=t.length-s,r=[];(i>0||s===0)&&r.push(`${i} SERIES`),s>0&&r.push(`${s} ${s===1?"PLACE":"PLACES"}`),s===0&&r.push(`${this.patients_count()} PATIENTS`);const a=[r.join(" · ")];return e.filter!==""&&a.push(e.filter),a.join(" · ")}async name_ensure(){if(this.cohort.name_get()!==null)return this.cohort.name_get();const t=(await this.handlers.name_ask(`gather-${new Date().toISOString().slice(0,10)}`)??"").trim();return t===""?null:(this.cohort.name_set(t),this.render(),t)}async manifest_save(){if(this.cohort.size()===0)return!1;const e=await this.name_ensure();if(e===null)return!1;const t=JSON.stringify({name:e,gatheredAt:new Date().toISOString(),series:[...this.cohort.members_get()].map(s=>({seriesUID:s.seriesUID,description:s.description,modality:s.modality,patient:s.patient,vfsPath:s.vfsPath}))});return this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${t}' ~/gather/${e}.json`),this.unsaved=!1,!0}async cohort_export(){if(this.cohort.size()===0)return;const e=await this.name_ensure();if(e===null)return;const t=[["patient","series","modality","seriesUID","path"].join(","),...[...this.cohort.members_get()].map(s=>[s.patient,s.description,s.modality,s.seriesUID,s.vfsPath].map(jS).join(","))];this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${t.join(`
4210
- `)}' ~/gather/${e}.csv`)}async feed_ensure(){const e=this.cohort.feed_get();if(e!==null)return e;if(this.cohort.size()===0)return null;const t=this.cohort.members_get().filter(a=>(a.kind??"series")!=="series");if(t.length>0)return this.handlers.note(`gather: this cohort holds ${t.length} ${t.length===1?"place":"places"} as well as series, and a feed is rooted by pulling its members — a place is already in ChRIS. PROCESS one place from its own row, or remove them to make a feed of the series. (Rooting a feed on the whole cohort, places included, is coming: CUBE takes the list.)`),null;const s=await this.name_ensure();if(s===null)return null;const i=[...this.cohort.members_get()].map(a=>a.vfsPath).join(" "),r=await this.handlers.feed_create(`pull --new-feed "${s}" ${i}`);return r!==null&&this.feed_set(r),r}async cohort_process(){const e=await this.feed_ensure();e!==null&&this.handlers.cohort_process({input:e.path,feed:e.feedId,node:e.rootInstanceId})}}class $S{members=new Map;title=null;landed=null;watchers=new Set;watch(e){return this.watchers.add(e),()=>{this.watchers.delete(e)}}changed(){for(const e of[...this.watchers])e()}members_get(){return[...this.members.values()]}size(){return this.members.size}has(e){return this.members.has(e)}take(e){const t=this.members.get(e.seriesUID);this.members.set(e.seriesUID,t===void 0?e:{...t,...e}),this.changed()}drop(e){const t=this.members.delete(e);return t&&this.changed(),t}clear(){this.members.size!==0&&(this.members.clear(),this.changed())}name_get(){return this.title}name_set(e){this.title=e,this.changed()}feed_get(){return this.landed}feed_set(e){this.landed=e,this.changed()}}class HS{grid;startHere;host;paintId=0;constructor(e,t){this.host=t,this.grid=e.querySelector(".launcher-grid"),this.startHere=e.querySelector(".launcher-start"),this.startHere.addEventListener("click",()=>{this.host.startHere_set(!this.host.startHere_get()),this.startHere_render()}),this.startHere_render()}render(){const e=++this.paintId;this.host.tiles().then(t=>{e!==this.paintId||!this.grid.isConnected||(this.grid.replaceChildren(...t.map((s,i)=>this.tile_build(s,i===0))),this.startHere_render())}).catch(()=>{e!==this.paintId||!this.grid.isConnected||this.grid.replaceChildren()})}numeral_press(e){const t=this.grid.querySelector(`[data-numeral="${e}"]`);return t===null?!1:(t.click(),!0)}startHere_render(){const e=this.host.startHere_get();this.startHere.textContent=e?"START HERE · ON":"START HERE · OFF",this.startHere.classList.toggle("pacs-capsule-off",!e)}tile_build(e,t){const s=document.createElement("button");s.className=`launcher-tile${t?" launcher-tile-wide":""}`,s.style.setProperty("--tile-hue",`var(${e.hue})`),s.dataset.numeral=e.numeral,s.title=e.verb,s.addEventListener("click",d=>{d.target instanceof Element&&d.target.closest(".launcher-row, .launcher-figure")!==null||e.enter()});const i=document.createElement("span");i.className="launcher-head";const r=document.createElement("span");r.className="launcher-name",r.textContent=e.name;const a=document.createElement("span");a.className="launcher-numeral",a.textContent=e.numeral,i.append(r);for(const d of e.figures){const h=document.createElement(d.open===void 0?"span":"button");if(h.className=`launcher-figure${d.errored===!0?" launcher-figure-errored":""}`,h.textContent=d.text,d.open!==void 0){const u=d.open;h.addEventListener("click",p=>{p.stopPropagation(),u()})}i.appendChild(h)}i.appendChild(a);const o=document.createElement("span");o.className="launcher-rule";const l=document.createElement("span");l.className="launcher-rows";for(const d of e.rows){const h=document.createElement(d.open===void 0?"span":"button");h.className=`launcher-row${d.arrived===!0?" launcher-row-arrived":""}`;const u=document.createElement("span");u.className=`launcher-dot${d.errored===!0?" launcher-dot-errored":""}`;const p=document.createElement("span");if(p.className="launcher-row-text",p.textContent=d.text,h.append(u,p),d.open!==void 0){const M=d.open,_=document.createElement("span");_.className="launcher-go",_.textContent="›",h.appendChild(_),h.addEventListener("click",m=>{m.stopPropagation(),M()})}l.appendChild(h)}const c=document.createElement("span");return c.className="launcher-verb",c.textContent=e.verb,s.append(i,o,l,c),s}}const qS=/\s--(?:\s|$)/;function wl(n){const e=qS.exec(n),t=e===null?n:n.slice(0,e.index),s=e===null?"":n.slice(e.index),i=t.lastIndexOf(";"),r=i===-1?0:i+1,a=t.slice(r),o=/^\s*\S+/.exec(a),l=r+(o===null?a.length:o[0].length);return{head:t.slice(0,l),args:t.slice(l),tail:s}}function Yf(n,e){return`cd "${n}"; ${e}`}function XS(n){return/^[A-Za-z0-9_./:@+=,-]+$/.test(n)?n:`"${n.replace(/(["\\])/g,"\\$1")}"`}function Km(n){const e=[],t=/"(?:[^"\\]|\\.)*"|\S+/g;let s=t.exec(n);for(;s!==null;)e.push(s[0]),s=t.exec(n);return e}function Kf(n){return n.length>=2&&n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\(["\\])/g,"$1"):n}function Zm(n){return n.startsWith("-")&&n!=="-"&&!/^-\d/.test(n)}function YS(n,e){const t=Km(wl(n).args);for(let s=0;s<t.length;s++){const i=t[s]??"";if(i===e){const r=t[s+1];return r===void 0||Zm(r)?!0:Kf(r)}if(i.startsWith(`${e}=`))return Kf(i.slice(e.length+1))}return null}function Zf(n,e,t){const s=wl(n),i=Km(s.args),r=[];let a=!1;const o=t===null||t===""?[]:t===!0?[e]:[e,XS(t)];for(let c=0;c<i.length;c++){const d=i[c]??"";if(d===e||d.startsWith(`${e}=`)){if(d===e){const h=i[c+1];h!==void 0&&!Zm(h)&&c++}a||(r.push(...o),a=!0);continue}r.push(d)}a||r.push(...o);const l=r.length===0?"":` ${r.join(" ")}`;return`${s.head}${l}${s.tail}`}function KS(n){return/\bfeed_title=/.test(wl(n).tail)}function ZS(n,e){return`${n} -- feed_title="${e.replace(/(["\\])/g,"\\$1")}"`}function Qf(n){return wl(n).head.replace(/^.*;\s*/,"").trim()}function QS(n,e,t){return/^[A-Za-z0-9_-]+$/.test(n)&&t.filter(i=>i===n).length===1?n:`@${e}`}function JS(n){return(n.replace(/\[[0-9;]*m/g,"").split(`
4211
- `).find(s=>s.trim().length>0)?.trim()??"").replace(/\s*\((?:[\d,]+\/[\d,]+(?:,\s*\d+%)?|initializing)\)(?=\.?$)/,"")}function As(n){return n.groups.map(e=>`${e.parent??"r"}:${e.plugin}`).join(">")}function Wd(n,e){return`feed:${n}:${e}`}function Qm(n){return`shape:${n}`}function dl(n){return Math.log2(Math.max(1,n)+1)}function eA(n){if(!(n.errored<=0||n.count<=0))return Math.min(1,n.errored/n.count)}function Ia(n,e="jobs"){const t=[],s=new Set,i=[...n].sort((a,o)=>a.id-o.id),r=new Map;for(const a of i){if(a.groups.length===0)continue;const o=As(a);r.set(o,(r.get(o)??0)+1)}for(const a of i){if(a.groups.length===0)continue;const o=As(a),l=Qm(o);s.has(o)||(s.add(o),t.push({id:l,label:yl(o),parentIds:[],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:r.get(o)??1})),a.groups.forEach((c,d)=>{const h=eA(c);t.push({id:Wd(a.id,d),label:c.plugin,parentIds:[c.parent===null?l:Wd(a.id,c.parent)],joinParentIds:[],status:c.status,metric:e==="jobs"?dl(c.count):1,...c.count>1?{count:c.count}:{},...h!==void 0?{share:h}:{}})})}return{nodes:t}}class Jm{byId=new Map;take(e){let t=!1;for(const s of e){const i=this.byId.get(s.id);i!==void 0&&i.status===s.status&&i.jobs===s.jobs&&JSON.stringify(i.groups)===JSON.stringify(s.groups)||(this.byId.set(s.id,{...s,chain:[...s.chain],groups:s.groups.map(r=>({...r}))}),t=!0)}return t}size(){return this.byId.size}shapes(){return new Set([...this.byId.values()].map(As)).size}all(){return[...this.byId.values()]}get(e){return this.byId.get(e)}clear(){this.byId.clear()}}function eM(n,e){const t=n.match(/^feed:(\d+):(\d+)$/);if(t===null)return null;const s=e.get(Number(t[1])),i=s?.groups[Number(t[2])];if(s===void 0||i===void 0)return null;const r=i.count>1?` ×${i.count.toLocaleString("en-US")}`:"",a=s.title.length>0?` · ${s.title}`:"",o=i.errored>0&&i.count>1?`${i.errored.toLocaleString("en-US")} errored`:i.status;return`${i.plugin}${r} · ${o} · feed ${s.id}${a}`}function tA(n,e){return`argus.universe.${n}@${e}`}const Dr={draw:"stars",view:"feeds",scale:"jobs",density:"shape",arrangement:"galaxy"};function sA(n,e,t,s,i=Dr.arrangement){return{draw:n,view:e,scale:t,density:s,arrangement:i}}function nA(n){let e={};try{const s=n===null?null:JSON.parse(n);s!==null&&typeof s=="object"&&!Array.isArray(s)&&(e=s)}catch{}const t=(s,i,r)=>typeof s=="string"&&i.includes(s)?s:r;return{draw:t(e.draw,["stars","spheres"],Dr.draw),view:t(e.view,["feeds","shapes"],Dr.view),scale:t(e.scale,["jobs","feeds"],Dr.scale),density:t(e.density,["shape","census"],Dr.density),arrangement:t(e.arrangement,["galaxy","spokes","clumps"],Dr.arrangement)}}function Jf(n){if(n===null||n.length===0)return{};try{const e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[s,i]of Object.entries(e))Array.isArray(i)&&i.length===3&&i.every(r=>typeof r=="number"&&Number.isFinite(r))&&(t[s]=[i[0],i[1],i[2]]);return t}catch{return{}}}function _c(n,e){return`inst:${n}:${e}`}function iA(n){const e=new Set(n.nodes.map(i=>i.id)),t=[],s=new Map;for(const i of n.nodes){const r=_c(n.feedId,i.id),a=i.parentIds.filter(d=>e.has(d)).map(d=>_c(n.feedId,d)),o=i.tally?.count??1,l=i.tally?.error??(i.status==="finishedWithError"?1:0),c=l>0&&o>0?Math.min(1,l/o):void 0;t.push({id:r,label:i.pluginName,parentIds:a,joinParentIds:i.joinParentIds.filter(d=>e.has(d)).map(d=>_c(n.feedId,d)),status:i.status,metric:dl(o),...o>1?{count:o}:{},...c!==void 0?{share:c}:{}}),s.set(r,i)}return{nodes:t,payloads:s}}function rA(n,e,t,s="jobs"){const i=Ia(n,s),r=`feed:${e}:`;return{nodes:[...i.nodes.filter(o=>!o.id.startsWith(r)).map(o=>({...o,dim:!0})),...t.nodes]}}function tM(n,e){return e.groups.map((t,s)=>Wd(n,s))}function yl(n){const e=[];for(const t of n.split(">")){const s=t.slice(t.indexOf(":")+1);s.length>0&&!e.includes(s)&&e.push(s)}return e.join(" > ")}function sM(n,e=3){const t=yl(n).split(" > ");return t.length<=e?t.join(" > "):`${t.slice(0,e).join(" > ")} … +${t.length-e}`}function aA(n,e){if(!n.startsWith("shape:"))return null;const t=n.slice(6),s=e.all().filter(i=>As(i)===t).length;return`${yl(t)} · ${s} feed${s===1?"":"s"}`}function oA(n,e){const t=[];for(const s of e.all())As(s)===n&&t.push(...tM(s.id,s));return t}function lA(n,e,t="jobs"){const s=Ia(n,t),i=new Set(n.filter(a=>As(a)===e).map(a=>a.id));return{nodes:s.nodes.map(a=>{if(a.ghost===!0)return a.id===Qm(e)?a:{...a,dim:!0};const o=a.id.match(/^feed:(\d+):/);return o!==null&&i.has(Number(o[1]))?a:{...a,dim:!0}})}}function Ld(n,e){return`fold:${n}:${e}`}function nM(n,e="jobs"){const t=new Map;for(const i of[...n].sort((r,a)=>r.id-a.id)){if(i.groups.length===0)continue;const r=As(i),a=t.get(r)??[];a.push(i),t.set(r,a)}const s=[];for(const[i,r]of t)r[0].groups.forEach((o,l)=>{let c=0,d=0;for(const u of r){const p=u.groups[l];p!==void 0&&(c+=p.count,p.errored>0&&(d+=1))}const h=d>0?Math.min(1,d/r.length):void 0;s.push({id:Ld(i,l),label:o.plugin,parentIds:o.parent===null?[]:[Ld(i,o.parent)],joinParentIds:[],status:d===r.length?"finishedWithError":"finishedSuccessfully",metric:dl(e==="feeds"?r.length:c),...r.length>1?{count:r.length}:{},...h!==void 0?{share:h}:{}})});return{nodes:s}}function cA(n,e){const t=n.match(/^fold:(.+):(\d+)$/);if(t===null)return null;const s=t[1],i=Number(t[2]),r=e.all().filter(d=>As(d)===s),a=r[0]?.groups[i]?.plugin;if(a===void 0)return null;const o=r.filter(d=>(d.groups[i]?.errored??0)>0).length,l=`${r.length.toLocaleString("en-US")} feed${r.length===1?"":"s"}`,c=o>0?` · ${o.toLocaleString("en-US")} with errors`:"";return`${a} · ${l}${c} · ${sM(s)}`}function ep(n){const e=n.match(/^fold:(.+):\d+$/);return e===null?null:e[1]}function tp(n,e){const t=e.all().find(s=>As(s)===n);return t===void 0?[]:t.groups.map((s,i)=>Ld(n,i))}function sp(n,e,t="jobs"){const s=n.filter(l=>As(l)===e),i=n.filter(l=>As(l)!==e),r=nM(i,t),a=Ia(s,t),o=a.nodes.filter(l=>l.ghost!==!0).map(l=>l.id);return{graph:{nodes:[...r.nodes.map(l=>({...l,dim:!0})),...a.nodes]},memberIds:o}}const dA=6e4,np=1e4,uA=new Set(["running","scheduled","created","started"]),hA=[/\/proc\/jobs\/feed_(\d+)(?:\/|$)/,/\/feeds?\/feed_(\d+)(?:\/|$)/],fA={running:"started",done:"finishedSuccessfully",error:"finishedWithError"};function ip(n){if(n.jobsTotal===void 0||n.jobsDone===void 0)return null;const e=n.status==="finishedWithError"||n.status==="cancelled",t=n.jobsErrored===void 0?void 0:n.jobsDone-n.jobsErrored;return{done:n.jobsDone,total:n.jobsTotal,...e?{failed:!0}:{},...t!==void 0?{succeeded:t}:{}}}function pA(n){const e=[];return n.layout==="molecule"&&e.push("dag layout molecule"),n.projection==="2d"&&e.push("dag projection 2d"),n.scale==="size"&&e.push("dag scale size"),n.hue==="compute"&&e.push("dag hue compute"),n.census==="census"&&e.push("dag census"),e}const mA=[{key:"control",label:"",className:"feedlist-control",capped:!1,width:"5.2em",cell:()=>{const n=document.createElement("span");return n.className="feedlist-control listing-capsule",n.textContent="OPEN",n}},{key:"id",label:"ID",className:"feedlist-id",width:"4em",cell:n=>String(n.id),compare:n=>n.id},{key:"title",label:"TITLE",className:"feedlist-title",width:"24em",cell:n=>n.title||"(untitled)",compare:n=>n.title},{key:"progress",label:"PROGRESS",className:"feedlist-progress",width:"1fr",cell:n=>Ro(ip(n)),compare:n=>{const e=ip(n);return e===null||e.total===0?-1:e.done/e.total}},{key:"status",label:"STATUS",className:"feedlist-status",width:"8em",cell:n=>n.status.toUpperCase(),compare:n=>n.status},{key:"nodes",label:"NODES",className:"feedlist-nodes",width:"4em",cell:n=>n.jobsTotal===void 0?"—":String(n.jobsTotal),compare:n=>n.jobsTotal??-1},{key:"sizeBytes",label:"SIZE",className:"feedlist-size",width:"5.5em",cell:n=>n.sizeBytes===void 0?"—":rM(n.sizeBytes),compare:n=>n.sizeBytes??-1},{key:"wallSeconds",label:"TIME",className:"feedlist-time",width:"6em",cell:n=>n.wallSeconds===void 0?"—":iM(n.wallSeconds),compare:n=>n.wallSeconds??-1},{key:"owner",label:"OWNER",className:"feedlist-owner",width:"7em",cell:n=>n.owner},{key:"createdAt",label:"CREATED",className:"feedlist-created",width:"7em",cell:n=>n.createdAt.slice(0,10),compare:n=>n.createdAt}];function rp(n,e){return n.nodes.length===e.nodes.length&&e.nodes.every((t,s)=>{const i=n.nodes[s];return i!==void 0&&i.id===t.id&&(i.tally?.count??1)===(t.tally?.count??1)&&i.parentIds.length===t.parentIds.length&&i.joinParentIds.length===t.joinParentIds.length})}class MA{scene;canvas;title;facts;empty;strategyPill;feedList;handlers;rosterTimer=null;shownFeedId=null;pinnedFeedId=null;requestedFeedId=null;defaultTitle;metricMode="time";lastModel=null;lastRoster=[];arrivals=new Set;arrivalsKey="";listing;stateSpan;watchedFeedId=null;liveState=null;pendingFeedId=null;lastCwd=null;constructor(e,t,s,i,r,a,o){this.feedList=a,this.canvas=e,e.style.display="none",this.title=t,this.defaultTitle=t.textContent??"",this.facts=s,this.empty=i,this.strategyPill=r,this.handlers=o;const l=r.closest(".pane-dag");this.stateSpan=l?.querySelector(".pane-state")??null,this.modeSpan=l?.querySelector(".pane-mode")??null;const c=o.feed_verbs;this.listing=new Ur({mount:this.feedList,traits:mA,key:f=>String(f.id),chrome:l===null?void 0:{root:l,prefix:"runs"},actions:c===void 0?void 0:{of:f=>c(f)},control:"control",activate:f=>this.feed_activate(f),indicated:f=>this.handlers.feed_indicated?.(f),row:{className:f=>`feedlist-row feedlist-${f.status}${this.arrivals.has(f.id)?" feedlist-arrived":""}`,decorate:(f,S)=>{f.dataset.feed=String(S.id),f.title=c===void 0?"enter the feed (Esc returns to this list)":"click to indicate, double-click to enter (Esc returns to this list)"}},state:f=>this.canvas.style.display==="block"?null:f.filter,defaultSort:{key:"createdAt",dir:"desc"}}),this.rosterTimer=setInterval(()=>{if(!this.feedList.isConnected||!this.rosterShown||this.rosterPending||document.visibilityState!=="visible")return;const S=this.lastRoster.some(v=>uA.has(v.status))?np:dA;Date.now()-this.rosterAskedAt<S||(this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds"))},np),this.scene=new _l(e,{select:f=>this.facts_show(f),activate:f=>this.node_activate(f),deselect:()=>this.facts.replaceChildren(),tip:f=>this.universeShown?eM(f.id,this.landed):null}),r.addEventListener("click",()=>{const f=this.scene.strategy_get()==="ranked"?"molecule":"ranked";this.scene.strategy_set(f),r.textContent=f.toUpperCase(),this.modes_render()});const d=r.parentElement?.querySelector(".dag-projection")??null;d?.addEventListener("click",()=>{const f=this.scene.projection_get()==="3d"?"2d":"3d";this.scene.projection_set(f),d.textContent=f.toUpperCase(),this.modes_render()});const h=r.parentElement?.querySelector(".dag-pulse")??null;h?.classList.add("rail-off"),h?.addEventListener("click",()=>{const f=!this.scene.waveLoop_get();this.scene.waveLoop_set(f),h.textContent=f?"PULSE ON":"PULSE OFF",h.classList.toggle("rail-off",!f),this.modes_render()});const u=r.parentElement?.querySelector(".dag-scale")??null;u?.addEventListener("click",()=>{this.metricMode=this.metricMode==="time"?"size":"time",u.textContent=this.metricMode==="time"?"TIME":"SIZE",this.lastModel!==null&&this.graph_show(this.lastModel,!1),this.modes_render()}),this.scalePill=u;const p=r.parentElement?.querySelector(".dag-census")??null;p?.addEventListener("click",()=>{const f=!this.scene.census_get();this.scene.census_set(f),p.textContent=f?"CENSUS":"SHAPE",this.modes_render()});const M=r.parentElement?.querySelector(".dag-gravity")??null;M?.classList.add("rail-off"),M?.addEventListener("click",()=>{const f=!this.scene.physics_get().gravity;this.scene.physics_set({gravity:f}),M.textContent=f?"GRAVITY ON":"GRAVITY OFF",M.classList.toggle("rail-off",!f),this.modes_render()});const _=r.parentElement?.querySelector(".dag-hue")??null;_?.addEventListener("click",()=>{this.hueMode=this.hueMode==="status"?"compute":"status",_.textContent=this.hueMode.toUpperCase(),this.lastModel!==null&&this.graph_show(this.lastModel,!1),this.hueMode==="compute"&&!this.computeKnown&&this.shownFeedId!==null&&this.canvas.style.display!=="none"&&(this.computeRereading=!0,this.handlers.command_run(`proc refresh ${this.shownFeedId}`),this.refresh()),this.modes_render()}),this.huePill=_,r.closest(".pane-dag")?.addEventListener("argus:dag-physics",f=>{const S=f.detail;if(S==="reset"){this.scene.physics_set({charge:!0,link:!0,collide:!0});return}if(S.term==="gravity"){this.scene.physics_get().gravity!==S.on&&M?.click();return}this.scene.physics_set({[S.term]:S.on})}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),window.addEventListener("resize",()=>this.scene.size_fit()),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),600)}).observe(document.body,{attributes:!0,attributeFilter:["data-zoom"]})}envelope_observe(e){if(e.model?.kind===Bp){const r=Rp.safeParse(e.model.data);r.success&&this.universe_show(r.data);return}if(e.model?.kind===Gp){this.rosterPending=!1;const r=Tp.safeParse(e.model.data);r.success&&(this.universe_end(!0),this.chooser_show(r.data.feeds));return}if(this.pendingFeedId!==null&&e.status==="error"&&e.model===void 0){this.feedRequest_refuse(e.renderedErr??e.rendered??"");return}if(this.rosterPending&&e.status==="error"){this.rosterPending=!1,this.rosterRefusal_show(e),this.universe_request();return}if(e.model?.kind===gi.feedIndexing){const r=nb.safeParse(e.model.data);if(!r.success)return;this.requestedFeedId===r.data.feedId?this.requestedFeedId=null:this.pendingFeedId!==r.data.feedId&&(this.pinnedFeedId=r.data.feedId,this.pendingFeedId=r.data.feedId),this.feedIndexing_show(r.data);return}if(e.model?.kind!==gi.feedDag)return;const t=Pc.safeParse(e.model.data);if(!t.success)return;const s=t.data;this.requestedFeedId===s.feedId?this.requestedFeedId=null:this.pinnedFeedId=s.feedId,this.universe_end(!1),this.shownFeedId=s.feedId,this.pendingFeedId=null,this.stateSpan?.classList.remove("state-wait"),this.title.textContent=`DAG · FEED ${s.feedId} — ${s.feedName}`.toUpperCase(),this.empty.style.display="none",this.roster_show(!1),this.canvas.style.display="block",this.lastModel!==null&&this.lastModel.feedId!==s.feedId&&(this.facts.replaceChildren(),this.scene.selection_clear());const i=this.lastModel;this.lastModel=s,i!==null&&i.feedId===s.feedId&&rp(i,s)?this.statuses_patch(s):this.graph_show(s),this.watch_open(s.feedId),this.handlers.feed_shown?.()}watch_open(e){this.watchedFeedId!==e&&(this.watch_release(),this.watchedFeedId=e,this.liveState_show(null),this.handlers.watch_set?.(`/proc/jobs/feed_${e}`,!0))}watch_release(){this.watchedFeedId!==null&&(this.handlers.watch_set?.(`/proc/jobs/feed_${this.watchedFeedId}`,!1),this.watchedFeedId=null,this.liveState_show(null))}modeSpan=null;hueMode="status";huePill=null;hueLegend=new Map;computeKnown=!1;computeRereading=!1;hueLegend_build(e){const t=getComputedStyle(document.documentElement),s=["--harvestgold","--daybreak","--orange","--honey","--butter","--october-sunset"].map(r=>t.getPropertyValue(r).trim()).filter(r=>r!==""),i=new Map;for(const r of e.nodes){const a=r.computeResource;a===void 0||a==="mixed"||i.has(a)||i.set(a,s[i.size%Math.max(1,s.length)]??"#888")}return i}modes_render(){if(this.modeSpan===null)return;const e=[];if(this.scene.strategy_get()!=="ranked"&&e.push("MOLECULE"),this.scene.projection_get()!=="3d"&&e.push("2D"),this.metricMode!=="time"&&e.push("SIZE"),this.scene.census_get()&&e.push("CENSUS"),this.scene.waveLoop_get()&&e.push("PULSE"),this.scene.physics_get().gravity&&e.push("GRAVITY"),this.modeSpan.replaceChildren(document.createTextNode(e.join(" · "))),this.hueMode==="compute"){const t=document.createElement("span");t.className="pane-legend",t.append(document.createTextNode(e.length>0?" · COMPUTE":"COMPUTE"));for(const[s,i]of this.hueLegend){const r=document.createElement("span");r.className="legend-swatch",r.style.backgroundColor=i;const a=document.createElement("span");a.textContent=s,t.append(document.createTextNode(" "),r,a)}this.hueLegend.size===0&&t.append(document.createTextNode(this.computeRereading?" (re-reading the feed…)":" (none reported)")),this.modeSpan.appendChild(t)}}liveState_show(e){if(this.liveState=e,this.stateSpan!==null){if(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),e===null){this.canvas.style.display!=="none"&&(this.stateSpan.textContent="");return}this.stateSpan.textContent=e.toUpperCase(),this.stateSpan.classList.add(`state-${e}`)}}liveState_get(){return this.liveState}feed_get(){return this.pendingFeedId??this.shownFeedId}graph_isShown(){return this.canvas.style.display==="block"}feedTitle_get(){return(this.title.textContent??"").replace(/^DAG\s*·\s*/i,"").trim()}view_lines(){const e=this.strategyPill.parentElement,t=s=>e?.querySelector(s)?.textContent?.trim().toLowerCase()??"";return pA({layout:t(".dag-strategy"),projection:t(".dag-projection"),scale:t(".dag-scale"),hue:t(".dag-hue"),census:t(".dag-census")})}watched_observe(e,t){const s=/feed_(\d+)$/.exec(e);!s||Number(s[1])!==this.watchedFeedId||this.liveState_show(t)}model_refresh(e){if(this.pendingFeedId===e.feedId&&this.canvas.style.display==="none"){this.envelope_observe({status:"ok",rendered:"",model:{kind:gi.feedDag,data:e}});return}if(this.shownFeedId!==e.feedId||this.canvas.style.display==="none")return;const t=this.lastModel;if(this.lastModel=e,t!==null&&rp(t,e)){this.statuses_patch(e);return}this.graph_show(e,!1)}statuses_patch(e){for(const t of e.nodes)this.scene.status_update(t.id,t.status),this.factsPayloads.set(t.id,t);this.factsShown!==null&&this.facts_show(this.factsShown)}refresh(){this.shownFeedId===null||this.canvas.style.display==="none"||(this.requestedFeedId=this.shownFeedId,this.handlers.command_run(`feed diagram feed_${this.shownFeedId}`))}scalePill=null;graph_show(e,t=!0){const s=o=>this.metricMode==="time"?o.metrics?.computeSeconds:o.metrics?.dataBytes,i=e.nodes.some(o=>s(o)!==void 0);this.scalePill?.classList.toggle("rail-na",!i),this.scalePill!==null&&(this.scalePill.title=i?"molecule node size: wall time or output bytes":`no ${this.metricMode==="time"?"wall-time":"output-size"} data in this feed's cache yet`),this.hueLegend=this.hueLegend_build(e);const r=e.nodes.some(o=>o.computeResource!==void 0);this.computeKnown=r,r&&(this.computeRereading=!1),this.huePill?.classList.toggle("rail-na",!r),this.huePill!==null&&(this.huePill.title=r?"what colors a node: its status, or the compute resource it ran on":"no compute resource reported for this feed's nodes yet");const a=o=>{if(this.hueMode==="compute")return o.computeResource===void 0?"#555":this.hueLegend.get(o.computeResource)??"#555"};this.scene.graph_set({nodes:e.nodes.map(o=>{const l=a(o);return{id:o.id,label:o.label,parentIds:o.parentIds,joinParentIds:o.joinParentIds,status:o.status,metric:s(o),count:o.tally?.count,...l!==void 0?{hue:l}:{}}})},{wave:t}),this.scene.size_fit(),this.hueMode==="compute"&&this.modes_render(),this.factsPayloads.clear();for(const o of e.nodes)this.factsPayloads.set(o.id,o);this.factsShown!==null&&(this.factsPayloads.has(this.factsShown.id)?this.facts_show(this.factsShown):this.factsShown=null)}factsPayloads=new Map;factsShown=null;promptContext_observe(e){const t=e.procWarmup?.landed??[];if(t.length>0&&this.universeLandings_take(t),this.universeShown&&this.universeLive){const o=e.procWarmup;if(o?.total!==void 0&&o.total>0&&o.sweeping!==!1){const l=Math.floor(o.loaded/o.total*100),c=`INDEX WARMING ${o.loaded.toLocaleString()}/${o.total.toLocaleString()} (${l}%)`;c!==this.universeWarming&&(this.universeWarming=c,this.universeTitle_paint())}else(o===void 0||o.sweeping===!1||o.state==="cached")&&(this.universeLive=!1,this.universeWarming="",this.universe_request())}if(this.rosterProgress!==null&&this.rosterProgress.isConnected){const o=e.procWarmup;if(o?.total!==void 0&&o.total>0&&o.sweeping!==!1){const l=Math.floor(o.loaded/o.total*100);this.rosterProgress.textContent=`INDEX WARMING — ${o.loaded}/${o.total} (${l}%). The roster opens when the index is whole.`}(o===void 0||o.sweeping===!1||o.state==="cached")&&(this.rosterProgress=null,this.feedsChooser_request())}this.arrivals_observe(e.procWarmup?.arrived??[]);const i=(e.procWarmup?.feeds??(e.procWarmup?.feed!==void 0?[e.procWarmup.feed]:[])).find(o=>o.id===this.pendingFeedId);if(i!==void 0&&this.feedIndexing_show({feedId:i.id,loaded:i.loaded,total:i.total,...i.failed!==void 0?{failed:i.failed}:{}}),!this.canvas.isConnected||this.rosterShown||this.pendingFeedId!==null)return;const r=this.lastCwd!==null&&e.cwd!==this.lastCwd;if(this.lastCwd=e.cwd,!r)return;const a=bA(e.cwd);a!==null&&a!==this.shownFeedId&&(this.pinnedFeedId!==null&&a===this.pinnedFeedId||(this.pinnedFeedId=null,this.requestedFeedId=a,this.handlers.command_run(`feed diagram feed_${a}`)))}progress_observe(e){if(e.itemId===void 0)return;const t=e.status!==void 0?fA[e.status]:void 0;t!==void 0&&this.scene.status_update(String(e.itemId),t)}size_fit(){this.scene.size_fit()}dispose(){this.watch_release(),this.rosterTimer!==null&&clearInterval(this.rosterTimer),this.scene.dispose()}feed_enter(e){this.pinnedFeedId=e,this.requestedFeedId=null,this.feedRequest_show(e),this.handlers.command_run(`feed diagram feed_${e}`)}feedRequest_show(e){this.pendingFeedId=e,this.roster_show(!1),this.canvas.style.display="none",this.facts.replaceChildren(),this.title.textContent=`DAG · FEED ${e}`,this.empty.textContent=`RETRIEVING FEED ${e}…`,this.empty.style.display="block",this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),this.stateSpan.classList.add("state-wait"),this.stateSpan.textContent="LOADING")}feedIndexing_show(e){this.pendingFeedId===null&&(this.pendingFeedId=e.feedId),this.roster_show(!1),this.canvas.style.display="none",this.title.textContent=`DAG · FEED ${e.feedId}`;const t=e.total>0?`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:`${e.loaded.toLocaleString()} / ?`;this.empty.textContent=e.failed!==void 0?`INDEXING FEED ${e.feedId} FAILED AT ${t} — ${e.failed.toUpperCase()} — REFRESH RETRIES`:`INDEXING FEED ${e.feedId} — ${t}`,this.empty.style.display="block",this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),this.stateSpan.classList.add("state-wait"),this.stateSpan.textContent=e.failed!==void 0?"FAILED":"LOADING"),e.failed===void 0&&this.watch_open(e.feedId)}feedRequest_refuse(e){const t=this.pendingFeedId;this.pendingFeedId=null,this.empty.textContent=`FEED ${t??"?"}: ${e.trim()||"not available"}`.toUpperCase(),this.empty.style.display="block",this.roster_show(!0),this.title.textContent=this.defaultTitle,this.stateSpan?.classList.remove("state-wait"),this.listing.state_refresh()}feedsChooser_request(){const e=document.createElement("div");e.className="feedlist-loading",e.textContent="RETRIEVING FEED ROSTER…",this.feedList.replaceChildren(e),this.roster_show(!0),this.rosterPending=!0,this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds")}rosterPending=!1;rosterShown=!1;rosterAskedAt=0;rosterProgress=null;landed=new Jm;universeShown=!1;universeLive=!1;universeRepaint=null;universeStrategyWas=null;universeWarming="";universe_request(){this.handlers.command_run("proc universe")}universe_show(e){this.landed.clear(),this.landed.take(e.feeds),this.universeLive=!e.whole,this.universeShown||(this.universeShown=!0,this.universeStrategyWas=this.scene.strategy_get(),this.scene.strategy_set("molecule"),this.scene.physics_set({gravity:!0})),this.roster_show(!1),this.pendingFeedId=null,this.pinnedFeedId=null,this.empty.style.display="none",this.canvas.style.display="block",this.universe_paint()}universe_paint(){this.lastModel=null,this.scene.graph_set(Ia(this.landed.all()),{wave:!1}),this.universeTitle_paint()}universeTitle_paint(){const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.universeLive?`UNIVERSE — ${e}${this.universeWarming.length>0?` · ${this.universeWarming}`:" · INDEX WARMING"}`:`UNIVERSE — ${e}`,this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale","state-wait"),this.stateSpan.classList.add(this.universeLive?"state-wait":"state-settled"),this.stateSpan.textContent=this.universeLive?"LANDING":"WHOLE")}universeLandings_take(e){!this.universeShown||!this.universeLive||!this.landed.take(e)||this.universeRepaint!==null||(this.universeRepaint=window.setTimeout(()=>{this.universeRepaint=null,this.universeShown&&this.universe_paint()},1e3))}universe_end(e){this.universeShown&&(this.universeShown=!1,this.universeLive=!1,this.universeWarming="",this.universeRepaint!==null&&(window.clearTimeout(this.universeRepaint),this.universeRepaint=null),this.landed.clear(),this.universeStrategyWas!==null&&(this.scene.strategy_set(this.universeStrategyWas),this.universeStrategyWas=null),this.scene.selection_clear(),e&&(this.canvas.style.display="none"))}rosterRefusal_show(e){const t=JS(e.renderedErr||e.rendered||""),s=t.length>0?t:"the roster request was refused",i=document.createElement("div");i.className="feedlist-refusal",i.textContent=s;const r=document.createElement("div");r.className="feedlist-warming",r.textContent="INDEX WARMING… the roster opens when the index is whole.",this.feedList.replaceChildren(i,r),this.roster_show(!0),this.rosterProgress=r}list_reset(){this.pendingFeedId=null,this.stateSpan?.classList.remove("state-wait"),this.watch_release(),this.facts.replaceChildren(),this.scene.selection_clear(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.empty.style.display="none"}nav_pop(){return this.pendingFeedId!==null&&this.feedList.childElementCount>0?(this.pendingFeedId=null,this.pinnedFeedId=null,this.requestedFeedId=null,this.empty.style.display="none",this.roster_show(!0),this.title.textContent=this.defaultTitle,this.stateSpan?.classList.remove("state-wait"),this.listing.state_refresh(),!0):this.canvas.style.display==="none"||this.feedList.childElementCount===0?!1:(this.watch_release(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.facts.replaceChildren(),this.scene.selection_clear(),this.roster_show(!0),this.listing.state_refresh(),!0)}arrivals_observe(e){const t=e.join(",");if(t===this.arrivalsKey)return;this.arrivalsKey=t,this.arrivals=new Set(e);for(const r of this.lastRoster)this.listing.row_element(String(r.id))?.classList.toggle("feedlist-arrived",this.arrivals.has(r.id));const s=new Set(this.lastRoster.map(r=>r.id));e.some(r=>!s.has(r))&&this.rosterShown&&this.feedsChooser_request()}chooser_show(e){this.lastRoster=e,this.empty.style.display="none",this.roster_show(!0),this.listing.rows_set([{key:"roster",rows:e}],{field:"roster"}),this.rosterFrame_track()}feed_activate(e){this.pinnedFeedId=e.id,this.requestedFeedId=null,this.handlers.feed_regard?.(`/proc/jobs/feed_${e.id}`),this.feedRequest_show(e.id),this.handlers.command_run(`feed diagram feed_${e.id}`)}row_indicate(e){this.listing.row_indicate(e===null?null:String(e.id))}rowReadout_show(e,t){this.listing.readout_show(String(e),t)}filter_toggle(e){this.listing.filter_toggle(e)}roster_filter(e){this.listing.filter_toggle(e!==""),this.listing.filter_set(e)}rosterFrameObserver=null;rosterFrame_track(){const e=this.feedList.parentElement,t=this.feedList.querySelector(".roster-order");if(this.rosterFrameObserver?.disconnect(),this.rosterFrameObserver=null,e===null)return;if(t===null){e.style.removeProperty("--mode-frame-top");return}const s=()=>{e.style.setProperty("--mode-frame-top",`${Math.ceil(t.getBoundingClientRect().bottom-e.getBoundingClientRect().top)}px`)};s(),this.rosterFrameObserver=new ResizeObserver(s),this.rosterFrameObserver.observe(t)}roster_show(e){this.rosterShown=e,this.feedList.style.display=e?"flex":"none",this.feedList.parentElement?.classList.toggle("roster-shown",e)}facts_show(e){this.factsShown=e;const t=this.factsPayloads.get(e.id);if(!t){this.facts.textContent=e.label;return}this.handlers.node_regard?.(t.vfsPath),this.facts.replaceChildren();const i=t.status==="finishedSuccessfully"||t.status==="finishedWithError"||t.status==="cancelled"?"awaiting warmup":"in flight",r=t.tally,a=[["PLUGIN",t.pluginName],[r?"REP. INSTANCE":"INSTANCE",String(t.instanceId)],["STATUS",t.status],...r?[["COUNT",`×${r.count} — ${r.done} done, ${r.error} err, ${r.running} live, ${r.other} other`]]:[],...r?.anomalies!==void 0&&r.anomalies.length>0?[["FAULTS",r.anomalies.map(o=>o.id).join(" ")+(r.count>r.done+r.anomalies.length?" …":"")]]:[],["WALL",t.metrics?.computeSeconds!==void 0?iM(t.metrics.computeSeconds):i],["SIZE",t.metrics?.dataBytes!==void 0?rM(t.metrics.dataBytes):i],["DATA",t.vfsPath]];for(const[o,l]of a){const c=document.createElement("div");c.className="telemetry-row";const d=document.createElement("span");d.className="telemetry-label",d.textContent=o;const h=document.createElement("span");h.className="telemetry-value",h.textContent=l,c.append(d,h),this.facts.appendChild(c)}if(this.facts.appendChild(gA(t.status)),this.handlers.node_process!==void 0){const o=this.handlers.node_process,l=document.createElement("button");l.className="pacs-capsule dag-process",r!==void 0?(l.textContent="PROCESS",l.disabled=!0,l.title=`${r.count} instances stand here: open one to process it`,l.classList.add("pacs-capsule-off")):(l.textContent="PROCESS",l.title=`open /bin bound to ${t.label} — a run appends to this node`,l.addEventListener("click",()=>o({vfsPath:t.vfsPath,instanceId:t.instanceId,label:t.label}))),this.facts.appendChild(l)}}node_activate(e){const t=this.factsPayloads.get(e.id);if(t)if(this.handlers.node_dive!==void 0){const s=this.handlers.node_dive;this.scene.flight_into(e.id,()=>s(t.vfsPath))}else this.handlers.node_enter(t.vfsPath)}detail_clear(){this.scene.selection_clear(),this.facts.replaceChildren()}wave_start(){this.scene.wave_start()}inside_isHeld(){return this.scene.holding_get()}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){for(const[t,s]of this.factsPayloads){if(s.instanceId!==e)continue;if(this.handlers.node_dive===void 0)return!1;const i=this.handlers.node_dive;return this.facts_show({id:t,label:s.label,parentIds:[],joinParentIds:[]}),this.scene.flight_into(t,()=>i(s.vfsPath)),!0}return!1}}function iM(n){const e=Math.round(n);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${String(e%60).padStart(2,"0")}s`:`${Math.floor(e/3600)}h ${String(Math.floor(e%3600/60)).padStart(2,"0")}m`}function rM(n){if(n<1024)return`${n}B`;const e=["K","M","G","T"];let t=n,s=-1;for(;t>=1024&&s<e.length-1;)t=t/1024,s=s+1;return`${t<10?t.toFixed(1):Math.round(t)}${e[s]}`}const wc=[{key:"created",label:"CREATED"},{key:"waiting",label:"WAITING"},{key:"scheduled",label:"SCHEDULED"},{key:"started",label:"STARTED"},{key:"registeringFiles",label:"REGISTERING"}];function gA(n){const e=document.createElement("div");e.className="dag-subway";const t=n==="finishedSuccessfully",s=n==="finishedWithError"||n==="cancelled",i=wc.findIndex(l=>l.key===n),r=t||s?wc.length:i;!t&&!s&&e.classList.add("dag-subway-live");const a=(l,c,d)=>{const h=document.createElement("span");h.className=`subway-step${d?" subway-step-here":""}`;const u=document.createElement("span");u.className=c;const p=document.createElement("span");return p.className="subway-label",p.textContent=l,h.append(u,p),h};wc.forEach((l,c)=>{if(c>0){const h=document.createElement("span");h.className="subway-link"+(c<=r?" subway-passed":""),e.appendChild(h)}const d=c===i&&!t&&!s;e.appendChild(a(l.label,"subway-stop"+(c<r?" subway-passed":"")+(d?" subway-here":""),d))});const o=document.createElement("span");return o.className="subway-link"+(t||s?" subway-passed":""),e.appendChild(o),e.appendChild(a(t?"FINISHED":s?n==="cancelled"?"CANCELLED":"ERROR":"FINISHED","subway-stop subway-terminal"+(t?" subway-done":"")+(s?" subway-failed":""),!1)),e}function bA(n){for(const e of hA){const t=n.match(e);if(t?.[1]!==void 0)return parseInt(t[1],10)}return null}class zA{root;label;fill;constructor(e){this.root=document.createElement("div"),this.root.className="wait-progress",this.root.hidden=!0,this.root.setAttribute("role","progressbar"),this.root.setAttribute("aria-valuemin","0"),this.root.setAttribute("aria-valuemax","100"),this.label=document.createElement("span"),this.label.className="wait-progress-label";const t=document.createElement("span");t.className="wait-progress-track",this.fill=document.createElement("span"),this.fill.className="wait-progress-fill",t.appendChild(this.fill),this.root.append(this.label,t),e.appendChild(this.root)}show(e,t){this.root.hidden=!1,this.label.textContent=t===null?e:`${e} · ${Math.floor(t*100)}%`,this.root.classList.toggle("wait-progress-indeterminate",t===null),this.fill.style.width=t===null?"":`${Math.max(0,Math.min(1,t))*100}%`,t===null?this.root.removeAttribute("aria-valuenow"):this.root.setAttribute("aria-valuenow",String(Math.floor(t*100)))}hide(){this.root.hidden=!0}shown(){return!this.root.hidden}}const yc=12,_A=240,wA=1e3,yA=5e3,vA=3e3,da=650,OA=650;class xA{scene;wait;asking=!1;spaceKey="";landed=new Jm;canvas;title;state;empty;handlers;store;whole=!1;shown=!1;warming="";repaintTimer=null;lastReask=0;rememberTimer=null;storeKey=null;arrivalsKey="";feedsCount=null;disposed=!1;scale="jobs";view="feeds";inside=null;cluster=null;flying=!1;entering=null;facts;viewPill=null;gravityPill=null;densityPill=null;density="shape";drawMode="stars";drawPill=null;arrangement="galaxy";arrangementPill=null;scalePill=null;physics={...ol,gravity:!0};backPill;openPill;pane;escape_listen;reach=null;constructor(e,t,s){this.canvas=e.canvas,this.title=e.title,this.state=e.state,this.empty=e.empty,this.handlers=t,this.store=s,this.facts=e.facts,this.backPill=e.backPill,this.openPill=e.openPill,this.pane=e.canvas.closest(".workspace-pane"),this.wait=new zA(e.canvas),this.scene=new _l(e.canvas,{progress:(i,r,a)=>this.settle_progress(i,r,a),handoffKey:i=>{const r=i.id.match(/^feed:(\d+):/);if(r!==null)return`feed:${r[1]}`;const a=ep(i.id);return a===null?null:`fold:${a}`},tip:i=>this.inside===null?cA(i.id,this.landed)??eM(i.id,this.landed)??aA(i.id,this.landed):null,select:i=>this.node_select(i),activate:i=>this.node_dive(i),deselect:()=>this.facts_clear()}),e.backPill?.addEventListener("click",()=>this.ascend()),e.openPill?.addEventListener("click",()=>{this.inside!==null&&this.handlers.feed_open?.(this.inside.feedId)}),this.escape_listen=i=>{i.key!=="Escape"||this.inside===null&&this.cluster===null||this.flying||this.scene.holding_get()||this.pane!==null&&this.pane.offsetParent===null||this.ascend()},window.addEventListener("keydown",this.escape_listen),this.scene.strategy_set("molecule"),this.scene.physics_set(this.physics),e.projectionPill?.addEventListener("click",()=>{const i=this.scene.projection_get()==="3d"?"2d":"3d";this.scene.projection_set(i),e.projectionPill!==null&&(e.projectionPill.textContent=i.toUpperCase())}),e.refreshPill?.addEventListener("click",()=>this.request()),e.scalePill?.addEventListener("click",()=>{this.scale=this.scale==="jobs"?"feeds":"jobs",e.scalePill!==null&&(e.scalePill.textContent=this.scale==="jobs"?"JOBS":"ALIKE"),this.shown&&this.paint(!0,"full"),this.settings_save()}),e.viewPill?.addEventListener("click",()=>this.view_set(this.view==="feeds"?"shapes":"feeds")),this.viewPill=e.viewPill,this.gravityPill=e.gravityPill,e.gravityPill?.addEventListener("click",()=>{this.physics_set("gravity",!this.physics.gravity)}),this.densityPill=e.densityPill,e.densityPill?.addEventListener("click",()=>{this.density_set(this.density==="shape"?"census":"shape")}),this.drawPill=e.drawPill??null,this.scalePill=e.scalePill,e.drawPill?.addEventListener("click",()=>{this.draw_set(this.drawMode==="stars"?"spheres":"stars")}),this.arrangementPill=e.arrangementPill??null,e.arrangementPill?.addEventListener("click",()=>{this.arrangement_set(this.arrangement==="galaxy"?"spokes":this.arrangement==="spokes"?"clumps":"galaxy")}),this.scene.draw_set(this.drawMode),this.canvas.style.display="none",this.title_paint()}request(){this.asking=!0,this.shown||this.wait.show("ASKING THE SESSION FOR THE SPACE",null),this.title_paint(),this.handlers.command_run("proc universe")}settle_progress(e,t,s){if(e>=t){this.wait.hide(),this.remember_later();return}this.wait.show(`SETTLING ${s.toLocaleString("en-US")} SPHERES`,t===0?1:e/t)}envelope_observe(e){if(e.model?.kind!==Bp)return;const t=Rp.safeParse(e.model.data);t.success&&this.space_show(t.data)}promptContext_observe(e){if(this.disposed)return;this.identity_note(e.user,e.uri);const t=e.procWarmup?.landed??[];t.length>0&&this.shown&&this.landings_take(t);const s=e.procWarmup;if(s?.total!==void 0&&s.total>0&&s.sweeping!==!1&&!this.whole){const i=Math.floor(s.loaded/s.total*100),r=`INDEX WARMING ${s.loaded.toLocaleString()}/${s.total.toLocaleString()} (${i}%)`;r!==this.warming&&(this.warming=r,this.title_paint())}else this.shown&&!this.whole&&(s===void 0||s.sweeping===!1||s.state==="cached")&&(this.warming="",this.request());if(this.shown&&this.whole){const i=(s?.arrived??[]).join(","),r=e.procIndex?.feeds??null,a=i.length>0&&i!==this.arrivalsKey||r!==null&&this.feedsCount!==null&&r!==this.feedsCount;this.arrivalsKey=i,r!==null&&(this.feedsCount=r),a&&Date.now()-this.lastReask>yA&&(this.lastReask=Date.now(),this.request())}}size_fit(){this.scene.size_fit()}control(e,t){if(e==="enter"){const s=parseInt(t[0]??"",10);return Number.isFinite(s)?this.landed.get(s)===void 0?`universe enter: feed ${s} has not landed here`:this.inside!==null?`universe enter: already inside feed ${this.inside.feedId}; universe back first`:(this.descend(s),`entering feed ${s}`):"universe enter <feed id>"}if(e==="node"){const s=parseInt(t[0]??"",10);return Number.isFinite(s)?this.inside===null?"universe node: not inside a feed (universe enter <feed> first)":this.node_flyTo(s)?`flying into instance ${s}`:`universe node: no node of feed ${this.inside.feedId} hosts instance ${s}`:"universe node <instance id>: fly into the entered feed's node that hosts it"}if(e==="state"){const s=this.scene.state_get(),i=(()=>{const r=this.settingsKey_get();try{return r===null||this.store===void 0?null:this.store.getItem(r)}catch{return null}})();return[`universe: ${this.inside!==null?`inside feed ${this.inside.feedId}`:this.cluster!==null?"in a cluster":"the whole space"}; view ${this.view}, scale ${this.scale}, density ${this.density}`,`scene: ${Object.entries(s).map(([r,a])=>`${r}=${String(a)}`).join(" ")}`,`kept settings: ${i??"(none)"}`].join(`
4212
- `)}if(e==="layout"){const s=(t[0]??"").toLowerCase();return s!=="galaxy"&&s!=="spokes"&&s!=="clumps"?"universe layout galaxy|spokes|clumps":this.arrangement_set(s)}if(e==="draw"){const s=(t[0]??"").toLowerCase();return s!=="stars"&&s!=="spheres"?"universe draw stars|spheres":this.draw_set(s)}if(e==="density"){const s=(t[0]??"").toLowerCase();return s!=="shape"&&s!=="census"?"universe density shape|census":this.density_set(s)}if(e==="physics"){const s=(t[0]??"").toLowerCase();if(s==="reset")return this.physics_reset();if(!["charge","link","collide","gravity"].includes(s))return"universe physics charge|link|collide|gravity [on|off] | reset";const i=(t[1]??"on").toLowerCase()!=="off";return this.physics_set(s,i)}if(e==="view"){const s=(t[0]??"").toLowerCase();return s!=="feeds"&&s!=="shapes"?"universe view feeds|shapes":this.inside!==null||this.cluster!==null?"universe view: climb out first (universe back)":(this.view_set(s),s==="feeds"?"every feed its own molecule":"the shapes folded, one molecule each")}if(this.flying&&(e==="enter"||e==="cluster"||e==="back"))return"universe: still moving; ask again";if(e==="cluster"){const s=parseInt(t[0]??"",10),i=Number.isFinite(s)?this.landed.get(s):void 0;return i===void 0?"universe cluster <feed id>: the cluster of a feed that landed here":this.inside!==null?`universe cluster: inside feed ${this.inside.feedId}; universe back first`:(this.cluster_enter(As(i)),`viewing the cluster of feed ${s}: ${yl(As(i))}`)}return e==="back"?this.inside===null&&this.cluster===null?"universe back: not inside a feed or a cluster":(this.ascend(),"climbing out"):e==="open"?this.inside===null?"universe open: not inside a feed":(this.handlers.feed_open?.(this.inside.feedId),`opening feed ${this.inside.feedId}`):"universe enter <feed>|node <instance>|cluster <feed>|view feeds|shapes|density shape|census|draw stars|spheres|layout galaxy|spokes|clumps|state|physics <term> on|off|reset|back|open"}physics_set(e,t){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":e==="reach"?"universe physics: reach is the pane's own":(this.physics={...this.physics,[e]:t},this.physics_apply(),`physics ${e} ${t?"on":"off"}`)}draw_set(e){return this.drawMode=e,this.drawPill!==null&&(this.drawPill.textContent=e.toUpperCase()),this.scene.draw_set(e),this.settings_save(),e==="stars"?"every sphere a point of light":"every sphere lit and solid"}arrangement_set(e){return this.arrangement=e,this.arrangementPill!==null&&(this.arrangementPill.textContent=e.toUpperCase()),this.remember_now(),this.inside===null&&this.cluster===null&&this.scene.arrangement_set(e,this.positions_recalled(e)),this.settings_save(),e==="galaxy"?"the space finds its own shape: every sphere pushing, every edge holding":e==="spokes"?"each molecule a spoke round its hub":"molecules packed round their hub"}settingsKey_get(){return this.storeKey===null?null:this.storeKey.replace(/^argus\.universe\./,"argus.universe.settings.")}settings_save(){const e=this.settingsKey_get();if(!(this.store===void 0||e===null))try{this.store.setItem(e,JSON.stringify(sA(this.drawMode,this.view,this.scale,this.density,this.arrangement)))}catch{}}settings_recall(){const e=this.settingsKey_get();if(this.store===void 0||e===null)return!1;let t=null;try{t=this.store.getItem(e)}catch{return!1}const s=nA(t),i=s.view!==this.view||s.scale!==this.scale;return this.drawMode=s.draw,this.view=s.view,this.scale=s.scale,this.density=s.density,this.arrangement=s.arrangement,this.arrangementPill!==null&&(this.arrangementPill.textContent=s.arrangement.toUpperCase()),this.scene.arrangement_set(s.arrangement,this.positions_recalled(s.arrangement)),this.drawPill!==null&&(this.drawPill.textContent=s.draw.toUpperCase()),this.viewPill!==null&&(this.viewPill.textContent=s.view.toUpperCase()),this.scalePill!==null&&(this.scalePill.textContent=s.scale==="jobs"?"JOBS":"ALIKE"),this.densityPill!==null&&(this.densityPill.textContent=s.density.toUpperCase()),this.scene.draw_set(s.draw),this.scene.census_set(s.density==="census"),i}density_set(e){return this.density=e,this.densityPill!==null&&(this.densityPill.textContent=e.toUpperCase()),this.scene.census_set(e==="census"),this.settings_save(),e==="census"?"every job its own point":"a stage one sphere, with its count"}physics_reset(){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":(this.physics={...ol,gravity:!0},this.physics_apply(),"physics reset")}physics_apply(){this.gravityPill!==null&&(this.gravityPill.textContent=this.physics.gravity?"GRAVITY ON":"GRAVITY OFF"),this.scene.physics_set({...this.physics,reach:this.reach??void 0}),this.title_paint()}view_set(e){this.view=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.shown&&this.inside===null&&this.cluster===null&&this.paint(!0,"full"),this.settings_save()}inside_get(){return this.inside?.feedId??null}shown_get(){return this.shown}dispose(){this.disposed=!0,window.removeEventListener("keydown",this.escape_listen),this.repaintTimer!==null&&window.clearTimeout(this.repaintTimer),this.rememberTimer!==null&&window.clearTimeout(this.rememberTimer),this.remember_now(),this.scene.dispose()}space_show(e){this.asking=!1;const t=`${e.whole?"W":"L"}|${e.feeds.map(s=>`${s.id}:${s.jobs}:${s.status}`).join(",")}`;if(this.shown&&t===this.spaceKey){this.title_paint();return}this.spaceKey=t,this.wait.hide(),this.whole=e.whole,this.shown||(this.shown=!0,this.seed_recall()),this.landed.clear(),this.landed.take(e.feeds),this.whole&&(this.warming=""),this.empty.style.display="none",this.canvas.style.display="block",this.inside===null&&this.cluster===null&&this.entering===null&&!this.flying?this.paint(!this.scene.camera_touched()):this.title_paint()}landings_take(e){!this.landed.take(e)||this.repaintTimer!==null||this.inside!==null||this.cluster!==null||this.entering!==null||(this.repaintTimer=window.setTimeout(()=>{this.repaintTimer=null,!(this.disposed||this.entering!==null||this.inside!==null||this.cluster!==null||this.flying)&&this.paint(!this.scene.camera_touched())},wA))}paint(e=!0,t="new"){const s=this.view==="shapes"?nM(this.landed.all(),this.scale):Ia(this.landed.all(),this.scale),i=s.nodes.length<=_A?yc:void 0;i!==this.reach&&(this.reach=i,this.scene.physics_set({reach:i},!1)),this.scene.graph_set(s,{wave:!1,fit:e,settle:t}),this.title_paint(),this.remember_later()}descend(e,t){const s=this.landed.get(e),i=this.handlers.feed_dag;if(s===void 0||i===void 0||this.flying||this.inside!==null)return;this.flying=!0,this.facts_clear();const r=tM(e,s);this.entering=e,this.title_paint();const a=Date.now();(l=>{t!==void 0?this.scene.camera_flyToward(t,14,da,l):this.scene.camera_flyToFit(r,da,l)})(()=>{i(e).then(l=>{if(this.disposed)return;if(this.entering=null,l===null){this.flying=!1,this.title_paint(),this.handlers.note?.(`universe: feed ${e}: the session gave no graph for it (feed diagram feed_${e} refused or answered nothing after ${Math.round((Date.now()-a)/1e3)}s)`);return}const c=iA(l);for(const f of c.nodes)f.solid=!0;const d=this.scene.positions_get(),h=[0,0,0];let u=0;for(const f of[...r,...tp(As(s),this.landed)]){const S=d[f];if(S!==void 0&&(h[0]+=S[0],h[1]+=S[1],h[2]+=S[2],u+=1,u===r.length&&r.some(v=>d[v]!==void 0)))break}u>0&&(h[0]/=u,h[1]/=u,h[2]/=u);for(const f of c.nodes)d[f.id]=[h[0]+(Math.random()-.5)*.5,h[1]+(Math.random()-.5)*.5,h[2]+(Math.random()-.5)*.5];this.scene.positions_seed(d);const p=`feed:${e}:`,M=this.view==="feeds"?rA(this.landed.all(),e,c,this.scale):{nodes:[...sp(this.landed.all(),As(s),this.scale).graph.nodes.filter(f=>!f.id.startsWith(p)).map(f=>({...f,dim:!0})),...c.nodes]},_=new Set(c.nodes.map(f=>f.id)),m=M.nodes.filter(f=>!_.has(f.id)).map(f=>f.id);this.scene.graph_set(M,{wave:!1,fit:!1,frozen:m,physics:{reach:yc,gravity:!1}}),this.inside={feedId:e,title:l.feedName,entered:c,ids:new Set(c.nodes.map(f=>f.id))},this.pane?.classList.add("universe-inside"),this.title_paint(),this.scene.camera_flyToFit([...this.inside.ids],da,()=>{this.flying=!1},1,.95)})})}ascend(){if(!this.flying){if(this.inside!==null){if(this.inside=null,this.facts_clear(),this.pane?.classList.remove("universe-inside"),this.cluster!==null){this.cluster_show(this.cluster.shape);return}}else{if(this.cluster===null)return;this.cluster=null,this.pane?.classList.remove("universe-cluster")}this.flying=!0,this.paint(!1),this.scene.camera_flyToFit([],OA,()=>{this.flying=!1})}}cluster_enter(e){this.flying||this.inside!==null||this.cluster_show(e)}cluster_show(e){if(this.view==="feeds"){const d=oA(e,this.landed);if(d.length===0)return;this.flying=!0,this.cluster={shape:e,ids:d},this.pane?.classList.add("universe-cluster");const h=lA(this.landed.all(),e,this.scale);this.scene.graph_set(h,{wave:!1,fit:!1,frozen:h.nodes.map(u=>u.id)}),this.title_paint(),this.scene.camera_flyToFit(d,da,()=>{this.flying=!1});return}const{graph:t,memberIds:s}=sp(this.landed.all(),e,this.scale);if(s.length===0)return;this.flying=!0,this.cluster={shape:e,ids:s},this.pane?.classList.add("universe-cluster");const i=this.scene.positions_get(),r=tp(e,this.landed),a=[0,0,0];let o=0;for(const d of r){const h=i[d];h!==void 0&&(a[0]+=h[0],a[1]+=h[1],a[2]+=h[2],o+=1)}o>0&&(a[0]/=o,a[1]/=o,a[2]/=o);const l=new Set(s);for(const d of t.nodes)(l.has(d.id)||d.ghost===!0)&&(i[d.id]=[a[0]+(Math.random()-.5)*.5,a[1]+(Math.random()-.5)*.5,a[2]+(Math.random()-.5)*.5]);this.scene.positions_seed(i);const c=t.nodes.filter(d=>!l.has(d.id)&&d.ghost!==!0).map(d=>d.id);this.scene.graph_set(t,{wave:!1,fit:!1,frozen:c,physics:{reach:yc,gravity:!1}}),this.title_paint(),this.scene.camera_flyToFit(s,da,()=>{this.flying=!1})}node_dive(e){const t=this.inside?.entered.payloads.get(e.id),s=this.handlers.node_dive;t===void 0||s===void 0||this.flying||this.scene.flight_into(e.id,()=>s(t.vfsPath))}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){if(this.inside===null)return!1;for(const[t,s]of this.inside.entered.payloads){if(s.instanceId!==e)continue;const i=this.handlers.node_dive;return i===void 0?!1:(this.scene.flight_into(t,()=>i(s.vfsPath)),!0)}return!1}node_select(e){if(this.flying)return;if(this.inside===null){const s=e.id.match(/^feed:(\d+):\d+$/),i=ep(e.id);s!==null?this.descend(Number(s[1]),e.id):i!==null?this.cluster_enter(i):e.id.startsWith("shape:")&&this.cluster_enter(e.id.slice(6));return}const t=this.inside.entered.payloads.get(e.id);t!==void 0&&this.facts_show(e,t)}facts_show(e,t){if(this.facts===null)return;this.facts.replaceChildren();const s=t.tally,i=[["PLUGIN",t.pluginName],[s?"REP. INSTANCE":"INSTANCE",String(t.instanceId)],["STATUS",t.status],...s?[["COUNT",`×${s.count} — ${s.done} done, ${s.error} err, ${s.running} live`]]:[],["DATA",t.vfsPath]];for(const[l,c]of i){const d=document.createElement("div");d.className="telemetry-row";const h=document.createElement("span");h.className="telemetry-label",h.textContent=l;const u=document.createElement("span");u.className="telemetry-value",u.textContent=c,d.append(h,u),this.facts.append(d)}const r=document.createElement("div");r.className="universe-node-verbs";const a=document.createElement("button");a.className="pacs-capsule universe-node-enter",a.textContent="ENTER NODE",a.title="fly into the node: its data, browsable inside (Esc flies out)",a.addEventListener("click",()=>{this.handlers.node_dive!==void 0?this.node_dive(e):this.handlers.node_enter?.(t.vfsPath)});const o=document.createElement("button");o.className="pacs-capsule universe-node-process",o.textContent="PROCESS",o.title="a catalogue bound to this node's data",o.addEventListener("click",()=>this.handlers.node_process?.({vfsPath:t.vfsPath,instanceId:t.instanceId,label:e.label})),r.append(a,o),this.facts.append(r),this.facts.hidden=!1}facts_clear(){this.facts!==null&&(this.facts.replaceChildren(),this.facts.hidden=!0)}title_paint(){if(this.entering!==null&&this.inside===null){const t=this.landed.get(this.entering);this.title.textContent=`UNIVERSE — ENTERING FEED ${this.entering}${t!==void 0&&t.title.length>0?` · ${t.title}`:""} …`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-wait"),this.state.textContent="ASKING");return}if(this.inside!==null){const t=this.inside.entered.nodes.reduce((s,i)=>s+(i.count??1),0);this.title.textContent=`UNIVERSE — INSIDE FEED ${this.inside.feedId} · ${this.inside.title} · ${t.toLocaleString("en-US")} JOBS`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-live"),this.state.textContent="INSIDE");return}if(this.cluster!==null){const t=this.landed.all().filter(s=>As(s)===this.cluster?.shape).length;this.title.textContent=`UNIVERSE — SHAPE ${sM(this.cluster.shape)} · ${t} FEED${t===1?"":"S"}`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-live"),this.state.textContent="CLUSTER");return}if(this.asking&&!this.shown){this.title.textContent="UNIVERSE — ASKING THE SESSION …",this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-wait"),this.state.textContent="ASKING");return}const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.whole?`UNIVERSE — ${e}`:`UNIVERSE — ${e}${this.warming.length>0?` · ${this.warming}`:" · INDEX WARMING"}`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add(this.whole?"state-settled":"state-wait"),this.state.textContent=this.whole?"WHOLE":"LANDING")}identity_note(e,t){const s=tA(e,t);if(s===this.storeKey)return;this.storeKey=s;const i=this.settings_recall();if(this.shown){const r=this.seed_recall();(i||r)&&this.inside===null&&this.cluster===null&&this.paint(!1)}}positionsKey_of(e){return this.storeKey===null?null:e==="galaxy"?this.storeKey:`${this.storeKey}.${e}`}positions_recalled(e){const t=this.positionsKey_of(e);if(!(this.store===void 0||t===null))try{const s=Jf(this.store.getItem(t));return Object.keys(s).length>0?s:void 0}catch{return}}seed_recall(){const e=this.positionsKey_of(this.arrangement);if(this.store===void 0||e===null)return!1;const t=Jf(this.store.getItem(e));return Object.keys(t).length===0?!1:(this.scene.positions_seed(t),!0)}remember_later(){this.rememberTimer===null&&(this.rememberTimer=window.setTimeout(()=>{this.rememberTimer=null,this.remember_now()},vA))}remember_now(){if(!(this.store===void 0||this.storeKey===null||!this.shown))try{const e=this.positionsKey_of(this.scene.arrangement_get());e!==null&&this.store.setItem(e,JSON.stringify(this.scene.positions_get()))}catch{}}}const ya=[];function SA(){const n=ya[ya.length-1];return n===void 0?!1:(n(),!0)}function AA(n){const e=n.querySelector(":scope > .pane-drawer");if(e!==null)return e.nextElementSibling;const t=n.querySelector(":scope > .lcars-terminal-header-bar");return t===null?n.firstElementChild:t.nextElementSibling}function vc(n,e){if(n.querySelector(":scope > .ask-bar")!==null)return Promise.resolve(null);const t=document.createElement("div");t.className="ask-bar";const s=document.createElement("span");s.className="ask-bar-glyph",s.textContent="?";const i=document.createElement("span");i.className="ask-bar-caption",i.textContent=e.message.trim(),t.append(s,i);const r=document.createElement("input"),a=document.createElement("button"),o=document.createElement("button"),l=document.createElement("button"),c=document.createElement("button");c.className="pacs-capsule ask-bar-abandon",c.textContent="ABANDON",c.title="abandon the question (Esc)",e.kind==="confirm"?(a.className="pacs-capsule ask-bar-yes",a.textContent="YES",o.className="pacs-capsule ask-bar-no",o.textContent="NO",t.append(a,o,c)):(r.className="ask-bar-field",r.spellcheck=!1,e.kind==="secret"?r.type="password":e.suggest!==void 0&&(r.value=e.suggest),l.className="pacs-capsule ask-bar-commit",l.textContent=e.commit??"ANSWER",t.append(r,l,c));const d=AA(n);return d===null?n.appendChild(t):n.insertBefore(t,d),window.requestAnimationFrame(()=>t.classList.add("ask-bar-shown")),new Promise(h=>{let u=!1;const p=m=>{if(u)return;u=!0;const f=ya.indexOf(M);f>=0&&ya.splice(f,1),t.remove(),h(m)},M=()=>p(null);ya.push(M);const _=()=>{const m=r.value.trim();p(m===""?null:m)};l.addEventListener("click",_),a.addEventListener("click",()=>p("y")),o.addEventListener("click",()=>p("n")),c.addEventListener("click",M),t.addEventListener("keydown",m=>{if(m.key==="Escape"){m.stopPropagation(),M();return}if(e.kind==="confirm"){m.key==="y"||m.key==="Y"?(m.stopPropagation(),p("y")):m.key==="n"||m.key==="N"||m.key==="Enter"&&m.target===o?(m.stopPropagation(),p("n")):m.key==="Enter"&&(m.stopPropagation(),p("y"));return}m.key==="Enter"&&(m.stopPropagation(),_())}),e.kind==="confirm"?a.focus():(r.focus(),r.select())})}const EA={"fs.listing":"files","feed.dag":"dag","feed.list":"dag","pacs.query":"pacs","dicom.series":"image","dicom.tags":"tags"};class DA{result;handlers;constructor(e,t){this.handlers=t,this.result=ua(e,".empty-result");const s=ua(e,".empty-prompt");s.addEventListener("keydown",i=>{i.key==="Enter"&&s.value.trim().length>0&&(this.line_run(s.value.trim()),s.value="")}),ua(e,".empty-go-files").addEventListener("click",()=>{this.line_run("ls .")}),ua(e,".empty-go-dag").addEventListener("click",()=>{this.line_run("proc feeds")}),ua(e,".empty-go-pacs").addEventListener("click",()=>{this.handlers.claim("pacs",[])}),window.setTimeout(()=>s.focus(),0)}async line_run(e){this.result.textContent="…";let t;try{t=await this.handlers.execute(e)}catch(i){this.result.textContent=i instanceof Error?i.message:String(i);return}for(const i of t.envelopes){const r=i.model?.kind!==void 0?EA[i.model.kind]:void 0;if(r!==void 0){this.handlers.claim(r,t.envelopes);return}}const s=t.envelopes.map(i=>i.rendered).join(`
4213
- `);this.result.textContent=IA(s)||"(no output)"}}function ua(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`empty pane template is missing ${e}`);return t}function IA(n){return n.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}class TA{container;title;handlers;currentAddress=null;constructor(e,t,s){this.container=e,this.title=t,this.handlers=s,this.awaiting_render()}regard_show(e){if(this.currentAddress=e.address,this.title.textContent=`VIEWER — ${e.address}`.toUpperCase(),this.handlers.path_isImage(e.address)){this.container.replaceChildren();const t=document.createElement("img");t.className="files-image",t.src=this.handlers.imageUrl_build(e.address),t.alt=e.address,this.container.appendChild(t);return}this.handlers.content_fetch(e.address).then(t=>{if(this.currentAddress!==e.address)return;if(this.container.replaceChildren(),t.trim().length===0){const i=document.createElement("p");i.className="files-empty",i.textContent=`NO PREVIEW — ${e.address.toUpperCase()}`,this.container.appendChild(i);return}const s=document.createElement("pre");s.className="files-content",s.textContent=t,this.container.appendChild(s)})}awaiting_render(){this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="NO REGARD — INDICATE A FILE OR NODE IN THIS PANE’S GROUP",this.container.appendChild(e)}}const GA="modulepreload",RA=function(n,e){return new URL(n,e).href},ap={},op=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){let c=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");i=c(t.map(d=>{if(d=RA(d,s),d in ap)return;ap[d]=!0;const h=d.endsWith(".css"),u=h?'[rel="stylesheet"]':"";if(s)for(let M=a.length-1;M>=0;M--){const _=a[M];if(_.href===d&&(!h||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":GA,h||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),h)return new Promise((M,_)=>{p.addEventListener("load",M),p.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},BA=[{label:"",tag:"PatientName"},{label:"MRN",tag:"PatientID"},{label:"ACC",tag:"AccessionNumber"},{label:"",tag:"StudyDescription"},{label:"",tag:"SeriesDescription"},{label:"",tag:"StudyDate"},{label:"",tag:"PatientAge"},{label:"",tag:"PatientSex"}],NA=256*1024*1024;function yo(n){const e=["B","KB","MB","GB","TB"];let t=n,s=0;for(;t>=1024&&s<e.length-1;)t/=1024,s++;return s===0?`${n} B`:`${t.toFixed(1)} ${e[s]}`}function CA(n){const e=n.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class PA{pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;presetPill;focusMark;guardBytes=NA;forced=!1;pendingLayout=null;progressNote=null;overlayNote=null;probeNote=null;overlay=!1;overlayLines=[];presetIndex=-1;toolPills=new Map;handlers;engine=null;series=null;siblings=[];colormap="gray";tool="wl";constructor(e,t){this.handlers=t,this.pane=e,this.field=Qs(e,".image-field"),this.title=Qs(e,".pane-title"),this.modeSpan=Qs(e,".pane-mode"),this.stateSpan=Qs(e,".pane-state");for(const s of e.querySelectorAll(".image-layout")){const i=s.dataset.layout??"single";this.layoutPills.set(i,s),s.addEventListener("click",()=>{this.layout_set(i)})}this.overlayPill=Qs(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=Qs(e,".image-colormap"),this.savePill=Qs(e,".image-save"),this.loadPill=Qs(e,".image-load"),this.presetPill=Qs(e,".image-preset"),this.focusMark=Qs(e,".image-focus"),this.field.tabIndex=0,this.colormapPill.addEventListener("click",()=>{this.colormap_cycle()}),this.savePill.addEventListener("click",()=>{this.annotations_save()}),this.loadPill.addEventListener("click",()=>{this.load_press()}),this.presetPill.addEventListener("click",()=>this.preset_cycle()),Qs(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const s of Af){const i=Qs(e,`.image-tool[data-tool="${s}"]`);this.toolPills.set(s,i),i.addEventListener("click",()=>{this.tool_set(s)})}this.toolPills_paint(),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",s=>{(!(s.relatedTarget instanceof Node)||!this.field.contains(s.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",s=>{if(s.key==="Escape"){this.field_release(),s.stopPropagation();return}s.stopPropagation()})}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}async series_show(e,t={}){if(this.engine_dispose(),this.series=e,this.forced=t.force===!0,this.pendingLayout=null,this.loadPill.hidden=!0,this.presets_paint(e.modality),this.siblings=t.siblings??[],this.pane.dataset.modality=CA(e.modality),this.title.textContent=`IMAGE ${e.modality.toUpperCase()} ${e.seriesDescription}`.trim(),this.title.title=this.title.textContent,this.siblings.length>1){const r=this.siblings.findIndex(a=>a.path===e.path)+1;this.handlers.note(`image: series ${r} of ${this.siblings.length} in this study; image series <n> switches`)}const{CornerstoneEngine:s}=await op(async()=>{const{CornerstoneEngine:r}=await import("./cornerstoneEngine-CQxasfu7.js").then(a=>a.b2);return{CornerstoneEngine:r}},__vite__mapDeps([0,1]),import.meta.url),i=new s(this.engineHost_get(),e,t.startAt??1);await this.engine_open(i),this.engine===i&&(this.guard_trips()?(this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${yo(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${yo(e.bytes)} to fetch before the stack scrolls; press LOAD, image load, or image --force <path>`)):i.slices_fill(),await this.annotations_reload(i,e))}async annotations_reload(e,t){let s=0;for(const i of t.annotations.filter(r=>/\.dcm$/i.test(r))){if(this.engine!==e)return;const r=i.split("/").pop()??i;try{const a=await fetch(this.handlers.source.url_of(i));if(!a.ok){this.handlers.note(`image: ${r}: HTTP ${a.status}`);continue}const o=await e.annotations_import(await a.arrayBuffer());s+=o,this.handlers.note(o>0?`image: ${o} measurement${o===1?"":"s"} from ${r}`:`image: ${r}: no measurements this engine can place`)}catch(a){this.handlers.note(`image: ${r}: ${a instanceof Error?a.message:String(a)}`)}}this.pane.dataset.annotations=String(s)}async volume_show(e){this.engine_dispose(),this.series=null,this.siblings=[],this.pane.dataset.modality="NIFTI",this.title.textContent=`IMAGE ${e.split("/").pop()??""}`,this.title.title=e,this.forced=!0,this.loadPill.hidden=!0,this.presets_paint("NIFTI");const{NiivueEngine:t}=await op(async()=>{const{NiivueEngine:s}=await import("./niivueEngine-DWd0hO7h.js");return{NiivueEngine:s}},[],import.meta.url);await this.engine_open(new t(this.engineHost_get(),e))}opening_show(e){const t=e.replace(/\/$/,"").split("/").pop()??e;this.stateSpan.textContent="OPENING",this.progress_show({label:`OPENING ${t}`,done:0,total:0})}opening_fail(e,t){this.stateSpan.textContent=t,this.progress_show({label:t,done:0,total:0});const s=this.progressNote;s!==null&&(s.classList.add("image-working-failed"),s.querySelector(".image-working-count").textContent=e)}siblings_get(){return this.siblings}series_get(){return this.series}state_get(){return this.engine===null?null:{...this.engine.state_get(),colormap:this.colormap,path:this.series?.path??null,guard:this.guardBytes,waiting:this.pendingLayout}}async layout_set(e){if(this.engine===null)return!1;if(e!=="single"&&this.guard_trips())return this.pendingLayout=e,this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${yo(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${yo(this.series?.bytes??0)} to fetch for ${e}; press LOAD, image load, or image --force <path>`),!1;const t=this.engine.state_get().layout;return this.layoutPills_paint(e),this.modeSpan.textContent=e==="single"?"":e.toUpperCase(),this.overlay_hide(),await this.engine.layout_set(e)?(this.progress_show(null),this.overlay_paint(),this.toolPills_paint(),!0):(this.progress_show(null),this.layoutPills_paint(t),this.modeSpan.textContent=t==="single"?"":t.toUpperCase(),this.handlers.note(`image: layout ${e}: not offered by ${this.engine.name}`),!1)}layoutPills_paint(e){for(const[t,s]of this.layoutPills)s.classList.toggle("rail-off",t!==e)}guard_trips(){return this.guardBytes!==null&&!this.forced&&this.engine?.name==="cornerstone"&&(this.series?.bytes??0)>this.guardBytes}async load_press(){this.forced=!0,this.loadPill.hidden=!0;const e=this.pendingLayout;return this.pendingLayout=null,e!==null?this.layout_set(e):this.engine===null||this.engine.state_get().filled?!1:this.engine.slices_fill()}guard_set(e){this.guardBytes=e}guard_get(){return this.guardBytes}preset_cycle(){const e=this.presets_for(this.series?.modality??"NIFTI");if(e.length===0)return;this.presetIndex=(this.presetIndex+1)%e.length;const t=e[this.presetIndex];t!==void 0&&this.wl_set(t.lower,t.upper)&&(this.presetPill.textContent=t.name.toUpperCase())}presets_for(e){const t=e.toUpperCase();return km.filter(s=>s.modalities.length===0||s.modalities.includes(t))}presets_paint(e){this.presetIndex=-1;const t=this.presets_for(e);this.presetPill.hidden=t.length===0,this.presetPill.textContent="PRESET"}slice_set(e){if(this.engine===null)return!1;const t=this.engine.slice_set(e);return t||this.handlers.note(`image: slice ${e}: not offered in ${this.engine.state_get().layout} layout by ${this.engine.name}`),t}wl_set(e,t){if(this.engine===null)return!1;const s=this.engine.wl_set(e,t);return s||this.handlers.note(`image: wl: not offered by ${this.engine.name}`),s}ghost_set(e){if(this.engine===null)return!1;const t=this.engine.ghost_set(e);return t||this.handlers.note("image: ghost applies to the SLAB layout"),t}wlPreset_set(e){const t=this.series?.modality??"NIFTI",s=gS(e,t);return s===void 0?(this.handlers.note(`image: wl preset ${e}: none for ${t}`),!1):this.wl_set(s.lower,s.upper)}colormap_set(e){return this.engine===null?!1:this.engine.colormap_set(e)?(this.colormap=e,this.colormapPill.textContent=e.toUpperCase(),!0):(this.handlers.note(`image: colormap ${e}: not offered by ${this.engine.name}`),!1)}tool_set(e){return this.engine===null?!1:this.engine.tool_set(e)?(this.tool=e,this.toolPills_paint(),!0):(this.handlers.note(`image: ${e}: not offered by ${this.engine.name}`),!1)}async annotations_save(){if(this.engine===null)return!1;const e=this.series?.seriesInstanceUID,t=/^(\/home\/[^/]+)\//.exec(this.series?.path??"")?.[1];if(e===void 0||t===void 0)return this.handlers.note("image: save: this series has no UID to file an annotation under"),!1;const s=await this.engine.annotations_export();if(s===null)return this.handlers.note(`image: save: nothing measured, or ${this.engine.name} writes no report`),!1;const i=`${t}/annotations/${e}/measurements.dcm`,r=await this.handlers.file_put(i,s);return this.handlers.note(r===200?`✓ ${i}`:`image: save: ${i}: HTTP ${r}`),r===200}dispose(){this.engine_dispose()}async colormap_cycle(){const e=Co[(Co.indexOf(this.colormap)+1)%Co.length]??"gray";this.colormap_set(e)}async engine_open(e){this.engine=e,this.field.replaceChildren(),this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.layoutPills_paint("single"),this.modeSpan.textContent="",this.colormapPill.textContent=this.colormap.toUpperCase();try{await e.open(this.field)}catch(s){this.stateSpan.textContent="REFUSED",this.handlers.note(`image: ${s instanceof Error?s.message:String(s)}`);return}const t=e.state_get().layout;this.layoutPills_paint(t),this.modeSpan.textContent=t==="single"?"":t.toUpperCase(),e.tool_set(this.tool),this.toolPills_paint(),this.progress_show(null),this.overlay_fill()}engine_dispose(){this.engine?.dispose(),this.engine=null,this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.field.replaceChildren(),this.stateSpan.textContent=""}engineHost_get(){return{source:this.handlers.source,readout_set:e=>{this.stateSpan.textContent=e},progress_set:e=>this.progress_show(e),note:this.handlers.note,regard:e=>{this.handlers.regard(e),this.overlaySlice_paint()},probe_set:e=>this.probe_show(e)}}probe_show(e){if(e===null){this.probeNote?.remove(),this.probeNote=null;return}if(this.probeNote===null||this.probeNote.parentElement===null){const t=document.createElement("div");t.className="image-probe-note",this.field.appendChild(t),this.probeNote=t}this.probeNote.textContent=e}overlaySlice_paint(){const e=this.overlayNote?.querySelector(".image-overlay-slice")??null;if(e===null||this.engine===null)return;const t=this.engine.state_get();e.textContent=t.slices>1?`SLICE ${Math.max(1,t.slice)} OF ${t.slices}`:"",e.hidden=t.slices<=1}progress_show(e){if(e===null){this.progressNote?.remove(),this.progressNote=null;return}if(this.progressNote===null||this.progressNote.parentElement===null){const a=document.createElement("div");a.className="image-working",a.innerHTML='<span class="image-working-label"></span><span class="image-working-track"><span class="image-working-fill"></span></span><span class="image-working-count"></span>',this.field.appendChild(a),this.progressNote=a}const t=this.progressNote;t.classList.remove("image-working-failed");const s=e.total>0,i=s?Math.min(1,e.done/e.total):0;t.querySelector(".image-working-label").textContent=e.label,t.querySelector(".image-working-count").textContent=s?`${e.done} / ${e.total} · ${Math.round(i*100)}%`:"";const r=t.querySelector(".image-working-fill");r.classList.toggle("image-working-pacing",!s),r.style.width=s?`${Math.round(i*100)}%`:""}async overlay_set(e){if(this.overlay=e,this.overlayPill.textContent=e?"OVERLAY ON":"OVERLAY OFF",this.overlayPill.classList.toggle("rail-off",!e),!e){this.overlay_hide();return}await this.overlay_fill()}overlay_hide(){this.overlayNote?.remove(),this.overlayNote=null}async overlay_fill(){if(!this.overlay||this.series===null)return;const e=this.series.files[0]??this.series.path,t=await this.handlers.tags_read(e);if(t===null){this.handlers.note(`image: overlay: ${e}: no header to read`);return}this.overlayLines=BA.flatMap(s=>{const r=(t.constant.find(a=>a.name===s.tag)?.value??"").trim();return r===""?[]:[s.label===""?r:`${s.label} ${r}`]}),this.overlay_paint()}overlay_paint(){if(!this.overlay||this.overlayLines.length===0)return;this.overlay_hide();const e=document.createElement("div");e.className="image-overlay-note";const t=document.createElement("span");t.className="image-overlay-slice",e.appendChild(t);for(const s of this.overlayLines){const i=document.createElement("span");i.textContent=s,e.appendChild(i)}this.field.appendChild(e),this.overlayNote=e,this.overlaySlice_paint()}toolPills_paint(){const e=new Set(this.engine?.toolsOffered_get()??Af),t=this.engine!==null?this.engine.state_get().primaryTool:this.tool;for(const[s,i]of this.toolPills){const r=e.has(s);i.classList.toggle("rail-na",!r),i.classList.toggle("rail-off",r&&s!==t),i.disabled=!r}}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("image-field-focused",e)}}function Qs(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`image pane: missing ${e}`);return t}const aM=["patient","study","series","image","equipment","meta","private","other","varying"],WA=new Set(["meta","private"]),lp="••••";class LA{pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,t){this.handlers=t,this.pane=e,this.title=vo(e,".pane-title"),this.modeSpan=vo(e,".pane-mode"),this.redactBlock=vo(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const s=vo(e,".tags-panel");this.listing=new Ur({mount:s,traits:this.groupTraits_declare(),key:i=>i.group,chrome:{root:e,prefix:"tags"},caps:"root",row:{className:()=>"tags-group-row",groupClassName:i=>`tags-group tags-group-${i.group}`,decorate:i=>{i.title="fold this group open or shut (it keeps its place)"}},child:Rr(i=>i.rows,{traits:this.tagTraits_declare(),key:i=>i.key,activatable:i=>i.items.length>0,row:{className:i=>`tags-row${i.phi?" tags-phi":""}`,groupClassName:()=>"tags-sequence",decorate:(i,r)=>{i.title=r.items.length>0?`${r.name}: fold the sequence open or shut`:`${r.tag} ${r.name}`}},child:Rr(i=>i.items,{traits:this.itemTraits_declare(),key:i=>i.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:Rr(i=>i.rows,{traits:this.tagTraits_declare(),key:i=>i.key,activatable:()=>!1,row:{className:i=>`tags-row tags-row-deep${i.phi?" tags-phi":""}`}})})}),state:i=>this.stateLine_compose(i),empty:()=>jA("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${UA(e)}`,this.pane.dataset.modality=FA(e),this.groups=kA(e),this.listing.rows_set([{key:e.path,rows:this.groups}],{field:e.path}),this.listing.open_set(0,this.groups.map(t=>t.group).filter(t=>!WA.has(t))),this.modeSpan.textContent=e.subject==="folder"?"FOLDER":""}path_get(){return this.model?.path??null}redact_get(){return this.redact}redact_set(e){this.redact=e,this.redactBlock_paint(),this.model!==null&&this.listing.rows_set([{key:this.model.path,rows:this.groups}],{field:this.model.path})}filter_set(e){if(e===null){this.listing.filter_toggle(!1);return}this.listing.filter_toggle(!0),this.listing.filter_set(e)}stateLine_compose(e){const t=this.groups.reduce((i,r)=>i+r.rows.length,0),s=[];return this.model!==null&&this.model.subject==="folder"&&(s.push(this.model.read===this.model.of?`${this.model.read} FILES`:`${this.model.read} OF ${this.model.of} FILES`),this.model.refused.length>0&&s.push(`REFUSED ${this.model.refused.length}`)),s.push(e.filter!==""?e.filter:`${t} TAGS`),this.redact&&s.push("REDACTED"),s.join(" · ")}redactBlock_paint(){this.redactBlock.textContent=this.redact?"REDACT ON":"REDACT OFF",this.redactBlock.classList.toggle("rail-off",!this.redact),this.pane.classList.toggle("tags-redacted",this.redact)}value_cell(e){const t=document.createElement("span");if(t.className="tags-value",e.phi&&this.redact)return t.textContent=lp,t.title="identifying value, redacted; the REDACT block on the frame reveals it",t;if(t.textContent=e.value,e.decoded!==void 0){const s=document.createElement("span");s.className="tags-decoded",s.textContent=` ${e.decoded}`,t.appendChild(s)}if(e.distinct!==void 0){const s=document.createElement("span");s.className="tags-decoded",s.textContent=` (${e.distinct} distinct)`,t.appendChild(s)}return t}groupTraits_declare(){return[Oc(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>aM.indexOf(e.group)},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}tagTraits_declare(){return[Oc(e=>e.items.length>0),{key:"tag",label:"TAG",className:"tags-tag",width:"7em",cell:e=>e.tag,compare:e=>e.tag},{key:"name",label:"NAME",className:"tags-name",width:"minmax(8em, 1.4fr)",cell:e=>e.name,compare:e=>e.name.toLowerCase()},{key:"vr",label:"VR",className:"tags-vr",width:"2.4em",cell:e=>e.vr,compare:e=>e.vr},{key:"value",label:"VALUE",className:"tags-value-cell",width:"minmax(6em, 2fr)",cell:e=>this.value_cell(e),compare:e=>(e.phi&&this.redact?lp:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[Oc(()=>!0),{key:"item",label:"ITEM",className:"tags-item-name",width:"minmax(12em, 1fr)",cell:e=>`ITEM ${e.index}`,compare:e=>e.index},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}}function Oc(n){return{key:"fold",label:"",className:"tags-fold",capped:!1,width:"1.4em",cell:e=>{const t=document.createElement("span");return t.className=n(e)?"tags-fold":"tags-fold tags-fold-none",t}}}function kA(n){const e=new Map;for(const t of n.constant){const s=t.group;e.has(s)||e.set(s,[]),e.get(s)?.push(oM(t,`${s}/${t.tag}`))}return n.varying.length>0&&e.set("varying",n.varying.map(t=>({tag:t.tag,name:t.name,vr:t.vr,value:t.distinct===1?t.first:`${t.first} .. ${t.last}`,phi:t.phi,items:[],distinct:t.distinct,key:`varying/${t.tag}`}))),aM.filter(t=>e.has(t)).map(t=>({group:t,rows:e.get(t)??[]}))}function oM(n,e){return{tag:n.tag,name:n.name,vr:n.vr,value:n.value,...n.decoded!==void 0?{decoded:n.decoded}:{},phi:n.phi,items:(n.items??[]).map((t,s)=>({index:s+1,key:`${e}/${s+1}`,rows:t.map(i=>oM(i,`${e}/${s+1}/${i.tag}`))})),key:e}}function UA(n){const e=n.path.replace(/\/$/,"").split("/").pop()??n.path;if(n.subject==="folder")return e.length>24?`${e.slice(0,22)}…`:e;const t=/^(\d+)-/.exec(e)?.[1];return t!==void 0?`INSTANCE ${Number(t)}`:e.length>24?`${e.slice(0,22)}…`:e}function FA(n){const e=(n.constant.find(t=>t.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function jA(n){const e=document.createElement("div");return e.className="tags-note",e.textContent=n,e}function vo(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`tags pane: missing ${e}`);return t}class VA{groups=new Map;membership=new Map;writeObserver=null;writeObserver_set(e){this.writeObserver=e}pane_join(e,t){this.pane_leave(e),this.membership.set(e,t),this.groups.has(t)||this.groups.set(t,{value:null,subscribers:new Map,viewers:new Set})}pane_leave(e){const t=this.membership.get(e);if(t===void 0)return;this.membership.delete(e);const s=this.groups.get(t);if(s!==void 0){s.subscribers.delete(e),s.viewers.delete(e);for(const i of this.membership.values())if(i===t)return;this.groups.delete(t)}}group_of(e){const t=this.membership.get(e);return t!==void 0?t:(this.pane_join(e,e),e)}viewer_mark(e){this.groups.get(this.group_of(e))?.viewers.add(e)}groupHasViewer(e){const t=this.groups.get(this.group_of(e));return t!==void 0&&t.viewers.size>0}regard_write(e,t){const s=this.group_of(e),i=this.groups.get(s),r={...t,paneId:e};i.value=r;for(const a of i.subscribers.values())a(r);this.writeObserver?.(r,s)}regard_subscribe(e,t){const s=this.groups.get(this.group_of(e));s.subscribers.set(e,t),s.value!==null&&t(s.value)}regard_get(e){return this.groups.get(this.group_of(e))?.value??null}}const xc=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],$A=new Set(["done","error","unconfirmed","stalled","timeout"]);function HA(n,e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const s=`${e.operation}:`;for(const i of[...n])(i===t||i.startsWith(s))&&n.delete(i);return}if(e.itemId!==void 0&&e.status!==void 0&&$A.has(e.status)){n.delete(t);return}n.add(t)}const qA=100;class XA{fields;running=new Set;activityTimer=null;activityFrame=0;constructor(e){this.fields={identity:Bi(e,"status-identity"),jobs:Bi(e,"status-jobs"),activity:Bi(e,"status-activity"),latency:Bi(e,"status-latency"),mismatch:Bi(e,"status-mismatch"),lamp:Bi(e,"status-lamp"),host:Bi(e,"status-host")}}attach_show(e){if(e.protocolVersion!==Ec){this.fields.mismatch.textContent=`WIRE V${e.protocolVersion} ≠ V${Ec}`,this.fields.mismatch.title="This surface and the daemon speak different contract versions. Some messages may be dropped.",this.hostControl_show(e.hostControl??[]);return}this.fields.mismatch.textContent="",this.fields.mismatch.title=e.stack!==void 0?`chell ${e.stack.chell} · calypso ${e.stack.calypso} · build ${e.stack.build}`:"",this.hostControl_show(e.hostControl??[])}hostControl_show(e){this.fields.host.textContent=e.length>0?`HOST ${e.join(" ")}`:"",this.fields.host.title=e.length>0?"Calypso was started with --host-control: `!` and pipes run on its host, upload/download reach its disk.":""}promptContext_show(e){const t=e.uri.replace(/^https?:\/\//,"");this.fields.identity.textContent=`${e.user}@${t}`.toUpperCase();const s=e.procWarmup,i=[];if(s!==void 0&&s.sweeping!==!1){const o=s.total!==void 0?`/${s.total}`:"",l=s.state!==void 0?` ${s.state.toUpperCase()}`:"";i.push(`JOBS ${s.loaded}${o}${l}`)}const r=s?.feeds??(s?.feed!==void 0?[s.feed]:[]);for(const o of r){const l=o.total>0?`/${o.total}`:"";i.push(o.failed!==void 0?`FEED ${o.id} FAILED ${o.loaded}${l}`:`FEED ${o.id} ${o.loaded}${l}`)}s?.roster!==void 0&&i.push(s.roster==="full"?"ROSTER WALK":"ROSTER DELTA"),s?.arrived!==void 0&&s.arrived.length>0&&i.push(s.arrived.length<=2?`+FEED ${s.arrived.join(" ")}`:`+${s.arrived.length} FEEDS`);const a=e.warmupFailures??[];a.length>0&&i.push(`WARM-UP FAILED: ${a.map(o=>o.label.toUpperCase()).join(" ")}`),this.fields.jobs.textContent=i.join(" · "),this.fields.jobs.classList.toggle("status-degraded",a.length>0),this.fields.jobs.title=a.length>0?a.map(o=>`${o.label}: ${o.message}`).join(`
4214
- `):r.length>0?"A feed is being indexed on its first visit; it opens when the walk completes.":"",this.fields.latency.textContent=e.lastCommandDurationMs>0?`${e.lastCommandDurationMs}MS`:""}progress_observe(e){HA(this.running,e),this.activity_paint()}activity_clear(){this.running.clear(),this.activity_paint()}connection_show(e){this.fields.lamp.textContent=e?"ONLINE":"OFFLINE",this.fields.lamp.classList.toggle("lamp-online",e),this.fields.lamp.classList.toggle("lamp-offline",!e),e||this.activity_clear()}activity_paint(){if(this.running.size===0){this.activityTimer!==null&&(clearInterval(this.activityTimer),this.activityTimer=null),this.fields.activity.textContent="";return}const e=()=>{const t=xc[this.activityFrame]??xc[0];this.fields.activity.textContent=`${t} ${this.running.size} RUNNING`};e(),this.activityTimer===null&&(this.activityTimer=window.setInterval(()=>{this.activityFrame=(this.activityFrame+1)%xc.length,e()},qA))}}function Bi(n,e){const t=n.getElementById(e);if(t===null)throw new Error(`status bar: no element with id '${e}'`);return t}function YA(n){return n>=6e4?`${Math.max(1,Math.round(n/6e4))} MIN`:`${Math.max(1,Math.round(n/1e3))} S`}function Js(n){return n.toLocaleString("en-US")}class KA{mount;counts=null;context=null;msPerPage=null;walkSamples=new Map;clock;acts;state=void 0;constructor(e,t=()=>Date.now(),s={}){this.mount=e,this.clock=t,this.acts=s,this.render()}state_show(e){this.state=e,this.render()}pace_show(e){this.msPerPage=e,this.render()}eta_of(e,t,s){const i=this.clock(),r=this.walkSamples.get(e);let a=r?.rowsPerMs??null;r!==void 0&&t>r.loaded&&i>r.at&&(a=(t-r.loaded)/(i-r.at)),(r===void 0||t!==r.loaded)&&this.walkSamples.set(e,{loaded:t,at:i,rowsPerMs:a});const o=Math.max(0,s-t);return s<=0?null:a!==null&&a>0?o/a:this.msPerPage!==null&&this.msPerPage>0?Math.ceil(o/100/4)*this.msPerPage:null}counts_show(e){this.counts=e,this.render()}promptContext_show(e){this.context=e,e.procIndex!==void 0&&(this.counts={jobs:e.procIndex.jobs,feeds:e.procIndex.feeds}),this.render()}rows_compose(){const e=[],t=this.context?.procWarmup,s=this.context?.warmupFailures??[],i=t!==void 0&&t.sweeping!==!1,r=this.counts!==null?`${Js(this.counts.jobs)} JOBS · ${Js(this.counts.feeds)} FEEDS`:"";if(s.length>0)e.push({label:"INDEX",bar:null,value:`${r}${r?" · ":""}FAILED: ${s.map(l=>l.label.toUpperCase()).join(" ")}`,title:s.map(l=>`${l.label}: ${l.message}`).join(`
4215
- `),degraded:!0});else if(i&&t!==void 0){const l=(t.state??"cold").toUpperCase();e.push({label:"INDEX",bar:{loaded:t.loaded,total:t.total??0,state:t.state==="failed"?"failed":"running"},value:`SWEEP ${Js(t.loaded)} / ${t.total!==void 0?Js(t.total):"?"} · ${l}`,title:"The global topology sweep: every plugin instance CUBE holds, walked page by page.",degraded:t.state==="failed"})}else e.push({label:"INDEX",bar:null,value:r?`${r} · CURRENT`:"CURRENT",title:"Nothing is moving: the process index is whole and current.",degraded:!1});if(this.state!==void 0){const l=this.state;e.push({label:"RUNNING",bar:null,value:`${Js(l.running)} IN ${Js(l.runningFeeds)} FEEDS · SCHEDULED ${Js(l.scheduled)}`,title:"Jobs running and waiting across every feed the index holds, from the roster's own counters.",degraded:!1,verb:this.acts.errored_open!==void 0?{label:`ERRORED ${Js(l.errored)} IN ${Js(l.erroredFeeds)} FEEDS`,title:"Open the runs roster filtered to the feeds with errored jobs.",act:this.acts.errored_open}:null})}const a=t?.feeds??(t?.feed!==void 0?[t.feed]:[]);for(const l of Array.from(this.walkSamples.keys()))a.some(c=>c.id===l)||this.walkSamples.delete(l);for(const l of a){const c=l.total>0?Js(l.total):"?";if(l.failed!==void 0)e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"failed"},value:`FAILED AT ${Js(l.loaded)} / ${c} · ${l.failed.toUpperCase()}`,title:"The walk stopped; the next visit to the feed starts it again.",degraded:!0});else{const d=this.eta_of(l.id,l.loaded,l.total);e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"running"},value:`INDEXING ${Js(l.loaded)} / ${c}${d!==null?` · ETA ${YA(d)}`:""}`,title:"A feed is being indexed on its first visit; it opens when the walk lands.",degraded:!1})}}t?.roster!==void 0&&e.push({label:"ROSTER",bar:null,value:t.roster==="full"?"FULL WALK · every feed the identity can see":"DELTA · feeds newer than the roster knows",title:"The roster is being brought up to date; the listing answered from the cache and refreshes when arrivals land.",degraded:!1});const o=t?.arrived??[];return o.length>0&&e.push({label:"ARRIVED",bar:null,value:o.length<=3?o.map(l=>`FEED ${l}`).join(" · "):`${o.length} FEEDS`,title:"Feeds the roster gained: created here, or shared with this identity.",degraded:!1}),e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const t of e){const s=document.createElement("div");s.className="index-row telemetry-row",s.classList.toggle("status-degraded",t.degraded),s.title=t.title;const i=document.createElement("span");if(i.className="telemetry-label",i.textContent=t.label,s.appendChild(i),t.bar!==null){const a=document.createElement("span");a.className=`index-bar listing-progress listing-progress-${t.bar.state}`;const o=document.createElement("span");o.className="listing-progress-fill";const l=t.bar.total>0?Math.min(100,Math.round(t.bar.loaded/t.bar.total*100)):0;o.style.width=`${l}%`,a.appendChild(o),s.appendChild(a)}const r=document.createElement("span");if(r.className="telemetry-value",r.textContent=t.value,s.appendChild(r),t.verb!==void 0&&t.verb!==null){const a=document.createElement("button");a.type="button",a.className="index-verb pacs-capsule",a.textContent=t.verb.label,a.title=t.verb.title,a.addEventListener("click",t.verb.act),s.appendChild(a)}this.mount.appendChild(s)}}}const ZA=3e3;class QA{mount;clock;lane=void 0;cube=void 0;beatAt=null;constructor(e,t=()=>Date.now()){this.mount=e,this.clock=t,this.render()}telemetry_show(e={}){this.beatAt=this.clock(),e.lane!==void 0&&(this.lane=e.lane),e.cube!==void 0&&(this.cube=e.cube),this.render()}tick(){this.render()}rows_compose(){const e=[],t=this.lane;if(t===void 0)e.push({label:"LANE",value:"—",title:"The daemon has not said what holds its lane (an older daemon).",degraded:!1});else if(t.running===null)e.push({label:"LANE",value:t.waiting>0?`IDLE · ${t.waiting} WAITING`:"IDLE",title:"The serialized command lane: nothing is executing.",degraded:!1});else{const i=(t.running.sinceMs/1e3).toFixed(1);e.push({label:"LANE",value:`${t.running.line} · ${i} S${t.waiting>0?` · ${t.waiting} WAITING`:""}`,title:`The command holding the lane${t.running.surface?`, from surface ${t.running.surface}`:""}; every other command waits behind it.`,degraded:t.running.sinceMs>=1e4})}if(this.beatAt===null)e.push({label:"BEAT",value:"NONE YET",title:"No telemetry heartbeat has landed.",degraded:!1});else{const i=Math.max(0,this.clock()-this.beatAt);e.push({label:"BEAT",value:`${(i/1e3).toFixed(1)} S AGO`,title:"The age of the last telemetry heartbeat; the daemon beats once a second while a surface is attached.",degraded:i>=ZA})}const s=this.cube;if(s===void 0)e.push({label:"CUBE",value:"NO PAGE TIMED",title:"CUBE's pace is known once a page of a list has been fetched.",degraded:!1});else{const i=s.msPerPage>0?Math.round(6e4/s.msPerPage):0;e.push({label:"CUBE",value:`${(s.msPerPage/1e3).toFixed(1)} S/PAGE · ${i} PAGES/MIN`,title:`The median of the last ${s.samples} page fetches (100 rows each).`,degraded:!1})}return e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const t of e){const s=document.createElement("div");s.className="lane-row telemetry-row",s.classList.toggle("status-degraded",t.degraded),s.title=t.title;const i=document.createElement("span");i.className="telemetry-label",i.textContent=t.label;const r=document.createElement("span");r.className="telemetry-value",r.textContent=t.value,s.append(i,r),this.mount.appendChild(s)}}}const JA=[2,3,3,2,2,11,2,2],eE=4,cp=300,tE=2600,sE=650;class nE{wrapper;cells=[];bootedAt=Date.now();telemetry={jobsLoaded:0,jobsTotal:0,feeds:0,lastLatencyMs:0,latencySumMs:0,lastExitCode:0,commandsRun:0,opsActive:0,opsDone:0,opsFailed:0,itemsCurrent:0,itemsTotal:0,connected:0};activeOperations=new Set;telemetryRows=[];constructor(e){if(this.wrapper=e,e===null){window.setInterval(()=>this.beat_paint(),cp);return}const t=this.narrowSources_list(),s=this.wideSources_list();let i=0,r=0;for(const a of JA){const o=document.createElement("div");o.className="data-column";for(let l=1;l<=eE;l++){const c=document.createElement("div");c.className=`dc-row-${l}`;let d;a>=6?(d=s[r%s.length],r++):(d=t[i%t.length],i++);const h={element:c,width:a,source:d??(()=>0)};c.textContent=dp(h.source(),a),o.appendChild(c),this.cells.push(h)}e.appendChild(o)}window.setInterval(()=>this.beat_paint(),cp),this.sweep_start()}promptContext_observe(e){const t=e.procWarmup;t!==void 0&&(this.telemetry.jobsLoaded=t.loaded,this.telemetry.jobsTotal=t.total??t.loaded);const s=e.procIndex;s!==void 0&&(t===void 0&&(this.telemetry.jobsLoaded=s.jobs,this.telemetry.jobsTotal=s.jobs),this.telemetry.feeds=s.feeds),e.lastCommandDurationMs>0&&(this.telemetry.lastLatencyMs=e.lastCommandDurationMs,this.telemetry.latencySumMs+=e.lastCommandDurationMs,this.telemetry.commandsRun++),this.telemetry.lastExitCode=e.lastExitCode}progress_observe(e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const s=`${e.operation}:`;for(const i of[...this.activeOperations])(i===t||i.startsWith(s))&&this.activeOperations.delete(i);e.status==="error"||e.phase==="failed"?this.telemetry.opsFailed++:this.telemetry.opsDone++}else e.itemId!==void 0&&e.status!==void 0&&["done","error","unconfirmed","stalled","timeout"].includes(e.status)?this.activeOperations.delete(t):this.activeOperations.add(t);this.telemetry.opsActive=this.activeOperations.size,e.current!==void 0&&(this.telemetry.itemsCurrent=e.current),e.total!==void 0&&(this.telemetry.itemsTotal=e.total)}index_observe(e){this.telemetry.jobsLoaded=e.jobs,this.telemetry.jobsTotal=e.jobs,this.telemetry.feeds=e.feeds}connection_show(e){this.telemetry.connected=e?1:0,this.wrapper?.classList.toggle("dc-stale",!e)}telemetryPanel_bind(e){const t=this.telemetry,s=[["LINK",()=>t.connected===1?"ONLINE":"OFFLINE"],["JOBS INDEXED",()=>`${t.jobsLoaded} / ${t.jobsTotal}`],["FEEDS VISIBLE",()=>String(t.feeds)],["OPS ACTIVE",()=>String(t.opsActive)],["OPS DONE",()=>String(t.opsDone)],["OPS FAILED",()=>String(t.opsFailed)],["ITEMS",()=>`${t.itemsCurrent} / ${t.itemsTotal}`],["LAST COMMAND",()=>`${t.lastLatencyMs} MS`],["LATENCY SUM",()=>`${t.latencySumMs} MS`],["COMMANDS RUN",()=>String(t.commandsRun)],["LAST EXIT",()=>String(t.lastExitCode)],["UPTIME",()=>`${this.uptimeSeconds_get()} S`]];for(const[i,r]of s){const a=document.createElement("div");a.className="telemetry-row";const o=document.createElement("span");o.className="telemetry-label",o.textContent=i;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r(),a.append(o,l),e.appendChild(a),this.telemetryRows.push({element:l,source:r})}}narrowSources_list(){const e=this.telemetry;return[()=>e.jobsLoaded,()=>e.feeds,()=>e.lastLatencyMs,()=>e.opsActive,()=>e.opsDone,()=>e.jobsTotal,()=>e.itemsCurrent,()=>e.itemsTotal,()=>e.opsFailed,()=>e.commandsRun,()=>e.lastExitCode,()=>new Date().getSeconds(),()=>this.uptimeSeconds_get()]}wideSources_list(){return[()=>Math.floor(Date.now()/1e3),()=>this.uptimeSeconds_get(),()=>this.telemetry.latencySumMs,()=>iE()]}uptimeSeconds_get(){return Math.floor((Date.now()-this.bootedAt)/1e3)}beat_paint(){for(const e of this.cells){const t=dp(e.source(),e.width);e.element.textContent!==t&&(e.element.textContent=t)}for(const e of this.telemetryRows){const t=e.source();e.element.textContent!==t&&(e.element.textContent=t)}}sweep_start(){if(this.wrapper===null)return;const e=Array.from(this.wrapper.querySelectorAll(".data-column"));window.setInterval(()=>{const t=e[Math.floor(Math.random()*e.length)];t!==void 0&&(t.classList.add("dc-sweep"),window.setTimeout(()=>t.classList.remove("dc-sweep"),sE))},tE)}}function dp(n,e){const t=String(Math.max(0,Math.floor(n)));return t.length>e?t.slice(t.length-e):t.padStart(e,"0")}function iE(){const n=new Date;return n.getHours()*1e4+n.getMinutes()*100+n.getSeconds()}const rE=2e4;class aE{scene;nameplate;command_run;names=[];cursor=0;timer=null;seen=new Map;constructor(e,t,s){this.nameplate=t,this.command_run=s,this.scene=new _l(e,{},{ambient:!0}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),60)}).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.addEventListener("resize",()=>this.scene.size_fit())}names_set(e){this.names=e,this.cursor=0,this.timer!==null&&(window.clearInterval(this.timer),this.timer=null),e.length!==0&&(this.next_request(),e.length>1&&(this.timer=window.setInterval(()=>this.next_request(),rE)))}envelope_observe(e){if(e.model?.kind!==gi.pipelineDiagram)return;const t=Cc.safeParse(e.model.data);if(!t.success)return;const s=t.data;this.seen.set(s.name,s),this.model_stage(s)}model_stage(e){this.nameplate.textContent=e.name,this.scene.graph_set({nodes:e.nodes.map(t=>({id:t.id,label:t.label,parentIds:t.parentIds,joinParentIds:t.joinParentIds}))}),this.scene.size_fit()}next_request(){const e=this.names[this.cursor%this.names.length];if(this.cursor++,e===void 0)return;const t=this.seen.get(e);if(t!==void 0){this.model_stage(t);return}this.command_run(`pipeline diagram ${e}`)}}const oE=new Set(["pane","view","runs","node","dag","universe","file","pacs","image","tags","header","console","back","desktop","dashboard","launcher","attach","argus"]),lM=new Set(["layout","slice","series","wl","colormap","save","tags","load","guard","ghost"]),lE={pacs:new Set(["sort","filter"]),tags:new Set(["redact","filter"]),image:lM};let qn=null;const xr="argus.desktop.",up="~/.config/argus/desktops";function cE(n){const e=n.trim().split(/\s+/),t=(e[0]??"").toLowerCase();if(!oE.has(t))return null;const s=lE[t];if(s!==void 0&&!s.has((e[1]??"").toLowerCase()))return null;let i=null,r=e.slice(1);return(r[0]?.startsWith("@")||r[0]?.startsWith("%"))&&(i=r[0],r=r.slice(1)),{subject:t,target:i,words:r}}function hp(n,e){if(e===null)return n.focused_get();if(e.startsWith("@"))return e.slice(1);const t=parseInt(e.slice(1),10);return qn===null?null:qn[t-1]??null}function $n(n,e,t){const i=n.paneMount_get(e)?.querySelector(t)??null;return i===null?!1:(i.click(),!0)}function Oo(n,e,t){const s=n.paneMount_get(e);if(s===null)return!1;for(const i of s.querySelectorAll(".drawer-child"))if(i.textContent?.trim().toUpperCase()===t)return i.click(),!0;return!1}function dE(n,e,t){return $n(n,e,`.drawer-cwdbind[data-follow="${t?"on":"off"}"]`)}function ha(n,e,t,s){const r=n.paneMount_get(e)?.querySelector(t)??null;if(r===null)return!1;for(let a=0;a<4;a++){if(r.textContent?.trim().toUpperCase()===s)return!0;r.click()}return r.textContent?.trim().toUpperCase()===s}function uE(n,e){const t=n.focused_get(),s=t!==null?n.paneRect_get(t):null;if(s===null)return null;const i=s.x+s.width/2,r=s.y+s.height/2;let a=null;for(const o of n.panes_shown()){if(o===t)continue;const l=n.paneRect_get(o);if(l===null)continue;const c=l.x+l.width/2-i,d=l.y+l.height/2-r,h=e==="left"?-c:e==="right"?c:e==="up"?-d:d;if(h<=1)continue;const u=Math.abs(e==="left"||e==="right"?d:c),p=h+u*2;(a===null||p<a.score)&&(a={id:o,score:p})}return a===null?null:(n.focus_set(a.id),a.id)}const hE={left:{split:"col",place:"before"},right:{split:"col",place:"after"},above:{split:"row",place:"before"},below:{split:"row",place:"after"}},fE=["pane [@id|%n] split left|right|above|below · zoom · close · bind unlinked|fs|viewer","pane [@id|%n] claim files|runs|pacs · focus left|right|up|down|@id","view files|runs|pacs (the gutter givens, workspace scope)","runs enter <feedId> · sort <col> [asc|desc] · filter <text>|off","node enter · immerse · back · clear (the indicated node)","dag [@id] layout ranked|molecule · projection 2d|3d · scale time|size · hue status|compute · pulse · census · physics charge|link|collide|gravity on|off · physics reset · refresh","file [@id] home|back|download|delete · follow · root · list|cards|preview · sort <col> [asc|desc] · filter <text>|off","pacs sort <col> [asc|desc] · filter <text>|off (the results listing; every other pacs verb is the session's)","image [@id] [--force] <path> · layout single|mpr|3d|slab · slice <n> · series <n> · wl <lo> <hi> · wl preset <name> · colormap gray|hot|jet|cool · save · tags · load · guard <bytes>|off · ghost <0..1>|off","tags [@id] redact on|off · filter <text>|off (the pane that follows an image pane's slice)","header stats|dag|away|restore","console open|close|toggle|zoom|height <px>","back (contextual back — exactly Esc)","desktop save|load|show|list|delete [name]","attach [--reveal] (how to reach THIS session from a terminal or another browser)","argus verbs (this table; the long form is docs/argus-lang.adoc)"].join(`
4216
- `);function pE(n,e){const t=new URL(window.location.href),s=t.searchParams.get("token")??"",i=s===""?"":e?s:"•".repeat(8),r=s===""?t.origin+t.pathname:`${t.origin}${t.pathname}?token=${i}`,a=n.identity_get(),o=/^(127\.|\[?::1\]?$|localhost$)/.test(t.hostname),l=["attach — this session, from anywhere that can reach it"];return a!==null&&a!==""&&l.push(` identity ${a}`),l.push(""),l.push(" this machine chell --remote"),l.push(` another machine chell --remote --attach "${r}"`),l.push(` another browser ${r}`),l.push(""),o&&(l.push(" bound to loopback — another machine cannot reach this session;"),l.push(" relaunch the daemon with CALYPSO_BIND=0.0.0.0 to change that")),s===""?(l.push(" this page carries no token: it was opened without one, and a"),l.push(" second surface cannot attach with what is on screen")):e?l.push(" revealed — anyone who reads this line holds the session"):(l.push(" the token is masked — `attach --reveal` prints it. It is a bearer"),l.push(" credential with no expiry: treat the line like a password")),l.join(`
4217
- `)}async function kd(n,e){const t=cE(e);if(t===null)return null;const{subject:s,words:i}=t,r=(i[0]??"").toLowerCase(),a=(i[1]??"").toLowerCase();if(s==="argus")return fE;if(s==="back")return window.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0})),"back";if(s==="attach")return pE(n,r==="--reveal"||a==="--reveal");if(s==="dashboard"||s==="launcher")return n.launcher_enter(),"dashboard";if(s==="view"){const c={files:"gutter-files",runs:"gutter-runs",pacs:"gutter-tools"}[r];return c===void 0?`view: unknown given '${r}' (files|runs|pacs)`:(document.getElementById(c)?.click(),qn!==null&&(qn.length=0,qn.push(r==="runs"?"dag":r==="pacs"?"pacs":"files")),`view ${r}`)}if(s==="header"){if(r==="restore")return document.getElementById("header-restore")?.click(),"header restored";if(r==="stats")return document.querySelector(".panel-1")?.click(),"header stats";if(r==="dag")return document.querySelector(".panel-2")?.click(),"header dag";if(r==="away"){const l=document.body.dataset.header,c=l==="stats"?".panel-1":".panel-2";return l!=="away"&&(l===void 0&&document.querySelector(".panel-2")?.click(),document.querySelector(c)?.click()),"header away"}return`header: unknown face '${r}' (stats|dag|away|restore)`}if(s==="console"){const l=document.getElementById("drawer");if(l===null)return"console: no drawer";const c=l.classList.contains("drawer-closed");if(r==="toggle"||r==="open"&&c||r==="close"&&!c)return document.getElementById("drawer-toggle")?.click(),`console ${r}`;if(r==="zoom")return n.consoleZoom_toggle(),"console zoom";if(r==="height"){const d=parseInt(a,10);return Number.isNaN(d)?"console height <px>":(l.style.height=`${d}px`,`console height ${d}`)}return r==="open"||r==="close"?`console already ${r==="open"?"open":"closed"}`:`console: unknown verb '${r}' (open|close|toggle|zoom|height)`}if((s==="runs"||s==="file"||s==="pacs")&&(r==="sort"||r==="filter")){const l=s==="runs"?".pane-dag":s==="file"?".pane-files":"#pacs-workspace",c=hp(n,t.target),h=(c===null?null:n.paneMount_get(c))?.querySelector(l)??document.querySelector(l);if(h===null)return`${s} ${r}: no ${s==="runs"?"DAG":s==="file"?"files":"PACS"} pane`;if(r==="sort"){if(a==="")return`${s} sort <column> [asc|desc]`;const p=(i[2]??"asc").toLowerCase()==="desc"?"desc":"asc";return h.dispatchEvent(new CustomEvent("argus:roster",{detail:{op:"sort",key:a,dir:p}})),`${s} sorted by ${a} ${p}`}const u=a==="off"?"":i.slice(1).join(" ");return h.dispatchEvent(new CustomEvent("argus:roster",{detail:{op:"filter",text:u}})),u===""?`${s} filter off`:`${s} filtered: ${u}`}if(s==="runs"){if(r==="enter"){const l=parseInt(a.replace(/^feed_/,""),10);return Number.isNaN(l)?"runs enter <feedId>":(n.feed_enter(l),`entering feed_${l}`)}return`runs: unknown verb '${r}' (enter)`}if(s==="desktop")return mE(n,r,i[1]);const o=hp(n,t.target);if(o===null)return`${s}: no target pane (nothing focused?)`;if(s==="pane"){if(r==="split"){const l=hE[a];if(l===void 0)return"pane split left|right|above|below";const c=new Set(n.panes_shown());if(!$n(n,o,`[data-split="${l.split}"][data-place="${l.place}"]`))return`pane split: '${o}' has no drawer`;const d=n.panes_shown().find(h=>!c.has(h));return d!==void 0&&qn!==null&&qn.push(d),`split ${a}: ${d??"(no pane created)"}`}if(r==="zoom")return $n(n,o,".drawer-zoom")?`zoomed ${o}`:"pane zoom: no drawer";if(r==="close")return $n(n,o,".drawer-close")?`closed ${o}`:"pane close: no drawer";if(r==="bind")return["unlinked","fs","viewer"].includes(a)?$n(n,o,`.drawer-bind[data-bind="${a}"]`)?`bind ${a}`:"pane bind: no drawer":"pane bind unlinked|fs|viewer";if(r==="claim"){const c={files:".empty-go-files",runs:".empty-go-dag",pacs:".empty-go-pacs"}[a];return c===void 0?"pane claim files|runs|pacs":$n(n,o,c)?`claiming ${o} as ${a}`:`pane claim: '${o}' is not an unlinked pane`}if(r==="focus"){if(a.startsWith("@"))return n.focus_set(a.slice(1))?`focused ${a.slice(1)}`:`no pane '${a.slice(1)}'`;const l=uE(n,a);return l!==null?`focused ${l}`:`pane focus: nothing ${a} of here`}return`pane: unknown verb '${r}'`}if(s==="dag"){if(r==="layout")return ha(n,o,".dag-strategy",a.toUpperCase())?`layout ${a}`:"dag layout ranked|molecule";if(r==="projection")return ha(n,o,".dag-projection",a.toUpperCase())?`projection ${a}`:"dag projection 2d|3d";if(r==="scale")return ha(n,o,".dag-scale",a.toUpperCase())?`scale ${a}`:"dag scale time|size";if(r==="hue")return ha(n,o,".dag-hue",a.toUpperCase())?`hue ${a}`:"dag hue status|compute";if(r==="pulse")return $n(n,o,".dag-pulse")?"pulse":"dag pulse: no mode frame";if(r==="census")return $n(n,o,".dag-census")?"census toggled":"dag census: no mode frame";if(r==="refresh")return Oo(n,o,"REFRESH")?"refreshing":"dag refresh: no DAG pane";if(r==="physics"){const l=a,c=n.paneMount_get(o),d=c?.querySelector(".pane-dag")??c;if(d===null)return"dag physics: no DAG pane";if(l==="reset")return d.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:"reset"})),"physics reset";const h=(i[2]??"on").toLowerCase()!=="off";return["charge","link","collide","gravity"].includes(l)?(d.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:{term:l,on:h}})),`physics ${l} ${h?"on":"off"}`):`dag physics: unknown term '${l}' (charge|link|collide|gravity|reset)`}return`dag: unknown verb '${r}' (layout|projection|scale|hue|pulse|census|physics|refresh)`}if(s==="file")return r==="list"||r==="cards"||r==="preview"?ha(n,o,".files-view",r.toUpperCase())?`file ${r}`:`file ${r}: no files mode frame`:r==="follow"||r==="root"?dE(n,o,r==="follow")?`file ${r}`:`file ${r}: not offered by '${o}'`:r==="home"||r==="back"?$n(n,o,r==="home"?".files-home":".files-back")?`file ${r}`:`file ${r}: not offered by '${o}'`:r==="download"?n.file_download(o)?"file download":"file download: nothing indicated":r==="delete"?n.file_delete(o)?"file delete":"file delete: nothing indicated":"file home|back|download|delete|sort|filter|follow|root|list|cards|preview";if(s==="image"){const c=i.filter(d=>d!=="--force")[0]??"";return lM.has(c.toLowerCase())?n.image_control(o,r,i.slice(1)):null}return s==="tags"?o===null?"tags: no pane in focus":n.tags_control(o,r,i.slice(1)):s==="universe"?n.universe_control(o,r,i.slice(1)):s==="node"?r==="enter"?Oo(n,o,"ENTER NODE")?"entering node":"node enter: no DAG drawer":r==="back"?Oo(n,o,"BACK")?"node back":"node back: no DAG drawer":r==="immerse"?n.node_immerse(o)?"immersing":"node immerse: nothing indicated":r==="clear"?Oo(n,o,"CLEAR DETAIL")?"detail cleared":"node clear: no DAG drawer":`node: unknown verb '${r}' (enter|immerse|back|clear)`:null}async function mE(n,e,t){if(e==="list"){const s=[];for(let i=0;i<window.localStorage.length;i++){const r=window.localStorage.key(i);r?.startsWith(xr)&&s.push(r.slice(xr.length))}return s.length>0?s.sort().join(`
4209
+ `||d==="\r"){l(),c(),a+=1;continue}s+=d,a+=1}return(s!==""||o||i.length>0)&&(l(),c()),t}function vS(n){if(n.length===0)return!1;const e=new Set;for(const t of n){const s=t.trim();if(s===""||e.has(s.toLowerCase())||s!==""&&Number.isFinite(Number(s)))return!1;e.add(s.toLowerCase())}return!0}function OS(n,e){const t=/\.tsv$/i.test(e)?" ":",",s=yS(n,t);if(s.length===0)return{caps:[],rows:[],headed:!1};const i=s[0],r=vS(i),a=r?s.slice(1):s,o=s.reduce((d,h)=>Math.max(d,h.length),0),l=r?Array.from({length:o},(d,h)=>(i[h]??`COLUMN ${h+1}`).trim()):Array.from({length:o},(d,h)=>`COLUMN ${h+1}`),c=a.map(d=>Array.from({length:o},(h,u)=>d[u]??""));return{caps:l,rows:c,headed:r}}function Df(n){return/-v(\d+(?:\.\d+)*)$/.exec(n)?.[1]??""}const If="",xS="/bin",Tf="/bin/recent",Mo={dir:"",file:"",link:"",plugin:"",pipeline:"",vfs:"",job:""},bc=["list","cards","preview"],SS=5e3,AS=new Set(["png","jpg","jpeg","gif","svg","webp","bmp"]),ES=new Set(["txt","md","adoc","rst","json","csv","tsv","log","yaml","yml","toml","ini","cfg","xml","html","py","sh","ts","js","mjs","r","c","h","cpp","java","go","rs","sql","tex","bib"]),Gf=160,Rf=100,go=10,DS=30,IS=256*1024,TS=4e3,GS=12*1024*1024,RS=400;function Wo(n){return AS.has(Fm(n))}function Fm(n){const e=n.split("/").pop()??"",t=e.lastIndexOf(".");return t>0?e.slice(t+1).toLowerCase():""}function BS(n){if(n.includes("\0"))return!0;const e=(n.match(/\uFFFD/g)??[]).length;return e>0&&e/n.length>.02}const NS=80;function ll(n){const e=document.createElement("a");e.href=n,e.download="",e.rel="noopener",document.body.append(e),e.click(),e.remove()}function Bf(n,e){if(n===null)return[];const t=document.createElement("button");return t.className="files-close-pill files-download-pill",t.textContent="DOWNLOAD",t.title="save this file to your disk",t.addEventListener("click",()=>ll(n.downloadUrl(e))),[t]}function Nf(n){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("viewBox",`0 0 ${Gf} ${Rf}`),t.setAttribute("preserveAspectRatio","xMidYMid meet");const s=zm(n),i=Math.max(s.width,1),r=Math.max(s.tierCount-1,1),a=new Map;for(const o of s.placements)a.set(o.id,{x:go+o.x/i*(Gf-2*go),y:go+o.tier/r*(Rf-2*go)});for(const o of n){const l=a.get(o.id);if(l)for(const c of o.parentIds){const d=a.get(c);if(!d)continue;const h=document.createElementNS(e,"line");h.setAttribute("x1",String(d.x)),h.setAttribute("y1",String(d.y)),h.setAttribute("x2",String(l.x)),h.setAttribute("y2",String(l.y)),h.setAttribute("stroke","currentColor"),h.setAttribute("stroke-width","1"),h.setAttribute("opacity","0.6"),t.appendChild(h)}}for(const[,o]of a){const l=document.createElementNS(e,"circle");l.setAttribute("cx",String(o.x)),l.setAttribute("cy",String(o.y)),l.setAttribute("r",n.length>DS?"2.2":"4"),l.setAttribute("fill","currentColor"),t.appendChild(l)}return t}function bo(n){return n.type==="dir"||n.type==="vfs"||n.type==="link"||n.type==="job"?"dir":n.type==="file"?"file":n.type==="plugin"||n.type==="pipeline"?n.type:null}class Cf{container;recent=null;activate;listing;lastListings=[];contentShown=!1;denied=new Set;following=!1;viewMode="list";viewPill;modeSpan;preview;catalogue;runStrip=null;feedOpen=null;headCache=new Map;thumbObserver=null;frameTopObserver=null;stale=!1;home=null;stateSpan;indicate=null;selectionVerbs=null;constructor(e,t,s=null,i={}){this.container=e,this.activate=t,this.preview=s,this.catalogue=i.catalogue===!0,this.catalogue&&e.parentElement?.classList.add("files-catalogue");const r=e.closest(".pane-files")??e.parentElement;this.viewPill=e.parentElement?.querySelector(".files-view")??null,this.modeSpan=e.closest(".pane-files")?.querySelector(".pane-mode")??null,this.stateSpan=r?.querySelector(".pane-state")??null,this.viewPill?.addEventListener("click",()=>{this.view_set(bc[(bc.indexOf(this.viewMode)+1)%bc.length]??"list")});const a=e.parentElement?.querySelector(":scope > .mode-frame")!==null;this.listing=new Ur({mount:e,traits:this.traits_declare(),key:o=>o.home===!0?"~":o.path,address:o=>o.path,chrome:r===null?void 0:{root:r,prefix:"files"},control:"control",activate:o=>this.row_activate(o),activatable:o=>o.updir||bo(o.entry)!==null,indicated:o=>this.indicate?.(o.entry,o.path),row:{className:o=>`files-row files-type-${o.entry.type}${o.home===!0?" files-lead-home":o.updir?" files-lead-up":""}${!o.updir&&this.denied.has(o.path)?" files-denied":""}`,decorate:(o,l)=>{o.dataset.path=l.path,!l.updir&&this.denied.has(l.path)&&(o.title="listed but not readable — CUBE refused this identity access to the contents")}},...a?{selection:{verbs:o=>this.selectionVerbs?.(o.map(([l,c])=>[l,c.entry]))??[]}}:{},state:o=>this.stateLine_compose(o),defaultSort:{key:"name",dir:"asc"}}),this.empty_render()}traits_declare(){return this.catalogue?this.catalogueTraits_declare():this.browserTraits_declare()}browserTraits_declare(){return[{key:"control",label:"",className:"files-control",capped:!1,width:"2.4em",cell:e=>{const t=document.createElement("span"),s=e.updir?"dir":e.entry.type,i=e.updir||bo(e.entry)!==null;return t.className=`files-control files-glyph files-glyph-${s}${i?" files-capsule":""}`,t.textContent=e.home===!0?If:!e.updir&&this.denied.has(e.path)?"⃠":Mo[s],t}},{key:"name",label:"NAME",className:"files-name",width:"minmax(12em, 1fr)",cell:e=>{const t=document.createElement("span");if(t.className="files-name",t.textContent=e.home===!0?"~":e.updir?"..":e.entry.name,e.home===!0){const s=document.createElement("span");s.className="files-target",s.textContent=e.path,t.appendChild(s),t.title=`home: ${e.path}`}if(!e.updir&&e.entry.type==="link"&&e.entry.target!==void 0){const s=document.createElement("span");s.className="files-target",s.textContent=`→ ${e.entry.target}`,t.appendChild(s),t.title=e.entry.target}return t},compare:e=>e.entry.name},{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:e=>e.updir?"":e.entry.type},{key:"size",label:"SIZE",className:"files-size",width:"6em",cell:e=>e.updir||e.entry.type==="dir"?"":Wf(e.entry.size),compare:e=>e.entry.size},{key:"date",label:"DATE",className:"files-date",width:"7em",cell:e=>e.updir?"":e.entry.date.slice(0,10),compare:e=>e.entry.date},{key:"owner",label:"OWNER",className:"files-owner",width:"10em",cell:e=>e.updir?"":e.entry.owner}]}row_activate(e){if(e.updir){this.activate({kind:"dir",path:e.path});return}const t=bo(e.entry);t!==null&&this.activate({kind:t,path:e.path})}envelope_observe(e){if(e.model?.kind!=="fs.listing")return;const t=Pf(e.model.data);if(t===null||t.length===0)return;this.lastListings=t;const s=t[0]?.path??"";this.container.closest(".workspace-pane")?.classList.toggle("files-projection",/^\/(proc|net|etc|usr)(\/|$)/.test(s)),!this.contentShown&&this.listings_render(t)}ambient_observe(e){if(e.model?.kind!=="fs.listing")return;const t=Pf(e.model.data);if(t===null||this.lastListings.length===0)return;let s=!1;const i=this.lastListings.map(r=>{const a=t.find(o=>o.path===r.path);return a===void 0?r:(s=!0,a)});if(s){if(this.contentShown){this.lastListings=i;return}this.listings_render(i)}}contentTable_show(e,t){const s=OS(t,e);if(s.caps.length===0){this.content_show(e,t);return}const i=s.rows.slice(0,SS),r=s.rows.length>i.length;this.contentRelease?.(),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren(),this.diagram_declare(!1);const a=document.createElement("section");a.className="files-content-view files-table-view";const o=document.createElement("header");o.className="files-path files-content-header";const l=document.createElement("span");l.textContent=e;const c=document.createElement("span");c.className="pane-state",o.append(l,c);const d=document.createElement("div");d.className="files-table-field";const h=document.createElement("span");h.className="field-rule";const u=document.createElement("button");u.className="mode-strip",u.title="display modes";const p=document.createElement("span");p.className="mode-elbow";const M=document.createElement("aside");M.className="mode-frame";const _=document.createElement("button");_.className="strategy-pill csv-filter rail-off",_.textContent="FILTER OFF",_.title="filter the table";const m=document.createElement("button");m.className="strategy-pill csv-raw",m.textContent="RAW",m.title="the bytes as written",m.addEventListener("click",()=>this.content_show(e,t));const f=document.createElement("button");f.className="strategy-pill csv-close",f.textContent="CLOSE",f.title="leave the table; the listing beneath returns",f.addEventListener("click",()=>this.listing_restore());const S=document.createElement("span");S.className="mode-fill",M.append(_,m,S);const v=this.preview;if(v!==null){const G=document.createElement("button");G.className="strategy-pill csv-download",G.textContent="DOWNLOAD",G.title="save this file to your disk",G.addEventListener("click",()=>ll(v.downloadUrl(e))),M.append(G)}M.append(f);const z=document.createElement("div");z.className="files-table-rows",d.append(h,u,p,M,z),a.append(o,d),this.container.appendChild(a);const O=s.caps.map((G,b)=>({key:`c${b}`,label:G.toUpperCase(),className:"files-table-cell",cell:T=>T.cells[b]??"",width:"minmax(6em, 1fr)"}));new Ur({mount:z,traits:O,key:G=>String(G.index),chrome:{root:a,prefix:"csv"},state:G=>{const b=[];return G.filter!==""?b.push(`${G.filter} ROWS`):b.push(r?`SHOWING ${i.length} OF ${s.rows.length} ROWS`:`${s.rows.length} ROWS`),s.headed||b.push("NO HEADER: COLUMNS NUMBERED"),b.join(" · ")},empty:()=>{const G=document.createElement("div");return G.className="files-note",G.textContent="NO ROWS",G}}).rows_set([{key:e,rows:i.map((G,b)=>({index:b,cells:G}))}],{field:e}),this.contentRelease=()=>{z.replaceChildren()}}content_show(e,t){this.diagram_declare(!1),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,...Bf(this.preview,e),r);const a=document.createElement("pre");a.className="files-content",a.textContent=t,this.container.append(s,a)}contentRefused_show(e,t){this.diagram_declare(!1),this.denied.add(e),this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header files-content-refused";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,r);const a=document.createElement("div");a.className="files-refused";const o=document.createElement("p");o.className="files-refused-lede",o.textContent="READ REFUSED";const l=document.createElement("pre");l.className="files-refused-said",l.textContent=t,a.append(o,l),this.container.append(s,a)}contentImage_show(e,t){this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const s=document.createElement("header");s.className="files-path files-content-header";const i=document.createElement("span");i.textContent=e;const r=document.createElement("button");r.className="files-close-pill",r.textContent="CLOSE",r.addEventListener("click",()=>this.listing_restore()),s.append(i,...Bf(this.preview,e),r);const a=document.createElement("img");a.className="files-image",a.src=t,a.alt=e,this.container.append(s,a)}rowVerbs_declare(e,t){this.indicate=t??null,this.listing.actions_declare({of:s=>s.updir?[]:e(s.entry,s.path).map(i=>({label:i.label,run:()=>i.run(s.entry),...i.offered!==void 0?{offered:()=>i.offered(s.entry)}:{},...i.disabled!==void 0?{disabled:()=>i.disabled(s.entry)}:{}}))})}catalogueTraits_declare(){return[...this.browserTraits_declare().filter(s=>s.key==="control"||s.key==="name"),{key:"type",label:"TYPE",className:"files-type",width:"6em",cell:s=>s.updir?"":s.entry.type},{key:"version",label:"VERSION",className:"files-version",width:"7em",cell:s=>s.updir?"":Df(s.entry.name),compare:s=>Df(s.entry.name)}]}catalogue_is(){return this.catalogue}binding_set(e){if(this.runStrip===null){const s=document.createElement("div");s.className="files-run-strip";const i=document.createElement("span");i.className="files-binding";const r=document.createElement("input");r.className="files-command",r.spellcheck=!1,r.autocomplete="off",r.placeholder="the line RUN will run",s.append(i,r),this.container.parentElement?.insertBefore(s,this.container),this.runStrip=s;const a=this.container.closest(".pane-files")?.querySelector(".pane-title");a!=null&&(a.textContent="CATALOGUE")}const t=this.runStrip.querySelector(".files-binding");t!==null&&(t.textContent=`INPUT ${e.input} → ${e.place}`),this.frameTop_track()}commandLine_get(){return this.runStrip?.querySelector(".files-command")?.value.trim()??""}commandLine_set(e){const t=this.runStrip?.querySelector(".files-command")??null;t!==null&&(t.value=e)}indicated_get(){return this.listing.indicated_get()}feedOpen_declare(e){this.feedOpen=e}run_show(e){if(this.runStrip===null)return;this.runStrip.querySelector(".files-feed")?.remove();const t=document.createElement("button");t.className="files-feed listing-capsule listing-action-selected",t.textContent=`FEED ${e}`,t.title="open this run's graph beside the catalogue",t.addEventListener("click",()=>this.feedOpen?.(e)),this.runStrip.appendChild(t)}row_indicate(e){this.listing.row_indicate(e)}rowReadout_show(e,t){this.listing.readout_show(e,t)}selectionVerbs_declare(e){this.selectionVerbs=e}select_toggle(e){this.listing.select_toggle(e)}select_isOn(){return this.listing.select_isOn()}selection_get(){return this.listing.selection_get()}path_current(){return this.lastListings[0]?.path??null}content_isShown(){return this.contentShown}contentRelease=null;contentHtml_show(e,t,s={}){this.contentRelease?.(),this.contentRelease=s.release??null,this.contentShown=!0,this.container.parentElement?.classList.add("content-view"),this.container.replaceChildren();const i=document.createElement("section");i.className="files-content-view";const r=document.createElement("header");r.className="files-path files-content-header";const a=document.createElement("span");a.textContent=e;const o=document.createElement("button");if(o.className="files-close-pill",o.textContent="CLOSE",o.addEventListener("click",()=>this.listing_restore()),r.append(a,o),i.appendChild(r),t!==""){const c=document.createElement("pre");c.className="files-content",c.innerHTML=t,i.appendChild(c)}let l=null;return s.diagram===!0&&(l=document.createElement("div"),l.className="files-diagram",i.appendChild(l)),this.diagram_declare(s.diagram===!0),this.container.appendChild(i),l}contentText_set(e){const t=this.container.querySelector(".files-content-view");if(t===null)return;const s=t.querySelector(".files-content"),i=s??document.createElement("pre");i.className="files-content",i.innerHTML=e,s===null&&t.querySelector(".files-content-header")?.after(i)}recent_set(e){this.recent=e===null?null:[...e],this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}listing_restore(){this.contentRelease?.(),this.contentRelease=null,this.lastListings.length>0?this.listings_render(this.lastListings):this.empty_render()}empty_render(){this.diagram_declare(!1),this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="AWAITING LISTING — TYPE ls IN THE CONSOLE",this.container.appendChild(e)}listings_render(e){this.diagram_declare(!1),this.contentShown=!1,this.container.parentElement?.classList.remove("content-view"),this.lastListings=e,this.thumbObserver?.disconnect(),this.thumbObserver=null,this.stale=e.some(i=>i.fresh===!1),this.stateSpan?.classList.toggle("state-stale",this.stale),this.listing.painter_set(this.viewMode==="list"?null:(i,r)=>this.cards_paint(i,r));const t=e.map(i=>this.block_of(i)),s=e.find(i=>i.path===xS);if(this.recent!==null&&this.recent.length>0&&s!==void 0){const i=this.recentBlock_of(s);i!==null&&t.unshift(i)}this.listing.rows_set(t,{field:e[0]?.path??""}),this.frameTop_track()}crumbs_build(e){const t=document.createElement("header");t.className="files-path files-crumbs";const s=[],i=this.home;let r;i!==null&&(e===i||e.startsWith(`${i}/`))?(s.push({label:"~",path:i}),r=e.slice(i.length)):(s.push({label:"/",path:"/"}),r=e);let a=s[0]?.path??"/";for(const o of r.split("/").filter(l=>l.length>0))a=a==="/"?`/${o}`:`${a}/${o}`,s.push({label:o,path:a});return s.forEach((o,l)=>{l>0&&s[l-1]?.label!=="/"&&t.append("/");const c=l===s.length-1,d=document.createElement(c?"span":"button");d.className=c?"files-crumb files-crumb-here":"files-crumb",d.textContent=o.label,d.dataset.path=o.path,c||(d.title=`go to ${o.path}`,d.addEventListener("click",h=>{h.stopPropagation(),this.activate({kind:"dir",path:o.path})})),t.appendChild(d)}),t}home_set(e){e!==this.home&&(this.home=e,!this.contentShown&&this.lastListings.length>0&&this.listings_render(this.lastListings))}block_of(e){const t=this.crumbs_build(e.path),s=e.items.map(r=>({entry:r,path:zo(e.path,r.name),updir:!1})),i=[];return!this.catalogue&&this.home!==null&&e.path!==this.home&&i.push({entry:{name:"~",type:"dir",size:0,owner:"",date:""},path:this.home,updir:!0,home:!0}),e.path!=="/"&&i.push({entry:{name:"..",type:"dir",size:0,owner:"",date:""},path:CS(e.path),updir:!0}),{key:e.path,header:t,lead:i,rows:s}}recentBlock_of(e){const t=new Map(e.items.map(r=>[r.name,r])),s=[];for(const r of this.recent??[]){const a=t.get(r);a!==void 0&&s.push({entry:a,path:zo(Tf,r),updir:!1})}if(s.length===0)return null;const i=document.createElement("header");return i.className="files-path files-recent",i.textContent="RECENT",{key:Tf,header:i,lead:[],rows:s}}cards_paint(e,t){const s=this.viewMode==="preview",i=document.createElement("div");i.className=s?"files-cards files-previews":"files-cards";for(const a of e.lead??[]){const o=document.createElement("article");o.className=a.home===!0?"files-card files-card-up files-card-home files-activatable":"files-card files-card-up files-activatable",o.textContent=a.home===!0?`${If} ~`:"▴ ..",o.addEventListener("click",()=>this.activate({kind:"dir",path:a.path})),i.appendChild(o)}const r=e.key;for(const a of e.rows)i.appendChild(this.card_build(r,a.entry,s));t.appendChild(i)}frameTop_track(){const e=this.container.parentElement,t=this.container.querySelector(".roster-order"),s=this.container.querySelector(".files-path");if(this.frameTopObserver?.disconnect(),this.frameTopObserver=null,e===null)return;if(t===null||s===null){e.style.removeProperty("--mode-frame-top"),e.style.removeProperty("--roster-frame-h");return}const i=()=>{const r=e.getBoundingClientRect().top,a=Math.ceil(t.getBoundingClientRect().bottom-r);e.style.setProperty("--roster-frame-h",`${a}px`),e.style.setProperty("--mode-frame-top",`${Math.ceil(s.getBoundingClientRect().bottom-r)}px`)};i(),this.frameTopObserver=new ResizeObserver(i),this.frameTopObserver.observe(t),this.frameTopObserver.observe(s)}follow_set(e){this.following=e,this.listing.state_refresh()}follow_get(){return this.following}view_set(e){this.viewMode=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.modeSpan!==null&&(this.modeSpan.textContent=e==="list"?"":e.toUpperCase()),this.lastListings.length>0&&!this.contentShown&&this.listings_render(this.lastListings)}view_get(){return this.viewMode}body_get(){return this.container.closest(".files-body")}diagram_declare(e){this.body_get()?.classList.toggle("diagram-shown",e),e||this.mode_annunciate(this.viewMode==="list"?"":this.viewMode.toUpperCase())}mode_annunciate(e){this.modeSpan!==null&&(this.modeSpan.textContent=e)}stateLine_compose(e){const t=[];return this.following&&t.push("CWD"),e.selecting&&t.push("SELECT"),t.push(this.stale?"STALE":e.filter),e.selected>0&&t.push(e.shown===e.selected?`${e.selected} SELECTED`:`${e.selected} SELECTED · ${e.shown} SHOWN`),t.filter(s=>s!=="").join(" · ")}card_build(e,t,s=!1){const i=document.createElement("article");i.className=`files-card files-type-${t.type}`,s&&i.appendChild(this.thumb_build(zo(e,t.name),t));const r=document.createElement("div");r.className="files-card-head";const a=document.createElement("span");a.className="files-card-badge",a.textContent=t.type.toUpperCase();const o=document.createElement("span");o.className="files-card-size",o.textContent=t.type==="dir"||t.size===0?"":Wf(t.size),r.append(a,o);const l=document.createElement("div");l.className="files-card-title",l.textContent=t.name;const c=document.createElement("div");c.className="files-card-meta";const d=document.createElement("span");d.textContent=t.owner;const h=document.createElement("span");if(h.textContent=t.date.slice(0,10),c.append(d,h),i.append(r,l,c),t.type==="link"&&t.target!==void 0){const M=document.createElement("div");M.className="files-card-target",M.textContent=`→ ${t.target}`,M.title=t.target,i.appendChild(M)}const u=zo(e,t.name),p=bo(t);return p!==null&&(i.classList.add("files-activatable"),i.addEventListener("click",()=>this.activate({kind:p,path:u}))),i}thumb_build(e,t){const s=document.createElement("div");s.className="files-card-thumb";const i=()=>{s.textContent=Mo[t.type]};if(Um.test(t.name)||Po.test(t.name)){s.classList.add("thumb-series");const h=document.createElement("span");h.className="thumb-series-mark",h.textContent="DCM";const u=/^\d+-(.*)-[0-9a-f]{7}$/.exec(t.name)?.[1];if(s.replaceChildren(h),u!==void 0){const p=document.createElement("span");p.className="thumb-series-text",p.textContent=u.replace(/_/g," "),s.appendChild(p)}return s}if(this.preview===null||!(t.type==="file"||t.type==="plugin"||t.type==="pipeline"))return i(),s;if(t.type==="plugin")return s.replaceChildren(Nf([{id:e,parentIds:[]}])),s;if(t.type==="pipeline"){const h=this.preview;s.classList.add("thumb-wait"),s.textContent=Mo[t.type];const u=()=>{h.pipelineGlimpse(e).then(p=>{if(s.classList.remove("thumb-wait"),p===null||p.length===0){i();return}if(p.length>NS){s.textContent=`${p.length} NODES`,s.classList.add("thumb-count");return}s.replaceChildren(Nf(p))}).catch(()=>{s.classList.remove("thumb-wait"),i()})};return this.thumbObserver_get().observe(s),s.addEventListener("files:thumb-seen",u,{once:!0}),s}const r=this.headCache.get(e);if(r!==void 0){const h=document.createElement("pre");return h.textContent=r,s.appendChild(h),s}const a=Wo(e)&&t.size<=GS,o=Fm(e),l=(o===""||ES.has(o))&&t.size<=IS;if(!a&&!l)return i(),s;s.classList.add("thumb-wait"),s.textContent=Mo.file;const c=this.preview,d=()=>{if(a){const h=document.createElement("img");h.alt=t.name,h.addEventListener("load",()=>{s.classList.remove("thumb-wait")}),h.addEventListener("error",()=>{s.classList.remove("thumb-wait"),i()}),h.src=c.imageUrl(e),s.replaceChildren(h);return}c.textHead(e,TS).then(h=>{if(this.headCache.size>=RS&&this.headCache.clear(),this.headCache.set(e,h),s.classList.remove("thumb-wait"),h.trim()===""||BS(h)){i();return}const u=document.createElement("pre");u.textContent=h,s.replaceChildren(u)}).catch(()=>{s.classList.remove("thumb-wait"),i()})};return this.thumbObserver_get().observe(s),s.addEventListener("files:thumb-seen",d,{once:!0}),s}thumbObserver_get(){return this.thumbObserver===null&&(this.thumbObserver=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(this.thumbObserver?.unobserve(t.target),t.target.dispatchEvent(new CustomEvent("files:thumb-seen")))},{root:this.container,rootMargin:"25%"})),this.thumbObserver}filter_toggle(e){this.listing.filter_toggle(e)}}function Pf(n){if(!Array.isArray(n))return null;for(const e of n){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.path!="string"||!Array.isArray(t.items))return null}return n}function zo(n,e){return n.endsWith("/")?`${n}${e}`:`${n}/${e}`}function CS(n){const e=n.endsWith("/")?n.slice(0,-1):n,t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Wf(n){if(n<1024)return String(n);const e=["K","M","G","T"];let t=n,s=-1;for(;t>=1024&&s<e.length-1;)t=t/1024,s=s+1;return`${t<10?t.toFixed(1):Math.round(t)}${e[s]}`}const jm={listing:"files.row",rules:[{name:"image",label:()=>"IMAGE",offered:n=>n.kind==="seriesFolder"},{name:"gather",label:()=>"GATHER",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"process",label:()=>"PROCESS",offered:n=>(n.kind==="directory"||n.kind==="seriesFolder")&&(n.feed===null||(n.node??null)!==null)},{name:"run",label:()=>"RUN",offered:n=>n.kind==="catalogue"&&n.bound===!0},{name:"download",label:()=>"DOWNLOAD",offered:n=>n.kind==="file"},{name:"move",label:()=>"MOVE",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"copy",label:()=>"COPY",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"delete",label:()=>"DELETE",offered:n=>n.kind!=="catalogue"&&n.projection!==!0},{name:"share",label:n=>`SHARE FEED ${n.feed??""}`,offered:n=>n.kind!=="catalogue"&&n.feed!==null&&n.projection!==!0}],states:[{name:"a plain file outside a feed",facts:{kind:"file",feed:null}},{name:"a file inside a feed",facts:{kind:"file",feed:12}},{name:"a directory",facts:{kind:"directory",feed:null}},{name:"a directory inside a feed that is not a node",facts:{kind:"directory",feed:12,node:null}},{name:"a node's data inside a feed",facts:{kind:"directory",feed:12,node:456}},{name:"a DICOM series folder",facts:{kind:"seriesFolder",feed:null}},{name:"a catalogue entry",facts:{kind:"catalogue",feed:null}},{name:"a catalogue entry in a bound catalogue",facts:{kind:"catalogue",feed:null,bound:!0}},{name:"a node's data seen through /proc",facts:{kind:"directory",feed:12,node:456,projection:!0}},{name:"a file seen through /proc",facts:{kind:"file",feed:12,projection:!0}}]},Vm={listing:"files.selection",rules:[{name:"delete",label:n=>`DELETE ${n.count}`,offered:()=>!0},{name:"move",label:n=>`MOVE ${n.count}`,offered:()=>!0},{name:"copy",label:n=>`COPY ${n.count}`,offered:()=>!0},{name:"share",label:n=>n.feeds.length===1?`SHARE FEED ${n.feeds[0]}`:`SHARE ${n.feeds.length} FEEDS`,offered:n=>n.feeds.length>0}],states:[{name:"a selection outside any feed",facts:{count:3,feeds:[]}},{name:"a selection in one feed",facts:{count:2,feeds:[12]}},{name:"a selection spanning feeds",facts:{count:5,feeds:[12,13]}}]},$m={listing:"runs.row",rules:[{name:"share",label:()=>"SHARE",offered:()=>!0},{name:"delete",label:()=>"DELETE",offered:()=>!0}],states:[{name:"any feed",facts:{feedId:12}}]},za={listing:"pacs.study",rules:[{name:"pullStudy",label:()=>"PULL STUDY",offered:n=>n.addressable},{name:"gather",label:()=>"GATHER",offered:n=>n.addressable},{name:"process",label:()=>"PROCESS",offered:n=>n.allInCube}],states:[{name:"a study with a path",facts:{addressable:!0,allInCube:!1}},{name:"a study with none",facts:{addressable:!1,allInCube:!1}},{name:"a study wholly home",facts:{addressable:!0,allInCube:!0,anyInCube:!0}},{name:"a study partly home",facts:{addressable:!0,allInCube:!1,anyInCube:!0}}]},ki={listing:"pacs.series",rules:[{name:"gather",label:()=>"GATHER",offered:n=>n.addressable||n.inCube},{name:"image",label:()=>"IMAGE",offered:n=>n.inCube&&n.folderKnown},{name:"dir",label:()=>"DIR",offered:n=>n.inCube&&n.folderKnown},{name:"process",label:()=>"PROCESS",offered:n=>n.inCube&&n.folderKnown},{name:"pull",label:()=>"PULL",offered:n=>!n.inCube}],states:[{name:"not yet retrieved",facts:{inCube:!1,folderKnown:!1,addressable:!0}},{name:"not retrieved and unaddressable",facts:{inCube:!1,folderKnown:!1,addressable:!1}},{name:"home, folder not yet named",facts:{inCube:!0,folderKnown:!1,addressable:!0}},{name:"home, folder named",facts:{inCube:!0,folderKnown:!0,addressable:!0}}]},Hm={listing:"gather.series",rules:[{name:"remove",label:()=>"REMOVE",offered:()=>!0},{name:"pull",label:()=>"PULL",offered:n=>n.pullable===!0},{name:"image",label:()=>"IMAGE",offered:n=>n.folderKnown&&n.imagery!==!1},{name:"process",label:()=>"PROCESS",offered:()=>!0}],states:[{name:"folder named",facts:{folderKnown:!0}},{name:"a place that is not imagery",facts:{folderKnown:!0,imagery:!1}},{name:"folder not yet named",facts:{folderKnown:!1}},{name:"not retrieved yet",facts:{folderKnown:!1,pullable:!0}}]},qm={listing:"gather.cohort",rules:[{name:"save",label:()=>"SAVE",offered:n=>n.count>0},{name:"export",label:()=>"EXPORT CSV",offered:n=>n.count>0},{name:"feed",label:()=>"CREATE FEED",offered:n=>n.count>0&&n.feed===null},{name:"process",label:()=>"PROCESS",offered:n=>n.count>0},{name:"dismiss",label:()=>"DISMISS",offered:()=>!0}],states:[{name:"holding series",facts:{count:2,feed:null}},{name:"holding series, rooted in a feed",facts:{count:2,feed:4501}},{name:"emptied",facts:{count:0,feed:null}}]};function Ri(n){return{listing:n.listing,visit(e){return e(n)}}}Ri(jm),Ri(Vm),Ri($m),Ri(za),Ri(ki),Ri(qm),Ri(Hm);function yn(n,e){const t=n.rules.find(s=>s.name===e);if(t===void 0)throw new Error(`${n.listing} declares no verb '${e}'`);return t}function PS(n){return{inCube:n.pulled===!0,folderKnown:n.folderPath!==void 0,addressable:n.vfsPath!==void 0}}function Lf(n){if(n.series.length===0)return null;const e=[];for(const s of n.series){if(s.pulled!==!0||s.folderPath===void 0)return null;e.push(s.folderPath.replace(/\/[^/]+\/?$/,""))}const t=e[0]??"";return e.every(s=>s===t)&&t!==""?t:null}function Un(n){const e=PS(n),t=s=>yn(ki,s).offered(e);return{gather:t("gather"),image:t("image"),dir:t("dir"),pull:t("pull")}}function WS(n,e,t,s){let i=!1;for(const r of n.studies)for(const a of r.series)a.seriesUID===e&&(s!==void 0&&a.folderPath!==s&&(a.folderPath=s,i=!0),a.pulled!==!0&&(a.pulled=!0,t!==void 0&&t>0&&(a.pulledFiles=t),i=!0));return i}const kf=[{id:"pacs-f-name",term:"PatientName"},{id:"pacs-f-mrn",term:"PatientID"},{id:"pacs-f-date",term:"StudyDate"},{id:"pacs-f-accession",term:"AccessionNumber"},{id:"pacs-f-modality",term:"Modality"}],_o={running:"RETRIEVING",done:"✓ PULLED",error:"✗ ERROR",unconfirmed:"? UNCONFIRMED",stalled:"STALLED",queued:"QUEUED",idle:"NOT RETRIEVED"},LS="--fresh",Uf="--anon",kS=/\s*--anon\b/,US=["pacs-f-name","pacs-f-mrn","pacs-f-accession","pacs-f-date"],Ff=/\s*--fresh\b/;function jf(n){const e=Date.parse(n);if(Number.isNaN(e))return null;const t=Math.max(0,Math.round((Date.now()-e)/1e3)),s=[{limit:60,size:1,name:"SECOND"},{limit:3600,size:60,name:"MINUTE"},{limit:86400,size:3600,name:"HOUR"},{limit:2592e3,size:86400,name:"DAY"},{limit:31536e3,size:2592e3,name:"MONTH"},{limit:1/0,size:31536e3,name:"YEAR"}];for(const i of s){if(t>=i.limit)continue;const r=Math.max(1,Math.floor(t/i.size));return`${r} ${i.name}${r===1?"":"S"} AGO`}return null}const cl=new Map;function Xm(n,e){const t=cl.get(n)??new Set;t.add(e),cl.set(n,t)}function FS(n,e){const t=cl.get(n);if(t!==void 0){for(const s of[...t]){if(!s.isConnected){t.delete(s);continue}e(s)}t.size===0&&cl.delete(n)}}function jS(n){const e=document.createElement("span");if(e.className="pacs-badge",n.pulled===!0){const i=document.createElement("span");i.className="pacs-bar-full";const r=document.createElement("span");return r.className="pacs-badge-note",r.textContent=n.pulledFiles!==void 0?`✓ ${n.pulledFiles} IN CUBE`:"✓ IN CUBE",e.append(i,r),e.dataset.state="done",e}const t=document.createElement("span");t.className="pacs-bar";const s=document.createElement("span");return s.className="pacs-badge-note",s.textContent="NOT RETRIEVED",e.append(t,s),e.dataset.state="idle",Xm(n.seriesUID,e),e}function Ym(n,e){return[{key:"series",label:"SERIES",className:"pacs-series-desc",width:"35.5em",cell:t=>n(t).description},{key:"state",label:"STATE",className:"pacs-badge",width:"1fr",cell:t=>e(n(t)),compare:t=>n(t).pulled===!0?"done":"idle"},{key:"modality",label:"MODALITY",className:"pacs-series-modality",width:"4em",cell:t=>n(t).modality},{key:"files",label:"FILES",className:"pacs-series-files",width:"6em",cell:t=>{const s=n(t).fileCount;return s!==void 0?`${s} FILES`:""},compare:t=>n(t).fileCount??-1}]}class VS{root;command;results;handlers;litFolders=new Map;badgeStates=new Map;seriesProgress=new Map;studyTracks=new Map;traits;actions;studyTraits;studyActions;patientTraits;listing;patientTracks=new Map;provenance;run;model=null;anon=!1;revealed=!1;anonPill;revealPill;replayed=!1;serverCell;serverStrip;servers=[];chosen=new Set;constructor(e,t){this.root=e,this.handlers=t,this.command=wo(e,"#pacs-command"),this.results=pn(e,"#pacs-results"),this.traits=this.traits_declare(),this.actions=this.actions_declare(),this.studyTraits=this.studyTraits_declare(),this.studyActions=this.studyActions_declare(),this.patientTraits=this.patientTraits_declare(),this.listing=new Ur({mount:this.results,traits:this.patientTraits,key:s=>s.key,chrome:{root:e,prefix:"pacs"},activatable:s=>s.studies.length>0,address:s=>s.studies.length>0?_b(s.patient):void 0,control:"fold",row:{className:()=>"pacs-patient-row",groupClassName:s=>s.patient.status==="unasked"?"pacs-patient pacs-patient-unasked":"pacs-patient",decorate:(s,i)=>{i.studies.length>0&&(s.title="unfold this patient's studies (the patient keeps its place)")}},child:Rr(s=>s.studies.map((i,r)=>({study:i,key:Vf(i,r)})),{traits:this.studyTraits,key:s=>s.key,address:s=>s.study.vfsPath,control:"fold",actions:{of:()=>this.studyActions},row:{className:()=>"pacs-study-row",groupClassName:()=>"pacs-study",decorate:s=>{s.title="unfold this study's series (the study keeps its place)"}},child:Rr(s=>s.study.series.map(i=>({study:s.study,studyKey:s.key,series:i})),{traits:this.traits,key:s=>s.series.seriesUID,address:s=>s.series.vfsPath,actions:{of:()=>this.actions},row:{className:()=>"pacs-series",decorate:(s,i)=>{s.dataset.seriesuid=i.series.seriesUID}}})}),state:s=>this.stateLine_compose(s),empty:()=>Hf("NO STUDIES FOUND")}),e.style.setProperty("--roster-cols",this.listing.template_get(1)),this.listing.rows_set([],{field:"pacs"});for(const{id:s}of kf){const i=wo(e,`#${s}`);i.addEventListener("input",()=>this.command_regenerate()),i.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.query_run())})}this.serverCell=pn(e,"#pacs-f-server"),this.serverStrip=pn(e,"#pacs-server-strip"),this.serverCell.addEventListener("click",()=>this.serverStrip_toggle()),this.serverCell_sync(),this.provenance=pn(e,"#pacs-provenance"),this.anonPill=pn(e,"#pacs-anon"),this.revealPill=pn(e,"#pacs-reveal"),this.anonPill.addEventListener("click",()=>this.anon_set(!this.anon)),this.revealPill.addEventListener("click",()=>this.reveal_set(!this.revealed)),this.run=pn(e,"#pacs-run"),this.run.addEventListener("click",()=>this.query_run(this.replayed)),this.command.addEventListener("keydown",s=>{s.key==="Enter"&&this.query_run()}),pn(e,"#pacs-export").addEventListener("click",()=>this.answer_export()),pn(e,"#pacs-gather-shown").addEventListener("click",()=>this.shown_gather()),pn(e,"#pacs-pull-shown").addEventListener("click",()=>this.shown_pull())}patientTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:e=>{const t=document.createElement("span");return t.className=e.studies.length===0?"pacs-fold pacs-fold-none":"pacs-fold",t}},{key:"patient",label:"PATIENT",className:"pacs-patient-name",width:"13em",cell:e=>e.patient.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-patient-mrn",width:"7.5em",cell:e=>e.patient.patientId||"—"},{key:"answered",label:"ANSWERED",className:"pacs-patient-answered",width:"12em",cell:e=>{const t=document.createElement("span");if(t.className=e.patient.status==="unasked"?"pacs-patient-answered pacs-unasked":"pacs-patient-answered",e.patient.status==="unasked")return t.textContent="UNASKED",e.patient.error!==void 0&&(t.title=e.patient.error),t;const s=e.patient.provenance?.answeredAt;return t.textContent=s===void 0?"—":jf(s)??"—",s!==void 0&&(t.title=s),t},compare:e=>{const t=e.patient.provenance?.answeredAt;if(t===void 0)return Number.MAX_SAFE_INTEGER;const s=Date.parse(t);return Number.isNaN(s)?Number.MAX_SAFE_INTEGER:s}},{key:"progress",label:"PROGRESS",className:"pacs-patient-progress",width:"1fr",cell:e=>{const t=document.createElement("span");return t.className="pacs-patient-progress",this.patientTracks.set(e.key,{mount:t,uids:e.studies.flatMap(s=>s.series.map(i=>i.seriesUID))}),this.patientTrack_paint(e.key),t},compare:e=>{const t=this.patientProgress_of(e);return t.total===0?-1:t.done/t.total}},{key:"studies",label:"STUDIES",className:"pacs-patient-count",width:"6em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.studyCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.studyCount},{key:"series",label:"SERIES",className:"pacs-patient-count",width:"5em",cell:e=>e.patient.status==="unasked"?"—":String(e.patient.seriesCount),compare:e=>e.patient.status==="unasked"?-1:e.patient.seriesCount},{key:"server",label:"SERVER",className:"pacs-patient-server",width:"9em",cell:e=>e.patient.server??this.model?.pacsName??"—"}]}patientProgress_of(e){return mo(e.studies.flatMap(t=>t.series.map(s=>this.seriesProgress.get(s.seriesUID)??{done:0,total:0})))}patientTrack_paint(e){const t=this.patientTracks.get(e);if(t===void 0)return;const s=t.uids.map(i=>this.seriesProgress.get(i)??{done:0,total:0});t.mount.replaceChildren(Ro(mo(s)))}patientRows_build(e){const t=(r,a)=>e.studies.filter(o=>o.patientId===r&&(a===void 0||o.server===void 0||o.server===a));if(e.patients!==void 0&&e.patients.length>0)return e.patients.map((r,a)=>({patient:r,key:`${r.patientId}::${r.server??""}::${a}`,studies:t(r.patientId,r.server)}));const s=[],i=new Map;for(const r of e.studies){const a=r.patientId;i.has(a)||(i.set(a,[]),s.push(a)),i.get(a).push(r)}return s.map((r,a)=>{const o=i.get(r)??[];return{key:`${r}::${a}`,studies:o,patient:{patientId:r,...o[0]?.patientName?{patientName:o[0].patientName}:{},status:"found",studyCount:o.length,seriesCount:o.reduce((l,c)=>l+c.series.length,0),...e.provenance===void 0?{}:{provenance:e.provenance}}}})}studyTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"patient",label:"PATIENT",className:"pacs-study-patient",width:"13em",cell:e=>e.study.patientName||"(unknown)"},{key:"mrn",label:"MRN",className:"pacs-study-mrn",width:"7.5em",cell:e=>e.study.patientId||"—"},{key:"study",label:"STUDY",className:"pacs-study-desc",width:"12em",cell:e=>e.study.description||"(no description)"},{key:"progress",label:"PROGRESS",className:"pacs-study-progress",width:"1fr",cell:e=>{const t=document.createElement("span");return t.className="pacs-study-progress",this.studyTracks.set(e.key,{mount:t,uids:e.study.series.map(s=>s.seriesUID)}),this.studyTrack_paint(e.key),t},compare:e=>{const t=this.studyProgress_of(e);return t.total===0?-1:t.done/t.total}},{key:"date",label:"DATE",className:"pacs-study-date",width:"7.5em",cell:e=>e.study.date},{key:"accession",label:"ACCESSION",className:"pacs-study-accession",width:"9em",cell:e=>e.study.accession||"—"},{key:"modality",label:"MODALITY",className:"pacs-study-modalities",width:"6.5em",cell:e=>e.study.modalities},{key:"server",label:"SERVER",className:"pacs-study-server",width:"9em",cell:e=>e.study.server??this.model?.pacsName??"—"},{key:"series",label:"SERIES",className:"pacs-study-count",width:"6.5em",cell:e=>String(e.study.series.length),compare:e=>e.study.series.length}]}studyActions_declare(){return[{label:yn(za,"pullStudy").label({addressable:!0,allInCube:!1}),offered:e=>yn(za,"pullStudy").offered({addressable:e.study.vfsPath!==void 0,allInCube:!1}),run:e=>{const t=e.study.vfsPath;if(t!==void 0){this.handlers.command_run(`pull ${t}`);for(const s of e.study.series)s.vfsPath!==void 0&&s.pulled!==!0&&this.badgeState_set(s.seriesUID,{status:"queued"})}}},{label:yn(za,"gather").label({addressable:!0,allInCube:!1,anyInCube:!0}),offered:e=>e.study.series.some(t=>Un(t).gather),run:e=>{const t=e.study.series.filter(i=>Un(i).gather);for(const i of t)this.gather_note(e.study,i);const s=e.study.series.length-t.length;this.handlers.note(`gather: ${t.length} series gathered${s>0?`, ${s} not in CUBE (pull them first)`:""}`)}},{label:yn(za,"process").label({addressable:!0,allInCube:!0}),offered:e=>Lf(e.study)!==null,run:e=>{const t=Lf(e.study);t!==null&&this.handlers.process_open(t)}}]}studyProgress_of(e){return mo(e.study.series.map(t=>this.seriesProgress.get(t.seriesUID)??{done:0,total:0}))}traits_declare(){return Ym(e=>e.series,e=>this.badge_build(e))}actions_declare(){return[{label:yn(ki,"gather").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).gather,selected:e=>this.handlers.gathered_is(e.series.seriesUID),run:e=>this.gather_note(e.study,e.series)},{label:yn(ki,"image").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).image,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get($f(e.series.folderPath))?.viewer??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.image_open(e.series.folderPath)}},{label:yn(ki,"dir").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).dir,selected:e=>e.series.folderPath!==void 0&&(this.litFolders.get($f(e.series.folderPath))?.browser??!1),run:e=>{e.series.folderPath!==void 0&&this.handlers.dir_open(e.series.folderPath)}},{label:yn(ki,"process").label({inCube:!0,folderKnown:!0,addressable:!0}),offered:e=>Un(e.series).image,run:e=>{e.series.folderPath!==void 0&&this.handlers.process_open(e.series.folderPath)}},{label:yn(ki,"pull").label({inCube:!1,folderKnown:!1,addressable:!0}),offered:e=>Un(e.series).pull,disabled:e=>e.series.vfsPath===void 0,run:e=>{const t=e.series.vfsPath;t!==void 0&&(this.handlers.command_run(`pull ${t}`),this.badgeState_set(e.series.seriesUID,{status:"queued"}))}}]}state_name(e){return e.pulled===!0?"pulled":this.badgeStates.get(e.seriesUID)?.status??"idle"}command_regenerate(){const e=[];for(const{id:i,term:r}of kf){const a=wo(this.root,`#${i}`).value.trim();a.length>0&&e.push(`${r}:${a}`)}const t=this.chosen.size>1?` --pacsserver ${[...this.chosen].join(",")}`:"",s=this.anon?` ${Uf}`:"";this.command.value=e.length>0||t!==""?`pacs query ${e.join(",")}${t}${s}`:""}anon_set(e){e!==this.anon&&(this.anon=e,this.revealed=!1,this.anonPill.textContent=e?"ANON ON":"ANON OFF",this.anonPill.classList.toggle("pacs-capsule-off",!e),this.revealPill.hidden=!e,this.model=null,this.listing.rows_set([],{field:"pending"}),this.provenance_show(void 0),this.command.value=e?`${this.command.value.trim()} ${Uf}`.trim():this.command.value.replace(kS,"").trimEnd(),this.masking_apply())}reveal_set(e){this.revealed=e,this.revealPill.textContent=e?"HIDE":"REVEAL",this.revealPill.classList.toggle("pacs-capsule-off",!e),this.masking_apply()}masking_apply(){const e=this.anon&&!this.revealed;for(const t of US)wo(this.root,`#${t}`).type=e?"password":"text";this.command.type=e?"password":"text"}serverStrip_toggle(e){const t=e??this.serverStrip.hidden;this.serverStrip.hidden=!t,this.serverCell.classList.toggle("pacs-server-open",t),t&&this.servers.length===0&&this.servers_ask(),t&&this.serverStrip_paint()}query_get(){return this.model===null?null:`pacs query ${this.model.expression}`}serverStrip_isOpen(){return!this.serverStrip.hidden}serverStrip_close(){this.serverStrip_toggle(!1)}servers_ask(){this.handlers.command_run("pacs list")}servers_take(e){this.servers=e,this.serverStrip_paint(),this.serverCell_sync()}serverStrip_paint(){if(this.serverStrip.replaceChildren(),this.servers.length===0){this.serverStrip.appendChild(Hf("ASKING THE SESSION FOR REGISTERED SERVERS"));return}for(const e of this.servers){const t=document.createElement("button");t.className=this.chosen.has(e.identifier)?"pacs-server-segment pacs-server-chosen":"pacs-server-segment",t.dataset.server=e.identifier,t.textContent=e.identifier,e.active&&(t.title="the session is connected to this server"),t.addEventListener("click",()=>this.server_choose(e.identifier)),this.serverStrip.appendChild(t)}}server_choose(e){if(this.chosen.has(e)?this.chosen.delete(e):this.chosen.add(e),this.chosen.size===1){const t=[...this.chosen][0];this.handlers.command_show(`pacs connect ${t}`)}this.serverStrip_paint(),this.serverCell_sync(),this.command_regenerate()}serverCell_sync(){const e=[...this.chosen];if(e.length===0){const t=this.servers.find(s=>s.active);this.serverCell.textContent=t?.identifier??"—",this.serverCell.classList.remove("pacs-server-many");return}this.serverCell.textContent=e.length===1?e[0]:`${e[0]} +${e.length-1}`,this.serverCell.classList.toggle("pacs-server-many",e.length>1)}wrote_show(e){const t=this.root.querySelector("#pacs-wrote");t!==null&&(t.textContent=`WROTE ${e}`,t.title="open the folder this landed in",t.classList.add("pacs-wrote-opens"),t.onclick=()=>{const s=e.lastIndexOf("/");this.handlers.dir_open(s<=0?e:e.slice(0,s))},t.hidden=!1)}answer_export(){if(this.model===null)return;const e=this.command.value.trim(),t=e===""?`pacs query ${this.model.expression}`:e;this.handlers.command_show(`${t} --csv-to`)}query_run(e=!1){e&&!Ff.test(this.command.value)&&(this.command.value=`${this.command.value.trim()} ${LS}`);const t=this.command.value.trim();t.length!==0&&(this.model=null,this.listing.rows_set([],{field:"pending"}),this.listing.field_get()?.appendChild(this.waiting_build()),this.handlers.command_run(t))}provenance_show(e){if(this.replayed=e?.replayed===!0,this.run.textContent=this.replayed?"RE-QUERY":"QUERY",this.run.classList.toggle("pacs-capsule-requery",this.replayed),this.provenance.hidden=!this.replayed,!this.replayed){this.provenance.textContent="",this.command.value=this.command.value.replace(Ff,"").trimEnd();return}const t=e?.answeredAt??"",s=jf(t),i=t.slice(0,10);this.provenance.textContent=s===null?`RESULTS ${i}`:`RESULTS ${i} · ${s}`,this.provenance.title=t}waiting_build(){const e=document.createElement("div");e.className="pacs-waiting";const t=document.createElement("span");t.className="pacs-bar pacs-bar-pacing";const s=document.createElement("span");s.className="pacs-bar-fill",t.appendChild(s);const i=document.createElement("span");return i.className="pacs-waiting-note",i.textContent="QUERYING THE PACS…",e.append(t,i),e}envelope_observe(e){const t=/✓ wrote (\S+)/.exec((e.rendered??"").replace(/\x1b\[[0-9;]*m/g,""));if(t!==null&&this.wrote_show(t[1]),e.model?.kind===bb){const i=gb.safeParse(e.model.data);i.success&&this.servers_take(i.data.servers);return}if(e.model?.kind!==zb)return;const s=mb.safeParse(e.model.data);s.success&&this.results_render(s.data)}progress_observe(e){if(e.operation!=="pull"||e.itemId===void 0)return;const t=e.status??"running",s={status:t};e.current!==void 0&&(s.current=e.current),e.total!==void 0&&(s.total=e.total),this.badgeState_set(e.itemId,s),t==="done"&&this.model!==null&&WS(this.model,e.itemId,e.current??e.total,e.path)&&this.results_repaint()}badgeState_set(e,t){this.badgeStates.set(e,t),this.seriesProgress.set(e,HS(t,this.seriesProgress.get(e))),FS(e,s=>this.badge_paint(s,t));for(const[s,i]of this.studyTracks)i.uids.includes(e)&&this.studyTrack_paint(s);for(const[s,i]of this.patientTracks)i.uids.includes(e)&&this.patientTrack_paint(s)}badge_build(e){const t=document.createElement("span");if(t.className="pacs-badge",e.pulled===!0){const s=document.createElement("span");s.className="pacs-bar-full";const i=document.createElement("span");return i.className="pacs-badge-note",i.textContent=e.pulledFiles!==void 0?`✓ ${e.pulledFiles} IN CUBE`:"✓ IN CUBE",t.append(s,i),t.dataset.state="done",t}return Xm(e.seriesUID,t),this.badge_paint(t,this.badgeStates.get(e.seriesUID)??{status:"idle"}),t}badge_paint(e,t){e.replaceChildren(),e.dataset.state=t.status;const s=document.createElement("span");if(s.className="pacs-badge-note",t.status==="idle"){s.textContent=_o.idle,e.append(Ro({done:0,total:0}),s);return}if(t.status!=="running"&&t.status!=="queued"){e.textContent=_o[t.status]??t.status.toUpperCase();return}const i=t.total!==void 0?` ${t.current??0}/${t.total}`:"",r=t.status==="queued"||t.total===void 0||t.total===0?null:Math.min(1,(t.current??0)/t.total),a=document.createElement("span");a.className=r===null?"pacs-bar pacs-bar-pacing":"pacs-bar";const o=document.createElement("span");o.className="pacs-bar-fill",r!==null&&(o.style.width=`${Math.round(r*100)}%`),a.appendChild(o),s.textContent=t.status==="queued"?_o.queued:`${_o.running}${i}`,e.append(a,s)}results_render(e){const t=this.model!==null&&this.model.queryId===e.queryId;if(this.model=e,this.provenance_show(e.provenance),!t){this.listing.open_clear(),this.badgeStates.clear();const s=this.patientRows_build(e),i=s.length===1?s[0]:void 0;i!==void 0&&i.studies.length>0&&this.listing.open_set(0,[i.key]),e.studies.length===1&&this.listing.open_set(1,[Vf(e.studies[0],0)])}for(const s of e.studies)for(const i of s.series)t&&this.badgeStates.has(i.seriesUID)||this.seriesProgress.set(i.seriesUID,$S(i));this.results_repaint()}results_repaint(){const e=this.model;if(this.studyTracks.clear(),this.patientTracks.clear(),e===null){this.listing.rows_set([],{field:"pacs"});return}this.listing.rows_set([{key:String(e.queryId),rows:this.patientRows_build(e)}],{field:String(e.queryId)})}studyTrack_paint(e){const t=this.studyTracks.get(e);if(t===void 0)return;const s=t.uids.map(i=>this.seriesProgress.get(i)??{done:0,total:0});t.mount.replaceChildren(Ro(mo(s)))}stateLine_compose(e){queueMicrotask(()=>{this.shownGather_render(),this.shownPull_render()});const t=[],s=this.model?.patients??[];if(s.length>0){const i=r=>s.filter(a=>a.status===r).length;t.push(`FOUND ${i("found")} · NONE ${i("none")} · UNASKED ${i("unasked")}`)}return e.filter!==""&&t.push(e.filter),t.join(" · ")}filter_toggle(e){this.listing.filter_toggle(e)}shown_candidates(){const e=[];if(!this.filtering()){for(const t of this.model?.studies??[])for(const s of t.series)e.push({study:t,series:s});return e}for(const t of this.root.querySelectorAll("#pacs-results .pacs-series")){const s=t.dataset.seriesuid;if(s!==void 0)for(const i of this.model?.studies??[]){const r=i.series.find(a=>a.seriesUID===s);r!==void 0&&e.push({study:i,series:r})}}return e}filtering(){return this.listing.filterText_get()!==""}shown_gatherable(){return this.shown_candidates().filter(({series:e})=>Un(e).gather&&!this.handlers.gathered_is(e.seriesUID))}shownGather_render(){const e=this.root.querySelector("#pacs-gather-shown");if(e===null)return;const t=this.shown_gatherable().length;e.hidden=t===0,e.textContent=this.filtering()?`GATHER ${t} SHOWN`:`GATHER ${t}`}shown_pullable(){return this.shown_candidates().map(({series:e})=>e).filter(e=>Un(e).pull&&e.vfsPath!==void 0)}shownPull_render(){const e=this.root.querySelector("#pacs-pull-shown");if(e===null)return;const t=this.shown_pullable().length;e.hidden=t===0,e.textContent=this.filtering()?`PULL ${t} SHOWN`:`PULL ${t}`}shown_pull(){const e=this.shown_pullable();if(e.length===0)return;const t=e.map(s=>`"${s.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${t}`);for(const s of e)this.badgeState_set(s.seriesUID,{status:"queued"});this.handlers.note(`pull: ${e.length} series asked for`),this.shownPull_render()}shown_gather(){const e=this.shown_gatherable();if(e.length!==0){for(const{study:t,series:s}of e)this.gather_note(t,s);this.handlers.note(this.filtering()?`gather: ${e.length} series gathered from what the filter left showing`:`gather: ${e.length} series gathered from the whole answer`),this.shownGather_render()}}gather_note(e,t){t.vfsPath!==void 0&&(this.handlers.gather_add({seriesUID:t.seriesUID,description:t.description,modality:t.modality,series:t,patient:e.patientId||e.patientName,...e.description===void 0||e.description===""?{}:{study:e.description},vfsPath:t.vfsPath,...t.folderPath!==void 0?{folderPath:t.folderPath}:{},...t.fileCount!==void 0?{files:t.fileCount}:{}}),this.selected_refresh())}stage_lit(e){this.litFolders=e,this.selected_refresh()}selected_refresh(){this.listing.indication_refresh()}}function Vf(n,e){return n.studyUID??`study-${e}`}function $f(n){return n.replace(/\/$/,"")}function $S(n){const e=n.pulledFiles??0,t=Math.max(n.fileCount??0,e);return n.pulled===!0?{done:t,total:t}:{done:e,total:t}}function HS(n,e){const t=n.total??e?.total??0;return n.status==="error"?{done:n.current??e?.done??0,total:t,failed:!0}:n.status==="done"?{done:t,total:t}:{done:n.current??e?.done??0,total:t}}function pn(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`PACS workspace is missing '${e}'`);return t}function wo(n,e){const t=pn(n,e);if(!(t instanceof HTMLInputElement))throw new Error(`'${e}' is not an input`);return t}function Hf(n){const e=document.createElement("p");return e.className="files-empty",e.textContent=n,e}function qf(n){return(n.kind??"series")==="series"?void 0:n.vfsPath}const zc="cohort";function qS(n){return/[",\n\r]/.test(n)?`"${n.split('"').join('""')}"`:n}function XS(n){const e=document.createElement("p");return e.className="files-empty",e.textContent=n,e}class Xf{handlers;title;cohort;greeted=!1;listing;cohortActions;seriesActions;constructor(e,t,s,i){this.handlers=s,this.cohort=i,i.watch(()=>{this.unsaved=!0,this.render()}),this.title=e.querySelector(".gather-title"),this.cohortActions=this.cohortActions_declare(),this.seriesActions=this.seriesActions_declare(),this.listing=new Ur({mount:t,traits:this.cohortTraits_declare(),key:r=>r.key,chrome:{root:e,prefix:"gather"},control:"fold",actions:{of:()=>this.cohortActions},row:{className:()=>"gather-cohort-row",groupClassName:()=>"gather-cohort",decorate:r=>{r.title="the cohort: click for its verbs, the fold cell folds its series"}},child:Rr(()=>[...this.cohort.members_get()].map(r=>({entry:r})),{traits:this.seriesTraits_declare(),key:r=>r.entry.seriesUID,address:r=>r.entry.vfsPath,actions:{of:()=>this.seriesActions},row:{className:()=>"gather-series",decorate:(r,a)=>{r.dataset.seriesuid=a.entry.seriesUID}}}),state:r=>this.stateLine_compose(r),empty:()=>XS("NOTHING GATHERED")}),this.pullBlock=e.querySelector(".gather-pull"),this.pullBlock?.addEventListener("click",()=>this.cohort_pull()),this.emptyBlock=e.querySelector(".gather-remove"),this.emptyBlock?.addEventListener("click",()=>{this.cohort_clear()}),this.processBlock=e.querySelector(".gather-process"),this.processBlock?.addEventListener("click",()=>{this.cohort_process()}),this.render()}pullBlock=null;emptyBlock=null;unsaved=!1;processBlock=null;cohort_empty(){this.cohort.size()!==0&&(this.cohort.clear(),this.handlers.changed(),this.render())}async cohort_clear(){if(this.cohort.size()!==0){if(this.unsaved){const e=await this.handlers.confirm_ask(`Save the cohort first? (${this.cohort.size()} ${this.cohort.size()===1?"member":"members"}, unsaved)`);if(e===null||e==="y"&&!await this.manifest_save())return}this.handlers.command_show("gather clear"),this.cohort_empty()}}away(){return[...this.cohort.members_get()].filter(e=>e.folderPath===void 0&&e.series?.pulled!==!0)}cohort_pull(){const e=this.away();if(e.length===0)return;const t=e.map(s=>`"${s.vfsPath}"`).join(" ");this.handlers.command_show(`pull ${t}`)}render_now(){this.render()}has(e){return this.cohort.has(e)}entries_get(){return[...this.cohort.members_get()]}name_get(){return this.cohort.name_get()}feed_get(){return this.cohort.feed_get()}feed_set(e){e!==null&&this.cohort.feed_set(e),this.render()}name_set(e){e!==null&&this.cohort.name_set(e),this.render()}series_add(e){this.cohort.take(e),this.render(),this.handlers.changed()}series_remove(e){this.cohort.drop(e)&&(this.render(),this.handlers.changed())}render(){if(this.title!==null&&(this.title.textContent=this.cohort.name_get()===null?"GATHER":`GATHER · ${this.cohort.name_get()??""}`.toUpperCase()),this.listing.rows_set([{key:"gather",rows:[{key:zc}]}],{field:"gather"}),this.cohort.size()>0&&this.listing.open_set(0,[zc]),this.pullBlock!==null){const e=this.away().length;this.pullBlock.hidden=e===0,this.pullBlock.textContent=`PULL ${e}`}this.emptyBlock!==null&&(this.emptyBlock.hidden=this.cohort.size()===0,this.emptyBlock.textContent=`CLEAR ${this.cohort.size()}`),this.processBlock!==null&&(this.processBlock.hidden=this.cohort.size()===0),this.greeted||(this.greeted=!0,this.listing.row_indicate(zc))}cohortTraits_declare(){return[{key:"fold",label:"",className:"pacs-fold",capped:!1,width:"5.2em",cell:()=>{const e=document.createElement("span");return e.className="pacs-fold",e}},{key:"name",label:"COHORT",className:"gather-cohort-name",width:"1fr",cell:()=>this.cohort.name_get()??"(unnamed — SAVE names it)"},{key:"series",label:"SERIES",className:"gather-cohort-count",width:"6em",cell:()=>String(this.series_count()),compare:()=>this.series_count()},{key:"patients",label:"PATIENTS",className:"gather-cohort-patients",width:"7em",cell:()=>String(this.patients_count()),compare:()=>this.patients_count()},{key:"feed",label:"FEED",className:"gather-cohort-feed",width:"7em",cell:()=>{if(this.cohort.feed_get()===null)return"—";const e=document.createElement("button");e.className="gather-feed listing-capsule listing-action-selected",e.textContent=`FEED ${this.cohort.feed_get()?.feedId??0}`,e.title="open the feed's graph beside the cohort";const t=this.cohort.feed_get()?.feedId??0;return e.addEventListener("click",s=>{s.stopPropagation(),this.handlers.feed_open(t)}),e},compare:()=>this.cohort.feed_get()?.feedId??-1}]}seriesTraits_declare(){const e=Ym(i=>i.entry.series??{seriesUID:i.entry.seriesUID,description:i.entry.description,modality:i.entry.modality,...i.entry.files===void 0?{}:{fileCount:i.entry.files},...i.entry.folderPath===void 0?{}:{pulled:!0,folderPath:i.entry.folderPath}},jS),t={key:"patient",label:"MRN",className:"gather-series-patient",width:"8em",cell:i=>i.entry.patient||"—"},s={key:"study",label:"STUDY",className:"gather-series-study",width:"14em",cell:i=>i.entry.study??"—"};return[...e.slice(0,1),s,t,...e.slice(1)]}cohortActions_declare(){const e=()=>({count:this.cohort.size(),feed:this.cohort.feed_get()?.feedId??null}),t={save:()=>{this.manifest_save()},export:()=>{this.cohort_export()},feed:()=>{this.feed_ensure()},process:()=>{this.cohort_process()},dismiss:()=>this.handlers.dismiss()};return qm.rules.map(s=>({label:s.label(e()),offered:()=>s.offered(e()),run:()=>t[s.name]?.()}))}seriesActions_declare(){const e=s=>({folderKnown:(s.entry.kind??"series")!=="series"||s.entry.folderPath!==void 0,imagery:(s.entry.kind??"series")==="series"||s.entry.imagery===!0,pullable:(s.entry.kind??"series")==="series"&&s.entry.folderPath===void 0&&s.entry.series?.pulled!==!0&&s.entry.vfsPath!==""}),t={remove:s=>this.series_remove(s.entry.seriesUID),pull:s=>this.handlers.command_show(`pull "${s.entry.vfsPath}"`),image:s=>{const i=s.entry.folderPath??qf(s.entry);i!==void 0&&this.handlers.image_open(i)},process:s=>{const i=s.entry.folderPath??qf(s.entry);if(i!==void 0){this.handlers.process_open(i);return}this.handlers.note(`gather: ${s.entry.description||s.entry.seriesUID} is not in CUBE yet — PULL it first, then PROCESS it.`)}};return Hm.rules.map(s=>({label:s.label({folderKnown:!0,pullable:!0}),offered:i=>s.offered(e(i)),run:i=>t[s.name]?.(i)}))}patients_count(){return new Set(this.cohort.members_get().filter(e=>(e.kind??"series")==="series").map(e=>e.patient)).size}series_count(){return this.cohort.members_get().filter(e=>(e.kind??"series")==="series").length}stateLine_compose(e){const t=this.cohort.members_get(),s=t.filter(o=>(o.kind??"series")!=="series").length,i=t.length-s,r=[];(i>0||s===0)&&r.push(`${i} SERIES`),s>0&&r.push(`${s} ${s===1?"PLACE":"PLACES"}`),s===0&&r.push(`${this.patients_count()} PATIENTS`);const a=[r.join(" · ")];return e.filter!==""&&a.push(e.filter),a.join(" · ")}async name_ensure(){if(this.cohort.name_get()!==null)return this.cohort.name_get();const t=(await this.handlers.name_ask(`gather-${new Date().toISOString().slice(0,10)}`)??"").trim();return t===""?null:(this.cohort.name_set(t),this.render(),t)}async manifest_save(){if(this.cohort.size()===0)return!1;const e=await this.name_ensure();if(e===null)return!1;const t=JSON.stringify({name:e,gatheredAt:new Date().toISOString(),series:[...this.cohort.members_get()].map(s=>({seriesUID:s.seriesUID,description:s.description,modality:s.modality,patient:s.patient,vfsPath:s.vfsPath}))});return this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${t}' ~/gather/${e}.json`),this.unsaved=!1,!0}async cohort_export(){if(this.cohort.size()===0)return;const e=await this.name_ensure();if(e===null)return;const t=[["patient","series","modality","seriesUID","path"].join(","),...[...this.cohort.members_get()].map(s=>[s.patient,s.description,s.modality,s.seriesUID,s.vfsPath].map(qS).join(","))];this.handlers.command_run("mkdir -p ~/gather"),this.handlers.command_show(`touch --withContents '${t.join(`
4210
+ `)}' ~/gather/${e}.csv`)}async feed_ensure(){const e=this.cohort.feed_get();if(e!==null)return e;if(this.cohort.size()===0)return null;const t=this.cohort.members_get().filter(a=>(a.kind??"series")!=="series");if(t.length>0)return this.handlers.note(`gather: this cohort holds ${t.length} ${t.length===1?"place":"places"} as well as series, and a feed is rooted by pulling its members — a place is already in ChRIS. PROCESS one place from its own row, or remove them to make a feed of the series. (Rooting a feed on the whole cohort, places included, is coming: CUBE takes the list.)`),null;const s=await this.name_ensure();if(s===null)return null;const i=[...this.cohort.members_get()].map(a=>a.vfsPath).join(" "),r=await this.handlers.feed_create(`pull --new-feed "${s}" ${i}`);return r!==null&&this.feed_set(r),r}async cohort_process(){const e=await this.feed_ensure();e!==null&&this.handlers.cohort_process({input:e.path,feed:e.feedId,node:e.rootInstanceId})}}class YS{members=new Map;title=null;landed=null;watchers=new Set;watch(e){return this.watchers.add(e),()=>{this.watchers.delete(e)}}changed(){for(const e of[...this.watchers])e()}members_get(){return[...this.members.values()]}size(){return this.members.size}has(e){return this.members.has(e)}take(e){const t=this.members.get(e.seriesUID);this.members.set(e.seriesUID,t===void 0?e:{...t,...e}),this.changed()}drop(e){const t=this.members.delete(e);return t&&this.changed(),t}clear(){this.members.size!==0&&(this.members.clear(),this.changed())}name_get(){return this.title}name_set(e){this.title=e,this.changed()}feed_get(){return this.landed}feed_set(e){this.landed=e,this.changed()}}class KS{grid;startHere;host;paintId=0;constructor(e,t){this.host=t,this.grid=e.querySelector(".launcher-grid"),this.startHere=e.querySelector(".launcher-start"),this.startHere.addEventListener("click",()=>{this.host.startHere_set(!this.host.startHere_get()),this.startHere_render()}),this.startHere_render()}render(){const e=++this.paintId;this.host.tiles().then(t=>{e!==this.paintId||!this.grid.isConnected||(this.grid.replaceChildren(...t.map((s,i)=>this.tile_build(s,i===0))),this.startHere_render())}).catch(()=>{e!==this.paintId||!this.grid.isConnected||this.grid.replaceChildren()})}numeral_press(e){const t=this.grid.querySelector(`[data-numeral="${e}"]`);return t===null?!1:(t.click(),!0)}startHere_render(){const e=this.host.startHere_get();this.startHere.textContent=e?"START HERE · ON":"START HERE · OFF",this.startHere.classList.toggle("pacs-capsule-off",!e)}tile_build(e,t){const s=document.createElement("button");s.className=`launcher-tile${t?" launcher-tile-wide":""}`,s.style.setProperty("--tile-hue",`var(${e.hue})`),s.dataset.numeral=e.numeral,s.title=e.verb,s.addEventListener("click",d=>{d.target instanceof Element&&d.target.closest(".launcher-row, .launcher-figure")!==null||e.enter()});const i=document.createElement("span");i.className="launcher-head";const r=document.createElement("span");r.className="launcher-name",r.textContent=e.name;const a=document.createElement("span");a.className="launcher-numeral",a.textContent=e.numeral,i.append(r);for(const d of e.figures){const h=document.createElement(d.open===void 0?"span":"button");if(h.className=`launcher-figure${d.errored===!0?" launcher-figure-errored":""}`,h.textContent=d.text,d.open!==void 0){const u=d.open;h.addEventListener("click",p=>{p.stopPropagation(),u()})}i.appendChild(h)}i.appendChild(a);const o=document.createElement("span");o.className="launcher-rule";const l=document.createElement("span");l.className="launcher-rows";for(const d of e.rows){const h=document.createElement(d.open===void 0?"span":"button");h.className=`launcher-row${d.arrived===!0?" launcher-row-arrived":""}`;const u=document.createElement("span");u.className=`launcher-dot${d.errored===!0?" launcher-dot-errored":""}`;const p=document.createElement("span");if(p.className="launcher-row-text",p.textContent=d.text,h.append(u,p),d.open!==void 0){const M=d.open,_=document.createElement("span");_.className="launcher-go",_.textContent="›",h.appendChild(_),h.addEventListener("click",m=>{m.stopPropagation(),M()})}l.appendChild(h)}const c=document.createElement("span");return c.className="launcher-verb",c.textContent=e.verb,s.append(i,o,l,c),s}}const ZS=/\s--(?:\s|$)/;function wl(n){const e=ZS.exec(n),t=e===null?n:n.slice(0,e.index),s=e===null?"":n.slice(e.index),i=t.lastIndexOf(";"),r=i===-1?0:i+1,a=t.slice(r),o=/^\s*\S+/.exec(a),l=r+(o===null?a.length:o[0].length);return{head:t.slice(0,l),args:t.slice(l),tail:s}}function Yf(n,e){return`cd "${n}"; ${e}`}function QS(n){return/^[A-Za-z0-9_./:@+=,-]+$/.test(n)?n:`"${n.replace(/(["\\])/g,"\\$1")}"`}function Km(n){const e=[],t=/"(?:[^"\\]|\\.)*"|\S+/g;let s=t.exec(n);for(;s!==null;)e.push(s[0]),s=t.exec(n);return e}function Kf(n){return n.length>=2&&n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\(["\\])/g,"$1"):n}function Zm(n){return n.startsWith("-")&&n!=="-"&&!/^-\d/.test(n)}function JS(n,e){const t=Km(wl(n).args);for(let s=0;s<t.length;s++){const i=t[s]??"";if(i===e){const r=t[s+1];return r===void 0||Zm(r)?!0:Kf(r)}if(i.startsWith(`${e}=`))return Kf(i.slice(e.length+1))}return null}function Zf(n,e,t){const s=wl(n),i=Km(s.args),r=[];let a=!1;const o=t===null||t===""?[]:t===!0?[e]:[e,QS(t)];for(let c=0;c<i.length;c++){const d=i[c]??"";if(d===e||d.startsWith(`${e}=`)){if(d===e){const h=i[c+1];h!==void 0&&!Zm(h)&&c++}a||(r.push(...o),a=!0);continue}r.push(d)}a||r.push(...o);const l=r.length===0?"":` ${r.join(" ")}`;return`${s.head}${l}${s.tail}`}function eA(n){return/\bfeed_title=/.test(wl(n).tail)}function tA(n,e){return`${n} -- feed_title="${e.replace(/(["\\])/g,"\\$1")}"`}function Qf(n){return wl(n).head.replace(/^.*;\s*/,"").trim()}function sA(n,e,t){return/^[A-Za-z0-9_-]+$/.test(n)&&t.filter(i=>i===n).length===1?n:`@${e}`}function nA(n){return(n.replace(/\[[0-9;]*m/g,"").split(`
4211
+ `).find(s=>s.trim().length>0)?.trim()??"").replace(/\s*\((?:[\d,]+\/[\d,]+(?:,\s*\d+%)?|initializing)\)(?=\.?$)/,"")}function As(n){return n.groups.map(e=>`${e.parent??"r"}:${e.plugin}`).join(">")}function Wd(n,e){return`feed:${n}:${e}`}function Qm(n){return`shape:${n}`}function dl(n){return Math.log2(Math.max(1,n)+1)}function iA(n){if(!(n.errored<=0||n.count<=0))return Math.min(1,n.errored/n.count)}function Ia(n,e="jobs"){const t=[],s=new Set,i=[...n].sort((a,o)=>a.id-o.id),r=new Map;for(const a of i){if(a.groups.length===0)continue;const o=As(a);r.set(o,(r.get(o)??0)+1)}for(const a of i){if(a.groups.length===0)continue;const o=As(a),l=Qm(o);s.has(o)||(s.add(o),t.push({id:l,label:yl(o),parentIds:[],joinParentIds:[],ghost:!0,halo:!0,metric:1,count:r.get(o)??1})),a.groups.forEach((c,d)=>{const h=iA(c);t.push({id:Wd(a.id,d),label:c.plugin,parentIds:[c.parent===null?l:Wd(a.id,c.parent)],joinParentIds:[],status:c.status,metric:e==="jobs"?dl(c.count):1,...c.count>1?{count:c.count}:{},...h!==void 0?{share:h}:{}})})}return{nodes:t}}class Jm{byId=new Map;take(e){let t=!1;for(const s of e){const i=this.byId.get(s.id);i!==void 0&&i.status===s.status&&i.jobs===s.jobs&&JSON.stringify(i.groups)===JSON.stringify(s.groups)||(this.byId.set(s.id,{...s,chain:[...s.chain],groups:s.groups.map(r=>({...r}))}),t=!0)}return t}size(){return this.byId.size}shapes(){return new Set([...this.byId.values()].map(As)).size}all(){return[...this.byId.values()]}get(e){return this.byId.get(e)}clear(){this.byId.clear()}}function eM(n,e){const t=n.match(/^feed:(\d+):(\d+)$/);if(t===null)return null;const s=e.get(Number(t[1])),i=s?.groups[Number(t[2])];if(s===void 0||i===void 0)return null;const r=i.count>1?` ×${i.count.toLocaleString("en-US")}`:"",a=s.title.length>0?` · ${s.title}`:"",o=i.errored>0&&i.count>1?`${i.errored.toLocaleString("en-US")} errored`:i.status;return`${i.plugin}${r} · ${o} · feed ${s.id}${a}`}function rA(n,e){return`argus.universe.${n}@${e}`}const Dr={draw:"stars",view:"feeds",scale:"jobs",density:"shape",arrangement:"galaxy"};function aA(n,e,t,s,i=Dr.arrangement){return{draw:n,view:e,scale:t,density:s,arrangement:i}}function oA(n){let e={};try{const s=n===null?null:JSON.parse(n);s!==null&&typeof s=="object"&&!Array.isArray(s)&&(e=s)}catch{}const t=(s,i,r)=>typeof s=="string"&&i.includes(s)?s:r;return{draw:t(e.draw,["stars","spheres"],Dr.draw),view:t(e.view,["feeds","shapes"],Dr.view),scale:t(e.scale,["jobs","feeds"],Dr.scale),density:t(e.density,["shape","census"],Dr.density),arrangement:t(e.arrangement,["galaxy","spokes","clumps"],Dr.arrangement)}}function Jf(n){if(n===null||n.length===0)return{};try{const e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[s,i]of Object.entries(e))Array.isArray(i)&&i.length===3&&i.every(r=>typeof r=="number"&&Number.isFinite(r))&&(t[s]=[i[0],i[1],i[2]]);return t}catch{return{}}}function _c(n,e){return`inst:${n}:${e}`}function lA(n){const e=new Set(n.nodes.map(i=>i.id)),t=[],s=new Map;for(const i of n.nodes){const r=_c(n.feedId,i.id),a=i.parentIds.filter(d=>e.has(d)).map(d=>_c(n.feedId,d)),o=i.tally?.count??1,l=i.tally?.error??(i.status==="finishedWithError"?1:0),c=l>0&&o>0?Math.min(1,l/o):void 0;t.push({id:r,label:i.pluginName,parentIds:a,joinParentIds:i.joinParentIds.filter(d=>e.has(d)).map(d=>_c(n.feedId,d)),status:i.status,metric:dl(o),...o>1?{count:o}:{},...c!==void 0?{share:c}:{}}),s.set(r,i)}return{nodes:t,payloads:s}}function cA(n,e,t,s="jobs"){const i=Ia(n,s),r=`feed:${e}:`;return{nodes:[...i.nodes.filter(o=>!o.id.startsWith(r)).map(o=>({...o,dim:!0})),...t.nodes]}}function tM(n,e){return e.groups.map((t,s)=>Wd(n,s))}function yl(n){const e=[];for(const t of n.split(">")){const s=t.slice(t.indexOf(":")+1);s.length>0&&!e.includes(s)&&e.push(s)}return e.join(" > ")}function sM(n,e=3){const t=yl(n).split(" > ");return t.length<=e?t.join(" > "):`${t.slice(0,e).join(" > ")} … +${t.length-e}`}function dA(n,e){if(!n.startsWith("shape:"))return null;const t=n.slice(6),s=e.all().filter(i=>As(i)===t).length;return`${yl(t)} · ${s} feed${s===1?"":"s"}`}function uA(n,e){const t=[];for(const s of e.all())As(s)===n&&t.push(...tM(s.id,s));return t}function hA(n,e,t="jobs"){const s=Ia(n,t),i=new Set(n.filter(a=>As(a)===e).map(a=>a.id));return{nodes:s.nodes.map(a=>{if(a.ghost===!0)return a.id===Qm(e)?a:{...a,dim:!0};const o=a.id.match(/^feed:(\d+):/);return o!==null&&i.has(Number(o[1]))?a:{...a,dim:!0}})}}function Ld(n,e){return`fold:${n}:${e}`}function nM(n,e="jobs"){const t=new Map;for(const i of[...n].sort((r,a)=>r.id-a.id)){if(i.groups.length===0)continue;const r=As(i),a=t.get(r)??[];a.push(i),t.set(r,a)}const s=[];for(const[i,r]of t)r[0].groups.forEach((o,l)=>{let c=0,d=0;for(const u of r){const p=u.groups[l];p!==void 0&&(c+=p.count,p.errored>0&&(d+=1))}const h=d>0?Math.min(1,d/r.length):void 0;s.push({id:Ld(i,l),label:o.plugin,parentIds:o.parent===null?[]:[Ld(i,o.parent)],joinParentIds:[],status:d===r.length?"finishedWithError":"finishedSuccessfully",metric:dl(e==="feeds"?r.length:c),...r.length>1?{count:r.length}:{},...h!==void 0?{share:h}:{}})});return{nodes:s}}function fA(n,e){const t=n.match(/^fold:(.+):(\d+)$/);if(t===null)return null;const s=t[1],i=Number(t[2]),r=e.all().filter(d=>As(d)===s),a=r[0]?.groups[i]?.plugin;if(a===void 0)return null;const o=r.filter(d=>(d.groups[i]?.errored??0)>0).length,l=`${r.length.toLocaleString("en-US")} feed${r.length===1?"":"s"}`,c=o>0?` · ${o.toLocaleString("en-US")} with errors`:"";return`${a} · ${l}${c} · ${sM(s)}`}function ep(n){const e=n.match(/^fold:(.+):\d+$/);return e===null?null:e[1]}function tp(n,e){const t=e.all().find(s=>As(s)===n);return t===void 0?[]:t.groups.map((s,i)=>Ld(n,i))}function sp(n,e,t="jobs"){const s=n.filter(l=>As(l)===e),i=n.filter(l=>As(l)!==e),r=nM(i,t),a=Ia(s,t),o=a.nodes.filter(l=>l.ghost!==!0).map(l=>l.id);return{graph:{nodes:[...r.nodes.map(l=>({...l,dim:!0})),...a.nodes]},memberIds:o}}const pA=6e4,np=1e4,mA=new Set(["running","scheduled","created","started"]),MA=[/\/proc\/jobs\/feed_(\d+)(?:\/|$)/,/\/feeds?\/feed_(\d+)(?:\/|$)/],gA={running:"started",done:"finishedSuccessfully",error:"finishedWithError"};function ip(n){if(n.jobsTotal===void 0||n.jobsDone===void 0)return null;const e=n.status==="finishedWithError"||n.status==="cancelled",t=n.jobsErrored===void 0?void 0:n.jobsDone-n.jobsErrored;return{done:n.jobsDone,total:n.jobsTotal,...e?{failed:!0}:{},...t!==void 0?{succeeded:t}:{}}}function bA(n){const e=[];return n.layout==="molecule"&&e.push("dag layout molecule"),n.projection==="2d"&&e.push("dag projection 2d"),n.scale==="size"&&e.push("dag scale size"),n.hue==="compute"&&e.push("dag hue compute"),n.census==="census"&&e.push("dag census"),e}const zA=[{key:"control",label:"",className:"feedlist-control",capped:!1,width:"5.2em",cell:()=>{const n=document.createElement("span");return n.className="feedlist-control listing-capsule",n.textContent="OPEN",n}},{key:"id",label:"ID",className:"feedlist-id",width:"4em",cell:n=>String(n.id),compare:n=>n.id},{key:"title",label:"TITLE",className:"feedlist-title",width:"24em",cell:n=>n.title||"(untitled)",compare:n=>n.title},{key:"progress",label:"PROGRESS",className:"feedlist-progress",width:"1fr",cell:n=>Ro(ip(n)),compare:n=>{const e=ip(n);return e===null||e.total===0?-1:e.done/e.total}},{key:"status",label:"STATUS",className:"feedlist-status",width:"8em",cell:n=>n.status.toUpperCase(),compare:n=>n.status},{key:"nodes",label:"NODES",className:"feedlist-nodes",width:"4em",cell:n=>n.jobsTotal===void 0?"—":String(n.jobsTotal),compare:n=>n.jobsTotal??-1},{key:"sizeBytes",label:"SIZE",className:"feedlist-size",width:"5.5em",cell:n=>n.sizeBytes===void 0?"—":rM(n.sizeBytes),compare:n=>n.sizeBytes??-1},{key:"wallSeconds",label:"TIME",className:"feedlist-time",width:"6em",cell:n=>n.wallSeconds===void 0?"—":iM(n.wallSeconds),compare:n=>n.wallSeconds??-1},{key:"owner",label:"OWNER",className:"feedlist-owner",width:"7em",cell:n=>n.owner},{key:"createdAt",label:"CREATED",className:"feedlist-created",width:"7em",cell:n=>n.createdAt.slice(0,10),compare:n=>n.createdAt}];function rp(n,e){return n.nodes.length===e.nodes.length&&e.nodes.every((t,s)=>{const i=n.nodes[s];return i!==void 0&&i.id===t.id&&(i.tally?.count??1)===(t.tally?.count??1)&&i.parentIds.length===t.parentIds.length&&i.joinParentIds.length===t.joinParentIds.length})}class _A{scene;canvas;title;facts;empty;strategyPill;feedList;handlers;rosterTimer=null;shownFeedId=null;pinnedFeedId=null;requestedFeedId=null;defaultTitle;metricMode="time";lastModel=null;lastRoster=[];arrivals=new Set;arrivalsKey="";listing;stateSpan;watchedFeedId=null;liveState=null;pendingFeedId=null;lastCwd=null;constructor(e,t,s,i,r,a,o){this.feedList=a,this.canvas=e,e.style.display="none",this.title=t,this.defaultTitle=t.textContent??"",this.facts=s,this.empty=i,this.strategyPill=r,this.handlers=o;const l=r.closest(".pane-dag");this.stateSpan=l?.querySelector(".pane-state")??null,this.modeSpan=l?.querySelector(".pane-mode")??null;const c=o.feed_verbs;this.listing=new Ur({mount:this.feedList,traits:zA,key:f=>String(f.id),chrome:l===null?void 0:{root:l,prefix:"runs"},actions:c===void 0?void 0:{of:f=>c(f)},control:"control",activate:f=>this.feed_activate(f),indicated:f=>this.handlers.feed_indicated?.(f),row:{className:f=>`feedlist-row feedlist-${f.status}${this.arrivals.has(f.id)?" feedlist-arrived":""}`,decorate:(f,S)=>{f.dataset.feed=String(S.id),f.title=c===void 0?"enter the feed (Esc returns to this list)":"click to indicate, double-click to enter (Esc returns to this list)"}},state:f=>this.canvas.style.display==="block"?null:f.filter,defaultSort:{key:"createdAt",dir:"desc"}}),this.rosterTimer=setInterval(()=>{if(!this.feedList.isConnected||!this.rosterShown||this.rosterPending||document.visibilityState!=="visible")return;const S=this.lastRoster.some(v=>mA.has(v.status))?np:pA;Date.now()-this.rosterAskedAt<S||(this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds"))},np),this.scene=new _l(e,{select:f=>this.facts_show(f),activate:f=>this.node_activate(f),deselect:()=>this.facts.replaceChildren(),tip:f=>this.universeShown?eM(f.id,this.landed):null}),r.addEventListener("click",()=>{const f=this.scene.strategy_get()==="ranked"?"molecule":"ranked";this.scene.strategy_set(f),r.textContent=f.toUpperCase(),this.modes_render()});const d=r.parentElement?.querySelector(".dag-projection")??null;d?.addEventListener("click",()=>{const f=this.scene.projection_get()==="3d"?"2d":"3d";this.scene.projection_set(f),d.textContent=f.toUpperCase(),this.modes_render()});const h=r.parentElement?.querySelector(".dag-pulse")??null;h?.classList.add("rail-off"),h?.addEventListener("click",()=>{const f=!this.scene.waveLoop_get();this.scene.waveLoop_set(f),h.textContent=f?"PULSE ON":"PULSE OFF",h.classList.toggle("rail-off",!f),this.modes_render()});const u=r.parentElement?.querySelector(".dag-scale")??null;u?.addEventListener("click",()=>{this.metricMode=this.metricMode==="time"?"size":"time",u.textContent=this.metricMode==="time"?"TIME":"SIZE",this.lastModel!==null&&this.graph_show(this.lastModel,!1),this.modes_render()}),this.scalePill=u;const p=r.parentElement?.querySelector(".dag-census")??null;p?.addEventListener("click",()=>{const f=!this.scene.census_get();this.scene.census_set(f),p.textContent=f?"CENSUS":"SHAPE",this.modes_render()});const M=r.parentElement?.querySelector(".dag-gravity")??null;M?.classList.add("rail-off"),M?.addEventListener("click",()=>{const f=!this.scene.physics_get().gravity;this.scene.physics_set({gravity:f}),M.textContent=f?"GRAVITY ON":"GRAVITY OFF",M.classList.toggle("rail-off",!f),this.modes_render()});const _=r.parentElement?.querySelector(".dag-hue")??null;_?.addEventListener("click",()=>{this.hueMode=this.hueMode==="status"?"compute":"status",_.textContent=this.hueMode.toUpperCase(),this.lastModel!==null&&this.graph_show(this.lastModel,!1),this.hueMode==="compute"&&!this.computeKnown&&this.shownFeedId!==null&&this.canvas.style.display!=="none"&&(this.computeRereading=!0,this.handlers.command_run(`proc refresh ${this.shownFeedId}`),this.refresh()),this.modes_render()}),this.huePill=_,r.closest(".pane-dag")?.addEventListener("argus:dag-physics",f=>{const S=f.detail;if(S==="reset"){this.scene.physics_set({charge:!0,link:!0,collide:!0});return}if(S.term==="gravity"){this.scene.physics_get().gravity!==S.on&&M?.click();return}this.scene.physics_set({[S.term]:S.on})}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),window.addEventListener("resize",()=>this.scene.size_fit()),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),600)}).observe(document.body,{attributes:!0,attributeFilter:["data-zoom"]})}envelope_observe(e){if(e.model?.kind===Bp){const r=Rp.safeParse(e.model.data);r.success&&this.universe_show(r.data);return}if(e.model?.kind===Gp){this.rosterPending=!1;const r=Tp.safeParse(e.model.data);r.success&&(this.universe_end(!0),this.chooser_show(r.data.feeds));return}if(this.pendingFeedId!==null&&e.status==="error"&&e.model===void 0){this.feedRequest_refuse(e.renderedErr??e.rendered??"");return}if(this.rosterPending&&e.status==="error"){this.rosterPending=!1,this.rosterRefusal_show(e),this.universe_request();return}if(e.model?.kind===bi.feedIndexing){const r=nb.safeParse(e.model.data);if(!r.success)return;this.requestedFeedId===r.data.feedId?this.requestedFeedId=null:this.pendingFeedId!==r.data.feedId&&(this.pinnedFeedId=r.data.feedId,this.pendingFeedId=r.data.feedId),this.feedIndexing_show(r.data);return}if(e.model?.kind!==bi.feedDag)return;const t=Pc.safeParse(e.model.data);if(!t.success)return;const s=t.data;this.requestedFeedId===s.feedId?this.requestedFeedId=null:this.pinnedFeedId=s.feedId,this.universe_end(!1),this.shownFeedId=s.feedId,this.pendingFeedId=null,this.stateSpan?.classList.remove("state-wait"),this.title.textContent=`DAG · FEED ${s.feedId} — ${s.feedName}`.toUpperCase(),this.empty.style.display="none",this.roster_show(!1),this.canvas.style.display="block",this.lastModel!==null&&this.lastModel.feedId!==s.feedId&&(this.facts.replaceChildren(),this.scene.selection_clear());const i=this.lastModel;this.lastModel=s,i!==null&&i.feedId===s.feedId&&rp(i,s)?this.statuses_patch(s):this.graph_show(s),this.watch_open(s.feedId),this.handlers.feed_shown?.()}watch_open(e){this.watchedFeedId!==e&&(this.watch_release(),this.watchedFeedId=e,this.liveState_show(null),this.handlers.watch_set?.(`/proc/jobs/feed_${e}`,!0))}watch_release(){this.watchedFeedId!==null&&(this.handlers.watch_set?.(`/proc/jobs/feed_${this.watchedFeedId}`,!1),this.watchedFeedId=null,this.liveState_show(null))}modeSpan=null;hueMode="status";huePill=null;hueLegend=new Map;computeKnown=!1;computeRereading=!1;hueLegend_build(e){const t=getComputedStyle(document.documentElement),s=["--harvestgold","--daybreak","--orange","--honey","--butter","--october-sunset"].map(r=>t.getPropertyValue(r).trim()).filter(r=>r!==""),i=new Map;for(const r of e.nodes){const a=r.computeResource;a===void 0||a==="mixed"||i.has(a)||i.set(a,s[i.size%Math.max(1,s.length)]??"#888")}return i}modes_render(){if(this.modeSpan===null)return;const e=[];if(this.scene.strategy_get()!=="ranked"&&e.push("MOLECULE"),this.scene.projection_get()!=="3d"&&e.push("2D"),this.metricMode!=="time"&&e.push("SIZE"),this.scene.census_get()&&e.push("CENSUS"),this.scene.waveLoop_get()&&e.push("PULSE"),this.scene.physics_get().gravity&&e.push("GRAVITY"),this.modeSpan.replaceChildren(document.createTextNode(e.join(" · "))),this.hueMode==="compute"){const t=document.createElement("span");t.className="pane-legend",t.append(document.createTextNode(e.length>0?" · COMPUTE":"COMPUTE"));for(const[s,i]of this.hueLegend){const r=document.createElement("span");r.className="legend-swatch",r.style.backgroundColor=i;const a=document.createElement("span");a.textContent=s,t.append(document.createTextNode(" "),r,a)}this.hueLegend.size===0&&t.append(document.createTextNode(this.computeRereading?" (re-reading the feed…)":" (none reported)")),this.modeSpan.appendChild(t)}}liveState_show(e){if(this.liveState=e,this.stateSpan!==null){if(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),e===null){this.canvas.style.display!=="none"&&(this.stateSpan.textContent="");return}this.stateSpan.textContent=e.toUpperCase(),this.stateSpan.classList.add(`state-${e}`)}}liveState_get(){return this.liveState}feed_get(){return this.pendingFeedId??this.shownFeedId}graph_isShown(){return this.canvas.style.display==="block"}feedTitle_get(){return(this.title.textContent??"").replace(/^DAG\s*·\s*/i,"").trim()}view_lines(){const e=this.strategyPill.parentElement,t=s=>e?.querySelector(s)?.textContent?.trim().toLowerCase()??"";return bA({layout:t(".dag-strategy"),projection:t(".dag-projection"),scale:t(".dag-scale"),hue:t(".dag-hue"),census:t(".dag-census")})}watched_observe(e,t){const s=/feed_(\d+)$/.exec(e);!s||Number(s[1])!==this.watchedFeedId||this.liveState_show(t)}model_refresh(e){if(this.pendingFeedId===e.feedId&&this.canvas.style.display==="none"){this.envelope_observe({status:"ok",rendered:"",model:{kind:bi.feedDag,data:e}});return}if(this.shownFeedId!==e.feedId||this.canvas.style.display==="none")return;const t=this.lastModel;if(this.lastModel=e,t!==null&&rp(t,e)){this.statuses_patch(e);return}this.graph_show(e,!1)}statuses_patch(e){for(const t of e.nodes)this.scene.status_update(t.id,t.status),this.factsPayloads.set(t.id,t);this.factsShown!==null&&this.facts_show(this.factsShown)}refresh(){this.shownFeedId===null||this.canvas.style.display==="none"||(this.requestedFeedId=this.shownFeedId,this.handlers.command_run(`feed diagram feed_${this.shownFeedId}`))}scalePill=null;graph_show(e,t=!0){const s=o=>this.metricMode==="time"?o.metrics?.computeSeconds:o.metrics?.dataBytes,i=e.nodes.some(o=>s(o)!==void 0);this.scalePill?.classList.toggle("rail-na",!i),this.scalePill!==null&&(this.scalePill.title=i?"molecule node size: wall time or output bytes":`no ${this.metricMode==="time"?"wall-time":"output-size"} data in this feed's cache yet`),this.hueLegend=this.hueLegend_build(e);const r=e.nodes.some(o=>o.computeResource!==void 0);this.computeKnown=r,r&&(this.computeRereading=!1),this.huePill?.classList.toggle("rail-na",!r),this.huePill!==null&&(this.huePill.title=r?"what colors a node: its status, or the compute resource it ran on":"no compute resource reported for this feed's nodes yet");const a=o=>{if(this.hueMode==="compute")return o.computeResource===void 0?"#555":this.hueLegend.get(o.computeResource)??"#555"};this.scene.graph_set({nodes:e.nodes.map(o=>{const l=a(o);return{id:o.id,label:o.label,parentIds:o.parentIds,joinParentIds:o.joinParentIds,status:o.status,metric:s(o),count:o.tally?.count,...l!==void 0?{hue:l}:{}}})},{wave:t}),this.scene.size_fit(),this.hueMode==="compute"&&this.modes_render(),this.factsPayloads.clear();for(const o of e.nodes)this.factsPayloads.set(o.id,o);this.factsShown!==null&&(this.factsPayloads.has(this.factsShown.id)?this.facts_show(this.factsShown):this.factsShown=null)}factsPayloads=new Map;factsShown=null;promptContext_observe(e){const t=e.procWarmup?.landed??[];if(t.length>0&&this.universeLandings_take(t),this.universeShown&&this.universeLive){const o=e.procWarmup;if(o?.total!==void 0&&o.total>0&&o.sweeping!==!1){const l=Math.floor(o.loaded/o.total*100),c=`INDEX WARMING ${o.loaded.toLocaleString()}/${o.total.toLocaleString()} (${l}%)`;c!==this.universeWarming&&(this.universeWarming=c,this.universeTitle_paint())}else(o===void 0||o.sweeping===!1||o.state==="cached")&&(this.universeLive=!1,this.universeWarming="",this.universe_request())}if(this.rosterProgress!==null&&this.rosterProgress.isConnected){const o=e.procWarmup;if(o?.total!==void 0&&o.total>0&&o.sweeping!==!1){const l=Math.floor(o.loaded/o.total*100);this.rosterProgress.textContent=`INDEX WARMING — ${o.loaded}/${o.total} (${l}%). The roster opens when the index is whole.`}(o===void 0||o.sweeping===!1||o.state==="cached")&&(this.rosterProgress=null,this.feedsChooser_request())}this.arrivals_observe(e.procWarmup?.arrived??[]);const i=(e.procWarmup?.feeds??(e.procWarmup?.feed!==void 0?[e.procWarmup.feed]:[])).find(o=>o.id===this.pendingFeedId);if(i!==void 0&&this.feedIndexing_show({feedId:i.id,loaded:i.loaded,total:i.total,...i.failed!==void 0?{failed:i.failed}:{}}),!this.canvas.isConnected||this.rosterShown||this.pendingFeedId!==null)return;const r=this.lastCwd!==null&&e.cwd!==this.lastCwd;if(this.lastCwd=e.cwd,!r)return;const a=yA(e.cwd);a!==null&&a!==this.shownFeedId&&(this.pinnedFeedId!==null&&a===this.pinnedFeedId||(this.pinnedFeedId=null,this.requestedFeedId=a,this.handlers.command_run(`feed diagram feed_${a}`)))}progress_observe(e){if(e.itemId===void 0)return;const t=e.status!==void 0?gA[e.status]:void 0;t!==void 0&&this.scene.status_update(String(e.itemId),t)}size_fit(){this.scene.size_fit()}dispose(){this.watch_release(),this.rosterTimer!==null&&clearInterval(this.rosterTimer),this.scene.dispose()}feed_enter(e){this.pinnedFeedId=e,this.requestedFeedId=null,this.feedRequest_show(e),this.handlers.command_run(`feed diagram feed_${e}`)}feedRequest_show(e){this.pendingFeedId=e,this.roster_show(!1),this.canvas.style.display="none",this.facts.replaceChildren(),this.title.textContent=`DAG · FEED ${e}`,this.empty.textContent=`RETRIEVING FEED ${e}…`,this.empty.style.display="block",this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),this.stateSpan.classList.add("state-wait"),this.stateSpan.textContent="LOADING")}feedIndexing_show(e){this.pendingFeedId===null&&(this.pendingFeedId=e.feedId),this.roster_show(!1),this.canvas.style.display="none",this.title.textContent=`DAG · FEED ${e.feedId}`;const t=e.total>0?`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:`${e.loaded.toLocaleString()} / ?`;this.empty.textContent=e.failed!==void 0?`INDEXING FEED ${e.feedId} FAILED AT ${t} — ${e.failed.toUpperCase()} — REFRESH RETRIES`:`INDEXING FEED ${e.feedId} — ${t}`,this.empty.style.display="block",this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale"),this.stateSpan.classList.add("state-wait"),this.stateSpan.textContent=e.failed!==void 0?"FAILED":"LOADING"),e.failed===void 0&&this.watch_open(e.feedId)}feedRequest_refuse(e){const t=this.pendingFeedId;this.pendingFeedId=null,this.empty.textContent=`FEED ${t??"?"}: ${e.trim()||"not available"}`.toUpperCase(),this.empty.style.display="block",this.roster_show(!0),this.title.textContent=this.defaultTitle,this.stateSpan?.classList.remove("state-wait"),this.listing.state_refresh()}feedsChooser_request(){const e=document.createElement("div");e.className="feedlist-loading",e.textContent="RETRIEVING FEED ROSTER…",this.feedList.replaceChildren(e),this.roster_show(!0),this.rosterPending=!0,this.rosterAskedAt=Date.now(),this.handlers.command_run("proc feeds")}rosterPending=!1;rosterShown=!1;rosterAskedAt=0;rosterProgress=null;landed=new Jm;universeShown=!1;universeLive=!1;universeRepaint=null;universeStrategyWas=null;universeWarming="";universe_request(){this.handlers.command_run("proc universe")}universe_show(e){this.landed.clear(),this.landed.take(e.feeds),this.universeLive=!e.whole,this.universeShown||(this.universeShown=!0,this.universeStrategyWas=this.scene.strategy_get(),this.scene.strategy_set("molecule"),this.scene.physics_set({gravity:!0})),this.roster_show(!1),this.pendingFeedId=null,this.pinnedFeedId=null,this.empty.style.display="none",this.canvas.style.display="block",this.universe_paint()}universe_paint(){this.lastModel=null,this.scene.graph_set(Ia(this.landed.all()),{wave:!1}),this.universeTitle_paint()}universeTitle_paint(){const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.universeLive?`UNIVERSE — ${e}${this.universeWarming.length>0?` · ${this.universeWarming}`:" · INDEX WARMING"}`:`UNIVERSE — ${e}`,this.stateSpan!==null&&(this.stateSpan.classList.remove("state-live","state-settled","state-stale","state-wait"),this.stateSpan.classList.add(this.universeLive?"state-wait":"state-settled"),this.stateSpan.textContent=this.universeLive?"LANDING":"WHOLE")}universeLandings_take(e){!this.universeShown||!this.universeLive||!this.landed.take(e)||this.universeRepaint!==null||(this.universeRepaint=window.setTimeout(()=>{this.universeRepaint=null,this.universeShown&&this.universe_paint()},1e3))}universe_end(e){this.universeShown&&(this.universeShown=!1,this.universeLive=!1,this.universeWarming="",this.universeRepaint!==null&&(window.clearTimeout(this.universeRepaint),this.universeRepaint=null),this.landed.clear(),this.universeStrategyWas!==null&&(this.scene.strategy_set(this.universeStrategyWas),this.universeStrategyWas=null),this.scene.selection_clear(),e&&(this.canvas.style.display="none"))}rosterRefusal_show(e){const t=nA(e.renderedErr||e.rendered||""),s=t.length>0?t:"the roster request was refused",i=document.createElement("div");i.className="feedlist-refusal",i.textContent=s;const r=document.createElement("div");r.className="feedlist-warming",r.textContent="INDEX WARMING… the roster opens when the index is whole.",this.feedList.replaceChildren(i,r),this.roster_show(!0),this.rosterProgress=r}list_reset(){this.pendingFeedId=null,this.stateSpan?.classList.remove("state-wait"),this.watch_release(),this.facts.replaceChildren(),this.scene.selection_clear(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.empty.style.display="none"}nav_pop(){return this.pendingFeedId!==null&&this.feedList.childElementCount>0?(this.pendingFeedId=null,this.pinnedFeedId=null,this.requestedFeedId=null,this.empty.style.display="none",this.roster_show(!0),this.title.textContent=this.defaultTitle,this.stateSpan?.classList.remove("state-wait"),this.listing.state_refresh(),!0):this.canvas.style.display==="none"||this.feedList.childElementCount===0?!1:(this.watch_release(),this.canvas.style.display="none",this.pinnedFeedId=null,this.requestedFeedId=null,this.title.textContent=this.defaultTitle,this.facts.replaceChildren(),this.scene.selection_clear(),this.roster_show(!0),this.listing.state_refresh(),!0)}arrivals_observe(e){const t=e.join(",");if(t===this.arrivalsKey)return;this.arrivalsKey=t,this.arrivals=new Set(e);for(const r of this.lastRoster)this.listing.row_element(String(r.id))?.classList.toggle("feedlist-arrived",this.arrivals.has(r.id));const s=new Set(this.lastRoster.map(r=>r.id));e.some(r=>!s.has(r))&&this.rosterShown&&this.feedsChooser_request()}chooser_show(e){this.lastRoster=e,this.empty.style.display="none",this.roster_show(!0),this.listing.rows_set([{key:"roster",rows:e}],{field:"roster"}),this.rosterFrame_track()}feed_activate(e){this.pinnedFeedId=e.id,this.requestedFeedId=null,this.handlers.feed_regard?.(`/proc/jobs/feed_${e.id}`),this.feedRequest_show(e.id),this.handlers.command_run(`feed diagram feed_${e.id}`)}row_indicate(e){this.listing.row_indicate(e===null?null:String(e.id))}rowReadout_show(e,t){this.listing.readout_show(String(e),t)}filter_toggle(e){this.listing.filter_toggle(e)}roster_filter(e){this.listing.filter_toggle(e!==""),this.listing.filter_set(e)}rosterFrameObserver=null;rosterFrame_track(){const e=this.feedList.parentElement,t=this.feedList.querySelector(".roster-order");if(this.rosterFrameObserver?.disconnect(),this.rosterFrameObserver=null,e===null)return;if(t===null){e.style.removeProperty("--mode-frame-top");return}const s=()=>{e.style.setProperty("--mode-frame-top",`${Math.ceil(t.getBoundingClientRect().bottom-e.getBoundingClientRect().top)}px`)};s(),this.rosterFrameObserver=new ResizeObserver(s),this.rosterFrameObserver.observe(t)}roster_show(e){this.rosterShown=e,this.feedList.style.display=e?"flex":"none",this.feedList.parentElement?.classList.toggle("roster-shown",e)}facts_show(e){this.factsShown=e;const t=this.factsPayloads.get(e.id);if(!t){this.facts.textContent=e.label;return}this.handlers.node_regard?.(t.vfsPath),this.facts.replaceChildren();const i=t.status==="finishedSuccessfully"||t.status==="finishedWithError"||t.status==="cancelled"?"awaiting warmup":"in flight",r=t.tally,a=[["PLUGIN",t.pluginName],[r?"REP. INSTANCE":"INSTANCE",String(t.instanceId)],["STATUS",t.status],...r?[["COUNT",`×${r.count} — ${r.done} done, ${r.error} err, ${r.running} live, ${r.other} other`]]:[],...r?.anomalies!==void 0&&r.anomalies.length>0?[["FAULTS",r.anomalies.map(o=>o.id).join(" ")+(r.count>r.done+r.anomalies.length?" …":"")]]:[],["WALL",t.metrics?.computeSeconds!==void 0?iM(t.metrics.computeSeconds):i],["SIZE",t.metrics?.dataBytes!==void 0?rM(t.metrics.dataBytes):i],["DATA",t.vfsPath]];for(const[o,l]of a){const c=document.createElement("div");c.className="telemetry-row";const d=document.createElement("span");d.className="telemetry-label",d.textContent=o;const h=document.createElement("span");h.className="telemetry-value",h.textContent=l,c.append(d,h),this.facts.appendChild(c)}if(this.facts.appendChild(wA(t.status)),this.handlers.node_process!==void 0){const o=this.handlers.node_process,l=document.createElement("button");l.className="pacs-capsule dag-process",r!==void 0?(l.textContent="PROCESS",l.disabled=!0,l.title=`${r.count} instances stand here: open one to process it`,l.classList.add("pacs-capsule-off")):(l.textContent="PROCESS",l.title=`open /bin bound to ${t.label} — a run appends to this node`,l.addEventListener("click",()=>o({vfsPath:t.vfsPath,instanceId:t.instanceId,label:t.label}))),this.facts.appendChild(l)}}node_activate(e){const t=this.factsPayloads.get(e.id);if(t)if(this.handlers.node_dive!==void 0){const s=this.handlers.node_dive;this.scene.flight_into(e.id,()=>s(t.vfsPath))}else this.handlers.node_enter(t.vfsPath)}detail_clear(){this.scene.selection_clear(),this.facts.replaceChildren()}wave_start(){this.scene.wave_start()}inside_isHeld(){return this.scene.holding_get()}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){for(const[t,s]of this.factsPayloads){if(s.instanceId!==e)continue;if(this.handlers.node_dive===void 0)return!1;const i=this.handlers.node_dive;return this.facts_show({id:t,label:s.label,parentIds:[],joinParentIds:[]}),this.scene.flight_into(t,()=>i(s.vfsPath)),!0}return!1}}function iM(n){const e=Math.round(n);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${String(e%60).padStart(2,"0")}s`:`${Math.floor(e/3600)}h ${String(Math.floor(e%3600/60)).padStart(2,"0")}m`}function rM(n){if(n<1024)return`${n}B`;const e=["K","M","G","T"];let t=n,s=-1;for(;t>=1024&&s<e.length-1;)t=t/1024,s=s+1;return`${t<10?t.toFixed(1):Math.round(t)}${e[s]}`}const wc=[{key:"created",label:"CREATED"},{key:"waiting",label:"WAITING"},{key:"scheduled",label:"SCHEDULED"},{key:"started",label:"STARTED"},{key:"registeringFiles",label:"REGISTERING"}];function wA(n){const e=document.createElement("div");e.className="dag-subway";const t=n==="finishedSuccessfully",s=n==="finishedWithError"||n==="cancelled",i=wc.findIndex(l=>l.key===n),r=t||s?wc.length:i;!t&&!s&&e.classList.add("dag-subway-live");const a=(l,c,d)=>{const h=document.createElement("span");h.className=`subway-step${d?" subway-step-here":""}`;const u=document.createElement("span");u.className=c;const p=document.createElement("span");return p.className="subway-label",p.textContent=l,h.append(u,p),h};wc.forEach((l,c)=>{if(c>0){const h=document.createElement("span");h.className="subway-link"+(c<=r?" subway-passed":""),e.appendChild(h)}const d=c===i&&!t&&!s;e.appendChild(a(l.label,"subway-stop"+(c<r?" subway-passed":"")+(d?" subway-here":""),d))});const o=document.createElement("span");return o.className="subway-link"+(t||s?" subway-passed":""),e.appendChild(o),e.appendChild(a(t?"FINISHED":s?n==="cancelled"?"CANCELLED":"ERROR":"FINISHED","subway-stop subway-terminal"+(t?" subway-done":"")+(s?" subway-failed":""),!1)),e}function yA(n){for(const e of MA){const t=n.match(e);if(t?.[1]!==void 0)return parseInt(t[1],10)}return null}class vA{root;label;fill;constructor(e){this.root=document.createElement("div"),this.root.className="wait-progress",this.root.hidden=!0,this.root.setAttribute("role","progressbar"),this.root.setAttribute("aria-valuemin","0"),this.root.setAttribute("aria-valuemax","100"),this.label=document.createElement("span"),this.label.className="wait-progress-label";const t=document.createElement("span");t.className="wait-progress-track",this.fill=document.createElement("span"),this.fill.className="wait-progress-fill",t.appendChild(this.fill),this.root.append(this.label,t),e.appendChild(this.root)}show(e,t){this.root.hidden=!1,this.label.textContent=t===null?e:`${e} · ${Math.floor(t*100)}%`,this.root.classList.toggle("wait-progress-indeterminate",t===null),this.fill.style.width=t===null?"":`${Math.max(0,Math.min(1,t))*100}%`,t===null?this.root.removeAttribute("aria-valuenow"):this.root.setAttribute("aria-valuenow",String(Math.floor(t*100)))}hide(){this.root.hidden=!0}shown(){return!this.root.hidden}}const yc=12,OA=240,xA=1e3,SA=5e3,AA=3e3,da=650,EA=650;class DA{scene;wait;asking=!1;spaceKey="";landed=new Jm;canvas;title;state;empty;handlers;store;whole=!1;shown=!1;warming="";repaintTimer=null;lastReask=0;rememberTimer=null;storeKey=null;arrivalsKey="";feedsCount=null;disposed=!1;scale="jobs";view="feeds";inside=null;cluster=null;flying=!1;entering=null;facts;viewPill=null;gravityPill=null;densityPill=null;density="shape";drawMode="stars";drawPill=null;arrangement="galaxy";arrangementPill=null;scalePill=null;physics={...ol,gravity:!0};backPill;openPill;pane;escape_listen;reach=null;constructor(e,t,s){this.canvas=e.canvas,this.title=e.title,this.state=e.state,this.empty=e.empty,this.handlers=t,this.store=s,this.facts=e.facts,this.backPill=e.backPill,this.openPill=e.openPill,this.pane=e.canvas.closest(".workspace-pane"),this.wait=new vA(e.canvas),this.scene=new _l(e.canvas,{progress:(i,r,a)=>this.settle_progress(i,r,a),handoffKey:i=>{const r=i.id.match(/^feed:(\d+):/);if(r!==null)return`feed:${r[1]}`;const a=ep(i.id);return a===null?null:`fold:${a}`},tip:i=>this.inside===null?fA(i.id,this.landed)??eM(i.id,this.landed)??dA(i.id,this.landed):null,select:i=>this.node_select(i),activate:i=>this.node_dive(i),deselect:()=>this.facts_clear()}),e.backPill?.addEventListener("click",()=>this.ascend()),e.openPill?.addEventListener("click",()=>{this.inside!==null&&this.handlers.feed_open?.(this.inside.feedId)}),this.escape_listen=i=>{i.key!=="Escape"||this.inside===null&&this.cluster===null||this.flying||this.scene.holding_get()||this.pane!==null&&this.pane.offsetParent===null||this.ascend()},window.addEventListener("keydown",this.escape_listen),this.scene.strategy_set("molecule"),this.scene.physics_set(this.physics),e.projectionPill?.addEventListener("click",()=>{const i=this.scene.projection_get()==="3d"?"2d":"3d";this.scene.projection_set(i),e.projectionPill!==null&&(e.projectionPill.textContent=i.toUpperCase())}),e.refreshPill?.addEventListener("click",()=>this.request()),e.scalePill?.addEventListener("click",()=>{this.scale=this.scale==="jobs"?"feeds":"jobs",e.scalePill!==null&&(e.scalePill.textContent=this.scale==="jobs"?"JOBS":"ALIKE"),this.shown&&this.paint(!0,"full"),this.settings_save()}),e.viewPill?.addEventListener("click",()=>this.view_set(this.view==="feeds"?"shapes":"feeds")),this.viewPill=e.viewPill,this.gravityPill=e.gravityPill,e.gravityPill?.addEventListener("click",()=>{this.physics_set("gravity",!this.physics.gravity)}),this.densityPill=e.densityPill,e.densityPill?.addEventListener("click",()=>{this.density_set(this.density==="shape"?"census":"shape")}),this.drawPill=e.drawPill??null,this.scalePill=e.scalePill,e.drawPill?.addEventListener("click",()=>{this.draw_set(this.drawMode==="stars"?"spheres":"stars")}),this.arrangementPill=e.arrangementPill??null,e.arrangementPill?.addEventListener("click",()=>{this.arrangement_set(this.arrangement==="galaxy"?"spokes":this.arrangement==="spokes"?"clumps":"galaxy")}),this.scene.draw_set(this.drawMode),this.canvas.style.display="none",this.title_paint()}request(){this.asking=!0,this.shown||this.wait.show("ASKING THE SESSION FOR THE SPACE",null),this.title_paint(),this.handlers.command_run("proc universe")}settle_progress(e,t,s){if(e>=t){this.wait.hide(),this.remember_later();return}this.wait.show(`SETTLING ${s.toLocaleString("en-US")} SPHERES`,t===0?1:e/t)}envelope_observe(e){if(e.model?.kind!==Bp)return;const t=Rp.safeParse(e.model.data);t.success&&this.space_show(t.data)}promptContext_observe(e){if(this.disposed)return;this.identity_note(e.user,e.uri);const t=e.procWarmup?.landed??[];t.length>0&&this.shown&&this.landings_take(t);const s=e.procWarmup;if(s?.total!==void 0&&s.total>0&&s.sweeping!==!1&&!this.whole){const i=Math.floor(s.loaded/s.total*100),r=`INDEX WARMING ${s.loaded.toLocaleString()}/${s.total.toLocaleString()} (${i}%)`;r!==this.warming&&(this.warming=r,this.title_paint())}else this.shown&&!this.whole&&(s===void 0||s.sweeping===!1||s.state==="cached")&&(this.warming="",this.request());if(this.shown&&this.whole){const i=(s?.arrived??[]).join(","),r=e.procIndex?.feeds??null,a=i.length>0&&i!==this.arrivalsKey||r!==null&&this.feedsCount!==null&&r!==this.feedsCount;this.arrivalsKey=i,r!==null&&(this.feedsCount=r),a&&Date.now()-this.lastReask>SA&&(this.lastReask=Date.now(),this.request())}}size_fit(){this.scene.size_fit()}control(e,t){if(e==="enter"){const s=parseInt(t[0]??"",10);return Number.isFinite(s)?this.landed.get(s)===void 0?`universe enter: feed ${s} has not landed here`:this.inside!==null?`universe enter: already inside feed ${this.inside.feedId}; universe back first`:(this.descend(s),`entering feed ${s}`):"universe enter <feed id>"}if(e==="node"){const s=parseInt(t[0]??"",10);return Number.isFinite(s)?this.inside===null?"universe node: not inside a feed (universe enter <feed> first)":this.node_flyTo(s)?`flying into instance ${s}`:`universe node: no node of feed ${this.inside.feedId} hosts instance ${s}`:"universe node <instance id>: fly into the entered feed's node that hosts it"}if(e==="state"){const s=this.scene.state_get(),i=(()=>{const r=this.settingsKey_get();try{return r===null||this.store===void 0?null:this.store.getItem(r)}catch{return null}})();return[`universe: ${this.inside!==null?`inside feed ${this.inside.feedId}`:this.cluster!==null?"in a cluster":"the whole space"}; view ${this.view}, scale ${this.scale}, density ${this.density}`,`scene: ${Object.entries(s).map(([r,a])=>`${r}=${String(a)}`).join(" ")}`,`kept settings: ${i??"(none)"}`].join(`
4212
+ `)}if(e==="layout"){const s=(t[0]??"").toLowerCase();return s!=="galaxy"&&s!=="spokes"&&s!=="clumps"?"universe layout galaxy|spokes|clumps":this.arrangement_set(s)}if(e==="draw"){const s=(t[0]??"").toLowerCase();return s!=="stars"&&s!=="spheres"?"universe draw stars|spheres":this.draw_set(s)}if(e==="density"){const s=(t[0]??"").toLowerCase();return s!=="shape"&&s!=="census"?"universe density shape|census":this.density_set(s)}if(e==="physics"){const s=(t[0]??"").toLowerCase();if(s==="reset")return this.physics_reset();if(!["charge","link","collide","gravity"].includes(s))return"universe physics charge|link|collide|gravity [on|off] | reset";const i=(t[1]??"on").toLowerCase()!=="off";return this.physics_set(s,i)}if(e==="view"){const s=(t[0]??"").toLowerCase();return s!=="feeds"&&s!=="shapes"?"universe view feeds|shapes":this.inside!==null||this.cluster!==null?"universe view: climb out first (universe back)":(this.view_set(s),s==="feeds"?"every feed its own molecule":"the shapes folded, one molecule each")}if(this.flying&&(e==="enter"||e==="cluster"||e==="back"))return"universe: still moving; ask again";if(e==="cluster"){const s=parseInt(t[0]??"",10),i=Number.isFinite(s)?this.landed.get(s):void 0;return i===void 0?"universe cluster <feed id>: the cluster of a feed that landed here":this.inside!==null?`universe cluster: inside feed ${this.inside.feedId}; universe back first`:(this.cluster_enter(As(i)),`viewing the cluster of feed ${s}: ${yl(As(i))}`)}return e==="back"?this.inside===null&&this.cluster===null?"universe back: not inside a feed or a cluster":(this.ascend(),"climbing out"):e==="open"?this.inside===null?"universe open: not inside a feed":(this.handlers.feed_open?.(this.inside.feedId),`opening feed ${this.inside.feedId}`):"universe enter <feed>|node <instance>|cluster <feed>|view feeds|shapes|density shape|census|draw stars|spheres|layout galaxy|spokes|clumps|state|physics <term> on|off|reset|back|open"}physics_set(e,t){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":e==="reach"?"universe physics: reach is the pane's own":(this.physics={...this.physics,[e]:t},this.physics_apply(),`physics ${e} ${t?"on":"off"}`)}draw_set(e){return this.drawMode=e,this.drawPill!==null&&(this.drawPill.textContent=e.toUpperCase()),this.scene.draw_set(e),this.settings_save(),e==="stars"?"every sphere a point of light":"every sphere lit and solid"}arrangement_set(e){return this.arrangement=e,this.arrangementPill!==null&&(this.arrangementPill.textContent=e.toUpperCase()),this.remember_now(),this.inside===null&&this.cluster===null&&this.scene.arrangement_set(e,this.positions_recalled(e)),this.settings_save(),e==="galaxy"?"the space finds its own shape: every sphere pushing, every edge holding":e==="spokes"?"each molecule a spoke round its hub":"molecules packed round their hub"}settingsKey_get(){return this.storeKey===null?null:this.storeKey.replace(/^argus\.universe\./,"argus.universe.settings.")}settings_save(){const e=this.settingsKey_get();if(!(this.store===void 0||e===null))try{this.store.setItem(e,JSON.stringify(aA(this.drawMode,this.view,this.scale,this.density,this.arrangement)))}catch{}}settings_recall(){const e=this.settingsKey_get();if(this.store===void 0||e===null)return!1;let t=null;try{t=this.store.getItem(e)}catch{return!1}const s=oA(t),i=s.view!==this.view||s.scale!==this.scale;return this.drawMode=s.draw,this.view=s.view,this.scale=s.scale,this.density=s.density,this.arrangement=s.arrangement,this.arrangementPill!==null&&(this.arrangementPill.textContent=s.arrangement.toUpperCase()),this.scene.arrangement_set(s.arrangement,this.positions_recalled(s.arrangement)),this.drawPill!==null&&(this.drawPill.textContent=s.draw.toUpperCase()),this.viewPill!==null&&(this.viewPill.textContent=s.view.toUpperCase()),this.scalePill!==null&&(this.scalePill.textContent=s.scale==="jobs"?"JOBS":"ALIKE"),this.densityPill!==null&&(this.densityPill.textContent=s.density.toUpperCase()),this.scene.draw_set(s.draw),this.scene.census_set(s.density==="census"),i}density_set(e){return this.density=e,this.densityPill!==null&&(this.densityPill.textContent=e.toUpperCase()),this.scene.census_set(e==="census"),this.settings_save(),e==="census"?"every job its own point":"a stage one sphere, with its count"}physics_reset(){return this.inside!==null||this.cluster!==null?"universe physics: climb out first (universe back)":(this.physics={...ol,gravity:!0},this.physics_apply(),"physics reset")}physics_apply(){this.gravityPill!==null&&(this.gravityPill.textContent=this.physics.gravity?"GRAVITY ON":"GRAVITY OFF"),this.scene.physics_set({...this.physics,reach:this.reach??void 0}),this.title_paint()}view_set(e){this.view=e,this.viewPill!==null&&(this.viewPill.textContent=e.toUpperCase()),this.shown&&this.inside===null&&this.cluster===null&&this.paint(!0,"full"),this.settings_save()}inside_get(){return this.inside?.feedId??null}shown_get(){return this.shown}dispose(){this.disposed=!0,window.removeEventListener("keydown",this.escape_listen),this.repaintTimer!==null&&window.clearTimeout(this.repaintTimer),this.rememberTimer!==null&&window.clearTimeout(this.rememberTimer),this.remember_now(),this.scene.dispose()}space_show(e){this.asking=!1;const t=`${e.whole?"W":"L"}|${e.feeds.map(s=>`${s.id}:${s.jobs}:${s.status}`).join(",")}`;if(this.shown&&t===this.spaceKey){this.title_paint();return}this.spaceKey=t,this.wait.hide(),this.whole=e.whole,this.shown||(this.shown=!0,this.seed_recall()),this.landed.clear(),this.landed.take(e.feeds),this.whole&&(this.warming=""),this.empty.style.display="none",this.canvas.style.display="block",this.inside===null&&this.cluster===null&&this.entering===null&&!this.flying?this.paint(!this.scene.camera_touched()):this.title_paint()}landings_take(e){!this.landed.take(e)||this.repaintTimer!==null||this.inside!==null||this.cluster!==null||this.entering!==null||(this.repaintTimer=window.setTimeout(()=>{this.repaintTimer=null,!(this.disposed||this.entering!==null||this.inside!==null||this.cluster!==null||this.flying)&&this.paint(!this.scene.camera_touched())},xA))}paint(e=!0,t="new"){const s=this.view==="shapes"?nM(this.landed.all(),this.scale):Ia(this.landed.all(),this.scale),i=s.nodes.length<=OA?yc:void 0;i!==this.reach&&(this.reach=i,this.scene.physics_set({reach:i},!1)),this.scene.graph_set(s,{wave:!1,fit:e,settle:t}),this.title_paint(),this.remember_later()}descend(e,t){const s=this.landed.get(e),i=this.handlers.feed_dag;if(s===void 0||i===void 0||this.flying||this.inside!==null)return;this.flying=!0,this.facts_clear();const r=tM(e,s);this.entering=e,this.title_paint();const a=Date.now();(l=>{t!==void 0?this.scene.camera_flyToward(t,14,da,l):this.scene.camera_flyToFit(r,da,l)})(()=>{i(e).then(l=>{if(this.disposed)return;if(this.entering=null,l===null){this.flying=!1,this.title_paint(),this.handlers.note?.(`universe: feed ${e}: the session gave no graph for it (feed diagram feed_${e} refused or answered nothing after ${Math.round((Date.now()-a)/1e3)}s)`);return}const c=lA(l);for(const f of c.nodes)f.solid=!0;const d=this.scene.positions_get(),h=[0,0,0];let u=0;for(const f of[...r,...tp(As(s),this.landed)]){const S=d[f];if(S!==void 0&&(h[0]+=S[0],h[1]+=S[1],h[2]+=S[2],u+=1,u===r.length&&r.some(v=>d[v]!==void 0)))break}u>0&&(h[0]/=u,h[1]/=u,h[2]/=u);for(const f of c.nodes)d[f.id]=[h[0]+(Math.random()-.5)*.5,h[1]+(Math.random()-.5)*.5,h[2]+(Math.random()-.5)*.5];this.scene.positions_seed(d);const p=`feed:${e}:`,M=this.view==="feeds"?cA(this.landed.all(),e,c,this.scale):{nodes:[...sp(this.landed.all(),As(s),this.scale).graph.nodes.filter(f=>!f.id.startsWith(p)).map(f=>({...f,dim:!0})),...c.nodes]},_=new Set(c.nodes.map(f=>f.id)),m=M.nodes.filter(f=>!_.has(f.id)).map(f=>f.id);this.scene.graph_set(M,{wave:!1,fit:!1,frozen:m,physics:{reach:yc,gravity:!1}}),this.inside={feedId:e,title:l.feedName,entered:c,ids:new Set(c.nodes.map(f=>f.id))},this.pane?.classList.add("universe-inside"),this.title_paint(),this.scene.camera_flyToFit([...this.inside.ids],da,()=>{this.flying=!1},1,.95)})})}ascend(){if(!this.flying){if(this.inside!==null){if(this.inside=null,this.facts_clear(),this.pane?.classList.remove("universe-inside"),this.cluster!==null){this.cluster_show(this.cluster.shape);return}}else{if(this.cluster===null)return;this.cluster=null,this.pane?.classList.remove("universe-cluster")}this.flying=!0,this.paint(!1),this.scene.camera_flyToFit([],EA,()=>{this.flying=!1})}}cluster_enter(e){this.flying||this.inside!==null||this.cluster_show(e)}cluster_show(e){if(this.view==="feeds"){const d=uA(e,this.landed);if(d.length===0)return;this.flying=!0,this.cluster={shape:e,ids:d},this.pane?.classList.add("universe-cluster");const h=hA(this.landed.all(),e,this.scale);this.scene.graph_set(h,{wave:!1,fit:!1,frozen:h.nodes.map(u=>u.id)}),this.title_paint(),this.scene.camera_flyToFit(d,da,()=>{this.flying=!1});return}const{graph:t,memberIds:s}=sp(this.landed.all(),e,this.scale);if(s.length===0)return;this.flying=!0,this.cluster={shape:e,ids:s},this.pane?.classList.add("universe-cluster");const i=this.scene.positions_get(),r=tp(e,this.landed),a=[0,0,0];let o=0;for(const d of r){const h=i[d];h!==void 0&&(a[0]+=h[0],a[1]+=h[1],a[2]+=h[2],o+=1)}o>0&&(a[0]/=o,a[1]/=o,a[2]/=o);const l=new Set(s);for(const d of t.nodes)(l.has(d.id)||d.ghost===!0)&&(i[d.id]=[a[0]+(Math.random()-.5)*.5,a[1]+(Math.random()-.5)*.5,a[2]+(Math.random()-.5)*.5]);this.scene.positions_seed(i);const c=t.nodes.filter(d=>!l.has(d.id)&&d.ghost!==!0).map(d=>d.id);this.scene.graph_set(t,{wave:!1,fit:!1,frozen:c,physics:{reach:yc,gravity:!1}}),this.title_paint(),this.scene.camera_flyToFit(s,da,()=>{this.flying=!1})}node_dive(e){const t=this.inside?.entered.payloads.get(e.id),s=this.handlers.node_dive;t===void 0||s===void 0||this.flying||this.scene.flight_into(e.id,()=>s(t.vfsPath))}flight_back(e){this.scene.flight_back(e)}node_flyTo(e){if(this.inside===null)return!1;for(const[t,s]of this.inside.entered.payloads){if(s.instanceId!==e)continue;const i=this.handlers.node_dive;return i===void 0?!1:(this.scene.flight_into(t,()=>i(s.vfsPath)),!0)}return!1}node_select(e){if(this.flying)return;if(this.inside===null){const s=e.id.match(/^feed:(\d+):\d+$/),i=ep(e.id);s!==null?this.descend(Number(s[1]),e.id):i!==null?this.cluster_enter(i):e.id.startsWith("shape:")&&this.cluster_enter(e.id.slice(6));return}const t=this.inside.entered.payloads.get(e.id);t!==void 0&&this.facts_show(e,t)}facts_show(e,t){if(this.facts===null)return;this.facts.replaceChildren();const s=t.tally,i=[["PLUGIN",t.pluginName],[s?"REP. INSTANCE":"INSTANCE",String(t.instanceId)],["STATUS",t.status],...s?[["COUNT",`×${s.count} — ${s.done} done, ${s.error} err, ${s.running} live`]]:[],["DATA",t.vfsPath]];for(const[l,c]of i){const d=document.createElement("div");d.className="telemetry-row";const h=document.createElement("span");h.className="telemetry-label",h.textContent=l;const u=document.createElement("span");u.className="telemetry-value",u.textContent=c,d.append(h,u),this.facts.append(d)}const r=document.createElement("div");r.className="universe-node-verbs";const a=document.createElement("button");a.className="pacs-capsule universe-node-enter",a.textContent="ENTER NODE",a.title="fly into the node: its data, browsable inside (Esc flies out)",a.addEventListener("click",()=>{this.handlers.node_dive!==void 0?this.node_dive(e):this.handlers.node_enter?.(t.vfsPath)});const o=document.createElement("button");o.className="pacs-capsule universe-node-process",o.textContent="PROCESS",o.title="a catalogue bound to this node's data",o.addEventListener("click",()=>this.handlers.node_process?.({vfsPath:t.vfsPath,instanceId:t.instanceId,label:e.label})),r.append(a,o),this.facts.append(r),this.facts.hidden=!1}facts_clear(){this.facts!==null&&(this.facts.replaceChildren(),this.facts.hidden=!0)}title_paint(){if(this.entering!==null&&this.inside===null){const t=this.landed.get(this.entering);this.title.textContent=`UNIVERSE — ENTERING FEED ${this.entering}${t!==void 0&&t.title.length>0?` · ${t.title}`:""} …`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-wait"),this.state.textContent="ASKING");return}if(this.inside!==null){const t=this.inside.entered.nodes.reduce((s,i)=>s+(i.count??1),0);this.title.textContent=`UNIVERSE — INSIDE FEED ${this.inside.feedId} · ${this.inside.title} · ${t.toLocaleString("en-US")} JOBS`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-live"),this.state.textContent="INSIDE");return}if(this.cluster!==null){const t=this.landed.all().filter(s=>As(s)===this.cluster?.shape).length;this.title.textContent=`UNIVERSE — SHAPE ${sM(this.cluster.shape)} · ${t} FEED${t===1?"":"S"}`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-live"),this.state.textContent="CLUSTER");return}if(this.asking&&!this.shown){this.title.textContent="UNIVERSE — ASKING THE SESSION …",this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add("state-wait"),this.state.textContent="ASKING");return}const e=`${this.landed.size()} FEEDS · ${this.landed.shapes()} SHAPES`;this.title.textContent=this.whole?`UNIVERSE — ${e}`:`UNIVERSE — ${e}${this.warming.length>0?` · ${this.warming}`:" · INDEX WARMING"}`,this.state!==null&&(this.state.classList.remove("state-live","state-settled","state-stale","state-wait"),this.state.classList.add(this.whole?"state-settled":"state-wait"),this.state.textContent=this.whole?"WHOLE":"LANDING")}identity_note(e,t){const s=rA(e,t);if(s===this.storeKey)return;this.storeKey=s;const i=this.settings_recall();if(this.shown){const r=this.seed_recall();(i||r)&&this.inside===null&&this.cluster===null&&this.paint(!1)}}positionsKey_of(e){return this.storeKey===null?null:e==="galaxy"?this.storeKey:`${this.storeKey}.${e}`}positions_recalled(e){const t=this.positionsKey_of(e);if(!(this.store===void 0||t===null))try{const s=Jf(this.store.getItem(t));return Object.keys(s).length>0?s:void 0}catch{return}}seed_recall(){const e=this.positionsKey_of(this.arrangement);if(this.store===void 0||e===null)return!1;const t=Jf(this.store.getItem(e));return Object.keys(t).length===0?!1:(this.scene.positions_seed(t),!0)}remember_later(){this.rememberTimer===null&&(this.rememberTimer=window.setTimeout(()=>{this.rememberTimer=null,this.remember_now()},AA))}remember_now(){if(!(this.store===void 0||this.storeKey===null||!this.shown))try{const e=this.positionsKey_of(this.scene.arrangement_get());e!==null&&this.store.setItem(e,JSON.stringify(this.scene.positions_get()))}catch{}}}const ya=[];function IA(){const n=ya[ya.length-1];return n===void 0?!1:(n(),!0)}function TA(n){const e=n.querySelector(":scope > .pane-drawer");if(e!==null)return e.nextElementSibling;const t=n.querySelector(":scope > .lcars-terminal-header-bar");return t===null?n.firstElementChild:t.nextElementSibling}function vc(n,e){if(n.querySelector(":scope > .ask-bar")!==null)return Promise.resolve(null);const t=document.createElement("div");t.className="ask-bar";const s=document.createElement("span");s.className="ask-bar-glyph",s.textContent="?";const i=document.createElement("span");i.className="ask-bar-caption",i.textContent=e.message.trim(),t.append(s,i);const r=document.createElement("input"),a=document.createElement("button"),o=document.createElement("button"),l=document.createElement("button"),c=document.createElement("button");c.className="pacs-capsule ask-bar-abandon",c.textContent="ABANDON",c.title="abandon the question (Esc)",e.kind==="confirm"?(a.className="pacs-capsule ask-bar-yes",a.textContent="YES",o.className="pacs-capsule ask-bar-no",o.textContent="NO",t.append(a,o,c)):(r.className="ask-bar-field",r.spellcheck=!1,e.kind==="secret"?r.type="password":e.suggest!==void 0&&(r.value=e.suggest),l.className="pacs-capsule ask-bar-commit",l.textContent=e.commit??"ANSWER",t.append(r,l,c));const d=TA(n);return d===null?n.appendChild(t):n.insertBefore(t,d),window.requestAnimationFrame(()=>t.classList.add("ask-bar-shown")),new Promise(h=>{let u=!1;const p=m=>{if(u)return;u=!0;const f=ya.indexOf(M);f>=0&&ya.splice(f,1),t.remove(),h(m)},M=()=>p(null);ya.push(M);const _=()=>{const m=r.value.trim();p(m===""?null:m)};l.addEventListener("click",_),a.addEventListener("click",()=>p("y")),o.addEventListener("click",()=>p("n")),c.addEventListener("click",M),t.addEventListener("keydown",m=>{if(m.key==="Escape"){m.stopPropagation(),M();return}if(e.kind==="confirm"){m.key==="y"||m.key==="Y"?(m.stopPropagation(),p("y")):m.key==="n"||m.key==="N"||m.key==="Enter"&&m.target===o?(m.stopPropagation(),p("n")):m.key==="Enter"&&(m.stopPropagation(),p("y"));return}m.key==="Enter"&&(m.stopPropagation(),_())}),e.kind==="confirm"?a.focus():(r.focus(),r.select())})}const GA={"fs.listing":"files","feed.dag":"dag","feed.list":"dag","pacs.query":"pacs","dicom.series":"image","dicom.tags":"tags"};class RA{result;handlers;constructor(e,t){this.handlers=t,this.result=ua(e,".empty-result");const s=ua(e,".empty-prompt");s.addEventListener("keydown",i=>{i.key==="Enter"&&s.value.trim().length>0&&(this.line_run(s.value.trim()),s.value="")}),ua(e,".empty-go-files").addEventListener("click",()=>{this.line_run("ls .")}),ua(e,".empty-go-dag").addEventListener("click",()=>{this.line_run("proc feeds")}),ua(e,".empty-go-pacs").addEventListener("click",()=>{this.handlers.claim("pacs",[])}),window.setTimeout(()=>s.focus(),0)}async line_run(e){this.result.textContent="…";let t;try{t=await this.handlers.execute(e)}catch(i){this.result.textContent=i instanceof Error?i.message:String(i);return}for(const i of t.envelopes){const r=i.model?.kind!==void 0?GA[i.model.kind]:void 0;if(r!==void 0){this.handlers.claim(r,t.envelopes);return}}const s=t.envelopes.map(i=>i.rendered).join(`
4213
+ `);this.result.textContent=BA(s)||"(no output)"}}function ua(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`empty pane template is missing ${e}`);return t}function BA(n){return n.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}class NA{container;title;handlers;currentAddress=null;constructor(e,t,s){this.container=e,this.title=t,this.handlers=s,this.awaiting_render()}regard_show(e){if(this.currentAddress=e.address,this.title.textContent=`VIEWER — ${e.address}`.toUpperCase(),this.handlers.path_isImage(e.address)){this.container.replaceChildren();const t=document.createElement("img");t.className="files-image",t.src=this.handlers.imageUrl_build(e.address),t.alt=e.address,this.container.appendChild(t);return}this.handlers.content_fetch(e.address).then(t=>{if(this.currentAddress!==e.address)return;if(this.container.replaceChildren(),t.trim().length===0){const i=document.createElement("p");i.className="files-empty",i.textContent=`NO PREVIEW — ${e.address.toUpperCase()}`,this.container.appendChild(i);return}const s=document.createElement("pre");s.className="files-content",s.textContent=t,this.container.appendChild(s)})}awaiting_render(){this.container.replaceChildren();const e=document.createElement("p");e.className="files-empty",e.textContent="NO REGARD — INDICATE A FILE OR NODE IN THIS PANE’S GROUP",this.container.appendChild(e)}}const CA="modulepreload",PA=function(n,e){return new URL(n,e).href},ap={},op=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){let c=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");i=c(t.map(d=>{if(d=PA(d,s),d in ap)return;ap[d]=!0;const h=d.endsWith(".css"),u=h?'[rel="stylesheet"]':"";if(s)for(let M=a.length-1;M>=0;M--){const _=a[M];if(_.href===d&&(!h||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":CA,h||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),h)return new Promise((M,_)=>{p.addEventListener("load",M),p.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},WA=[{label:"",tag:"PatientName"},{label:"MRN",tag:"PatientID"},{label:"ACC",tag:"AccessionNumber"},{label:"",tag:"StudyDescription"},{label:"",tag:"SeriesDescription"},{label:"",tag:"StudyDate"},{label:"",tag:"PatientAge"},{label:"",tag:"PatientSex"}],LA=256*1024*1024;function yo(n){const e=["B","KB","MB","GB","TB"];let t=n,s=0;for(;t>=1024&&s<e.length-1;)t/=1024,s++;return s===0?`${n} B`:`${t.toFixed(1)} ${e[s]}`}function kA(n){const e=n.toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}class UA{pane;field;title;modeSpan;stateSpan;layoutPills=new Map;overlayPill;colormapPill;savePill;loadPill;presetPill;focusMark;guardBytes=LA;forced=!1;pendingLayout=null;progressNote=null;overlayNote=null;probeNote=null;overlay=!1;overlayLines=[];presetIndex=-1;toolPills=new Map;handlers;engine=null;series=null;siblings=[];colormap="gray";tool="wl";constructor(e,t){this.handlers=t,this.pane=e,this.field=Qs(e,".image-field"),this.title=Qs(e,".pane-title"),this.modeSpan=Qs(e,".pane-mode"),this.stateSpan=Qs(e,".pane-state");for(const s of e.querySelectorAll(".image-layout")){const i=s.dataset.layout??"single";this.layoutPills.set(i,s),s.addEventListener("click",()=>{this.layout_set(i)})}this.overlayPill=Qs(e,".image-overlay"),this.overlayPill.addEventListener("click",()=>{this.overlay_set(!this.overlay)}),this.colormapPill=Qs(e,".image-colormap"),this.savePill=Qs(e,".image-save"),this.loadPill=Qs(e,".image-load"),this.presetPill=Qs(e,".image-preset"),this.focusMark=Qs(e,".image-focus"),this.field.tabIndex=0,this.colormapPill.addEventListener("click",()=>{this.colormap_cycle()}),this.savePill.addEventListener("click",()=>{this.annotations_save()}),this.loadPill.addEventListener("click",()=>{this.load_press()}),this.presetPill.addEventListener("click",()=>this.preset_cycle()),Qs(e,".image-tags").addEventListener("click",()=>this.handlers.tags_open());for(const s of Af){const i=Qs(e,`.image-tool[data-tool="${s}"]`);this.toolPills.set(s,i),i.addEventListener("click",()=>{this.tool_set(s)})}this.toolPills_paint(),this.field.addEventListener("mousedown",()=>{this.field.focus(),this.focusMark_paint(!0)}),this.field.addEventListener("focusin",()=>this.focusMark_paint(!0)),this.field.addEventListener("focusout",s=>{(!(s.relatedTarget instanceof Node)||!this.field.contains(s.relatedTarget))&&this.focusMark_paint(!1)}),this.field.addEventListener("keydown",s=>{if(s.key==="Escape"){this.field_release(),s.stopPropagation();return}s.stopPropagation()})}field_hasFocus(){return document.activeElement instanceof Node&&this.field.contains(document.activeElement)}field_release(){return this.field_hasFocus()?(document.activeElement.blur(),this.focusMark_paint(!1),!0):!1}async series_show(e,t={}){if(this.engine_dispose(),this.series=e,this.forced=t.force===!0,this.pendingLayout=null,this.loadPill.hidden=!0,this.presets_paint(e.modality),this.siblings=t.siblings??[],this.pane.dataset.modality=kA(e.modality),this.title.textContent=`IMAGE ${e.modality.toUpperCase()} ${e.seriesDescription}`.trim(),this.title.title=this.title.textContent,this.siblings.length>1){const r=this.siblings.findIndex(a=>a.path===e.path)+1;this.handlers.note(`image: series ${r} of ${this.siblings.length} in this study; image series <n> switches`)}const{CornerstoneEngine:s}=await op(async()=>{const{CornerstoneEngine:r}=await import("./cornerstoneEngine-DeIhrHvT.js").then(a=>a.b2);return{CornerstoneEngine:r}},__vite__mapDeps([0,1]),import.meta.url),i=new s(this.engineHost_get(),e,t.startAt??1);await this.engine_open(i),this.engine===i&&(this.guard_trips()?(this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${yo(e.bytes)} · LOAD FOR STACK`,this.handlers.note(`image: ${yo(e.bytes)} to fetch before the stack scrolls; press LOAD, image load, or image --force <path>`)):i.slices_fill(),await this.annotations_reload(i,e))}async annotations_reload(e,t){let s=0;for(const i of t.annotations.filter(r=>/\.dcm$/i.test(r))){if(this.engine!==e)return;const r=i.split("/").pop()??i;try{const a=await fetch(this.handlers.source.url_of(i));if(!a.ok){this.handlers.note(`image: ${r}: HTTP ${a.status}`);continue}const o=await e.annotations_import(await a.arrayBuffer());s+=o,this.handlers.note(o>0?`image: ${o} measurement${o===1?"":"s"} from ${r}`:`image: ${r}: no measurements this engine can place`)}catch(a){this.handlers.note(`image: ${r}: ${a instanceof Error?a.message:String(a)}`)}}this.pane.dataset.annotations=String(s)}async volume_show(e){this.engine_dispose(),this.series=null,this.siblings=[],this.pane.dataset.modality="NIFTI",this.title.textContent=`IMAGE ${e.split("/").pop()??""}`,this.title.title=e,this.forced=!0,this.loadPill.hidden=!0,this.presets_paint("NIFTI");const{NiivueEngine:t}=await op(async()=>{const{NiivueEngine:s}=await import("./niivueEngine-CUXKkvoW.js");return{NiivueEngine:s}},[],import.meta.url);await this.engine_open(new t(this.engineHost_get(),e))}opening_show(e){const t=e.replace(/\/$/,"").split("/").pop()??e;this.stateSpan.textContent="OPENING",this.progress_show({label:`OPENING ${t}`,done:0,total:0})}opening_fail(e,t){this.stateSpan.textContent=t,this.progress_show({label:t,done:0,total:0});const s=this.progressNote;s!==null&&(s.classList.add("image-working-failed"),s.querySelector(".image-working-count").textContent=e)}siblings_get(){return this.siblings}series_get(){return this.series}state_get(){return this.engine===null?null:{...this.engine.state_get(),colormap:this.colormap,path:this.series?.path??null,guard:this.guardBytes,waiting:this.pendingLayout}}async layout_set(e){if(this.engine===null)return!1;if(e!=="single"&&this.guard_trips())return this.pendingLayout=e,this.loadPill.hidden=!1,this.stateSpan.textContent=`SERIES ${yo(this.series?.bytes??0)} · LOAD FOR ${e.toUpperCase()}`,this.handlers.note(`image: ${yo(this.series?.bytes??0)} to fetch for ${e}; press LOAD, image load, or image --force <path>`),!1;const t=this.engine.state_get().layout;return this.layoutPills_paint(e),this.modeSpan.textContent=e==="single"?"":e.toUpperCase(),this.overlay_hide(),await this.engine.layout_set(e)?(this.progress_show(null),this.overlay_paint(),this.toolPills_paint(),!0):(this.progress_show(null),this.layoutPills_paint(t),this.modeSpan.textContent=t==="single"?"":t.toUpperCase(),this.handlers.note(`image: layout ${e}: not offered by ${this.engine.name}`),!1)}layoutPills_paint(e){for(const[t,s]of this.layoutPills)s.classList.toggle("rail-off",t!==e)}guard_trips(){return this.guardBytes!==null&&!this.forced&&this.engine?.name==="cornerstone"&&(this.series?.bytes??0)>this.guardBytes}async load_press(){this.forced=!0,this.loadPill.hidden=!0;const e=this.pendingLayout;return this.pendingLayout=null,e!==null?this.layout_set(e):this.engine===null||this.engine.state_get().filled?!1:this.engine.slices_fill()}guard_set(e){this.guardBytes=e}guard_get(){return this.guardBytes}preset_cycle(){const e=this.presets_for(this.series?.modality??"NIFTI");if(e.length===0)return;this.presetIndex=(this.presetIndex+1)%e.length;const t=e[this.presetIndex];t!==void 0&&this.wl_set(t.lower,t.upper)&&(this.presetPill.textContent=t.name.toUpperCase())}presets_for(e){const t=e.toUpperCase();return km.filter(s=>s.modalities.length===0||s.modalities.includes(t))}presets_paint(e){this.presetIndex=-1;const t=this.presets_for(e);this.presetPill.hidden=t.length===0,this.presetPill.textContent="PRESET"}slice_set(e){if(this.engine===null)return!1;const t=this.engine.slice_set(e);return t||this.handlers.note(`image: slice ${e}: not offered in ${this.engine.state_get().layout} layout by ${this.engine.name}`),t}wl_set(e,t){if(this.engine===null)return!1;const s=this.engine.wl_set(e,t);return s||this.handlers.note(`image: wl: not offered by ${this.engine.name}`),s}ghost_set(e){if(this.engine===null)return!1;const t=this.engine.ghost_set(e);return t||this.handlers.note("image: ghost applies to the SLAB layout"),t}wlPreset_set(e){const t=this.series?.modality??"NIFTI",s=wS(e,t);return s===void 0?(this.handlers.note(`image: wl preset ${e}: none for ${t}`),!1):this.wl_set(s.lower,s.upper)}colormap_set(e){return this.engine===null?!1:this.engine.colormap_set(e)?(this.colormap=e,this.colormapPill.textContent=e.toUpperCase(),!0):(this.handlers.note(`image: colormap ${e}: not offered by ${this.engine.name}`),!1)}tool_set(e){return this.engine===null?!1:this.engine.tool_set(e)?(this.tool=e,this.toolPills_paint(),!0):(this.handlers.note(`image: ${e}: not offered by ${this.engine.name}`),!1)}async annotations_save(){if(this.engine===null)return!1;const e=this.series?.seriesInstanceUID,t=/^(\/home\/[^/]+)\//.exec(this.series?.path??"")?.[1];if(e===void 0||t===void 0)return this.handlers.note("image: save: this series has no UID to file an annotation under"),!1;const s=await this.engine.annotations_export();if(s===null)return this.handlers.note(`image: save: nothing measured, or ${this.engine.name} writes no report`),!1;const i=`${t}/annotations/${e}/measurements.dcm`,r=await this.handlers.file_put(i,s);return this.handlers.note(r===200?`✓ ${i}`:`image: save: ${i}: HTTP ${r}`),r===200}dispose(){this.engine_dispose()}async colormap_cycle(){const e=Co[(Co.indexOf(this.colormap)+1)%Co.length]??"gray";this.colormap_set(e)}async engine_open(e){this.engine=e,this.field.replaceChildren(),this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.layoutPills_paint("single"),this.modeSpan.textContent="",this.colormapPill.textContent=this.colormap.toUpperCase();try{await e.open(this.field)}catch(s){this.stateSpan.textContent="REFUSED",this.handlers.note(`image: ${s instanceof Error?s.message:String(s)}`);return}const t=e.state_get().layout;this.layoutPills_paint(t),this.modeSpan.textContent=t==="single"?"":t.toUpperCase(),e.tool_set(this.tool),this.toolPills_paint(),this.progress_show(null),this.overlay_fill()}engine_dispose(){this.engine?.dispose(),this.engine=null,this.progressNote=null,this.overlayNote=null,this.probeNote=null,this.field.replaceChildren(),this.stateSpan.textContent=""}engineHost_get(){return{source:this.handlers.source,readout_set:e=>{this.stateSpan.textContent=e},progress_set:e=>this.progress_show(e),note:this.handlers.note,regard:e=>{this.handlers.regard(e),this.overlaySlice_paint()},probe_set:e=>this.probe_show(e)}}probe_show(e){if(e===null){this.probeNote?.remove(),this.probeNote=null;return}if(this.probeNote===null||this.probeNote.parentElement===null){const t=document.createElement("div");t.className="image-probe-note",this.field.appendChild(t),this.probeNote=t}this.probeNote.textContent=e}overlaySlice_paint(){const e=this.overlayNote?.querySelector(".image-overlay-slice")??null;if(e===null||this.engine===null)return;const t=this.engine.state_get();e.textContent=t.slices>1?`SLICE ${Math.max(1,t.slice)} OF ${t.slices}`:"",e.hidden=t.slices<=1}progress_show(e){if(e===null){this.progressNote?.remove(),this.progressNote=null;return}if(this.progressNote===null||this.progressNote.parentElement===null){const a=document.createElement("div");a.className="image-working",a.innerHTML='<span class="image-working-label"></span><span class="image-working-track"><span class="image-working-fill"></span></span><span class="image-working-count"></span>',this.field.appendChild(a),this.progressNote=a}const t=this.progressNote;t.classList.remove("image-working-failed");const s=e.total>0,i=s?Math.min(1,e.done/e.total):0;t.querySelector(".image-working-label").textContent=e.label,t.querySelector(".image-working-count").textContent=s?`${e.done} / ${e.total} · ${Math.round(i*100)}%`:"";const r=t.querySelector(".image-working-fill");r.classList.toggle("image-working-pacing",!s),r.style.width=s?`${Math.round(i*100)}%`:""}async overlay_set(e){if(this.overlay=e,this.overlayPill.textContent=e?"OVERLAY ON":"OVERLAY OFF",this.overlayPill.classList.toggle("rail-off",!e),!e){this.overlay_hide();return}await this.overlay_fill()}overlay_hide(){this.overlayNote?.remove(),this.overlayNote=null}async overlay_fill(){if(!this.overlay||this.series===null)return;const e=this.series.files[0]??this.series.path,t=await this.handlers.tags_read(e);if(t===null){this.handlers.note(`image: overlay: ${e}: no header to read`);return}this.overlayLines=WA.flatMap(s=>{const r=(t.constant.find(a=>a.name===s.tag)?.value??"").trim();return r===""?[]:[s.label===""?r:`${s.label} ${r}`]}),this.overlay_paint()}overlay_paint(){if(!this.overlay||this.overlayLines.length===0)return;this.overlay_hide();const e=document.createElement("div");e.className="image-overlay-note";const t=document.createElement("span");t.className="image-overlay-slice",e.appendChild(t);for(const s of this.overlayLines){const i=document.createElement("span");i.textContent=s,e.appendChild(i)}this.field.appendChild(e),this.overlayNote=e,this.overlaySlice_paint()}toolPills_paint(){const e=new Set(this.engine?.toolsOffered_get()??Af),t=this.engine!==null?this.engine.state_get().primaryTool:this.tool;for(const[s,i]of this.toolPills){const r=e.has(s);i.classList.toggle("rail-na",!r),i.classList.toggle("rail-off",r&&s!==t),i.disabled=!r}}focusMark_paint(e){this.focusMark.hidden=!e,this.pane.classList.toggle("image-field-focused",e)}}function Qs(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`image pane: missing ${e}`);return t}const aM=["patient","study","series","image","equipment","meta","private","other","varying"],FA=new Set(["meta","private"]),lp="••••";class jA{pane;title;modeSpan;redactBlock;listing;handlers;redact=!0;model=null;groups=[];constructor(e,t){this.handlers=t,this.pane=e,this.title=vo(e,".pane-title"),this.modeSpan=vo(e,".pane-mode"),this.redactBlock=vo(e,".tags-redact"),this.redactBlock.addEventListener("click",()=>this.redact_set(!this.redact));const s=vo(e,".tags-panel");this.listing=new Ur({mount:s,traits:this.groupTraits_declare(),key:i=>i.group,chrome:{root:e,prefix:"tags"},caps:"root",row:{className:()=>"tags-group-row",groupClassName:i=>`tags-group tags-group-${i.group}`,decorate:i=>{i.title="fold this group open or shut (it keeps its place)"}},child:Rr(i=>i.rows,{traits:this.tagTraits_declare(),key:i=>i.key,activatable:i=>i.items.length>0,row:{className:i=>`tags-row${i.phi?" tags-phi":""}`,groupClassName:()=>"tags-sequence",decorate:(i,r)=>{i.title=r.items.length>0?`${r.name}: fold the sequence open or shut`:`${r.tag} ${r.name}`}},child:Rr(i=>i.items,{traits:this.itemTraits_declare(),key:i=>i.key,row:{className:()=>"tags-item-row",groupClassName:()=>"tags-item"},child:Rr(i=>i.rows,{traits:this.tagTraits_declare(),key:i=>i.key,activatable:()=>!1,row:{className:i=>`tags-row tags-row-deep${i.phi?" tags-phi":""}`}})})}),state:i=>this.stateLine_compose(i),empty:()=>qA("NO TAGS")}),this.redactBlock_paint(),this.listing.rows_set([],{field:"tags"})}model_show(e){this.model=e,this.title.textContent=`TAGS ${$A(e)}`,this.pane.dataset.modality=HA(e),this.groups=VA(e),this.listing.rows_set([{key:e.path,rows:this.groups}],{field:e.path}),this.listing.open_set(0,this.groups.map(t=>t.group).filter(t=>!FA.has(t))),this.modeSpan.textContent=e.subject==="folder"?"FOLDER":""}path_get(){return this.model?.path??null}redact_get(){return this.redact}redact_set(e){this.redact=e,this.redactBlock_paint(),this.model!==null&&this.listing.rows_set([{key:this.model.path,rows:this.groups}],{field:this.model.path})}filter_set(e){if(e===null){this.listing.filter_toggle(!1);return}this.listing.filter_toggle(!0),this.listing.filter_set(e)}stateLine_compose(e){const t=this.groups.reduce((i,r)=>i+r.rows.length,0),s=[];return this.model!==null&&this.model.subject==="folder"&&(s.push(this.model.read===this.model.of?`${this.model.read} FILES`:`${this.model.read} OF ${this.model.of} FILES`),this.model.refused.length>0&&s.push(`REFUSED ${this.model.refused.length}`)),s.push(e.filter!==""?e.filter:`${t} TAGS`),this.redact&&s.push("REDACTED"),s.join(" · ")}redactBlock_paint(){this.redactBlock.textContent=this.redact?"REDACT ON":"REDACT OFF",this.redactBlock.classList.toggle("rail-off",!this.redact),this.pane.classList.toggle("tags-redacted",this.redact)}value_cell(e){const t=document.createElement("span");if(t.className="tags-value",e.phi&&this.redact)return t.textContent=lp,t.title="identifying value, redacted; the REDACT block on the frame reveals it",t;if(t.textContent=e.value,e.decoded!==void 0){const s=document.createElement("span");s.className="tags-decoded",s.textContent=` ${e.decoded}`,t.appendChild(s)}if(e.distinct!==void 0){const s=document.createElement("span");s.className="tags-decoded",s.textContent=` (${e.distinct} distinct)`,t.appendChild(s)}return t}groupTraits_declare(){return[Oc(()=>!0),{key:"group",label:"GROUP",className:"tags-group-name",width:"minmax(12em, 1fr)",cell:e=>e.group.toUpperCase(),compare:e=>aM.indexOf(e.group)},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}tagTraits_declare(){return[Oc(e=>e.items.length>0),{key:"tag",label:"TAG",className:"tags-tag",width:"7em",cell:e=>e.tag,compare:e=>e.tag},{key:"name",label:"NAME",className:"tags-name",width:"minmax(8em, 1.4fr)",cell:e=>e.name,compare:e=>e.name.toLowerCase()},{key:"vr",label:"VR",className:"tags-vr",width:"2.4em",cell:e=>e.vr,compare:e=>e.vr},{key:"value",label:"VALUE",className:"tags-value-cell",width:"minmax(6em, 2fr)",cell:e=>this.value_cell(e),compare:e=>(e.phi&&this.redact?lp:`${e.value} ${e.decoded??""}`).toLowerCase()}]}itemTraits_declare(){return[Oc(()=>!0),{key:"item",label:"ITEM",className:"tags-item-name",width:"minmax(12em, 1fr)",cell:e=>`ITEM ${e.index}`,compare:e=>e.index},{key:"count",label:"TAGS",className:"tags-group-count",width:"5em",cell:e=>String(e.rows.length),compare:e=>e.rows.length}]}}function Oc(n){return{key:"fold",label:"",className:"tags-fold",capped:!1,width:"1.4em",cell:e=>{const t=document.createElement("span");return t.className=n(e)?"tags-fold":"tags-fold tags-fold-none",t}}}function VA(n){const e=new Map;for(const t of n.constant){const s=t.group;e.has(s)||e.set(s,[]),e.get(s)?.push(oM(t,`${s}/${t.tag}`))}return n.varying.length>0&&e.set("varying",n.varying.map(t=>({tag:t.tag,name:t.name,vr:t.vr,value:t.distinct===1?t.first:`${t.first} .. ${t.last}`,phi:t.phi,items:[],distinct:t.distinct,key:`varying/${t.tag}`}))),aM.filter(t=>e.has(t)).map(t=>({group:t,rows:e.get(t)??[]}))}function oM(n,e){return{tag:n.tag,name:n.name,vr:n.vr,value:n.value,...n.decoded!==void 0?{decoded:n.decoded}:{},phi:n.phi,items:(n.items??[]).map((t,s)=>({index:s+1,key:`${e}/${s+1}`,rows:t.map(i=>oM(i,`${e}/${s+1}/${i.tag}`))})),key:e}}function $A(n){const e=n.path.replace(/\/$/,"").split("/").pop()??n.path;if(n.subject==="folder")return e.length>24?`${e.slice(0,22)}…`:e;const t=/^(\d+)-/.exec(e)?.[1];return t!==void 0?`INSTANCE ${Number(t)}`:e.length>24?`${e.slice(0,22)}…`:e}function HA(n){const e=(n.constant.find(t=>t.name==="Modality")?.value??"").toUpperCase();return e==="MR"||e==="CT"||e==="PT"?e:"OT"}function qA(n){const e=document.createElement("div");return e.className="tags-note",e.textContent=n,e}function vo(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`tags pane: missing ${e}`);return t}class XA{groups=new Map;membership=new Map;writeObserver=null;writeObserver_set(e){this.writeObserver=e}pane_join(e,t){this.pane_leave(e),this.membership.set(e,t),this.groups.has(t)||this.groups.set(t,{value:null,subscribers:new Map,viewers:new Set})}pane_leave(e){const t=this.membership.get(e);if(t===void 0)return;this.membership.delete(e);const s=this.groups.get(t);if(s!==void 0){s.subscribers.delete(e),s.viewers.delete(e);for(const i of this.membership.values())if(i===t)return;this.groups.delete(t)}}group_of(e){const t=this.membership.get(e);return t!==void 0?t:(this.pane_join(e,e),e)}viewer_mark(e){this.groups.get(this.group_of(e))?.viewers.add(e)}groupHasViewer(e){const t=this.groups.get(this.group_of(e));return t!==void 0&&t.viewers.size>0}regard_write(e,t){const s=this.group_of(e),i=this.groups.get(s),r={...t,paneId:e};i.value=r;for(const a of i.subscribers.values())a(r);this.writeObserver?.(r,s)}regard_subscribe(e,t){const s=this.groups.get(this.group_of(e));s.subscribers.set(e,t),s.value!==null&&t(s.value)}regard_get(e){return this.groups.get(this.group_of(e))?.value??null}}const xc=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],YA=new Set(["done","error","unconfirmed","stalled","timeout"]);function KA(n,e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const s=`${e.operation}:`;for(const i of[...n])(i===t||i.startsWith(s))&&n.delete(i);return}if(e.itemId!==void 0&&e.status!==void 0&&YA.has(e.status)){n.delete(t);return}n.add(t)}const ZA=100;class QA{fields;running=new Set;activityTimer=null;activityFrame=0;constructor(e){this.fields={identity:Bi(e,"status-identity"),jobs:Bi(e,"status-jobs"),activity:Bi(e,"status-activity"),latency:Bi(e,"status-latency"),mismatch:Bi(e,"status-mismatch"),lamp:Bi(e,"status-lamp"),host:Bi(e,"status-host")}}attach_show(e){if(e.protocolVersion!==Ec){this.fields.mismatch.textContent=`WIRE V${e.protocolVersion} ≠ V${Ec}`,this.fields.mismatch.title="This surface and the daemon speak different contract versions. Some messages may be dropped.",this.hostControl_show(e.hostControl??[]);return}this.fields.mismatch.textContent="",this.fields.mismatch.title=e.stack!==void 0?`chell ${e.stack.chell} · calypso ${e.stack.calypso} · build ${e.stack.build}`:"",this.hostControl_show(e.hostControl??[])}hostControl_show(e){this.fields.host.textContent=e.length>0?`HOST ${e.join(" ")}`:"",this.fields.host.title=e.length>0?"Calypso was started with --host-control: `!` and pipes run on its host, upload/download reach its disk.":""}promptContext_show(e){const t=e.uri.replace(/^https?:\/\//,"");this.fields.identity.textContent=`${e.user}@${t}`.toUpperCase();const s=e.procWarmup,i=[];if(s!==void 0&&s.sweeping!==!1){const o=s.total!==void 0?`/${s.total}`:"",l=s.state!==void 0?` ${s.state.toUpperCase()}`:"";i.push(`JOBS ${s.loaded}${o}${l}`)}const r=s?.feeds??(s?.feed!==void 0?[s.feed]:[]);for(const o of r){const l=o.total>0?`/${o.total}`:"";i.push(o.failed!==void 0?`FEED ${o.id} FAILED ${o.loaded}${l}`:`FEED ${o.id} ${o.loaded}${l}`)}s?.roster!==void 0&&i.push(s.roster==="full"?"ROSTER WALK":"ROSTER DELTA"),s?.arrived!==void 0&&s.arrived.length>0&&i.push(s.arrived.length<=2?`+FEED ${s.arrived.join(" ")}`:`+${s.arrived.length} FEEDS`);const a=e.warmupFailures??[];a.length>0&&i.push(`WARM-UP FAILED: ${a.map(o=>o.label.toUpperCase()).join(" ")}`),this.fields.jobs.textContent=i.join(" · "),this.fields.jobs.classList.toggle("status-degraded",a.length>0),this.fields.jobs.title=a.length>0?a.map(o=>`${o.label}: ${o.message}`).join(`
4214
+ `):r.length>0?"A feed is being indexed on its first visit; it opens when the walk completes.":"",this.fields.latency.textContent=e.lastCommandDurationMs>0?`${e.lastCommandDurationMs}MS`:""}progress_observe(e){KA(this.running,e),this.activity_paint()}activity_clear(){this.running.clear(),this.activity_paint()}connection_show(e){this.fields.lamp.textContent=e?"ONLINE":"OFFLINE",this.fields.lamp.classList.toggle("lamp-online",e),this.fields.lamp.classList.toggle("lamp-offline",!e),e||this.activity_clear()}activity_paint(){if(this.running.size===0){this.activityTimer!==null&&(clearInterval(this.activityTimer),this.activityTimer=null),this.fields.activity.textContent="";return}const e=()=>{const t=xc[this.activityFrame]??xc[0];this.fields.activity.textContent=`${t} ${this.running.size} RUNNING`};e(),this.activityTimer===null&&(this.activityTimer=window.setInterval(()=>{this.activityFrame=(this.activityFrame+1)%xc.length,e()},ZA))}}function Bi(n,e){const t=n.getElementById(e);if(t===null)throw new Error(`status bar: no element with id '${e}'`);return t}function JA(n){return n>=6e4?`${Math.max(1,Math.round(n/6e4))} MIN`:`${Math.max(1,Math.round(n/1e3))} S`}function Js(n){return n.toLocaleString("en-US")}class eE{mount;counts=null;context=null;msPerPage=null;walkSamples=new Map;clock;acts;state=void 0;constructor(e,t=()=>Date.now(),s={}){this.mount=e,this.clock=t,this.acts=s,this.render()}state_show(e){this.state=e,this.render()}pace_show(e){this.msPerPage=e,this.render()}eta_of(e,t,s){const i=this.clock(),r=this.walkSamples.get(e);let a=r?.rowsPerMs??null;r!==void 0&&t>r.loaded&&i>r.at&&(a=(t-r.loaded)/(i-r.at)),(r===void 0||t!==r.loaded)&&this.walkSamples.set(e,{loaded:t,at:i,rowsPerMs:a});const o=Math.max(0,s-t);return s<=0?null:a!==null&&a>0?o/a:this.msPerPage!==null&&this.msPerPage>0?Math.ceil(o/100/4)*this.msPerPage:null}counts_show(e){this.counts=e,this.render()}promptContext_show(e){this.context=e,e.procIndex!==void 0&&(this.counts={jobs:e.procIndex.jobs,feeds:e.procIndex.feeds}),this.render()}rows_compose(){const e=[],t=this.context?.procWarmup,s=this.context?.warmupFailures??[],i=t!==void 0&&t.sweeping!==!1,r=this.counts!==null?`${Js(this.counts.jobs)} JOBS · ${Js(this.counts.feeds)} FEEDS`:"";if(s.length>0)e.push({label:"INDEX",bar:null,value:`${r}${r?" · ":""}FAILED: ${s.map(l=>l.label.toUpperCase()).join(" ")}`,title:s.map(l=>`${l.label}: ${l.message}`).join(`
4215
+ `),degraded:!0});else if(i&&t!==void 0){const l=(t.state??"cold").toUpperCase();e.push({label:"INDEX",bar:{loaded:t.loaded,total:t.total??0,state:t.state==="failed"?"failed":"running"},value:`SWEEP ${Js(t.loaded)} / ${t.total!==void 0?Js(t.total):"?"} · ${l}`,title:"The global topology sweep: every plugin instance CUBE holds, walked page by page.",degraded:t.state==="failed"})}else e.push({label:"INDEX",bar:null,value:r?`${r} · CURRENT`:"CURRENT",title:"Nothing is moving: the process index is whole and current.",degraded:!1});if(this.state!==void 0){const l=this.state;e.push({label:"RUNNING",bar:null,value:`${Js(l.running)} IN ${Js(l.runningFeeds)} FEEDS · SCHEDULED ${Js(l.scheduled)}`,title:"Jobs running and waiting across every feed the index holds, from the roster's own counters.",degraded:!1,verb:this.acts.errored_open!==void 0?{label:`ERRORED ${Js(l.errored)} IN ${Js(l.erroredFeeds)} FEEDS`,title:"Open the runs roster filtered to the feeds with errored jobs.",act:this.acts.errored_open}:null})}const a=t?.feeds??(t?.feed!==void 0?[t.feed]:[]);for(const l of Array.from(this.walkSamples.keys()))a.some(c=>c.id===l)||this.walkSamples.delete(l);for(const l of a){const c=l.total>0?Js(l.total):"?";if(l.failed!==void 0)e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"failed"},value:`FAILED AT ${Js(l.loaded)} / ${c} · ${l.failed.toUpperCase()}`,title:"The walk stopped; the next visit to the feed starts it again.",degraded:!0});else{const d=this.eta_of(l.id,l.loaded,l.total);e.push({label:`FEED ${l.id}`,bar:{loaded:l.loaded,total:l.total,state:"running"},value:`INDEXING ${Js(l.loaded)} / ${c}${d!==null?` · ETA ${JA(d)}`:""}`,title:"A feed is being indexed on its first visit; it opens when the walk lands.",degraded:!1})}}t?.roster!==void 0&&e.push({label:"ROSTER",bar:null,value:t.roster==="full"?"FULL WALK · every feed the identity can see":"DELTA · feeds newer than the roster knows",title:"The roster is being brought up to date; the listing answered from the cache and refreshes when arrivals land.",degraded:!1});const o=t?.arrived??[];return o.length>0&&e.push({label:"ARRIVED",bar:null,value:o.length<=3?o.map(l=>`FEED ${l}`).join(" · "):`${o.length} FEEDS`,title:"Feeds the roster gained: created here, or shared with this identity.",degraded:!1}),e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const t of e){const s=document.createElement("div");s.className="index-row telemetry-row",s.classList.toggle("status-degraded",t.degraded),s.title=t.title;const i=document.createElement("span");if(i.className="telemetry-label",i.textContent=t.label,s.appendChild(i),t.bar!==null){const a=document.createElement("span");a.className=`index-bar listing-progress listing-progress-${t.bar.state}`;const o=document.createElement("span");o.className="listing-progress-fill";const l=t.bar.total>0?Math.min(100,Math.round(t.bar.loaded/t.bar.total*100)):0;o.style.width=`${l}%`,a.appendChild(o),s.appendChild(a)}const r=document.createElement("span");if(r.className="telemetry-value",r.textContent=t.value,s.appendChild(r),t.verb!==void 0&&t.verb!==null){const a=document.createElement("button");a.type="button",a.className="index-verb pacs-capsule",a.textContent=t.verb.label,a.title=t.verb.title,a.addEventListener("click",t.verb.act),s.appendChild(a)}this.mount.appendChild(s)}}}const tE=3e3;class sE{mount;clock;lane=void 0;cube=void 0;beatAt=null;constructor(e,t=()=>Date.now()){this.mount=e,this.clock=t,this.render()}telemetry_show(e={}){this.beatAt=this.clock(),e.lane!==void 0&&(this.lane=e.lane),e.cube!==void 0&&(this.cube=e.cube),this.render()}tick(){this.render()}rows_compose(){const e=[],t=this.lane;if(t===void 0)e.push({label:"LANE",value:"—",title:"The daemon has not said what holds its lane (an older daemon).",degraded:!1});else if(t.running===null)e.push({label:"LANE",value:t.waiting>0?`IDLE · ${t.waiting} WAITING`:"IDLE",title:"The serialized command lane: nothing is executing.",degraded:!1});else{const i=(t.running.sinceMs/1e3).toFixed(1);e.push({label:"LANE",value:`${t.running.line} · ${i} S${t.waiting>0?` · ${t.waiting} WAITING`:""}`,title:`The command holding the lane${t.running.surface?`, from surface ${t.running.surface}`:""}; every other command waits behind it.`,degraded:t.running.sinceMs>=1e4})}if(this.beatAt===null)e.push({label:"BEAT",value:"NONE YET",title:"No telemetry heartbeat has landed.",degraded:!1});else{const i=Math.max(0,this.clock()-this.beatAt);e.push({label:"BEAT",value:`${(i/1e3).toFixed(1)} S AGO`,title:"The age of the last telemetry heartbeat; the daemon beats once a second while a surface is attached.",degraded:i>=tE})}const s=this.cube;if(s===void 0)e.push({label:"CUBE",value:"NO PAGE TIMED",title:"CUBE's pace is known once a page of a list has been fetched.",degraded:!1});else{const i=s.msPerPage>0?Math.round(6e4/s.msPerPage):0;e.push({label:"CUBE",value:`${(s.msPerPage/1e3).toFixed(1)} S/PAGE · ${i} PAGES/MIN`,title:`The median of the last ${s.samples} page fetches (100 rows each).`,degraded:!1})}return e}render(){const e=this.rows_compose();this.mount.replaceChildren();for(const t of e){const s=document.createElement("div");s.className="lane-row telemetry-row",s.classList.toggle("status-degraded",t.degraded),s.title=t.title;const i=document.createElement("span");i.className="telemetry-label",i.textContent=t.label;const r=document.createElement("span");r.className="telemetry-value",r.textContent=t.value,s.append(i,r),this.mount.appendChild(s)}}}const nE=[2,3,3,2,2,11,2,2],iE=4,cp=300,rE=2600,aE=650;class oE{wrapper;cells=[];bootedAt=Date.now();telemetry={jobsLoaded:0,jobsTotal:0,feeds:0,lastLatencyMs:0,latencySumMs:0,lastExitCode:0,commandsRun:0,opsActive:0,opsDone:0,opsFailed:0,itemsCurrent:0,itemsTotal:0,connected:0};activeOperations=new Set;telemetryRows=[];constructor(e){if(this.wrapper=e,e===null){window.setInterval(()=>this.beat_paint(),cp);return}const t=this.narrowSources_list(),s=this.wideSources_list();let i=0,r=0;for(const a of nE){const o=document.createElement("div");o.className="data-column";for(let l=1;l<=iE;l++){const c=document.createElement("div");c.className=`dc-row-${l}`;let d;a>=6?(d=s[r%s.length],r++):(d=t[i%t.length],i++);const h={element:c,width:a,source:d??(()=>0)};c.textContent=dp(h.source(),a),o.appendChild(c),this.cells.push(h)}e.appendChild(o)}window.setInterval(()=>this.beat_paint(),cp),this.sweep_start()}promptContext_observe(e){const t=e.procWarmup;t!==void 0&&(this.telemetry.jobsLoaded=t.loaded,this.telemetry.jobsTotal=t.total??t.loaded);const s=e.procIndex;s!==void 0&&(t===void 0&&(this.telemetry.jobsLoaded=s.jobs,this.telemetry.jobsTotal=s.jobs),this.telemetry.feeds=s.feeds),e.lastCommandDurationMs>0&&(this.telemetry.lastLatencyMs=e.lastCommandDurationMs,this.telemetry.latencySumMs+=e.lastCommandDurationMs,this.telemetry.commandsRun++),this.telemetry.lastExitCode=e.lastExitCode}progress_observe(e){const t=`${e.operation}:${e.itemId??""}`;if(e.phase==="complete"||e.phase==="failed"){const s=`${e.operation}:`;for(const i of[...this.activeOperations])(i===t||i.startsWith(s))&&this.activeOperations.delete(i);e.status==="error"||e.phase==="failed"?this.telemetry.opsFailed++:this.telemetry.opsDone++}else e.itemId!==void 0&&e.status!==void 0&&["done","error","unconfirmed","stalled","timeout"].includes(e.status)?this.activeOperations.delete(t):this.activeOperations.add(t);this.telemetry.opsActive=this.activeOperations.size,e.current!==void 0&&(this.telemetry.itemsCurrent=e.current),e.total!==void 0&&(this.telemetry.itemsTotal=e.total)}index_observe(e){this.telemetry.jobsLoaded=e.jobs,this.telemetry.jobsTotal=e.jobs,this.telemetry.feeds=e.feeds}connection_show(e){this.telemetry.connected=e?1:0,this.wrapper?.classList.toggle("dc-stale",!e)}telemetryPanel_bind(e){const t=this.telemetry,s=[["LINK",()=>t.connected===1?"ONLINE":"OFFLINE"],["JOBS INDEXED",()=>`${t.jobsLoaded} / ${t.jobsTotal}`],["FEEDS VISIBLE",()=>String(t.feeds)],["OPS ACTIVE",()=>String(t.opsActive)],["OPS DONE",()=>String(t.opsDone)],["OPS FAILED",()=>String(t.opsFailed)],["ITEMS",()=>`${t.itemsCurrent} / ${t.itemsTotal}`],["LAST COMMAND",()=>`${t.lastLatencyMs} MS`],["LATENCY SUM",()=>`${t.latencySumMs} MS`],["COMMANDS RUN",()=>String(t.commandsRun)],["LAST EXIT",()=>String(t.lastExitCode)],["UPTIME",()=>`${this.uptimeSeconds_get()} S`]];for(const[i,r]of s){const a=document.createElement("div");a.className="telemetry-row";const o=document.createElement("span");o.className="telemetry-label",o.textContent=i;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r(),a.append(o,l),e.appendChild(a),this.telemetryRows.push({element:l,source:r})}}narrowSources_list(){const e=this.telemetry;return[()=>e.jobsLoaded,()=>e.feeds,()=>e.lastLatencyMs,()=>e.opsActive,()=>e.opsDone,()=>e.jobsTotal,()=>e.itemsCurrent,()=>e.itemsTotal,()=>e.opsFailed,()=>e.commandsRun,()=>e.lastExitCode,()=>new Date().getSeconds(),()=>this.uptimeSeconds_get()]}wideSources_list(){return[()=>Math.floor(Date.now()/1e3),()=>this.uptimeSeconds_get(),()=>this.telemetry.latencySumMs,()=>lE()]}uptimeSeconds_get(){return Math.floor((Date.now()-this.bootedAt)/1e3)}beat_paint(){for(const e of this.cells){const t=dp(e.source(),e.width);e.element.textContent!==t&&(e.element.textContent=t)}for(const e of this.telemetryRows){const t=e.source();e.element.textContent!==t&&(e.element.textContent=t)}}sweep_start(){if(this.wrapper===null)return;const e=Array.from(this.wrapper.querySelectorAll(".data-column"));window.setInterval(()=>{const t=e[Math.floor(Math.random()*e.length)];t!==void 0&&(t.classList.add("dc-sweep"),window.setTimeout(()=>t.classList.remove("dc-sweep"),aE))},rE)}}function dp(n,e){const t=String(Math.max(0,Math.floor(n)));return t.length>e?t.slice(t.length-e):t.padStart(e,"0")}function lE(){const n=new Date;return n.getHours()*1e4+n.getMinutes()*100+n.getSeconds()}const cE=2e4;class dE{scene;nameplate;command_run;names=[];cursor=0;timer=null;seen=new Map;constructor(e,t,s){this.nameplate=t,this.command_run=s,this.scene=new _l(e,{},{ambient:!0}),new MutationObserver(()=>this.scene.palette_refresh()).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),new MutationObserver(()=>{window.setTimeout(()=>this.scene.size_fit(),60)}).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.addEventListener("resize",()=>this.scene.size_fit())}names_set(e){this.names=e,this.cursor=0,this.timer!==null&&(window.clearInterval(this.timer),this.timer=null),e.length!==0&&(this.next_request(),e.length>1&&(this.timer=window.setInterval(()=>this.next_request(),cE)))}envelope_observe(e){if(e.model?.kind!==bi.pipelineDiagram)return;const t=Cc.safeParse(e.model.data);if(!t.success)return;const s=t.data;this.seen.set(s.name,s),this.model_stage(s)}model_stage(e){this.nameplate.textContent=e.name,this.scene.graph_set({nodes:e.nodes.map(t=>({id:t.id,label:t.label,parentIds:t.parentIds,joinParentIds:t.joinParentIds}))}),this.scene.size_fit()}next_request(){const e=this.names[this.cursor%this.names.length];if(this.cursor++,e===void 0)return;const t=this.seen.get(e);if(t!==void 0){this.model_stage(t);return}this.command_run(`pipeline diagram ${e}`)}}const uE=new Set(["pane","view","runs","node","dag","universe","file","pacs","image","tags","header","console","back","desktop","dashboard","launcher","attach","argus"]),lM=new Set(["layout","slice","series","wl","colormap","save","tags","load","guard","ghost"]),hE={pacs:new Set(["sort","filter"]),tags:new Set(["redact","filter"]),image:lM};let qn=null;const xr="argus.desktop.",up="~/.config/argus/desktops";function fE(n){const e=n.trim().split(/\s+/),t=(e[0]??"").toLowerCase();if(!uE.has(t))return null;const s=hE[t];if(s!==void 0&&!s.has((e[1]??"").toLowerCase()))return null;let i=null,r=e.slice(1);return(r[0]?.startsWith("@")||r[0]?.startsWith("%"))&&(i=r[0],r=r.slice(1)),{subject:t,target:i,words:r}}function hp(n,e){if(e===null)return n.focused_get();if(e.startsWith("@"))return e.slice(1);const t=parseInt(e.slice(1),10);return qn===null?null:qn[t-1]??null}function $n(n,e,t){const i=n.paneMount_get(e)?.querySelector(t)??null;return i===null?!1:(i.click(),!0)}function Oo(n,e,t){const s=n.paneMount_get(e);if(s===null)return!1;for(const i of s.querySelectorAll(".drawer-child"))if(i.textContent?.trim().toUpperCase()===t)return i.click(),!0;return!1}function pE(n,e,t){return $n(n,e,`.drawer-cwdbind[data-follow="${t?"on":"off"}"]`)}function ha(n,e,t,s){const r=n.paneMount_get(e)?.querySelector(t)??null;if(r===null)return!1;for(let a=0;a<4;a++){if(r.textContent?.trim().toUpperCase()===s)return!0;r.click()}return r.textContent?.trim().toUpperCase()===s}function mE(n,e){const t=n.focused_get(),s=t!==null?n.paneRect_get(t):null;if(s===null)return null;const i=s.x+s.width/2,r=s.y+s.height/2;let a=null;for(const o of n.panes_shown()){if(o===t)continue;const l=n.paneRect_get(o);if(l===null)continue;const c=l.x+l.width/2-i,d=l.y+l.height/2-r,h=e==="left"?-c:e==="right"?c:e==="up"?-d:d;if(h<=1)continue;const u=Math.abs(e==="left"||e==="right"?d:c),p=h+u*2;(a===null||p<a.score)&&(a={id:o,score:p})}return a===null?null:(n.focus_set(a.id),a.id)}const ME={left:{split:"col",place:"before"},right:{split:"col",place:"after"},above:{split:"row",place:"before"},below:{split:"row",place:"after"}},gE=["pane [@id|%n] split left|right|above|below · zoom · close · bind unlinked|fs|viewer","pane [@id|%n] claim files|runs|pacs · focus left|right|up|down|@id","view files|runs|pacs (the gutter givens, workspace scope)","runs enter <feedId> · sort <col> [asc|desc] · filter <text>|off","node enter · immerse · back · clear (the indicated node)","dag [@id] layout ranked|molecule · projection 2d|3d · scale time|size · hue status|compute · pulse · census · physics charge|link|collide|gravity on|off · physics reset · refresh","file [@id] home|back|download|delete · follow · root · list|cards|preview · sort <col> [asc|desc] · filter <text>|off","pacs sort <col> [asc|desc] · filter <text>|off (the results listing; every other pacs verb is the session's)","image [@id] [--force] <path> · layout single|mpr|3d|slab · slice <n> · series <n> · wl <lo> <hi> · wl preset <name> · colormap gray|hot|jet|cool · save · tags · load · guard <bytes>|off · ghost <0..1>|off","tags [@id] redact on|off · filter <text>|off (the pane that follows an image pane's slice)","header stats|dag|away|restore","console open|close|toggle|zoom|height <px>","back (contextual back — exactly Esc)","desktop save|load|show|list|delete [name]","attach [--reveal] (how to reach THIS session from a terminal or another browser)","argus verbs (this table; the long form is docs/argus-lang.adoc)"].join(`
4216
+ `);function bE(n,e){const t=new URL(window.location.href),s=t.searchParams.get("token")??"",i=s===""?"":e?s:"•".repeat(8),r=s===""?t.origin+t.pathname:`${t.origin}${t.pathname}?token=${i}`,a=n.identity_get(),o=/^(127\.|\[?::1\]?$|localhost$)/.test(t.hostname),l=["attach — this session, from anywhere that can reach it"];return a!==null&&a!==""&&l.push(` identity ${a}`),l.push(""),l.push(" this machine chell --remote"),l.push(` another machine chell --remote --attach "${r}"`),l.push(` another browser ${r}`),l.push(""),o&&(l.push(" bound to loopback — another machine cannot reach this session;"),l.push(" relaunch the daemon with CALYPSO_BIND=0.0.0.0 to change that")),s===""?(l.push(" this page carries no token: it was opened without one, and a"),l.push(" second surface cannot attach with what is on screen")):e?l.push(" revealed — anyone who reads this line holds the session"):(l.push(" the token is masked — `attach --reveal` prints it. It is a bearer"),l.push(" credential with no expiry: treat the line like a password")),l.join(`
4217
+ `)}async function kd(n,e){const t=fE(e);if(t===null)return null;const{subject:s,words:i}=t,r=(i[0]??"").toLowerCase(),a=(i[1]??"").toLowerCase();if(s==="argus")return gE;if(s==="back")return window.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0})),"back";if(s==="attach")return bE(n,r==="--reveal"||a==="--reveal");if(s==="dashboard"||s==="launcher")return n.launcher_enter(),"dashboard";if(s==="view"){const c={files:"gutter-files",runs:"gutter-runs",pacs:"gutter-tools"}[r];return c===void 0?`view: unknown given '${r}' (files|runs|pacs)`:(document.getElementById(c)?.click(),qn!==null&&(qn.length=0,qn.push(r==="runs"?"dag":r==="pacs"?"pacs":"files")),`view ${r}`)}if(s==="header"){if(r==="restore")return document.getElementById("header-restore")?.click(),"header restored";if(r==="stats")return document.querySelector(".panel-1")?.click(),"header stats";if(r==="dag")return document.querySelector(".panel-2")?.click(),"header dag";if(r==="away"){const l=document.body.dataset.header,c=l==="stats"?".panel-1":".panel-2";return l!=="away"&&(l===void 0&&document.querySelector(".panel-2")?.click(),document.querySelector(c)?.click()),"header away"}return`header: unknown face '${r}' (stats|dag|away|restore)`}if(s==="console"){const l=document.getElementById("drawer");if(l===null)return"console: no drawer";const c=l.classList.contains("drawer-closed");if(r==="toggle"||r==="open"&&c||r==="close"&&!c)return document.getElementById("drawer-toggle")?.click(),`console ${r}`;if(r==="zoom")return n.consoleZoom_toggle(),"console zoom";if(r==="height"){const d=parseInt(a,10);return Number.isNaN(d)?"console height <px>":(l.style.height=`${d}px`,`console height ${d}`)}return r==="open"||r==="close"?`console already ${r==="open"?"open":"closed"}`:`console: unknown verb '${r}' (open|close|toggle|zoom|height)`}if((s==="runs"||s==="file"||s==="pacs")&&(r==="sort"||r==="filter")){const l=s==="runs"?".pane-dag":s==="file"?".pane-files":"#pacs-workspace",c=hp(n,t.target),h=(c===null?null:n.paneMount_get(c))?.querySelector(l)??document.querySelector(l);if(h===null)return`${s} ${r}: no ${s==="runs"?"DAG":s==="file"?"files":"PACS"} pane`;if(r==="sort"){if(a==="")return`${s} sort <column> [asc|desc]`;const p=(i[2]??"asc").toLowerCase()==="desc"?"desc":"asc";return h.dispatchEvent(new CustomEvent("argus:roster",{detail:{op:"sort",key:a,dir:p}})),`${s} sorted by ${a} ${p}`}const u=a==="off"?"":i.slice(1).join(" ");return h.dispatchEvent(new CustomEvent("argus:roster",{detail:{op:"filter",text:u}})),u===""?`${s} filter off`:`${s} filtered: ${u}`}if(s==="runs"){if(r==="enter"){const l=parseInt(a.replace(/^feed_/,""),10);return Number.isNaN(l)?"runs enter <feedId>":(n.feed_enter(l),`entering feed_${l}`)}return`runs: unknown verb '${r}' (enter)`}if(s==="desktop")return zE(n,r,i[1]);const o=hp(n,t.target);if(o===null)return`${s}: no target pane (nothing focused?)`;if(s==="pane"){if(r==="split"){const l=ME[a];if(l===void 0)return"pane split left|right|above|below";const c=new Set(n.panes_shown());if(!$n(n,o,`[data-split="${l.split}"][data-place="${l.place}"]`))return`pane split: '${o}' has no drawer`;const d=n.panes_shown().find(h=>!c.has(h));return d!==void 0&&qn!==null&&qn.push(d),`split ${a}: ${d??"(no pane created)"}`}if(r==="zoom")return $n(n,o,".drawer-zoom")?`zoomed ${o}`:"pane zoom: no drawer";if(r==="close")return $n(n,o,".drawer-close")?`closed ${o}`:"pane close: no drawer";if(r==="bind")return["unlinked","fs","viewer"].includes(a)?$n(n,o,`.drawer-bind[data-bind="${a}"]`)?`bind ${a}`:"pane bind: no drawer":"pane bind unlinked|fs|viewer";if(r==="claim"){const c={files:".empty-go-files",runs:".empty-go-dag",pacs:".empty-go-pacs"}[a];return c===void 0?"pane claim files|runs|pacs":$n(n,o,c)?`claiming ${o} as ${a}`:`pane claim: '${o}' is not an unlinked pane`}if(r==="focus"){if(a.startsWith("@"))return n.focus_set(a.slice(1))?`focused ${a.slice(1)}`:`no pane '${a.slice(1)}'`;const l=mE(n,a);return l!==null?`focused ${l}`:`pane focus: nothing ${a} of here`}return`pane: unknown verb '${r}'`}if(s==="dag"){if(r==="layout")return ha(n,o,".dag-strategy",a.toUpperCase())?`layout ${a}`:"dag layout ranked|molecule";if(r==="projection")return ha(n,o,".dag-projection",a.toUpperCase())?`projection ${a}`:"dag projection 2d|3d";if(r==="scale")return ha(n,o,".dag-scale",a.toUpperCase())?`scale ${a}`:"dag scale time|size";if(r==="hue")return ha(n,o,".dag-hue",a.toUpperCase())?`hue ${a}`:"dag hue status|compute";if(r==="pulse")return $n(n,o,".dag-pulse")?"pulse":"dag pulse: no mode frame";if(r==="census")return $n(n,o,".dag-census")?"census toggled":"dag census: no mode frame";if(r==="refresh")return Oo(n,o,"REFRESH")?"refreshing":"dag refresh: no DAG pane";if(r==="physics"){const l=a,c=n.paneMount_get(o),d=c?.querySelector(".pane-dag")??c;if(d===null)return"dag physics: no DAG pane";if(l==="reset")return d.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:"reset"})),"physics reset";const h=(i[2]??"on").toLowerCase()!=="off";return["charge","link","collide","gravity"].includes(l)?(d.dispatchEvent(new CustomEvent("argus:dag-physics",{detail:{term:l,on:h}})),`physics ${l} ${h?"on":"off"}`):`dag physics: unknown term '${l}' (charge|link|collide|gravity|reset)`}return`dag: unknown verb '${r}' (layout|projection|scale|hue|pulse|census|physics|refresh)`}if(s==="file")return r==="list"||r==="cards"||r==="preview"?ha(n,o,".files-view",r.toUpperCase())?`file ${r}`:`file ${r}: no files mode frame`:r==="follow"||r==="root"?pE(n,o,r==="follow")?`file ${r}`:`file ${r}: not offered by '${o}'`:r==="home"||r==="back"?$n(n,o,r==="home"?".files-home":".files-back")?`file ${r}`:`file ${r}: not offered by '${o}'`:r==="download"?n.file_download(o)?"file download":"file download: nothing indicated":r==="delete"?n.file_delete(o)?"file delete":"file delete: nothing indicated":"file home|back|download|delete|sort|filter|follow|root|list|cards|preview";if(s==="image"){const c=i.filter(d=>d!=="--force")[0]??"";return lM.has(c.toLowerCase())?n.image_control(o,r,i.slice(1)):null}return s==="tags"?o===null?"tags: no pane in focus":n.tags_control(o,r,i.slice(1)):s==="universe"?n.universe_control(o,r,i.slice(1)):s==="node"?r==="enter"?Oo(n,o,"ENTER NODE")?"entering node":"node enter: no DAG drawer":r==="back"?Oo(n,o,"BACK")?"node back":"node back: no DAG drawer":r==="immerse"?n.node_immerse(o)?"immersing":"node immerse: nothing indicated":r==="clear"?Oo(n,o,"CLEAR DETAIL")?"detail cleared":"node clear: no DAG drawer":`node: unknown verb '${r}' (enter|immerse|back|clear)`:null}async function zE(n,e,t){if(e==="list"){const s=[];for(let i=0;i<window.localStorage.length;i++){const r=window.localStorage.key(i);r?.startsWith(xr)&&s.push(r.slice(xr.length))}return s.length>0?s.sort().join(`
4218
4218
  `):"(no desktops saved)"}if(e==="show")return t===void 0?n.desktop_serialize():window.localStorage.getItem(xr+t)??`(no desktop '${t}')`;if(t===void 0)return`desktop ${e} <name>`;if(e==="save"){const s=n.desktop_serialize();try{window.localStorage.setItem(xr+t,s)}catch{return"desktop save: local storage refused the write"}const i=window.btoa(unescape(encodeURIComponent(s))),r=await n.session_run(`config write ${up}/${t}.desk ${i}`),a=r.includes("wrote");return`saved '${t}' (local${a?" + CFS":"; CFS unavailable: "+r.trim().split(`
4219
4219
  `)[0]})`}if(e==="delete")return window.localStorage.removeItem(xr+t),`deleted '${t}' (local; a CFS copy, if any, is yours to rm)`;if(e==="load"){let s=window.localStorage.getItem(xr+t);if(s===null){const r=await n.session_run(`cat ${up}/${t}.desk`);r.trim().length>0&&!r.includes("No such")&&!r.toLowerCase().includes("error")&&(s=r)}if(s===null)return`(no desktop '${t}')`;qn=[];const i=[];try{for(const r of s.split(`
4220
4220
  `)){const a=r.trim();if(a===""||a.startsWith("#"))continue;const o=await kd(n,a);i.push(`${a} → ${o??"(session line?)"}`),await new Promise(l=>{window.setTimeout(l,60)})}}finally{qn=null}return`loaded '${t}'
4221
4221
  ${i.join(`
4222
- `)}`}return"desktop save|load|show|list|delete [name]"}const cM=new Map,Fr=new Map;let ME=0;function Fn(n,e){cM.set(n,e)}function gE(n){const e=cM.get(n);if(e===void 0)throw new Error(`no pane factory registered for kind '${n}'`);const t=e(`${n}-${ME++}`);return Fr.set(t.id,t),t}function Sr(n){Fr.set(n.id,n)}function mn(n){return Fr.get(n)}function xo(){return[...Fr.values()]}function $s(n){const e=Fr.get(n);e!==void 0&&(Fr.delete(n),e.dispose?.(),e.mount.remove())}const fp="argus-layout";class bE{root;mounts;presets=new Map;prefs={};activePreset="";tree=null;focusedPane=null;renderObserver=null;constructor(e,t){this.root=e,this.mounts=t;try{const s=window.localStorage.getItem(fp);this.prefs=s!==null?JSON.parse(s):{}}catch{this.prefs={}}}renderObserver_set(e){this.renderObserver=e}preset_register(e,t){this.presets.set(e,t)}mount_register(e,t){this.mounts.set(e,t)}mount_remove(e){this.mounts.delete(e),this.focusedPane===e&&(this.focusedPane=null)}leaf_split(e,t,s,i=!1){if(this.tree===null)return!1;const r=ul(this.tree,e,{dir:t,ratio:.5,first:i?{pane:s}:{pane:e},second:i?{pane:e}:{pane:s}});return r===null?!1:(this.tree=r,this.focusedPane=s,this.render(),!0)}leaf_replace(e,t){if(this.tree===null)return!1;const s=ul(this.tree,e,{pane:t});return s===null?!1:(this.tree=s,this.focusedPane===e&&(this.focusedPane=t),this.render(),!0)}leaf_close(e){if(this.tree===null||"pane"in this.tree)return!1;const t=Ud(this.tree,e);return t===null?!1:(this.tree=t,this.focusedPane===e&&(this.focusedPane=null),this.render(),!0)}focused_get(){return this.focusedPane}savedPreset_get(){return this.prefs.preset!==void 0&&this.presets.has(this.prefs.preset)?this.prefs.preset:null}activePreset_get(){return this.activePreset}preset_apply(e){const t=this.presets.get(e);t!==void 0&&(this.activePreset=e,this.prefs.preset=e,this.prefs_save(),this.tree=this.ratios_restore(t(),e,""),this.render(),this.root.classList.remove("layout-arrive"),this.root.offsetWidth,this.root.classList.add("layout-arrive"))}tree_get(){return this.tree===null?null:JSON.parse(JSON.stringify(this.tree))}tree_set(e){this.tree=this.ratios_restore(e,this.activePreset,""),this.render()}panes_shown(){const e=[],t=s=>{if(s!==null){if("pane"in s){e.push(s.pane);return}t(s.first),t(s.second)}};return t(this.tree),e}render(){if(this.tree!==null){for(const e of this.mounts.values())e.remove();this.root.replaceChildren(this.node_render(this.tree,"")),this.renderObserver?.()}}node_render(e,t){if("pane"in e){const o=document.createElement("div");o.className="layout-leaf",o.dataset.leaf=e.pane;const l=this.mounts.get(e.pane);return l!==void 0&&(o.appendChild(l),l.style.display="",o.addEventListener("mousedown",()=>this.focus_set(e.pane),{capture:!0}),e.pane===this.focusedPane&&o.classList.add("pane-focused")),o}const s=document.createElement("div");s.className=`layout-split layout-${e.dir}`;const i=this.node_render(e.first,`${t}0`),r=this.node_render(e.second,`${t}1`);i.style.flex=`${e.ratio} 1 0`,r.style.flex=`${1-e.ratio} 1 0`;const a=document.createElement("div");return a.className="layout-divider",this.divider_wire(a,s,e,i,r,t),s.append(i,a,r),s}divider_wire(e,t,s,i,r,a){let o=!1;e.addEventListener("mousedown",l=>{o=!0,l.preventDefault()}),window.addEventListener("mousemove",l=>{if(!o)return;const c=t.getBoundingClientRect(),d=s.dir==="col"?(l.clientX-c.left)/c.width:(l.clientY-c.top)/c.height;s.ratio=Math.min(.85,Math.max(.15,d)),i.style.flex=`${s.ratio} 1 0`,r.style.flex=`${1-s.ratio} 1 0`}),window.addEventListener("mouseup",()=>{o&&(o=!1,this.ratio_remember(a,s.ratio),this.renderObserver?.())})}focus_set(e){if(this.focusedPane===e)return;this.focusedPane=e,document.body.dataset.focus=e;for(const s of this.root.querySelectorAll(".layout-leaf"))s.classList.remove("pane-focused");this.mounts.get(e)?.parentElement?.classList.add("pane-focused")}ratios_restore(e,t,s){if("pane"in e)return e;const i=this.prefs.ratios?.[`${t}:${s}`];return{...e,ratio:i??e.ratio,first:this.ratios_restore(e.first,t,`${s}0`),second:this.ratios_restore(e.second,t,`${s}1`)}}ratio_remember(e,t){this.prefs.ratios={...this.prefs.ratios??{},[`${this.activePreset}:${e}`]:t},this.prefs_save()}prefs_save(){try{window.localStorage.setItem(fp,JSON.stringify(this.prefs))}catch{}}}function ul(n,e,t){if("pane"in n)return n.pane===e?t:null;const s=ul(n.first,e,t);if(s!==null)return{...n,first:s};const i=ul(n.second,e,t);return i!==null?{...n,second:i}:null}function Ud(n,e){if("pane"in n)return null;if("pane"in n.first&&n.first.pane===e)return n.second;if("pane"in n.second&&n.second.pane===e)return n.first;const t=Ud(n.first,e);if(t!==null)return{...n,first:t};const s=Ud(n.second,e);return s!==null?{...n,second:s}:null}const zE=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function _E(n){const e=n instanceof Error?n.message:String(n??"");return zE.test(e)}function wE(n,e=document.body){let t=!1;const s=()=>{if(t)return;t=!0,n("argus: the server has a newer argus than this page — reload to continue (what failed to load was part of the old one)");const i=document.createElement("div");i.className="stale-page",i.setAttribute("role","alert");const r=document.createElement("span");r.className="stale-page-words",r.textContent="ARGUS WAS UPDATED ON THE SERVER — THIS PAGE IS OLDER";const a=document.createElement("button");a.className="pacs-capsule stale-page-reload",a.textContent="RELOAD",a.title="load the argus the server has now",a.addEventListener("click",()=>{window.location.reload()}),i.append(r,a),e.appendChild(i)};window.addEventListener("vite:preloadError",i=>{i.preventDefault(),s()}),window.addEventListener("unhandledrejection",i=>{_E(i.reason)&&s()})}let dM=()=>{};function yE(){dM(document.body.dataset.zoom==="console"?null:"console")}const vE=$x(),OE="ARGUS",pp="argus-audio",xE=.4;let Ni=!1;function kt(n){if(Ni)return;const e=document.getElementById(n);e instanceof HTMLAudioElement&&(e.currentTime=0,e.volume=xE,e.play().catch(()=>{}))}function SE(){const n=rt("audio-pill");try{Ni=window.localStorage.getItem(pp)==="off"}catch{Ni=!1}const e=()=>{n.classList.toggle("audio-off",Ni)};e(),n.addEventListener("click",()=>{Ni=!Ni;try{window.localStorage.setItem(pp,Ni?"off":"on")}catch{}e(),kt("audio2")})}function rt(n){const e=document.getElementById(n);if(e===null)throw new Error(`required element #${n} is missing`);return e}function fn(n){const e=rt(n);if(!(e instanceof HTMLTemplateElement))throw new Error(`#${n} is not a template`);const t=e.content.firstElementChild;if(!(t instanceof HTMLElement))throw new Error(`template #${n} is empty`);return t.cloneNode(!0)}function Bs(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`pane template is missing ${e}`);return t}function AE(){return Hx(window.location)}const mp=/\.(csv|tsv)$/i;let Sc=null,hl=0;function uM(n,e){const t=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(hl=Math.ceil(n.getBoundingClientRect().bottom),e.style.setProperty("--zoom-header-height",`${hl}px`))};t(),Sc===null&&(Sc=new ResizeObserver(t),Sc.observe(n))}const EE=2200,Mp=120,DE=96;function IE(n,e,t,s){let i="";const r=c=>{c?(i=n.style.height,n.style.height=""):i!==""&&(n.style.height=i),n.classList.toggle("drawer-closed",c),kt("audio3"),c||(s.size_fit(),s.focus_take())};t.addEventListener("click",()=>r(!n.classList.contains("drawer-closed")));let a=0,o=0,l=!1;return e.addEventListener("mousedown",c=>{l=!0,a=c.clientY,o=n.getBoundingClientRect().height,n.classList.add("drawer-dragging"),c.preventDefault()}),window.addEventListener("mousemove",c=>{if(!l)return;const d=Math.max(Mp,window.innerHeight-DE),h=o+(c.clientY-a),u=Math.min(Math.max(Mp,h),d);n.style.height=`${u}px`,s.size_fit()}),window.addEventListener("mouseup",()=>{l=!1,n.classList.remove("drawer-dragging")}),r}function TE(n){const e=document.body,t=document.querySelector(".wrap:not(#gap)");let s;const i=r=>{for(const a of document.querySelectorAll(".pane-zoomed, .pane-zoomed-path"))a.classList.remove("pane-zoomed","pane-zoomed-path");if(r===null)delete e.dataset.zoom,s!==void 0&&(e.dataset.header=s,s=void 0);else{window.scrollTo(0,0),e.dataset.header==="away"?(s="away",delete e.dataset.header,hl>0&&e.style.setProperty("--zoom-header-height",`${hl}px`)):t!==null&&uM(t,e),e.dataset.zoom=r;const o=mn(r)?.mount?.parentElement??null;o?.classList.add("pane-zoomed");let l=o?.parentElement??null;for(;l!==null&&l.id!=="layout-root";)l.classList.add("pane-zoomed-path"),l=l.parentElement}for(const a of document.querySelectorAll(".drawer-zoom"))a.textContent=r!==null&&a.dataset.pane===r?"RESTORE":"ZOOM";kt("audio3")};return rt("header-restore").addEventListener("click",()=>{e.dataset.zoom!==void 0&&i(null)}),document.addEventListener("click",r=>{const a=r.target;if(!(a instanceof Element))return;const o=a.closest("[data-pane]");if(o===null)return;const l=o.dataset.pane??"";l!==""&&i(e.dataset.zoom===l?null:l)}),window.addEventListener("keydown",r=>{r.key==="Escape"&&e.dataset.zoom!==void 0&&(i(null),r.stopImmediatePropagation())}),rt("drawer").addEventListener("transitionend",r=>{r.propertyName==="height"&&n.size_fit()}),i}function GE(){const n=new nE(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&n.telemetryPanel_bind(e),n}const Ac=96,RE=220,gp="argus.headerBand.height";function BE(){const n=document.documentElement,e=document.getElementById("header-strip"),t=document.querySelector(".wrap:not(#gap)");if(e===null||t===null)return;const s=c=>{const d=Math.max(Ac,window.innerHeight-RE),h=Math.min(Math.max(Ac,c),d);n.style.setProperty("--header-band-h",`${h}px`);try{window.localStorage.setItem(gp,String(h))}catch{}},i=(()=>{try{return window.localStorage.getItem(gp)}catch{return null}})();i!==null&&Number.isFinite(Number(i))&&s(Number(i));const r=()=>{const c=t.getBoundingClientRect();e.style.top=`${Math.max(0,c.bottom-5)}px`};r(),window.addEventListener("resize",r),new MutationObserver(r).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.setInterval(r,500);let a=!1,o=0,l=0;e.addEventListener("mousedown",c=>{const d=document.querySelector(".header-face");a=!0,o=c.clientY,l=d===null?Ac:d.getBoundingClientRect().height,c.preventDefault()}),window.addEventListener("mousemove",c=>{a&&(s(l+(c.clientY-o)),r())}),window.addEventListener("mouseup",()=>{a=!1,r()})}let hM=null;function NE(){const n=document.body,e=document.querySelector(".wrap:not(#gap)"),t=r=>{n.dataset.header===r?(e!==null&&uM(e,n),n.dataset.header="away"):n.dataset.header=r};document.querySelector(".panel-1")?.addEventListener("click",()=>t("stats")),document.querySelector(".panel-2")?.addEventListener("click",()=>t("dag")),document.querySelector(".panel-gather")?.addEventListener("click",()=>t("gather"));const s=document.querySelector(".header-gather-field");s?.querySelector(".gather-stage")?.addEventListener("click",r=>{r.stopPropagation(),hM?.()}),s?.querySelector(".mode-strip")?.addEventListener("click",()=>{s!==null&&(s.dataset.modes==="open"?delete s.dataset.modes:s.dataset.modes="open")});const i=()=>{n.dataset.zoom===void 0&&(delete n.dataset.header,kt("audio3"))};rt("header-restore").addEventListener("click",i),window.addEventListener("keydown",r=>{r.key==="Escape"&&n.dataset.header==="away"&&n.dataset.zoom===void 0&&n.dataset.gutter!=="away"&&i()})}const Ar=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],fM="argus-landing",CE=15e3;function bp(){try{return(window.localStorage.getItem(fM)??"launcher")==="launcher"}catch{return!0}}function PE(n){try{window.localStorage.setItem(fM,n?"launcher":"last")}catch{}}const zp="argus-theme",WE="argus-lcars",LE="medical",kE={sickbay:"medical"};function UE(){const n=rt("theme-pill"),e=Math.max(Ar.findIndex(r=>r.key===LE),0);let t=e;try{const r=window.localStorage.getItem(zp)??window.localStorage.getItem(WE),a=r===null?null:kE[r]??r,o=Ar.findIndex(l=>l.key===a);t=o>=0?o:e}catch{t=e}const s=document.documentElement,i=()=>{const r=Ar[t]??Ar[0];r.key==="lower-decks"?delete s.dataset.theme:s.dataset.theme=r.key,n.textContent=r.label};i(),n.addEventListener("click",()=>{t=(t+1)%Ar.length,i();try{window.localStorage.setItem(zp,Ar[t]?.key??"lower-decks")}catch{}kt("audio2")})}function FE(n){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const t={cumin:n.stack?.cumin,salsa:n.stack?.salsa,chili:n.stack?.chili,brasa:n.stack?.brasa,calypso:n.stack?.calypso,chell:n.stack?.chell},s=[];for(const[i,r]of Object.entries(t))r!==void 0&&s.push([i.toUpperCase(),r]);s.push(["MENU","0.11.0"],["ARGUS","43521c1 · 2026-09-24 19:08Z"],["WIRE",`V${n.protocolVersion}`]),n.stack?.build!==void 0&&s.push(["BUILD",n.stack.build]);for(const[i,r]of s){const a=document.createElement("div");a.className="telemetry-row";const o=document.createElement("span");o.className="telemetry-label",o.textContent=i;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r,l.title=r,a.append(o,l),e.appendChild(a)}}function _p(n){return n.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}function jE(){for(const n of document.querySelectorAll(".left-frame button, .left-frame-top button"))n.addEventListener("click",()=>kt("audio2"))}let Ir=null;async function VE(n){const e=new XA(document),t=new KA(rt("index-instrument"),()=>Date.now(),{errored_open:()=>Gs("status:error")}),s=new QA(rt("lane-instrument"));window.setInterval(()=>s.tick(),500);const i=new Map,r=new Map,a=new Map,o=new Map,l=new VA;l.writeObserver_set((g,y)=>{bt.regard_send({address:g.address,...g.modelKind!==void 0?{modelKind:g.modelKind}:{},groupId:y,paneId:g.paneId}),zn()});const c=g=>Mu(g,n),d=g=>qx(g,n),p={imageUrl:c,downloadUrl:d,textHead:async(g,y)=>{const E=await fetch(c(g));if(!E.ok||E.body===null)return(await M(g)).text.slice(0,y);const I=E.body.getReader(),D=new TextDecoder;let B="";for(;B.length<y;){const{done:U,value:F}=await I.read();if(U)break;B+=D.decode(F,{stream:!0})}return I.cancel().catch(()=>{}),B.slice(0,y)},pipelineGlimpse:async g=>{const y=/_id(\d+)$/.exec(g)?.[1]??g.replace(/^.*\//,""),E=await bt.line_execute(`pipeline diagram ${y}`,{silent:!0,observe:!1});for(const I of E.envelopes){if(I.model?.kind!==gi.pipelineDiagram)continue;const D=Cc.safeParse(I.model.data);if(D.success)return D.data.nodes.map(B=>({id:B.id,parentIds:[...B.parentIds,...B.joinParentIds??[]]}))}return null}},M=g=>bt.line_execute(`cat "${g}"`,{silent:!0,observe:!1}).then(y=>{if(!y.envelopes.some(D=>D.status==="error"))return{ok:!0,text:_p(y.envelopes.map(D=>D.rendered).join(`
4222
+ `)}`}return"desktop save|load|show|list|delete [name]"}const cM=new Map,Fr=new Map;let _E=0;function Fn(n,e){cM.set(n,e)}function wE(n){const e=cM.get(n);if(e===void 0)throw new Error(`no pane factory registered for kind '${n}'`);const t=e(`${n}-${_E++}`);return Fr.set(t.id,t),t}function Sr(n){Fr.set(n.id,n)}function mn(n){return Fr.get(n)}function xo(){return[...Fr.values()]}function $s(n){const e=Fr.get(n);e!==void 0&&(Fr.delete(n),e.dispose?.(),e.mount.remove())}const fp="argus-layout";class yE{root;mounts;presets=new Map;prefs={};activePreset="";tree=null;focusedPane=null;renderObserver=null;constructor(e,t){this.root=e,this.mounts=t;try{const s=window.localStorage.getItem(fp);this.prefs=s!==null?JSON.parse(s):{}}catch{this.prefs={}}}renderObserver_set(e){this.renderObserver=e}preset_register(e,t){this.presets.set(e,t)}mount_register(e,t){this.mounts.set(e,t)}mount_remove(e){this.mounts.delete(e),this.focusedPane===e&&(this.focusedPane=null)}leaf_split(e,t,s,i=!1){if(this.tree===null)return!1;const r=ul(this.tree,e,{dir:t,ratio:.5,first:i?{pane:s}:{pane:e},second:i?{pane:e}:{pane:s}});return r===null?!1:(this.tree=r,this.focusedPane=s,this.render(),!0)}leaf_replace(e,t){if(this.tree===null)return!1;const s=ul(this.tree,e,{pane:t});return s===null?!1:(this.tree=s,this.focusedPane===e&&(this.focusedPane=t),this.render(),!0)}leaf_close(e){if(this.tree===null||"pane"in this.tree)return!1;const t=Ud(this.tree,e);return t===null?!1:(this.tree=t,this.focusedPane===e&&(this.focusedPane=null),this.render(),!0)}focused_get(){return this.focusedPane}savedPreset_get(){return this.prefs.preset!==void 0&&this.presets.has(this.prefs.preset)?this.prefs.preset:null}activePreset_get(){return this.activePreset}preset_apply(e){const t=this.presets.get(e);t!==void 0&&(this.activePreset=e,this.prefs.preset=e,this.prefs_save(),this.tree=this.ratios_restore(t(),e,""),this.render(),this.root.classList.remove("layout-arrive"),this.root.offsetWidth,this.root.classList.add("layout-arrive"))}tree_get(){return this.tree===null?null:JSON.parse(JSON.stringify(this.tree))}tree_set(e){this.tree=this.ratios_restore(e,this.activePreset,""),this.render()}panes_shown(){const e=[],t=s=>{if(s!==null){if("pane"in s){e.push(s.pane);return}t(s.first),t(s.second)}};return t(this.tree),e}render(){if(this.tree!==null){for(const e of this.mounts.values())e.remove();this.root.replaceChildren(this.node_render(this.tree,"")),this.renderObserver?.()}}node_render(e,t){if("pane"in e){const o=document.createElement("div");o.className="layout-leaf",o.dataset.leaf=e.pane;const l=this.mounts.get(e.pane);return l!==void 0&&(o.appendChild(l),l.style.display="",o.addEventListener("mousedown",()=>this.focus_set(e.pane),{capture:!0}),e.pane===this.focusedPane&&o.classList.add("pane-focused")),o}const s=document.createElement("div");s.className=`layout-split layout-${e.dir}`;const i=this.node_render(e.first,`${t}0`),r=this.node_render(e.second,`${t}1`);i.style.flex=`${e.ratio} 1 0`,r.style.flex=`${1-e.ratio} 1 0`;const a=document.createElement("div");return a.className="layout-divider",this.divider_wire(a,s,e,i,r,t),s.append(i,a,r),s}divider_wire(e,t,s,i,r,a){let o=!1;e.addEventListener("mousedown",l=>{o=!0,l.preventDefault()}),window.addEventListener("mousemove",l=>{if(!o)return;const c=t.getBoundingClientRect(),d=s.dir==="col"?(l.clientX-c.left)/c.width:(l.clientY-c.top)/c.height;s.ratio=Math.min(.85,Math.max(.15,d)),i.style.flex=`${s.ratio} 1 0`,r.style.flex=`${1-s.ratio} 1 0`}),window.addEventListener("mouseup",()=>{o&&(o=!1,this.ratio_remember(a,s.ratio),this.renderObserver?.())})}focus_set(e){if(this.focusedPane===e)return;this.focusedPane=e,document.body.dataset.focus=e;for(const s of this.root.querySelectorAll(".layout-leaf"))s.classList.remove("pane-focused");this.mounts.get(e)?.parentElement?.classList.add("pane-focused")}ratios_restore(e,t,s){if("pane"in e)return e;const i=this.prefs.ratios?.[`${t}:${s}`];return{...e,ratio:i??e.ratio,first:this.ratios_restore(e.first,t,`${s}0`),second:this.ratios_restore(e.second,t,`${s}1`)}}ratio_remember(e,t){this.prefs.ratios={...this.prefs.ratios??{},[`${this.activePreset}:${e}`]:t},this.prefs_save()}prefs_save(){try{window.localStorage.setItem(fp,JSON.stringify(this.prefs))}catch{}}}function ul(n,e,t){if("pane"in n)return n.pane===e?t:null;const s=ul(n.first,e,t);if(s!==null)return{...n,first:s};const i=ul(n.second,e,t);return i!==null?{...n,second:i}:null}function Ud(n,e){if("pane"in n)return null;if("pane"in n.first&&n.first.pane===e)return n.second;if("pane"in n.second&&n.second.pane===e)return n.first;const t=Ud(n.first,e);if(t!==null)return{...n,first:t};const s=Ud(n.second,e);return s!==null?{...n,second:s}:null}const vE=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed/i;function OE(n){const e=n instanceof Error?n.message:String(n??"");return vE.test(e)}function xE(n,e=document.body){let t=!1;const s=()=>{if(t)return;t=!0,n("argus: the server has a newer argus than this page — reload to continue (what failed to load was part of the old one)");const i=document.createElement("div");i.className="stale-page",i.setAttribute("role","alert");const r=document.createElement("span");r.className="stale-page-words",r.textContent="ARGUS WAS UPDATED ON THE SERVER — THIS PAGE IS OLDER";const a=document.createElement("button");a.className="pacs-capsule stale-page-reload",a.textContent="RELOAD",a.title="load the argus the server has now",a.addEventListener("click",()=>{window.location.reload()}),i.append(r,a),e.appendChild(i)};window.addEventListener("vite:preloadError",i=>{i.preventDefault(),s()}),window.addEventListener("unhandledrejection",i=>{OE(i.reason)&&s()})}let dM=()=>{};function SE(){dM(document.body.dataset.zoom==="console"?null:"console")}const AE=Yx(),EE="ARGUS",pp="argus-audio",DE=.4;let Ni=!1;function kt(n){if(Ni)return;const e=document.getElementById(n);e instanceof HTMLAudioElement&&(e.currentTime=0,e.volume=DE,e.play().catch(()=>{}))}function IE(){const n=st("head-menu-pill"),e=t=>{t?document.body.dataset.headMenu="open":delete document.body.dataset.headMenu,n.setAttribute("aria-expanded",String(t))};n.addEventListener("click",t=>{t.stopPropagation(),e(document.body.dataset.headMenu!=="open")}),document.addEventListener("click",t=>{if(document.body.dataset.headMenu!=="open")return;t.target instanceof Element&&t.target.closest("#header-dag-info")!==null||e(!1)})}function TE(){const n=st("audio-pill");try{Ni=window.localStorage.getItem(pp)==="off"}catch{Ni=!1}const e=()=>{n.classList.toggle("audio-off",Ni)};e(),n.addEventListener("click",()=>{Ni=!Ni;try{window.localStorage.setItem(pp,Ni?"off":"on")}catch{}e(),kt("audio2")})}function st(n){const e=document.getElementById(n);if(e===null)throw new Error(`required element #${n} is missing`);return e}function fn(n){const e=st(n);if(!(e instanceof HTMLTemplateElement))throw new Error(`#${n} is not a template`);const t=e.content.firstElementChild;if(!(t instanceof HTMLElement))throw new Error(`template #${n} is empty`);return t.cloneNode(!0)}function Bs(n,e){const t=n.querySelector(e);if(t===null)throw new Error(`pane template is missing ${e}`);return t}function GE(){return Kx(window.location)}const mp=/\.(csv|tsv)$/i;let Sc=null,hl=0;function uM(n,e){const t=()=>{e.dataset.zoom!==void 0||e.dataset.header==="away"||(hl=Math.ceil(n.getBoundingClientRect().bottom),e.style.setProperty("--zoom-header-height",`${hl}px`))};t(),Sc===null&&(Sc=new ResizeObserver(t),Sc.observe(n))}const RE=2200,Mp=120,BE=96;function NE(n,e,t,s){let i="";const r=c=>{c?(i=n.style.height,n.style.height=""):i!==""&&(n.style.height=i),n.classList.toggle("drawer-closed",c),kt("audio3"),c||(s.size_fit(),s.focus_take())};t.addEventListener("click",()=>r(!n.classList.contains("drawer-closed")));let a=0,o=0,l=!1;return e.addEventListener("mousedown",c=>{l=!0,a=c.clientY,o=n.getBoundingClientRect().height,n.classList.add("drawer-dragging"),c.preventDefault()}),window.addEventListener("mousemove",c=>{if(!l)return;const d=Math.max(Mp,window.innerHeight-BE),h=o+(c.clientY-a),u=Math.min(Math.max(Mp,h),d);n.style.height=`${u}px`,s.size_fit()}),window.addEventListener("mouseup",()=>{l=!1,n.classList.remove("drawer-dragging")}),r}function CE(n){const e=document.body,t=document.querySelector(".wrap:not(#gap)");let s;const i=r=>{for(const a of document.querySelectorAll(".pane-zoomed, .pane-zoomed-path"))a.classList.remove("pane-zoomed","pane-zoomed-path");if(r===null)delete e.dataset.zoom,s!==void 0&&(e.dataset.header=s,s=void 0);else{window.scrollTo(0,0),e.dataset.header==="away"?(s="away",delete e.dataset.header,hl>0&&e.style.setProperty("--zoom-header-height",`${hl}px`)):t!==null&&uM(t,e),e.dataset.zoom=r;const o=mn(r)?.mount?.parentElement??null;o?.classList.add("pane-zoomed");let l=o?.parentElement??null;for(;l!==null&&l.id!=="layout-root";)l.classList.add("pane-zoomed-path"),l=l.parentElement}for(const a of document.querySelectorAll(".drawer-zoom"))a.textContent=r!==null&&a.dataset.pane===r?"RESTORE":"ZOOM";kt("audio3")};return st("header-restore").addEventListener("click",()=>{e.dataset.zoom!==void 0&&i(null)}),document.addEventListener("click",r=>{const a=r.target;if(!(a instanceof Element))return;const o=a.closest("[data-pane]");if(o===null)return;const l=o.dataset.pane??"";l!==""&&i(e.dataset.zoom===l?null:l)}),window.addEventListener("keydown",r=>{r.key==="Escape"&&e.dataset.zoom!==void 0&&(i(null),r.stopImmediatePropagation())}),st("drawer").addEventListener("transitionend",r=>{r.propertyName==="height"&&n.size_fit()}),i}function PE(){const n=new oE(document.getElementById("data-cascade")),e=document.getElementById("header-telemetry");return e!==null&&n.telemetryPanel_bind(e),n}const Ac=96,WE=220,gp="argus.headerBand.height";function LE(){const n=document.documentElement,e=document.getElementById("header-strip"),t=document.querySelector(".wrap:not(#gap)");if(e===null||t===null)return;const s=c=>{const d=Math.max(Ac,window.innerHeight-WE),h=Math.min(Math.max(Ac,c),d);n.style.setProperty("--header-band-h",`${h}px`);try{window.localStorage.setItem(gp,String(h))}catch{}},i=(()=>{try{return window.localStorage.getItem(gp)}catch{return null}})();i!==null&&Number.isFinite(Number(i))&&s(Number(i));const r=()=>{const c=t.getBoundingClientRect();e.style.top=`${Math.max(0,c.bottom-5)}px`};r(),window.addEventListener("resize",r),new MutationObserver(r).observe(document.body,{attributes:!0,attributeFilter:["data-header"]}),window.setInterval(r,500);let a=!1,o=0,l=0;e.addEventListener("mousedown",c=>{const d=document.querySelector(".header-face");a=!0,o=c.clientY,l=d===null?Ac:d.getBoundingClientRect().height,c.preventDefault()}),window.addEventListener("mousemove",c=>{a&&(s(l+(c.clientY-o)),r())}),window.addEventListener("mouseup",()=>{a=!1,r()})}let hM=null;function kE(){const n=document.body,e=document.querySelector(".wrap:not(#gap)"),t=r=>{n.dataset.header===r?(e!==null&&uM(e,n),n.dataset.header="away"):n.dataset.header=r};document.querySelector(".panel-1")?.addEventListener("click",()=>t("stats")),document.querySelector(".panel-2")?.addEventListener("click",()=>t("dag")),document.querySelector(".panel-gather")?.addEventListener("click",()=>t("gather"));const s=document.querySelector(".header-gather-field");s?.querySelector(".gather-stage")?.addEventListener("click",r=>{r.stopPropagation(),hM?.()}),s?.querySelector(".mode-strip")?.addEventListener("click",()=>{s!==null&&(s.dataset.modes==="open"?delete s.dataset.modes:s.dataset.modes="open")});const i=()=>{n.dataset.zoom===void 0&&(delete n.dataset.header,kt("audio3"))};st("header-restore").addEventListener("click",i),window.addEventListener("keydown",r=>{r.key==="Escape"&&n.dataset.header==="away"&&n.dataset.zoom===void 0&&n.dataset.gutter!=="away"&&i()})}const Ar=[{key:"lower-decks",label:"LOWER DECKS"},{key:"gold",label:"CERRITOS GOLD"},{key:"medical",label:"MEDICAL"},{key:"nemesis",label:"NEMESIS"},{key:"pharos",label:"PHAROS"}],fM="argus-landing",UE=15e3;function bp(){try{return(window.localStorage.getItem(fM)??"launcher")==="launcher"}catch{return!0}}function FE(n){try{window.localStorage.setItem(fM,n?"launcher":"last")}catch{}}const zp="argus-theme",jE="argus-lcars",VE="medical",$E={sickbay:"medical"};function HE(){const n=st("theme-pill"),e=Math.max(Ar.findIndex(r=>r.key===VE),0);let t=e;try{const r=window.localStorage.getItem(zp)??window.localStorage.getItem(jE),a=r===null?null:$E[r]??r,o=Ar.findIndex(l=>l.key===a);t=o>=0?o:e}catch{t=e}const s=document.documentElement,i=()=>{const r=Ar[t]??Ar[0];r.key==="lower-decks"?delete s.dataset.theme:s.dataset.theme=r.key,n.textContent=r.label};i(),n.addEventListener("click",()=>{t=(t+1)%Ar.length,i();try{window.localStorage.setItem(zp,Ar[t]?.key??"lower-decks")}catch{}kt("audio2")})}function qE(n){const e=document.getElementById("about-rows");if(e===null)return;e.replaceChildren();const t={cumin:n.stack?.cumin,salsa:n.stack?.salsa,chili:n.stack?.chili,brasa:n.stack?.brasa,calypso:n.stack?.calypso,chell:n.stack?.chell},s=[];for(const[i,r]of Object.entries(t))r!==void 0&&s.push([i.toUpperCase(),r]);s.push(["MENU","0.11.0"],["ARGUS","9906cb9 · 2026-09-25 02:42Z"],["WIRE",`V${n.protocolVersion}`]),n.stack?.build!==void 0&&s.push(["BUILD",n.stack.build]);for(const[i,r]of s){const a=document.createElement("div");a.className="telemetry-row";const o=document.createElement("span");o.className="telemetry-label",o.textContent=i;const l=document.createElement("span");l.className="telemetry-value",l.textContent=r,l.title=r,a.append(o,l),e.appendChild(a)}}function _p(n){return n.replace(/\x1b\[[0-9;:]*[A-Za-z]/g,"")}function XE(){for(const n of document.querySelectorAll(".left-frame button, .left-frame-top button"))n.addEventListener("click",()=>kt("audio2"))}let Ir=null;async function YE(n){const e=new QA(document),t=new eE(st("index-instrument"),()=>Date.now(),{errored_open:()=>Gs("status:error")}),s=new sE(st("lane-instrument"));window.setInterval(()=>s.tick(),500);const i=new Map,r=new Map,a=new Map,o=new Map,l=new XA;l.writeObserver_set((g,y)=>{bt.regard_send({address:g.address,...g.modelKind!==void 0?{modelKind:g.modelKind}:{},groupId:y,paneId:g.paneId}),zn()});const c=g=>Mu(g,n),d=g=>Zx(g,n),p={imageUrl:c,downloadUrl:d,textHead:async(g,y)=>{const E=await fetch(c(g));if(!E.ok||E.body===null)return(await M(g)).text.slice(0,y);const I=E.body.getReader(),D=new TextDecoder;let B="";for(;B.length<y;){const{done:U,value:F}=await I.read();if(U)break;B+=D.decode(F,{stream:!0})}return I.cancel().catch(()=>{}),B.slice(0,y)},pipelineGlimpse:async g=>{const y=/_id(\d+)$/.exec(g)?.[1]??g.replace(/^.*\//,""),E=await bt.line_execute(`pipeline diagram ${y}`,{silent:!0,observe:!1});for(const I of E.envelopes){if(I.model?.kind!==bi.pipelineDiagram)continue;const D=Cc.safeParse(I.model.data);if(D.success)return D.data.nodes.map(B=>({id:B.id,parentIds:[...B.parentIds,...B.joinParentIds??[]]}))}return null}},M=g=>bt.line_execute(`cat "${g}"`,{silent:!0,observe:!1}).then(y=>{if(!y.envelopes.some(D=>D.status==="error"))return{ok:!0,text:_p(y.envelopes.map(D=>D.rendered).join(`
4223
4223
  `))};const I=y.envelopes.flatMap(D=>(D.errors??[]).map(B=>B.message)).concat(y.envelopes.map(D=>D.renderedErr??"")).map(D=>_p(D).trim()).filter(D=>D!=="").join(`
4224
4224
  `);return{ok:!1,text:I===""?"the session refused this read and said nothing further":I}}),_=new Map,m=new Map,f=new Map,S=(g,y)=>{f.set(g,y)},v=g=>{f.get(g)?.()},z=(g,y)=>{m.set(g,y),v(g);const E=i.get(g);E?.follow_set(y),y&&E!==void 0&&bt.line_execute("ls",{silent:!0,observe:!1}).then(I=>{for(const D of I.envelopes)E.envelope_observe(D)})},O=async(g,y,E)=>{for(const I of E){const D=`${y}/${I.name}`;ve.line_note(`putting ${I.name} in ${y}…`);try{const B=await fetch(c(D),{method:"POST",body:I});if(!B.ok){ve.line_note(`upload: ${I.name}: ${(await B.text()).trim()||B.statusText}`);continue}ve.line_note(`✓ ${D}`)}catch(B){ve.line_note(`upload: ${I.name}: ${B instanceof Error?B.message:String(B)}`)}}x(g,y)},x=(g,y)=>{const E=i.get(g);E!==void 0&&(m.get(g)===!0?ve.line_run("ls"):b(g,E,y))},G=(g,y)=>{ni(g,{message:`New directory in ${y}: `,kind:"text",commit:"MAKE IT"}).then(E=>{const I=(E??"").trim();I!==""&&(ve.line_run(`mkdir "${y}/${I}"`),x(g,y))})},b=(g,y,E)=>{const I=E==="~"?"ls ~":`ls "${E}"`;bt.line_execute(I,{silent:!0,observe:!1}).then(D=>{for(const B of D.envelopes)y.envelope_observe(B)})},T=g=>/\x1b\[/.test(g)?Vn(g):Hs(g).replace(/(&quot;[^&]*&quot;)/g,'<span class="man-str">$1</span>').replace(/(^|\s)(--?[a-zA-Z][\w-]*)/g,'$1<span class="man-flag">$2</span>').replace(/^(\s{0,2})([A-Za-z_ ]+):(\s)/gm,'$1<span class="man-key">$2:</span>$3').replace(/^([A-Z][A-Z ]{2,})$/gm,'<span class="man-head">$1</span>'),N=(g,y,E,I)=>{let D=null,B=null;const U=g.contentHtml_show(y,"",{diagram:!0,release:()=>{H=null,B?.(),B=null,g.mode_annunciate(""),D?.dispose(),D=null}});U!==null&&E().then(F=>{if(!U.isConnected)return;if(F===null||F.nodes.length===0){U.textContent="NOTHING TO DRAW FOR THIS ENTRY",U.classList.add("files-diagram-empty");return}F.text!==""&&g.contentText_set(F.text);const X=document.createElement("div");X.className="dag-facts",U.appendChild(X);const re=new _l(U,{select:fe=>F.facts_show(X,fe.id,!1,I),activate:fe=>le(fe),deselect:()=>X.replaceChildren()},{}),le=fe=>{re.flight_into(fe.id,()=>{H={scene:re,facts:X},F.facts_show(X,fe.id,!0,I)})};D=re,re.graph_set({nodes:F.nodes},{wave:!1}),re.size_fit(),B=Se(U,re,g,I===null?void 0:I.run);const ge=F.nodes.length===1?F.nodes[0]:void 0;ge!==void 0&&le(ge)})},C=async g=>{const y=/_id(\d+)$/.exec(g)?.[1]??g.replace(/^.*\//,""),[E,I]=await Promise.all([bt.line_execute(`cat "${g}"`,{silent:!0,observe:!1}),bt.line_execute(`pipeline diagram ${y}`,{silent:!0,observe:!1})]),D=E.envelopes.map(B=>B.rendered).join(`
4225
- `);for(const B of I.envelopes){if(B.model?.kind!==gi.pipelineDiagram)continue;const U=Cc.safeParse(B.model.data);if(!U.success)continue;const F=new Map(U.data.nodes.map(X=>[X.id,X]));return{text:T(D),nodes:U.data.nodes.map(X=>({id:X.id,label:X.label,parentIds:X.parentIds,joinParentIds:X.joinParentIds})),facts_show:(X,re,le,ge)=>{const fe=U.data.nodes.map(Ue=>Ue.label);J(X,ue(F.get(re),le,ge!==null,fe),le,ge)}}}return null},W=async g=>{const y=g.replace(/^.*\//,""),E=await bt.line_execute(`plugin info "${y}"`,{silent:!0,observe:!1});for(const I of E.envelopes){if(I.model?.kind!==cb)continue;const D=lb.safeParse(I.model.data);if(!D.success)continue;const B=D.data;return{text:"",nodes:[{id:y,label:B.name,parentIds:[],joinParentIds:[]}],facts_show:(U,F,X,re)=>{J(U,he(B,X,re!==null),X,re)}}}return null},Q=(g,y,E,I)=>{N(y,E,()=>I==="plugin"?W(E):C(E),se(g,y,E,I))},se=(g,y,E,I)=>{const D=ye.get(g);if(D===void 0)return null;const B=E.replace(/^.*\//,"");return Qf(y.commandLine_get())!==B&&y.commandLine_set(Yf(D.input,B)),{line_get:()=>y.commandLine_get(),line_set:U=>y.commandLine_set(U),run:()=>{we(g,B,I)}}};let H=null;function ee(){const g=H;return g===null?!1:(H=null,g.scene.flight_back(()=>{g.facts.classList.remove("dag-facts-immersed"),g.facts.replaceChildren()}),!0)}function J(g,y,E,I){g.replaceChildren(),g.classList.toggle("dag-facts-immersed",E);for(const{label:D,value:B,edit:U}of y){const F=document.createElement("div");F.className="telemetry-row";const X=document.createElement("span");if(X.className="telemetry-label",X.textContent=D,F.appendChild(X),U===void 0||I===null){const re=document.createElement("span");re.className="telemetry-value",re.textContent=B,F.appendChild(re)}else{const re=YS(I.line_get(),U.flag),le=document.createElement("input");le.className="telemetry-input",le.spellcheck=!1,le.autocomplete="off",le.title=`${U.flag} — ${B}`,U.type==="boolean"?(le.type="checkbox",le.checked=re===!0,le.addEventListener("change",()=>{I.line_set(Zf(I.line_get(),U.flag,le.checked?!0:null))})):(le.type="text",le.placeholder=U.placeholder,le.value=re===null||re===!0?"":re,le.addEventListener("input",()=>{I.line_set(Zf(I.line_get(),U.flag,le.value))}));const ge=document.createElement("span");ge.className="telemetry-hint",ge.textContent=B,F.append(le,ge)}g.appendChild(F)}}function ue(g,y,E,I){if(g===void 0)return[];const D=g.arguments??[],B=[{label:"NODE",value:`${g.label} · @${g.id}`},{label:"PLUGIN",value:g.pluginName},...g.pluginVersion!==void 0?[{label:"VERSION",value:g.pluginVersion}]:[]];if(y){const U=QS(g.label,g.id,I);B.push(...D.length===0?[{label:"ARGUMENTS",value:"none — this node runs on the plugin's defaults"}]:D.map(F=>({label:F.name,value:String(F.value??""),...E?{edit:{flag:`--${U}.${F.name}`,type:typeof F.value=="boolean"?"boolean":"string",placeholder:String(F.value??"")}}:{}})))}else B.push({label:"ARGUMENTS",value:D.length===0?"none":`${D.length} — open the node to read them`});return B}function he(g,y,E){const I=[{label:"PLUGIN",value:g.name},{label:"VERSION",value:g.version},{label:"TYPE",value:g.type.toUpperCase()}],D=g.parameters;if(!y)return I.push({label:"PARAMETERS",value:D.length===0?"none":`${D.length} — open the node to read them`}),I;if(D.length===0)return I.push({label:"PARAMETERS",value:"none — this plugin takes no arguments"}),I;for(const B of D){const U=[B.type];B.optional||U.push("required");const F=B.default===void 0||B.default===null?"":String(B.default);F!==""&&U.push(`default ${F}`);const X=U.join(" · ");I.push({label:B.flag,value:B.help===void 0?X:`${X} — ${B.help}`,...E?{edit:{flag:B.flag,type:B.type,placeholder:F}}:{}})}return I}function Se(g,y,E,I){const D=g.closest(".files-body"),B=D?.querySelector(".diagram-strategy")??null,U=D?.querySelector(".diagram-projection")??null,F=D?.querySelector(".diagram-pulse")??null,X=I===void 0?null:D?.querySelector(".diagram-run")??null,re=()=>I?.(),le=()=>{const Fe=[];y.strategy_get()!=="ranked"&&Fe.push("MOLECULE"),y.projection_get()!=="3d"&&Fe.push("2D"),E.mode_annunciate(Fe.join(" · "))},ge=()=>{y.strategy_set(y.strategy_get()==="ranked"?"molecule":"ranked"),B!==null&&(B.textContent=y.strategy_get().toUpperCase()),le()},fe=()=>{y.projection_set(y.projection_get()==="3d"?"2d":"3d"),U!==null&&(U.textContent=y.projection_get().toUpperCase()),le()},Ue=()=>{y.wave_start(),F?.classList.add("pulse-running"),window.setTimeout(()=>F?.classList.remove("pulse-running"),EE)};return B!==null&&(B.textContent=y.strategy_get().toUpperCase()),U!==null&&(U.textContent=y.projection_get().toUpperCase()),B?.addEventListener("click",ge),U?.addEventListener("click",fe),F?.addEventListener("click",Ue),X?.addEventListener("click",re),le(),()=>{B?.removeEventListener("click",ge),U?.removeEventListener("click",fe),F?.removeEventListener("click",Ue),X?.removeEventListener("click",re),F?.classList.remove("pulse-running")}}const be=(g,y,E)=>{if(E.kind==="dir"){if(m.get(g)===!0)ve.line_run(`cd "${E.path}"`);else{const I=y.path_current();I!==null&&_.get(g)?.push(I),b(g,y,E.path)}return}if(E.kind==="plugin"||E.kind==="pipeline"){Q(g,y,E.path,E.kind);return}if(Re(E.path)){gt(g,E.path).then(I=>ve.line_note(I));return}if(l.regard_write(g,{address:E.path,modelKind:"fs.file"}),!l.groupHasViewer(g)){if(Wo(E.path)){y.contentImage_show(E.path,c(E.path));return}M(E.path).then(I=>{if(!I.ok){y.contentRefused_show(E.path,I.text);return}mp.test(E.path)?y.contentTable_show(E.path,I.text):y.content_show(E.path,I.text)})}},Re=g=>Mc.test(g)||Po.test(g),ht=()=>{const g=fn("tpl-pane-files").querySelector(".files-body");if(g===null)throw new Error("tpl-pane-files has no files-body");return g};let ct=null,tt=null;const oe=g=>{const y=/_(\d+)\/data\/?$/.exec(g);return y===null?null:parseInt(y[1]??"",10)},ye=new Map,Me=g=>{const y=g.match(/\/(?:feeds|jobs)\/feed_(\d+)(?:\/|$)/);return y===null?null:Number(y[1])},et=g=>/^\/(proc|net|etc|usr)(\/|$)/.test(g),nt=(g,y,E)=>{const I=`"${E}"`,D=y.type==="dir"||y.type==="vfs"||y.type==="job",B=Me(E),U={kind:y.type==="plugin"||y.type==="pipeline"?"catalogue":D&&gc(E,y.name)?"seriesFolder":y.type==="file"?"file":"directory",feed:B,node:B===null?null:oe(E),bound:ye.has(g),projection:et(E)},F={image:()=>{gt(g,E).then(X=>ve.line_note(X))},download:()=>ll(d(E)),process:()=>R(g,{input:E,feed:B,node:B===null?null:oe(E)}),gather:()=>ae([{kind:D?"dir":"file",seriesUID:E,description:y.name,imagery:gc(E,y.name),modality:gc(E,y.name)?"MR":"—",patient:ct??"",vfsPath:E,folderPath:E}]),run:()=>{we(g,y.name,y.type==="pipeline"?"pipeline":"plugin")},move:()=>bn(g,`mv ${I}`),copy:()=>bn(g,`cp ${I}`),delete:()=>bn(g,`rm ${D?"-ri":"-i"} ${I}`),share:()=>bn(g,`setfacl ${I}`)};return jm.rules.filter(X=>X.offered(U)).map(X=>({label:X.label(U),run:()=>F[X.name]?.()}))},Ye=g=>{for(const y of g.envelopes){const E=y.model;if(typeof E!="object"||E===null)continue;const I=E.data;if(E.kind!=="fs.acl"||!Array.isArray(I))continue;const D=[];for(const B of I)Array.isArray(B.usernames)&&D.push(...B.usernames.map(String));return D.length===0?"SHARED WITH NOBODY":`SHARED WITH ${D.join(", ")}`}return"ACCESS UNREAD"},qt=(g,y,E=!1)=>{const I=fn("tpl-pane-files"),D=new Cf(Bs(I,".files-panel"),B=>be(g,D,B),p,{catalogue:E});return D.selectionVerbs_declare(B=>{const U=B.map(([ge])=>ge),F=U.map(ge=>`"${ge}"`).join(" ");B.every(([,ge])=>ge.type==="file");const X=[];for(const ge of U){const fe=Me(ge);fe!==null&&!X.includes(fe)&&X.push(fe)}const re={count:U.length,feeds:X},le={delete:()=>bn(g,`rm -rI ${F}`),move:()=>ve.line_run(`mv -t ${F}`),copy:()=>ve.line_run(`cp -t ${F}`),share:()=>ve.line_run(`setfacl ${X.map(ge=>`feed_${ge}`).join(" ")}`)};return Vm.rules.filter(ge=>ge.offered(re)).map(ge=>({label:ge.label(re),run:()=>le[ge.name]?.()}))}),D.rowVerbs_declare((B,U)=>nt(g,B,U),(B,U)=>{l.regard_write(g,{address:U,modelKind:"fs.file"}),Me(U)!==null&&bt.line_execute(`getfacl "${U}"`,{silent:!0,observe:!1}).then(F=>{D.rowReadout_show(U,Ye(F))}).catch(()=>{D.rowReadout_show(U,"ACCESS UNREAD")})}),i.set(g,D),ct!==null&&ct!==""&&D.home_set(`/home/${ct}`),_.set(g,[]),m.set(g,y),v(g),D.follow_set(y),{id:g,kind:"files",mount:I,dispose:()=>{i.delete(g),_.delete(g),l.pane_leave(g)}}},pt=new Map,dt=new Map,At=g=>{const y=fn("tpl-pane-universe"),E=new xA({canvas:Bs(y,".universe-canvas"),title:Bs(y,".universe-title"),state:y.querySelector(".pane-state"),empty:Bs(y,".universe-empty"),projectionPill:y.querySelector(".universe-projection"),refreshPill:y.querySelector(".universe-refresh"),scalePill:y.querySelector(".universe-scale"),viewPill:y.querySelector(".universe-view"),gravityPill:y.querySelector(".universe-gravity"),densityPill:y.querySelector(".universe-density"),drawPill:y.querySelector(".universe-draw"),arrangementPill:y.querySelector(".universe-arrangement"),facts:y.querySelector(".universe-facts"),backPill:y.querySelector(".universe-back"),openPill:y.querySelector(".universe-open")},{command_run:I=>{bt.line_execute(I,{silent:!0,observe:!1}).then(D=>{for(const B of D.envelopes)E.envelope_observe(B)})},feed_dag:async I=>{const D=await bt.line_execute(`feed diagram feed_${I}`,{silent:!0,observe:!1});for(const B of D.envelopes){if(B.model?.kind!==gi.feedDag)continue;const U=Pc.safeParse(B.model.data);if(U.success)return U.data}return null},node_enter:I=>{ve.line_run(`cd "${I}"`)},node_dive:I=>{ke(g,I.replace(/\/data$/,""))},node_process:I=>{const D=Me(I.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(I.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(I.vfsPath)[1])),B=ct===null?I.vfsPath:I.vfsPath.replace(/^\/proc\/jobs\//,`/home/${ct}/feeds/`);R(g,{input:B,feed:D,node:I.instanceId})},feed_open:I=>{Gs(),Ys.feed_enter(I)},note:I=>ve.line_note(I)},bf());return o.set(g,E),{id:g,kind:"universe",mount:y,dispose:()=>{o.delete(g),l.pane_leave(g),E.dispose()}}},vt=g=>{const y=fn("tpl-pane-image"),E=new PA(y,{source:{url_of:c},note:I=>ve.line_note(I),regard:I=>l.regard_write(g,{address:I,modelKind:"dicom.instance"}),file_put:async(I,D)=>{try{return(await fetch(c(I),{method:"POST",body:D})).status}catch{return 0}},tags_read:I=>ss(I),tags_open:()=>{ve.line_note(Xt(g))}});return dt.set(g,E),{id:g,kind:"image",mount:y,dispose:()=>{E.dispose(),dt.delete(g),l.pane_leave(g)}}},Pt=new Map,ts=g=>{const y=fn("tpl-pane-tags"),E=new LA(y,{note:I=>ve.line_note(I)});return Pt.set(g,E),{id:g,kind:"tags",mount:y,dispose:()=>{Pt.delete(g),l.pane_leave(g)}}},ss=async g=>{try{const y=await bt.line_execute(`dcm tags "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!==Ga.tags)continue;const I=Nu.safeParse(E.model.data);if(I.success)return I.data}}catch{}return null},ls=(g,y)=>{const E=Pt.get(g);E===void 0||E.path_get()===y||ss(y).then(I=>{if(I===null){ve.line_note(`tags: ${y}: not a readable DICOM file`);return}Pt.get(g)?.model_show(I)})},Xt=g=>{const y=new Set(me.panes_shown()),E=l.group_of(g);for(const D of Pt.keys())if(y.has(D)&&l.group_of(D)===E)return me.focus_set(D),"image tags";if(!y.has(g))return"image tags: the image pane is not on stage";const I=De("tags",g);return me.leaf_split(g,de?.dir??"col",I.id,de?.before??!1)?(ln(I.id,g,de?.dir??"col",de?.before??!1),"image tags"):($s(I.id),me.mount_remove(I.id),"image tags: could not open beside the image pane")},Zt=async g=>{try{const y=await bt.line_execute(`dcm series "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!==Ga.series)continue;const I=Cu.safeParse(E.model.data);if(I.success)return I.data}}catch{}return null},j=async g=>{try{const y=await bt.line_execute(`ls "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!=="fs.listing")continue;const I=E.model.data,D=(I.path??g).replace(/\/$/,"");return(I.entries??[]).filter(B=>B.type==="dir").map(B=>`${D}/${B.name}`)}}catch{}return[]},vs=(g,y)=>{const E=F=>{y!==void 0&&l.regard_write(F,y)};if(g!==null&&dt.has(g))return E(g),dt.get(g)??null;const I=new Set(me.panes_shown());if(y!==void 0){for(const[F,X]of dt)if(I.has(F)&&l.regard_get(F)?.address===y.address)return E(F),X}const D=g!==null?l.group_of(g):null;for(const[F,X]of dt)if(I.has(F)&&D!==null&&l.group_of(F)===D)return X;const B=g!==null&&I.has(g)?g:an();if(B===null)return null;const U=De("image",g??void 0);return me.leaf_split(B,de?.dir??"col",U.id,de?.before??!1)?(ln(U.id,B,de?.dir??"col",de?.before??!1),E(U.id),dt.get(U.id)??null):($s(U.id),me.mount_remove(U.id),null)},gt=async(g,y,E={},I)=>{It();const D=g!==null?void 0:Mc.test(y)?{address:y,modelKind:"image.volume"}:{address:Po.test(y)?y.slice(0,y.lastIndexOf("/")):y.replace(/\/$/,""),modelKind:"dicom.series"},B=vs(g,D);if(B===null)return"image: no pane to open beside";const U=ot(B);if(U!==null&&I?.(U),Mc.test(y))return B.opening_show(y),B.volume_show(y),`image ${y}`;const F=Po.test(y),X=F?y.slice(0,y.lastIndexOf("/")):y.replace(/\/$/,"");B.opening_show(X);let re=await Zt(X),le=[];if(re===null&&!F){const fe=(await j(X)).slice(0,32);for(const Ue of fe){const Fe=await Zt(Ue);if(Fe!==null){le=fe.map(wt=>({path:wt,label:wt.split("/").pop()??wt})),re=Fe;break}}}if(re===null)return B.opening_fail(y,"NOT A READABLE SERIES"),`image: ${y}: not a readable DICOM series, study, or volume`;const ge=F?Math.max(1,re.files.indexOf(y)+1):1;return B.series_show(re,{siblings:le,startAt:ge,...E.force===!0?{force:!0}:{}}),`image ${re.path}${le.length>1?` (1 of ${le.length} series)`:""}`},R=(g,y)=>{It();const E=new Set(me.panes_shown());for(const[U,F]of ye)if(E.has(U)&&F.input===y.input){me.focus_set(U);return}const I=E.has(g)?g:an()??g,D=De("catalogue",g);if(!me.leaf_split(I,de?.dir??"col",D.id,de?.before??!1)){$s(D.id),me.mount_remove(D.id);return}ln(D.id,I,de?.dir??"col",de?.before??!1),ye.set(D.id,y);const B=i.get(D.id);B!==void 0&&(B.binding_set({input:y.input,place:y.feed===null?"new feed":`feed ${y.feed}${y.node===null?"":` · node ${y.node}`}`}),B.feedOpen_declare(U=>te(D.id,U)),b(D.id,B,"/bin"),K(B),me.focus_set(D.id))},w=5,$=40,K=g=>{bt.line_execute(`plugininstance list --limit ${$} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(E=>{const I=[];for(const D of E.envelopes)if(!(D.model?.kind!=="plugininstance.list"||!Array.isArray(D.model.data)))for(const B of D.model.data){if(typeof B.pluginName!="string"||typeof B.pluginVersion!="string"||ct!==null&&typeof B.owner=="string"&&B.owner!==ct||B.pluginName==="pl-dircopy")continue;const U=`${B.pluginName}-v${B.pluginVersion}`;if(I.includes(U)||I.push(U),I.length>=w)break}g.recent_set(I.length===0?null:I)}).catch(()=>{})},te=(g,y)=>{It();const E=new Set(me.panes_shown());for(const[B,U]of a)if(B!=="dag"&&E.has(B)&&U.feed_get()===y){me.focus_set(B);return}const I=E.has(g)?g:an()??g,D=De("dag",g);if(!me.leaf_split(I,de?.dir??"col",D.id,de?.before??!1)){$s(D.id),me.mount_remove(D.id);return}ln(D.id,I,de?.dir??"col",de?.before??!1),a.get(D.id)?.feed_enter(y)},we=async(g,y,E)=>{const I=ye.get(g),D=i.get(g);if(I===void 0||D===void 0)return;const B=fe=>{ve.output_write("err",`\x1B[31m${fe}\x1B[0m
4226
- `);const Ue=D.indicated_get();Ue!==null&&D.rowReadout_show(Ue,fe.toUpperCase().slice(0,80))};if(E==="pipeline"&&I.node===null){B(`${y}: a pipeline runs on a node — PROCESS a node of a feed`);return}let U=D.commandLine_get();if((U===""||Qf(U)!==y)&&(U=Yf(I.input,y)),I.feed===null&&!KS(U)){const fe=I.input.split("/").filter(Boolean).pop()??"feed",Fe=(await ni(g,{message:"Feed title: ",kind:"text",suggest:fe,commit:"RUN"})??"").trim();if(Fe==="")return;U=ZS(U,Fe)}D.commandLine_set(U),ve.line_echo(U);let F;try{F=await bt.line_execute(U,{silent:!0})}catch(fe){B(fe instanceof Error?fe.message:String(fe));return}ve.outcome_write(F),F.envelopes.some(fe=>fe.model?.kind==="fs.cwd")&&bt.line_execute("ls",{silent:!0});const re=F.envelopes.find(fe=>fe.model?.kind==="run.scheduled")?.model?.data;if(typeof re?.feedId=="number"){D.run_show(re.feedId);return}const le=F.envelopes.map(fe=>fe.renderedErr??"").join(" ").replace(/\x1b\[[0-9;]*m/g,"").trim().split(`
4225
+ `);for(const B of I.envelopes){if(B.model?.kind!==bi.pipelineDiagram)continue;const U=Cc.safeParse(B.model.data);if(!U.success)continue;const F=new Map(U.data.nodes.map(X=>[X.id,X]));return{text:T(D),nodes:U.data.nodes.map(X=>({id:X.id,label:X.label,parentIds:X.parentIds,joinParentIds:X.joinParentIds})),facts_show:(X,re,le,ge)=>{const fe=U.data.nodes.map(Ue=>Ue.label);J(X,ue(F.get(re),le,ge!==null,fe),le,ge)}}}return null},W=async g=>{const y=g.replace(/^.*\//,""),E=await bt.line_execute(`plugin info "${y}"`,{silent:!0,observe:!1});for(const I of E.envelopes){if(I.model?.kind!==cb)continue;const D=lb.safeParse(I.model.data);if(!D.success)continue;const B=D.data;return{text:"",nodes:[{id:y,label:B.name,parentIds:[],joinParentIds:[]}],facts_show:(U,F,X,re)=>{J(U,he(B,X,re!==null),X,re)}}}return null},Q=(g,y,E,I)=>{N(y,E,()=>I==="plugin"?W(E):C(E),se(g,y,E,I))},se=(g,y,E,I)=>{const D=ye.get(g);if(D===void 0)return null;const B=E.replace(/^.*\//,"");return Qf(y.commandLine_get())!==B&&y.commandLine_set(Yf(D.input,B)),{line_get:()=>y.commandLine_get(),line_set:U=>y.commandLine_set(U),run:()=>{we(g,B,I)}}};let H=null;function ee(){const g=H;return g===null?!1:(H=null,g.scene.flight_back(()=>{g.facts.classList.remove("dag-facts-immersed"),g.facts.replaceChildren()}),!0)}function J(g,y,E,I){g.replaceChildren(),g.classList.toggle("dag-facts-immersed",E);for(const{label:D,value:B,edit:U}of y){const F=document.createElement("div");F.className="telemetry-row";const X=document.createElement("span");if(X.className="telemetry-label",X.textContent=D,F.appendChild(X),U===void 0||I===null){const re=document.createElement("span");re.className="telemetry-value",re.textContent=B,F.appendChild(re)}else{const re=JS(I.line_get(),U.flag),le=document.createElement("input");le.className="telemetry-input",le.spellcheck=!1,le.autocomplete="off",le.title=`${U.flag} — ${B}`,U.type==="boolean"?(le.type="checkbox",le.checked=re===!0,le.addEventListener("change",()=>{I.line_set(Zf(I.line_get(),U.flag,le.checked?!0:null))})):(le.type="text",le.placeholder=U.placeholder,le.value=re===null||re===!0?"":re,le.addEventListener("input",()=>{I.line_set(Zf(I.line_get(),U.flag,le.value))}));const ge=document.createElement("span");ge.className="telemetry-hint",ge.textContent=B,F.append(le,ge)}g.appendChild(F)}}function ue(g,y,E,I){if(g===void 0)return[];const D=g.arguments??[],B=[{label:"NODE",value:`${g.label} · @${g.id}`},{label:"PLUGIN",value:g.pluginName},...g.pluginVersion!==void 0?[{label:"VERSION",value:g.pluginVersion}]:[]];if(y){const U=sA(g.label,g.id,I);B.push(...D.length===0?[{label:"ARGUMENTS",value:"none — this node runs on the plugin's defaults"}]:D.map(F=>({label:F.name,value:String(F.value??""),...E?{edit:{flag:`--${U}.${F.name}`,type:typeof F.value=="boolean"?"boolean":"string",placeholder:String(F.value??"")}}:{}})))}else B.push({label:"ARGUMENTS",value:D.length===0?"none":`${D.length} — open the node to read them`});return B}function he(g,y,E){const I=[{label:"PLUGIN",value:g.name},{label:"VERSION",value:g.version},{label:"TYPE",value:g.type.toUpperCase()}],D=g.parameters;if(!y)return I.push({label:"PARAMETERS",value:D.length===0?"none":`${D.length} — open the node to read them`}),I;if(D.length===0)return I.push({label:"PARAMETERS",value:"none — this plugin takes no arguments"}),I;for(const B of D){const U=[B.type];B.optional||U.push("required");const F=B.default===void 0||B.default===null?"":String(B.default);F!==""&&U.push(`default ${F}`);const X=U.join(" · ");I.push({label:B.flag,value:B.help===void 0?X:`${X} — ${B.help}`,...E?{edit:{flag:B.flag,type:B.type,placeholder:F}}:{}})}return I}function Se(g,y,E,I){const D=g.closest(".files-body"),B=D?.querySelector(".diagram-strategy")??null,U=D?.querySelector(".diagram-projection")??null,F=D?.querySelector(".diagram-pulse")??null,X=I===void 0?null:D?.querySelector(".diagram-run")??null,re=()=>I?.(),le=()=>{const Fe=[];y.strategy_get()!=="ranked"&&Fe.push("MOLECULE"),y.projection_get()!=="3d"&&Fe.push("2D"),E.mode_annunciate(Fe.join(" · "))},ge=()=>{y.strategy_set(y.strategy_get()==="ranked"?"molecule":"ranked"),B!==null&&(B.textContent=y.strategy_get().toUpperCase()),le()},fe=()=>{y.projection_set(y.projection_get()==="3d"?"2d":"3d"),U!==null&&(U.textContent=y.projection_get().toUpperCase()),le()},Ue=()=>{y.wave_start(),F?.classList.add("pulse-running"),window.setTimeout(()=>F?.classList.remove("pulse-running"),RE)};return B!==null&&(B.textContent=y.strategy_get().toUpperCase()),U!==null&&(U.textContent=y.projection_get().toUpperCase()),B?.addEventListener("click",ge),U?.addEventListener("click",fe),F?.addEventListener("click",Ue),X?.addEventListener("click",re),le(),()=>{B?.removeEventListener("click",ge),U?.removeEventListener("click",fe),F?.removeEventListener("click",Ue),X?.removeEventListener("click",re),F?.classList.remove("pulse-running")}}const be=(g,y,E)=>{if(E.kind==="dir"){if(m.get(g)===!0)ve.line_run(`cd "${E.path}"`);else{const I=y.path_current();I!==null&&_.get(g)?.push(I),b(g,y,E.path)}return}if(E.kind==="plugin"||E.kind==="pipeline"){Q(g,y,E.path,E.kind);return}if(Re(E.path)){gt(g,E.path).then(I=>ve.line_note(I));return}if(l.regard_write(g,{address:E.path,modelKind:"fs.file"}),!l.groupHasViewer(g)){if(Wo(E.path)){y.contentImage_show(E.path,c(E.path));return}M(E.path).then(I=>{if(!I.ok){y.contentRefused_show(E.path,I.text);return}mp.test(E.path)?y.contentTable_show(E.path,I.text):y.content_show(E.path,I.text)})}},Re=g=>Mc.test(g)||Po.test(g),ht=()=>{const g=fn("tpl-pane-files").querySelector(".files-body");if(g===null)throw new Error("tpl-pane-files has no files-body");return g};let ct=null,tt=null;const oe=g=>{const y=/_(\d+)\/data\/?$/.exec(g);return y===null?null:parseInt(y[1]??"",10)},ye=new Map,Me=g=>{const y=g.match(/\/(?:feeds|jobs)\/feed_(\d+)(?:\/|$)/);return y===null?null:Number(y[1])},et=g=>/^\/(proc|net|etc|usr)(\/|$)/.test(g),it=(g,y,E)=>{const I=`"${E}"`,D=y.type==="dir"||y.type==="vfs"||y.type==="job",B=Me(E),U={kind:y.type==="plugin"||y.type==="pipeline"?"catalogue":D&&gc(E,y.name)?"seriesFolder":y.type==="file"?"file":"directory",feed:B,node:B===null?null:oe(E),bound:ye.has(g),projection:et(E)},F={image:()=>{gt(g,E).then(X=>ve.line_note(X))},download:()=>ll(d(E)),process:()=>R(g,{input:E,feed:B,node:B===null?null:oe(E)}),gather:()=>ae([{kind:D?"dir":"file",seriesUID:E,description:y.name,imagery:gc(E,y.name),modality:gc(E,y.name)?"MR":"—",patient:ct??"",vfsPath:E,folderPath:E}]),run:()=>{we(g,y.name,y.type==="pipeline"?"pipeline":"plugin")},move:()=>bn(g,`mv ${I}`),copy:()=>bn(g,`cp ${I}`),delete:()=>bn(g,`rm ${D?"-ri":"-i"} ${I}`),share:()=>bn(g,`setfacl ${I}`)};return jm.rules.filter(X=>X.offered(U)).map(X=>({label:X.label(U),run:()=>F[X.name]?.()}))},Ye=g=>{for(const y of g.envelopes){const E=y.model;if(typeof E!="object"||E===null)continue;const I=E.data;if(E.kind!=="fs.acl"||!Array.isArray(I))continue;const D=[];for(const B of I)Array.isArray(B.usernames)&&D.push(...B.usernames.map(String));return D.length===0?"SHARED WITH NOBODY":`SHARED WITH ${D.join(", ")}`}return"ACCESS UNREAD"},qt=(g,y,E=!1)=>{const I=fn("tpl-pane-files"),D=new Cf(Bs(I,".files-panel"),B=>be(g,D,B),p,{catalogue:E});return D.selectionVerbs_declare(B=>{const U=B.map(([ge])=>ge),F=U.map(ge=>`"${ge}"`).join(" ");B.every(([,ge])=>ge.type==="file");const X=[];for(const ge of U){const fe=Me(ge);fe!==null&&!X.includes(fe)&&X.push(fe)}const re={count:U.length,feeds:X},le={delete:()=>bn(g,`rm -rI ${F}`),move:()=>ve.line_run(`mv -t ${F}`),copy:()=>ve.line_run(`cp -t ${F}`),share:()=>ve.line_run(`setfacl ${X.map(ge=>`feed_${ge}`).join(" ")}`)};return Vm.rules.filter(ge=>ge.offered(re)).map(ge=>({label:ge.label(re),run:()=>le[ge.name]?.()}))}),D.rowVerbs_declare((B,U)=>it(g,B,U),(B,U)=>{l.regard_write(g,{address:U,modelKind:"fs.file"}),Me(U)!==null&&bt.line_execute(`getfacl "${U}"`,{silent:!0,observe:!1}).then(F=>{D.rowReadout_show(U,Ye(F))}).catch(()=>{D.rowReadout_show(U,"ACCESS UNREAD")})}),i.set(g,D),ct!==null&&ct!==""&&D.home_set(`/home/${ct}`),_.set(g,[]),m.set(g,y),v(g),D.follow_set(y),{id:g,kind:"files",mount:I,dispose:()=>{i.delete(g),_.delete(g),l.pane_leave(g)}}},pt=new Map,dt=new Map,At=g=>{const y=fn("tpl-pane-universe"),E=new DA({canvas:Bs(y,".universe-canvas"),title:Bs(y,".universe-title"),state:y.querySelector(".pane-state"),empty:Bs(y,".universe-empty"),projectionPill:y.querySelector(".universe-projection"),refreshPill:y.querySelector(".universe-refresh"),scalePill:y.querySelector(".universe-scale"),viewPill:y.querySelector(".universe-view"),gravityPill:y.querySelector(".universe-gravity"),densityPill:y.querySelector(".universe-density"),drawPill:y.querySelector(".universe-draw"),arrangementPill:y.querySelector(".universe-arrangement"),facts:y.querySelector(".universe-facts"),backPill:y.querySelector(".universe-back"),openPill:y.querySelector(".universe-open")},{command_run:I=>{bt.line_execute(I,{silent:!0,observe:!1}).then(D=>{for(const B of D.envelopes)E.envelope_observe(B)})},feed_dag:async I=>{const D=await bt.line_execute(`feed diagram feed_${I}`,{silent:!0,observe:!1});for(const B of D.envelopes){if(B.model?.kind!==bi.feedDag)continue;const U=Pc.safeParse(B.model.data);if(U.success)return U.data}return null},node_enter:I=>{ve.line_run(`cd "${I}"`)},node_dive:I=>{ke(g,I.replace(/\/data$/,""))},node_process:I=>{const D=Me(I.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(I.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(I.vfsPath)[1])),B=ct===null?I.vfsPath:I.vfsPath.replace(/^\/proc\/jobs\//,`/home/${ct}/feeds/`);R(g,{input:B,feed:D,node:I.instanceId})},feed_open:I=>{Gs(),Ys.feed_enter(I)},note:I=>ve.line_note(I)},bf());return o.set(g,E),{id:g,kind:"universe",mount:y,dispose:()=>{o.delete(g),l.pane_leave(g),E.dispose()}}},vt=g=>{const y=fn("tpl-pane-image"),E=new UA(y,{source:{url_of:c},note:I=>ve.line_note(I),regard:I=>l.regard_write(g,{address:I,modelKind:"dicom.instance"}),file_put:async(I,D)=>{try{return(await fetch(c(I),{method:"POST",body:D})).status}catch{return 0}},tags_read:I=>ss(I),tags_open:()=>{ve.line_note(Xt(g))}});return dt.set(g,E),{id:g,kind:"image",mount:y,dispose:()=>{E.dispose(),dt.delete(g),l.pane_leave(g)}}},Pt=new Map,ts=g=>{const y=fn("tpl-pane-tags"),E=new jA(y,{note:I=>ve.line_note(I)});return Pt.set(g,E),{id:g,kind:"tags",mount:y,dispose:()=>{Pt.delete(g),l.pane_leave(g)}}},ss=async g=>{try{const y=await bt.line_execute(`dcm tags "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!==Ga.tags)continue;const I=Nu.safeParse(E.model.data);if(I.success)return I.data}}catch{}return null},ls=(g,y)=>{const E=Pt.get(g);E===void 0||E.path_get()===y||ss(y).then(I=>{if(I===null){ve.line_note(`tags: ${y}: not a readable DICOM file`);return}Pt.get(g)?.model_show(I)})},Xt=g=>{const y=new Set(me.panes_shown()),E=l.group_of(g);for(const D of Pt.keys())if(y.has(D)&&l.group_of(D)===E)return me.focus_set(D),"image tags";if(!y.has(g))return"image tags: the image pane is not on stage";const I=De("tags",g);return me.leaf_split(g,de?.dir??"col",I.id,de?.before??!1)?(ln(I.id,g,de?.dir??"col",de?.before??!1),"image tags"):($s(I.id),me.mount_remove(I.id),"image tags: could not open beside the image pane")},Zt=async g=>{try{const y=await bt.line_execute(`dcm series "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!==Ga.series)continue;const I=Cu.safeParse(E.model.data);if(I.success)return I.data}}catch{}return null},j=async g=>{try{const y=await bt.line_execute(`ls "${g}"`,{silent:!0,observe:!1});for(const E of y.envelopes){if(E.model?.kind!=="fs.listing")continue;const I=E.model.data,D=(I.path??g).replace(/\/$/,"");return(I.entries??[]).filter(B=>B.type==="dir").map(B=>`${D}/${B.name}`)}}catch{}return[]},vs=(g,y)=>{const E=F=>{y!==void 0&&l.regard_write(F,y)};if(g!==null&&dt.has(g))return E(g),dt.get(g)??null;const I=new Set(me.panes_shown());if(y!==void 0){for(const[F,X]of dt)if(I.has(F)&&l.regard_get(F)?.address===y.address)return E(F),X}const D=g!==null?l.group_of(g):null;for(const[F,X]of dt)if(I.has(F)&&D!==null&&l.group_of(F)===D)return X;const B=g!==null&&I.has(g)?g:an();if(B===null)return null;const U=De("image",g??void 0);return me.leaf_split(B,de?.dir??"col",U.id,de?.before??!1)?(ln(U.id,B,de?.dir??"col",de?.before??!1),E(U.id),dt.get(U.id)??null):($s(U.id),me.mount_remove(U.id),null)},gt=async(g,y,E={},I)=>{It();const D=g!==null?void 0:Mc.test(y)?{address:y,modelKind:"image.volume"}:{address:Po.test(y)?y.slice(0,y.lastIndexOf("/")):y.replace(/\/$/,""),modelKind:"dicom.series"},B=vs(g,D);if(B===null)return"image: no pane to open beside";const U=ot(B);if(U!==null&&I?.(U),Mc.test(y))return B.opening_show(y),B.volume_show(y),`image ${y}`;const F=Po.test(y),X=F?y.slice(0,y.lastIndexOf("/")):y.replace(/\/$/,"");B.opening_show(X);let re=await Zt(X),le=[];if(re===null&&!F){const fe=(await j(X)).slice(0,32);for(const Ue of fe){const Fe=await Zt(Ue);if(Fe!==null){le=fe.map(wt=>({path:wt,label:wt.split("/").pop()??wt})),re=Fe;break}}}if(re===null)return B.opening_fail(y,"NOT A READABLE SERIES"),`image: ${y}: not a readable DICOM series, study, or volume`;const ge=F?Math.max(1,re.files.indexOf(y)+1):1;return B.series_show(re,{siblings:le,startAt:ge,...E.force===!0?{force:!0}:{}}),`image ${re.path}${le.length>1?` (1 of ${le.length} series)`:""}`},R=(g,y)=>{It();const E=new Set(me.panes_shown());for(const[U,F]of ye)if(E.has(U)&&F.input===y.input){me.focus_set(U);return}const I=E.has(g)?g:an()??g,D=De("catalogue",g);if(!me.leaf_split(I,de?.dir??"col",D.id,de?.before??!1)){$s(D.id),me.mount_remove(D.id);return}ln(D.id,I,de?.dir??"col",de?.before??!1),ye.set(D.id,y);const B=i.get(D.id);B!==void 0&&(B.binding_set({input:y.input,place:y.feed===null?"new feed":`feed ${y.feed}${y.node===null?"":` · node ${y.node}`}`}),B.feedOpen_declare(U=>te(D.id,U)),b(D.id,B,"/bin"),K(B),me.focus_set(D.id))},w=5,$=40,K=g=>{bt.line_execute(`plugininstance list --limit ${$} --fields id,plugin_name,plugin_version,owner_username`,{silent:!0,observe:!1}).then(E=>{const I=[];for(const D of E.envelopes)if(!(D.model?.kind!=="plugininstance.list"||!Array.isArray(D.model.data)))for(const B of D.model.data){if(typeof B.pluginName!="string"||typeof B.pluginVersion!="string"||ct!==null&&typeof B.owner=="string"&&B.owner!==ct||B.pluginName==="pl-dircopy")continue;const U=`${B.pluginName}-v${B.pluginVersion}`;if(I.includes(U)||I.push(U),I.length>=w)break}g.recent_set(I.length===0?null:I)}).catch(()=>{})},te=(g,y)=>{It();const E=new Set(me.panes_shown());for(const[B,U]of a)if(B!=="dag"&&E.has(B)&&U.feed_get()===y){me.focus_set(B);return}const I=E.has(g)?g:an()??g,D=De("dag",g);if(!me.leaf_split(I,de?.dir??"col",D.id,de?.before??!1)){$s(D.id),me.mount_remove(D.id);return}ln(D.id,I,de?.dir??"col",de?.before??!1),a.get(D.id)?.feed_enter(y)},we=async(g,y,E)=>{const I=ye.get(g),D=i.get(g);if(I===void 0||D===void 0)return;const B=fe=>{ve.output_write("err",`\x1B[31m${fe}\x1B[0m
4226
+ `);const Ue=D.indicated_get();Ue!==null&&D.rowReadout_show(Ue,fe.toUpperCase().slice(0,80))};if(E==="pipeline"&&I.node===null){B(`${y}: a pipeline runs on a node — PROCESS a node of a feed`);return}let U=D.commandLine_get();if((U===""||Qf(U)!==y)&&(U=Yf(I.input,y)),I.feed===null&&!eA(U)){const fe=I.input.split("/").filter(Boolean).pop()??"feed",Fe=(await ni(g,{message:"Feed title: ",kind:"text",suggest:fe,commit:"RUN"})??"").trim();if(Fe==="")return;U=tA(U,Fe)}D.commandLine_set(U),ve.line_echo(U);let F;try{F=await bt.line_execute(U,{silent:!0})}catch(fe){B(fe instanceof Error?fe.message:String(fe));return}ve.outcome_write(F),F.envelopes.some(fe=>fe.model?.kind==="fs.cwd")&&bt.line_execute("ls",{silent:!0});const re=F.envelopes.find(fe=>fe.model?.kind==="run.scheduled")?.model?.data;if(typeof re?.feedId=="number"){D.run_show(re.feedId);return}const le=F.envelopes.map(fe=>fe.renderedErr??"").join(" ").replace(/\x1b\[[0-9;]*m/g,"").trim().split(`
4227
4227
  `)[0]??"",ge=D.indicated_get();ge!==null&&D.rowReadout_show(ge,le===""?"NOT SCHEDULED":le.toUpperCase().slice(0,80))},Ae=g=>{It();const y=new Set(me.panes_shown());for(const[U]of i)if(y.has(U)&&l.regard_get(U)?.address===g){me.focus_set(U);return}let E;for(const[U,F]of dt)if(y.has(U)&&(l.regard_get(U)?.address===g||F.state_get()?.path===g)){E=U;break}const I=an();if(I===null)return;const D=De("files",E);if(!me.leaf_split(I,de?.dir??"col",D.id,de?.before??!1)){$s(D.id),me.mount_remove(D.id);return}ln(D.id,I,de?.dir??"col",de?.before??!1),E===void 0&&l.regard_write(D.id,{address:g,modelKind:"dicom.series"});const B=i.get(D.id);B!==void 0&&b(D.id,B,g)},ne=g=>{const y=fn("tpl-pane-gather"),E=new Xf(y,Bs(y,".gather-rows"),{command_run:I=>{bt.line_execute(I,{silent:!0})},command_show:I=>ve.line_run(I),note:I=>ve.line_note(I),image_open:I=>{gt(g,I).then(D=>ve.line_note(D))},process_open:I=>R(g,{input:I,feed:null,node:null}),name_ask:I=>ni(g,{message:"Cohort name: ",kind:"text",suggest:I,commit:"NAME IT"}),confirm_ask:async I=>{const D=await ni(g,{message:I,kind:"confirm"});return D==="y"||D==="n"?D:null},changed:()=>zn(),dismiss:()=>{me.leaf_close(g)||Le(),Te(),zn()},feed_create:async I=>{ve.line_echo(I);let D;try{D=await bt.line_execute(I,{silent:!0})}catch(B){return ve.output_write("err",`\x1B[31m${B instanceof Error?B.message:String(B)}\x1B[0m
4228
- `),null}ve.outcome_write(D);for(const B of D.envelopes){if(B.model?.kind!=="feed.created")continue;const U=B.model.data;if(typeof U.feedId=="number"&&typeof U.rootInstanceId=="number"&&typeof U.path=="string")return{feedId:U.feedId,rootInstanceId:U.rootInstanceId,path:U.path}}return null},cohort_process:I=>R(g,I),feed_open:I=>te(g,I)},Ee);return r.set(g,E),{id:g,kind:"gather",mount:y,dispose:()=>{r.delete(g),l.pane_leave(g)}}};let ie=null;const Ee=new $S;let Ve=!1;const Ge="~/gather/current.json";let xe=null;const Xe=()=>{xe!==null&&window.clearTimeout(xe),xe=window.setTimeout(()=>{xe=null;const g=ie?.entries_get()??[],y=JSON.stringify({version:1,name:ie?.name_get()??null,feed:ie?.feed_get()??null,series:g});bt.line_execute("mkdir -p ~/gather",{silent:!0,observe:!1}),bt.line_execute(`touch --withContents '${y.replace(/'/g,"'\\''")}' ${Ge}`,{silent:!0,observe:!1})},1200)},Ke=async()=>{const g=await M(Ge);if(g.ok)try{const y=JSON.parse(g.text);if(!Array.isArray(y.series)||y.series.length===0)return;ie===null&&(ie=it());for(const E of y.series)ie.series_add(E);Oe(),zn()}catch{}},it=()=>{const g=rt("header-gather"),y=()=>an()??"pacs";return new Xf(g,Bs(g,".gather-rows"),{command_run:E=>{bt.line_execute(E,{silent:!0})},command_show:E=>ve.line_run(E),note:E=>ve.line_note(E),image_open:E=>{gt(y(),E).then(I=>ve.line_note(I))},process_open:E=>R(y(),{input:E,feed:null,node:null}),name_ask:async E=>{const I=rt("header-gather"),D=ve.ask_note("Cohort name: "),B=await vc(I,{message:"Cohort name: ",kind:"text",suggest:E,commit:"NAME IT"});return D(B),B},confirm_ask:async E=>{const I=rt("header-gather"),D=ve.ask_note(`${E} `),B=await vc(I,{message:E,kind:"confirm"});return D(B),B==="y"||B==="n"?B:null},changed:()=>{zn(),Oe(),Xe()},dismiss:()=>{document.body.dataset.header="away",Ve=!0,Oe()},feed_create:async E=>{ve.line_echo(E);let I;try{I=await bt.line_execute(E,{silent:!0})}catch(D){return ve.output_write("err",`\x1B[31m${D instanceof Error?D.message:String(D)}\x1B[0m
4229
- `),null}ve.outcome_write(I);for(const D of I.envelopes){if(D.model?.kind!=="feed.created")continue;const B=D.model.data;if(typeof B.feedId=="number"&&typeof B.rootInstanceId=="number"&&typeof B.path=="string")return{feedId:B.feedId,rootInstanceId:B.rootInstanceId,path:B.path}}return null},cohort_process:E=>R(y(),E),feed_open:E=>te(y(),E)},Ee)},L=()=>{const g=new Set(me.panes_shown()),y=[...r.keys()].find(E=>g.has(E))??null;if(y!==null)me.focus_set(y);else{const E=an()??"pacs",I=De("gather","pacs");if(!me.leaf_split(E,"col",I.id,!1)){$s(I.id),me.mount_remove(I.id);return}ln(I.id,E,"col",!1),r.get(I.id)?.render_now()}document.body.dataset.header="away",Ve=!0},Oe=()=>{const g=document.querySelector("#header-gather-pill");if(g===null)return;const y=ie?.entries_get().length??0;g.classList.toggle("panel-gather-empty",y===0)},ae=g=>{ie===null&&(ie=it());for(const E of g)ie.series_add(E);const y=document.body.dataset.header==="away";(!Ve||!y)&&(document.body.dataset.header="gather",Ve=!1),Oe(),Xe()},Ie=(g,y="pacs")=>{const E=new Set(me.panes_shown());let I=[...r.keys()].find(B=>E.has(B))??null;if(I===null){const B=E.has(y)?y:an()??y,U=De("gather","pacs");if(!me.leaf_split(B,de?.dir??"row",U.id,de?.before??!1))return $s(U.id),me.mount_remove(U.id),null;ln(U.id,B,de?.dir??"row",de?.before??!1),I=U.id}const D=r.get(I);if(D===void 0)return null;for(const B of g)D.series_add(B);return I},Ne=g=>{const y=fn("tpl-pane-view"),E=new TA(Bs(y,".view-body"),Bs(y,".view-title"),{content_fetch:async I=>(await M(I)).text,imageUrl_build:c,path_isImage:Wo});return pt.set(g,E),{id:g,kind:"view",mount:y,dispose:()=>{pt.delete(g),l.pane_leave(g)}}},ce=new Map,$e=g=>a.get(g)??o.get(g),ke=(g,y)=>{const I=mn(g)?.mount?.querySelector(".dag-canvas, .universe-canvas")??null,D=ce.get(g);if(D!==void 0&&!D.element.isConnected&&ce.delete(g),I===null||ce.has(g)){ve.line_note(`dag: ${y}: ${I===null?"this pane has no scene to fly in":"a node is already open here"} — flew back out`),$e(g)?.flight_back(()=>{});return}const B=document.createElement("div");B.className="node-overlay";const U=document.createElement("header");U.className="node-overlay-header";const F=document.createElement("span");F.textContent=`INSIDE ${y}`.toUpperCase();const X=document.createElement("span");X.className="node-overlay-hint",X.textContent="ESC EXITS NODE",U.append(F,X);const re=ht();re.classList.add("node-overlay-body"),B.append(U,re);const le=[],ge=new Cf(Bs(re,".files-panel"),fe=>{if(fe.kind==="dir"){const Ue=fe.path.startsWith("/proc/jobs/")?(fe.path.split("/").pop()??"").match(/_(\d+)$/):null;if(Ue!==null){const wt=parseInt(Ue[1]??"",10);Yt(g,()=>{$e(g)?.node_flyTo(wt)!==!0&&ke(g,fe.path)});return}const Fe=ge.path_current();Fe!==null&&le.push(Fe),b(g,ge,fe.path);return}if(l.regard_write(g,{address:fe.path,modelKind:"fs.file"}),!l.groupHasViewer(g)){if(Re(fe.path)){gt(g,fe.path).then(Ue=>ve.line_note(Ue));return}if(Wo(fe.path)){ge.contentImage_show(fe.path,c(fe.path));return}M(fe.path).then(Ue=>{if(!Ue.ok){ge.contentRefused_show(fe.path,Ue.text);return}mp.test(fe.path)?ge.contentTable_show(fe.path,Ue.text):ge.content_show(fe.path,Ue.text)})}},p);ge.rowVerbs_declare((fe,Ue)=>nt(g,fe,Ue),(fe,Ue)=>{l.regard_write(g,{address:Ue,modelKind:"fs.file"})}),ce.set(g,{element:B,panel:ge,history:le}),I.appendChild(B),window.requestAnimationFrame(()=>B.classList.add("node-overlay-open")),b(g,ge,y)},Yt=(g,y)=>{const E=ce.get(g);if(E===void 0){y?.();return}ce.delete(g),E.element.classList.remove("node-overlay-open");const I=()=>{E.element.remove(),y?.()},D=$e(g);D!==void 0?D.flight_back(I):I()},Wt=(g,y)=>{const E=fn("tpl-pane-dag"),I=new MA(Bs(E,".dag-canvas"),Bs(E,".dag-title"),Bs(E,".dag-facts"),Bs(E,".dag-empty"),Bs(E,".dag-strategy"),Bs(E,".dag-feedlist"),{command_run:D=>{bt.line_execute(D,{silent:!0,observe:!1}).then(B=>{for(const U of B.envelopes)I.envelope_observe(U)})},watch_set:(D,B)=>{B?bt.watch_send(D):bt.unwatch_send(D)},node_enter:D=>{ve.line_run(`cd "${D}"`)},node_dive:D=>{ke(g,D.replace(/\/data$/,""))},node_regard:D=>{l.regard_write(g,{address:D,modelKind:"feed.node"})},node_process:D=>{const B=Me(D.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(D.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(D.vfsPath)[1])),U=ct===null?D.vfsPath:D.vfsPath.replace(/^\/proc\/jobs\//,`/home/${ct}/feeds/`);R(g,{input:U,feed:B,node:D.instanceId})},feed_regard:D=>{l.regard_write(g,{address:D,modelKind:"feed"})},feed_verbs:D=>{const B={feedId:D.id},U={share:()=>ve.line_run(`setfacl feed_${D.id}`),delete:()=>ve.line_run(`feed rm feed_${D.id}`)};return $m.rules.filter(F=>F.offered(B)).map(F=>({label:F.label(B),run:()=>U[F.name]?.()}))},feed_indicated:D=>{l.regard_write(g,{address:`/proc/jobs/feed_${D.id}`,modelKind:"feed"}),bt.line_execute(`getfacl feed_${D.id}`,{silent:!0,observe:!1}).then(B=>{a.get(g)?.rowReadout_show(D.id,Ye(B))}).catch(()=>{a.get(g)?.rowReadout_show(D.id,"ACCESS UNREAD")})},...y?{feed_shown:()=>ps()}:{}});return a.set(g,I),{id:g,kind:"dag",mount:E,dispose:()=>{ce.get(g)?.element.remove(),ce.delete(g),a.delete(g),l.pane_leave(g),I.dispose()}}},Ws=qt("files",!0);Sr(Ws);const Ls=Wt("dag",!0);Sr(Ls);const Vr=At("universe");Sr(Vr);const Oi=fn("tpl-pane-launcher");Sr({id:"launcher",kind:"launcher",mount:Oi});const xi=fn("tpl-pane-panes");Sr({id:"panes",kind:"panes",mount:xi});const $r=i.get("files"),Ys=a.get("dag"),Hr=new aE(rt("pipeline-cycler"),rt("pipeline-cycler-name"),g=>{bt.line_execute(g,{silent:!0})}),an=()=>{const g=me.tree_get();if(g===null)return null;const y=[],E=D=>{if("pane"in D){y.push(D.pane);return}E(D.first),E(D.second)};E(g);const I=me.focused_get();return I!==null&&y.includes(I)?I:y[0]??null},Gn=async g=>{const y=an();if(y===null)return null;const E=De("files");if(!me.leaf_split(y,de?.dir??"col",E.id,de?.before??!1))return $s(E.id),me.mount_remove(E.id),null;ln(E.id,y,de?.dir??"col",de?.before??!1);const I=i.get(E.id),D=g.path?.anchor??"~";I!==void 0&&b(E.id,I,D);const B=E.mount.querySelector(".files-body");if(B===null)return $s(E.id),me.mount_remove(E.id),null;const U=document.createElement("div");U.className="errand-bar",B.insertBefore(U,B.firstChild);const F=document.createElement("span");F.className="errand-caption",F.textContent=g.message.trim();const X=document.createElement("input");X.className="errand-path",X.spellcheck=!1;const re=document.createElement("button");re.className="pacs-capsule errand-commit",re.textContent=g.commit??"USE THIS",U.append(F,X,re);const le=()=>{const Ue=I?.path_current()??D,Fe=g.path?.suggest;X.value=g.path?.wantsDirectory===!0||Fe===void 0?Ue:`${Ue.replace(/\/$/,"")}/${Fe}`};le();let ge=!1;X.addEventListener("input",()=>{ge=!0});const fe=()=>{ge||le()};return E.mount.addEventListener("click",fe),ve.question_set(!0),new Promise(Ue=>{const Fe=wt=>{E.mount.removeEventListener("click",fe),ve.question_set(!1),si=null,me.leaf_close(E.id),$s(E.id),me.mount_remove(E.id),Ue(wt)};si=()=>Fe(null),re.addEventListener("click",()=>Fe(X.value.trim()===""?null:X.value.trim())),X.addEventListener("keydown",wt=>{wt.key==="Enter"&&Fe(X.value.trim()===""?null:X.value.trim())})})};let si=null,tr=null,sr=null;const bn=(g,y)=>{sr=g,ve.line_run(y)},ni=async(g,y)=>{const E=mn(g)?.mount;if(E===void 0)return tr?.(!1),ve.ask_open({message:y.message,kind:y.kind,...y.suggest===void 0?{}:{suggest:y.suggest}});const I=ve.ask_note(y.message),D=await vc(E,y);return I(y.kind==="secret"&&D!==null?"••••••":D),D},ks=new kS(rt("pacs-workspace"),{command_run:g=>{/^(pacs query|pull )/.test(g)&&ve.line_echo(g),bt.line_execute(g,{silent:!0}).then(y=>{for(const E of y.envelopes)ks.envelope_observe(E)})},command_show:g=>{ve.line_run(g)},note:g=>ve.line_note(g),image_open:g=>{gt(null,g).then(y=>ve.line_note(y))},dir_open:g=>Ae(g),process_open:g=>R("pacs",{input:g,feed:null,node:null}),gather_add:g=>ae([g]),gathered_is:g=>ie?.has(g)===!0,workspace_close:()=>Le()});Sr({id:"pacs",kind:"pacs",mount:rt("pacs-workspace")});const zn=()=>{const g=new Set(me.panes_shown()),y=new Map;for(const E of xo()){if(!g.has(E.id))continue;const I=l.regard_get(E.id)?.address;if(I===void 0)continue;const D=zs(E.id);if(D!=="image"&&D!=="files")continue;const B=I.replace(/\/$/,""),U=y.get(B)??{viewer:!1,browser:!1};D==="image"?U.viewer=!0:U.browser=!0,y.set(B,U)}ks.stage_lit(y)},me=new bE(rt("layout-root"),new Map([["dag",Ls.mount],["universe",Vr.mount],["files",Ws.mount],["pacs",rt("pacs-workspace")],["launcher",Oi],["panes",xi]]));let on=!1;const vl=()=>on?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};me.preset_register("files",vl),me.preset_register("pacs",()=>({pane:"pacs"})),me.preset_register("dag",()=>({pane:"dag"})),me.preset_register("universe",()=>({pane:"universe"})),me.preset_register("panes",()=>({pane:"panes"})),me.preset_register("launcher",()=>({pane:"launcher"})),me.renderObserver_set(()=>{window.requestAnimationFrame(()=>{for(const g of a.values())g.size_fit()})});const Ta=new Map,ln=(g,y,E,I,D)=>{Ta.set(g,{parent:y,dir:E,before:I,...D!==void 0?{binding:D}:{}})},A=(g,y,E,I)=>{const D=y==="view"?De("view",g):y==="fs"?De("files",g):De("empty");if(!me.leaf_split(g,E,D.id,I))return $s(D.id),me.mount_remove(D.id),null;if(ln(D.id,g,E,I,y),y==="fs"){const B=F=>{const X=i.get(D.id);if(X===void 0)return;const re=F.modelKind==="fs.file"?F.address.replace(/\/[^/]*$/,"")||"/":F.address;b(D.id,X,re)};l.regard_subscribe(D.id,B);const U=l.regard_get(g);U!==null&&B(U)}return D.id},k=new Bx(Rm,bf());Object.assign(globalThis,{__argusDormant:{list:()=>k.list(),get:g=>k.get(g),dismiss:g=>k.dismiss(g)}});const Z=g=>{if(g==="pacs")return"⊞";if(g==="dag")return"⋔";const y=zs(g);return y==="image"?"▣":y==="tags"?"≣":"▤"},Y=g=>{if(g.length===0)return;const y=[];for(const re of g){const le=mn(re)?.mount;if(le===void 0)continue;const ge=le.getBoundingClientRect();ge.width>0&&ge.height>0&&y.push({id:re,left:ge.left,top:ge.top,width:ge.width,height:ge.height})}if(y.length===0)return;const E=Math.min(...y.map(re=>re.left)),I=Math.min(...y.map(re=>re.top)),D=Math.max(...y.map(re=>re.left+re.width))-E,B=Math.max(...y.map(re=>re.top+re.height))-I;if(D<=0||B<=0)return;const U=240,F=U/D,X=Math.max(40,Math.min(260,Math.round(B*F)));try{const re=document.createElement("canvas");re.width=U,re.height=X;const le=re.getContext("2d");if(le===null)return;const fe=getComputedStyle(document.documentElement).getPropertyValue("--harvestgold").trim()||"#c9a15a";le.fillStyle="#05070a",le.fillRect(0,0,U,X);for(const Ue of y){const Fe=Math.round((Ue.left-E)*F),wt=Math.round((Ue.top-I)*F),Kt=Math.max(6,Math.round(Ue.width*F)),yt=Math.max(6,Math.round(Ue.height*F)),ut=mn(Ue.id)?.mount.querySelector("canvas");if(ut!=null&&ut.width>0){const ms=Math.min(Kt/ut.width,yt/ut.height),mt=Math.round(ut.width*ms),Nt=Math.round(ut.height*ms);le.fillStyle="#000",le.fillRect(Fe,wt,Kt,yt),le.drawImage(ut,Fe+Math.round((Kt-mt)/2),wt+Math.round((yt-Nt)/2),mt,Nt)}else le.fillStyle="rgba(255,255,255,0.05)",le.fillRect(Fe,wt,Kt,yt),le.fillStyle=fe,le.font=`${Math.max(9,Math.min(28,Math.round(Math.min(Kt,yt)*.5)))}px serif`,le.textAlign="center",le.textBaseline="middle",le.fillText(Z(Ue.id),Fe+Kt/2,wt+yt/2+1);le.strokeStyle="rgba(255,255,255,0.22)",le.lineWidth=1,le.strokeRect(Fe+.5,wt+.5,Kt-1,yt-1)}return re.toDataURL("image/png")}catch{return}};let q=!1,de=null;const We=()=>{if(q)return;const g=new Set(me.panes_shown()),y=me.activePreset_get();if(y==="panes"||y==="launcher")return;const E=xo().map(Fe=>Fe.id).filter(Fe=>g.has(Fe)),I=new Map;let D,B;const U=[];for(const Fe of E){const wt=zs(Fe),Kt=Ta.get(Fe),yt=I.get(Kt?.parent??"")??0,ut={dir:Kt?.dir??"col",side:Kt?.before?"before":"after"},ms=mt=>{I.set(Fe,U.length),U.push(mt)};if(Fe==="pacs"||Fe==="files"||Fe==="dag"){const mt=y==="dag"?"runs":y,Nt=y==="pacs"?ks.query_get():null,Ms=y==="dag"?a.get("dag"):void 0,Ks=Ms!==void 0&&Ms.graph_isShown()?Ms.feed_get():null,Yr=Ks!==null&&Ms!==void 0?Ms.view_lines():[];Ks!==null&&B===void 0&&(B=Ms?.feedTitle_get()),ms({op:"domain",domain:mt,...Nt!==null?{query:Nt}:{},...Ks!==null?{feed:Ks}:{},...Yr.length>0?{view:Yr}:{}})}else if(Kt?.binding==="fs"||Kt?.binding==="view"||Kt?.binding==="empty")ms({op:Kt.binding,target:yt,...ut});else if(wt==="image"){const mt=dt.get(Fe),Nt=mt?.state_get()??null;if(mt===void 0||Nt===null||Nt.path===null)continue;const Ms=[];if(Nt.layout!=="single"&&Ms.push(`image layout ${Nt.layout}`),Nt.colormap!==void 0&&Nt.colormap!=="gray"&&Ms.push(`image colormap ${Nt.colormap}`),Nt.voi!==void 0&&Nt.voi!==null&&Ms.push(`image wl ${Nt.voi.lower} ${Nt.voi.upper}`),Nt.slice>1&&Ms.push(`image slice ${Nt.slice}`),Nt.ghost!==void 0&&Nt.ghost!==null&&Nt.layout==="slab"&&Ms.push(`image ghost ${Nt.ghost}`),ms({op:"image",path:Nt.path,target:yt,...ut,...Ms.length>0?{view:Ms}:{}}),D===void 0){D=Nt.path;const Ks=mt.series_get(),Yr=[Ks?.seriesDescription??"",Ks?.modality??""].filter(MM=>MM!=="");Yr.length>0&&(B=Yr.join(" · "))}}else if(ye.has(Fe)){const mt=ye.get(Fe);if(mt===void 0)continue;const Nt=i.get(Fe)?.commandLine_get()??"";ms({op:"catalogue",input:mt.input,target:yt,...ut,...mt.feed!==null?{feed:mt.feed}:{},...mt.node!==null?{node:mt.node}:{},...Nt!==""?{line:Nt}:{}}),B===void 0&&(B=`PROCESS ${mt.input.split("/").filter(Boolean).pop()??mt.input}`)}else if(wt==="files"){const mt=i.get(Fe)?.path_current()??null;if(typeof mt!="string"||mt.length===0)continue;ms({op:"dir",path:mt,target:yt,...ut})}else if(wt==="gather"){const mt=r.get(Fe);if(mt===void 0)continue;const Nt=[...mt.entries_get()],Ms=mt.name_get(),Ks=mt.feed_get();ms({op:"gather",series:Nt,target:yt,...ut,...Ms!==null?{name:Ms}:{},...Ks!==null?{feed:Ks.feedId,root:{instance:Ks.rootInstanceId,path:Ks.path}}:{}}),B===void 0&&(B=Ms??`GATHER · ${Nt.length} series`)}else if(wt==="dag"){const mt=a.get(Fe)?.feed_get()??null;if(mt===null)continue;ms({op:"graph",feed:mt,target:yt,...ut})}else wt==="tags"&&ms({op:"tags",target:yt,...ut})}const F=U.filter(Fe=>Fe.op!=="domain"||Fe.feed!==void 0);if(F.length===0)return;const X=Y(E),re={image:"viewer",view:"viewer",dir:"files",fs:"files",tags:"tags",empty:"pane",domain:"dag",catalogue:"catalogue",graph:"dag",gather:"gather"},le=[...new Set(F.map(Fe=>re[Fe.op]??"pane"))];let ge,fe,Ue;if(D!==void 0)ge=D,fe=B??D.split("/").pop()??D,Ue={address:D,modelKind:"dicom.series"};else{const Fe=F.map(yt=>yt.path).find(yt=>yt!==void 0),wt=F.map(yt=>yt.path??(yt.input!==void 0?`catalogue:${yt.input}`:yt.series!==void 0?`gather:${yt.series.map(ut=>ut.seriesUID).join(",")}`:yt.feed!==void 0?`feed:${yt.feed}`:yt.op)).sort().join("|"),Kt=y==="dag"?"RUNS":y.toUpperCase();ge=`${y}:${wt}`,fe=B!==void 0&&B!==""?B:Fe!==void 0?Fe.split("/").pop()??Fe:`${Kt} · ${F.length+1} panes`,Ue={address:ge,modelKind:"argus.desktop"}}k.add({id:ge,label:fe,regard:Ue,members:le,actions:U,...X===void 0?{}:{thumbnail:X},lastTouched:Date.now()})},Te=()=>{const g=new Set(me.panes_shown());for(const y of xo())g.has(y.id)||y.id==="files"||y.id==="dag"||y.id==="pacs"||y.id==="panes"||y.id==="launcher"||y.id==="universe"||($s(y.id),me.mount_remove(y.id));zn()},Pe=g=>{We(),me.preset_apply(g),Te()},Le=()=>{Pe("files"),Ys.size_fit()},ot=g=>[...dt.entries()].find(([,y])=>y===g)?.[0]??null,ft=async g=>{const y=k.get(g);if(y===void 0||y.actions===void 0)return;k.dismiss(g);const E=I=>xo().filter(D=>me.panes_shown().includes(D.id)&&zs(D.id)===I).map(D=>D.id);q=!0;try{const I=[];for(const D of y.actions){const B=I[D.target??0]??null,U={dir:D.dir??"col",before:D.side==="before"};if(D.op==="domain"){const F=D.domain==="runs"?"dag":D.domain==="pacs"?"pacs":"files";if(Pe(F),D.query!==void 0&&ve.line_run(D.query),D.feed!==void 0){const X=D.feed,re=D.view??[],le=a.get("dag");if(le?.feed_enter(X),re.length>0&&le!==void 0){const ge=fe=>{if(le.graph_isShown()&&le.feed_get()===X){for(const Ue of re)ve.line_run(Ue);return}fe>0&&window.setTimeout(()=>ge(fe-1),250)};ge(240)}}I.push(F)}else if(D.op==="image"&&D.path!==void 0){B!==null&&me.focus_set(B);let F=null;de=U;const X=gt(null,D.path,{},ge=>{F=ge});de=null,I.push(F);const re=D.view,le=F;re!==void 0&&re.length>0&&le!==null&&X.then(()=>{for(const ge of re)me.focus_set(le),ve.line_run(ge)}).catch(()=>{})}else if(D.op==="dir"&&D.path!==void 0){B!==null&&me.focus_set(B);const F=new Set(E("files"));de=U,Ae(D.path),de=null,I.push(E("files").find(X=>!F.has(X))??null)}else if(D.op==="tags"){B!==null&&me.focus_set(B);const F=new Set(E("tags"));de=U,ve.line_run("image tags"),de=null,I.push(E("tags").find(X=>!F.has(X))??null)}else if(D.op==="catalogue"&&D.input!==void 0){B!==null&&me.focus_set(B);const F=()=>[...ye.keys()].filter(le=>me.panes_shown().includes(le)),X=new Set(F());de=U,R(B??"files",{input:D.input,feed:D.feed??null,node:D.node??null}),de=null;const re=F().find(le=>!X.has(le))??null;re!==null&&D.line!==void 0&&i.get(re)?.commandLine_set(D.line),I.push(re)}else if(D.op==="gather"&&D.series!==void 0){B!==null&&me.focus_set(B),de=U;const F=Ie([...D.series],B??"pacs");de=null,F!==null&&D.name!==void 0&&r.get(F)?.name_set(D.name),F!==null&&D.feed!==void 0&&D.root!==void 0&&r.get(F)?.feed_set({feedId:D.feed,rootInstanceId:D.root.instance,path:D.root.path}),I.push(F)}else if(D.op==="graph"&&D.feed!==void 0){B!==null&&me.focus_set(B);const F=new Set(E("dag"));de=U,te(B??"files",D.feed),de=null,I.push(E("dag").find(X=>!F.has(X))??null)}else if(D.op==="fs"||D.op==="view"||D.op==="empty"){if(B===null){I.push(null);continue}me.focus_set(B),I.push(A(B,D.op,U.dir,U.before))}else I.push(null)}}finally{q=!1,zn()}},qe=()=>{Pe("launcher"),jt.render(),me.focus_set("launcher")},It=()=>{me.activePreset_get()==="launcher"&&(on=!1,Le())},Qt=async()=>{const[g,y]=await Promise.all([bt.line_execute("proc feeds",{silent:!0,observe:!1}),bt.line_execute("ls ~",{silent:!0,observe:!1})]);let E=[];for(const ut of g.envelopes){const ms=ut.model;if(ms===void 0||ms.kind!==Gp)continue;const mt=Tp.safeParse(ms.data);mt.success&&(E=mt.data.feeds)}const D=E.length===0&&g.envelopes.some(ut=>ut.status==="error")?"INDEX WARMING":`${E.length} FEEDS`,B=E.filter(ut=>/error/i.test(ut.status)).length,U=E.filter(ut=>/running|scheduled|created|started/i.test(ut.status)).length;let F=[],X="~";for(const ut of y.envelopes){if(ut.model?.kind!=="fs.listing")continue;const mt=ut.model.data[0];mt!==void 0&&Array.isArray(mt.items)&&(F=mt.items,typeof mt.path=="string"&&(X=mt.path))}const re=F.filter(ut=>ut.type==="dir"),le=k.list(),ge={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:D}],rows:[{text:"every feed as it landed — branches by pipeline, feeds as leaves",open:()=>Lt()}],verb:"SEE THE SPACE",enter:()=>Lt()},fe={key:"analyses",name:"ANALYSES",hue:"--october-sunset",numeral:"3",figures:[{text:D},...U>0?[{text:`${U} RUNNING`}]:[],...B>0?[{text:`${B} ERRORED`,errored:!0,open:()=>Gs("status:error")}]:[]],rows:E.slice(0,6).map(ut=>({text:`${ut.id} ${ut.title}`,errored:/error/i.test(ut.status),open:()=>{Gs(),a.get("dag")?.feed_enter(ut.id)}})),verb:"OPEN THE ROSTER",enter:()=>Gs()},Ue={key:"files",name:"FILES",hue:"--harvestgold",numeral:"2",figures:[{text:`${F.length} ENTRIES`}],rows:re.slice(0,5).map(ut=>({text:ut.name,open:()=>{on=!1,Le();const ms=X.endsWith("/")?`${X}${ut.name}`:`${X}/${ut.name}`;ve.line_run(`cd "${ms}"`)}})),verb:"OPEN HOME",enter:()=>{on=!1,Le(),me.focus_set("files")}},Fe=ks.query_get()??"",wt={key:"pacs",name:"PACS",hue:"--daybreak",numeral:"4",figures:[{text:Fe===""?"NO ANSWER":"ANSWERED"}],rows:Fe===""?[{text:"pacs query PatientID:…",open:()=>ve.line_offer("pacs query PatientID:")},{text:"pacs query AccessionNumber:…",open:()=>ve.line_offer("pacs query AccessionNumber:")}]:[{text:Fe.slice(0,48)}],verb:"ASK A PACS",enter:()=>{Pe("pacs"),me.focus_set("pacs")}},Kt={key:"panes",name:"PANES",hue:"--butter",numeral:"6",figures:[{text:le.length===0?"EMPTY":`${le.length} DESKTOPS`}],rows:le.slice(0,5).map(ut=>({text:ut.label,open:()=>{ft(ut.id)}})),verb:"SEE DESKTOPS",enter:()=>{Pe("panes"),Ct.render(),me.focus_set("panes")}},yt=[Ue,wt,Kt,ge];return E.length>=F.length?[fe,...yt]:[Ue,fe,wt,Kt,ge]},jt=new HS(Oi,{tiles:Qt,startHere_get:bp,startHere_set:PE});setInterval(()=>{me.activePreset_get()==="launcher"&&(!Oi.isConnected||document.visibilityState!=="visible"||jt.render())},CE);const Ct=new Nx(xi,{list:()=>k.list(),restore:g=>{ft(g)},dismiss:g=>{k.dismiss(g)}}),ps=()=>{const g=me.activePreset_get();if(g==="pacs"||g==="dag"||g==="launcher"){on=!0;return}on&&g==="files"||(on=!0,Le())},De=(g,y)=>{const E=gE(g);return l.pane_join(E.id,y!==void 0?l.group_of(y):E.id),g==="tags"&&l.regard_subscribe(E.id,I=>{I.modelKind==="dicom.instance"&&ls(E.id,I.address)}),g==="view"&&(l.viewer_mark(E.id),l.regard_subscribe(E.id,I=>{I.modelKind!=="dicom.instance"&&pt.get(E.id)?.regard_show(I)})),me.mount_register(E.id,E.mount),ns(E.id,g,E.mount),E},ns=(g,y,E)=>{const I=E.querySelector(".pane-drawer"),D=E.querySelector(".pane-handle");if(I===null||D===null)return;D.addEventListener("click",X=>{X.target instanceof Element&&X.target.closest("button")!==null||(I.hidden=!I.hidden,I.hidden||I.querySelector("button")?.focus(),kt("audio3"))});const B=I.querySelector(".drawer-zoom");B!==null&&(B.dataset.pane=g);for(const X of I.querySelectorAll(".drawer-bind"))X.addEventListener("click",()=>{for(const re of I.querySelectorAll(".drawer-bind"))re.classList.remove("drawer-bind-selected");X.classList.add("drawer-bind-selected"),kt("audio3")});for(const X of I.querySelectorAll("[data-split]"))X.addEventListener("click",()=>{const re=X.dataset.split==="row"?"row":"col",le=X.dataset.place==="before",ge=I.querySelector(".drawer-bind-selected")?.dataset.bind??"unlinked";A(g,ge==="viewer"?"view":ge==="fs"?"fs":"empty",re,le)!==null&&(I.hidden=!0,kt("audio3"))});I.querySelector(".drawer-close")?.addEventListener("click",()=>{if(g==="dag"){on=!1,Le();return}me.leaf_close(g)||Le(),Te(),kt("audio3")});const U=I.querySelector(".drawer-children");if(U===null)return;const F=(X,re,le,ge="")=>{const fe=document.createElement("button");fe.className=`pacs-capsule drawer-child${ge===""?"":` ${ge}`}`,fe.textContent=X,fe.title=re,fe.addEventListener("click",()=>{le(),I.hidden=!0,kt("audio3")}),U.appendChild(fe)};if(y==="files"||y==="catalogue"){const X=I.querySelector(".drawer-binding");if(X!==null){const fe=document.createElement("span");fe.className="drawer-label drawer-label-cwd",fe.textContent="CWD",X.appendChild(fe);const Ue=(Fe,wt,Kt)=>{const yt=document.createElement("button");return yt.className="pacs-capsule drawer-cwdbind",yt.dataset.follow=wt?"on":"off",yt.textContent=Fe,yt.title=Kt,yt.addEventListener("click",()=>{m.get(g)===!0!==wt&&z(g,wt),kt("audio3")}),X.appendChild(yt),yt};Ue("FOLLOW CWD",!0,"bind this browser to the session cwd (the console's browser)"),Ue("ROOT HERE",!1,"unbind from the cwd: this browser keeps its own place"),S(g,()=>{const Fe=m.get(g)===!0;for(const wt of X.querySelectorAll(".drawer-cwdbind"))wt.classList.toggle("drawer-bind-selected",wt.dataset.follow==="on"===Fe)}),v(g)}const re=()=>m.get(g)===!0;E.querySelector(".files-home")?.addEventListener("click",()=>{if(re()){ve.line_run("cd ~");return}const fe=i.get(g);if(fe===void 0)return;const Ue=fe.path_current();Ue!==null&&_.get(g)?.push(Ue),b(g,fe,"~")}),E.querySelector(".files-back")?.addEventListener("click",()=>{if(re()){ve.line_run("cd -");return}const fe=i.get(g),Ue=_.get(g)?.pop();fe!==void 0&&Ue!==void 0&&b(g,fe,Ue)});const le=()=>i.get(g)?.path_current()??null;E.querySelector(".files-mkdir")?.addEventListener("click",()=>{const fe=le();fe!==null&&G(g,fe)}),E.querySelector(".files-refresh")?.addEventListener("click",()=>{const fe=le();fe!==null&&x(g,fe)});const ge=E.querySelector(".files-upload-input");E.querySelector(".files-upload")?.addEventListener("click",()=>{le()!==null&&ge?.click()}),ge?.addEventListener("change",()=>{const fe=le(),Ue=ge.files;fe===null||Ue===null||Ue.length===0||(O(g,fe,Array.from(Ue)),ge.value="")})}y==="dag"&&(F("ENTER NODE","move the session into the indicated node (its data directory)",()=>{const X=l.regard_get(g),re=a.get(g)?.feed_get()??null,le=X===null?re===null?null:`/proc/jobs/feed_${re}`:X.modelKind==="fs.file"?X.address.replace(/\/[^/]*$/,"")||"/":X.address;le!==null&&ve.line_run(`cd "${le}"`)}),F("PROCESS NODE","run an executable on the indicated node's output (a catalogue opens beside)",()=>{const X=l.regard_get(g),re=a.get(g)?.feed_get()??null;if(X===null||re===null)return;const le=X.modelKind==="fs.file"?X.address.replace(/\/[^/]*$/,"")||"/":X.address,ge=oe(le)??(/_(\d+)\/?$/.exec(le)===null?null:parseInt(/_(\d+)\/?$/.exec(le)?.[1]??"",10));ge!==null&&R(g,{input:le.replace(/\/data\/?$/,"")+"/data",feed:re,node:ge})}),F("ENTER FEED","move the session into the feed on stage (or the one picked in the roster)",()=>{const X=a.get(g)?.feed_get()??null;X!==null&&ve.line_run(`cd "/proc/jobs/feed_${X}"`)}),F("BACK","return to the previous listing inside the node",()=>{const X=ce.get(g),re=X?.history.pop();X!==void 0&&re!==void 0&&b(g,X.panel,re)}),F("CLEAR DETAIL","dismiss the node facts (a click on empty space does too)",()=>{a.get(g)?.detail_clear()}),F("REFRESH","revisit the feed now (a watch keeps sampling it while it runs)",()=>{a.get(g)?.refresh()}))};ns("files","files",Ws.mount),ns("dag","dag",Ls.mount),ns("universe","universe",Vr.mount),ns("pacs","pacs",rt("pacs-workspace")),ns("launcher","launcher",Oi),ns("panes","panes",xi);let _t=!1;const cs=g=>{_t=g};for(const g of["click","focusin"])document.addEventListener(g,y=>{y.target instanceof Element&&(y.target.closest("#drawer")!==null?_t=!0:y.target.closest("#layout-root")!==null&&(_t=!1))});const Ts=()=>{let g=!1;for(const y of document.querySelectorAll(".pane-drawer:not([hidden])"))y.hidden=!0,g=!0;return g},cn=()=>{let g=!1;for(const y of document.querySelectorAll('.workspace-pane[data-modes="open"]'))delete y.dataset.modes,g=!0;return ks.serverStrip_isOpen()&&(ks.serverStrip_close(),g=!0),g};document.addEventListener("click",g=>{if(!(g.target instanceof Element)||g.target.closest(".mode-frame")!==null&&g.target.closest(".mode-fill")===null||g.target.closest("#pacs-server-strip")!==null||g.target.closest("#pacs-f-server")!==null||g.target.closest(".listing-framed .listing-row")!==null)return;const y=g.target.closest(".mode-strip"),E=y?.closest(".workspace-pane")??null,I=E?.dataset.modes==="open",D=cn();if(y!==null&&E!==null&&!I){E.dataset.modes="open",kt("audio3");return}D&&kt("audio3")}),window.addEventListener("keydown",g=>{if(g.key==="Escape"){if(!Si.hidden){qr(),g.stopImmediatePropagation();return}if(ve.ask_abandon()){g.stopImmediatePropagation(),kt("audio3");return}if(SA()){g.stopImmediatePropagation(),kt("audio3");return}if(si!==null){si(),g.stopImmediatePropagation(),kt("audio3");return}for(const re of dt.values())if(re.field_release()){g.stopImmediatePropagation(),kt("audio3");return}let y=!1;for(const re of ve.ask_isOpen()?[]:i.values())re.select_isOn()&&(re.select_toggle(!1),y=!0);if(y){g.stopImmediatePropagation(),kt("audio3");return}const E=Ts(),I=cn();if(E||I){g.stopImmediatePropagation(),kt("audio3");return}if(document.body.dataset.zoom!==void 0)return;if(ee()){g.stopImmediatePropagation(),kt("audio3");return}const D=[...ce.keys()].pop();if(D!==void 0){const re=ce.get(D);re!==void 0&&re.panel.content_isShown()?re.panel.listing_restore():Yt(D),g.stopImmediatePropagation(),kt("audio3");return}const B=[...a.entries()].find(([,re])=>re.inside_isHeld());if(B!==void 0){B[1].flight_back(()=>{}),g.stopImmediatePropagation(),kt("audio3");return}const U=me.focused_get(),X=[...i.entries()].filter(([,re])=>re.content_isShown()).sort(([re],[le])=>re===U?-1:le===U?1:0)[0];if(X!==void 0){X[1].listing_restore(),g.stopImmediatePropagation(),kt("audio3");return}for(const re of a.values())if(re.nav_pop()){g.stopImmediatePropagation(),kt("audio3");return}return}if((g.key==="ArrowRight"||g.key==="ArrowLeft"||g.key==="ArrowDown"||g.key==="ArrowUp")&&document.activeElement instanceof HTMLButtonElement){const y=document.activeElement.closest(".pane-drawer");if(y!==null&&!y.hidden){const E=[...y.querySelectorAll("button")],I=E.indexOf(document.activeElement),D=g.key==="ArrowRight"||g.key==="ArrowDown";E[(I+(D?1:E.length-1))%E.length]?.focus(),g.preventDefault(),g.stopImmediatePropagation()}return}if(g.key===":"&&document.querySelector(".pane-drawer:not([hidden])")!==null){Ts(),Sl(),g.preventDefault(),g.stopImmediatePropagation();return}if(g.key==="b"&&g.ctrlKey&&!g.altKey&&!g.metaKey){if(document.querySelector(".pane-drawer:not([hidden])")!==null){Ts(),Sl(),g.preventDefault();return}g.preventDefault();const y=document.body.dataset.zoom,E=y==="console"||y===void 0&&_t,I=y!==void 0&&y!=="console"?y:me.focused_get()??"files",D=E?rt("console-drawer"):mn(I)?.mount?.querySelector(".pane-drawer")??null;if(D===null)return;g.preventDefault(),D.hidden=!D.hidden,D.hidden||D.querySelector("button")?.focus(),kt("audio3")}},{capture:!0});const ii=(g,y,E)=>{if(y==="pacs"){me.preset_apply("pacs"),Te();for(const B of E)ks.envelope_observe(B);return}const I=De(y);if(me.leaf_replace(g,I.id),$s(g),me.mount_remove(g),y==="tags"){const B=Pt.get(I.id);for(const U of E){if(U.model?.kind!==Ga.tags)continue;const F=Nu.safeParse(U.model.data);F.success&&B?.model_show(F.data)}return}if(y==="image"){const B=dt.get(I.id);for(const U of E){if(U.model?.kind!==Ga.series)continue;const F=Cu.safeParse(U.model.data);F.success&&B?.series_show(F.data)}return}const D=y==="files"||y==="catalogue"?i.get(I.id):a.get(I.id);for(const B of E)D?.envelope_observe(B)};Fn("files",g=>qt(g,!1)),Fn("catalogue",g=>qt(g,!1,!0)),Fn("dag",g=>Wt(g,!1)),Fn("universe",At),Fn("view",Ne),Fn("image",vt),Fn("tags",ts),Fn("gather",ne),Fn("empty",g=>{const y=fn("tpl-pane-empty");return new DA(y,{execute:E=>bt.line_execute(E,{silent:!0,observe:!1}),claim:(E,I)=>ii(g,E,I)}),{id:g,kind:"empty",mount:y}});const Bt=g=>{g?document.body.dataset.gutter="away":delete document.body.dataset.gutter,kt("audio3")},Vt=(g,y)=>{if(me.activePreset_get()===g){Bt(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,y()};rt("gutter-restore").addEventListener("click",()=>Bt(!1)),window.addEventListener("keydown",g=>{g.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&Bt(!1)}),rt("gutter-files").addEventListener("click",()=>{Vt("files",()=>{on=!1,Le(),me.focus_set("files"),cs(!1)})});const Gs=(g="")=>{Pe("dag"),Ys.list_reset(),Ys.roster_filter(g),Ys.feedsChooser_request(),me.focus_set("dag"),cs(!1)},Lt=()=>{Pe("universe");const g=o.get("universe");g!==void 0&&!g.shown_get()&&g.request(),me.focus_set("universe"),cs(!1)};rt("gutter-runs").addEventListener("click",()=>Vt("dag",()=>Gs())),rt("gutter-console").addEventListener("click",()=>{rt("drawer").classList.contains("drawer-closed")&&rt("drawer-toggle").click(),ve.focus_take(),cs(!0)}),rt("gutter-tools").addEventListener("click",()=>{Vt("pacs",()=>{Pe("pacs"),me.focus_set("pacs"),cs(!1)})}),rt("gutter-dashboard").addEventListener("click",()=>{Vt("launcher",qe)}),rt("gutter-panes").addEventListener("click",()=>{Vt("panes",()=>{Pe("panes"),Ct.render(),me.focus_set("panes"),cs(!1)})});const zs=g=>mn(g)?.kind??null,Rn={focused_get:()=>{const g=document.body.dataset.zoom;return g!==void 0&&g!=="console"?g:me.focused_get()??me.panes_shown()[0]??null},focus_set:g=>mn(g)===void 0?!1:(me.focus_set(g),!0),panes_shown:()=>me.panes_shown(),paneRect_get:g=>document.querySelector(`.layout-leaf[data-leaf="${g}"]`)?.getBoundingClientRect()??null,paneMount_get:g=>mn(g)?.mount??null,paneKind_get:zs,paneLinked_get:g=>l.group_of(g)!==g,feed_enter:g=>Ys.feed_enter(g),consoleZoom_toggle:yE,launcher_enter:qe,identity_get:()=>tt,node_immerse:g=>{const E=l.regard_get(g)?.address.match(/_(\d+)(?:\/data)?\/?$/)??null;return E===null?!1:a.get(g)?.node_flyTo(parseInt(E[1]??"",10))??!1},file_download:g=>{const y=l.regard_get(g);return y===null||y.modelKind!=="fs.file"?!1:(ll(d(y.address)),!0)},image_open:(g,y,E)=>gt(g,y,E??{}),image_control:async(g,y,E)=>{const I=new Set(me.panes_shown()),D=l.group_of(g),B=[...dt.entries()].filter(([F])=>I.has(F)),U=dt.get(g)??B.find(([F])=>l.group_of(F)===D)?.[1]??(B.length===1?B[0]?.[1]:void 0);if(U===void 0)return`image ${y}: no image pane on stage for '${g}'`;if(y==="layout"){const F=E[0]??"";return mS.includes(F)?await U.layout_set(F)?`image layout ${F}`:U.state_get()?.waiting===F?`image layout ${F}: waiting for LOAD`:`image layout ${F}: not offered`:"image layout single|mpr|3d|slab"}if(y==="slice"){const F=Number(E[0]);return!Number.isInteger(F)||F<1?"image slice <n>":U.slice_set(F)?`image slice ${F}`:`image slice ${F}: not offered`}if(y==="series"){const F=Number(E[0]),X=U.siblings_get();if(X.length===0)return"image series: this pane holds one series, not a study";const re=X[F-1];if(re===void 0)return`image series <1..${X.length}>: ${X.map((ge,fe)=>`${fe+1} ${ge.label}`).join(" · ")}`;const le=await Zt(re.path);return le===null?`image series ${F}: ${re.path}: not a readable DICOM series`:(U.series_show(le,{siblings:[...X]}),`image series ${F} ${re.label}`)}if(y==="wl"){if((E[0]??"").toLowerCase()==="preset"){const re=E[1]??"";return re===""?"image wl preset <brain|bone|lung|soft|liver>":U.wlPreset_set(re)?`image wl preset ${re}`:`image wl preset ${re}: none for this modality`}const F=Number(E[0]),X=Number(E[1]);return!Number.isFinite(F)||!Number.isFinite(X)||F>=X?"image wl <lower> <upper> | image wl preset <name>":U.wl_set(F,X)?`image wl ${F} ${X}`:"image wl: not offered"}if(y==="colormap"){const F=(E[0]??"").toLowerCase();return Co.includes(F)?U.colormap_set(F)?`image colormap ${F}`:`image colormap ${F}: not offered`:"image colormap gray|hot|jet|cool"}if(y==="save")return await U.annotations_save()?"image save":"image save: nothing saved (the console says why)";if(y==="load")return await U.load_press()?"image load":"image load: nothing was waiting";if(y==="guard"){if((E[0]??"").toLowerCase()==="off")return U.guard_set(null),"image guard off";const X=Number(E[0]);return!Number.isFinite(X)||X<0?`image guard <bytes>|off (now ${U.guard_get()===null?"off":U.guard_get()})`:(U.guard_set(X),`image guard ${X}`)}if(y==="ghost"){const X=(E[0]??"").toLowerCase()==="off"?null:Number(E[0]);return X!==null&&(!Number.isFinite(X)||X<0||X>1)?"image ghost <0..1>|off (SLAB layout)":U.ghost_set(X)?`image ghost ${X===null?"off":X}`:"image ghost: SLAB layout only"}if(y==="tags"){const F=[...dt.entries()].find(([,X])=>X===U)?.[0];return F===void 0?"image tags: no image pane":Xt(F)}return"image <path> · layout single|mpr|3d · slice <n> · series <n> · wl <lo> <hi> | wl preset <name> · colormap <name> · save"},universe_control:(g,y,E)=>{const I=new Set(me.panes_shown()),D=(g!==null?o.get(g):void 0)??[...o.entries()].find(([B])=>I.has(B))?.[1];return D===void 0?"universe: no universe pane on stage (press the dashboard tile)":D.control(y,E)},tags_control:(g,y,E)=>{const I=new Set(me.panes_shown()),D=l.group_of(g),B=[...Pt.entries()].filter(([F])=>I.has(F)),U=Pt.get(g)??B.find(([F])=>l.group_of(F)===D)?.[1]??(B.length===1?B[0]?.[1]:void 0);if(U===void 0)return`tags ${y}: no tags pane on stage for '${g}'`;if(y==="redact"){const F=(E[0]??"").toLowerCase();return F!=="on"&&F!=="off"?"tags redact on|off":(U.redact_set(F==="on"),`tags redact ${F}`)}if(y==="filter"){const F=E.join(" ");return F===""||F.toLowerCase()==="off"?(U.filter_set(null),"tags filter off"):(U.filter_set(F),`tags filter ${F}`)}return"tags redact on|off · filter <text>|off"},file_delete:g=>{const y=l.regard_get(g);return y===null||y.modelKind!=="fs.file"?!1:(ve.line_run(`rm "${y.address}"`),!0)},session_run:async g=>{try{return(await bt.line_execute(g,{silent:!0,observe:!1})).envelopes.map(E=>E.renderedErr??E.rendered).join(`
4228
+ `),null}ve.outcome_write(D);for(const B of D.envelopes){if(B.model?.kind!=="feed.created")continue;const U=B.model.data;if(typeof U.feedId=="number"&&typeof U.rootInstanceId=="number"&&typeof U.path=="string")return{feedId:U.feedId,rootInstanceId:U.rootInstanceId,path:U.path}}return null},cohort_process:I=>R(g,I),feed_open:I=>te(g,I)},Ee);return r.set(g,E),{id:g,kind:"gather",mount:y,dispose:()=>{r.delete(g),l.pane_leave(g)}}};let ie=null;const Ee=new YS;let Ve=!1;const Ge="~/gather/current.json";let xe=null;const Xe=()=>{xe!==null&&window.clearTimeout(xe),xe=window.setTimeout(()=>{xe=null;const g=ie?.entries_get()??[],y=JSON.stringify({version:1,name:ie?.name_get()??null,feed:ie?.feed_get()??null,series:g});bt.line_execute("mkdir -p ~/gather",{silent:!0,observe:!1}),bt.line_execute(`touch --withContents '${y.replace(/'/g,"'\\''")}' ${Ge}`,{silent:!0,observe:!1})},1200)},Ke=async()=>{const g=await M(Ge);if(g.ok)try{const y=JSON.parse(g.text);if(!Array.isArray(y.series)||y.series.length===0)return;ie===null&&(ie=rt());for(const E of y.series)ie.series_add(E);Oe(),zn()}catch{}},rt=()=>{const g=st("header-gather"),y=()=>an()??"pacs";return new Xf(g,Bs(g,".gather-rows"),{command_run:E=>{bt.line_execute(E,{silent:!0})},command_show:E=>ve.line_run(E),note:E=>ve.line_note(E),image_open:E=>{gt(y(),E).then(I=>ve.line_note(I))},process_open:E=>R(y(),{input:E,feed:null,node:null}),name_ask:async E=>{const I=st("header-gather"),D=ve.ask_note("Cohort name: "),B=await vc(I,{message:"Cohort name: ",kind:"text",suggest:E,commit:"NAME IT"});return D(B),B},confirm_ask:async E=>{const I=st("header-gather"),D=ve.ask_note(`${E} `),B=await vc(I,{message:E,kind:"confirm"});return D(B),B==="y"||B==="n"?B:null},changed:()=>{zn(),Oe(),Xe()},dismiss:()=>{document.body.dataset.header="away",Ve=!0,Oe()},feed_create:async E=>{ve.line_echo(E);let I;try{I=await bt.line_execute(E,{silent:!0})}catch(D){return ve.output_write("err",`\x1B[31m${D instanceof Error?D.message:String(D)}\x1B[0m
4229
+ `),null}ve.outcome_write(I);for(const D of I.envelopes){if(D.model?.kind!=="feed.created")continue;const B=D.model.data;if(typeof B.feedId=="number"&&typeof B.rootInstanceId=="number"&&typeof B.path=="string")return{feedId:B.feedId,rootInstanceId:B.rootInstanceId,path:B.path}}return null},cohort_process:E=>R(y(),E),feed_open:E=>te(y(),E)},Ee)},L=()=>{const g=new Set(me.panes_shown()),y=[...r.keys()].find(E=>g.has(E))??null;if(y!==null)me.focus_set(y);else{const E=an()??"pacs",I=De("gather","pacs");if(!me.leaf_split(E,"col",I.id,!1)){$s(I.id),me.mount_remove(I.id);return}ln(I.id,E,"col",!1),r.get(I.id)?.render_now()}document.body.dataset.header="away",Ve=!0},Oe=()=>{const g=document.querySelector("#header-gather-pill");if(g===null)return;const y=ie?.entries_get().length??0;g.classList.toggle("panel-gather-empty",y===0)},ae=g=>{ie===null&&(ie=rt());for(const E of g)ie.series_add(E);const y=document.body.dataset.header==="away";(!Ve||!y)&&(document.body.dataset.header="gather",Ve=!1),Oe(),Xe()},Ie=(g,y="pacs")=>{const E=new Set(me.panes_shown());let I=[...r.keys()].find(B=>E.has(B))??null;if(I===null){const B=E.has(y)?y:an()??y,U=De("gather","pacs");if(!me.leaf_split(B,de?.dir??"row",U.id,de?.before??!1))return $s(U.id),me.mount_remove(U.id),null;ln(U.id,B,de?.dir??"row",de?.before??!1),I=U.id}const D=r.get(I);if(D===void 0)return null;for(const B of g)D.series_add(B);return I},Ne=g=>{const y=fn("tpl-pane-view"),E=new NA(Bs(y,".view-body"),Bs(y,".view-title"),{content_fetch:async I=>(await M(I)).text,imageUrl_build:c,path_isImage:Wo});return pt.set(g,E),{id:g,kind:"view",mount:y,dispose:()=>{pt.delete(g),l.pane_leave(g)}}},ce=new Map,$e=g=>a.get(g)??o.get(g),ke=(g,y)=>{const I=mn(g)?.mount?.querySelector(".dag-canvas, .universe-canvas")??null,D=ce.get(g);if(D!==void 0&&!D.element.isConnected&&ce.delete(g),I===null||ce.has(g)){ve.line_note(`dag: ${y}: ${I===null?"this pane has no scene to fly in":"a node is already open here"} — flew back out`),$e(g)?.flight_back(()=>{});return}const B=document.createElement("div");B.className="node-overlay";const U=document.createElement("header");U.className="node-overlay-header";const F=document.createElement("span");F.textContent=`INSIDE ${y}`.toUpperCase();const X=document.createElement("span");X.className="node-overlay-hint",X.textContent="ESC EXITS NODE",U.append(F,X);const re=ht();re.classList.add("node-overlay-body"),B.append(U,re);const le=[],ge=new Cf(Bs(re,".files-panel"),fe=>{if(fe.kind==="dir"){const Ue=fe.path.startsWith("/proc/jobs/")?(fe.path.split("/").pop()??"").match(/_(\d+)$/):null;if(Ue!==null){const wt=parseInt(Ue[1]??"",10);Yt(g,()=>{$e(g)?.node_flyTo(wt)!==!0&&ke(g,fe.path)});return}const Fe=ge.path_current();Fe!==null&&le.push(Fe),b(g,ge,fe.path);return}if(l.regard_write(g,{address:fe.path,modelKind:"fs.file"}),!l.groupHasViewer(g)){if(Re(fe.path)){gt(g,fe.path).then(Ue=>ve.line_note(Ue));return}if(Wo(fe.path)){ge.contentImage_show(fe.path,c(fe.path));return}M(fe.path).then(Ue=>{if(!Ue.ok){ge.contentRefused_show(fe.path,Ue.text);return}mp.test(fe.path)?ge.contentTable_show(fe.path,Ue.text):ge.content_show(fe.path,Ue.text)})}},p);ge.rowVerbs_declare((fe,Ue)=>it(g,fe,Ue),(fe,Ue)=>{l.regard_write(g,{address:Ue,modelKind:"fs.file"})}),ce.set(g,{element:B,panel:ge,history:le}),I.appendChild(B),window.requestAnimationFrame(()=>B.classList.add("node-overlay-open")),b(g,ge,y)},Yt=(g,y)=>{const E=ce.get(g);if(E===void 0){y?.();return}ce.delete(g),E.element.classList.remove("node-overlay-open");const I=()=>{E.element.remove(),y?.()},D=$e(g);D!==void 0?D.flight_back(I):I()},Wt=(g,y)=>{const E=fn("tpl-pane-dag"),I=new _A(Bs(E,".dag-canvas"),Bs(E,".dag-title"),Bs(E,".dag-facts"),Bs(E,".dag-empty"),Bs(E,".dag-strategy"),Bs(E,".dag-feedlist"),{command_run:D=>{bt.line_execute(D,{silent:!0,observe:!1}).then(B=>{for(const U of B.envelopes)I.envelope_observe(U)})},watch_set:(D,B)=>{B?bt.watch_send(D):bt.unwatch_send(D)},node_enter:D=>{ve.line_run(`cd "${D}"`)},node_dive:D=>{ke(g,D.replace(/\/data$/,""))},node_regard:D=>{l.regard_write(g,{address:D,modelKind:"feed.node"})},node_process:D=>{const B=Me(D.vfsPath)??(/\/feed_(\d+)(?:\/|$)/.exec(D.vfsPath)===null?null:Number(/\/feed_(\d+)(?:\/|$)/.exec(D.vfsPath)[1])),U=ct===null?D.vfsPath:D.vfsPath.replace(/^\/proc\/jobs\//,`/home/${ct}/feeds/`);R(g,{input:U,feed:B,node:D.instanceId})},feed_regard:D=>{l.regard_write(g,{address:D,modelKind:"feed"})},feed_verbs:D=>{const B={feedId:D.id},U={share:()=>ve.line_run(`setfacl feed_${D.id}`),delete:()=>ve.line_run(`feed rm feed_${D.id}`)};return $m.rules.filter(F=>F.offered(B)).map(F=>({label:F.label(B),run:()=>U[F.name]?.()}))},feed_indicated:D=>{l.regard_write(g,{address:`/proc/jobs/feed_${D.id}`,modelKind:"feed"}),bt.line_execute(`getfacl feed_${D.id}`,{silent:!0,observe:!1}).then(B=>{a.get(g)?.rowReadout_show(D.id,Ye(B))}).catch(()=>{a.get(g)?.rowReadout_show(D.id,"ACCESS UNREAD")})},...y?{feed_shown:()=>ps()}:{}});return a.set(g,I),{id:g,kind:"dag",mount:E,dispose:()=>{ce.get(g)?.element.remove(),ce.delete(g),a.delete(g),l.pane_leave(g),I.dispose()}}},Ws=qt("files",!0);Sr(Ws);const Ls=Wt("dag",!0);Sr(Ls);const Vr=At("universe");Sr(Vr);const xi=fn("tpl-pane-launcher");Sr({id:"launcher",kind:"launcher",mount:xi});const Si=fn("tpl-pane-panes");Sr({id:"panes",kind:"panes",mount:Si});const $r=i.get("files"),Ys=a.get("dag"),Hr=new dE(st("pipeline-cycler"),st("pipeline-cycler-name"),g=>{bt.line_execute(g,{silent:!0})}),an=()=>{const g=me.tree_get();if(g===null)return null;const y=[],E=D=>{if("pane"in D){y.push(D.pane);return}E(D.first),E(D.second)};E(g);const I=me.focused_get();return I!==null&&y.includes(I)?I:y[0]??null},Gn=async g=>{const y=an();if(y===null)return null;const E=De("files");if(!me.leaf_split(y,de?.dir??"col",E.id,de?.before??!1))return $s(E.id),me.mount_remove(E.id),null;ln(E.id,y,de?.dir??"col",de?.before??!1);const I=i.get(E.id),D=g.path?.anchor??"~";I!==void 0&&b(E.id,I,D);const B=E.mount.querySelector(".files-body");if(B===null)return $s(E.id),me.mount_remove(E.id),null;const U=document.createElement("div");U.className="errand-bar",B.insertBefore(U,B.firstChild);const F=document.createElement("span");F.className="errand-caption",F.textContent=g.message.trim();const X=document.createElement("input");X.className="errand-path",X.spellcheck=!1;const re=document.createElement("button");re.className="pacs-capsule errand-commit",re.textContent=g.commit??"USE THIS",U.append(F,X,re);const le=()=>{const Ue=I?.path_current()??D,Fe=g.path?.suggest;X.value=g.path?.wantsDirectory===!0||Fe===void 0?Ue:`${Ue.replace(/\/$/,"")}/${Fe}`};le();let ge=!1;X.addEventListener("input",()=>{ge=!0});const fe=()=>{ge||le()};return E.mount.addEventListener("click",fe),ve.question_set(!0),new Promise(Ue=>{const Fe=wt=>{E.mount.removeEventListener("click",fe),ve.question_set(!1),si=null,me.leaf_close(E.id),$s(E.id),me.mount_remove(E.id),Ue(wt)};si=()=>Fe(null),re.addEventListener("click",()=>Fe(X.value.trim()===""?null:X.value.trim())),X.addEventListener("keydown",wt=>{wt.key==="Enter"&&Fe(X.value.trim()===""?null:X.value.trim())})})};let si=null,tr=null,sr=null;const bn=(g,y)=>{sr=g,ve.line_run(y)},ni=async(g,y)=>{const E=mn(g)?.mount;if(E===void 0)return tr?.(!1),ve.ask_open({message:y.message,kind:y.kind,...y.suggest===void 0?{}:{suggest:y.suggest}});const I=ve.ask_note(y.message),D=await vc(E,y);return I(y.kind==="secret"&&D!==null?"••••••":D),D},ks=new VS(st("pacs-workspace"),{command_run:g=>{/^(pacs query|pull )/.test(g)&&ve.line_echo(g),bt.line_execute(g,{silent:!0}).then(y=>{for(const E of y.envelopes)ks.envelope_observe(E)})},command_show:g=>{ve.line_run(g)},note:g=>ve.line_note(g),image_open:g=>{gt(null,g).then(y=>ve.line_note(y))},dir_open:g=>Ae(g),process_open:g=>R("pacs",{input:g,feed:null,node:null}),gather_add:g=>ae([g]),gathered_is:g=>ie?.has(g)===!0,workspace_close:()=>Le()});Sr({id:"pacs",kind:"pacs",mount:st("pacs-workspace")});const zn=()=>{const g=new Set(me.panes_shown()),y=new Map;for(const E of xo()){if(!g.has(E.id))continue;const I=l.regard_get(E.id)?.address;if(I===void 0)continue;const D=zs(E.id);if(D!=="image"&&D!=="files")continue;const B=I.replace(/\/$/,""),U=y.get(B)??{viewer:!1,browser:!1};D==="image"?U.viewer=!0:U.browser=!0,y.set(B,U)}ks.stage_lit(y)},me=new yE(st("layout-root"),new Map([["dag",Ls.mount],["universe",Vr.mount],["files",Ws.mount],["pacs",st("pacs-workspace")],["launcher",xi],["panes",Si]]));let on=!1;const vl=()=>on?{dir:"col",ratio:.45,first:{pane:"files"},second:{pane:"dag"}}:{pane:"files"};me.preset_register("files",vl),me.preset_register("pacs",()=>({pane:"pacs"})),me.preset_register("dag",()=>({pane:"dag"})),me.preset_register("universe",()=>({pane:"universe"})),me.preset_register("panes",()=>({pane:"panes"})),me.preset_register("launcher",()=>({pane:"launcher"})),me.renderObserver_set(()=>{window.requestAnimationFrame(()=>{for(const g of a.values())g.size_fit()})});const Ta=new Map,ln=(g,y,E,I,D)=>{Ta.set(g,{parent:y,dir:E,before:I,...D!==void 0?{binding:D}:{}})},A=(g,y,E,I)=>{const D=y==="view"?De("view",g):y==="fs"?De("files",g):De("empty");if(!me.leaf_split(g,E,D.id,I))return $s(D.id),me.mount_remove(D.id),null;if(ln(D.id,g,E,I,y),y==="fs"){const B=F=>{const X=i.get(D.id);if(X===void 0)return;const re=F.modelKind==="fs.file"?F.address.replace(/\/[^/]*$/,"")||"/":F.address;b(D.id,X,re)};l.regard_subscribe(D.id,B);const U=l.regard_get(g);U!==null&&B(U)}return D.id},k=new Wx(Rm,bf());Object.assign(globalThis,{__argusDormant:{list:()=>k.list(),get:g=>k.get(g),dismiss:g=>k.dismiss(g)}});const Z=g=>{if(g==="pacs")return"⊞";if(g==="dag")return"⋔";const y=zs(g);return y==="image"?"▣":y==="tags"?"≣":"▤"},Y=g=>{if(g.length===0)return;const y=[];for(const re of g){const le=mn(re)?.mount;if(le===void 0)continue;const ge=le.getBoundingClientRect();ge.width>0&&ge.height>0&&y.push({id:re,left:ge.left,top:ge.top,width:ge.width,height:ge.height})}if(y.length===0)return;const E=Math.min(...y.map(re=>re.left)),I=Math.min(...y.map(re=>re.top)),D=Math.max(...y.map(re=>re.left+re.width))-E,B=Math.max(...y.map(re=>re.top+re.height))-I;if(D<=0||B<=0)return;const U=240,F=U/D,X=Math.max(40,Math.min(260,Math.round(B*F)));try{const re=document.createElement("canvas");re.width=U,re.height=X;const le=re.getContext("2d");if(le===null)return;const fe=getComputedStyle(document.documentElement).getPropertyValue("--harvestgold").trim()||"#c9a15a";le.fillStyle="#05070a",le.fillRect(0,0,U,X);for(const Ue of y){const Fe=Math.round((Ue.left-E)*F),wt=Math.round((Ue.top-I)*F),Kt=Math.max(6,Math.round(Ue.width*F)),yt=Math.max(6,Math.round(Ue.height*F)),ut=mn(Ue.id)?.mount.querySelector("canvas");if(ut!=null&&ut.width>0){const ms=Math.min(Kt/ut.width,yt/ut.height),mt=Math.round(ut.width*ms),Nt=Math.round(ut.height*ms);le.fillStyle="#000",le.fillRect(Fe,wt,Kt,yt),le.drawImage(ut,Fe+Math.round((Kt-mt)/2),wt+Math.round((yt-Nt)/2),mt,Nt)}else le.fillStyle="rgba(255,255,255,0.05)",le.fillRect(Fe,wt,Kt,yt),le.fillStyle=fe,le.font=`${Math.max(9,Math.min(28,Math.round(Math.min(Kt,yt)*.5)))}px serif`,le.textAlign="center",le.textBaseline="middle",le.fillText(Z(Ue.id),Fe+Kt/2,wt+yt/2+1);le.strokeStyle="rgba(255,255,255,0.22)",le.lineWidth=1,le.strokeRect(Fe+.5,wt+.5,Kt-1,yt-1)}return re.toDataURL("image/png")}catch{return}};let q=!1,de=null;const We=()=>{if(q)return;const g=new Set(me.panes_shown()),y=me.activePreset_get();if(y==="panes"||y==="launcher")return;const E=xo().map(Fe=>Fe.id).filter(Fe=>g.has(Fe)),I=new Map;let D,B;const U=[];for(const Fe of E){const wt=zs(Fe),Kt=Ta.get(Fe),yt=I.get(Kt?.parent??"")??0,ut={dir:Kt?.dir??"col",side:Kt?.before?"before":"after"},ms=mt=>{I.set(Fe,U.length),U.push(mt)};if(Fe==="pacs"||Fe==="files"||Fe==="dag"){const mt=y==="dag"?"runs":y,Nt=y==="pacs"?ks.query_get():null,Ms=y==="dag"?a.get("dag"):void 0,Ks=Ms!==void 0&&Ms.graph_isShown()?Ms.feed_get():null,Yr=Ks!==null&&Ms!==void 0?Ms.view_lines():[];Ks!==null&&B===void 0&&(B=Ms?.feedTitle_get()),ms({op:"domain",domain:mt,...Nt!==null?{query:Nt}:{},...Ks!==null?{feed:Ks}:{},...Yr.length>0?{view:Yr}:{}})}else if(Kt?.binding==="fs"||Kt?.binding==="view"||Kt?.binding==="empty")ms({op:Kt.binding,target:yt,...ut});else if(wt==="image"){const mt=dt.get(Fe),Nt=mt?.state_get()??null;if(mt===void 0||Nt===null||Nt.path===null)continue;const Ms=[];if(Nt.layout!=="single"&&Ms.push(`image layout ${Nt.layout}`),Nt.colormap!==void 0&&Nt.colormap!=="gray"&&Ms.push(`image colormap ${Nt.colormap}`),Nt.voi!==void 0&&Nt.voi!==null&&Ms.push(`image wl ${Nt.voi.lower} ${Nt.voi.upper}`),Nt.slice>1&&Ms.push(`image slice ${Nt.slice}`),Nt.ghost!==void 0&&Nt.ghost!==null&&Nt.layout==="slab"&&Ms.push(`image ghost ${Nt.ghost}`),ms({op:"image",path:Nt.path,target:yt,...ut,...Ms.length>0?{view:Ms}:{}}),D===void 0){D=Nt.path;const Ks=mt.series_get(),Yr=[Ks?.seriesDescription??"",Ks?.modality??""].filter(MM=>MM!=="");Yr.length>0&&(B=Yr.join(" · "))}}else if(ye.has(Fe)){const mt=ye.get(Fe);if(mt===void 0)continue;const Nt=i.get(Fe)?.commandLine_get()??"";ms({op:"catalogue",input:mt.input,target:yt,...ut,...mt.feed!==null?{feed:mt.feed}:{},...mt.node!==null?{node:mt.node}:{},...Nt!==""?{line:Nt}:{}}),B===void 0&&(B=`PROCESS ${mt.input.split("/").filter(Boolean).pop()??mt.input}`)}else if(wt==="files"){const mt=i.get(Fe)?.path_current()??null;if(typeof mt!="string"||mt.length===0)continue;ms({op:"dir",path:mt,target:yt,...ut})}else if(wt==="gather"){const mt=r.get(Fe);if(mt===void 0)continue;const Nt=[...mt.entries_get()],Ms=mt.name_get(),Ks=mt.feed_get();ms({op:"gather",series:Nt,target:yt,...ut,...Ms!==null?{name:Ms}:{},...Ks!==null?{feed:Ks.feedId,root:{instance:Ks.rootInstanceId,path:Ks.path}}:{}}),B===void 0&&(B=Ms??`GATHER · ${Nt.length} series`)}else if(wt==="dag"){const mt=a.get(Fe)?.feed_get()??null;if(mt===null)continue;ms({op:"graph",feed:mt,target:yt,...ut})}else wt==="tags"&&ms({op:"tags",target:yt,...ut})}const F=U.filter(Fe=>Fe.op!=="domain"||Fe.feed!==void 0);if(F.length===0)return;const X=Y(E),re={image:"viewer",view:"viewer",dir:"files",fs:"files",tags:"tags",empty:"pane",domain:"dag",catalogue:"catalogue",graph:"dag",gather:"gather"},le=[...new Set(F.map(Fe=>re[Fe.op]??"pane"))];let ge,fe,Ue;if(D!==void 0)ge=D,fe=B??D.split("/").pop()??D,Ue={address:D,modelKind:"dicom.series"};else{const Fe=F.map(yt=>yt.path).find(yt=>yt!==void 0),wt=F.map(yt=>yt.path??(yt.input!==void 0?`catalogue:${yt.input}`:yt.series!==void 0?`gather:${yt.series.map(ut=>ut.seriesUID).join(",")}`:yt.feed!==void 0?`feed:${yt.feed}`:yt.op)).sort().join("|"),Kt=y==="dag"?"RUNS":y.toUpperCase();ge=`${y}:${wt}`,fe=B!==void 0&&B!==""?B:Fe!==void 0?Fe.split("/").pop()??Fe:`${Kt} · ${F.length+1} panes`,Ue={address:ge,modelKind:"argus.desktop"}}k.add({id:ge,label:fe,regard:Ue,members:le,actions:U,...X===void 0?{}:{thumbnail:X},lastTouched:Date.now()})},Te=()=>{const g=new Set(me.panes_shown());for(const y of xo())g.has(y.id)||y.id==="files"||y.id==="dag"||y.id==="pacs"||y.id==="panes"||y.id==="launcher"||y.id==="universe"||($s(y.id),me.mount_remove(y.id));zn()},Pe=g=>{We(),me.preset_apply(g),Te()},Le=()=>{Pe("files"),Ys.size_fit()},ot=g=>[...dt.entries()].find(([,y])=>y===g)?.[0]??null,ft=async g=>{const y=k.get(g);if(y===void 0||y.actions===void 0)return;k.dismiss(g);const E=I=>xo().filter(D=>me.panes_shown().includes(D.id)&&zs(D.id)===I).map(D=>D.id);q=!0;try{const I=[];for(const D of y.actions){const B=I[D.target??0]??null,U={dir:D.dir??"col",before:D.side==="before"};if(D.op==="domain"){const F=D.domain==="runs"?"dag":D.domain==="pacs"?"pacs":"files";if(Pe(F),D.query!==void 0&&ve.line_run(D.query),D.feed!==void 0){const X=D.feed,re=D.view??[],le=a.get("dag");if(le?.feed_enter(X),re.length>0&&le!==void 0){const ge=fe=>{if(le.graph_isShown()&&le.feed_get()===X){for(const Ue of re)ve.line_run(Ue);return}fe>0&&window.setTimeout(()=>ge(fe-1),250)};ge(240)}}I.push(F)}else if(D.op==="image"&&D.path!==void 0){B!==null&&me.focus_set(B);let F=null;de=U;const X=gt(null,D.path,{},ge=>{F=ge});de=null,I.push(F);const re=D.view,le=F;re!==void 0&&re.length>0&&le!==null&&X.then(()=>{for(const ge of re)me.focus_set(le),ve.line_run(ge)}).catch(()=>{})}else if(D.op==="dir"&&D.path!==void 0){B!==null&&me.focus_set(B);const F=new Set(E("files"));de=U,Ae(D.path),de=null,I.push(E("files").find(X=>!F.has(X))??null)}else if(D.op==="tags"){B!==null&&me.focus_set(B);const F=new Set(E("tags"));de=U,ve.line_run("image tags"),de=null,I.push(E("tags").find(X=>!F.has(X))??null)}else if(D.op==="catalogue"&&D.input!==void 0){B!==null&&me.focus_set(B);const F=()=>[...ye.keys()].filter(le=>me.panes_shown().includes(le)),X=new Set(F());de=U,R(B??"files",{input:D.input,feed:D.feed??null,node:D.node??null}),de=null;const re=F().find(le=>!X.has(le))??null;re!==null&&D.line!==void 0&&i.get(re)?.commandLine_set(D.line),I.push(re)}else if(D.op==="gather"&&D.series!==void 0){B!==null&&me.focus_set(B),de=U;const F=Ie([...D.series],B??"pacs");de=null,F!==null&&D.name!==void 0&&r.get(F)?.name_set(D.name),F!==null&&D.feed!==void 0&&D.root!==void 0&&r.get(F)?.feed_set({feedId:D.feed,rootInstanceId:D.root.instance,path:D.root.path}),I.push(F)}else if(D.op==="graph"&&D.feed!==void 0){B!==null&&me.focus_set(B);const F=new Set(E("dag"));de=U,te(B??"files",D.feed),de=null,I.push(E("dag").find(X=>!F.has(X))??null)}else if(D.op==="fs"||D.op==="view"||D.op==="empty"){if(B===null){I.push(null);continue}me.focus_set(B),I.push(A(B,D.op,U.dir,U.before))}else I.push(null)}}finally{q=!1,zn()}},qe=()=>{Pe("launcher"),jt.render(),me.focus_set("launcher")},It=()=>{me.activePreset_get()==="launcher"&&(on=!1,Le())},Qt=async()=>{const[g,y]=await Promise.all([bt.line_execute("proc feeds",{silent:!0,observe:!1}),bt.line_execute("ls ~",{silent:!0,observe:!1})]);let E=[];for(const ut of g.envelopes){const ms=ut.model;if(ms===void 0||ms.kind!==Gp)continue;const mt=Tp.safeParse(ms.data);mt.success&&(E=mt.data.feeds)}const D=E.length===0&&g.envelopes.some(ut=>ut.status==="error")?"INDEX WARMING":`${E.length} FEEDS`,B=E.filter(ut=>/error/i.test(ut.status)).length,U=E.filter(ut=>/running|scheduled|created|started/i.test(ut.status)).length;let F=[],X="~";for(const ut of y.envelopes){if(ut.model?.kind!=="fs.listing")continue;const mt=ut.model.data[0];mt!==void 0&&Array.isArray(mt.items)&&(F=mt.items,typeof mt.path=="string"&&(X=mt.path))}const re=F.filter(ut=>ut.type==="dir"),le=k.list(),ge={key:"universe",name:"UNIVERSE",hue:"--honey",numeral:"",figures:[{text:D}],rows:[{text:"every feed as it landed — branches by pipeline, feeds as leaves",open:()=>Lt()}],verb:"SEE THE SPACE",enter:()=>Lt()},fe={key:"analyses",name:"ANALYSES",hue:"--october-sunset",numeral:"3",figures:[{text:D},...U>0?[{text:`${U} RUNNING`}]:[],...B>0?[{text:`${B} ERRORED`,errored:!0,open:()=>Gs("status:error")}]:[]],rows:E.slice(0,6).map(ut=>({text:`${ut.id} ${ut.title}`,errored:/error/i.test(ut.status),open:()=>{Gs(),a.get("dag")?.feed_enter(ut.id)}})),verb:"OPEN THE ROSTER",enter:()=>Gs()},Ue={key:"files",name:"FILES",hue:"--harvestgold",numeral:"2",figures:[{text:`${F.length} ENTRIES`}],rows:re.slice(0,5).map(ut=>({text:ut.name,open:()=>{on=!1,Le();const ms=X.endsWith("/")?`${X}${ut.name}`:`${X}/${ut.name}`;ve.line_run(`cd "${ms}"`)}})),verb:"OPEN HOME",enter:()=>{on=!1,Le(),me.focus_set("files")}},Fe=ks.query_get()??"",wt={key:"pacs",name:"PACS",hue:"--daybreak",numeral:"4",figures:[{text:Fe===""?"NO ANSWER":"ANSWERED"}],rows:Fe===""?[{text:"pacs query PatientID:…",open:()=>ve.line_offer("pacs query PatientID:")},{text:"pacs query AccessionNumber:…",open:()=>ve.line_offer("pacs query AccessionNumber:")}]:[{text:Fe.slice(0,48)}],verb:"ASK A PACS",enter:()=>{Pe("pacs"),me.focus_set("pacs")}},Kt={key:"panes",name:"PANES",hue:"--butter",numeral:"6",figures:[{text:le.length===0?"EMPTY":`${le.length} DESKTOPS`}],rows:le.slice(0,5).map(ut=>({text:ut.label,open:()=>{ft(ut.id)}})),verb:"SEE DESKTOPS",enter:()=>{Pe("panes"),Ct.render(),me.focus_set("panes")}},yt=[Ue,wt,Kt,ge];return E.length>=F.length?[fe,...yt]:[Ue,fe,wt,Kt,ge]},jt=new KS(xi,{tiles:Qt,startHere_get:bp,startHere_set:FE});setInterval(()=>{me.activePreset_get()==="launcher"&&(!xi.isConnected||document.visibilityState!=="visible"||jt.render())},UE);const Ct=new Lx(Si,{list:()=>k.list(),restore:g=>{ft(g)},dismiss:g=>{k.dismiss(g)}}),ps=()=>{const g=me.activePreset_get();if(g==="pacs"||g==="dag"||g==="launcher"){on=!0;return}on&&g==="files"||(on=!0,Le())},De=(g,y)=>{const E=wE(g);return l.pane_join(E.id,y!==void 0?l.group_of(y):E.id),g==="tags"&&l.regard_subscribe(E.id,I=>{I.modelKind==="dicom.instance"&&ls(E.id,I.address)}),g==="view"&&(l.viewer_mark(E.id),l.regard_subscribe(E.id,I=>{I.modelKind!=="dicom.instance"&&pt.get(E.id)?.regard_show(I)})),me.mount_register(E.id,E.mount),ns(E.id,g,E.mount),E},ns=(g,y,E)=>{const I=E.querySelector(".pane-drawer"),D=E.querySelector(".pane-handle");if(I===null||D===null)return;D.addEventListener("click",X=>{X.target instanceof Element&&X.target.closest("button")!==null||(I.hidden=!I.hidden,I.hidden||I.querySelector("button")?.focus(),kt("audio3"))});const B=I.querySelector(".drawer-zoom");B!==null&&(B.dataset.pane=g);for(const X of I.querySelectorAll(".drawer-bind"))X.addEventListener("click",()=>{for(const re of I.querySelectorAll(".drawer-bind"))re.classList.remove("drawer-bind-selected");X.classList.add("drawer-bind-selected"),kt("audio3")});for(const X of I.querySelectorAll("[data-split]"))X.addEventListener("click",()=>{const re=X.dataset.split==="row"?"row":"col",le=X.dataset.place==="before",ge=I.querySelector(".drawer-bind-selected")?.dataset.bind??"unlinked";A(g,ge==="viewer"?"view":ge==="fs"?"fs":"empty",re,le)!==null&&(I.hidden=!0,kt("audio3"))});I.querySelector(".drawer-close")?.addEventListener("click",()=>{if(g==="dag"){on=!1,Le();return}me.leaf_close(g)||Le(),Te(),kt("audio3")});const U=I.querySelector(".drawer-children");if(U===null)return;const F=(X,re,le,ge="")=>{const fe=document.createElement("button");fe.className=`pacs-capsule drawer-child${ge===""?"":` ${ge}`}`,fe.textContent=X,fe.title=re,fe.addEventListener("click",()=>{le(),I.hidden=!0,kt("audio3")}),U.appendChild(fe)};if(y==="files"||y==="catalogue"){const X=I.querySelector(".drawer-binding");if(X!==null){const fe=document.createElement("span");fe.className="drawer-label drawer-label-cwd",fe.textContent="CWD",X.appendChild(fe);const Ue=(Fe,wt,Kt)=>{const yt=document.createElement("button");return yt.className="pacs-capsule drawer-cwdbind",yt.dataset.follow=wt?"on":"off",yt.textContent=Fe,yt.title=Kt,yt.addEventListener("click",()=>{m.get(g)===!0!==wt&&z(g,wt),kt("audio3")}),X.appendChild(yt),yt};Ue("FOLLOW CWD",!0,"bind this browser to the session cwd (the console's browser)"),Ue("ROOT HERE",!1,"unbind from the cwd: this browser keeps its own place"),S(g,()=>{const Fe=m.get(g)===!0;for(const wt of X.querySelectorAll(".drawer-cwdbind"))wt.classList.toggle("drawer-bind-selected",wt.dataset.follow==="on"===Fe)}),v(g)}const re=()=>m.get(g)===!0;E.querySelector(".files-home")?.addEventListener("click",()=>{if(re()){ve.line_run("cd ~");return}const fe=i.get(g);if(fe===void 0)return;const Ue=fe.path_current();Ue!==null&&_.get(g)?.push(Ue),b(g,fe,"~")}),E.querySelector(".files-back")?.addEventListener("click",()=>{if(re()){ve.line_run("cd -");return}const fe=i.get(g),Ue=_.get(g)?.pop();fe!==void 0&&Ue!==void 0&&b(g,fe,Ue)});const le=()=>i.get(g)?.path_current()??null;E.querySelector(".files-mkdir")?.addEventListener("click",()=>{const fe=le();fe!==null&&G(g,fe)}),E.querySelector(".files-refresh")?.addEventListener("click",()=>{const fe=le();fe!==null&&x(g,fe)});const ge=E.querySelector(".files-upload-input");E.querySelector(".files-upload")?.addEventListener("click",()=>{le()!==null&&ge?.click()}),ge?.addEventListener("change",()=>{const fe=le(),Ue=ge.files;fe===null||Ue===null||Ue.length===0||(O(g,fe,Array.from(Ue)),ge.value="")})}y==="dag"&&(F("ENTER NODE","move the session into the indicated node (its data directory)",()=>{const X=l.regard_get(g),re=a.get(g)?.feed_get()??null,le=X===null?re===null?null:`/proc/jobs/feed_${re}`:X.modelKind==="fs.file"?X.address.replace(/\/[^/]*$/,"")||"/":X.address;le!==null&&ve.line_run(`cd "${le}"`)}),F("PROCESS NODE","run an executable on the indicated node's output (a catalogue opens beside)",()=>{const X=l.regard_get(g),re=a.get(g)?.feed_get()??null;if(X===null||re===null)return;const le=X.modelKind==="fs.file"?X.address.replace(/\/[^/]*$/,"")||"/":X.address,ge=oe(le)??(/_(\d+)\/?$/.exec(le)===null?null:parseInt(/_(\d+)\/?$/.exec(le)?.[1]??"",10));ge!==null&&R(g,{input:le.replace(/\/data\/?$/,"")+"/data",feed:re,node:ge})}),F("ENTER FEED","move the session into the feed on stage (or the one picked in the roster)",()=>{const X=a.get(g)?.feed_get()??null;X!==null&&ve.line_run(`cd "/proc/jobs/feed_${X}"`)}),F("BACK","return to the previous listing inside the node",()=>{const X=ce.get(g),re=X?.history.pop();X!==void 0&&re!==void 0&&b(g,X.panel,re)}),F("CLEAR DETAIL","dismiss the node facts (a click on empty space does too)",()=>{a.get(g)?.detail_clear()}),F("REFRESH","revisit the feed now (a watch keeps sampling it while it runs)",()=>{a.get(g)?.refresh()}))};ns("files","files",Ws.mount),ns("dag","dag",Ls.mount),ns("universe","universe",Vr.mount),ns("pacs","pacs",st("pacs-workspace")),ns("launcher","launcher",xi),ns("panes","panes",Si);let _t=!1;const cs=g=>{_t=g};for(const g of["click","focusin"])document.addEventListener(g,y=>{y.target instanceof Element&&(y.target.closest("#drawer")!==null?_t=!0:y.target.closest("#layout-root")!==null&&(_t=!1))});const Ts=()=>{let g=!1;for(const y of document.querySelectorAll(".pane-drawer:not([hidden])"))y.hidden=!0,g=!0;return g},cn=()=>{let g=!1;for(const y of document.querySelectorAll('.workspace-pane[data-modes="open"]'))delete y.dataset.modes,g=!0;return ks.serverStrip_isOpen()&&(ks.serverStrip_close(),g=!0),g};document.addEventListener("click",g=>{if(!(g.target instanceof Element)||g.target.closest(".mode-frame")!==null&&g.target.closest(".mode-fill")===null||g.target.closest("#pacs-server-strip")!==null||g.target.closest("#pacs-f-server")!==null||g.target.closest(".listing-framed .listing-row")!==null)return;const y=g.target.closest(".mode-strip"),E=y?.closest(".workspace-pane")??null,I=E?.dataset.modes==="open",D=cn();if(y!==null&&E!==null&&!I){E.dataset.modes="open",kt("audio3");return}D&&kt("audio3")}),window.addEventListener("keydown",g=>{if(g.key==="Escape"){if(!Ai.hidden){qr(),g.stopImmediatePropagation();return}if(ve.ask_abandon()){g.stopImmediatePropagation(),kt("audio3");return}if(IA()){g.stopImmediatePropagation(),kt("audio3");return}if(si!==null){si(),g.stopImmediatePropagation(),kt("audio3");return}for(const re of dt.values())if(re.field_release()){g.stopImmediatePropagation(),kt("audio3");return}let y=!1;for(const re of ve.ask_isOpen()?[]:i.values())re.select_isOn()&&(re.select_toggle(!1),y=!0);if(y){g.stopImmediatePropagation(),kt("audio3");return}const E=Ts(),I=cn();if(E||I){g.stopImmediatePropagation(),kt("audio3");return}if(document.body.dataset.zoom!==void 0)return;if(ee()){g.stopImmediatePropagation(),kt("audio3");return}const D=[...ce.keys()].pop();if(D!==void 0){const re=ce.get(D);re!==void 0&&re.panel.content_isShown()?re.panel.listing_restore():Yt(D),g.stopImmediatePropagation(),kt("audio3");return}const B=[...a.entries()].find(([,re])=>re.inside_isHeld());if(B!==void 0){B[1].flight_back(()=>{}),g.stopImmediatePropagation(),kt("audio3");return}const U=me.focused_get(),X=[...i.entries()].filter(([,re])=>re.content_isShown()).sort(([re],[le])=>re===U?-1:le===U?1:0)[0];if(X!==void 0){X[1].listing_restore(),g.stopImmediatePropagation(),kt("audio3");return}for(const re of a.values())if(re.nav_pop()){g.stopImmediatePropagation(),kt("audio3");return}return}if((g.key==="ArrowRight"||g.key==="ArrowLeft"||g.key==="ArrowDown"||g.key==="ArrowUp")&&document.activeElement instanceof HTMLButtonElement){const y=document.activeElement.closest(".pane-drawer");if(y!==null&&!y.hidden){const E=[...y.querySelectorAll("button")],I=E.indexOf(document.activeElement),D=g.key==="ArrowRight"||g.key==="ArrowDown";E[(I+(D?1:E.length-1))%E.length]?.focus(),g.preventDefault(),g.stopImmediatePropagation()}return}if(g.key===":"&&document.querySelector(".pane-drawer:not([hidden])")!==null){Ts(),Sl(),g.preventDefault(),g.stopImmediatePropagation();return}if(g.key==="b"&&g.ctrlKey&&!g.altKey&&!g.metaKey){if(document.querySelector(".pane-drawer:not([hidden])")!==null){Ts(),Sl(),g.preventDefault();return}g.preventDefault();const y=document.body.dataset.zoom,E=y==="console"||y===void 0&&_t,I=y!==void 0&&y!=="console"?y:me.focused_get()??"files",D=E?st("console-drawer"):mn(I)?.mount?.querySelector(".pane-drawer")??null;if(D===null)return;g.preventDefault(),D.hidden=!D.hidden,D.hidden||D.querySelector("button")?.focus(),kt("audio3")}},{capture:!0});const ii=(g,y,E)=>{if(y==="pacs"){me.preset_apply("pacs"),Te();for(const B of E)ks.envelope_observe(B);return}const I=De(y);if(me.leaf_replace(g,I.id),$s(g),me.mount_remove(g),y==="tags"){const B=Pt.get(I.id);for(const U of E){if(U.model?.kind!==Ga.tags)continue;const F=Nu.safeParse(U.model.data);F.success&&B?.model_show(F.data)}return}if(y==="image"){const B=dt.get(I.id);for(const U of E){if(U.model?.kind!==Ga.series)continue;const F=Cu.safeParse(U.model.data);F.success&&B?.series_show(F.data)}return}const D=y==="files"||y==="catalogue"?i.get(I.id):a.get(I.id);for(const B of E)D?.envelope_observe(B)};Fn("files",g=>qt(g,!1)),Fn("catalogue",g=>qt(g,!1,!0)),Fn("dag",g=>Wt(g,!1)),Fn("universe",At),Fn("view",Ne),Fn("image",vt),Fn("tags",ts),Fn("gather",ne),Fn("empty",g=>{const y=fn("tpl-pane-empty");return new RA(y,{execute:E=>bt.line_execute(E,{silent:!0,observe:!1}),claim:(E,I)=>ii(g,E,I)}),{id:g,kind:"empty",mount:y}});const Bt=g=>{g?document.body.dataset.gutter="away":delete document.body.dataset.gutter,kt("audio3")},Vt=(g,y)=>{if(me.activePreset_get()===g){Bt(!0);return}document.body.dataset.gutter==="away"&&delete document.body.dataset.gutter,y()};st("gutter-restore").addEventListener("click",()=>Bt(!1)),window.addEventListener("keydown",g=>{g.key==="Escape"&&document.body.dataset.gutter==="away"&&document.body.dataset.zoom===void 0&&Bt(!1)}),st("gutter-files").addEventListener("click",()=>{Vt("files",()=>{on=!1,Le(),me.focus_set("files"),cs(!1)})});const Gs=(g="")=>{Pe("dag"),Ys.list_reset(),Ys.roster_filter(g),Ys.feedsChooser_request(),me.focus_set("dag"),cs(!1)},Lt=()=>{Pe("universe");const g=o.get("universe");g!==void 0&&!g.shown_get()&&g.request(),me.focus_set("universe"),cs(!1)};st("gutter-runs").addEventListener("click",()=>Vt("dag",()=>Gs())),st("gutter-console").addEventListener("click",()=>{st("drawer").classList.contains("drawer-closed")&&st("drawer-toggle").click(),ve.focus_take(),cs(!0)}),st("gutter-tools").addEventListener("click",()=>{Vt("pacs",()=>{Pe("pacs"),me.focus_set("pacs"),cs(!1)})}),st("gutter-dashboard").addEventListener("click",()=>{Vt("launcher",qe)}),st("gutter-panes").addEventListener("click",()=>{Vt("panes",()=>{Pe("panes"),Ct.render(),me.focus_set("panes"),cs(!1)})});const zs=g=>mn(g)?.kind??null,Rn={focused_get:()=>{const g=document.body.dataset.zoom;return g!==void 0&&g!=="console"?g:me.focused_get()??me.panes_shown()[0]??null},focus_set:g=>mn(g)===void 0?!1:(me.focus_set(g),!0),panes_shown:()=>me.panes_shown(),paneRect_get:g=>document.querySelector(`.layout-leaf[data-leaf="${g}"]`)?.getBoundingClientRect()??null,paneMount_get:g=>mn(g)?.mount??null,paneKind_get:zs,paneLinked_get:g=>l.group_of(g)!==g,feed_enter:g=>Ys.feed_enter(g),consoleZoom_toggle:SE,launcher_enter:qe,identity_get:()=>tt,node_immerse:g=>{const E=l.regard_get(g)?.address.match(/_(\d+)(?:\/data)?\/?$/)??null;return E===null?!1:a.get(g)?.node_flyTo(parseInt(E[1]??"",10))??!1},file_download:g=>{const y=l.regard_get(g);return y===null||y.modelKind!=="fs.file"?!1:(ll(d(y.address)),!0)},image_open:(g,y,E)=>gt(g,y,E??{}),image_control:async(g,y,E)=>{const I=new Set(me.panes_shown()),D=l.group_of(g),B=[...dt.entries()].filter(([F])=>I.has(F)),U=dt.get(g)??B.find(([F])=>l.group_of(F)===D)?.[1]??(B.length===1?B[0]?.[1]:void 0);if(U===void 0)return`image ${y}: no image pane on stage for '${g}'`;if(y==="layout"){const F=E[0]??"";return zS.includes(F)?await U.layout_set(F)?`image layout ${F}`:U.state_get()?.waiting===F?`image layout ${F}: waiting for LOAD`:`image layout ${F}: not offered`:"image layout single|mpr|3d|slab"}if(y==="slice"){const F=Number(E[0]);return!Number.isInteger(F)||F<1?"image slice <n>":U.slice_set(F)?`image slice ${F}`:`image slice ${F}: not offered`}if(y==="series"){const F=Number(E[0]),X=U.siblings_get();if(X.length===0)return"image series: this pane holds one series, not a study";const re=X[F-1];if(re===void 0)return`image series <1..${X.length}>: ${X.map((ge,fe)=>`${fe+1} ${ge.label}`).join(" · ")}`;const le=await Zt(re.path);return le===null?`image series ${F}: ${re.path}: not a readable DICOM series`:(U.series_show(le,{siblings:[...X]}),`image series ${F} ${re.label}`)}if(y==="wl"){if((E[0]??"").toLowerCase()==="preset"){const re=E[1]??"";return re===""?"image wl preset <brain|bone|lung|soft|liver>":U.wlPreset_set(re)?`image wl preset ${re}`:`image wl preset ${re}: none for this modality`}const F=Number(E[0]),X=Number(E[1]);return!Number.isFinite(F)||!Number.isFinite(X)||F>=X?"image wl <lower> <upper> | image wl preset <name>":U.wl_set(F,X)?`image wl ${F} ${X}`:"image wl: not offered"}if(y==="colormap"){const F=(E[0]??"").toLowerCase();return Co.includes(F)?U.colormap_set(F)?`image colormap ${F}`:`image colormap ${F}: not offered`:"image colormap gray|hot|jet|cool"}if(y==="save")return await U.annotations_save()?"image save":"image save: nothing saved (the console says why)";if(y==="load")return await U.load_press()?"image load":"image load: nothing was waiting";if(y==="guard"){if((E[0]??"").toLowerCase()==="off")return U.guard_set(null),"image guard off";const X=Number(E[0]);return!Number.isFinite(X)||X<0?`image guard <bytes>|off (now ${U.guard_get()===null?"off":U.guard_get()})`:(U.guard_set(X),`image guard ${X}`)}if(y==="ghost"){const X=(E[0]??"").toLowerCase()==="off"?null:Number(E[0]);return X!==null&&(!Number.isFinite(X)||X<0||X>1)?"image ghost <0..1>|off (SLAB layout)":U.ghost_set(X)?`image ghost ${X===null?"off":X}`:"image ghost: SLAB layout only"}if(y==="tags"){const F=[...dt.entries()].find(([,X])=>X===U)?.[0];return F===void 0?"image tags: no image pane":Xt(F)}return"image <path> · layout single|mpr|3d · slice <n> · series <n> · wl <lo> <hi> | wl preset <name> · colormap <name> · save"},universe_control:(g,y,E)=>{const I=new Set(me.panes_shown()),D=(g!==null?o.get(g):void 0)??[...o.entries()].find(([B])=>I.has(B))?.[1];return D===void 0?"universe: no universe pane on stage (press the dashboard tile)":D.control(y,E)},tags_control:(g,y,E)=>{const I=new Set(me.panes_shown()),D=l.group_of(g),B=[...Pt.entries()].filter(([F])=>I.has(F)),U=Pt.get(g)??B.find(([F])=>l.group_of(F)===D)?.[1]??(B.length===1?B[0]?.[1]:void 0);if(U===void 0)return`tags ${y}: no tags pane on stage for '${g}'`;if(y==="redact"){const F=(E[0]??"").toLowerCase();return F!=="on"&&F!=="off"?"tags redact on|off":(U.redact_set(F==="on"),`tags redact ${F}`)}if(y==="filter"){const F=E.join(" ");return F===""||F.toLowerCase()==="off"?(U.filter_set(null),"tags filter off"):(U.filter_set(F),`tags filter ${F}`)}return"tags redact on|off · filter <text>|off"},file_delete:g=>{const y=l.regard_get(g);return y===null||y.modelKind!=="fs.file"?!1:(ve.line_run(`rm "${y.address}"`),!0)},session_run:async g=>{try{return(await bt.line_execute(g,{silent:!0,observe:!1})).envelopes.map(E=>E.renderedErr??E.rendered).join(`
4230
4230
  `)}catch(y){return y instanceof Error?y.message:String(y)}},desktop_serialize:()=>{const g=me.tree_get();if(g===null)return"# empty desktop";const y=[],E=le=>"pane"in le?le.pane:E(le.first),I=E(g),D=zs(I);y.push(`view ${D==="dag"?"runs":D==="pacs"?"pacs":"files"}`);let B=1;const U=(le,ge)=>{const fe=zs(le);if(fe==="dag"&&le!==I&&y.push(`pane %${ge} claim runs`),fe==="files"&&le!==I&&l.group_of(le)===le&&y.push(`pane %${ge} claim files`),fe==="dag"){const Ue=mn(le)?.mount,Fe=Ue?.querySelector(".dag-strategy")?.textContent?.toLowerCase()??"ranked",wt=Ue?.querySelector(".dag-projection")?.textContent?.toLowerCase()??"3d",Kt=Ue?.querySelector(".dag-hue")?.textContent?.toLowerCase()??"status";Fe!=="ranked"&&y.push(`dag %${ge} layout ${Fe}`),wt!=="3d"&&y.push(`dag %${ge} projection ${wt}`),Kt!=="status"&&y.push(`dag %${ge} hue ${Kt}`)}},F=(le,ge)=>{if("pane"in le){U(le.pane,ge);return}const fe=E(le.second),Ue=zs(fe),Fe=Ue==="view"?"viewer":Ue==="files"&&l.group_of(fe)!==fe?"fs":"unlinked";y.push(`pane %${ge} bind ${Fe}`),y.push(`pane %${ge} split ${le.dir==="col"?"right":"below"}`);const wt=++B;F(le.first,ge),F(le.second,wt)};F(g,B);const X=document.body.dataset.header;return X!==void 0&&y.push(`header ${X}`),document.getElementById("drawer")?.classList.contains("drawer-closed")&&y.push("console close"),y.join(`
4231
- `)}},Si=rt("lang-palette"),ri=rt("lang-input"),Ol=rt("lang-result"),xl=rt("lang-pill"),Sl=()=>{Ts(),Si.hidden=!1,xl.classList.add("lang-live"),Ol.textContent="",ri.value="",ri.focus(),kt("audio3")},qr=()=>{Si.hidden=!0,xl.classList.remove("lang-live"),Ol.textContent=""};xl.addEventListener("click",()=>{Si.hidden?Sl():qr()});const pM=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus"],Ou={pane:["split","zoom","close","bind","claim","focus"],view:["files","runs","pacs"],runs:["enter","sort","filter"],node:["enter","immerse","back","clear"],dag:["layout","projection","scale","hue","pulse","census","physics","refresh"],physics:["charge","link","collide","gravity","reset"],file:["home","back","download","delete","sort","filter","follow","root","list","cards","preview"],pacs:["sort","filter","connect","disconnect","list","query","pull","status"],header:["stats","dag","away","restore"],console:["open","close","toggle","zoom","height"],desktop:["save","load","show","list","delete"],split:["left","right","above","below"],bind:["unlinked","fs","viewer"],claim:["files","runs","pacs"],layout:["ranked","molecule"],projection:["2d","3d"],scale:["time","size"],hue:["status","compute"],argus:["verbs"]};ri.addEventListener("keydown",g=>{if(g.key==="Escape"){g.stopPropagation(),qr();return}if(g.key==="Tab"){g.preventDefault();const y=ri.value.split(/\s+/),E=y[y.length-1]??"",I=y.length<=1?"":y[y.length-2]??"",B=(y.length<=1?pM:Ou[I]??Ou[y[0]??""]??[]).find(U=>U.startsWith(E.toLowerCase()));B!==void 0&&(y[y.length-1]=B,ri.value=`${y.join(" ")} `);return}if(g.key==="Enter"){const y=ri.value.trim();if(y.length===0){qr();return}kd(Rn,y).then(E=>{E!==null?(Ol.textContent=E,ve.output_write("data",`: ${y}
4231
+ `)}},Ai=st("lang-palette"),ri=st("lang-input"),Ol=st("lang-result"),xl=st("lang-pill"),Sl=()=>{Ts(),Ai.hidden=!1,xl.classList.add("lang-live"),Ol.textContent="",ri.value="",ri.focus(),kt("audio3")},qr=()=>{Ai.hidden=!0,xl.classList.remove("lang-live"),Ol.textContent=""};xl.addEventListener("click",()=>{Ai.hidden?Sl():qr()});const pM=["pane","view","runs","node","dag","file","pacs","header","console","back","desktop","argus"],Ou={pane:["split","zoom","close","bind","claim","focus"],view:["files","runs","pacs"],runs:["enter","sort","filter"],node:["enter","immerse","back","clear"],dag:["layout","projection","scale","hue","pulse","census","physics","refresh"],physics:["charge","link","collide","gravity","reset"],file:["home","back","download","delete","sort","filter","follow","root","list","cards","preview"],pacs:["sort","filter","connect","disconnect","list","query","pull","status"],header:["stats","dag","away","restore"],console:["open","close","toggle","zoom","height"],desktop:["save","load","show","list","delete"],split:["left","right","above","below"],bind:["unlinked","fs","viewer"],claim:["files","runs","pacs"],layout:["ranked","molecule"],projection:["2d","3d"],scale:["time","size"],hue:["status","compute"],argus:["verbs"]};ri.addEventListener("keydown",g=>{if(g.key==="Escape"){g.stopPropagation(),qr();return}if(g.key==="Tab"){g.preventDefault();const y=ri.value.split(/\s+/),E=y[y.length-1]??"",I=y.length<=1?"":y[y.length-2]??"",B=(y.length<=1?pM:Ou[I]??Ou[y[0]??""]??[]).find(U=>U.startsWith(E.toLowerCase()));B!==void 0&&(y[y.length-1]=B,ri.value=`${y.join(" ")} `);return}if(g.key==="Enter"){const y=ri.value.trim();if(y.length===0){qr();return}kd(Rn,y).then(E=>{E!==null?(Ol.textContent=E,ve.output_write("data",`: ${y}
4232
4232
  ${E}
4233
- `),ri.value="",ri.select()):(qr(),ve.line_run(y))})}}),bp()?(me.preset_apply("launcher"),jt.render()):me.preset_apply(me.savedPreset_get()??"files");const mM=rt("drawer-status"),Xr=g=>{mM.textContent=`MODE: [${g}]`};Ux(document.documentElement);const ve=new Qx(rt("terminal"),async g=>{const y=await kd(Rn,g);if(y!==null){ve.output_write("data",`${y}
4233
+ `),ri.value="",ri.select()):(qr(),ve.line_run(y))})}}),bp()?(me.preset_apply("launcher"),jt.render()):me.preset_apply(me.savedPreset_get()??"files");const mM=st("drawer-status"),Xr=g=>{mM.textContent=`MODE: [${g}]`};$x(document.documentElement);const ve=new sS(st("terminal"),async g=>{const y=await kd(Rn,g);if(y!==null){ve.output_write("data",`${y}
4234
4234
  `),ve.prompt_draw(),Xr("READY");return}Xr("BUSY");const E=performance.now();try{const I=await bt.line_execute(g);ve.outcome_write(I),I.envelopes.some(D=>D.model?.kind==="fs.cwd")&&bt.line_execute("ls",{silent:!0})}catch(I){const D=I instanceof Error?I.message:String(I);ve.output_write("err",`\x1B[31m${D}\x1B[0m
4235
- `)}xu.clear(),e.activity_clear(),Xr(`READY ${Math.round(performance.now()-E)}ms`),ve.prompt_draw()},g=>bt.line_complete(g));wE(g=>ve.line_note(g));const xu=new sS(ve.progressRegion_get(),g=>ve.output_write("err",g)),Al=await gu.session_attach(AE(),n,{output_receive:(g,y)=>ve.output_write(g,y),progress_receive:g=>{xu.write(g),e.progress_observe(g),Ir?.progress_observe(g);for(const y of a.values())y.progress_observe(g);ks.progress_observe(g)},ask_receive:async g=>{if(g.kind!=="path"){const I=sr;return sr=null,I!==null&&mn(I)!==void 0?ni(I,{message:g.message,kind:g.kind==="secret"?"secret":g.kind==="confirm"?"confirm":"text",...g.suggest===void 0?{}:{suggest:g.suggest}}):(tr?.(!1),ve.ask_open({message:g.message,kind:g.kind,...g.suggest===void 0?{}:{suggest:g.suggest}}))}const y=ve.ask_note(g.message),E=await Gn(g);return y(E),E},promptline_receive:g=>{ct=g.user,tt=g.uri===""?g.user:`${g.user}@${g.uri}`,Object.assign(globalThis,{__argusPromptContext:g,__argusPromptContext_show:y=>e.promptContext_show(y)}),ve.promptContext_set(g),e.promptContext_show(g),t.promptContext_show(g),Ir?.promptContext_observe(g),Ys.promptContext_observe(g);for(const y of o.values())y.promptContext_observe(g);for(const y of i.values())y.home_set(g.user===""?null:`/home/${g.user}`)},telemetry_receive:(g,y)=>{t.counts_show(g),y?.state!==void 0&&t.state_show(y.state),s.telemetry_show(y??{}),y?.cube!==void 0&&t.pace_show(y.cube.msPerPage),Ir?.index_observe(g)},session_receive:(g,y)=>ve.session_write(g,y),ambient_receive:g=>{if(g.model?.kind==="fs.listing"){$r.ambient_observe(g);for(const E of i.values())E.ambient_observe(g);return}if(g.model?.kind!=="feed.dag")return;const y=Pc.safeParse(g.model.data);if(y.success){Ys.model_refresh(y.data);for(const E of a.values())E.model_refresh(y.data)}},watched_receive:(g,y)=>{Ys.watched_observe(g,y);for(const E of a.values())E.watched_observe(g,y)},numbered_receive:g=>{uS({source:g.source,handles:g.handles})},envelope_observe:g=>{const y=g.model?.kind;if(y===xb.view){const E=Ob.safeParse(g.model?.data);E.success&&gt(me.focused_get(),E.data.path,E.data.force===!0?{force:!0}:{}).then(I=>ve.line_note(I));return}if(y==="feed.dag"||y==="feed.list"||y===gi.feedIndexing){const E=me.focused_get();(E!==null&&a.has(E)?a.get(E):Ys).envelope_observe(g)}else{for(const[E,I]of i)m.get(E)===!0&&I.envelope_observe(g);if(ks.envelope_observe(g),y==="fs.rm"||y==="fs.mv"||y==="fs.cp")for(const[E,I]of i){const D=I.path_current();D!==null&&x(E,D)}}Hr.envelope_observe(g)},close_handle:()=>{e.connection_show(!1),Ir?.connection_show(!1),Xr("OFFLINE")}}),bt=Al.client;e.attach_show(Al.attach),e.connection_show(!0),Ir?.connection_show(!0),FE(Al.attach),bt.line_execute("ls /bin",{silent:!0,observe:!1}).then(g=>{const I=(g.envelopes.find(D=>D.model?.kind==="fs.listing")?.model?.data??[]).flatMap(D=>D.items).filter(D=>D.type==="pipeline").map(D=>D.name);Hr.names_set(I)}),bt.line_execute("ls",{silent:!0}),me.activePreset_get()==="launcher"&&jt.render(),hM=L,Oe(),Ke(),Xr("READY"),ve.splash_write(vE),ve.prompt_draw(),ve.focus_take(),bt.line_execute(`motd ${OE}`,{silent:!0,observe:!1}).then(g=>{const y=g.envelopes.filter(E=>E.status==="ok").map(E=>E.rendered).join("").trimEnd();y.length>0&&ve.greeting_write(y.split(`
4236
- `))}).catch(()=>{}),tr=IE(rt("drawer"),rt("drawer-strip"),rt("drawer-toggle"),ve);const nr=rt("console-drawer");rt("console-handle").addEventListener("click",g=>{g.target instanceof Element&&g.target.closest("button")!==null||(nr.hidden=!nr.hidden,nr.hidden||nr.querySelector("button")?.focus(),kt("audio3"))}),nr.querySelector(".console-retract")?.addEventListener("click",()=>{nr.hidden=!0,rt("drawer-toggle").click()}),dM=TE(ve),jE(),window.addEventListener("resize",()=>ve.size_fit())}function $E(){const n=rt("door-pill");Pm(window.location.search)&&(n.hidden=!1,n.addEventListener("click",()=>{const e=wf(window.location.pathname,"logout"),t=wf(window.location.pathname,"login");fetch(e,{method:"POST",headers:{accept:"application/json"}}).catch(()=>{}).then(()=>{window.location.assign(t)})}))}function HE(){Ir=GE(),NE(),BE(),SE(),UE(),$E();const e=new URLSearchParams(window.location.search).get("token"),t=Pm(window.location.search),s=rt("attach-form"),i=rt("attach-error"),r=o=>{VE(o).then(()=>{s.classList.add("attach-hidden")},l=>{s.classList.remove("attach-hidden"),i.textContent=l instanceof Error?l.message:String(l)})},a=rt("attach-token");rt("attach-submit").addEventListener("click",()=>{a.value.trim().length>0&&r(a.value.trim())}),a.addEventListener("keydown",o=>{o.key==="Enter"&&a.value.trim().length>0&&r(a.value.trim())}),e!==null&&e.length>0?(s.classList.add("attach-hidden"),r(e)):t&&(s.classList.add("attach-hidden"),r(""))}HE();export{Af as I,op as _,qE as b};
4235
+ `)}xu.clear(),e.activity_clear(),Xr(`READY ${Math.round(performance.now()-E)}ms`),ve.prompt_draw()},g=>bt.line_complete(g));xE(g=>ve.line_note(g));const xu=new aS(ve.progressRegion_get(),g=>ve.output_write("err",g)),Al=await gu.session_attach(GE(),n,{output_receive:(g,y)=>ve.output_write(g,y),progress_receive:g=>{xu.write(g),e.progress_observe(g),Ir?.progress_observe(g);for(const y of a.values())y.progress_observe(g);ks.progress_observe(g)},ask_receive:async g=>{if(g.kind!=="path"){const I=sr;return sr=null,I!==null&&mn(I)!==void 0?ni(I,{message:g.message,kind:g.kind==="secret"?"secret":g.kind==="confirm"?"confirm":"text",...g.suggest===void 0?{}:{suggest:g.suggest}}):(tr?.(!1),ve.ask_open({message:g.message,kind:g.kind,...g.suggest===void 0?{}:{suggest:g.suggest}}))}const y=ve.ask_note(g.message),E=await Gn(g);return y(E),E},promptline_receive:g=>{ct=g.user,tt=g.uri===""?g.user:`${g.user}@${g.uri}`,Object.assign(globalThis,{__argusPromptContext:g,__argusPromptContext_show:y=>e.promptContext_show(y)}),ve.promptContext_set(g),e.promptContext_show(g),t.promptContext_show(g),Ir?.promptContext_observe(g),Ys.promptContext_observe(g);for(const y of o.values())y.promptContext_observe(g);for(const y of i.values())y.home_set(g.user===""?null:`/home/${g.user}`)},telemetry_receive:(g,y)=>{t.counts_show(g),y?.state!==void 0&&t.state_show(y.state),s.telemetry_show(y??{}),y?.cube!==void 0&&t.pace_show(y.cube.msPerPage),Ir?.index_observe(g)},session_receive:(g,y)=>ve.session_write(g,y),ambient_receive:g=>{if(g.model?.kind==="fs.listing"){$r.ambient_observe(g);for(const E of i.values())E.ambient_observe(g);return}if(g.model?.kind!=="feed.dag")return;const y=Pc.safeParse(g.model.data);if(y.success){Ys.model_refresh(y.data);for(const E of a.values())E.model_refresh(y.data)}},watched_receive:(g,y)=>{Ys.watched_observe(g,y);for(const E of a.values())E.watched_observe(g,y)},numbered_receive:g=>{mS({source:g.source,handles:g.handles})},envelope_observe:g=>{const y=g.model?.kind;if(y===xb.view){const E=Ob.safeParse(g.model?.data);E.success&&gt(me.focused_get(),E.data.path,E.data.force===!0?{force:!0}:{}).then(I=>ve.line_note(I));return}if(y==="feed.dag"||y==="feed.list"||y===bi.feedIndexing){const E=me.focused_get();(E!==null&&a.has(E)?a.get(E):Ys).envelope_observe(g)}else{for(const[E,I]of i)m.get(E)===!0&&I.envelope_observe(g);if(ks.envelope_observe(g),y==="fs.rm"||y==="fs.mv"||y==="fs.cp")for(const[E,I]of i){const D=I.path_current();D!==null&&x(E,D)}}Hr.envelope_observe(g)},close_handle:()=>{e.connection_show(!1),Ir?.connection_show(!1),Xr("OFFLINE")}}),bt=Al.client;e.attach_show(Al.attach),e.connection_show(!0),Ir?.connection_show(!0),qE(Al.attach),bt.line_execute("ls /bin",{silent:!0,observe:!1}).then(g=>{const I=(g.envelopes.find(D=>D.model?.kind==="fs.listing")?.model?.data??[]).flatMap(D=>D.items).filter(D=>D.type==="pipeline").map(D=>D.name);Hr.names_set(I)}),bt.line_execute("ls",{silent:!0}),me.activePreset_get()==="launcher"&&jt.render(),hM=L,Oe(),Ke(),Xr("READY"),ve.splash_write(AE),ve.prompt_draw(),ve.focus_take(),bt.line_execute(`motd ${EE}`,{silent:!0,observe:!1}).then(g=>{const y=g.envelopes.filter(E=>E.status==="ok").map(E=>E.rendered).join("").trimEnd();y.length>0&&ve.greeting_write(y.split(`
4236
+ `))}).catch(()=>{}),tr=NE(st("drawer"),st("drawer-strip"),st("drawer-toggle"),ve);const nr=st("console-drawer");st("console-handle").addEventListener("click",g=>{g.target instanceof Element&&g.target.closest("button")!==null||(nr.hidden=!nr.hidden,nr.hidden||nr.querySelector("button")?.focus(),kt("audio3"))}),nr.querySelector(".console-retract")?.addEventListener("click",()=>{nr.hidden=!0,st("drawer-toggle").click()}),dM=CE(ve),XE(),window.addEventListener("resize",()=>ve.size_fit())}function KE(){const n=st("door-pill");Pm(window.location.search)&&(n.hidden=!1,n.addEventListener("click",()=>{const e=wf(window.location.pathname,"logout"),t=wf(window.location.pathname,"login");fetch(e,{method:"POST",headers:{accept:"application/json"}}).catch(()=>{}).then(()=>{window.location.assign(t)})}))}function ZE(){Ir=PE(),kE(),LE(),IE(),TE(),HE(),KE();const e=new URLSearchParams(window.location.search).get("token"),t=Pm(window.location.search),s=st("attach-form"),i=st("attach-error"),r=o=>{YE(o).then(()=>{s.classList.add("attach-hidden")},l=>{s.classList.remove("attach-hidden"),i.textContent=l instanceof Error?l.message:String(l)})},a=st("attach-token");st("attach-submit").addEventListener("click",()=>{a.value.trim().length>0&&r(a.value.trim())}),a.addEventListener("keydown",o=>{o.key==="Enter"&&a.value.trim().length>0&&r(a.value.trim())}),e!==null&&e.length>0?(s.classList.add("attach-hidden"),r(e)):t&&(s.classList.add("attach-hidden"),r(""))}ZE();export{Af as I,op as _,QE as b};