@rr0/ufoathome 0.55.1 → 0.55.2

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,4 +1,4 @@
1
- const im=["nw","n","ne","e","se","s","sw","w"];function Er(s,e,t){const n=s.x-e.x,i=s.y-e.y,a=Math.cos(t),r=Math.sin(t);return{x:e.x+n*a-i*r,y:e.y+n*r+i*a}}function Ps(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const Zg={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class nt{static handlePointsFor(e){const{x:t,y:n,width:i,height:a}=e.bounds,r={nw:{x:t,y:n},n:{x:t+i/2,y:n},ne:{x:t+i,y:n},e:{x:t+i,y:n+a/2},se:{x:t+i,y:n+a},s:{x:t+i/2,y:n+a},sw:{x:t,y:n+a},w:{x:t,y:n+a/2},rotate:{x:t+i/2,y:n-24}},o=Ps(e.bounds),l={};for(const c of Object.keys(r))l[c]=Er(r[c],o,e.angle);return l}static hitTestHandle(e,t,n=8,i=[...im,"rotate"]){const a=nt.handlePointsFor(e);for(const r of i)if(Math.hypot(t.x-a[r].x,t.y-a[r].y)<=n)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(e,t){const i=((nt.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,a=["ew","nwse","ns","nesw"];return a[Math.round(i)%a.length]}static resizeBounds(e,t,n,i){const a=Ps(e),r=Er(i,a,-t),{x:o,y:l,width:c,height:h}=e,d=Zg[n];let u=o,f=l,g=o+c,v=l+h;return d.left&&(u=Math.min(r.x,g-8)),d.right&&(g=Math.max(r.x,u+8)),d.top&&(f=Math.min(r.y,v-8)),d.bottom&&(v=Math.max(r.y,f+8)),{x:u,y:f,width:g-u,height:v-f}}static resizeShape(e,t,n){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:a}=e.bounds,r=nt.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:r};const o=i===0?1:r.width/i,l=a===0?1:r.height/a;return{...e,bounds:r,points:e.points.map(c=>({x:c.x*o,y:c.y*l}))}}static rotateShape(e,t){const n=Ps(e.bounds),i=Math.atan2(t.y-n.y,t.x-n.x)+Math.PI/2;return{...e,angle:i}}static groupBoundsFor(e){const t=Math.min(...e.map(r=>r.x)),n=Math.min(...e.map(r=>r.y)),i=Math.max(...e.map(r=>r.x+r.width)),a=Math.max(...e.map(r=>r.y+r.height));return{x:t,y:n,width:i-t,height:a-n}}static vertexPointsFor(e){const t=Ps(e.bounds);return e.points.map(n=>Er({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=8){const i=nt.vertexPointsFor(e);let a,r=n;return i.forEach((o,l)=>{const c=Math.hypot(t.x-o.x,t.y-o.y);c<=r&&(r=c,a=l)}),a}static toLocalPoint(e,t){const n=Ps(e.bounds),i=Er(t,n,-e.angle);return{x:i.x-e.bounds.x,y:i.y-e.bounds.y}}static moveVertex(e,t,n){const i=e.points.map((d,u)=>u===t?nt.toLocalPoint(e,n):d),a=Math.min(...i.map(d=>d.x)),r=Math.min(...i.map(d=>d.y)),o=Math.max(...i.map(d=>d.x)),l=Math.max(...i.map(d=>d.y)),c={x:e.bounds.x+a,y:e.bounds.y+r,width:o-a,height:l-r},h=i.map(d=>({x:d.x-a,y:d.y-r}));return{...e,bounds:c,points:h}}static insertVertexNear(e,t){const n=nt.toLocalPoint(e,t),{points:i}=e;let a=i.length-1,r=1/0;for(let l=0;l<i.length;l++){const c=i[l],h=i[(l+1)%i.length],d=nt.distanceToSegment(n,c,h);d<r&&(r=d,a=l)}const o=[...i.slice(0,a+1),n,...i.slice(a+1)];return{...e,points:o}}static distanceToSegment(e,t,n){const i=n.x-t.x,a=n.y-t.y,r=i*i+a*a,o=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*a)/r)),l=t.x+o*i,c=t.y+o*a;return Math.hypot(e.x-l,e.y-c)}static deleteVertex(e,t){return e.points.length<=3?e:{...e,points:e.points.filter((n,i)=>i!==t)}}}class ic{constructor(e){this.members=e}bounds(){return nt.groupBoundsFor(this.members.map(e=>e.shape.bounds))}scaleTo(e){const t=this.bounds(),n=t.width===0?1:e.width/t.width,i=t.height===0?1:e.height/t.height;return this.members.map(({sourceId:a,shape:r})=>{const o=Math.max(r.bounds.width*n,8),l=Math.max(r.bounds.height*i,8),c=e.x+(r.bounds.x-t.x)*n,h=e.y+(r.bounds.y-t.y)*i,d={x:c,y:h,width:o,height:l};return r.kind==="oval"?{sourceId:a,shape:{...r,bounds:d}}:{sourceId:a,shape:{...r,bounds:d,points:r.points.map(u=>({x:u.x*n,y:u.y*i}))}}})}resize(e,t){return this.scaleTo(nt.resizeBounds(this.bounds(),0,e,t))}rotate(e,t){const n=Ps(this.bounds()),i=r=>Math.atan2(r.y-n.y,r.x-n.x),a=i(e)-i(t);return this.members.map(({sourceId:r,shape:o})=>{const l=Ps(o.bounds),c=Er(l,n,a),h={x:c.x-o.bounds.width/2,y:c.y-o.bounds.height/2,width:o.bounds.width,height:o.bounds.height};return{sourceId:r,shape:{...o,bounds:h,angle:o.angle+a}}})}}const bh=6,oo=bh/2,Bu=20,xh=24,zu=9,Hu=6,Gu=7,Vu=6,Wu=4;class wh{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}static paintExtent(e){const{x:t,y:n,width:i,height:a}=e.bounds,r=t+i/2,o=n+a/2,l=e.angle%(2*Math.PI)!==0,c=Math.hypot(i,a)/2,h=l?c:i/2,d=l?c:a/2,u=Math.max(i,a)/2,f=e.brightness??0,g=f>0?Math.max(u*(1+zu*f),Vu*f)-u:0,v=f>0?u*(1+Gu*f)-u:0,p=3*xh*(e.blur??0)+1.5*Bu*e.haloScale,m=Math.max(g,v,0)+p+2;return{x:r-h-m,y:o-d-m,width:2*(h+m),height:2*(d+m)}}paintInto(e,t,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-t.x,-t.y),this.paintShape(e.selected?{...e,selected:!1}:e),this.ctx.restore()}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(xh*t).toFixed(2)}px)`);const n=e.brightness??0;n>0&&this.paintDazzle(e,n),e.haloScale>0&&this.paintHalo(e),this.paintBase(e),this.ctx.restore(),e.selected&&this.paintSelectionHandles(e)}setStarPoints(e){this.starPoints=Math.max(0,Math.floor(e))}setRoll(e){this.roll=e}paintDazzle(e,t){const{x:n,y:i,width:a,height:r}=e.bounds,o=n+a/2,l=i+r/2,c=Math.max(a,r)/2,h=Math.max(c*(1+zu*t),Vu*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const d=this.ctx.createRadialGradient(o,l,0,o,l,h);for(let u=0;u<=Hu;u++){const f=u/Hu,g=1/(1+24*f*f);this.ctx.globalAlpha=1,d.addColorStop(f,this.withAlpha(e.color,g*t*.55))}if(this.ctx.fillStyle=d,this.ctx.beginPath(),this.ctx.arc(o,l,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const u=c*(1+Gu*t);this.ctx.lineWidth=Math.max(1,c*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(g)*u,p=l+Math.sin(g)*u,m=this.ctx.createLinearGradient(o,l,v,p);m.addColorStop(0,this.withAlpha(e.color,t*.55)),m.addColorStop(.35,this.withAlpha(e.color,t*.22)),m.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,l),this.ctx.lineTo(v,p),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const n=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!n)return e.color;const i=Number.parseInt(n[1],16),a=r=>Math.round(r+(255-r)*t);return`rgb(${a(i>>16&255)}, ${a(i>>8&255)}, ${a(i&255)})`}withAlpha(e,t){const n=Math.max(0,Math.min(1,t)),i=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!i)return e;const a=Number.parseInt(i[1],16);return`rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${n.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:n,width:i,height:a}=e.bounds,r=i/2,o=a/2;this.ctx.ellipse(t+r,n+o,r,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:i,height:a}=e.bounds;this.ctx.save(),this.ctx.translate(t+i/2,n+a/2),this.ctx.rotate(e.angle),this.ctx.translate(-i/2,-a/2),e.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=Bu*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(nt.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of nt.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Wu,Wu,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(nt.handlePointsFor(e))}paintSelectionOnly(e){this.paintSelectionHandles(e)}paintGroupHandles(e){this.paintHandleFrame(nt.handlePointsFor({bounds:e,angle:0}),{includeRotate:!0})}paintOutline(e){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(e.nw.x,e.nw.y),this.ctx.lineTo(e.ne.x,e.ne.y),this.ctx.lineTo(e.se.x,e.se.y),this.ctx.lineTo(e.sw.x,e.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(e,{includeRotate:t}){this.paintOutline(e),this.ctx.fillStyle="lightgray";for(const n of im){const i=e[n];this.ctx.fillRect(i.x-oo,i.y-oo,bh,bh)}t&&(this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,oo+1,oo+1,0,0,2*Math.PI),this.ctx.fill())}}class Cs extends Error{constructor(e,t,n){super(`${e}: ${t}${n===void 0?"":` (HTTP ${n})`}`),this.kind=e,this.url=t,this.status=n,this.name="SightingFetchError"}}class Kd{static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new Cs("mixed-content",e);let n;try{n=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!n.ok)throw new Cs("status",e,n.status);try{return await n.json()}catch{throw new Cs("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new Cs("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new Cs("cors",e)}catch{return new Cs("unreachable",e)}}}const Jg="modulepreload",jg=function(s,e){return new URL(s,e).href},Xu={},Qn=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let r=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");i=r(t.map(h=>{if(h=jg(h,n),h in Xu)return;Xu[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const p=o[v];if(p.href===h&&(!d||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":Jg,d||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),d)return new Promise((v,p)=>{g.addEventListener("load",v),g.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return i.then(r=>{for(const o of r||[])o.status==="rejected"&&a(o.reason);return e().catch(a)})};class Cn extends Error{constructor(e,t,n){const i=e==="rejected"&&typeof t=="string"?t:void 0,a=e==="rejected"?n:t;super(i??e,a===void 0?void 0:{cause:a}),this.kind=e,this.name="NarrativeError",this.detail=i}detail}class Pn{constructor(e){this.entries=e}static empty(){return new Pn(new Map)}get size(){return this.entries.size}at(e){return this.entries.get(e)}paths(){return[...this.entries.keys()]}set(e,t){t.basis==="stated"&&t.rationale===void 0?this.entries.delete(e):this.entries.set(e,t)}clear(e){for(const t of this.entries.keys())(t===e||t.startsWith(`${e}.`))&&this.entries.delete(t)}static strip(e){const t=new Pn(new Map);return{recording:Pn.stripValue(e,[],t),provenance:t}}static restore(e,t){if(t.size===0)return e;const n=structuredClone(e);for(const i of t.paths()){const a=t.at(i),r=i.split("."),o=Pn.holderOf(n,r);if(!o)continue;const l=r[r.length-1],c=o[l];c!==void 0&&(a.of!==void 0&&JSON.stringify(a.of)!==JSON.stringify(c)||(o[l]={value:c,...a.basis==="stated"?{}:{basis:a.basis},...a.rationale===void 0?{}:{rationale:a.rationale}}))}return n}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,n){return Pn.isWrapper(e)?(n.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),Pn.stripValue(e.value,t,n)):Array.isArray(e)?e.map((i,a)=>Pn.stripValue(i,[...t,String(a)],n)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Pn.stripValue(a,[...t,i],n)])):e}static holderOf(e,t){let n=e;for(const i of t.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}class wl{static of(e){const{recording:t}=Pn.strip(e),{timeline:n,...i}=t,a=(n?.keyframes??[]).map(o=>wl.keyframe(o)),r=Object.entries(i).filter(([o,l])=>o!=="version"&&l!==void 0);if(!(r.length===0&&a.every(o=>o.shapes.length===0)))return{...Object.fromEntries(r),...a.length>0?{timeline:{keyframes:a}}:{}}}static keyframe(e){return{t:e.t,shapes:e.shapes.map(t=>wl.shape(t.sourceId,t.shape))}}static shape(e,t){const n=t??{},i=n.angular,a=n.aim;return{sourceId:e,kind:n.kind??"oval",...n.title===void 0?{}:{title:n.title},...i?.widthDeg===void 0||i.heightDeg===void 0?{}:{angular:{widthDeg:i.widthDeg,heightDeg:i.heightDeg}},...a?.azimuthDeg===void 0||a.altitudeDeg===void 0?{}:{aim:{azimuthDeg:a.azimuthDeg,altitudeDeg:a.altitudeDeg}}}}}const qu={name:"draft_recording",description:"Record what the account states, what justifies each value, and what it leaves out.",input_schema:{type:"object",properties:{recording:{type:"object",description:"The recording, in the format given above. Partial: only the fields the account actually states."},claims:{type:"array",description:"One entry per value in `recording`. EVERY value needs one: a value with no claim is a value nobody can check.",items:{type:"object",properties:{path:{type:"string",description:'Where the value sits in `recording`, dot-joined, array indices as steps: "time.hour", "place.0.lat", "timeline.keyframes.1.shapes.0.shape.angular.widthDeg".'},basis:{type:"string",enum:["stated","derived","assumed"],description:'"stated": the witness said it. "derived": worked out from what they said plus something checkable. "assumed": chosen so the reconstruction has a value at all, on nothing they said.'},rationale:{type:"string",description:`For "stated", the account's own words, copied verbatim, never a paraphrase. For "derived", the working, with the numbers in it. For "assumed", what the guess was chosen for and how wrong it could be.`}},required:["path","basis","rationale"]}},gaps:{type:"array",description:"What nothing could settle, not even a guess worth making — one short sentence each, in the reader's language. Usually empty.",items:{type:"string"}}},required:["recording","claims","gaps"]}},Qg=`You are reading a witness's account of an aerial sighting and reconstructing it in the
1
+ const im=["nw","n","ne","e","se","s","sw","w"];function Er(s,e,t){const n=s.x-e.x,i=s.y-e.y,a=Math.cos(t),r=Math.sin(t);return{x:e.x+n*a-i*r,y:e.y+n*r+i*a}}function Ps(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const Zg={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class it{static handlePointsFor(e){const{x:t,y:n,width:i,height:a}=e.bounds,r={nw:{x:t,y:n},n:{x:t+i/2,y:n},ne:{x:t+i,y:n},e:{x:t+i,y:n+a/2},se:{x:t+i,y:n+a},s:{x:t+i/2,y:n+a},sw:{x:t,y:n+a},w:{x:t,y:n+a/2},rotate:{x:t+i/2,y:n-24}},o=Ps(e.bounds),l={};for(const c of Object.keys(r))l[c]=Er(r[c],o,e.angle);return l}static hitTestHandle(e,t,n=8,i=[...im,"rotate"]){const a=it.handlePointsFor(e);for(const r of i)if(Math.hypot(t.x-a[r].x,t.y-a[r].y)<=n)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(e,t){const i=((it.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,a=["ew","nwse","ns","nesw"];return a[Math.round(i)%a.length]}static resizeBounds(e,t,n,i){const a=Ps(e),r=Er(i,a,-t),{x:o,y:l,width:c,height:h}=e,d=Zg[n];let u=o,f=l,g=o+c,v=l+h;return d.left&&(u=Math.min(r.x,g-8)),d.right&&(g=Math.max(r.x,u+8)),d.top&&(f=Math.min(r.y,v-8)),d.bottom&&(v=Math.max(r.y,f+8)),{x:u,y:f,width:g-u,height:v-f}}static resizeShape(e,t,n){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:a}=e.bounds,r=it.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:r};const o=i===0?1:r.width/i,l=a===0?1:r.height/a;return{...e,bounds:r,points:e.points.map(c=>({x:c.x*o,y:c.y*l}))}}static rotateShape(e,t){const n=Ps(e.bounds),i=Math.atan2(t.y-n.y,t.x-n.x)+Math.PI/2;return{...e,angle:i}}static groupBoundsFor(e){const t=Math.min(...e.map(r=>r.x)),n=Math.min(...e.map(r=>r.y)),i=Math.max(...e.map(r=>r.x+r.width)),a=Math.max(...e.map(r=>r.y+r.height));return{x:t,y:n,width:i-t,height:a-n}}static vertexPointsFor(e){const t=Ps(e.bounds);return e.points.map(n=>Er({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=8){const i=it.vertexPointsFor(e);let a,r=n;return i.forEach((o,l)=>{const c=Math.hypot(t.x-o.x,t.y-o.y);c<=r&&(r=c,a=l)}),a}static toLocalPoint(e,t){const n=Ps(e.bounds),i=Er(t,n,-e.angle);return{x:i.x-e.bounds.x,y:i.y-e.bounds.y}}static moveVertex(e,t,n){const i=e.points.map((d,u)=>u===t?it.toLocalPoint(e,n):d),a=Math.min(...i.map(d=>d.x)),r=Math.min(...i.map(d=>d.y)),o=Math.max(...i.map(d=>d.x)),l=Math.max(...i.map(d=>d.y)),c={x:e.bounds.x+a,y:e.bounds.y+r,width:o-a,height:l-r},h=i.map(d=>({x:d.x-a,y:d.y-r}));return{...e,bounds:c,points:h}}static insertVertexNear(e,t){const n=it.toLocalPoint(e,t),{points:i}=e;let a=i.length-1,r=1/0;for(let l=0;l<i.length;l++){const c=i[l],h=i[(l+1)%i.length],d=it.distanceToSegment(n,c,h);d<r&&(r=d,a=l)}const o=[...i.slice(0,a+1),n,...i.slice(a+1)];return{...e,points:o}}static distanceToSegment(e,t,n){const i=n.x-t.x,a=n.y-t.y,r=i*i+a*a,o=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*a)/r)),l=t.x+o*i,c=t.y+o*a;return Math.hypot(e.x-l,e.y-c)}static deleteVertex(e,t){return e.points.length<=3?e:{...e,points:e.points.filter((n,i)=>i!==t)}}}class ic{constructor(e){this.members=e}bounds(){return it.groupBoundsFor(this.members.map(e=>e.shape.bounds))}scaleTo(e){const t=this.bounds(),n=t.width===0?1:e.width/t.width,i=t.height===0?1:e.height/t.height;return this.members.map(({sourceId:a,shape:r})=>{const o=Math.max(r.bounds.width*n,8),l=Math.max(r.bounds.height*i,8),c=e.x+(r.bounds.x-t.x)*n,h=e.y+(r.bounds.y-t.y)*i,d={x:c,y:h,width:o,height:l};return r.kind==="oval"?{sourceId:a,shape:{...r,bounds:d}}:{sourceId:a,shape:{...r,bounds:d,points:r.points.map(u=>({x:u.x*n,y:u.y*i}))}}})}resize(e,t){return this.scaleTo(it.resizeBounds(this.bounds(),0,e,t))}rotate(e,t){const n=Ps(this.bounds()),i=r=>Math.atan2(r.y-n.y,r.x-n.x),a=i(e)-i(t);return this.members.map(({sourceId:r,shape:o})=>{const l=Ps(o.bounds),c=Er(l,n,a),h={x:c.x-o.bounds.width/2,y:c.y-o.bounds.height/2,width:o.bounds.width,height:o.bounds.height};return{sourceId:r,shape:{...o,bounds:h,angle:o.angle+a}}})}}const bh=6,oo=bh/2,Bu=20,xh=24,zu=9,Hu=6,Gu=7,Vu=6,Wu=4;class wh{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}static paintExtent(e){const{x:t,y:n,width:i,height:a}=e.bounds,r=t+i/2,o=n+a/2,l=e.angle%(2*Math.PI)!==0,c=Math.hypot(i,a)/2,h=l?c:i/2,d=l?c:a/2,u=Math.max(i,a)/2,f=e.brightness??0,g=f>0?Math.max(u*(1+zu*f),Vu*f)-u:0,v=f>0?u*(1+Gu*f)-u:0,p=3*xh*(e.blur??0)+1.5*Bu*e.haloScale,m=Math.max(g,v,0)+p+2;return{x:r-h-m,y:o-d-m,width:2*(h+m),height:2*(d+m)}}paintInto(e,t,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-t.x,-t.y),this.paintShape(e.selected?{...e,selected:!1}:e),this.ctx.restore()}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(xh*t).toFixed(2)}px)`);const n=e.brightness??0;n>0&&this.paintDazzle(e,n),e.haloScale>0&&this.paintHalo(e),this.paintBase(e),this.ctx.restore(),e.selected&&this.paintSelectionHandles(e)}setStarPoints(e){this.starPoints=Math.max(0,Math.floor(e))}setRoll(e){this.roll=e}paintDazzle(e,t){const{x:n,y:i,width:a,height:r}=e.bounds,o=n+a/2,l=i+r/2,c=Math.max(a,r)/2,h=Math.max(c*(1+zu*t),Vu*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const d=this.ctx.createRadialGradient(o,l,0,o,l,h);for(let u=0;u<=Hu;u++){const f=u/Hu,g=1/(1+24*f*f);this.ctx.globalAlpha=1,d.addColorStop(f,this.withAlpha(e.color,g*t*.55))}if(this.ctx.fillStyle=d,this.ctx.beginPath(),this.ctx.arc(o,l,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const u=c*(1+Gu*t);this.ctx.lineWidth=Math.max(1,c*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(g)*u,p=l+Math.sin(g)*u,m=this.ctx.createLinearGradient(o,l,v,p);m.addColorStop(0,this.withAlpha(e.color,t*.55)),m.addColorStop(.35,this.withAlpha(e.color,t*.22)),m.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,l),this.ctx.lineTo(v,p),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const n=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!n)return e.color;const i=Number.parseInt(n[1],16),a=r=>Math.round(r+(255-r)*t);return`rgb(${a(i>>16&255)}, ${a(i>>8&255)}, ${a(i&255)})`}withAlpha(e,t){const n=Math.max(0,Math.min(1,t)),i=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!i)return e;const a=Number.parseInt(i[1],16);return`rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${n.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:n,width:i,height:a}=e.bounds,r=i/2,o=a/2;this.ctx.ellipse(t+r,n+o,r,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:i,height:a}=e.bounds;this.ctx.save(),this.ctx.translate(t+i/2,n+a/2),this.ctx.rotate(e.angle),this.ctx.translate(-i/2,-a/2),e.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=Bu*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(it.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of it.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Wu,Wu,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(it.handlePointsFor(e))}paintSelectionOnly(e){this.paintSelectionHandles(e)}paintGroupHandles(e){this.paintHandleFrame(it.handlePointsFor({bounds:e,angle:0}),{includeRotate:!0})}paintOutline(e){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(e.nw.x,e.nw.y),this.ctx.lineTo(e.ne.x,e.ne.y),this.ctx.lineTo(e.se.x,e.se.y),this.ctx.lineTo(e.sw.x,e.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(e,{includeRotate:t}){this.paintOutline(e),this.ctx.fillStyle="lightgray";for(const n of im){const i=e[n];this.ctx.fillRect(i.x-oo,i.y-oo,bh,bh)}t&&(this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,oo+1,oo+1,0,0,2*Math.PI),this.ctx.fill())}}class Cs extends Error{constructor(e,t,n){super(`${e}: ${t}${n===void 0?"":` (HTTP ${n})`}`),this.kind=e,this.url=t,this.status=n,this.name="SightingFetchError"}}class Kd{static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new Cs("mixed-content",e);let n;try{n=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!n.ok)throw new Cs("status",e,n.status);try{return await n.json()}catch{throw new Cs("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new Cs("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new Cs("cors",e)}catch{return new Cs("unreachable",e)}}}const Jg="modulepreload",jg=function(s,e){return new URL(s,e).href},Xu={},ei=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let r=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");i=r(t.map(h=>{if(h=jg(h,n),h in Xu)return;Xu[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const p=o[v];if(p.href===h&&(!d||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":Jg,d||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),d)return new Promise((v,p)=>{g.addEventListener("load",v),g.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return i.then(r=>{for(const o of r||[])o.status==="rejected"&&a(o.reason);return e().catch(a)})};class Cn extends Error{constructor(e,t,n){const i=e==="rejected"&&typeof t=="string"?t:void 0,a=e==="rejected"?n:t;super(i??e,a===void 0?void 0:{cause:a}),this.kind=e,this.name="NarrativeError",this.detail=i}detail}class Pn{constructor(e){this.entries=e}static empty(){return new Pn(new Map)}get size(){return this.entries.size}at(e){return this.entries.get(e)}paths(){return[...this.entries.keys()]}set(e,t){t.basis==="stated"&&t.rationale===void 0?this.entries.delete(e):this.entries.set(e,t)}clear(e){for(const t of this.entries.keys())(t===e||t.startsWith(`${e}.`))&&this.entries.delete(t)}static strip(e){const t=new Pn(new Map);return{recording:Pn.stripValue(e,[],t),provenance:t}}static restore(e,t){if(t.size===0)return e;const n=structuredClone(e);for(const i of t.paths()){const a=t.at(i),r=i.split("."),o=Pn.holderOf(n,r);if(!o)continue;const l=r[r.length-1],c=o[l];c!==void 0&&(a.of!==void 0&&JSON.stringify(a.of)!==JSON.stringify(c)||(o[l]={value:c,...a.basis==="stated"?{}:{basis:a.basis},...a.rationale===void 0?{}:{rationale:a.rationale}}))}return n}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,n){return Pn.isWrapper(e)?(n.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),Pn.stripValue(e.value,t,n)):Array.isArray(e)?e.map((i,a)=>Pn.stripValue(i,[...t,String(a)],n)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Pn.stripValue(a,[...t,i],n)])):e}static holderOf(e,t){let n=e;for(const i of t.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}class wl{static of(e){const{recording:t}=Pn.strip(e),{timeline:n,...i}=t,a=(n?.keyframes??[]).map(o=>wl.keyframe(o)),r=Object.entries(i).filter(([o,l])=>o!=="version"&&l!==void 0);if(!(r.length===0&&a.every(o=>o.shapes.length===0)))return{...Object.fromEntries(r),...a.length>0?{timeline:{keyframes:a}}:{}}}static keyframe(e){return{t:e.t,shapes:e.shapes.map(t=>wl.shape(t.sourceId,t.shape))}}static shape(e,t){const n=t??{},i=n.angular,a=n.aim;return{sourceId:e,kind:n.kind??"oval",...n.title===void 0?{}:{title:n.title},...i?.widthDeg===void 0||i.heightDeg===void 0?{}:{angular:{widthDeg:i.widthDeg,heightDeg:i.heightDeg}},...a?.azimuthDeg===void 0||a.altitudeDeg===void 0?{}:{aim:{azimuthDeg:a.azimuthDeg,altitudeDeg:a.altitudeDeg}}}}}const qu={name:"draft_recording",description:"Record what the account states, what justifies each value, and what it leaves out.",input_schema:{type:"object",properties:{recording:{type:"object",description:"The recording, in the format given above. Partial: only the fields the account actually states."},claims:{type:"array",description:"One entry per value in `recording`. EVERY value needs one: a value with no claim is a value nobody can check.",items:{type:"object",properties:{path:{type:"string",description:'Where the value sits in `recording`, dot-joined, array indices as steps: "time.hour", "place.0.lat", "timeline.keyframes.1.shapes.0.shape.angular.widthDeg".'},basis:{type:"string",enum:["stated","derived","assumed"],description:'"stated": the witness said it. "derived": worked out from what they said plus something checkable. "assumed": chosen so the reconstruction has a value at all, on nothing they said.'},rationale:{type:"string",description:`For "stated", the account's own words, copied verbatim, never a paraphrase. For "derived", the working, with the numbers in it. For "assumed", what the guess was chosen for and how wrong it could be.`}},required:["path","basis","rationale"]}},gaps:{type:"array",description:"What nothing could settle, not even a guess worth making — one short sentence each, in the reader's language. Usually empty.",items:{type:"string"}}},required:["recording","claims","gaps"]}},Qg=`You are reading a witness's account of an aerial sighting and reconstructing it in the
2
2
  recording format of UFO@home, a tool that replays what a witness reported seeing, from where they
3
3
  stood, under the real sky of that moment.
4
4
 
@@ -85,7 +85,7 @@ Then:
85
85
  says an investigator came, or that it is a press cutting.
86
86
  12. Silence is a statement. A witness who says the thing was silent is not a witness who said nothing
87
87
  about sound: write a \`soundTrack\` whose keyframe holds a sound of kind "none", and mark it
88
- "stated". An account that simply never mentions sound gets no soundTrack at all.`;class Ca{needsCredential=!0;acceptsCredentialScope=!0;static MODEL="claude-opus-5";client;clientFor_;format;async draft(e,t){const n=await this.clientFor(e.credential,e.credentialScope),i=this.format??=JSON.stringify((await Qn(async()=>{const{default:o}=await import("./sightingSchema-VqeOJZ7p.js");return{default:o}},[],import.meta.url)).default),a=n.messages.stream({model:Ca.MODEL,max_tokens:16e3,system:[{type:"text",text:Qg},{type:"text",text:`The recording format, every key with what its own declaration says about it:
88
+ "stated". An account that simply never mentions sound gets no soundTrack at all.`;class Ca{needsCredential=!0;acceptsCredentialScope=!0;static MODEL="claude-opus-5";client;clientFor_;format;async draft(e,t){const n=await this.clientFor(e.credential,e.credentialScope),i=this.format??=JSON.stringify((await ei(async()=>{const{default:o}=await import("./sightingSchema-VqeOJZ7p.js");return{default:o}},[],import.meta.url)).default),a=n.messages.stream({model:Ca.MODEL,max_tokens:16e3,system:[{type:"text",text:Qg},{type:"text",text:`The recording format, every key with what its own declaration says about it:
89
89
 
90
90
  ${i}`,cache_control:{type:"ephemeral"}}],messages:this.messages(e),tools:[qu],tool_choice:{type:"auto",disable_parallel_tool_use:!0}}),r=()=>a.controller.abort();t?.aborted&&r(),t?.addEventListener("abort",r,{once:!0});try{return Ca.read(await a.finalMessage())}catch(o){throw await Ca.diagnose(o,t)}finally{t?.removeEventListener("abort",r)}}messages(e){return[{role:"user",content:[...(e.images??[]).map(t=>Ca.imageBlock(t)),{type:"text",text:this.ask(e)}]}]}ask(e){const t=[];e.language&&t.push(`Write the gaps in ${e.language}.`);const n=e.current?wl.of(e.current):void 0;return n&&t.push(`What the editor already holds, shapes reduced to their stated angle and direction. Do not restate a value here that the account does not itself state:
91
91
 
@@ -93,7 +93,7 @@ ${JSON.stringify(n)}`),t.push(`The account:
93
93
 
94
94
  ${e.ask}`,"Answer by calling draft_recording."),t.join(`
95
95
 
96
- `)}static imageBlock(e){return{type:"image",source:{type:"base64",media_type:e.mediaType,data:e.data}}}async clientFor(e,t){if(!e)throw new Cn("credential");const n=`${e}\0${t??""}`;if(this.client&&this.clientFor_===n)return this.client;const{default:i}=await Qn(async()=>{const{default:a}=await import("./index-DQDuRMiM.js").then(r=>r.i);return{default:a}},[],import.meta.url);return this.client=new i({apiKey:e,...t?{defaultHeaders:{"anthropic-workspace-id":t}}:{},dangerouslyAllowBrowser:!0,maxRetries:1}),this.clientFor_=n,this.client}static read(e){if(e.stop_reason==="refusal")throw new Cn("refused");const t=e.content.find(i=>i.type==="tool_use"&&i.name===qu.name);if(!t||t.type!=="tool_use")throw new Cn("malformed");const n=t.input;if(typeof n?.recording!="object"||n.recording===null||Array.isArray(n.recording))throw new Cn("malformed");return{recording:n.recording,claims:Array.isArray(n.claims)?n.claims.flatMap(i=>{const{path:a,basis:r,rationale:o}=i??{};return typeof a!="string"||typeof o!="string"?[]:[{path:a,basis:r==="derived"||r==="assumed"?r:"stated",rationale:o}]}):[],gaps:Array.isArray(n.gaps)?n.gaps.filter(i=>typeof i=="string"):[]}}static async diagnose(e,t){if(e instanceof Cn)return e;if(t?.aborted)return new Cn("cancelled",e);const{default:n}=await Qn(async()=>{const{default:i}=await import("./index-DQDuRMiM.js").then(a=>a.i);return{default:i}},[],import.meta.url);return e instanceof n.AuthenticationError||e instanceof n.PermissionDeniedError?new Cn("credential",e):e instanceof n.RateLimitError?new Cn("rate-limited",e):e instanceof n.BadRequestError||e instanceof n.NotFoundError?new Cn("rejected",e.message,e):e instanceof n.APIConnectionError?new Cn("unreachable",e):new Cn("malformed",e)}}const ws=[{id:"claude",name:"Claude",credit:"Anthropic",creditUrl:"https://www.anthropic.com/legal/consumer-terms",create:()=>new Ca}],e1=[{id:"coverage",name:"Coverage",credit:"UFO@home",creditUrl:"https://ufoathome.org",create:()=>({about:"witness",assess:async s=>{const{CoverageAssessor:e}=await Qn(async()=>{const{CoverageAssessor:t}=await import("./CoverageAssessor-FIt771Wz.js");return{CoverageAssessor:t}},[],import.meta.url);return new e().assess(s)}})},{id:"hynek",name:"Hynek",credit:"J. Allen Hynek",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/",create:()=>({about:"temporal",assess:async s=>{const{HynekAssessor:e}=await Qn(async()=>{const{HynekAssessor:t}=await import("./HynekAssessor-DUqRa3Su.js");return{HynekAssessor:t}},[],import.meta.url);return new e().assess(s)}})}];class t1{constructor(e){this.labels=e}async read(e){const t=[],n=new Set;for(const i of e1){let a;try{a=await i.create().assess(e)}catch{continue}for(const o of a.criteria)o.basis===void 0&&!o.unsupported&&n.add(o.id);const r=a.score===void 0?a.verdict===void 0?"":this.verdictName(i.id,a.verdict):`${Math.round(a.score*100)}%`;r!==""&&t.push({group:"assessment",field:i.id,label:this.labels.assessmentNames[i.id]??i.name,value:r,unit:"",fromSource:!1,about:i.create().about})}return{entries:t,unanswered:n}}verdictName(e,t){return this.labels.assessmentVerdicts[`${e}.${t}`]??t.toUpperCase()}}class pi{static stated(e){return pi.statedIn(e,[])}static apply(e,t,n){const i=structuredClone(e);for(const a of n){const r=a.split("."),o=pi.read(t,r);o!==void 0&&pi.write(i,r,structuredClone(o))}return i}static statedIn(e,t){const n=[];for(const[i,a]of Object.entries(e)){if(a===void 0)continue;const r=[...t,i];pi.isPlainObject(a)?n.push(...pi.statedIn(a,r)):n.push(r.join("."))}return n}static isPlainObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}static read(e,t){let n=e;for(const i of t){if(!pi.isPlainObject(n))return;n=n[i]}return n}static write(e,t,n){let i=e;for(const a of t.slice(0,-1)){const r=i[a];pi.isPlainObject(r)||(i[a]={}),i=i[a]}i[t[t.length-1]]=n}}class ht{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(e){return 2*Math.atan(e.sizeM/(2*e.distanceM))*180/Math.PI}static inMoons(e){return e/ht.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,n){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*n,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*n}}static sizeMAt(e,t){return 2*e*Math.tan(t*Math.PI/360)}static distanceMAt(e,t){return e/(2*Math.tan(t*Math.PI/360))}}const Qs=["front","behind","left","right","front-left","front-right","behind-left","behind-right"];function $d(s){return s==="vehicle"?["front","behind","front-left","front-right","behind-left","behind-right"]:["front","behind","left","right"]}function n1(s){return s==="vehicle"?["front-left","front-right","behind-left","behind-right"]:$d(s)}const Mh=90,i1=50;function sm(s){if(!Zd(s))return;const e={};for(const t of $d(s))e[t]=Sh(s,t)?i1:Mh;return e}const Oa=2;function Zd(s){return s==="building"||s==="vehicle"}function Sh(s,e){return s==="building"?!0:s==="vehicle"?e!=="front"&&e!=="behind":!1}function Ra(s){return s==="building"||s==="vehicle"}function Ml(s,e){const t=s.litKeyframes;if(!t||t.length===0)return s.lit??!1;let n=t[0];for(const i of t){if(i.t>e)break;n=i}return n.lit}function s1(s,e){return s.pattern.kind==="steady"?!0:am(s,e,e+1)>.5}function am(s,e,t){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:a=0}=s.pattern,r=Math.min(Math.max(i,0),1);if(r===0||n<=0)return 0;const o=6e4/n,l=e/o+a,c=t/o+a;if(c<=l)return Math.min(Math.max(l-Math.floor(l),0),r)<r?1:0;const h=d=>Math.floor(d)*r+Math.min(d-Math.floor(d),r);return(h(c)-h(l))/(c-l)}function Ya(s,e){const t=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!t||t.length===0)return n;if(t.length===1||e<=t[0].t)return Yu(t[0],s);const i=t[t.length-1];if(e>=i.t)return Yu(i,s);for(let a=0;a<t.length-1;a++){const r=t[a],o=t[a+1];if(e<r.t||e>o.t)continue;const l=o.t-r.t,c=l===0?0:(e-r.t)/l;return{eastM:r.eastM+(o.eastM-r.eastM)*c,northM:r.northM+(o.northM-r.northM)*c,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*c,headingDeg:r.headingDeg??s.headingDeg}}return n}function Yu(s,e){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??e.headingDeg}}const a1={x:ht.CANVAS_WIDTH_PX/2,y:ht.CANVAS_HEIGHT_PX/2,width:1,height:1};class Sl{static loadable(e){const t=e.decor?{decor:e.decor.map((i,a)=>Sl.decor(i,a))}:{},n=e.timeline?.keyframes;return n?{...e,...t,timeline:{...e.timeline,keyframes:n.map(i=>({t:i.t??0,shapes:(i.shapes??[]).map(a=>({sourceId:a.sourceId,shape:Sl.shape(a.shape)}))}))}}:{...e,...t}}static decor(e,t){const n=e.kind??"vehicle";return{...Zd(n)?{windows:sm(n)}:{},...n==="building"?{floors:Oa}:{},...e,id:e.id??`decor-${t+1}`,kind:n,eastM:e.eastM??0,northM:e.northM??0}}static shape(e){const t=e?.kind==="polygon"?"polygon":"oval";return{...t==="polygon"?{points:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}]}:{},...e,kind:t,bounds:{...a1},color:typeof e?.color=="string"?e.color:"#e8e6df",angle:0,transparency:0,haloScale:0,selected:!1}}}const r1=`
96
+ `)}static imageBlock(e){return{type:"image",source:{type:"base64",media_type:e.mediaType,data:e.data}}}async clientFor(e,t){if(!e)throw new Cn("credential");const n=`${e}\0${t??""}`;if(this.client&&this.clientFor_===n)return this.client;const{default:i}=await ei(async()=>{const{default:a}=await import("./index-DQDuRMiM.js").then(r=>r.i);return{default:a}},[],import.meta.url);return this.client=new i({apiKey:e,...t?{defaultHeaders:{"anthropic-workspace-id":t}}:{},dangerouslyAllowBrowser:!0,maxRetries:1}),this.clientFor_=n,this.client}static read(e){if(e.stop_reason==="refusal")throw new Cn("refused");const t=e.content.find(i=>i.type==="tool_use"&&i.name===qu.name);if(!t||t.type!=="tool_use")throw new Cn("malformed");const n=t.input;if(typeof n?.recording!="object"||n.recording===null||Array.isArray(n.recording))throw new Cn("malformed");return{recording:n.recording,claims:Array.isArray(n.claims)?n.claims.flatMap(i=>{const{path:a,basis:r,rationale:o}=i??{};return typeof a!="string"||typeof o!="string"?[]:[{path:a,basis:r==="derived"||r==="assumed"?r:"stated",rationale:o}]}):[],gaps:Array.isArray(n.gaps)?n.gaps.filter(i=>typeof i=="string"):[]}}static async diagnose(e,t){if(e instanceof Cn)return e;if(t?.aborted)return new Cn("cancelled",e);const{default:n}=await ei(async()=>{const{default:i}=await import("./index-DQDuRMiM.js").then(a=>a.i);return{default:i}},[],import.meta.url);return e instanceof n.AuthenticationError||e instanceof n.PermissionDeniedError?new Cn("credential",e):e instanceof n.RateLimitError?new Cn("rate-limited",e):e instanceof n.BadRequestError||e instanceof n.NotFoundError?new Cn("rejected",e.message,e):e instanceof n.APIConnectionError?new Cn("unreachable",e):new Cn("malformed",e)}}const ws=[{id:"claude",name:"Claude",credit:"Anthropic",creditUrl:"https://www.anthropic.com/legal/consumer-terms",create:()=>new Ca}],e1=[{id:"coverage",name:"Coverage",credit:"UFO@home",creditUrl:"https://ufoathome.org",create:()=>({about:"witness",assess:async s=>{const{CoverageAssessor:e}=await ei(async()=>{const{CoverageAssessor:t}=await import("./CoverageAssessor-FIt771Wz.js");return{CoverageAssessor:t}},[],import.meta.url);return new e().assess(s)}})},{id:"hynek",name:"Hynek",credit:"J. Allen Hynek",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/",create:()=>({about:"temporal",assess:async s=>{const{HynekAssessor:e}=await ei(async()=>{const{HynekAssessor:t}=await import("./HynekAssessor-DUqRa3Su.js");return{HynekAssessor:t}},[],import.meta.url);return new e().assess(s)}})}];class t1{constructor(e){this.labels=e}async read(e){const t=[],n=new Set;for(const i of e1){let a;try{a=await i.create().assess(e)}catch{continue}for(const o of a.criteria)o.basis===void 0&&!o.unsupported&&n.add(o.id);const r=a.score===void 0?a.verdict===void 0?"":this.verdictName(i.id,a.verdict):`${Math.round(a.score*100)}%`;r!==""&&t.push({group:"assessment",field:i.id,label:this.labels.assessmentNames[i.id]??i.name,value:r,unit:"",fromSource:!1,about:i.create().about})}return{entries:t,unanswered:n}}verdictName(e,t){return this.labels.assessmentVerdicts[`${e}.${t}`]??t.toUpperCase()}}class mi{static stated(e){return mi.statedIn(e,[])}static apply(e,t,n){const i=structuredClone(e);for(const a of n){const r=a.split("."),o=mi.read(t,r);o!==void 0&&mi.write(i,r,structuredClone(o))}return i}static statedIn(e,t){const n=[];for(const[i,a]of Object.entries(e)){if(a===void 0)continue;const r=[...t,i];mi.isPlainObject(a)?n.push(...mi.statedIn(a,r)):n.push(r.join("."))}return n}static isPlainObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}static read(e,t){let n=e;for(const i of t){if(!mi.isPlainObject(n))return;n=n[i]}return n}static write(e,t,n){let i=e;for(const a of t.slice(0,-1)){const r=i[a];mi.isPlainObject(r)||(i[a]={}),i=i[a]}i[t[t.length-1]]=n}}class et{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(e){return 2*Math.atan(e.sizeM/(2*e.distanceM))*180/Math.PI}static inMoons(e){return e/et.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,n){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*n,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*n}}static sizeMAt(e,t){return 2*e*Math.tan(t*Math.PI/360)}static distanceMAt(e,t){return e/(2*Math.tan(t*Math.PI/360))}}const Qs=["front","behind","left","right","front-left","front-right","behind-left","behind-right"];function $d(s){return s==="vehicle"?["front","behind","front-left","front-right","behind-left","behind-right"]:["front","behind","left","right"]}function n1(s){return s==="vehicle"?["front-left","front-right","behind-left","behind-right"]:$d(s)}const Mh=90,i1=50;function sm(s){if(!Zd(s))return;const e={};for(const t of $d(s))e[t]=Sh(s,t)?i1:Mh;return e}const Oa=2;function Zd(s){return s==="building"||s==="vehicle"}function Sh(s,e){return s==="building"?!0:s==="vehicle"?e!=="front"&&e!=="behind":!1}function Ra(s){return s==="building"||s==="vehicle"}function Ml(s,e){const t=s.litKeyframes;if(!t||t.length===0)return s.lit??!1;let n=t[0];for(const i of t){if(i.t>e)break;n=i}return n.lit}function s1(s,e){return s.pattern.kind==="steady"?!0:am(s,e,e+1)>.5}function am(s,e,t){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:a=0}=s.pattern,r=Math.min(Math.max(i,0),1);if(r===0||n<=0)return 0;const o=6e4/n,l=e/o+a,c=t/o+a;if(c<=l)return Math.min(Math.max(l-Math.floor(l),0),r)<r?1:0;const h=d=>Math.floor(d)*r+Math.min(d-Math.floor(d),r);return(h(c)-h(l))/(c-l)}function Ya(s,e){const t=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!t||t.length===0)return n;if(t.length===1||e<=t[0].t)return Yu(t[0],s);const i=t[t.length-1];if(e>=i.t)return Yu(i,s);for(let a=0;a<t.length-1;a++){const r=t[a],o=t[a+1];if(e<r.t||e>o.t)continue;const l=o.t-r.t,c=l===0?0:(e-r.t)/l;return{eastM:r.eastM+(o.eastM-r.eastM)*c,northM:r.northM+(o.northM-r.northM)*c,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*c,headingDeg:r.headingDeg??s.headingDeg}}return n}function Yu(s,e){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??e.headingDeg}}const a1={x:et.CANVAS_WIDTH_PX/2,y:et.CANVAS_HEIGHT_PX/2,width:1,height:1};class Sl{static loadable(e){const t=e.decor?{decor:e.decor.map((i,a)=>Sl.decor(i,a))}:{},n=e.timeline?.keyframes;return n?{...e,...t,timeline:{...e.timeline,keyframes:n.map(i=>({t:i.t??0,shapes:(i.shapes??[]).map(a=>({sourceId:a.sourceId,shape:Sl.shape(a.shape)}))}))}}:{...e,...t}}static decor(e,t){const n=e.kind??"vehicle";return{...Zd(n)?{windows:sm(n)}:{},...n==="building"?{floors:Oa}:{},...e,id:e.id??`decor-${t+1}`,kind:n,eastM:e.eastM??0,northM:e.northM??0}}static shape(e){const t=e?.kind==="polygon"?"polygon":"oval";return{...t==="polygon"?{points:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}]}:{},...e,kind:t,bounds:{...a1},color:typeof e?.color=="string"?e.color:"#e8e6df",angle:0,transparency:0,haloScale:0,selected:!1}}}const r1=`
97
97
  <!-- The groups' own handles, gathered onto one wrapping strip instead of standing as seven stacked
98
98
  <summary> rows down the left edge. Seven collapsed rows cost 259px of pure chrome before a
99
99
  single field is shown, which is most of a phone's screen spent on nothing; the same seven
@@ -480,22 +480,32 @@ ${e.ask}`,"Answer by calling draft_recording."),t.join(`
480
480
  <button id="add-shape" type="button" class="icon-btn" title="Add shape" aria-label="Add shape">+</button>
481
481
  <button id="delete-shape" type="button" class="icon-btn" title="Delete shape" aria-label="Delete shape">🗑</button>
482
482
  <label><span id="label-shape-title">Name</span> <input id="shapeTitle" type="text"/></label>
483
- <label><span id="label-object-size">Try a size</span>
484
- <input id="objectSize" type="number" min="0" step="0.1" placeholder="assumed width" title="A real width to try, so the shape's apparent size is computed rather than eyeballed. Not stored."/> m</label>
485
- <label><span id="label-object-distance">at a distance of</span>
486
- <input id="objectDistance" type="number" min="0" step="1" placeholder="assumed distance" title="The distance to try that width at. Not stored either only the resulting angular size is."/> m</label>
487
- <output id="apparent-size" class="apparent-size" for="objectSize objectDistance"></output>
488
- <output id="real-size" class="apparent-size" for="objectSize objectDistance"></output>
489
- <!-- Where the shape is DRAWN along its line of sight — a parameter of the picture and never of
490
- the recording (see PhenomenonDepth): from the witness's eye it looks the same at any
491
- distance, and what changes is what the decor hides of it. Slid rather than typed, because a
492
- hypothesis is tested by watching it fail: drag the craft out to five hundred metres and see
493
- it go behind the patrol car it was drawn in front of. -->
494
- <label><span id="label-distance-hypothesis">Show it at</span>
495
- <input id="distanceHypothesis" type="range" min="0" max="1" step="0.002" value="0" title="How far along its line of sight the shape is drawn — what decides what the decor hides of it. Not stored: a reader's hypothesis, never the witness's statement."/>
496
- <output id="distance-hypothesis-value" class="apparent-size" for="distanceHypothesis"></output>
497
- <button id="clear-distance-hypothesis" type="button" class="icon-btn" title="Back to what the recording establishes" aria-label="Back to what the recording establishes">×</button></label>
498
- <output id="depth-basis" class="apparent-size" for="distanceHypothesis"></output>
483
+ <!-- Three readings of ONE relation, apparent width = f(real width, distance), kept in step.
484
+ Only the apparent width is the recording's (BaseShape.angular); the real width is derived
485
+ from it, and the distance is where the scene DRAWS the shape (see PhenomenonDepth), never a
486
+ statement. Edit any one and one of the other two follows — the held one never moves, and
487
+ with nothing held the real width is what a thing keeps: a distance edit changes how big it
488
+ looks, and a width edit changes the other width at the distance it stands (the shape is
489
+ resized on the canvas, which is what "try a size at a distance" always did). -->
490
+ <label><span id="label-apparent-width">Apparent width</span>
491
+ <input id="apparentWidth" type="number" min="0" step="0.1" title="How wide it looked, in degrees the recording's own statement of size"/>°
492
+ <output id="apparent-size" class="apparent-size inline" for="apparentWidth"></output></label>
493
+ <label><span id="label-real-width">Real width</span>
494
+ <input id="realWidth" type="number" min="0" step="0.1" title="What that angle is in metres at the distance beside it. Derived, never stored"/> m</label>
495
+ <label><span id="label-object-distance">Distance</span>
496
+ <input id="objectDistance" type="number" min="0" step="1" title="How far along its line of sight the shape is drawn — what decides what the decor hides of it. A hypothesis, never the witness's statement"/> m</label>
497
+ <label><span id="label-size-lock">Hold</span>
498
+ <select id="sizeLock" title="Which of the three stays put while another is edited">
499
+ <option id="option-lock-none" value="none">nothing</option>
500
+ <option id="option-lock-apparent" value="apparent">the apparent width</option>
501
+ <option id="option-lock-real" value="real">the real width</option>
502
+ <option id="option-lock-distance" value="distance">the distance</option>
503
+ </select></label>
504
+ <!-- Shown only while a distance of the reader's own is in force — whichever field put it there:
505
+ the distance itself, or the real width with the apparent width held. -->
506
+ <button id="clear-distance-hypothesis" type="button" title="Back to what the recording establishes">Withdraw the distance hypothesis</button>
507
+ <output id="real-size" class="apparent-size" for="realWidth"></output>
508
+ <output id="depth-basis" class="apparent-size" for="objectDistance"></output>
499
509
  <!-- The depth of field, read backwards. The scene blurs the WORLD from its distance and leaves
500
510
  the witness's object alone, because that distance is the unknown; a blur the witness
501
511
  STATED runs the geometry the other way and bounds it. See DepthOfField's own doc comment,
@@ -680,14 +690,14 @@ input.invalid {
680
690
  #apparent-size {
681
691
  white-space: nowrap;
682
692
  }
683
- /* Inside its label beside the slider, not a flex item: reserved wide enough for "20 000 m" so the
684
- slider does not slide sideways as the number under it changes length. */
685
- #distance-hypothesis-value {
686
- display: inline-block;
687
- min-width: 6.5ch;
693
+ /* A readout inside a label, after its field, is not a flex item and takes no line of its own. */
694
+ .apparent-size.inline {
695
+ display: inline;
688
696
  flex-basis: auto;
689
697
  min-height: 0;
698
+ margin-left: 0.4em;
690
699
  }
700
+
691
701
  /* Record and the sampling rate it records at are one control, not two: grouping them makes them a
692
702
  single flex item of the wrapping toolbar, so they stay on the same line together wherever that
693
703
  line happens to break, instead of the button drifting up next to whatever field precedes it.
@@ -1343,7 +1353,7 @@ select.weather-field:disabled {
1343
1353
  .submenu label:hover {
1344
1354
  background: #eef;
1345
1355
  }
1346
- `;function l1(s,e,t){if(!s||!e)return t<1?s:e;const n=((e.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*t)%360+360)%360,altitudeDeg:s.altitudeDeg+(e.altitudeDeg-s.altitudeDeg)*t}}function c1(s,e="#39ff14"){return{kind:"oval",bounds:s,color:e,angle:0,transparency:0,haloScale:0,selected:!1}}function h1(s,e,t="#39ff14"){return{kind:"polygon",bounds:s,points:e,color:t,angle:0,transparency:0,haloScale:0,selected:!1}}function d1(s,e="#39ff14"){const{width:t,height:n}=s;return h1(s,[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],e)}const u1={oval:c1,polygon:d1};function Ku(s,e){return{...u1[e.presetId](s,e.color),transparency:e.transparency,haloScale:e.haloScale,blur:e.blur,brightness:e.brightness}}function f1(s,e,t){const{bounds:n}=s;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function rm(s,e,t){const n=s.bounds.width,i=s.bounds.height;return{...s,bounds:{x:e-n/2,y:t-i/2,width:n,height:i}}}function Sn(s,e,t){return s+(e-s)*t}function $u(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function p1(s){return`#${s.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function m1(s,e,t){const n=$u(s),i=$u(e);return!n||!i?t<1?s:e:p1([Sn(n[0],i[0],t),Sn(n[1],i[1],t),Sn(n[2],i[2],t)])}function g1(s,e,t){const n={x:Sn(s.bounds.x,e.bounds.x,t),y:Sn(s.bounds.y,e.bounds.y,t),width:Sn(s.bounds.width,e.bounds.width,t),height:Sn(s.bounds.height,e.bounds.height,t)},i=Sn(s.angle,e.angle,t),a=Sn(s.transparency,e.transparency,t),r=Sn(s.haloScale,e.haloScale,t),o=Sn(s.blur??0,e.blur??0,t),l=Sn(s.brightness??0,e.brightness??0,t),c=m1(s.color,e.color,t),h=ht.lerpAngular(s.angular,e.angular,t),d=l1(s.aim,e.aim,t);return s.kind==="polygon"&&e.kind==="polygon"&&s.points.length===e.points.length?{...s,bounds:n,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:c,angular:h,aim:d,behindCloud:t<1?s.behindCloud:e.behindCloud,points:s.points.map((u,f)=>({x:Sn(u.x,e.points[f].x,t),y:Sn(u.y,e.points[f].y,t)}))}:{...t<1?s:e,bounds:n,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:c,angular:h,aim:d}}class Wl{keyframes=[];order=[];groups=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const i=new Set(t.map(a=>a.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(a=>!i.has(a.sourceId)),...t]}}else this.keyframes.splice(n,0,{t:e,shapes:[...t]});for(const i of t)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t];return n?.t===e?n:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(n=>n.sourceId===t)?.shape}getLatestShapeAt(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return i.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const i=this.findShapeAtOrAfter(e,t);return n?i?g1(n.shape,i.shape,(e-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(e,t,n,i){const a=this.sourceIds;for(let r=a.length-1;r>=0;r--){if(i?.has(a[r]))continue;const o=this.getInterpolatedShapeAt(e,a[r]);if(o&&f1(o,t,n))return{sourceId:a[r],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const n=this.keyframes[t].shapes.filter(i=>i.sourceId!==e);n.length===0?this.keyframes.splice(t,1):n.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:n})}this.order=this.order.filter(t=>t!==e),this.removeFromGroup(e)}group(e){if(!(e.length<2)){for(const t of e)this.removeFromGroup(t);this.groups.push([...e])}}ungroup(e){const t=this.groups.findIndex(n=>n.includes(e));t!==-1&&this.groups.splice(t,1)}groupMembers(e){return this.groups.find(t=>t.includes(e))}removeFromGroup(e){const t=this.groups.findIndex(i=>i.includes(e));if(t===-1)return;const n=this.groups[t].filter(i=>i!==e);n.length<2?this.groups.splice(t,1):this.groups[t]=n}bringToFront(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.push(e))}sendToBack(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.unshift(e))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(e){const t=new Wl;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);if(e.order){const n=t.order.filter(i=>!e.order.includes(i));t.order=[...e.order,...n]}return e.groups&&(t.groups=e.groups.map(n=>n.filter(i=>t.order.includes(i))).filter(n=>n.length>=2)),t}}function v1(s,e,t){return Math.max(e,Math.min(t,s))}function y1(s,e,t){const n=((e-s)%360+540)%360-180;return((s+n*t)%360+360)%360}function ea(s,e,t){return s+(e-s)*t}function b1(s,e,t){return{lat:s.lat===void 0||e.lat===void 0?void 0:ea(s.lat,e.lat,t),lng:s.lng===void 0||e.lng===void 0?void 0:ea(s.lng,e.lng,t),elevationM:ea(s.elevationM,e.elevationM,t),headingDeg:s.headingDeg===void 0||e.headingDeg===void 0?void 0:y1(s.headingDeg,e.headingDeg,t),pitchDeg:ea(s.pitchDeg,e.pitchDeg,t),rollDeg:ea(s.rollDeg??0,e.rollDeg??0,t),fovDeg:ea(s.fovDeg,e.fovDeg,t),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class Hr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,pose:t}:this.keyframes.splice(n,0,{t:e,pose:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getLatestPoseAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].pose:void 0}getInterpolatedPoseAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.pose;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?i?b1(n.pose,i.pose,v1((e-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Hr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function es(s,e,t){return s+(e-s)*t}function x1(s,e,t){const n=((e-s)%360+540)%360-180;return((s+n*t)%360+360)%360}function w1(s,e,t){return Math.max(e,Math.min(t,s))}function M1(s,e,t){return{cloudCover:es(s.cloudCover,e.cloudCover,t),cloudDarkness:es(s.cloudDarkness,e.cloudDarkness,t),highCloudCover:s.highCloudCover===void 0||e.highCloudCover===void 0?void 0:es(s.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:s.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:es(s.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:s.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:es(s.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:s.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:es(s.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?s.precipitationType:e.precipitationType,precipitationIntensity:es(s.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:x1(s.windDirectionDeg,e.windDirectionDeg,t),windSpeed:es(s.windSpeed,e.windSpeed,t),storm:t<1?s.storm:e.storm}}class Gr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,weather:t}:this.keyframes.splice(n,0,{t:e,weather:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getLatestWeatherAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].weather:void 0}getInterpolatedWeatherAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.weather;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?i?M1(n.weather,i.weather,w1((e-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Gr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class Vr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,sound:t}:this.keyframes.splice(n,0,{t:e,sound:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}getLatestSoundAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].sound:void 0}getInterpolatedSoundAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.sound;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!n)return i?.sound;if(!i)return n.sound;const a=(e-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,a)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Vr;for(const n of e.keyframes)t.addKeyframe(n.t,n.sound);return t}lerp(e,t,n){return{kind:n<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*n,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*n,src:n<1?e.src:t.src}}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}}const om=1e3,_h=.65,lm={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},S1=["none","hum","whistle","rumble","crackle"],_1=100,E1={kind:"none",volume:0,pitchHz:_1},lo=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class it{static get default(){return lo[0]}static byId(e){return lo.find(t=>t.id===e)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(e){const t=e.frame;return t?2*Math.atan(t.heightMm/(2*t.focalLengthMm))*180/Math.PI:it.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:it.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*it.aspectOf(e))}static availableAt(e){return e===void 0?lo:lo.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const n=e.frame;if(!(!n||t<=0))return 2*Math.atan(n.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const n=e.frame;if(!(!n||t<=0||t>=180))return n.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const n=t??e.fNumber;if(n===void 0||e.apertureBlades===void 0)return 0;const i=e.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??it.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}const T1=/^(?:(?<year>\d{4}|\d{3}X|\d{2}XX)(-(?<month>0[1-9]|1[0-2]))?(-(?<day>0[1-9]|[12]\d|3[01]))?(?:[T ](?<hour>[01]?\d|2[0-3]):(?<minute>[0-5]\d)(?::(?<second>[0-5]\d))?)?|(?<timeOnlyHour>[01]?\d|2[0-3]):(?<timeOnlyMinute>[0-5]\d)(?::(?<timeOnlySecond>[0-5]\d))?)[?~%]?$/;function Zu(s){const e=T1.exec(s.trim());if(!e?.groups)return;const{year:t,month:n,day:i,hour:a,minute:r,second:o,timeOnlyHour:l,timeOnlyMinute:c,timeOnlySecond:h}=e.groups,d=a??l,u=r??c,f=o??h;return{year:t&&!t.includes("X")?Number(t):void 0,month:n?Number(n):void 0,day:i?Number(i):void 0,hour:d?Number(d):void 0,minute:u?Number(u):void 0,second:f?Number(f):void 0,raw:s.trim()}}function _l(s){if(s.raw!==void 0)return s.raw;if(s.year===void 0){if(s.hour===void 0)return"";let t=`${String(s.hour).padStart(2,"0")}:${String(s.minute??0).padStart(2,"0")}`;return s.second!==void 0&&(t+=`:${String(s.second).padStart(2,"0")}`),t}let e=String(s.year).padStart(4,"0");return s.month===void 0||(e+=`-${String(s.month).padStart(2,"0")}`,s.day===void 0)||(e+=`-${String(s.day).padStart(2,"0")}`,s.hour===void 0)||(e+=`T${String(s.hour).padStart(2,"0")}:${String(s.minute??0).padStart(2,"0")}`,s.second!==void 0&&(e+=`:${String(s.second).padStart(2,"0")}`)),e}function Eh(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Ju(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const A1=["year","month","day","hour","minute"],I1=["day","hour","minute"];function ju(s,e){return e.filter(t=>s[t]!==void 0).join(",")}function Ka(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const e=s.time.year!==void 0&&s.endTime.year!==void 0,t=e?A1:I1,n=ju(s.time,t);if(!(n===""||n!==ju(s.endTime,t)))return e?Eh(s.endTime)-Eh(s.time):Ju(s.endTime)-Ju(s.time)}function D1(s){if(s.durationSeconds===void 0&&!(!s.time||!s.endTime))return Ka(s)===void 0?"imprecise":void 0}class Xl{constructor(e,t,n,i,a,r,o,l,c=[],h,d,u,f=[]){this.event=e,this.timeline=t,this.witnessTrack=n,this.weatherTrack=i,this.soundTrack=a,this.witness=r,this.caseId=o,this.weather=l,this.decor=c,this.weatherSource=h,this.instrumentId=d,this.exposureSeconds=u,this.milestones=f}provenance=Pn.empty();testimony;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return it.byId(this.instrumentId)}static create(e,t,n){return new Xl({eventType:"sighting",time:e,place:t},new Wl,new Hr,new Gr,new Vr,n)}}const C1=0,R1=0;function xt(s,e){const t=s.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:C1,headingDeg:void 0,pitchDeg:R1,fovDeg:it.fieldOfViewDeg(s.instrument)}}function Fs(s,e){return s.weatherTrack.getInterpolatedWeatherAt(e)??s.weather??lm}function Jd(s,e){return s.soundTrack.getInterpolatedSoundAt(e)??E1}const Qu="#ff2200",ef="#00ff44",Ms="#ffffff",co="#ffa500",ta="#ff0000",P1="#2244ff",Th=[{id:"airliner",name:"Airliner",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Qu,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:ef,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Ms,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Ms,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Ms,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Qu,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:ef,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Ms,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Ms,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Ms,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Ms,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:ta,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:ta,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:P1,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:ta,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class sc{static forKind(e){return Th.filter(t=>t.kinds.includes(e))}static byId(e){return Th.find(t=>t.id===e)}}class Ah{constructor(e){this.names=e}name(e){return this.names[e.toLowerCase()]??e}stored(e){const t=e.trim().toLowerCase();for(const[n,i]of Object.entries(this.names))if(i.toLowerCase()===t)return n;return e.trim()}}class tf{constructor(e,t,n,i=new Ah({})){this.labels=e,this.language=t,this.said=n,this.tags=i}entriesFor(e,t,n={}){const i=[];return this.addObservation(i,e),this.addWitness(i,e,t),this.addLocation(i,e,t,n.groundElevationM),this.addDecor(i,e,t,n),this.addTemporal(i,e),this.addWeather(i,e,t),this.addSound(i,e,t),i}push(e,t,n,i,a,r="",o={}){a===void 0||a===""||e.push({group:t,field:n,label:i,value:String(a),unit:r,color:o.color,fromSource:o.fromSource===!0})}percent(e){return e===void 0?void 0:`${Math.round(e*100)} %`}rounded(e,t=0){return e===void 0?void 0:String(Number(e.toFixed(t)))}shows(e,t=0){return e!==void 0&&Number(e.toFixed(t))!==0}showsPercent(e){return this.shows(e===void 0?void 0:e*100)}percentShown(e){return this.showsPercent(e)?this.percent(e):void 0}roundedShown(e,t=0){return this.shows(e,t)?this.rounded(e,t):void 0}addObservation(e,t){this.push(e,"observation","caseId",this.labels.caseId,t.caseId);const n=t.event.tags;this.push(e,"observation","tags",this.labels.tags,n&&n.length>0?n.map(i=>this.tags.name(i)).join(", "):void 0)}addWitness(e,t,n){const i=t.witness;this.push(e,"witness","witnessId",this.labels.witnessId,i?.id),this.push(e,"witness","witnessTitle",this.labels.witnessTitle,i?.title),this.push(e,"witness","witnessLastName",this.labels.witnessLastName,i?.lastName);const a=i?.firstNames;this.push(e,"witness","witnessFirstNames",this.labels.witnessFirstNames,a&&a.length>0?a.join(", "):void 0);const r=t.instrument;this.push(e,"witness","instrument",this.labels.instrument,r.name[this.language]);const o=t.exposure;this.push(e,"witness","exposureSeconds",this.labels.exposure,o===void 0?void 0:o<1?`1/${Math.round(1/o)}`:this.rounded(o,2),"s");const l=xt(t,n);if(l){const c=it.focalLengthMmFor(r,l.fovDeg);c===void 0?this.push(e,"witness","focalLength",this.labels.fieldOfView,this.rounded(l.fovDeg,1),"°"):this.push(e,"witness","focalLength",this.labels.focalLength,this.rounded(c,1),"mm"),this.push(e,"witness","fNumber",this.labels.aperture,this.rounded(l.fNumber??r.fNumber,1)),this.push(e,"witness","focusDistance",this.labels.focusDistance,this.rounded(l.focusDistanceM,1),"m"),this.push(e,"witness","roll",this.labels.roll,this.roundedShown(l.rollDeg),"°")}}addLocation(e,t,n,i){const a=t.event.place?.[0];this.push(e,"location","placeName",this.labels.placeName,a?.name);const r=xt(t,n);r&&(this.push(e,"location","lat",this.labels.latitude,this.rounded(r.lat,6)),this.push(e,"location","lng",this.labels.longitude,this.rounded(r.lng,6)),this.push(e,"location","heading",this.labels.heading,this.rounded(r.headingDeg),"°"),this.push(e,"location","pitch",this.labels.pitch,this.rounded(r.pitchDeg),"°"),i===void 0?this.push(e,"location","elevation",this.labels.heightAboveGround,this.roundedShown(r.elevationM),"m"):this.push(e,"location","elevation",this.labels.elevation,this.rounded(i+r.elevationM),"m"))}addDecor(e,t,n,i){const a=t.decor.find(c=>c.id===i.decorId);if(!a){if(i.decorPicker===!0)for(const c of t.decor)this.push(e,"decor",`decor:${c.id}`,this.decorLabel(c),this.decorKindName(c.kind));return}this.push(e,"decor","decorTitle",this.labels.decorTitle,this.said.read(a.title));const r=Ya(a,n);this.push(e,"decor","decorEast",this.labels.decorEast,this.rounded(r.eastM,1),"m"),this.push(e,"decor","decorNorth",this.labels.decorNorth,this.rounded(r.northM,1),"m"),this.push(e,"decor","decorAltitude",this.labels.decorAltitude,this.roundedShown(r.altitudeM),"m"),this.push(e,"decor","decorHeading",this.labels.decorHeading,this.rounded(r.headingDeg),"°"),Ml(a,n)&&this.push(e,"decor","decorLit",this.labels.decorLit,"✓");const o=a.lights?.map(c=>c.id).join()??"",l=o===""?void 0:Th.find(c=>c.create().map(h=>h.id).join()===o);this.push(e,"decor","decorLightRig",this.labels.decorLights,l?.name),this.push(e,"decor","decorFloors",this.labels.decorFloors,a.floors),this.push(e,"decor","decorOccupiedFloor",this.labels.decorOccupiedFloor,a.occupiedFloor),this.push(e,"decor","decorWitnessSide",this.labels.decorWitnessSide,this.decorSideName(a.witnessSide));for(const[c,h]of Object.entries(a.windows??{}))this.push(e,"decor",`decorWindow${this.capitalise(c)}`,`${this.labels.decorWindows} ${this.decorSideName(c)}`,h,"%")}addTemporal(e,t){const n=t.event;this.push(e,"temporal","obs-time",this.labels.observationTime,n.time&&_l(n.time)),this.push(e,"temporal","obs-end-time",this.labels.observationEndTime,n.endTime&&_l(n.endTime));const i=Ka(n);this.push(e,"temporal","durationSeconds",this.labels.duration,this.roundedShown(i&&i/1e3,1),"s"),this.push(e,"temporal","timeZone",this.labels.utcOffset,n.timeZone),this.push(e,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(n.utcOffsetHours,1),"UTC±h")}addWeather(e,t,n){const i=Fs(t,n),r={fromSource:t.weatherSource!==void 0},o=this.showsPercent(i.cloudCover)||this.showsPercent(i.lowerCloudCover)||this.showsPercent(i.highCloudCover);this.push(e,"weather","cloudCover",this.labels.cloudCover,this.percentShown(i.cloudCover),"",r),this.push(e,"weather","highCloudCover",this.labels.highCloudCover,this.percentShown(i.highCloudCover),"",r),this.push(e,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.showsPercent(i.highCloudCover)?this.percent(i.iceCrystalAlignment):void 0),this.push(e,"weather","cloudDarkness",this.labels.cloudDarkness,o?this.percent(i.cloudDarkness):void 0,"",r),this.push(e,"weather","cloudBase",this.labels.cloudBase,o?this.rounded(i.cloudBaseM):void 0,"m",r);const l=i.precipitationType!=="none"&&this.showsPercent(i.precipitationIntensity);this.push(e,"weather","precipitationType",this.labels.precipitationType,l?this.precipitationName(i.precipitationType):void 0,"",r),this.push(e,"weather","precipitationIntensity",this.labels.precipitationIntensity,l?this.percent(i.precipitationIntensity):void 0,"",r),this.push(e,"weather","windDirection",this.labels.windDirection,this.shows(i.windSpeed,2)?this.rounded(i.windDirectionDeg):void 0,"°",r),this.push(e,"weather","windSpeed",this.labels.windSpeed,this.roundedShown(i.windSpeed,2),"m/s",r),i.storm&&this.push(e,"weather","storm",this.labels.storm,"✓","",r)}addSound(e,t,n){const i=Jd(t,n);i.kind!=="none"&&(this.push(e,"sound","soundKind",this.labels.soundKind,this.soundKindName(i.kind)),this.push(e,"sound","soundVolume",this.labels.soundVolume,this.percentShown(i.volume)),this.push(e,"sound","soundPitch",this.labels.soundPitch,this.roundedShown(i.pitchHz),"Hz"),this.push(e,"sound","soundSrc",this.labels.soundSrc,i.src))}decorLabel(e){return this.said.read(e.title)??this.decorKindName(e.kind)}decorKindName(e){switch(e){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"crop":return this.labels.decorCrop;case"mound":return this.labels.decorMound;case"streetlight":return this.labels.decorStreetlight;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorWitness}}decorSideName(e){switch(e){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(e){switch(e){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(e){switch(e){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}capitalise(e){return e.replace(/(^|-)([a-z])/g,(t,n,i)=>i.toUpperCase())}}const L1=`
1356
+ `;function l1(s,e,t){if(!s||!e)return t<1?s:e;const n=((e.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*t)%360+360)%360,altitudeDeg:s.altitudeDeg+(e.altitudeDeg-s.altitudeDeg)*t}}function c1(s,e="#39ff14"){return{kind:"oval",bounds:s,color:e,angle:0,transparency:0,haloScale:0,selected:!1}}function h1(s,e,t="#39ff14"){return{kind:"polygon",bounds:s,points:e,color:t,angle:0,transparency:0,haloScale:0,selected:!1}}function d1(s,e="#39ff14"){const{width:t,height:n}=s;return h1(s,[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}],e)}const u1={oval:c1,polygon:d1};function Ku(s,e){return{...u1[e.presetId](s,e.color),transparency:e.transparency,haloScale:e.haloScale,blur:e.blur,brightness:e.brightness}}function f1(s,e,t){const{bounds:n}=s;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function rm(s,e,t){const n=s.bounds.width,i=s.bounds.height;return{...s,bounds:{x:e-n/2,y:t-i/2,width:n,height:i}}}function _n(s,e,t){return s+(e-s)*t}function $u(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function p1(s){return`#${s.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function m1(s,e,t){const n=$u(s),i=$u(e);return!n||!i?t<1?s:e:p1([_n(n[0],i[0],t),_n(n[1],i[1],t),_n(n[2],i[2],t)])}function g1(s,e,t){const n={x:_n(s.bounds.x,e.bounds.x,t),y:_n(s.bounds.y,e.bounds.y,t),width:_n(s.bounds.width,e.bounds.width,t),height:_n(s.bounds.height,e.bounds.height,t)},i=_n(s.angle,e.angle,t),a=_n(s.transparency,e.transparency,t),r=_n(s.haloScale,e.haloScale,t),o=_n(s.blur??0,e.blur??0,t),l=_n(s.brightness??0,e.brightness??0,t),c=m1(s.color,e.color,t),h=et.lerpAngular(s.angular,e.angular,t),d=l1(s.aim,e.aim,t);return s.kind==="polygon"&&e.kind==="polygon"&&s.points.length===e.points.length?{...s,bounds:n,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:c,angular:h,aim:d,behindCloud:t<1?s.behindCloud:e.behindCloud,points:s.points.map((u,f)=>({x:_n(u.x,e.points[f].x,t),y:_n(u.y,e.points[f].y,t)}))}:{...t<1?s:e,bounds:n,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:c,angular:h,aim:d}}class Wl{keyframes=[];order=[];groups=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const i=new Set(t.map(a=>a.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(a=>!i.has(a.sourceId)),...t]}}else this.keyframes.splice(n,0,{t:e,shapes:[...t]});for(const i of t)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t];return n?.t===e?n:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(n=>n.sourceId===t)?.shape}getLatestShapeAt(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return i.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const i=this.findShapeAtOrAfter(e,t);return n?i?g1(n.shape,i.shape,(e-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(a=>a.sourceId===t);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(e,t,n,i){const a=this.sourceIds;for(let r=a.length-1;r>=0;r--){if(i?.has(a[r]))continue;const o=this.getInterpolatedShapeAt(e,a[r]);if(o&&f1(o,t,n))return{sourceId:a[r],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const n=this.keyframes[t].shapes.filter(i=>i.sourceId!==e);n.length===0?this.keyframes.splice(t,1):n.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:n})}this.order=this.order.filter(t=>t!==e),this.removeFromGroup(e)}group(e){if(!(e.length<2)){for(const t of e)this.removeFromGroup(t);this.groups.push([...e])}}ungroup(e){const t=this.groups.findIndex(n=>n.includes(e));t!==-1&&this.groups.splice(t,1)}groupMembers(e){return this.groups.find(t=>t.includes(e))}removeFromGroup(e){const t=this.groups.findIndex(i=>i.includes(e));if(t===-1)return;const n=this.groups[t].filter(i=>i!==e);n.length<2?this.groups.splice(t,1):this.groups[t]=n}bringToFront(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.push(e))}sendToBack(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.unshift(e))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(e){const t=new Wl;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);if(e.order){const n=t.order.filter(i=>!e.order.includes(i));t.order=[...e.order,...n]}return e.groups&&(t.groups=e.groups.map(n=>n.filter(i=>t.order.includes(i))).filter(n=>n.length>=2)),t}}function v1(s,e,t){return Math.max(e,Math.min(t,s))}function y1(s,e,t){const n=((e-s)%360+540)%360-180;return((s+n*t)%360+360)%360}function ea(s,e,t){return s+(e-s)*t}function b1(s,e,t){return{lat:s.lat===void 0||e.lat===void 0?void 0:ea(s.lat,e.lat,t),lng:s.lng===void 0||e.lng===void 0?void 0:ea(s.lng,e.lng,t),elevationM:ea(s.elevationM,e.elevationM,t),headingDeg:s.headingDeg===void 0||e.headingDeg===void 0?void 0:y1(s.headingDeg,e.headingDeg,t),pitchDeg:ea(s.pitchDeg,e.pitchDeg,t),rollDeg:ea(s.rollDeg??0,e.rollDeg??0,t),fovDeg:ea(s.fovDeg,e.fovDeg,t),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class Hr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,pose:t}:this.keyframes.splice(n,0,{t:e,pose:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getLatestPoseAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].pose:void 0}getInterpolatedPoseAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.pose;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?i?b1(n.pose,i.pose,v1((e-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Hr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function es(s,e,t){return s+(e-s)*t}function x1(s,e,t){const n=((e-s)%360+540)%360-180;return((s+n*t)%360+360)%360}function w1(s,e,t){return Math.max(e,Math.min(t,s))}function M1(s,e,t){return{cloudCover:es(s.cloudCover,e.cloudCover,t),cloudDarkness:es(s.cloudDarkness,e.cloudDarkness,t),highCloudCover:s.highCloudCover===void 0||e.highCloudCover===void 0?void 0:es(s.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:s.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:es(s.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:s.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:es(s.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:s.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:es(s.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?s.precipitationType:e.precipitationType,precipitationIntensity:es(s.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:x1(s.windDirectionDeg,e.windDirectionDeg,t),windSpeed:es(s.windSpeed,e.windSpeed,t),storm:t<1?s.storm:e.storm}}class Gr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,weather:t}:this.keyframes.splice(n,0,{t:e,weather:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}getLatestWeatherAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].weather:void 0}getInterpolatedWeatherAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.weather;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?i?M1(n.weather,i.weather,w1((e-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Gr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class Vr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,sound:t}:this.keyframes.splice(n,0,{t:e,sound:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}getLatestSoundAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].sound:void 0}getInterpolatedSoundAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.sound;const i=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!n)return i?.sound;if(!i)return n.sound;const a=(e-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,a)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Vr;for(const n of e.keyframes)t.addKeyframe(n.t,n.sound);return t}lerp(e,t,n){return{kind:n<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*n,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*n,src:n<1?e.src:t.src}}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const i=t+n>>>1;this.keyframes[i].t<e?t=i+1:n=i}return t}}const om=1e3,_h=.65,lm={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},S1=["none","hum","whistle","rumble","crackle"],_1=100,E1={kind:"none",volume:0,pitchHz:_1},lo=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class st{static get default(){return lo[0]}static byId(e){return lo.find(t=>t.id===e)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(e){const t=e.frame;return t?2*Math.atan(t.heightMm/(2*t.focalLengthMm))*180/Math.PI:st.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:st.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*st.aspectOf(e))}static availableAt(e){return e===void 0?lo:lo.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const n=e.frame;if(!(!n||t<=0))return 2*Math.atan(n.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const n=e.frame;if(!(!n||t<=0||t>=180))return n.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const n=t??e.fNumber;if(n===void 0||e.apertureBlades===void 0)return 0;const i=e.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??st.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}const T1=/^(?:(?<year>\d{4}|\d{3}X|\d{2}XX)(-(?<month>0[1-9]|1[0-2]))?(-(?<day>0[1-9]|[12]\d|3[01]))?(?:[T ](?<hour>[01]?\d|2[0-3]):(?<minute>[0-5]\d)(?::(?<second>[0-5]\d))?)?|(?<timeOnlyHour>[01]?\d|2[0-3]):(?<timeOnlyMinute>[0-5]\d)(?::(?<timeOnlySecond>[0-5]\d))?)[?~%]?$/;function Zu(s){const e=T1.exec(s.trim());if(!e?.groups)return;const{year:t,month:n,day:i,hour:a,minute:r,second:o,timeOnlyHour:l,timeOnlyMinute:c,timeOnlySecond:h}=e.groups,d=a??l,u=r??c,f=o??h;return{year:t&&!t.includes("X")?Number(t):void 0,month:n?Number(n):void 0,day:i?Number(i):void 0,hour:d?Number(d):void 0,minute:u?Number(u):void 0,second:f?Number(f):void 0,raw:s.trim()}}function _l(s){if(s.raw!==void 0)return s.raw;if(s.year===void 0){if(s.hour===void 0)return"";let t=`${String(s.hour).padStart(2,"0")}:${String(s.minute??0).padStart(2,"0")}`;return s.second!==void 0&&(t+=`:${String(s.second).padStart(2,"0")}`),t}let e=String(s.year).padStart(4,"0");return s.month===void 0||(e+=`-${String(s.month).padStart(2,"0")}`,s.day===void 0)||(e+=`-${String(s.day).padStart(2,"0")}`,s.hour===void 0)||(e+=`T${String(s.hour).padStart(2,"0")}:${String(s.minute??0).padStart(2,"0")}`,s.second!==void 0&&(e+=`:${String(s.second).padStart(2,"0")}`)),e}function Eh(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Ju(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const A1=["year","month","day","hour","minute"],I1=["day","hour","minute"];function ju(s,e){return e.filter(t=>s[t]!==void 0).join(",")}function Ka(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const e=s.time.year!==void 0&&s.endTime.year!==void 0,t=e?A1:I1,n=ju(s.time,t);if(!(n===""||n!==ju(s.endTime,t)))return e?Eh(s.endTime)-Eh(s.time):Ju(s.endTime)-Ju(s.time)}function D1(s){if(s.durationSeconds===void 0&&!(!s.time||!s.endTime))return Ka(s)===void 0?"imprecise":void 0}class Xl{constructor(e,t,n,i,a,r,o,l,c=[],h,d,u,f=[]){this.event=e,this.timeline=t,this.witnessTrack=n,this.weatherTrack=i,this.soundTrack=a,this.witness=r,this.caseId=o,this.weather=l,this.decor=c,this.weatherSource=h,this.instrumentId=d,this.exposureSeconds=u,this.milestones=f}provenance=Pn.empty();testimony;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return st.byId(this.instrumentId)}static create(e,t,n){return new Xl({eventType:"sighting",time:e,place:t},new Wl,new Hr,new Gr,new Vr,n)}}const C1=0,R1=0;function bt(s,e){const t=s.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:C1,headingDeg:void 0,pitchDeg:R1,fovDeg:st.fieldOfViewDeg(s.instrument)}}function Fs(s,e){return s.weatherTrack.getInterpolatedWeatherAt(e)??s.weather??lm}function Jd(s,e){return s.soundTrack.getInterpolatedSoundAt(e)??E1}const Qu="#ff2200",ef="#00ff44",Ms="#ffffff",co="#ffa500",ta="#ff0000",P1="#2244ff",Th=[{id:"airliner",name:"Airliner",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Qu,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:ef,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Ms,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Ms,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Ms,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Qu,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:ef,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Ms,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:ta,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Ms,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Ms,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Ms,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:ta,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:ta,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:co,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:P1,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:ta,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class sc{static forKind(e){return Th.filter(t=>t.kinds.includes(e))}static byId(e){return Th.find(t=>t.id===e)}}class Ah{constructor(e){this.names=e}name(e){return this.names[e.toLowerCase()]??e}stored(e){const t=e.trim().toLowerCase();for(const[n,i]of Object.entries(this.names))if(i.toLowerCase()===t)return n;return e.trim()}}class tf{constructor(e,t,n,i=new Ah({})){this.labels=e,this.language=t,this.said=n,this.tags=i}entriesFor(e,t,n={}){const i=[];return this.addObservation(i,e),this.addWitness(i,e,t),this.addLocation(i,e,t,n.groundElevationM),this.addDecor(i,e,t,n),this.addTemporal(i,e),this.addWeather(i,e,t),this.addSound(i,e,t),i}push(e,t,n,i,a,r="",o={}){a===void 0||a===""||e.push({group:t,field:n,label:i,value:String(a),unit:r,color:o.color,fromSource:o.fromSource===!0})}percent(e){return e===void 0?void 0:`${Math.round(e*100)} %`}rounded(e,t=0){return e===void 0?void 0:String(Number(e.toFixed(t)))}shows(e,t=0){return e!==void 0&&Number(e.toFixed(t))!==0}showsPercent(e){return this.shows(e===void 0?void 0:e*100)}percentShown(e){return this.showsPercent(e)?this.percent(e):void 0}roundedShown(e,t=0){return this.shows(e,t)?this.rounded(e,t):void 0}addObservation(e,t){this.push(e,"observation","caseId",this.labels.caseId,t.caseId);const n=t.event.tags;this.push(e,"observation","tags",this.labels.tags,n&&n.length>0?n.map(i=>this.tags.name(i)).join(", "):void 0)}addWitness(e,t,n){const i=t.witness;this.push(e,"witness","witnessId",this.labels.witnessId,i?.id),this.push(e,"witness","witnessTitle",this.labels.witnessTitle,i?.title),this.push(e,"witness","witnessLastName",this.labels.witnessLastName,i?.lastName);const a=i?.firstNames;this.push(e,"witness","witnessFirstNames",this.labels.witnessFirstNames,a&&a.length>0?a.join(", "):void 0);const r=t.instrument;this.push(e,"witness","instrument",this.labels.instrument,r.name[this.language]);const o=t.exposure;this.push(e,"witness","exposureSeconds",this.labels.exposure,o===void 0?void 0:o<1?`1/${Math.round(1/o)}`:this.rounded(o,2),"s");const l=bt(t,n);if(l){const c=st.focalLengthMmFor(r,l.fovDeg);c===void 0?this.push(e,"witness","focalLength",this.labels.fieldOfView,this.rounded(l.fovDeg,1),"°"):this.push(e,"witness","focalLength",this.labels.focalLength,this.rounded(c,1),"mm"),this.push(e,"witness","fNumber",this.labels.aperture,this.rounded(l.fNumber??r.fNumber,1)),this.push(e,"witness","focusDistance",this.labels.focusDistance,this.rounded(l.focusDistanceM,1),"m"),this.push(e,"witness","roll",this.labels.roll,this.roundedShown(l.rollDeg),"°")}}addLocation(e,t,n,i){const a=t.event.place?.[0];this.push(e,"location","placeName",this.labels.placeName,a?.name);const r=bt(t,n);r&&(this.push(e,"location","lat",this.labels.latitude,this.rounded(r.lat,6)),this.push(e,"location","lng",this.labels.longitude,this.rounded(r.lng,6)),this.push(e,"location","heading",this.labels.heading,this.rounded(r.headingDeg),"°"),this.push(e,"location","pitch",this.labels.pitch,this.rounded(r.pitchDeg),"°"),i===void 0?this.push(e,"location","elevation",this.labels.heightAboveGround,this.roundedShown(r.elevationM),"m"):this.push(e,"location","elevation",this.labels.elevation,this.rounded(i+r.elevationM),"m"))}addDecor(e,t,n,i){const a=t.decor.find(c=>c.id===i.decorId);if(!a){if(i.decorPicker===!0)for(const c of t.decor)this.push(e,"decor",`decor:${c.id}`,this.decorLabel(c),this.decorKindName(c.kind));return}this.push(e,"decor","decorTitle",this.labels.decorTitle,this.said.read(a.title));const r=Ya(a,n);this.push(e,"decor","decorEast",this.labels.decorEast,this.rounded(r.eastM,1),"m"),this.push(e,"decor","decorNorth",this.labels.decorNorth,this.rounded(r.northM,1),"m"),this.push(e,"decor","decorAltitude",this.labels.decorAltitude,this.roundedShown(r.altitudeM),"m"),this.push(e,"decor","decorHeading",this.labels.decorHeading,this.rounded(r.headingDeg),"°"),Ml(a,n)&&this.push(e,"decor","decorLit",this.labels.decorLit,"✓");const o=a.lights?.map(c=>c.id).join()??"",l=o===""?void 0:Th.find(c=>c.create().map(h=>h.id).join()===o);this.push(e,"decor","decorLightRig",this.labels.decorLights,l?.name),this.push(e,"decor","decorFloors",this.labels.decorFloors,a.floors),this.push(e,"decor","decorOccupiedFloor",this.labels.decorOccupiedFloor,a.occupiedFloor),this.push(e,"decor","decorWitnessSide",this.labels.decorWitnessSide,this.decorSideName(a.witnessSide));for(const[c,h]of Object.entries(a.windows??{}))this.push(e,"decor",`decorWindow${this.capitalise(c)}`,`${this.labels.decorWindows} ${this.decorSideName(c)}`,h,"%")}addTemporal(e,t){const n=t.event;this.push(e,"temporal","obs-time",this.labels.observationTime,n.time&&_l(n.time)),this.push(e,"temporal","obs-end-time",this.labels.observationEndTime,n.endTime&&_l(n.endTime));const i=Ka(n);this.push(e,"temporal","durationSeconds",this.labels.duration,this.roundedShown(i&&i/1e3,1),"s"),this.push(e,"temporal","timeZone",this.labels.utcOffset,n.timeZone),this.push(e,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(n.utcOffsetHours,1),"UTC±h")}addWeather(e,t,n){const i=Fs(t,n),r={fromSource:t.weatherSource!==void 0},o=this.showsPercent(i.cloudCover)||this.showsPercent(i.lowerCloudCover)||this.showsPercent(i.highCloudCover);this.push(e,"weather","cloudCover",this.labels.cloudCover,this.percentShown(i.cloudCover),"",r),this.push(e,"weather","highCloudCover",this.labels.highCloudCover,this.percentShown(i.highCloudCover),"",r),this.push(e,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.showsPercent(i.highCloudCover)?this.percent(i.iceCrystalAlignment):void 0),this.push(e,"weather","cloudDarkness",this.labels.cloudDarkness,o?this.percent(i.cloudDarkness):void 0,"",r),this.push(e,"weather","cloudBase",this.labels.cloudBase,o?this.rounded(i.cloudBaseM):void 0,"m",r);const l=i.precipitationType!=="none"&&this.showsPercent(i.precipitationIntensity);this.push(e,"weather","precipitationType",this.labels.precipitationType,l?this.precipitationName(i.precipitationType):void 0,"",r),this.push(e,"weather","precipitationIntensity",this.labels.precipitationIntensity,l?this.percent(i.precipitationIntensity):void 0,"",r),this.push(e,"weather","windDirection",this.labels.windDirection,this.shows(i.windSpeed,2)?this.rounded(i.windDirectionDeg):void 0,"°",r),this.push(e,"weather","windSpeed",this.labels.windSpeed,this.roundedShown(i.windSpeed,2),"m/s",r),i.storm&&this.push(e,"weather","storm",this.labels.storm,"✓","",r)}addSound(e,t,n){const i=Jd(t,n);i.kind!=="none"&&(this.push(e,"sound","soundKind",this.labels.soundKind,this.soundKindName(i.kind)),this.push(e,"sound","soundVolume",this.labels.soundVolume,this.percentShown(i.volume)),this.push(e,"sound","soundPitch",this.labels.soundPitch,this.roundedShown(i.pitchHz),"Hz"),this.push(e,"sound","soundSrc",this.labels.soundSrc,i.src))}decorLabel(e){return this.said.read(e.title)??this.decorKindName(e.kind)}decorKindName(e){switch(e){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"crop":return this.labels.decorCrop;case"mound":return this.labels.decorMound;case"streetlight":return this.labels.decorStreetlight;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorWitness}}decorSideName(e){switch(e){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(e){switch(e){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(e){switch(e){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}capitalise(e){return e.replace(/(^|-)([a-z])/g,(t,n,i)=>i.toUpperCase())}}const L1=`
1347
1357
  <div class="stage" id="stage">
1348
1358
  <div class="frame" id="frame">
1349
1359
  <canvas id="canvas" width="640" height="360"></canvas>
@@ -1746,7 +1756,7 @@ input[type=range] {
1746
1756
  pointer-events: none;
1747
1757
  white-space: nowrap;
1748
1758
  }
1749
- `,cm=Math.PI/180,El=111320;function gn(s,e,t,n){const i=El*Math.cos(t*cm),a=(s-t)*El;return{x:(e-n)*i,z:-a}}function zi(s,e,t,n){const i=El*Math.cos(t*cm),a=-e,r=s;return{lat:t+a/El,lng:n+r/i}}class Wr{constructor(e){this.points=e}static STATIONARY_M=5;static of(e){const t=[];for(const n of e.witnessTrack.allKeyframes){const{lat:i,lng:a,headingDeg:r}=n.pose;i===void 0||a===void 0||t.push({t:n.t,lat:i,lng:a,headingDeg:r})}if(t.length===0){const n=e.event.place?.[0];if(!n)return;t.push({t:0,lat:n.lat,lng:n.lng})}return new Wr(t)}get moved(){return this.spanM>Wr.STATIONARY_M}get spanM(){const e=this.box,t=(e.south+e.north)/2,n=(e.west+e.east)/2;return Math.max(Math.abs(gn(t,e.east,t,e.west).x),Math.abs(gn(e.north,n,e.south,n).z))}get center(){const e=this.box;return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}boundsAround(e,t){const{lat:n,lng:i}=this.center,a=Math.max(this.spanM*(1+t),e)/2;return{north:zi(0,-a,n,i).lat,south:zi(0,a,n,i).lat,east:zi(a,0,n,i).lng,west:zi(-a,0,n,i).lng}}get box(){const e=this.points.map(n=>n.lat),t=this.points.map(n=>n.lng);return{south:Math.min(...e),north:Math.max(...e),west:Math.min(...t),east:Math.max(...t)}}}class Gt{constructor(e,t){this.stretches=e,this.rotationPassed=t}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(e){const t=Wr.of(e);if(!t||t.points.length<2)return;const n=[];let i=0;for(let a=1;a<t.points.length;a++){const r=t.points[a-1],o=t.points[a],l=(o.t-r.t)/1e3;if(l<=0)continue;const c=gn(o.lat,o.lng,r.lat,r.lng),h=c.x,d=-c.z,u=Math.hypot(h,d),f=u/l,g=Gt.stepHzFor(f);n.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:u>0?h/u:0,northUnit:u>0?d/u:0,stepHz:g,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=g*l}for(let a=0;a<n.length;a++){const r=n[a-1],o=n[a+1];n[a].rampsIn=r===void 0||r.stepHz===0,n[a].rampsOut=o===void 0||o.stepHz===0}if(n.some(a=>a.stepHz>0))return new Gt(n,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<Gt.SLOWEST_WALK_M_PER_S||e>Gt.FASTEST_WALK_M_PER_S?0:Gt.REFERENCE_STEP_HZ*Math.pow(e/Gt.REFERENCE_SPEED_M_PER_S,Gt.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(l=>e>=l.startMs&&e<=l.endMs);if(!t||t.stepHz===0)return Gt.STILL;const n=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,i=2*Math.PI*n,a=this.amplitudeAt(t,e),r=Gt.SWAY_M*a*Math.cos(i/2),o=a*this.rotationPassed*t.speedMPerS/Gt.REFERENCE_SPEED_M_PER_S;return{eastM:r*t.northUnit,northM:-r*t.eastUnit,upM:Gt.RISE_M_PER_M_PER_S*t.speedMPerS*a*Math.cos(i),rollDeg:Gt.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Gt.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(e,t){const n=1e3/e.stepHz,i=Math.min(n,(e.endMs-e.startMs)/2);if(i<=0)return 1;const a=t-e.startMs,r=e.endMs-t,o=Math.min(e.rampsIn?a/i:1,e.rampsOut?r/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class O1{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(e,n);i&&t.set(n,i)}this.onFrame(e,t)}}const nf=.05,sf=.08,af=2,rf=3,k1=14,U1=.02;class F1{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}this.context.state==="suspended"&&this.context.resume()}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const n=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,n):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const n=this.context;if(!e||!n)return;const i=n.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,i,nf);for(const{param:a,ratio:r}of e.pitch)a.setTargetAtTime(Math.min(t.pitchHz*r,n.sampleRate/2-1),i,nf)}buildSynthesizedVoice(e,t){const n=this.context;if(n)switch(e.kind){case"hum":return this.buildHum(n,t);case"whistle":return this.buildWhistle(n,t);case"rumble":return this.buildRumble(n,t);case"crackle":return this.buildCrackle(n,t);default:return}}buildHum(e,t){const n=e.createOscillator();n.type="sawtooth";const i=e.createOscillator();i.type="sawtooth";const a=e.createBiquadFilter();a.type="lowpass",a.Q.value=1;const r=e.createGain();return r.gain.value=0,n.connect(a),i.connect(a),a.connect(r).connect(e.destination),n.start(),i.start(),{key:t,nodes:[a,r],sources:[n,i],volumeParam:r.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:a.frequency,ratio:6}]}}buildWhistle(e,t){const n=e.createOscillator();n.type="sine";const i=e.createOscillator();i.type="sine",i.frequency.value=5;const a=e.createGain(),r=e.createGain();return r.gain.value=0,i.connect(a).connect(n.frequency),n.connect(r).connect(e.destination),n.start(),i.start(),{key:t,nodes:[a,r],sources:[n,i],volumeParam:r.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:a.gain,ratio:.012}]}}buildRumble(e,t){const n=e.createBufferSource();n.buffer=this.brownNoise(e),n.loop=!0;const i=e.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const a=e.createGain();return a.gain.value=0,n.connect(i).connect(a).connect(e.destination),n.start(),{key:t,nodes:[i,a],sources:[n],volumeParam:a.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(e,t){const n=e.createBufferSource();n.buffer=this.whiteNoise(e),n.loop=!0;const i=e.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const a=e.createGain();a.gain.value=0;const r=e.createBufferSource();r.buffer=this.crackleEnvelope(e),r.loop=!0;const o=e.createGain();return o.gain.value=0,r.connect(o).connect(a.gain),n.connect(i).connect(a).connect(e.destination),n.start(),r.start(),{key:t,nodes:[i,a,o],sources:[n,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(e,t,n){const i=this.context;if(!i)return;let a;try{a=await this.getBuffer(e)}catch(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);return}if(n!==this.voiceToken||!this.context)return;const r=i.createBufferSource();r.buffer=a,r.loop=!0;const o=i.createGain();o.gain.value=0,r.connect(o).connect(i.destination),r.start(),this.voice={key:t,nodes:[o],sources:[r],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${e}`);return i.arrayBuffer()}).then(i=>t.decodeAudioData(i)),this.buffers.set(e,n)),n}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*af),e.sampleRate),n=t.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*af),e.sampleRate),n=t.getChannelData(0);let i=0,a=0;for(let r=0;r<n.length;r++)i=(i+.02*(Math.random()*2-1))/1.02,n[r]=i,a=Math.max(a,Math.abs(i));if(a>0)for(let r=0;r<n.length;r++)n[r]/=a;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*rf),e.sampleRate),n=t.getChannelData(0),i=Math.max(1,Math.floor(U1*e.sampleRate)),a=Math.round(rf*k1);for(let r=0;r<a;r++){const o=Math.floor(Math.random()*n.length),l=.4+Math.random()*.6;for(let c=0;c<i&&o+c<n.length;c++)n[o+c]=Math.max(n[o+c],l*(1-c/i))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const n=t.currentTime;e.volumeParam.cancelScheduledValues(n),e.volumeParam.setTargetAtTime(0,n,sf/3);const i=n+sf;for(const a of e.sources){a.onended=()=>{a.disconnect();for(const r of e.nodes)r.disconnect()};try{a.stop(i)}catch{a.disconnect();for(const r of e.nodes)r.disconnect()}}}}function $a(s){return[...s].sort((e,t)=>e.t-t.t)}function of(s,e){let t;for(const n of $a(s)){if(n.t>e)break;t=n}return t}const ac=Math.PI/180,ho=180/Math.PI;class xi{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const i=n*ac/2;this.focalPx=e==="equidistant"?t/2/i:t/2/Math.tan(i)}focalPx;static of(e,t,n){return new xi(e.projection,t,n)}degToPx(e){const t=e*ac;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*ho:2*Math.atan(e/(2*this.focalPx))*ho}angleDegToRadiusPx(e){const t=e*ac;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}halfWidthAngleDeg(e){return this.radiusPxToAngleDeg(this.canvasHeightPx*e/2)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*ho:Math.atan(e/this.focalPx)*ho}ofBounds(e){return{widthDeg:this.pxToDeg(e.width),heightDeg:this.pxToDeg(e.height)}}toBoundsSize(e){return{width:this.degToPx(e.widthDeg),height:this.degToPx(e.heightDeg)}}widthPx(e){return this.degToPx(ht.angularWidthDeg(e))}}class on{static fovOf(e,t){return xt(e,t)?.fovDeg??it.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,n)=>({...t,angular:n.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,n)=>{if(!t.angular)return t;const{width:i,height:a}=n.toBoundsSize(t.angular),r={x:t.bounds.x+(t.bounds.width-i)/2,y:t.bounds.y+(t.bounds.height-a)/2,width:i,height:a};if(t.kind!=="polygon")return{...t,bounds:r};const o=t.bounds.width===0?1:i/t.bounds.width,l=t.bounds.height===0?1:a/t.bounds.height;return{...t,bounds:r,points:t.points.map(c=>({x:c.x*o,y:c.y*l}))}})}static toAim(e){this.eachKeyframe(e,(t,n,i)=>{const a=this.aimFrom(e,n,i,t.bounds);return a?{...t,aim:a}:t})}static aimOf(e,t,n){const i=xi.of(e.instrument,ht.CANVAS_HEIGHT_PX,this.fovOf(e,t));return this.aimFrom(e,i,xt(e,t),n)}static aimFrom(e,t,n,i){if(n?.headingDeg===void 0)return;const a=this.frameCentre(e),r=t.radiusPxToAngleDeg(i.x+i.width/2-a.x),o=t.radiusPxToAngleDeg(a.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+r)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,n,i)=>{if(!t.aim||i?.headingDeg===void 0)return t;const a=this.frameCentre(e),r=this.shortestArc(t.aim.azimuthDeg-i.headingDeg),o=t.aim.altitudeDeg-i.pitchDeg,l=a.x+this.offAxisPx(n,r)-t.bounds.width/2,c=a.y-this.offAxisPx(n,o)-t.bounds.height/2;return{...t,bounds:{...t.bounds,x:l,y:c}}})}static frameCentre(e){return{x:it.frameWidthPx(e.instrument,ht.CANVAS_HEIGHT_PX)/2,y:ht.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=on.OFF_CANVAS_DEG?Math.sign(t)*on.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,n){const i=it.frameWidthPx(t,ht.CANVAS_HEIGHT_PX)/2,a=it.frameWidthPx(e.instrument,ht.CANVAS_HEIGHT_PX)/2,r=ht.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const l=this.fovOf(e,o.t),c=n?.get(o.t)??l,h=xi.of(t,ht.CANVAS_HEIGHT_PX,c),d=xi.of(e.instrument,ht.CANVAS_HEIGHT_PX,l);e.timeline.addKeyframe(o.t,o.shapes.map(u=>{const{bounds:f}=u.shape,g=f.x+f.width/2-i,v=f.y+f.height/2-r,p=Math.hypot(g,v),m=p===0?1:d.angleDegToRadiusPx(h.radiusPxToAngleDeg(p))/p,S={...f,x:a+g*m-f.width/2,y:r+v*m-f.height/2};return{...u,shape:{...u.shape,bounds:S}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const i of[...n.allKeyframes]){const a=xt(e,i.t),r=this.fovOf(e,i.t),o=xi.of(e.instrument,ht.CANVAS_HEIGHT_PX,r);n.addKeyframe(i.t,i.shapes.map(l=>({...l,shape:t(l.shape,o,a)})))}}}function B1(s){return Pn.restore(Ih(s),s.provenance)}function Ih(s){return on.toAngular(s),on.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function z1(s){const{recording:e,provenance:t}=Pn.strip(s),n=H1(e);return n.provenance=t,n}function H1(s){const e=new Xl({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},Wl.fromJSON(s.timeline),s.witnessTrack?Hr.fromJSON(s.witnessTrack):new Hr,s.weatherTrack?Gr.fromJSON(s.weatherTrack):new Gr,s.soundTrack?Vr.fromJSON(s.soundTrack):new Vr,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),$a(s.milestones??[]));return e.testimony=s.testimony,on.toBounds(e),on.toPosition(e),e}function Xr(s,e){for(const t of s){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}class Vs{static preferencesFor(e){const t=navigator.languages??[],n=this.declaredFor(e);return n?[n,...t]:t}static declaredFor(e){for(let t=e;t;){const n=t.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=t.getRootNode();t=i instanceof ShadowRoot?i.host:void 0}}}class Fi{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const n of this.preferences){const i=e[n]??e[Fi.base(n)];if(i)return i}const t=new Set(this.preferences.map(n=>Fi.base(n)));for(const[n,i]of Object.entries(e))if(i&&t.has(Fi.base(n)))return i;return Object.values(e).find(n=>n)??void 0}write(e,t,n){const i=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return i;const a={...e},r=Object.keys(a).find(o=>o===n)??Object.keys(a).find(o=>Fi.base(o)===Fi.base(n))??n;return i===void 0?delete a[r]:a[r]=i,Object.keys(a).length===0?void 0:a}static base(e){return e.toLowerCase().split("-")[0]}}const hm=["en","fr"],G1={en:()=>Qn(()=>Promise.resolve().then(()=>Y1),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>Qn(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function V1(s){return G1[s]()}const W1={en:()=>Qn(()=>Promise.resolve().then(()=>NT),void 0,import.meta.url).then(s=>s.sightingEditorMessages_en),fr:()=>Qn(()=>import("./SightingEditorMessages_fr-Dt3bkCHu.js"),[],import.meta.url).then(s=>s.sightingEditorMessages_fr)};function X1(s){return W1[s]()}function q1(s){return s==="fr"?Qn(()=>import("./TagNames_fr-Dnqq6HQ5.js"),[],import.meta.url).then(e=>e.tagNames_fr):Promise.resolve({})}const dm={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},Y1=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:dm},Symbol.toStringTag,{value:"Module"})),um=Math.PI/180,K1=180/Math.PI,$1=256,Z1=19;function J1(s,e){return 156543.03392*Math.cos(s*um)/2**e}function j1(s,e){return J1(s,e)*$1}function fm(s,e){let t=0;for(;t<Z1&&j1(s,t+1)>=e;)t++;return t}function hl(s){const e=s*um;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function pm(s,e,t){const n=2**t;return{x:(s+180)/360*n,y:hl(e)*n}}function mm(s,e,t){const n=hl(s.north),i=hl(s.south);return{x:(e-s.west)/(s.east-s.west),y:(hl(t)-n)/(i-n)}}function Q1(s,e,t){const{x:n,y:i}=pm(s,e,t);return{x:Math.floor(n),y:Math.floor(i),z:t}}function ev(s){const e=2**s.z,t=s.x/e*360-180,n=(s.x+1)/e*360-180,i=lf(s.y,e);return{south:lf(s.y+1,e),north:i,west:t,east:n}}function lf(s,e){const t=s/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*K1}function gm(s,e,t,n){const i=Q1(s,e,t),a=Math.floor(n/2),r=[];for(let c=-a;c<=a;c++)for(let h=-a;h<=a;h++)r.push({x:i.x+h,y:i.y+c,z:t});const o=r.map(ev),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:r,bounds:l}}class Ls{constructor(e){this.ctx=e}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(e,t){let n,i=1/0;for(const a of this.targets){const r=Math.hypot(a.x-e,a.y-t);r>a.radius||r>i||(n=a,i=r)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(e){const{ctx:t}=this;t.save(),this.targets=[],t.clearRect(0,0,this.width,this.height),this.paintGround(e),this.paintNight(e.nightFraction),this.paintPath(e),e.position?(this.paintCone(e,e.position),this.paintDecor(e),this.paintMarkers(e),this.paintWitness(e,e.position)):(this.paintDecor(e),this.paintMarkers(e)),this.paintNorth(),this.paintFooter(e.bounds,e.attribution),t.restore()}toCanvas(e,t,n){const i=mm(e,n,t);return{x:i.x*this.width,y:i.y*this.height}}paintGround(e){const{ctx:t}=this;t.fillStyle="#1d2321",t.fillRect(0,0,this.width,this.height);const n=e.imagery;if(!n)return;const i=this.toCanvas(e.bounds,n.bounds.north,n.bounds.west),a=this.toCanvas(e.bounds,n.bounds.south,n.bounds.east);t.drawImage(n.source,i.x,i.y,a.x-i.x,a.y-i.y)}paintNight(e=0){if(e<=0)return;const{ctx:t}=this;t.save(),t.fillStyle=`rgba(6, 12, 30, ${Math.min(e,1)*.78})`,t.fillRect(0,0,this.width,this.height),t.restore()}paintDecor(e){const{ctx:t}=this;for(const n of e.decor){const i=this.toCanvas(e.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),t.beginPath(),t.rect(i.x-3.5,i.y-3.5,7,7),t.fillStyle="rgba(120, 220, 255, 0.85)",t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.7)",t.stroke(),n.headingDeg===void 0)continue;const a=(n.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(i.x+Math.cos(a)*10,i.y+Math.sin(a)*10),t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.6)",t.stroke(),t.lineWidth=1.5,t.strokeStyle="rgba(120, 220, 255, 0.9)",t.stroke()}}paintPath(e){if(!e.path.moved)return;const{ctx:t}=this,n=e.path.points.map(i=>this.toCanvas(e.bounds,i.lat,i.lng));t.beginPath(),t.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))t.lineTo(i.x,i.y);t.lineJoin="round",t.lineCap="round",t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=5,t.stroke(),t.strokeStyle="rgba(255, 255, 255, 0.9)",t.lineWidth=2,t.stroke()}paintCone(e,t){const{headingDeg:n,coneHalfAngleDeg:i}=e;if(n===void 0||i===void 0)return;const{ctx:a}=this,r=this.toCanvas(e.bounds,t.lat,t.lng),o=Math.hypot(this.width,this.height),l=(n-90)*Math.PI/180,c=i*Math.PI/180;a.save(),a.beginPath(),a.moveTo(r.x,r.y),a.arc(r.x,r.y,o,l-c,l+c),a.closePath();const h=a.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),a.fillStyle=h,a.fill(),a.restore()}paintMarkers(e){const{ctx:t}=this;t.textAlign="center",t.textBaseline="middle",t.font="bold 10px sans-serif";for(const n of[...e.markers].sort((i,a)=>Number(i.current)-Number(a.current))){const i=this.toCanvas(e.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:Ls.MARKER_RADIUS_PX}),t.beginPath(),t.arc(i.x,i.y,Ls.MARKER_RADIUS_PX,0,Math.PI*2),t.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",t.fill(),t.lineWidth=2,t.strokeStyle="rgba(255, 255, 255, 0.9)",t.stroke(),t.fillStyle=n.current?"#1d2321":"#fff",t.fillText(n.label,i.x,i.y)}}paintWitness(e,t){const{ctx:n}=this,i=this.toCanvas(e.bounds,t.lat,t.lng);e.witnessLabel&&this.targets.push({kind:"witness",label:e.witnessLabel,lat:t.lat,lng:t.lng,x:i.x,y:i.y,radius:8});const a=e.markers.some(r=>{if(!r.current)return!1;const o=gn(r.lat,r.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=Ls.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,a?Ls.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),a||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=a?3:2.5,n.strokeStyle=a?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:e}=this,t=this.width-14,n=16;e.beginPath(),e.moveTo(t,n-9),e.lineTo(t-4.5,n+5),e.lineTo(t,n+2),e.lineTo(t+4.5,n+5),e.closePath(),e.fillStyle="rgba(255, 255, 255, 0.92)",e.strokeStyle="rgba(0, 0, 0, 0.6)",e.lineWidth=1,e.fill(),e.stroke(),e.font="bold 9px sans-serif",e.textAlign="center",e.textBaseline="top",e.strokeText("N",t,n+6),e.fillText("N",t,n+6)}paintFooter(e,t){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=t?this.wrap(t,this.width-20):[];let a=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,a),a-=11;const r=(e.south+e.north)/2,l=Math.abs(gn(r,e.east,r,e.west).x)/this.width,c=Ls.SCALE_STEPS_M.find(f=>f/l<=this.width/3);if(c===void 0)return;const h=c/l,d=8,u=a-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(d,u),n.lineTo(d+h,u),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(c>=1e3?`${c/1e3} km`:`${c} m`,d,u-3)}paintOutlinedText(e,t,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(e,t,n),i.fillStyle="#fff",i.fillText(e,t,n)}wrap(e,t){const n=[];let i="";for(const a of e.split(" ")){const r=i?`${i} ${a}`:a;i&&this.ctx.measureText(r).width>t?(n.push(i),i=a):i=r}return i&&n.push(i),n}}const Fn=256,cf=3,tv=32768;class vm{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,i=(e.west+e.east)/2,a=Math.abs(gn(n,e.east,n,e.west).x),r=Math.abs(gn(e.north,i,e.south,i).z),o=fm(n,Math.max(a,r)),{tiles:l}=gm(i,n,o,cf),c=cf*Fn,h=new Float32Array(c*c),d=l[0];await Promise.all(l.map(f=>this.decodeTileInto(f,d,h,c)));const u=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const g=e.north+(e.south-e.north)*(f/(t.height-1));for(let v=0;v<t.width;v++){const p=e.west+(e.east-e.west)*(v/(t.width-1));u[f*t.width+v]=this.sampleAt(g,p,o,d,h,c)}}return{heights:u,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,i){const a=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),r=await this.fetchImpl(a);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${a}`);const o=await createImageBitmap(await r.blob()),l=document.createElement("canvas");l.width=Fn,l.height=Fn;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.getImageData(0,0,Fn,Fn),d=(e.x-t.x)*Fn,u=(e.y-t.y)*Fn;for(let f=0;f<Fn;f++)for(let g=0;g<Fn;g++){const v=(f*Fn+g)*4,p=h[v]*256+h[v+1]+h[v+2]/256-tv,m=d+g,S=u+f;n[S*i+m]=p}}sampleAt(e,t,n,i,a,r){const{x:o,y:l}=pm(t,e,n),c=(o-i.x)*Fn,h=(l-i.y)*Fn,d=Math.max(0,Math.min(r-1,Math.floor(c))),u=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,d+1),g=Math.min(r-1,u+1),v=c-d,p=h-u,m=a[u*r+d],S=a[u*r+f],_=a[g*r+d],x=a[g*r+f],M=m+(S-m)*v,E=_+(x-_)*v;return M+(E-M)*p}}const rc=256,hf=3;async function ym(s,e,t,n){const i=(s.south+s.north)/2,a=(s.west+s.east)/2,r=Math.abs(gn(i,s.east,i,s.west).x),o=Math.abs(gn(s.north,a,s.south,a).z),l=fm(i,Math.max(r,o)/2),{tiles:c,bounds:h}=gm(a,i,l,hf),d=hf*rc,u=document.createElement("canvas");u.width=d,u.height=d;const f=u.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const g=c[0];await Promise.all(c.map(async m=>{const S=t(m),_=await n(S);if(!_.ok)throw new Error(`Imagery tile fetch failed (${_.status}): ${S}`);const x=await createImageBitmap(await _.blob());f.drawImage(x,(m.x-g.x)*rc,(m.y-g.y)*rc)}));const v=document.createElement("canvas");v.width=e.width,v.height=e.height;const p=v.getContext("2d");if(!p)throw new Error("2D canvas context unavailable");return p.drawImage(u,0,0,d,d,0,0,e.width,e.height),{source:v,width:e.width,height:e.height,bounds:h}}class bm{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return ym(e,t,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function nv(){return{elevation:new vm,imagery:xm()}}function xm(){return new bm}const iv=new Set,Ws="show-witness-map",ka="hide-milestones";class zn extends HTMLElement{static get observedAttributes(){return["src",Ws,ka]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Xl.create();sightingAudio=new F1;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=dm;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.shapeAt(t.x,t.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const a=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-a.left+12}px`,this.tooltip.style.top=`${e.clientY-a.top+12}px`};handleWitnessMapPointerMove=e=>{const t=this.witnessMapTargetFrom(e);if(!t){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=t.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-n.left+12}px`,this.tooltip.style.top=`${e.clientY-n.top+12}px`};handleWitnessMapClick=e=>{const t=this.witnessMapTargetFrom(e);if(t){if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(e){const t=this.witnessMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.witnessMapRenderer.hitTest((e.clientX-t.left)/t.width*this.witnessMapCanvas.width,(e.clientY-t.top)/t.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${N1}</style>${L1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new wh(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new Ls(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.toggleTimeDisplay()),t.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e===Ws&&this.applyWitnessMapDefault(),e===ka&&this.setMilestonesShown(!this.hasAttribute(ka))}async loadFromSrc(e){this.sightingData=await Kd.json(e)}get sightingData(){return B1(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=z1(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=t,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?$a(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/e,0),1)*100}%`;const a=this.said.read(n.label)??"",r=this.said.read(n.note),o=r?`${a} — ${r}`:a;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?of(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,!t)return;const n=document.createElement("b");n.textContent=this.said.read(t.label)??"";const i=this.said.read(t.note),a=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(a))}exposureInstants(e){const t=this.exposureTimes(e),n=1/t.length;return t.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(e=this.currentTime){const t=(this.currentSighting.exposure??0)*1e3;if(t<zn.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const n=Math.min(zn.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/zn.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(e,t)/zn.EXPOSURE_STEP_PX),a=Math.min(zn.MAX_TRAVEL_STEPS,Math.max(n,i)),r=[];for(let o=0;o<a;o++)r.push(e+t*o/a);return r}travelPxOver(e,t){const n=this.shapesAt(e),i=this.shapesAt(e+t);let a=0;for(const[r,o]of n){const l=i.get(r);if(!l)continue;const c=l.bounds.x+l.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=l.bounds.y+l.bounds.height/2-(o.bounds.y+o.bounds.height/2);a=Math.max(a,Math.hypot(c,h))}return a}shapeAt(e,t,n){for(const i of this.exposureTimes()){const a=this.currentSighting.timeline.hitTest(i,e,t,n);if(a)return a}}shapesAt(e){const t=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(e,n);i&&t.set(n,i)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=it.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:iv;this.canvasRenderer.setStarPoints(it.starPointsOf(this.sighting.instrument));const i=(xt(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const a=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of a)for(const[,l]of o.shapes){const c=o.share,h=c===1?l:{...l,transparency:1-(1-l.transparency)*c};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,l]of a[0].shapes)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));if(n.size>1){const o=nt.groupBoundsFor([...t].filter(([l])=>n.has(l)).map(([,l])=>l.bounds));this.canvasRenderer.paintGroupHandles(o)}this.keepWitnessMapClear(a[0].shapes),this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintWitnessMap(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Jd(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new O1(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const n=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",e),this.cornerButtons.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(Ws)&&this.witnessPath!==void 0)}setWitnessMapOpen(e){this.witnessMapPanel.hidden=!e,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(e)),this.updateWitnessMapButton(),e&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const t=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=t,this.witnessMapButton.setAttribute("aria-label",t)}updateWitnessMap(){const e=this.witnessPath!==void 0;if(this.witnessPath=Wr.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!e&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const t=this.witnessPath.boundsAround(zn.WITNESS_MAP_MIN_SPAN_M,zn.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,t))&&(this.witnessMapBounds=t,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(e,t){const n=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<n&&Math.abs(e.south-t.south)<n&&Math.abs(e.west-t.west)<n&&Math.abs(e.east-t.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const e=xm(),t=this.witnessMapBounds;try{const n=await e.getImageryTexture(t,{width:zn.WITNESS_MAP_IMAGERY_PX,height:zn.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==t)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=e.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(e){if(this.witnessMapPanel.hidden)return;const t=this.witnessMapBoxPx;if(!t)return;const n=(o,l,c)=>{for(const h of e.values())if(!(h.transparency>=1)&&!(h.bounds.x+h.bounds.width<o-c||h.bounds.x>l+c)&&!(h.bounds.y>t.bottom+c||h.bounds.y+h.bounds.height<t.top-c))return!0;return!1},i=[this.canvas.width-t.width,this.canvas.width],a=[0,t.width],r=zn.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){n(i[0],i[1],r)||this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(a[0],a[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const e=this.witnessMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==t&&(this.witnessMapCanvas.width=t,this.witnessMapCanvas.height=t)}measureWitnessMapBox(){const e=this.witnessMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const n=this.canvas.width/t.width,i=this.canvas.height/t.height;this.witnessMapBoxPx={width:e.width*n,top:(e.top-t.top)*i,bottom:(e.bottom-t.top)*i}}paintWitnessMap(e){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const t=xt(this.currentSighting,e),n=this.currentSighting.instrument,i=[],a=this.currentSighting.milestones.length>0?of(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?$a(this.currentSighting.milestones):[]){const o=xt(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===a})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?xi.of(n,this.canvas.height,t.fovDeg).halfWidthAngleDeg(it.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(e),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.milestonesButton.setAttribute("aria-pressed",String(e)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const e=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}witnessMapDecorAt(e){const t=xt(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=Ya(n,e),{lat:a,lng:r}=zi(i.eastM,-i.northM,t.lat,t.lng);return{lat:a,lng:r,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=t,this.paintWitnessMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,n=this.lookPitchDeg+e.pitchDeg;if(t===0&&n===0)return{x:0,y:0};const i=xt(this.currentSighting,this.currentTime),a=xi.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-a.angleDegToRadiusPx(t),y:a.angleDegToRadiusPx(n)}}gaitAt(e){return Gt.of(this.currentSighting)?.offsetAt(e)??Gt.STILL}updateFullscreenButton(){const e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Xr(Vs.preferencesFor(this),hm);e!=="en"&&this.applyMessages(await V1(e))}updateTimeLabelTitles(){const e=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=this.messages.currentPosition+t,this.timeEndLabel.title=this.messages.duration+t;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(e){this.messages=e,this.updateTimeLabelTitles(),this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const e=this.currentSighting.event,t=Ka(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Eh(e.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(e){if(this.realDurationMs===void 0)return uo(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?uf(df(this.realStartMs+n)):uo(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?uo(this.currentSighting.timeline.duration):this.canShowClockTime?uf(df(this.realStartMs+this.realDurationMs)):uo(this.realDurationMs)}}function df(s){const e=new Date(s);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function uf(s){if(s.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return s.second?`${e(s.hour)}:${e(s.minute??0)}:${e(s.second)}`:`${e(s.hour)}:${e(s.minute??0)}`}function uo(s){const e=Math.round(s/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Dh="rr0-ufo";function ql(){customElements.get(Dh)||customElements.define(Dh,zn)}const sv=`
1759
+ `,cm=Math.PI/180,El=111320;function gn(s,e,t,n){const i=El*Math.cos(t*cm),a=(s-t)*El;return{x:(e-n)*i,z:-a}}function zi(s,e,t,n){const i=El*Math.cos(t*cm),a=-e,r=s;return{lat:t+a/El,lng:n+r/i}}class Wr{constructor(e){this.points=e}static STATIONARY_M=5;static of(e){const t=[];for(const n of e.witnessTrack.allKeyframes){const{lat:i,lng:a,headingDeg:r}=n.pose;i===void 0||a===void 0||t.push({t:n.t,lat:i,lng:a,headingDeg:r})}if(t.length===0){const n=e.event.place?.[0];if(!n)return;t.push({t:0,lat:n.lat,lng:n.lng})}return new Wr(t)}get moved(){return this.spanM>Wr.STATIONARY_M}get spanM(){const e=this.box,t=(e.south+e.north)/2,n=(e.west+e.east)/2;return Math.max(Math.abs(gn(t,e.east,t,e.west).x),Math.abs(gn(e.north,n,e.south,n).z))}get center(){const e=this.box;return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}boundsAround(e,t){const{lat:n,lng:i}=this.center,a=Math.max(this.spanM*(1+t),e)/2;return{north:zi(0,-a,n,i).lat,south:zi(0,a,n,i).lat,east:zi(a,0,n,i).lng,west:zi(-a,0,n,i).lng}}get box(){const e=this.points.map(n=>n.lat),t=this.points.map(n=>n.lng);return{south:Math.min(...e),north:Math.max(...e),west:Math.min(...t),east:Math.max(...t)}}}class Gt{constructor(e,t){this.stretches=e,this.rotationPassed=t}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(e){const t=Wr.of(e);if(!t||t.points.length<2)return;const n=[];let i=0;for(let a=1;a<t.points.length;a++){const r=t.points[a-1],o=t.points[a],l=(o.t-r.t)/1e3;if(l<=0)continue;const c=gn(o.lat,o.lng,r.lat,r.lng),h=c.x,d=-c.z,u=Math.hypot(h,d),f=u/l,g=Gt.stepHzFor(f);n.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:u>0?h/u:0,northUnit:u>0?d/u:0,stepHz:g,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=g*l}for(let a=0;a<n.length;a++){const r=n[a-1],o=n[a+1];n[a].rampsIn=r===void 0||r.stepHz===0,n[a].rampsOut=o===void 0||o.stepHz===0}if(n.some(a=>a.stepHz>0))return new Gt(n,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<Gt.SLOWEST_WALK_M_PER_S||e>Gt.FASTEST_WALK_M_PER_S?0:Gt.REFERENCE_STEP_HZ*Math.pow(e/Gt.REFERENCE_SPEED_M_PER_S,Gt.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(l=>e>=l.startMs&&e<=l.endMs);if(!t||t.stepHz===0)return Gt.STILL;const n=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,i=2*Math.PI*n,a=this.amplitudeAt(t,e),r=Gt.SWAY_M*a*Math.cos(i/2),o=a*this.rotationPassed*t.speedMPerS/Gt.REFERENCE_SPEED_M_PER_S;return{eastM:r*t.northUnit,northM:-r*t.eastUnit,upM:Gt.RISE_M_PER_M_PER_S*t.speedMPerS*a*Math.cos(i),rollDeg:Gt.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Gt.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(e,t){const n=1e3/e.stepHz,i=Math.min(n,(e.endMs-e.startMs)/2);if(i<=0)return 1;const a=t-e.startMs,r=e.endMs-t,o=Math.min(e.rampsIn?a/i:1,e.rampsOut?r/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class O1{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(e,n);i&&t.set(n,i)}this.onFrame(e,t)}}const nf=.05,sf=.08,af=2,rf=3,k1=14,U1=.02;class F1{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}this.context.state==="suspended"&&this.context.resume()}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const n=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,n):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const n=this.context;if(!e||!n)return;const i=n.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,i,nf);for(const{param:a,ratio:r}of e.pitch)a.setTargetAtTime(Math.min(t.pitchHz*r,n.sampleRate/2-1),i,nf)}buildSynthesizedVoice(e,t){const n=this.context;if(n)switch(e.kind){case"hum":return this.buildHum(n,t);case"whistle":return this.buildWhistle(n,t);case"rumble":return this.buildRumble(n,t);case"crackle":return this.buildCrackle(n,t);default:return}}buildHum(e,t){const n=e.createOscillator();n.type="sawtooth";const i=e.createOscillator();i.type="sawtooth";const a=e.createBiquadFilter();a.type="lowpass",a.Q.value=1;const r=e.createGain();return r.gain.value=0,n.connect(a),i.connect(a),a.connect(r).connect(e.destination),n.start(),i.start(),{key:t,nodes:[a,r],sources:[n,i],volumeParam:r.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:a.frequency,ratio:6}]}}buildWhistle(e,t){const n=e.createOscillator();n.type="sine";const i=e.createOscillator();i.type="sine",i.frequency.value=5;const a=e.createGain(),r=e.createGain();return r.gain.value=0,i.connect(a).connect(n.frequency),n.connect(r).connect(e.destination),n.start(),i.start(),{key:t,nodes:[a,r],sources:[n,i],volumeParam:r.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:a.gain,ratio:.012}]}}buildRumble(e,t){const n=e.createBufferSource();n.buffer=this.brownNoise(e),n.loop=!0;const i=e.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const a=e.createGain();return a.gain.value=0,n.connect(i).connect(a).connect(e.destination),n.start(),{key:t,nodes:[i,a],sources:[n],volumeParam:a.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(e,t){const n=e.createBufferSource();n.buffer=this.whiteNoise(e),n.loop=!0;const i=e.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const a=e.createGain();a.gain.value=0;const r=e.createBufferSource();r.buffer=this.crackleEnvelope(e),r.loop=!0;const o=e.createGain();return o.gain.value=0,r.connect(o).connect(a.gain),n.connect(i).connect(a).connect(e.destination),n.start(),r.start(),{key:t,nodes:[i,a,o],sources:[n,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(e,t,n){const i=this.context;if(!i)return;let a;try{a=await this.getBuffer(e)}catch(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);return}if(n!==this.voiceToken||!this.context)return;const r=i.createBufferSource();r.buffer=a,r.loop=!0;const o=i.createGain();o.gain.value=0,r.connect(o).connect(i.destination),r.start(),this.voice={key:t,nodes:[o],sources:[r],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${e}`);return i.arrayBuffer()}).then(i=>t.decodeAudioData(i)),this.buffers.set(e,n)),n}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*af),e.sampleRate),n=t.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*af),e.sampleRate),n=t.getChannelData(0);let i=0,a=0;for(let r=0;r<n.length;r++)i=(i+.02*(Math.random()*2-1))/1.02,n[r]=i,a=Math.max(a,Math.abs(i));if(a>0)for(let r=0;r<n.length;r++)n[r]/=a;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*rf),e.sampleRate),n=t.getChannelData(0),i=Math.max(1,Math.floor(U1*e.sampleRate)),a=Math.round(rf*k1);for(let r=0;r<a;r++){const o=Math.floor(Math.random()*n.length),l=.4+Math.random()*.6;for(let c=0;c<i&&o+c<n.length;c++)n[o+c]=Math.max(n[o+c],l*(1-c/i))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const n=t.currentTime;e.volumeParam.cancelScheduledValues(n),e.volumeParam.setTargetAtTime(0,n,sf/3);const i=n+sf;for(const a of e.sources){a.onended=()=>{a.disconnect();for(const r of e.nodes)r.disconnect()};try{a.stop(i)}catch{a.disconnect();for(const r of e.nodes)r.disconnect()}}}}function $a(s){return[...s].sort((e,t)=>e.t-t.t)}function of(s,e){let t;for(const n of $a(s)){if(n.t>e)break;t=n}return t}const ac=Math.PI/180,ho=180/Math.PI;class Qn{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const i=n*ac/2;this.focalPx=e==="equidistant"?t/2/i:t/2/Math.tan(i)}focalPx;static of(e,t,n){return new Qn(e.projection,t,n)}degToPx(e){const t=e*ac;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*ho:2*Math.atan(e/(2*this.focalPx))*ho}angleDegToRadiusPx(e){const t=e*ac;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}halfWidthAngleDeg(e){return this.radiusPxToAngleDeg(this.canvasHeightPx*e/2)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*ho:Math.atan(e/this.focalPx)*ho}ofBounds(e){return{widthDeg:this.pxToDeg(e.width),heightDeg:this.pxToDeg(e.height)}}toBoundsSize(e){return{width:this.degToPx(e.widthDeg),height:this.degToPx(e.heightDeg)}}widthPx(e){return this.degToPx(et.angularWidthDeg(e))}}class en{static fovOf(e,t){return bt(e,t)?.fovDeg??st.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,n)=>({...t,angular:n.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,n)=>{if(!t.angular)return t;const{width:i,height:a}=n.toBoundsSize(t.angular),r={x:t.bounds.x+(t.bounds.width-i)/2,y:t.bounds.y+(t.bounds.height-a)/2,width:i,height:a};if(t.kind!=="polygon")return{...t,bounds:r};const o=t.bounds.width===0?1:i/t.bounds.width,l=t.bounds.height===0?1:a/t.bounds.height;return{...t,bounds:r,points:t.points.map(c=>({x:c.x*o,y:c.y*l}))}})}static toAim(e){this.eachKeyframe(e,(t,n,i)=>{const a=this.aimFrom(e,n,i,t.bounds);return a?{...t,aim:a}:t})}static aimOf(e,t,n){const i=Qn.of(e.instrument,et.CANVAS_HEIGHT_PX,this.fovOf(e,t));return this.aimFrom(e,i,bt(e,t),n)}static aimFrom(e,t,n,i){if(n?.headingDeg===void 0)return;const a=this.frameCentre(e),r=t.radiusPxToAngleDeg(i.x+i.width/2-a.x),o=t.radiusPxToAngleDeg(a.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+r)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,n,i)=>{if(!t.aim||i?.headingDeg===void 0)return t;const a=this.frameCentre(e),r=this.shortestArc(t.aim.azimuthDeg-i.headingDeg),o=t.aim.altitudeDeg-i.pitchDeg,l=a.x+this.offAxisPx(n,r)-t.bounds.width/2,c=a.y-this.offAxisPx(n,o)-t.bounds.height/2;return{...t,bounds:{...t.bounds,x:l,y:c}}})}static frameCentre(e){return{x:st.frameWidthPx(e.instrument,et.CANVAS_HEIGHT_PX)/2,y:et.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=en.OFF_CANVAS_DEG?Math.sign(t)*en.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,n){const i=st.frameWidthPx(t,et.CANVAS_HEIGHT_PX)/2,a=st.frameWidthPx(e.instrument,et.CANVAS_HEIGHT_PX)/2,r=et.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const l=this.fovOf(e,o.t),c=n?.get(o.t)??l,h=Qn.of(t,et.CANVAS_HEIGHT_PX,c),d=Qn.of(e.instrument,et.CANVAS_HEIGHT_PX,l);e.timeline.addKeyframe(o.t,o.shapes.map(u=>{const{bounds:f}=u.shape,g=f.x+f.width/2-i,v=f.y+f.height/2-r,p=Math.hypot(g,v),m=p===0?1:d.angleDegToRadiusPx(h.radiusPxToAngleDeg(p))/p,S={...f,x:a+g*m-f.width/2,y:r+v*m-f.height/2};return{...u,shape:{...u.shape,bounds:S}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const i of[...n.allKeyframes]){const a=bt(e,i.t),r=this.fovOf(e,i.t),o=Qn.of(e.instrument,et.CANVAS_HEIGHT_PX,r);n.addKeyframe(i.t,i.shapes.map(l=>({...l,shape:t(l.shape,o,a)})))}}}function B1(s){return Pn.restore(Ih(s),s.provenance)}function Ih(s){return en.toAngular(s),en.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function z1(s){const{recording:e,provenance:t}=Pn.strip(s),n=H1(e);return n.provenance=t,n}function H1(s){const e=new Xl({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},Wl.fromJSON(s.timeline),s.witnessTrack?Hr.fromJSON(s.witnessTrack):new Hr,s.weatherTrack?Gr.fromJSON(s.weatherTrack):new Gr,s.soundTrack?Vr.fromJSON(s.soundTrack):new Vr,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),$a(s.milestones??[]));return e.testimony=s.testimony,en.toBounds(e),en.toPosition(e),e}function Xr(s,e){for(const t of s){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}class Vs{static preferencesFor(e){const t=navigator.languages??[],n=this.declaredFor(e);return n?[n,...t]:t}static declaredFor(e){for(let t=e;t;){const n=t.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=t.getRootNode();t=i instanceof ShadowRoot?i.host:void 0}}}class Fi{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const n of this.preferences){const i=e[n]??e[Fi.base(n)];if(i)return i}const t=new Set(this.preferences.map(n=>Fi.base(n)));for(const[n,i]of Object.entries(e))if(i&&t.has(Fi.base(n)))return i;return Object.values(e).find(n=>n)??void 0}write(e,t,n){const i=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return i;const a={...e},r=Object.keys(a).find(o=>o===n)??Object.keys(a).find(o=>Fi.base(o)===Fi.base(n))??n;return i===void 0?delete a[r]:a[r]=i,Object.keys(a).length===0?void 0:a}static base(e){return e.toLowerCase().split("-")[0]}}const hm=["en","fr"],G1={en:()=>ei(()=>Promise.resolve().then(()=>Y1),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>ei(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function V1(s){return G1[s]()}const W1={en:()=>ei(()=>Promise.resolve().then(()=>NT),void 0,import.meta.url).then(s=>s.sightingEditorMessages_en),fr:()=>ei(()=>import("./SightingEditorMessages_fr-CBPyMrE5.js"),[],import.meta.url).then(s=>s.sightingEditorMessages_fr)};function X1(s){return W1[s]()}function q1(s){return s==="fr"?ei(()=>import("./TagNames_fr-Dnqq6HQ5.js"),[],import.meta.url).then(e=>e.tagNames_fr):Promise.resolve({})}const dm={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},Y1=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:dm},Symbol.toStringTag,{value:"Module"})),um=Math.PI/180,K1=180/Math.PI,$1=256,Z1=19;function J1(s,e){return 156543.03392*Math.cos(s*um)/2**e}function j1(s,e){return J1(s,e)*$1}function fm(s,e){let t=0;for(;t<Z1&&j1(s,t+1)>=e;)t++;return t}function hl(s){const e=s*um;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function pm(s,e,t){const n=2**t;return{x:(s+180)/360*n,y:hl(e)*n}}function mm(s,e,t){const n=hl(s.north),i=hl(s.south);return{x:(e-s.west)/(s.east-s.west),y:(hl(t)-n)/(i-n)}}function Q1(s,e,t){const{x:n,y:i}=pm(s,e,t);return{x:Math.floor(n),y:Math.floor(i),z:t}}function ev(s){const e=2**s.z,t=s.x/e*360-180,n=(s.x+1)/e*360-180,i=lf(s.y,e);return{south:lf(s.y+1,e),north:i,west:t,east:n}}function lf(s,e){const t=s/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*K1}function gm(s,e,t,n){const i=Q1(s,e,t),a=Math.floor(n/2),r=[];for(let c=-a;c<=a;c++)for(let h=-a;h<=a;h++)r.push({x:i.x+h,y:i.y+c,z:t});const o=r.map(ev),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:r,bounds:l}}class Ls{constructor(e){this.ctx=e}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(e,t){let n,i=1/0;for(const a of this.targets){const r=Math.hypot(a.x-e,a.y-t);r>a.radius||r>i||(n=a,i=r)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(e){const{ctx:t}=this;t.save(),this.targets=[],t.clearRect(0,0,this.width,this.height),this.paintGround(e),this.paintNight(e.nightFraction),this.paintPath(e),e.position?(this.paintCone(e,e.position),this.paintDecor(e),this.paintMarkers(e),this.paintWitness(e,e.position)):(this.paintDecor(e),this.paintMarkers(e)),this.paintNorth(),this.paintFooter(e.bounds,e.attribution),t.restore()}toCanvas(e,t,n){const i=mm(e,n,t);return{x:i.x*this.width,y:i.y*this.height}}paintGround(e){const{ctx:t}=this;t.fillStyle="#1d2321",t.fillRect(0,0,this.width,this.height);const n=e.imagery;if(!n)return;const i=this.toCanvas(e.bounds,n.bounds.north,n.bounds.west),a=this.toCanvas(e.bounds,n.bounds.south,n.bounds.east);t.drawImage(n.source,i.x,i.y,a.x-i.x,a.y-i.y)}paintNight(e=0){if(e<=0)return;const{ctx:t}=this;t.save(),t.fillStyle=`rgba(6, 12, 30, ${Math.min(e,1)*.78})`,t.fillRect(0,0,this.width,this.height),t.restore()}paintDecor(e){const{ctx:t}=this;for(const n of e.decor){const i=this.toCanvas(e.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),t.beginPath(),t.rect(i.x-3.5,i.y-3.5,7,7),t.fillStyle="rgba(120, 220, 255, 0.85)",t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.7)",t.stroke(),n.headingDeg===void 0)continue;const a=(n.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(i.x+Math.cos(a)*10,i.y+Math.sin(a)*10),t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.6)",t.stroke(),t.lineWidth=1.5,t.strokeStyle="rgba(120, 220, 255, 0.9)",t.stroke()}}paintPath(e){if(!e.path.moved)return;const{ctx:t}=this,n=e.path.points.map(i=>this.toCanvas(e.bounds,i.lat,i.lng));t.beginPath(),t.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))t.lineTo(i.x,i.y);t.lineJoin="round",t.lineCap="round",t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=5,t.stroke(),t.strokeStyle="rgba(255, 255, 255, 0.9)",t.lineWidth=2,t.stroke()}paintCone(e,t){const{headingDeg:n,coneHalfAngleDeg:i}=e;if(n===void 0||i===void 0)return;const{ctx:a}=this,r=this.toCanvas(e.bounds,t.lat,t.lng),o=Math.hypot(this.width,this.height),l=(n-90)*Math.PI/180,c=i*Math.PI/180;a.save(),a.beginPath(),a.moveTo(r.x,r.y),a.arc(r.x,r.y,o,l-c,l+c),a.closePath();const h=a.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),a.fillStyle=h,a.fill(),a.restore()}paintMarkers(e){const{ctx:t}=this;t.textAlign="center",t.textBaseline="middle",t.font="bold 10px sans-serif";for(const n of[...e.markers].sort((i,a)=>Number(i.current)-Number(a.current))){const i=this.toCanvas(e.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:Ls.MARKER_RADIUS_PX}),t.beginPath(),t.arc(i.x,i.y,Ls.MARKER_RADIUS_PX,0,Math.PI*2),t.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",t.fill(),t.lineWidth=2,t.strokeStyle="rgba(255, 255, 255, 0.9)",t.stroke(),t.fillStyle=n.current?"#1d2321":"#fff",t.fillText(n.label,i.x,i.y)}}paintWitness(e,t){const{ctx:n}=this,i=this.toCanvas(e.bounds,t.lat,t.lng);e.witnessLabel&&this.targets.push({kind:"witness",label:e.witnessLabel,lat:t.lat,lng:t.lng,x:i.x,y:i.y,radius:8});const a=e.markers.some(r=>{if(!r.current)return!1;const o=gn(r.lat,r.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=Ls.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,a?Ls.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),a||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=a?3:2.5,n.strokeStyle=a?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:e}=this,t=this.width-14,n=16;e.beginPath(),e.moveTo(t,n-9),e.lineTo(t-4.5,n+5),e.lineTo(t,n+2),e.lineTo(t+4.5,n+5),e.closePath(),e.fillStyle="rgba(255, 255, 255, 0.92)",e.strokeStyle="rgba(0, 0, 0, 0.6)",e.lineWidth=1,e.fill(),e.stroke(),e.font="bold 9px sans-serif",e.textAlign="center",e.textBaseline="top",e.strokeText("N",t,n+6),e.fillText("N",t,n+6)}paintFooter(e,t){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=t?this.wrap(t,this.width-20):[];let a=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,a),a-=11;const r=(e.south+e.north)/2,l=Math.abs(gn(r,e.east,r,e.west).x)/this.width,c=Ls.SCALE_STEPS_M.find(f=>f/l<=this.width/3);if(c===void 0)return;const h=c/l,d=8,u=a-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(d,u),n.lineTo(d+h,u),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(c>=1e3?`${c/1e3} km`:`${c} m`,d,u-3)}paintOutlinedText(e,t,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(e,t,n),i.fillStyle="#fff",i.fillText(e,t,n)}wrap(e,t){const n=[];let i="";for(const a of e.split(" ")){const r=i?`${i} ${a}`:a;i&&this.ctx.measureText(r).width>t?(n.push(i),i=a):i=r}return i&&n.push(i),n}}const Fn=256,cf=3,tv=32768;class vm{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,i=(e.west+e.east)/2,a=Math.abs(gn(n,e.east,n,e.west).x),r=Math.abs(gn(e.north,i,e.south,i).z),o=fm(n,Math.max(a,r)),{tiles:l}=gm(i,n,o,cf),c=cf*Fn,h=new Float32Array(c*c),d=l[0];await Promise.all(l.map(f=>this.decodeTileInto(f,d,h,c)));const u=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const g=e.north+(e.south-e.north)*(f/(t.height-1));for(let v=0;v<t.width;v++){const p=e.west+(e.east-e.west)*(v/(t.width-1));u[f*t.width+v]=this.sampleAt(g,p,o,d,h,c)}}return{heights:u,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,i){const a=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),r=await this.fetchImpl(a);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${a}`);const o=await createImageBitmap(await r.blob()),l=document.createElement("canvas");l.width=Fn,l.height=Fn;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.getImageData(0,0,Fn,Fn),d=(e.x-t.x)*Fn,u=(e.y-t.y)*Fn;for(let f=0;f<Fn;f++)for(let g=0;g<Fn;g++){const v=(f*Fn+g)*4,p=h[v]*256+h[v+1]+h[v+2]/256-tv,m=d+g,S=u+f;n[S*i+m]=p}}sampleAt(e,t,n,i,a,r){const{x:o,y:l}=pm(t,e,n),c=(o-i.x)*Fn,h=(l-i.y)*Fn,d=Math.max(0,Math.min(r-1,Math.floor(c))),u=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,d+1),g=Math.min(r-1,u+1),v=c-d,p=h-u,m=a[u*r+d],S=a[u*r+f],_=a[g*r+d],x=a[g*r+f],M=m+(S-m)*v,E=_+(x-_)*v;return M+(E-M)*p}}const rc=256,hf=3;async function ym(s,e,t,n){const i=(s.south+s.north)/2,a=(s.west+s.east)/2,r=Math.abs(gn(i,s.east,i,s.west).x),o=Math.abs(gn(s.north,a,s.south,a).z),l=fm(i,Math.max(r,o)/2),{tiles:c,bounds:h}=gm(a,i,l,hf),d=hf*rc,u=document.createElement("canvas");u.width=d,u.height=d;const f=u.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const g=c[0];await Promise.all(c.map(async m=>{const S=t(m),_=await n(S);if(!_.ok)throw new Error(`Imagery tile fetch failed (${_.status}): ${S}`);const x=await createImageBitmap(await _.blob());f.drawImage(x,(m.x-g.x)*rc,(m.y-g.y)*rc)}));const v=document.createElement("canvas");v.width=e.width,v.height=e.height;const p=v.getContext("2d");if(!p)throw new Error("2D canvas context unavailable");return p.drawImage(u,0,0,d,d,0,0,e.width,e.height),{source:v,width:e.width,height:e.height,bounds:h}}class bm{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return ym(e,t,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function nv(){return{elevation:new vm,imagery:xm()}}function xm(){return new bm}const iv=new Set,Ws="show-witness-map",ka="hide-milestones";class zn extends HTMLElement{static get observedAttributes(){return["src",Ws,ka]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Xl.create();sightingAudio=new F1;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=dm;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.shapeAt(t.x,t.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const a=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-a.left+12}px`,this.tooltip.style.top=`${e.clientY-a.top+12}px`};handleWitnessMapPointerMove=e=>{const t=this.witnessMapTargetFrom(e);if(!t){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=t.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-n.left+12}px`,this.tooltip.style.top=`${e.clientY-n.top+12}px`};handleWitnessMapClick=e=>{const t=this.witnessMapTargetFrom(e);if(t){if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(e){const t=this.witnessMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.witnessMapRenderer.hitTest((e.clientX-t.left)/t.width*this.witnessMapCanvas.width,(e.clientY-t.top)/t.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${N1}</style>${L1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new wh(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new Ls(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.toggleTimeDisplay()),t.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e===Ws&&this.applyWitnessMapDefault(),e===ka&&this.setMilestonesShown(!this.hasAttribute(ka))}async loadFromSrc(e){this.sightingData=await Kd.json(e)}get sightingData(){return B1(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=z1(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=t,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?$a(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/e,0),1)*100}%`;const a=this.said.read(n.label)??"",r=this.said.read(n.note),o=r?`${a} — ${r}`:a;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?of(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,!t)return;const n=document.createElement("b");n.textContent=this.said.read(t.label)??"";const i=this.said.read(t.note),a=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(a))}exposureInstants(e){const t=this.exposureTimes(e),n=1/t.length;return t.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(e=this.currentTime){const t=(this.currentSighting.exposure??0)*1e3;if(t<zn.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const n=Math.min(zn.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/zn.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(e,t)/zn.EXPOSURE_STEP_PX),a=Math.min(zn.MAX_TRAVEL_STEPS,Math.max(n,i)),r=[];for(let o=0;o<a;o++)r.push(e+t*o/a);return r}travelPxOver(e,t){const n=this.shapesAt(e),i=this.shapesAt(e+t);let a=0;for(const[r,o]of n){const l=i.get(r);if(!l)continue;const c=l.bounds.x+l.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=l.bounds.y+l.bounds.height/2-(o.bounds.y+o.bounds.height/2);a=Math.max(a,Math.hypot(c,h))}return a}shapeAt(e,t,n){for(const i of this.exposureTimes()){const a=this.currentSighting.timeline.hitTest(i,e,t,n);if(a)return a}}shapesAt(e){const t=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(e,n);i&&t.set(n,i)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=st.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:iv;this.canvasRenderer.setStarPoints(st.starPointsOf(this.sighting.instrument));const i=(bt(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const a=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of a)for(const[,l]of o.shapes){const c=o.share,h=c===1?l:{...l,transparency:1-(1-l.transparency)*c};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,l]of a[0].shapes)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));if(n.size>1){const o=it.groupBoundsFor([...t].filter(([l])=>n.has(l)).map(([,l])=>l.bounds));this.canvasRenderer.paintGroupHandles(o)}this.keepWitnessMapClear(a[0].shapes),this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintWitnessMap(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Jd(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new O1(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const n=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",e),this.cornerButtons.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(Ws)&&this.witnessPath!==void 0)}setWitnessMapOpen(e){this.witnessMapPanel.hidden=!e,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(e)),this.updateWitnessMapButton(),e&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const t=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=t,this.witnessMapButton.setAttribute("aria-label",t)}updateWitnessMap(){const e=this.witnessPath!==void 0;if(this.witnessPath=Wr.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!e&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const t=this.witnessPath.boundsAround(zn.WITNESS_MAP_MIN_SPAN_M,zn.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,t))&&(this.witnessMapBounds=t,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(e,t){const n=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<n&&Math.abs(e.south-t.south)<n&&Math.abs(e.west-t.west)<n&&Math.abs(e.east-t.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const e=xm(),t=this.witnessMapBounds;try{const n=await e.getImageryTexture(t,{width:zn.WITNESS_MAP_IMAGERY_PX,height:zn.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==t)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=e.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(e){if(this.witnessMapPanel.hidden)return;const t=this.witnessMapBoxPx;if(!t)return;const n=(o,l,c)=>{for(const h of e.values())if(!(h.transparency>=1)&&!(h.bounds.x+h.bounds.width<o-c||h.bounds.x>l+c)&&!(h.bounds.y>t.bottom+c||h.bounds.y+h.bounds.height<t.top-c))return!0;return!1},i=[this.canvas.width-t.width,this.canvas.width],a=[0,t.width],r=zn.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){n(i[0],i[1],r)||this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(a[0],a[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const e=this.witnessMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==t&&(this.witnessMapCanvas.width=t,this.witnessMapCanvas.height=t)}measureWitnessMapBox(){const e=this.witnessMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const n=this.canvas.width/t.width,i=this.canvas.height/t.height;this.witnessMapBoxPx={width:e.width*n,top:(e.top-t.top)*i,bottom:(e.bottom-t.top)*i}}paintWitnessMap(e){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const t=bt(this.currentSighting,e),n=this.currentSighting.instrument,i=[],a=this.currentSighting.milestones.length>0?of(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?$a(this.currentSighting.milestones):[]){const o=bt(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===a})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?Qn.of(n,this.canvas.height,t.fovDeg).halfWidthAngleDeg(st.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(e),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.milestonesButton.setAttribute("aria-pressed",String(e)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const e=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}witnessMapDecorAt(e){const t=bt(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=Ya(n,e),{lat:a,lng:r}=zi(i.eastM,-i.northM,t.lat,t.lng);return{lat:a,lng:r,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=t,this.paintWitnessMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,n=this.lookPitchDeg+e.pitchDeg;if(t===0&&n===0)return{x:0,y:0};const i=bt(this.currentSighting,this.currentTime),a=Qn.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-a.angleDegToRadiusPx(t),y:a.angleDegToRadiusPx(n)}}gaitAt(e){return Gt.of(this.currentSighting)?.offsetAt(e)??Gt.STILL}updateFullscreenButton(){const e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Xr(Vs.preferencesFor(this),hm);e!=="en"&&this.applyMessages(await V1(e))}updateTimeLabelTitles(){const e=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=this.messages.currentPosition+t,this.timeEndLabel.title=this.messages.duration+t;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(e){this.messages=e,this.updateTimeLabelTitles(),this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const e=this.currentSighting.event,t=Ka(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Eh(e.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(e){if(this.realDurationMs===void 0)return uo(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?uf(df(this.realStartMs+n)):uo(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?uo(this.currentSighting.timeline.duration):this.canShowClockTime?uf(df(this.realStartMs+this.realDurationMs)):uo(this.realDurationMs)}}function df(s){const e=new Date(s);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function uf(s){if(s.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return s.second?`${e(s.hour)}:${e(s.minute??0)}:${e(s.second)}`:`${e(s.hour)}:${e(s.minute??0)}`}function uo(s){const e=Math.round(s/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Dh="rr0-ufo";function ql(){customElements.get(Dh)||customElements.define(Dh,zn)}const sv=`
1750
1760
  <div class="stage" id="stage">
1751
1761
  <div class="frame" id="frame">
1752
1762
  <canvas id="scene-canvas"></canvas>
@@ -1856,11 +1866,11 @@ input[type=range] {
1856
1866
  * @license
1857
1867
  * Copyright 2010-2026 Three.js Authors
1858
1868
  * SPDX-License-Identifier: MIT
1859
- */const jd="185",rv=0,ff=1,ov=2,Pr=1,lv=2,Tr=3,vs=0,Vt=1,Zn=2,Si=0,Ua=1,ti=2,pf=3,mf=4,cv=5,Ns=100,hv=101,dv=102,uv=103,fv=104,pv=200,mv=201,gv=202,vv=203,Ch=204,Rh=205,yv=206,bv=207,xv=208,wv=209,Mv=210,Sv=211,_v=212,Ev=213,Tv=214,Ph=0,Lh=1,Nh=2,Za=3,Oh=4,kh=5,Uh=6,Fh=7,Qd=0,Av=1,Iv=2,_i=0,wm=1,Mm=2,Sm=3,_m=4,Em=5,Tm=6,Am=7,gf="attached",Dv="detached",Im=300,qs=301,Ja=302,oc=303,lc=304,Yl=306,Tl=1e3,vn=1001,Bh=1002,Wt=1003,Cv=1004,fo=1005,At=1006,cc=1007,Bs=1008,kn=1009,Dm=1010,Cm=1011,qr=1012,eu=1013,ni=1014,Vn=1015,cn=1016,tu=1017,nu=1018,Yr=1020,Rm=35902,Pm=35899,Lm=1021,Nm=1022,yn=1023,Wi=1026,zs=1027,iu=1028,su=1029,Ys=1030,au=1031,ru=1033,dl=33776,ul=33777,fl=33778,pl=33779,zh=35840,Hh=35841,Gh=35842,Vh=35843,Wh=36196,Xh=37492,qh=37496,Yh=37488,Kh=37489,Al=37490,$h=37491,Zh=37808,Jh=37809,jh=37810,Qh=37811,ed=37812,td=37813,nd=37814,id=37815,sd=37816,ad=37817,rd=37818,od=37819,ld=37820,cd=37821,hd=36492,dd=36494,ud=36495,fd=36283,pd=36284,Il=36285,md=36286,Dl=2300,gd=2301,hc=2302,vf=2303,yf=2400,bf=2401,xf=2402,Rv=2500,ZT=0,JT=1,jT=2,Pv=3200,Cl=0,Lv=1,us="",Nn="srgb",Rl="srgb-linear",Pl="linear",ot="srgb",na=7680,wf=519,Nv=512,Ov=513,kv=514,ou=515,Uv=516,Fv=517,lu=518,Bv=519,vd=35044,Mf="300 es",wi=2e3,Kr=2001;function zv(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Hv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function $r(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Gv(){const s=$r("canvas");return s.style.display="block",s}const Sf={};function Ll(...s){const e="THREE."+s.shift();console.log(e,...s)}function Om(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ee(...s){s=Om(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Fe(...s){s=Om(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Fa(...s){const e=s.join(" ");e in Sf||(Sf[e]=!0,Ee(...s))}function Vv(s,e,t){return new Promise(function(n,i){function a(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:n()}}setTimeout(a,t)})}const Wv={[Ph]:Lh,[Nh]:Uh,[Oh]:Fh,[Za]:kh,[Lh]:Ph,[Uh]:Nh,[Fh]:Oh,[kh]:Za};class Zs{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const a=i.indexOf(t);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let a=0,r=i.length;a<r;a++)i[a].call(this,e);e.target=null}}}const nn=["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"];let _f=1234567;const Lr=Math.PI/180,ja=180/Math.PI;function ei(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(nn[s&255]+nn[s>>8&255]+nn[s>>16&255]+nn[s>>24&255]+"-"+nn[e&255]+nn[e>>8&255]+"-"+nn[e>>16&15|64]+nn[e>>24&255]+"-"+nn[t&63|128]+nn[t>>8&255]+"-"+nn[t>>16&255]+nn[t>>24&255]+nn[n&255]+nn[n>>8&255]+nn[n>>16&255]+nn[n>>24&255]).toLowerCase()}function Ke(s,e,t){return Math.max(e,Math.min(t,s))}function cu(s,e){return(s%e+e)%e}function Xv(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function qv(s,e,t){return s!==e?(t-s)/(e-s):0}function Nr(s,e,t){return(1-t)*s+t*e}function Yv(s,e,t,n){return Nr(s,e,1-Math.exp(-t*n))}function Kv(s,e=1){return e-Math.abs(cu(s,e*2)-e)}function $v(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Zv(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Jv(s,e){return s+Math.floor(Math.random()*(e-s+1))}function jv(s,e){return s+Math.random()*(e-s)}function Qv(s){return s*(.5-Math.random())}function ey(s){s!==void 0&&(_f=s);let e=_f+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ty(s){return s*Lr}function ny(s){return s*ja}function iy(s){return(s&s-1)===0&&s!==0}function sy(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ay(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function ry(s,e,t,n,i){const a=Math.cos,r=Math.sin,o=a(t/2),l=r(t/2),c=a((e+n)/2),h=r((e+n)/2),d=a((e-n)/2),u=r((e-n)/2),f=a((n-e)/2),g=r((n-e)/2);switch(i){case"XYX":s.set(o*h,l*d,l*u,o*c);break;case"YZY":s.set(l*u,o*h,l*d,o*c);break;case"ZXZ":s.set(l*d,l*u,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*f,o*c);break;case"YXY":s.set(l*f,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*f,o*h,o*c);break;default:Ee("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Jn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function lt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const QT={DEG2RAD:Lr,RAD2DEG:ja,generateUUID:ei,clamp:Ke,euclideanModulo:cu,mapLinear:Xv,inverseLerp:qv,lerp:Nr,damp:Yv,pingpong:Kv,smoothstep:$v,smootherstep:Zv,randInt:Jv,randFloat:jv,randFloatSpread:Qv,seededRandom:ey,degToRad:ty,radToDeg:ny,isPowerOfTwo:iy,ceilPowerOfTwo:sy,floorPowerOfTwo:ay,setQuaternionFromProperEuler:ry,normalize:lt,denormalize:Jn};class Re{static{Re.prototype.isVector2=!0}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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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 n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),a=this.x-e.x,r=this.y-e.y;return this.x=a*n-r*i+e.x,this.y=a*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class bs{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,a,r,o){let l=n[i+0],c=n[i+1],h=n[i+2],d=n[i+3],u=a[r+0],f=a[r+1],g=a[r+2],v=a[r+3];if(d!==v||l!==u||c!==f||h!==g){let p=l*u+c*f+h*g+d*v;p<0&&(u=-u,f=-f,g=-g,v=-v,p=-p);let m=1-o;if(p<.9995){const S=Math.acos(p),_=Math.sin(S);m=Math.sin(m*S)/_,o=Math.sin(o*S)/_,l=l*m+u*o,c=c*m+f*o,h=h*m+g*o,d=d*m+v*o}else{l=l*m+u*o,c=c*m+f*o,h=h*m+g*o,d=d*m+v*o;const S=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=S,c*=S,h*=S,d*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,i,a,r){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],d=a[r],u=a[r+1],f=a[r+2],g=a[r+3];return e[t]=o*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-o*f,e[t+2]=c*g+h*f+o*u-l*d,e[t+3]=h*g-o*d-l*u-c*f,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,n,i){return this._x=e,this._y=t,this._z=n,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 n=e._x,i=e._y,a=e._z,r=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),d=o(a/2),u=l(n/2),f=l(i/2),g=l(a/2);switch(r){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ee("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],a=t[8],r=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(a-c)*f,this._z=(r-i)*f}else if(n>o&&n>d){const f=2*Math.sqrt(1+n-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(i+r)/f,this._z=(a+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-n-d);this._w=(a-c)/f,this._x=(i+r)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-n-o);this._w=(r-i)/f,this._x=(a+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ke(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);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 n=e._x,i=e._y,a=e._z,r=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+r*o+i*c-a*l,this._y=i*h+r*l+a*o-n*c,this._z=a*h+r*c+n*l-i*o,this._w=r*h-n*o-i*l-a*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,a=e._z,r=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,a=-a,r=-r,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+a*t,this._w=this._w*l+r*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+a*t,this._w=this._w*l+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),a=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(t),a*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}}class R{static{R.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Ef.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ef.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,a=e.elements;return this.x=a[0]*t+a[3]*n+a[6]*i,this.y=a[1]*t+a[4]*n+a[7]*i,this.z=a[2]*t+a[5]*n+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,a=e.elements,r=1/(a[3]*t+a[7]*n+a[11]*i+a[15]);return this.x=(a[0]*t+a[4]*n+a[8]*i+a[12])*r,this.y=(a[1]*t+a[5]*n+a[9]*i+a[13])*r,this.z=(a[2]*t+a[6]*n+a[10]*i+a[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,a=e.x,r=e.y,o=e.z,l=e.w,c=2*(r*i-o*n),h=2*(o*t-a*i),d=2*(a*n-r*t);return this.x=t+l*c+r*d-o*h,this.y=n+l*h+o*c-a*d,this.z=i+l*d+a*h-r*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,n=this.y,i=this.z,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i,this.y=a[1]*t+a[5]*n+a[9]*i,this.z=a[2]*t+a[6]*n+a[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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,a=e.z,r=t.x,o=t.y,l=t.z;return this.x=i*l-a*o,this.y=a*r-n*l,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return dc.copy(this).projectOnVector(e),this.sub(dc)}reflect(e){return this.sub(dc.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 n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+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,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dc=new R,Ef=new bs;class Be{static{Be.prototype.isMatrix3=!0}constructor(e,t,n,i,a,r,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,a,r,o,l,c)}set(e,t,n,i,a,r,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=a,h[5]=l,h[6]=n,h[7]=r,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,a=this.elements,r=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],v=i[0],p=i[3],m=i[6],S=i[1],_=i[4],x=i[7],M=i[2],E=i[5],I=i[8];return a[0]=r*v+o*S+l*M,a[3]=r*p+o*_+l*E,a[6]=r*m+o*x+l*I,a[1]=c*v+h*S+d*M,a[4]=c*p+h*_+d*E,a[7]=c*m+h*x+d*I,a[2]=u*v+f*S+g*M,a[5]=u*p+f*_+g*E,a[8]=u*m+f*x+g*I,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],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*r*h-t*o*c-n*a*h+n*o*l+i*a*c-i*r*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*r-o*c,u=o*l-h*a,f=c*a-r*l,g=t*d+n*u+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=d*v,e[1]=(i*c-h*n)*v,e[2]=(o*n-i*r)*v,e[3]=u*v,e[4]=(h*t-i*l)*v,e[5]=(i*a-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(r*t-n*a)*v,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,n,i,a,r,o){const l=Math.cos(a),c=Math.sin(a);return this.set(n*l,n*c,-n*(l*r+c*o)+r+e,-i*c,i*l,-i*(-c*r+l*o)+o+t,0,0,1),this}scale(e,t){return Fa("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(uc.makeScale(e,t)),this}rotate(e){return Fa("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(uc.makeRotation(-e)),this}translate(e,t){return Fa("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(uc.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const uc=new Be,Tf=new Be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Af=new Be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function oy(){const s={enabled:!0,workingColorSpace:Rl,spaces:{},convert:function(i,a,r){return this.enabled===!1||a===r||!a||!r||(this.spaces[a].transfer===ot&&(i.r=Gi(i.r),i.g=Gi(i.g),i.b=Gi(i.b)),this.spaces[a].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===ot&&(i.r=Ba(i.r),i.g=Ba(i.g),i.b=Ba(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===us?Pl:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,r){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return Fa("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return Fa("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Rl]:{primaries:e,whitePoint:n,transfer:Pl,toXYZ:Tf,fromXYZ:Af,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nn},outputColorSpaceConfig:{drawingBufferColorSpace:Nn}},[Nn]:{primaries:e,whitePoint:n,transfer:ot,toXYZ:Tf,fromXYZ:Af,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nn}}}),s}const Qe=oy();function Gi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ba(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ia;class ly{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ia===void 0&&(ia=$r("canvas")),ia.width=e.width,ia.height=e.height;const i=ia.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ia}return n.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=$r("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),a=i.data;for(let r=0;r<a.length;r++)a[r]=Gi(a[r]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Gi(t[n]/255)*255):t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ee("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cy=0;class hu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cy++}),this.uuid=ei(),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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?a.push(fc(i[r].image)):a.push(fc(i[r]))}else a=fc(i);n.url=a}return t||(e.images[this.uuid]=n),n}}function fc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?ly.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ee("Texture: Unable to serialize Texture."),{})}let hy=0;const pc=new R;class en extends Zs{constructor(e=en.DEFAULT_IMAGE,t=en.DEFAULT_MAPPING,n=vn,i=vn,a=At,r=Bs,o=yn,l=kn,c=en.DEFAULT_ANISOTROPY,h=us){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hy++}),this.uuid=ei(),this.name="",this.source=new hu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=a,this.minFilter=r,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Re(0,0),this.repeat=new Re(1,1),this.center=new Re(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Be,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(pc).x}get height(){return this.source.getSize(pc).y}get depth(){return this.source.getSize(pc).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 n=e[t];if(n===void 0){Ee(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ee(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Im)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tl:e.x=e.x-Math.floor(e.x);break;case vn:e.x=e.x<0?0:1;break;case Bh: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 Tl:e.y=e.y-Math.floor(e.y);break;case vn:e.y=e.y<0?0:1;break;case Bh: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++}}en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=Im;en.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,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,n,i){return this.x=e,this.y=t,this.z=n,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,n=this.y,i=this.z,a=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*a,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*a,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*a,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*a,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,n,i,a;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],v=l[2],p=l[6],m=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(c+1)/2,x=(f+1)/2,M=(m+1)/2,E=(h+u)/4,I=(d+v)/4,y=(g+p)/4;return _>x&&_>M?_<.01?(n=0,i=.707106781,a=.707106781):(n=Math.sqrt(_),i=E/n,a=I/n):x>M?x<.01?(n=.707106781,i=0,a=.707106781):(i=Math.sqrt(x),n=E/i,a=y/i):M<.01?(n=.707106781,i=.707106781,a=0):(a=Math.sqrt(M),n=I/a,i=y/a),this.set(n,i,a,t),this}let S=Math.sqrt((p-g)*(p-g)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(S)<.001&&(S=1),this.x=(p-g)/S,this.y=(d-v)/S,this.z=(u-h)/S,this.w=Math.acos((c+f+m-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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this.w=Ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this.w=Ke(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}}class dy extends Zs{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},a=new en(i),r=n.count;for(let o=0;o<r;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:At,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 n=0;n<this.textures.length;n++)this.textures[n].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,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,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,n=e.textures.length;t<n;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 hu(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 En extends dy{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class km extends en{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class uy extends en{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qe{static{qe.prototype.isMatrix4=!0}constructor(e,t,n,i,a,r,o,l,c,h,d,u,f,g,v,p){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,n,i,a,r,o,l,c,h,d,u,f,g,v,p)}set(e,t,n,i,a,r,o,l,c,h,d,u,f,g,v,p){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=a,m[5]=r,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=d,m[14]=u,m[3]=f,m[7]=g,m[11]=v,m[15]=p,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 qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/sa.setFromMatrixColumn(e,0).length(),a=1/sa.setFromMatrixColumn(e,1).length(),r=1/sa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*a,t[5]=n[5]*a,t[6]=n[6]*a,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,a=e.z,r=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(a),d=Math.sin(a);if(e.order==="XYZ"){const u=r*h,f=r*d,g=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+g*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=g+f*c,t[10]=r*l}else if(e.order==="YXZ"){const u=l*h,f=l*d,g=c*h,v=c*d;t[0]=u+v*o,t[4]=g*o-f,t[8]=r*c,t[1]=r*d,t[5]=r*h,t[9]=-o,t[2]=f*o-g,t[6]=v+u*o,t[10]=r*l}else if(e.order==="ZXY"){const u=l*h,f=l*d,g=c*h,v=c*d;t[0]=u-v*o,t[4]=-r*d,t[8]=g+f*o,t[1]=f+g*o,t[5]=r*h,t[9]=v-u*o,t[2]=-r*c,t[6]=o,t[10]=r*l}else if(e.order==="ZYX"){const u=r*h,f=r*d,g=o*h,v=o*d;t[0]=l*h,t[4]=g*c-f,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=r*l}else if(e.order==="YZX"){const u=r*l,f=r*c,g=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=g*d+f,t[1]=d,t[5]=r*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*d+g,t[10]=u-v*d}else if(e.order==="XZY"){const u=r*l,f=r*c,g=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=r*h,t[9]=f*d-g,t[2]=g*d-f,t[6]=o*h,t[10]=v*d+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(fy,e,py)}lookAt(e,t,n){const i=this.elements;return An.subVectors(e,t),An.lengthSq()===0&&(An.z=1),An.normalize(),ts.crossVectors(n,An),ts.lengthSq()===0&&(Math.abs(n.z)===1?An.x+=1e-4:An.z+=1e-4,An.normalize(),ts.crossVectors(n,An)),ts.normalize(),po.crossVectors(An,ts),i[0]=ts.x,i[4]=po.x,i[8]=An.x,i[1]=ts.y,i[5]=po.y,i[9]=An.y,i[2]=ts.z,i[6]=po.z,i[10]=An.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,a=this.elements,r=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],f=n[13],g=n[2],v=n[6],p=n[10],m=n[14],S=n[3],_=n[7],x=n[11],M=n[15],E=i[0],I=i[4],y=i[8],T=i[12],C=i[1],D=i[5],P=i[9],V=i[13],q=i[2],O=i[6],W=i[10],G=i[14],Z=i[3],te=i[7],Q=i[11],ie=i[15];return a[0]=r*E+o*C+l*q+c*Z,a[4]=r*I+o*D+l*O+c*te,a[8]=r*y+o*P+l*W+c*Q,a[12]=r*T+o*V+l*G+c*ie,a[1]=h*E+d*C+u*q+f*Z,a[5]=h*I+d*D+u*O+f*te,a[9]=h*y+d*P+u*W+f*Q,a[13]=h*T+d*V+u*G+f*ie,a[2]=g*E+v*C+p*q+m*Z,a[6]=g*I+v*D+p*O+m*te,a[10]=g*y+v*P+p*W+m*Q,a[14]=g*T+v*V+p*G+m*ie,a[3]=S*E+_*C+x*q+M*Z,a[7]=S*I+_*D+x*O+M*te,a[11]=S*y+_*P+x*W+M*Q,a[15]=S*T+_*V+x*G+M*ie,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],n=e[4],i=e[8],a=e[12],r=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],g=e[3],v=e[7],p=e[11],m=e[15],S=l*f-c*u,_=o*f-c*d,x=o*u-l*d,M=r*f-c*h,E=r*u-l*h,I=r*d-o*h;return t*(v*S-p*_+m*x)-n*(g*S-p*M+m*E)+i*(g*_-v*M+m*I)-a*(g*x-v*E+p*I)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],a=e[1],r=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(r*h-o*c)-n*(a*h-o*l)+i*(a*c-r*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,n){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]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],g=e[12],v=e[13],p=e[14],m=e[15],S=t*o-n*r,_=t*l-i*r,x=t*c-a*r,M=n*l-i*o,E=n*c-a*o,I=i*c-a*l,y=h*v-d*g,T=h*p-u*g,C=h*m-f*g,D=d*p-u*v,P=d*m-f*v,V=u*m-f*p,q=S*V-_*P+x*D+M*C-E*T+I*y;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/q;return e[0]=(o*V-l*P+c*D)*O,e[1]=(i*P-n*V-a*D)*O,e[2]=(v*I-p*E+m*M)*O,e[3]=(u*E-d*I-f*M)*O,e[4]=(l*C-r*V-c*T)*O,e[5]=(t*V-i*C+a*T)*O,e[6]=(p*x-g*I-m*_)*O,e[7]=(h*I-u*x+f*_)*O,e[8]=(r*P-o*C+c*y)*O,e[9]=(n*C-t*P-a*y)*O,e[10]=(g*E-v*x+m*S)*O,e[11]=(d*x-h*E-f*S)*O,e[12]=(o*T-r*D-l*y)*O,e[13]=(t*D-n*T+i*y)*O,e[14]=(v*_-g*M-p*S)*O,e[15]=(h*M-d*_+u*S)*O,this}scale(e){const t=this.elements,n=e.x,i=e.y,a=e.z;return t[0]*=n,t[4]*=i,t[8]*=a,t[1]*=n,t[5]*=i,t[9]*=a,t[2]*=n,t[6]*=i,t[10]*=a,t[3]*=n,t[7]*=i,t[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=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,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),a=1-n,r=e.x,o=e.y,l=e.z,c=a*r,h=a*o;return this.set(c*r+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*r,0,c*l-i*o,h*l+i*r,a*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,a,r){return this.set(1,n,a,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,a=t._x,r=t._y,o=t._z,l=t._w,c=a+a,h=r+r,d=o+o,u=a*c,f=a*h,g=a*d,v=r*h,p=r*d,m=o*d,S=l*c,_=l*h,x=l*d,M=n.x,E=n.y,I=n.z;return i[0]=(1-(v+m))*M,i[1]=(f+x)*M,i[2]=(g-_)*M,i[3]=0,i[4]=(f-x)*E,i[5]=(1-(u+m))*E,i[6]=(p+S)*E,i[7]=0,i[8]=(g+_)*I,i[9]=(p-S)*I,i[10]=(1-(u+v))*I,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const a=this.determinantAffine();if(a===0)return n.set(1,1,1),t.identity(),this;let r=sa.set(i[0],i[1],i[2]).length();const o=sa.set(i[4],i[5],i[6]).length(),l=sa.set(i[8],i[9],i[10]).length();a<0&&(r=-r),Xn.copy(this);const c=1/r,h=1/o,d=1/l;return Xn.elements[0]*=c,Xn.elements[1]*=c,Xn.elements[2]*=c,Xn.elements[4]*=h,Xn.elements[5]*=h,Xn.elements[6]*=h,Xn.elements[8]*=d,Xn.elements[9]*=d,Xn.elements[10]*=d,t.setFromRotationMatrix(Xn),n.x=r,n.y=o,n.z=l,this}makePerspective(e,t,n,i,a,r,o=wi,l=!1){const c=this.elements,h=2*a/(t-e),d=2*a/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let g,v;if(l)g=a/(r-a),v=r*a/(r-a);else if(o===wi)g=-(r+a)/(r-a),v=-2*r*a/(r-a);else if(o===Kr)g=-r/(r-a),v=-r*a/(r-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,a,r,o=wi,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-i),u=-(t+e)/(t-e),f=-(n+i)/(n-i);let g,v;if(l)g=1/(r-a),v=r/(r-a);else if(o===wi)g=-2/(r-a),v=-(r+a)/(r-a);else if(o===Kr)g=-1/(r-a),v=-a/(r-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sa=new R,Xn=new qe,fy=new R(0,0,0),py=new R(1,1,1),ts=new R,po=new R,An=new R,If=new qe,Df=new bs;class Xi{constructor(e=0,t=0,n=0,i=Xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,i=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){const i=e.elements,a=i[0],r=i[4],o=i[8],l=i[1],c=i[5],h=i[9],d=i[2],u=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,a)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Ke(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Ke(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Ee("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return If.makeRotationFromQuaternion(e),this.setFromRotationMatrix(If,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Df.setFromEuler(this),this.setFromQuaternion(Df,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}}Xi.DEFAULT_ORDER="XYZ";class du{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 my=0;const Cf=new R,aa=new bs,Ii=new qe,mo=new R,or=new R,gy=new R,vy=new bs,Rf=new R(1,0,0),Pf=new R(0,1,0),Lf=new R(0,0,1),Nf={type:"added"},yy={type:"removed"},ra={type:"childadded",child:null},mc={type:"childremoved",child:null};class Tt extends Zs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:my++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Tt.DEFAULT_UP.clone();const e=new R,t=new Xi,n=new bs,i=new R(1,1,1);function a(){n.setFromEuler(t,!1)}function r(){t.setFromQuaternion(n,void 0,!1)}t._onChange(a),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new qe},normalMatrix:{value:new Be}}),this.matrix=new qe,this.matrixWorld=new qe,this.matrixAutoUpdate=Tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new du,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 aa.setFromAxisAngle(e,t),this.quaternion.multiply(aa),this}rotateOnWorldAxis(e,t){return aa.setFromAxisAngle(e,t),this.quaternion.premultiply(aa),this}rotateX(e){return this.rotateOnAxis(Rf,e)}rotateY(e){return this.rotateOnAxis(Pf,e)}rotateZ(e){return this.rotateOnAxis(Lf,e)}translateOnAxis(e,t){return Cf.copy(e).applyQuaternion(this.quaternion),this.position.add(Cf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rf,e)}translateY(e){return this.translateOnAxis(Pf,e)}translateZ(e){return this.translateOnAxis(Lf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ii.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?mo.copy(e):mo.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ii.lookAt(or,mo,this.up):Ii.lookAt(mo,or,this.up),this.quaternion.setFromRotationMatrix(Ii),i&&(Ii.extractRotation(i.matrixWorld),aa.setFromRotationMatrix(Ii),this.quaternion.premultiply(aa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Fe("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(Nf),ra.child=e,this.dispatchEvent(ra),ra.child=null):Fe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(yy),mc.child=e,this.dispatchEvent(mc),mc.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),Ii.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ii.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ii),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Nf),ra.child=e,this.dispatchEvent(ra),ra.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 n=0,i=this.children.length;n<i;n++){const r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let a=0,r=i.length;a<r;a++)i[a].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,e,gy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,vy,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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,n=e.y,i=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*n-a[8]*i,a[13]+=n-a[1]*t-a[5]*n-a[9]*i,a[14]+=i-a[2]*t-a[6]*n-a[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 n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const a=this.children;for(let r=0,o=a.length;r<o;r++)a[r].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.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 a(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=a(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,h=l.length;c<h;c++){const d=l[c];a(e.shapes,d)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(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(a(e.materials,this.material[l]));i.material=o}else i.material=a(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(a(e.animations,l))}}if(t){const o=r(e.geometries),l=r(e.materials),c=r(e.textures),h=r(e.images),d=r(e.shapes),u=r(e.skeletons),f=r(e.animations),g=r(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Tt.DEFAULT_UP=new R(0,1,0);Tt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ln extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const by={type:"move"};class gc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ln,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 ln,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ln,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,a=null,r=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){r=!0;for(const v of e.hand.values()){const p=t.getJointPose(v,n),m=this._getHandJoint(c,v);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,g=.005;c.inputState.pinching&&u>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,n),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&a!==null&&(i=a),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(by)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=r!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ln;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Um={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},ns={h:0,s:0,l:0},go={h:0,s:0,l:0};function vc(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Qe.workingColorSpace){if(e=cu(e,1),t=Ke(t,0,1),n=Ke(n,0,1),t===0)this.r=this.g=this.b=n;else{const a=n<=.5?n*(1+t):n+t-n*t,r=2*n-a;this.r=vc(r,a,e+1/3),this.g=vc(r,a,e),this.b=vc(r,a,e-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(e,t=Nn){function n(a){a!==void 0&&parseFloat(a)<1&&Ee("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:Ee("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],r=a.length;if(r===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(a,16),t);Ee("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nn){const n=Um[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ee("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=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=Ba(e.r),this.g=Ba(e.g),this.b=Ba(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nn){return Qe.workingToColorSpace(sn.copy(this),e),Math.round(Ke(sn.r*255,0,255))*65536+Math.round(Ke(sn.g*255,0,255))*256+Math.round(Ke(sn.b*255,0,255))}getHexString(e=Nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(sn.copy(this),t);const n=sn.r,i=sn.g,a=sn.b,r=Math.max(n,i,a),o=Math.min(n,i,a);let l,c;const h=(o+r)/2;if(o===r)l=0,c=0;else{const d=r-o;switch(c=h<=.5?d/(r+o):d/(2-r-o),r){case n:l=(i-a)/d+(i<a?6:0);break;case i:l=(a-n)/d+2;break;case a:l=(n-i)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(sn.copy(this),t),e.r=sn.r,e.g=sn.g,e.b=sn.b,e}getStyle(e=Nn){Qe.workingToColorSpace(sn.copy(this),e);const t=sn.r,n=sn.g,i=sn.b;return e!==Nn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ns),this.setHSL(ns.h+e,ns.s+t,ns.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ns),e.getHSL(go);const n=Nr(ns.h,go.h,t),i=Nr(ns.s,go.s,t),a=Nr(ns.l,go.l,t);return this.setHSL(n,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,a=e.elements;return this.r=a[0]*t+a[3]*n+a[6]*i,this.g=a[1]*t+a[4]*n+a[7]*i,this.b=a[2]*t+a[5]*n+a[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 sn=new ve;ve.NAMES=Um;class uu{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new uu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Kl extends Tt{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 Xi,this.environmentIntensity=1,this.environmentRotation=new Xi,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 qn=new R,Di=new R,yc=new R,Ci=new R,oa=new R,la=new R,Of=new R,bc=new R,xc=new R,wc=new R,Mc=new pt,Sc=new pt,_c=new pt;class Gn{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),qn.subVectors(e,t),i.cross(qn);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,t,n,i,a){qn.subVectors(i,t),Di.subVectors(n,t),yc.subVectors(e,t);const r=qn.dot(qn),o=qn.dot(Di),l=qn.dot(yc),c=Di.dot(Di),h=Di.dot(yc),d=r*c-o*o;if(d===0)return a.set(0,0,0),null;const u=1/d,f=(c*l-o*h)*u,g=(r*h-o*l)*u;return a.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ci)===null?!1:Ci.x>=0&&Ci.y>=0&&Ci.x+Ci.y<=1}static getInterpolation(e,t,n,i,a,r,o,l){return this.getBarycoord(e,t,n,i,Ci)===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(a,Ci.x),l.addScaledVector(r,Ci.y),l.addScaledVector(o,Ci.z),l)}static getInterpolatedAttribute(e,t,n,i,a,r){return Mc.setScalar(0),Sc.setScalar(0),_c.setScalar(0),Mc.fromBufferAttribute(e,t),Sc.fromBufferAttribute(e,n),_c.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(Mc,a.x),r.addScaledVector(Sc,a.y),r.addScaledVector(_c,a.z),r}static isFrontFacing(e,t,n,i){return qn.subVectors(n,t),Di.subVectors(e,t),qn.cross(Di).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 qn.subVectors(this.c,this.b),Di.subVectors(this.a,this.b),qn.cross(Di).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Gn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,a){return Gn.getInterpolation(e,this.a,this.b,this.c,t,n,i,a)}containsPoint(e){return Gn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,a=this.c;let r,o;oa.subVectors(i,n),la.subVectors(a,n),bc.subVectors(e,n);const l=oa.dot(bc),c=la.dot(bc);if(l<=0&&c<=0)return t.copy(n);xc.subVectors(e,i);const h=oa.dot(xc),d=la.dot(xc);if(h>=0&&d<=h)return t.copy(i);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return r=l/(l-h),t.copy(n).addScaledVector(oa,r);wc.subVectors(e,a);const f=oa.dot(wc),g=la.dot(wc);if(g>=0&&f<=g)return t.copy(a);const v=f*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(la,o);const p=h*g-f*d;if(p<=0&&d-h>=0&&f-g>=0)return Of.subVectors(a,i),o=(d-h)/(d-h+(f-g)),t.copy(i).addScaledVector(Of,o);const m=1/(p+v+u);return r=v*m,o=u*m,t.copy(n).addScaledVector(oa,r).addScaledVector(la,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ti{constructor(e=new R(1/0,1/0,1/0),t=new R(-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,n=e.length;t<n;t+=3)this.expandByPoint(Yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){const a=n.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let r=0,o=a.count;r<o;r++)e.isMesh===!0?e.getVertexPosition(r,Yn):Yn.fromBufferAttribute(a,r),Yn.applyMatrix4(e.matrixWorld),this.expandByPoint(Yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),vo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),vo.copy(n.boundingBox)),vo.applyMatrix4(e.matrixWorld),this.union(vo)}const i=e.children;for(let a=0,r=i.length;a<r;a++)this.expandByObject(i[a],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,Yn),Yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),yo.subVectors(this.max,lr),ca.subVectors(e.a,lr),ha.subVectors(e.b,lr),da.subVectors(e.c,lr),is.subVectors(ha,ca),ss.subVectors(da,ha),Ss.subVectors(ca,da);let t=[0,-is.z,is.y,0,-ss.z,ss.y,0,-Ss.z,Ss.y,is.z,0,-is.x,ss.z,0,-ss.x,Ss.z,0,-Ss.x,-is.y,is.x,0,-ss.y,ss.x,0,-Ss.y,Ss.x,0];return!Ec(t,ca,ha,da,yo)||(t=[1,0,0,0,1,0,0,0,1],!Ec(t,ca,ha,da,yo))?!1:(bo.crossVectors(is,ss),t=[bo.x,bo.y,bo.z],Ec(t,ca,ha,da,yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yn).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:(Ri[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ri[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ri[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ri[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ri[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ri[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ri[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ri[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ri),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 Ri=[new R,new R,new R,new R,new R,new R,new R,new R],Yn=new R,vo=new Ti,ca=new R,ha=new R,da=new R,is=new R,ss=new R,Ss=new R,lr=new R,yo=new R,bo=new R,_s=new R;function Ec(s,e,t,n,i){for(let a=0,r=s.length-3;a<=r;a+=3){_s.fromArray(s,a);const o=i.x*Math.abs(_s.x)+i.y*Math.abs(_s.y)+i.z*Math.abs(_s.z),l=e.dot(_s),c=t.dot(_s),h=n.dot(_s);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Bi=xy();function xy(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const a=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,a[l]=c|h}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)r[l]=l<<23;r[31]=1199570944,r[32]=2147483648;for(let l=33;l<63;++l)r[l]=2147483648+(l-32<<23);r[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:a,exponentTable:r,offsetTable:o}}function wy(s){Math.abs(s)>65504&&Ee("DataUtils.toHalfFloat(): Value out of range."),s=Ke(s,-65504,65504),Bi.floatView[0]=s;const e=Bi.uint32View[0],t=e>>23&511;return Bi.baseTable[t]+((e&8388607)>>Bi.shiftTable[t])}function My(s){const e=s>>10;return Bi.uint32View[0]=Bi.mantissaTable[Bi.offsetTable[e]+(s&1023)]+Bi.exponentTable[e],Bi.floatView[0]}class ms{static toHalfFloat(e){return wy(e)}static fromHalfFloat(e){return My(e)}}const zt=new R,xo=new Re;let Sy=0;class vt extends Zs{constructor(e,t,n=!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:Sy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=vd,this.updateRanges=[],this.gpuType=Vn,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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xo.fromBufferAttribute(this,t),xo.applyMatrix3(e),this.setXY(t,xo.x,xo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=lt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Jn(t,this.array)),t}setX(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Jn(t,this.array)),t}setY(e,t){return this.normalized&&(t=lt(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=Jn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=lt(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=Jn(t,this.array)),t}setW(e,t){return this.normalized&&(t=lt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),i=lt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,a){return e*=this.itemSize,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),i=lt(i,this.array),a=lt(a,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=a,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!==vd&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Fm extends vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class fu extends vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class It extends vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const _y=new Ti,cr=new R,Tc=new R;class Yi{constructor(e=new R,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 n=this.center;t!==void 0?n.copy(t):_y.setFromPoints(e).getCenter(n);let i=0;for(let a=0,r=e.length;a<r;a++)i=Math.max(i,n.distanceToSquared(e[a]));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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(cr,i/n),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):(Tc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Tc)),this.expandByPoint(cr.copy(e.center).sub(Tc))),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 Ey=0;const Bn=new qe,Ac=new Tt,ua=new R,In=new Ti,hr=new Ti,Kt=new R;class Dt extends Zs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=ei(),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(zv(e)?fu:Fm)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){const a=new Be().getNormalMatrix(e);n.applyNormalMatrix(a),n.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 Bn.makeRotationFromQuaternion(e),this.applyMatrix4(Bn),this}rotateX(e){return Bn.makeRotationX(e),this.applyMatrix4(Bn),this}rotateY(e){return Bn.makeRotationY(e),this.applyMatrix4(Bn),this}rotateZ(e){return Bn.makeRotationZ(e),this.applyMatrix4(Bn),this}translate(e,t,n){return Bn.makeTranslation(e,t,n),this.applyMatrix4(Bn),this}scale(e,t,n){return Bn.makeScale(e,t,n),this.applyMatrix4(Bn),this}lookAt(e){return Ac.lookAt(e),Ac.updateMatrix(),this.applyMatrix4(Ac.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ua).negate(),this.translate(ua.x,ua.y,ua.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,a=e.length;i<a;i++){const r=e[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new It(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const a=e[i];t.setXYZ(i,a.x,a.y,a.z||0)}e.length>t.count&&Ee("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 Ti);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const a=t[n];In.setFromBufferAttribute(a),this.morphTargetsRelative?(Kt.addVectors(this.boundingBox.min,In.min),this.boundingBox.expandByPoint(Kt),Kt.addVectors(this.boundingBox.max,In.max),this.boundingBox.expandByPoint(Kt)):(this.boundingBox.expandByPoint(In.min),this.boundingBox.expandByPoint(In.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Fe('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 Yi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){const n=this.boundingSphere.center;if(In.setFromBufferAttribute(e),t)for(let a=0,r=t.length;a<r;a++){const o=t[a];hr.setFromBufferAttribute(o),this.morphTargetsRelative?(Kt.addVectors(In.min,hr.min),In.expandByPoint(Kt),Kt.addVectors(In.max,hr.max),In.expandByPoint(Kt)):(In.expandByPoint(hr.min),In.expandByPoint(hr.max))}In.getCenter(n);let i=0;for(let a=0,r=e.count;a<r;a++)Kt.fromBufferAttribute(e,a),i=Math.max(i,n.distanceToSquared(Kt));if(t)for(let a=0,r=t.length;a<r;a++){const o=t[a],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Kt.fromBufferAttribute(o,c),l&&(ua.fromBufferAttribute(e,c),Kt.add(ua)),i=Math.max(i,n.distanceToSquared(Kt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Fe('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){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,a=t.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==n.count)&&(r=new vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",r));const o=[],l=[];for(let y=0;y<n.count;y++)o[y]=new R,l[y]=new R;const c=new R,h=new R,d=new R,u=new Re,f=new Re,g=new Re,v=new R,p=new R;function m(y,T,C){c.fromBufferAttribute(n,y),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,C),u.fromBufferAttribute(a,y),f.fromBufferAttribute(a,T),g.fromBufferAttribute(a,C),h.sub(c),d.sub(c),f.sub(u),g.sub(u);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(d,-f.y).multiplyScalar(D),p.copy(d).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[y].add(v),o[T].add(v),o[C].add(v),l[y].add(p),l[T].add(p),l[C].add(p))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let y=0,T=S.length;y<T;++y){const C=S[y],D=C.start,P=C.count;for(let V=D,q=D+P;V<q;V+=3)m(e.getX(V+0),e.getX(V+1),e.getX(V+2))}const _=new R,x=new R,M=new R,E=new R;function I(y){M.fromBufferAttribute(i,y),E.copy(M);const T=o[y];_.copy(T),_.sub(M.multiplyScalar(M.dot(T))).normalize(),x.crossVectors(E,T);const D=x.dot(l[y])<0?-1:1;r.setXYZW(y,_.x,_.y,_.z,D)}for(let y=0,T=S.length;y<T;++y){const C=S[y],D=C.start,P=C.count;for(let V=D,q=D+P;V<q;V+=3)I(e.getX(V+0)),I(e.getX(V+1)),I(e.getX(V+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);const i=new R,a=new R,r=new R,o=new R,l=new R,c=new R,h=new R,d=new R;if(e)for(let u=0,f=e.count;u<f;u+=3){const g=e.getX(u+0),v=e.getX(u+1),p=e.getX(u+2);i.fromBufferAttribute(t,g),a.fromBufferAttribute(t,v),r.fromBufferAttribute(t,p),h.subVectors(r,a),d.subVectors(i,a),h.cross(d),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)i.fromBufferAttribute(t,u+0),a.fromBufferAttribute(t,u+1),r.fromBufferAttribute(t,u+2),h.subVectors(r,a),d.subVectors(i,a),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Kt.fromBufferAttribute(e,t),Kt.normalize(),e.setXYZ(t,Kt.x,Kt.y,Kt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let f=0,g=0;for(let v=0,p=l.length;v<p;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*h;for(let m=0;m<h;m++)u[g++]=c[f++]}return new vt(u,h,d)}if(this.index===null)return Ee("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Dt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],f=e(u,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,l=r.length;o<l;o++){const c=r[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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(i[l]=h,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));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 n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const a=e.morphAttributes;for(const c in a){const h=[],d=a[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const r=e.groups;for(let c=0,h=r.length;c<h;c++){const d=r[c];this.addGroup(d.start,d.count,d.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 Ty{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=vd,this.updateRanges=[],this.version=0,this.uuid=ei()}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,n){e*=this.stride,n*=t.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=t.array[n+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=ei()),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]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=ei()),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 hn=new R;class Nl{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=lt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=lt(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=Jn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Jn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Jn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Jn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),i=lt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=lt(t,this.array),n=lt(n,this.array),i=lt(i,this.array),a=lt(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){Ll("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[i+a])}return new vt(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 Nl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ll("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[i+a])}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 Ay=0;class Ki extends Zs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ay++}),this.uuid=ei(),this.name="",this.type="Material",this.blending=Ua,this.side=vs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ch,this.blendDst=Rh,this.blendEquation=Ns,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ve(0,0,0),this.blendAlpha=0,this.depthFunc=Za,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=na,this.stencilZFail=na,this.stencilZPass=na,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 n=e[t];if(n===void 0){Ee(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ee(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ua&&(n.blending=this.blending),this.side!==vs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ch&&(n.blendSrc=this.blendSrc),this.blendDst!==Rh&&(n.blendDst=this.blendDst),this.blendEquation!==Ns&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Za&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==na&&(n.stencilFail=this.stencilFail),this.stencilZFail!==na&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==na&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}if(t){const a=i(e.textures),r=i(e.images);a.length>0&&(n.textures=a),r.length>0&&(n.images=r)}return n}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 ve().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 n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Re().fromArray(n)}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 Re().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 n=null;if(t!==null){const i=t.length;n=new Array(i);for(let a=0;a!==i;++a)n[a]=t[a].clone()}return this.clippingPlanes=n,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 Ar extends Ki{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ve(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 fa;const dr=new R,pa=new R,ma=new R,ga=new Re,ur=new Re,Bm=new qe,wo=new R,fr=new R,Mo=new R,kf=new Re,Ic=new Re,Uf=new Re;class So extends Tt{constructor(e=new Ar){if(super(),this.isSprite=!0,this.type="Sprite",fa===void 0){fa=new Dt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Ty(t,5);fa.setIndex([0,1,2,0,2,3]),fa.setAttribute("position",new Nl(n,3,0,!1)),fa.setAttribute("uv",new Nl(n,2,3,!1))}this.geometry=fa,this.material=e,this.center=new Re(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),pa.setFromMatrixScale(this.matrixWorld),Bm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ma.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&pa.multiplyScalar(-ma.z);const n=this.material.rotation;let i,a;n!==0&&(a=Math.cos(n),i=Math.sin(n));const r=this.center;_o(wo.set(-.5,-.5,0),ma,r,pa,i,a),_o(fr.set(.5,-.5,0),ma,r,pa,i,a),_o(Mo.set(.5,.5,0),ma,r,pa,i,a),kf.set(0,0),Ic.set(1,0),Uf.set(1,1);let o=e.ray.intersectTriangle(wo,fr,Mo,!1,dr);if(o===null&&(_o(fr.set(-.5,.5,0),ma,r,pa,i,a),Ic.set(0,1),o=e.ray.intersectTriangle(wo,Mo,fr,!1,dr),o===null))return;const l=e.ray.origin.distanceTo(dr);l<e.near||l>e.far||t.push({distance:l,point:dr.clone(),uv:Gn.getInterpolation(dr,wo,fr,Mo,kf,Ic,Uf,new Re),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 _o(s,e,t,n,i,a){ga.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(ur.x=a*ga.x-i*ga.y,ur.y=i*ga.x+a*ga.y):ur.copy(ga),s.copy(e),s.x+=ur.x,s.y+=ur.y,s.applyMatrix4(Bm)}const Pi=new R,Dc=new R,Eo=new R,as=new R,Cc=new R,To=new R,Rc=new R;class jr{constructor(e=new R,t=new R(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,Pi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Pi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Pi.copy(this.origin).addScaledVector(this.direction,t),Pi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Dc.copy(e).add(t).multiplyScalar(.5),Eo.copy(t).sub(e).normalize(),as.copy(this.origin).sub(Dc);const a=e.distanceTo(t)*.5,r=-this.direction.dot(Eo),o=as.dot(this.direction),l=-as.dot(Eo),c=as.lengthSq(),h=Math.abs(1-r*r);let d,u,f,g;if(h>0)if(d=r*l-o,u=r*o-l,g=a*h,d>=0)if(u>=-g)if(u<=g){const v=1/h;d*=v,u*=v,f=d*(d+r*u+2*o)+u*(r*d+u+2*l)+c}else u=a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;else u=-a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-r*a+o)),u=d>0?-a:Math.min(Math.max(-a,-l),a),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-a,-l),a),f=u*(u+2*l)+c):(d=Math.max(0,-(r*a+o)),u=d>0?a:Math.min(Math.max(-a,-l),a),f=-d*d+u*(u+2*l)+c);else u=r>0?-a:a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(Dc).addScaledVector(Eo,u),f}intersectSphere(e,t){Pi.subVectors(e.center,this.origin);const n=Pi.dot(this.direction),i=Pi.dot(Pi)-n*n,a=e.radius*e.radius;if(i>a)return null;const r=Math.sqrt(a-i),o=n-r,l=n+r;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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,a,r,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),h>=0?(a=(e.min.y-u.y)*h,r=(e.max.y-u.y)*h):(a=(e.max.y-u.y)*h,r=(e.min.y-u.y)*h),n>r||a>i||((a>n||isNaN(n))&&(n=a),(r<i||isNaN(i))&&(i=r),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Pi)!==null}intersectTriangle(e,t,n,i,a){Cc.subVectors(t,e),To.subVectors(n,e),Rc.crossVectors(Cc,To);let r=this.direction.dot(Rc),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;as.subVectors(this.origin,e);const l=o*this.direction.dot(To.crossVectors(as,To));if(l<0)return null;const c=o*this.direction.dot(Cc.cross(as));if(c<0||l+c>r)return null;const h=-o*as.dot(Rc);return h<0?null:this.at(h/r,a)}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 Vi extends Ki{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(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 Xi,this.combine=Qd,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 Ff=new qe,Es=new jr,Ao=new Yi,Bf=new R,Io=new R,Do=new R,Co=new R,Pc=new R,Ro=new R,zf=new R,Po=new R;class Ze extends Tt{constructor(e=new Dt,t=new Vi){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,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,a=n.morphAttributes.position,r=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Ro.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const h=o[l],d=a[l];h!==0&&(Pc.fromBufferAttribute(d,e),r?Ro.addScaledVector(Pc,h):Ro.addScaledVector(Pc.sub(t),h))}t.add(Ro)}return t}raycast(e,t){const n=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ao.copy(n.boundingSphere),Ao.applyMatrix4(a),Es.copy(e.ray).recast(e.near),!(Ao.containsPoint(Es.origin)===!1&&(Es.intersectSphere(Ao,Bf)===null||Es.origin.distanceToSquared(Bf)>(e.far-e.near)**2))&&(Ff.copy(a).invert(),Es.copy(e.ray).applyMatrix4(Ff),!(n.boundingBox!==null&&Es.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Es)))}_computeIntersections(e,t,n){let i;const a=this.geometry,r=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,h=a.attributes.uv1,d=a.attributes.normal,u=a.groups,f=a.drawRange;if(o!==null)if(Array.isArray(r))for(let g=0,v=u.length;g<v;g++){const p=u[g],m=r[p.materialIndex],S=Math.max(p.start,f.start),_=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let x=S,M=_;x<M;x+=3){const E=o.getX(x),I=o.getX(x+1),y=o.getX(x+2);i=Lo(this,m,e,n,c,h,d,E,I,y),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const S=o.getX(p),_=o.getX(p+1),x=o.getX(p+2);i=Lo(this,r,e,n,c,h,d,S,_,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(r))for(let g=0,v=u.length;g<v;g++){const p=u[g],m=r[p.materialIndex],S=Math.max(p.start,f.start),_=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let x=S,M=_;x<M;x+=3){const E=x,I=x+1,y=x+2;i=Lo(this,m,e,n,c,h,d,E,I,y),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const S=p,_=p+1,x=p+2;i=Lo(this,r,e,n,c,h,d,S,_,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function Iy(s,e,t,n,i,a,r,o){let l;if(e.side===Vt?l=n.intersectTriangle(r,a,i,!0,o):l=n.intersectTriangle(i,a,r,e.side===vs,o),l===null)return null;Po.copy(o),Po.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Po);return c<t.near||c>t.far?null:{distance:c,point:Po.clone(),object:s}}function Lo(s,e,t,n,i,a,r,o,l,c){s.getVertexPosition(o,Io),s.getVertexPosition(l,Do),s.getVertexPosition(c,Co);const h=Iy(s,e,t,n,Io,Do,Co,zf);if(h){const d=new R;Gn.getBarycoord(zf,Io,Do,Co,d),i&&(h.uv=Gn.getInterpolatedAttribute(i,o,l,c,d,new Re)),a&&(h.uv1=Gn.getInterpolatedAttribute(a,o,l,c,d,new Re)),r&&(h.normal=Gn.getInterpolatedAttribute(r,o,l,c,d,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new R,materialIndex:0};Gn.getNormal(Io,Do,Co,u.normal),h.face=u,h.barycoord=d}return h}const pr=new pt,Hf=new pt,Gf=new pt,Dy=new pt,Vf=new qe,No=new R,Lc=new Yi,Wf=new qe,Nc=new jr;class eA extends Ze{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gf,this.bindMatrix=new qe,this.bindMatrixInverse=new qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ti),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,No),this.boundingBox.expandByPoint(No)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Yi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,No),this.boundingSphere.expandByPoint(No)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Lc.copy(this.boundingSphere),Lc.applyMatrix4(i),e.ray.intersectsSphere(Lc)!==!1&&(Wf.copy(i).invert(),Nc.copy(e.ray).applyMatrix4(Wf),!(this.boundingBox!==null&&Nc.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Nc)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===gf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Dv?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ee("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Hf.fromBufferAttribute(i.attributes.skinIndex,e),Gf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(pr.copy(t),t.set(0,0,0,0)):(pr.set(...t,1),t.set(0,0,0)),pr.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){const r=Gf.getComponent(a);if(r!==0){const o=Hf.getComponent(a);Vf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Dy.copy(pr).applyMatrix4(Vf),r)}}return t.isVector4&&(t.w=pr.w),t.applyMatrix4(this.bindMatrixInverse)}}class Cy extends Tt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class nr extends en{constructor(e=null,t=1,n=1,i,a,r,o,l,c=Wt,h=Wt,d,u){super(null,r,o,l,c,h,i,a,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xf=new qe,Ry=new qe;class zm{constructor(e=[],t=[]){this.uuid=ei(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ee("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let a=0,r=e.length;a<r;a++){const o=e[a]?e[a].matrixWorld:Ry;Xf.multiplyMatrices(o,t[a]),Xf.toArray(n,a*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new zm(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new nr(t,e,e,yn,Vn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const a=e.bones[n];let r=t[a];r===void 0&&(Ee("Skeleton: No bone found with UUID:",a),r=new Cy),this.bones.push(r),this.boneInverses.push(new qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,a=t.length;i<a;i++){const r=t[i];e.bones.push(r.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class qf extends vt{constructor(e,t,n,i=1){super(e,t,n),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 va=new qe,Yf=new qe,Oo=[],Kf=new Ti,Py=new qe,mr=new Ze,gr=new Yi;class tA extends Ze{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qf(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Py)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ti),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,va),Kf.copy(e.boundingBox).applyMatrix4(va),this.boundingBox.union(Kf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Yi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,va),gr.copy(e.boundingSphere).applyMatrix4(va),this.boundingSphere.union(gr)}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 n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,a=n.length+1,r=e*a+1;for(let o=0;o<n.length;o++)n[o]=i[r+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(mr.geometry=this.geometry,mr.material=this.material,mr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gr.copy(this.boundingSphere),gr.applyMatrix4(n),e.ray.intersectsSphere(gr)!==!1))for(let a=0;a<i;a++){this.getMatrixAt(a,va),Yf.multiplyMatrices(n,va),mr.matrixWorld=Yf,mr.raycast(e,Oo);for(let r=0,o=Oo.length;r<o;r++){const l=Oo[r];l.instanceId=a,l.object=this,t.push(l)}Oo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new qf(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 n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new nr(new Float32Array(i*this.count),i,this.count,iu,Vn));const a=this.morphTexture.source.data.data;let r=0;for(let c=0;c<n.length;c++)r+=n[c];const o=this.geometry.morphTargetsRelative?1:1-r,l=i*e;return a[l]=o,a.set(n,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Oc=new R,Ly=new R,Ny=new Be;class Rs{constructor(e=new R(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Oc.subVectors(n,t).cross(Ly.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,n=!0){const i=e.delta(Oc),a=this.normal.dot(i);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/a;return n===!0&&(r<0||r>1)?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Ny.getNormalMatrix(e),i=this.coplanarPoint(Oc).applyMatrix4(e),a=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(a),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 Ts=new Yi,Oy=new Re(.5,.5),ko=new R;class pu{constructor(e=new Rs,t=new Rs,n=new Rs,i=new Rs,a=new Rs,r=new Rs){this.planes=[e,t,n,i,a,r]}set(e,t,n,i,a,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(a),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=wi,n=!1){const i=this.planes,a=e.elements,r=a[0],o=a[1],l=a[2],c=a[3],h=a[4],d=a[5],u=a[6],f=a[7],g=a[8],v=a[9],p=a[10],m=a[11],S=a[12],_=a[13],x=a[14],M=a[15];if(i[0].setComponents(c-r,f-h,m-g,M-S).normalize(),i[1].setComponents(c+r,f+h,m+g,M+S).normalize(),i[2].setComponents(c+o,f+d,m+v,M+_).normalize(),i[3].setComponents(c-o,f-d,m-v,M-_).normalize(),n)i[4].setComponents(l,u,p,x).normalize(),i[5].setComponents(c-l,f-u,m-p,M-x).normalize();else if(i[4].setComponents(c-l,f-u,m-p,M-x).normalize(),t===wi)i[5].setComponents(c+l,f+u,m+p,M+x).normalize();else if(t===Kr)i[5].setComponents(l,u,p,x).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(),Ts.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ts.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ts)}intersectsSprite(e){Ts.center.set(0,0,0);const t=Oy.distanceTo(e.center);return Ts.radius=.7071067811865476+t,Ts.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ts)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ko.x=i.normal.x>0?e.max.x:e.min.x,ko.y=i.normal.y>0?e.max.y:e.min.y,ko.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ko)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ky extends Ki{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ve(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 Ol=new R,kl=new R,$f=new qe,vr=new jr,Uo=new Yi,kc=new R,Zf=new R;class Hm extends Tt{constructor(e=new Dt,t=new ky){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,n=[0];for(let i=1,a=t.count;i<a;i++)Ol.fromBufferAttribute(t,i-1),kl.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ol.distanceTo(kl);e.setAttribute("lineDistance",new It(n,1))}else Ee("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,r=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Uo.copy(n.boundingSphere),Uo.applyMatrix4(i),Uo.radius+=a,e.ray.intersectsSphere(Uo)===!1)return;$f.copy(i).invert(),vr.copy(e.ray).applyMatrix4($f);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){const f=Math.max(0,r.start),g=Math.min(h.count,r.start+r.count);for(let v=f,p=g-1;v<p;v+=c){const m=h.getX(v),S=h.getX(v+1),_=Fo(this,e,vr,l,m,S,v);_&&t.push(_)}if(this.isLineLoop){const v=h.getX(g-1),p=h.getX(f),m=Fo(this,e,vr,l,v,p,g-1);m&&t.push(m)}}else{const f=Math.max(0,r.start),g=Math.min(u.count,r.start+r.count);for(let v=f,p=g-1;v<p;v+=c){const m=Fo(this,e,vr,l,v,v+1,v);m&&t.push(m)}if(this.isLineLoop){const v=Fo(this,e,vr,l,g-1,f,g-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function Fo(s,e,t,n,i,a,r){const o=s.geometry.attributes.position;if(Ol.fromBufferAttribute(o,i),kl.fromBufferAttribute(o,a),t.distanceSqToSegment(Ol,kl,kc,Zf)>n)return;kc.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(kc);if(!(c<e.near||c>e.far))return{distance:c,point:Zf.clone().applyMatrix4(s.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:s}}const Jf=new R,jf=new R;class nA extends Hm{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,n=[];for(let i=0,a=t.count;i<a;i+=2)Jf.fromBufferAttribute(t,i),jf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jf.distanceTo(jf);e.setAttribute("lineDistance",new It(n,1))}else Ee("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class iA extends Hm{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Gm extends Ki{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ve(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 Qf=new qe,yd=new jr,Bo=new Yi,zo=new R;class ml extends Tt{constructor(e=new Dt,t=new Gm){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 n=this.geometry,i=this.matrixWorld,a=e.params.Points.threshold,r=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Bo.copy(n.boundingSphere),Bo.applyMatrix4(i),Bo.radius+=a,e.ray.intersectsSphere(Bo)===!1)return;Qf.copy(i).invert(),yd.copy(e.ray).applyMatrix4(Qf);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const u=Math.max(0,r.start),f=Math.min(c.count,r.start+r.count);for(let g=u,v=f;g<v;g++){const p=c.getX(g);zo.fromBufferAttribute(d,p),ep(zo,p,l,i,e,t,this)}}else{const u=Math.max(0,r.start),f=Math.min(d.count,r.start+r.count);for(let g=u,v=f;g<v;g++)zo.fromBufferAttribute(d,g),ep(zo,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function ep(s,e,t,n,i,a,r){const o=yd.distanceSqToPoint(s);if(o<t){const l=new R;yd.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}class Vm extends en{constructor(e=[],t=qs,n,i,a,r,o,l,c,h){super(e,t,n,i,a,r,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ai extends en{constructor(e,t,n,i,a,r,o,l,c){super(e,t,n,i,a,r,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends en{constructor(e,t,n=ni,i,a,r,o=Wt,l=Wt,c,h=Wi,d=1){if(h!==Wi&&h!==zs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,i,a,r,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hu(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 Uy extends Ks{constructor(e,t=ni,n=qs,i,a,r=Wt,o=Wt,l,c=Wi){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,i,a,r,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Wm extends en{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Wn extends Dt{constructor(e=1,t=1,n=1,i=1,a=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:a,depthSegments:r};const o=this;i=Math.floor(i),a=Math.floor(a),r=Math.floor(r);const l=[],c=[],h=[],d=[];let u=0,f=0;g("z","y","x",-1,-1,n,t,e,r,a,0),g("z","y","x",1,-1,n,t,-e,r,a,1),g("x","z","y",1,1,e,n,t,i,r,2),g("x","z","y",1,-1,e,n,-t,i,r,3),g("x","y","z",1,-1,e,t,n,i,a,4),g("x","y","z",-1,-1,e,t,-n,i,a,5),this.setIndex(l),this.setAttribute("position",new It(c,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(d,2));function g(v,p,m,S,_,x,M,E,I,y,T){const C=x/I,D=M/y,P=x/2,V=M/2,q=E/2,O=I+1,W=y+1;let G=0,Z=0;const te=new R;for(let Q=0;Q<W;Q++){const ie=Q*D-V;for(let de=0;de<O;de++){const He=de*C-P;te[v]=He*S,te[p]=ie*_,te[m]=q,c.push(te.x,te.y,te.z),te[v]=0,te[p]=0,te[m]=E>0?1:-1,h.push(te.x,te.y,te.z),d.push(de/I),d.push(1-Q/y),G+=1}}for(let Q=0;Q<y;Q++)for(let ie=0;ie<I;ie++){const de=u+ie+O*Q,He=u+ie+O*(Q+1),Je=u+(ie+1)+O*(Q+1),ze=u+(ie+1)+O*Q;l.push(de,He,ze),l.push(He,Je,ze),Z+=6}o.addGroup(f,Z,T),f+=Z,u+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mu extends Dt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const a=[],r=[],o=[],l=[],c=new R,h=new Re;r.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const f=n+d/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),r.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(r[u]/e+1)/2,h.y=(r[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)a.push(d,d+1,0);this.setIndex(a),this.setAttribute("position",new It(r,3)),this.setAttribute("normal",new It(o,3)),this.setAttribute("uv",new It(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mu(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class $i extends Dt{constructor(e=1,t=1,n=1,i=32,a=1,r=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:a,openEnded:r,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),a=Math.floor(a);const h=[],d=[],u=[],f=[];let g=0;const v=[],p=n/2;let m=0;S(),r===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new It(d,3)),this.setAttribute("normal",new It(u,3)),this.setAttribute("uv",new It(f,2));function S(){const x=new R,M=new R;let E=0;const I=(t-e)/n;for(let y=0;y<=a;y++){const T=[],C=y/a,D=C*(t-e)+e;for(let P=0;P<=i;P++){const V=P/i,q=V*l+o,O=Math.sin(q),W=Math.cos(q);M.x=D*O,M.y=-C*n+p,M.z=D*W,d.push(M.x,M.y,M.z),x.set(O,I,W).normalize(),u.push(x.x,x.y,x.z),f.push(V,1-C),T.push(g++)}v.push(T)}for(let y=0;y<i;y++)for(let T=0;T<a;T++){const C=v[T][y],D=v[T+1][y],P=v[T+1][y+1],V=v[T][y+1];(e>0||T!==0)&&(h.push(C,D,V),E+=3),(t>0||T!==a-1)&&(h.push(D,P,V),E+=3)}c.addGroup(m,E,0),m+=E}function _(x){const M=g,E=new Re,I=new R;let y=0;const T=x===!0?e:t,C=x===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,p*C,0),u.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let P=0;P<=i;P++){const q=P/i*l+o,O=Math.cos(q),W=Math.sin(q);I.x=T*W,I.y=p*C,I.z=T*O,d.push(I.x,I.y,I.z),u.push(0,C,0),E.x=O*.5+.5,E.y=W*.5*C+.5,f.push(E.x,E.y),g++}for(let P=0;P<i;P++){const V=M+P,q=D+P;x===!0?h.push(q,q+1,V):h.push(q+1,q,V),y+=3}c.addGroup(m,y,x===!0?1:2),m+=y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qr extends $i{constructor(e=1,t=1,n=32,i=1,a=!1,r=0,o=Math.PI*2){super(0,e,t,n,i,a,r,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:a,thetaStart:r,thetaLength:o}}static fromJSON(e){return new Qr(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Zi extends Dt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const a=e/2,r=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,d=e/o,u=t/l,f=[],g=[],v=[],p=[];for(let m=0;m<h;m++){const S=m*u-r;for(let _=0;_<c;_++){const x=_*d-a;g.push(x,-S,0),v.push(0,0,1),p.push(_/o),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let S=0;S<o;S++){const _=S+c*m,x=S+c*(m+1),M=S+1+c*(m+1),E=S+1+c*m;f.push(_,x,E),f.push(x,M,E)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zi(e.width,e.height,e.widthSegments,e.heightSegments)}}class bn extends Dt{constructor(e=1,t=32,n=16,i=0,a=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:a,thetaStart:r,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(r+o,Math.PI);let c=0;const h=[],d=new R,u=new R,f=[],g=[],v=[],p=[];for(let m=0;m<=n;m++){const S=[],_=m/n,x=r+_*o,M=e*Math.cos(x),E=Math.sqrt(e*e-M*M);let I=0;m===0&&r===0?I=.5/t:m===n&&l===Math.PI&&(I=-.5/t);for(let y=0;y<=t;y++){const T=y/t,C=i+T*a;d.x=-E*Math.cos(C),d.y=M,d.z=E*Math.sin(C),g.push(d.x,d.y,d.z),u.copy(d).normalize(),v.push(u.x,u.y,u.z),p.push(T+I,1-_),S.push(c++)}h.push(S)}for(let m=0;m<n;m++)for(let S=0;S<t;S++){const _=h[m][S+1],x=h[m][S],M=h[m+1][S],E=h[m+1][S+1];(m!==0||r>0)&&f.push(_,x,E),(m!==n-1||l<Math.PI)&&f.push(x,M,E)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Qa(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(tp(i))i.isRenderTargetTexture?(Ee("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(tp(i[0])){const a=[];for(let r=0,o=i.length;r<o;r++)a[r]=i[r].clone();e[t][n]=a}else e[t][n]=i.slice();else e[t][n]=i}}return e}function dn(s){const e={};for(let t=0;t<s.length;t++){const n=Qa(s[t]);for(const i in n)e[i]=n[i]}return e}function tp(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function Fy(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Xm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const By={clone:Qa,merge:dn};var zy=`void main() {
1869
+ */const jd="185",rv=0,ff=1,ov=2,Pr=1,lv=2,Tr=3,vs=0,Vt=1,Zn=2,Si=0,Ua=1,ni=2,pf=3,mf=4,cv=5,Ns=100,hv=101,dv=102,uv=103,fv=104,pv=200,mv=201,gv=202,vv=203,Ch=204,Rh=205,yv=206,bv=207,xv=208,wv=209,Mv=210,Sv=211,_v=212,Ev=213,Tv=214,Ph=0,Lh=1,Nh=2,Za=3,Oh=4,kh=5,Uh=6,Fh=7,Qd=0,Av=1,Iv=2,_i=0,wm=1,Mm=2,Sm=3,_m=4,Em=5,Tm=6,Am=7,gf="attached",Dv="detached",Im=300,qs=301,Ja=302,oc=303,lc=304,Yl=306,Tl=1e3,vn=1001,Bh=1002,Wt=1003,Cv=1004,fo=1005,At=1006,cc=1007,Bs=1008,kn=1009,Dm=1010,Cm=1011,qr=1012,eu=1013,ii=1014,Vn=1015,hn=1016,tu=1017,nu=1018,Yr=1020,Rm=35902,Pm=35899,Lm=1021,Nm=1022,yn=1023,Wi=1026,zs=1027,iu=1028,su=1029,Ys=1030,au=1031,ru=1033,dl=33776,ul=33777,fl=33778,pl=33779,zh=35840,Hh=35841,Gh=35842,Vh=35843,Wh=36196,Xh=37492,qh=37496,Yh=37488,Kh=37489,Al=37490,$h=37491,Zh=37808,Jh=37809,jh=37810,Qh=37811,ed=37812,td=37813,nd=37814,id=37815,sd=37816,ad=37817,rd=37818,od=37819,ld=37820,cd=37821,hd=36492,dd=36494,ud=36495,fd=36283,pd=36284,Il=36285,md=36286,Dl=2300,gd=2301,hc=2302,vf=2303,yf=2400,bf=2401,xf=2402,Rv=2500,ZT=0,JT=1,jT=2,Pv=3200,Cl=0,Lv=1,us="",Nn="srgb",Rl="srgb-linear",Pl="linear",lt="srgb",na=7680,wf=519,Nv=512,Ov=513,kv=514,ou=515,Uv=516,Fv=517,lu=518,Bv=519,vd=35044,Mf="300 es",wi=2e3,Kr=2001;function zv(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Hv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function $r(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Gv(){const s=$r("canvas");return s.style.display="block",s}const Sf={};function Ll(...s){const e="THREE."+s.shift();console.log(e,...s)}function Om(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ee(...s){s=Om(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Fe(...s){s=Om(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Fa(...s){const e=s.join(" ");e in Sf||(Sf[e]=!0,Ee(...s))}function Vv(s,e,t){return new Promise(function(n,i){function a(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:n()}}setTimeout(a,t)})}const Wv={[Ph]:Lh,[Nh]:Uh,[Oh]:Fh,[Za]:kh,[Lh]:Ph,[Uh]:Nh,[Fh]:Oh,[kh]:Za};class Zs{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const a=i.indexOf(t);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let a=0,r=i.length;a<r;a++)i[a].call(this,e);e.target=null}}}const sn=["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"];let _f=1234567;const Lr=Math.PI/180,ja=180/Math.PI;function ti(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(sn[s&255]+sn[s>>8&255]+sn[s>>16&255]+sn[s>>24&255]+"-"+sn[e&255]+sn[e>>8&255]+"-"+sn[e>>16&15|64]+sn[e>>24&255]+"-"+sn[t&63|128]+sn[t>>8&255]+"-"+sn[t>>16&255]+sn[t>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function Ke(s,e,t){return Math.max(e,Math.min(t,s))}function cu(s,e){return(s%e+e)%e}function Xv(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function qv(s,e,t){return s!==e?(t-s)/(e-s):0}function Nr(s,e,t){return(1-t)*s+t*e}function Yv(s,e,t,n){return Nr(s,e,1-Math.exp(-t*n))}function Kv(s,e=1){return e-Math.abs(cu(s,e*2)-e)}function $v(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Zv(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Jv(s,e){return s+Math.floor(Math.random()*(e-s+1))}function jv(s,e){return s+Math.random()*(e-s)}function Qv(s){return s*(.5-Math.random())}function ey(s){s!==void 0&&(_f=s);let e=_f+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ty(s){return s*Lr}function ny(s){return s*ja}function iy(s){return(s&s-1)===0&&s!==0}function sy(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ay(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function ry(s,e,t,n,i){const a=Math.cos,r=Math.sin,o=a(t/2),l=r(t/2),c=a((e+n)/2),h=r((e+n)/2),d=a((e-n)/2),u=r((e-n)/2),f=a((n-e)/2),g=r((n-e)/2);switch(i){case"XYX":s.set(o*h,l*d,l*u,o*c);break;case"YZY":s.set(l*u,o*h,l*d,o*c);break;case"ZXZ":s.set(l*d,l*u,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*f,o*c);break;case"YXY":s.set(l*f,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*f,o*h,o*c);break;default:Ee("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Jn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ct(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const QT={DEG2RAD:Lr,RAD2DEG:ja,generateUUID:ti,clamp:Ke,euclideanModulo:cu,mapLinear:Xv,inverseLerp:qv,lerp:Nr,damp:Yv,pingpong:Kv,smoothstep:$v,smootherstep:Zv,randInt:Jv,randFloat:jv,randFloatSpread:Qv,seededRandom:ey,degToRad:ty,radToDeg:ny,isPowerOfTwo:iy,ceilPowerOfTwo:sy,floorPowerOfTwo:ay,setQuaternionFromProperEuler:ry,normalize:ct,denormalize:Jn};class Re{static{Re.prototype.isVector2=!0}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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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 n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),a=this.x-e.x,r=this.y-e.y;return this.x=a*n-r*i+e.x,this.y=a*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class bs{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,a,r,o){let l=n[i+0],c=n[i+1],h=n[i+2],d=n[i+3],u=a[r+0],f=a[r+1],g=a[r+2],v=a[r+3];if(d!==v||l!==u||c!==f||h!==g){let p=l*u+c*f+h*g+d*v;p<0&&(u=-u,f=-f,g=-g,v=-v,p=-p);let m=1-o;if(p<.9995){const S=Math.acos(p),_=Math.sin(S);m=Math.sin(m*S)/_,o=Math.sin(o*S)/_,l=l*m+u*o,c=c*m+f*o,h=h*m+g*o,d=d*m+v*o}else{l=l*m+u*o,c=c*m+f*o,h=h*m+g*o,d=d*m+v*o;const S=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=S,c*=S,h*=S,d*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,i,a,r){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],d=a[r],u=a[r+1],f=a[r+2],g=a[r+3];return e[t]=o*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-o*f,e[t+2]=c*g+h*f+o*u-l*d,e[t+3]=h*g-o*d-l*u-c*f,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,n,i){return this._x=e,this._y=t,this._z=n,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 n=e._x,i=e._y,a=e._z,r=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),d=o(a/2),u=l(n/2),f=l(i/2),g=l(a/2);switch(r){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ee("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],a=t[8],r=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(a-c)*f,this._z=(r-i)*f}else if(n>o&&n>d){const f=2*Math.sqrt(1+n-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(i+r)/f,this._z=(a+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-n-d);this._w=(a-c)/f,this._x=(i+r)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-n-o);this._w=(r-i)/f,this._x=(a+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ke(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);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 n=e._x,i=e._y,a=e._z,r=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+r*o+i*c-a*l,this._y=i*h+r*l+a*o-n*c,this._z=a*h+r*c+n*l-i*o,this._w=r*h-n*o-i*l-a*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,a=e._z,r=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,a=-a,r=-r,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+a*t,this._w=this._w*l+r*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+a*t,this._w=this._w*l+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),a=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(t),a*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}}class R{static{R.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Ef.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ef.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,a=e.elements;return this.x=a[0]*t+a[3]*n+a[6]*i,this.y=a[1]*t+a[4]*n+a[7]*i,this.z=a[2]*t+a[5]*n+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,a=e.elements,r=1/(a[3]*t+a[7]*n+a[11]*i+a[15]);return this.x=(a[0]*t+a[4]*n+a[8]*i+a[12])*r,this.y=(a[1]*t+a[5]*n+a[9]*i+a[13])*r,this.z=(a[2]*t+a[6]*n+a[10]*i+a[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,a=e.x,r=e.y,o=e.z,l=e.w,c=2*(r*i-o*n),h=2*(o*t-a*i),d=2*(a*n-r*t);return this.x=t+l*c+r*d-o*h,this.y=n+l*h+o*c-a*d,this.z=i+l*d+a*h-r*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,n=this.y,i=this.z,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i,this.y=a[1]*t+a[5]*n+a[9]*i,this.z=a[2]*t+a[6]*n+a[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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,a=e.z,r=t.x,o=t.y,l=t.z;return this.x=i*l-a*o,this.y=a*r-n*l,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return dc.copy(this).projectOnVector(e),this.sub(dc)}reflect(e){return this.sub(dc.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 n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+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,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dc=new R,Ef=new bs;class Be{static{Be.prototype.isMatrix3=!0}constructor(e,t,n,i,a,r,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,a,r,o,l,c)}set(e,t,n,i,a,r,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=a,h[5]=l,h[6]=n,h[7]=r,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,a=this.elements,r=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],v=i[0],p=i[3],m=i[6],S=i[1],_=i[4],x=i[7],M=i[2],E=i[5],I=i[8];return a[0]=r*v+o*S+l*M,a[3]=r*p+o*_+l*E,a[6]=r*m+o*x+l*I,a[1]=c*v+h*S+d*M,a[4]=c*p+h*_+d*E,a[7]=c*m+h*x+d*I,a[2]=u*v+f*S+g*M,a[5]=u*p+f*_+g*E,a[8]=u*m+f*x+g*I,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],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*r*h-t*o*c-n*a*h+n*o*l+i*a*c-i*r*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*r-o*c,u=o*l-h*a,f=c*a-r*l,g=t*d+n*u+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=d*v,e[1]=(i*c-h*n)*v,e[2]=(o*n-i*r)*v,e[3]=u*v,e[4]=(h*t-i*l)*v,e[5]=(i*a-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(r*t-n*a)*v,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,n,i,a,r,o){const l=Math.cos(a),c=Math.sin(a);return this.set(n*l,n*c,-n*(l*r+c*o)+r+e,-i*c,i*l,-i*(-c*r+l*o)+o+t,0,0,1),this}scale(e,t){return Fa("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(uc.makeScale(e,t)),this}rotate(e){return Fa("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(uc.makeRotation(-e)),this}translate(e,t){return Fa("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(uc.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const uc=new Be,Tf=new Be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Af=new Be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function oy(){const s={enabled:!0,workingColorSpace:Rl,spaces:{},convert:function(i,a,r){return this.enabled===!1||a===r||!a||!r||(this.spaces[a].transfer===lt&&(i.r=Gi(i.r),i.g=Gi(i.g),i.b=Gi(i.b)),this.spaces[a].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===lt&&(i.r=Ba(i.r),i.g=Ba(i.g),i.b=Ba(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===us?Pl:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,r){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return Fa("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return Fa("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Rl]:{primaries:e,whitePoint:n,transfer:Pl,toXYZ:Tf,fromXYZ:Af,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nn},outputColorSpaceConfig:{drawingBufferColorSpace:Nn}},[Nn]:{primaries:e,whitePoint:n,transfer:lt,toXYZ:Tf,fromXYZ:Af,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nn}}}),s}const Qe=oy();function Gi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ba(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ia;class ly{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ia===void 0&&(ia=$r("canvas")),ia.width=e.width,ia.height=e.height;const i=ia.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ia}return n.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=$r("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),a=i.data;for(let r=0;r<a.length;r++)a[r]=Gi(a[r]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Gi(t[n]/255)*255):t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ee("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cy=0;class hu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cy++}),this.uuid=ti(),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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?a.push(fc(i[r].image)):a.push(fc(i[r]))}else a=fc(i);n.url=a}return t||(e.images[this.uuid]=n),n}}function fc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?ly.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ee("Texture: Unable to serialize Texture."),{})}let hy=0;const pc=new R;class tn extends Zs{constructor(e=tn.DEFAULT_IMAGE,t=tn.DEFAULT_MAPPING,n=vn,i=vn,a=At,r=Bs,o=yn,l=kn,c=tn.DEFAULT_ANISOTROPY,h=us){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hy++}),this.uuid=ti(),this.name="",this.source=new hu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=a,this.minFilter=r,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Re(0,0),this.repeat=new Re(1,1),this.center=new Re(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Be,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(pc).x}get height(){return this.source.getSize(pc).y}get depth(){return this.source.getSize(pc).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 n=e[t];if(n===void 0){Ee(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ee(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Im)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tl:e.x=e.x-Math.floor(e.x);break;case vn:e.x=e.x<0?0:1;break;case Bh: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 Tl:e.y=e.y-Math.floor(e.y);break;case vn:e.y=e.y<0?0:1;break;case Bh: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++}}tn.DEFAULT_IMAGE=null;tn.DEFAULT_MAPPING=Im;tn.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,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,n,i){return this.x=e,this.y=t,this.z=n,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,n=this.y,i=this.z,a=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*a,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*a,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*a,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*a,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,n,i,a;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],v=l[2],p=l[6],m=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(c+1)/2,x=(f+1)/2,M=(m+1)/2,E=(h+u)/4,I=(d+v)/4,y=(g+p)/4;return _>x&&_>M?_<.01?(n=0,i=.707106781,a=.707106781):(n=Math.sqrt(_),i=E/n,a=I/n):x>M?x<.01?(n=.707106781,i=0,a=.707106781):(i=Math.sqrt(x),n=E/i,a=y/i):M<.01?(n=.707106781,i=.707106781,a=0):(a=Math.sqrt(M),n=I/a,i=y/a),this.set(n,i,a,t),this}let S=Math.sqrt((p-g)*(p-g)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(S)<.001&&(S=1),this.x=(p-g)/S,this.y=(d-v)/S,this.z=(u-h)/S,this.w=Math.acos((c+f+m-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=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this.w=Ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this.w=Ke(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}}class dy extends Zs{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},a=new tn(i),r=n.count;for(let o=0;o<r;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:At,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 n=0;n<this.textures.length;n++)this.textures[n].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,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,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,n=e.textures.length;t<n;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 hu(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 Tn extends dy{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class km extends tn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class uy extends tn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qe{static{qe.prototype.isMatrix4=!0}constructor(e,t,n,i,a,r,o,l,c,h,d,u,f,g,v,p){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,n,i,a,r,o,l,c,h,d,u,f,g,v,p)}set(e,t,n,i,a,r,o,l,c,h,d,u,f,g,v,p){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=a,m[5]=r,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=d,m[14]=u,m[3]=f,m[7]=g,m[11]=v,m[15]=p,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 qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/sa.setFromMatrixColumn(e,0).length(),a=1/sa.setFromMatrixColumn(e,1).length(),r=1/sa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*a,t[5]=n[5]*a,t[6]=n[6]*a,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,a=e.z,r=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(a),d=Math.sin(a);if(e.order==="XYZ"){const u=r*h,f=r*d,g=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+g*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=g+f*c,t[10]=r*l}else if(e.order==="YXZ"){const u=l*h,f=l*d,g=c*h,v=c*d;t[0]=u+v*o,t[4]=g*o-f,t[8]=r*c,t[1]=r*d,t[5]=r*h,t[9]=-o,t[2]=f*o-g,t[6]=v+u*o,t[10]=r*l}else if(e.order==="ZXY"){const u=l*h,f=l*d,g=c*h,v=c*d;t[0]=u-v*o,t[4]=-r*d,t[8]=g+f*o,t[1]=f+g*o,t[5]=r*h,t[9]=v-u*o,t[2]=-r*c,t[6]=o,t[10]=r*l}else if(e.order==="ZYX"){const u=r*h,f=r*d,g=o*h,v=o*d;t[0]=l*h,t[4]=g*c-f,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=r*l}else if(e.order==="YZX"){const u=r*l,f=r*c,g=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=g*d+f,t[1]=d,t[5]=r*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*d+g,t[10]=u-v*d}else if(e.order==="XZY"){const u=r*l,f=r*c,g=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=r*h,t[9]=f*d-g,t[2]=g*d-f,t[6]=o*h,t[10]=v*d+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(fy,e,py)}lookAt(e,t,n){const i=this.elements;return In.subVectors(e,t),In.lengthSq()===0&&(In.z=1),In.normalize(),ts.crossVectors(n,In),ts.lengthSq()===0&&(Math.abs(n.z)===1?In.x+=1e-4:In.z+=1e-4,In.normalize(),ts.crossVectors(n,In)),ts.normalize(),po.crossVectors(In,ts),i[0]=ts.x,i[4]=po.x,i[8]=In.x,i[1]=ts.y,i[5]=po.y,i[9]=In.y,i[2]=ts.z,i[6]=po.z,i[10]=In.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,a=this.elements,r=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],f=n[13],g=n[2],v=n[6],p=n[10],m=n[14],S=n[3],_=n[7],x=n[11],M=n[15],E=i[0],I=i[4],y=i[8],T=i[12],C=i[1],D=i[5],P=i[9],V=i[13],q=i[2],O=i[6],W=i[10],G=i[14],Z=i[3],te=i[7],Q=i[11],ie=i[15];return a[0]=r*E+o*C+l*q+c*Z,a[4]=r*I+o*D+l*O+c*te,a[8]=r*y+o*P+l*W+c*Q,a[12]=r*T+o*V+l*G+c*ie,a[1]=h*E+d*C+u*q+f*Z,a[5]=h*I+d*D+u*O+f*te,a[9]=h*y+d*P+u*W+f*Q,a[13]=h*T+d*V+u*G+f*ie,a[2]=g*E+v*C+p*q+m*Z,a[6]=g*I+v*D+p*O+m*te,a[10]=g*y+v*P+p*W+m*Q,a[14]=g*T+v*V+p*G+m*ie,a[3]=S*E+_*C+x*q+M*Z,a[7]=S*I+_*D+x*O+M*te,a[11]=S*y+_*P+x*W+M*Q,a[15]=S*T+_*V+x*G+M*ie,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],n=e[4],i=e[8],a=e[12],r=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],g=e[3],v=e[7],p=e[11],m=e[15],S=l*f-c*u,_=o*f-c*d,x=o*u-l*d,M=r*f-c*h,E=r*u-l*h,I=r*d-o*h;return t*(v*S-p*_+m*x)-n*(g*S-p*M+m*E)+i*(g*_-v*M+m*I)-a*(g*x-v*E+p*I)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],a=e[1],r=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(r*h-o*c)-n*(a*h-o*l)+i*(a*c-r*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,n){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]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],g=e[12],v=e[13],p=e[14],m=e[15],S=t*o-n*r,_=t*l-i*r,x=t*c-a*r,M=n*l-i*o,E=n*c-a*o,I=i*c-a*l,y=h*v-d*g,T=h*p-u*g,C=h*m-f*g,D=d*p-u*v,P=d*m-f*v,V=u*m-f*p,q=S*V-_*P+x*D+M*C-E*T+I*y;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/q;return e[0]=(o*V-l*P+c*D)*O,e[1]=(i*P-n*V-a*D)*O,e[2]=(v*I-p*E+m*M)*O,e[3]=(u*E-d*I-f*M)*O,e[4]=(l*C-r*V-c*T)*O,e[5]=(t*V-i*C+a*T)*O,e[6]=(p*x-g*I-m*_)*O,e[7]=(h*I-u*x+f*_)*O,e[8]=(r*P-o*C+c*y)*O,e[9]=(n*C-t*P-a*y)*O,e[10]=(g*E-v*x+m*S)*O,e[11]=(d*x-h*E-f*S)*O,e[12]=(o*T-r*D-l*y)*O,e[13]=(t*D-n*T+i*y)*O,e[14]=(v*_-g*M-p*S)*O,e[15]=(h*M-d*_+u*S)*O,this}scale(e){const t=this.elements,n=e.x,i=e.y,a=e.z;return t[0]*=n,t[4]*=i,t[8]*=a,t[1]*=n,t[5]*=i,t[9]*=a,t[2]*=n,t[6]*=i,t[10]*=a,t[3]*=n,t[7]*=i,t[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=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,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),a=1-n,r=e.x,o=e.y,l=e.z,c=a*r,h=a*o;return this.set(c*r+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*r,0,c*l-i*o,h*l+i*r,a*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,a,r){return this.set(1,n,a,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,a=t._x,r=t._y,o=t._z,l=t._w,c=a+a,h=r+r,d=o+o,u=a*c,f=a*h,g=a*d,v=r*h,p=r*d,m=o*d,S=l*c,_=l*h,x=l*d,M=n.x,E=n.y,I=n.z;return i[0]=(1-(v+m))*M,i[1]=(f+x)*M,i[2]=(g-_)*M,i[3]=0,i[4]=(f-x)*E,i[5]=(1-(u+m))*E,i[6]=(p+S)*E,i[7]=0,i[8]=(g+_)*I,i[9]=(p-S)*I,i[10]=(1-(u+v))*I,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const a=this.determinantAffine();if(a===0)return n.set(1,1,1),t.identity(),this;let r=sa.set(i[0],i[1],i[2]).length();const o=sa.set(i[4],i[5],i[6]).length(),l=sa.set(i[8],i[9],i[10]).length();a<0&&(r=-r),Xn.copy(this);const c=1/r,h=1/o,d=1/l;return Xn.elements[0]*=c,Xn.elements[1]*=c,Xn.elements[2]*=c,Xn.elements[4]*=h,Xn.elements[5]*=h,Xn.elements[6]*=h,Xn.elements[8]*=d,Xn.elements[9]*=d,Xn.elements[10]*=d,t.setFromRotationMatrix(Xn),n.x=r,n.y=o,n.z=l,this}makePerspective(e,t,n,i,a,r,o=wi,l=!1){const c=this.elements,h=2*a/(t-e),d=2*a/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let g,v;if(l)g=a/(r-a),v=r*a/(r-a);else if(o===wi)g=-(r+a)/(r-a),v=-2*r*a/(r-a);else if(o===Kr)g=-r/(r-a),v=-r*a/(r-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,a,r,o=wi,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-i),u=-(t+e)/(t-e),f=-(n+i)/(n-i);let g,v;if(l)g=1/(r-a),v=r/(r-a);else if(o===wi)g=-2/(r-a),v=-(r+a)/(r-a);else if(o===Kr)g=-1/(r-a),v=-a/(r-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sa=new R,Xn=new qe,fy=new R(0,0,0),py=new R(1,1,1),ts=new R,po=new R,In=new R,If=new qe,Df=new bs;class Xi{constructor(e=0,t=0,n=0,i=Xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,i=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){const i=e.elements,a=i[0],r=i[4],o=i[8],l=i[1],c=i[5],h=i[9],d=i[2],u=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,a)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Ke(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Ke(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Ee("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return If.makeRotationFromQuaternion(e),this.setFromRotationMatrix(If,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Df.setFromEuler(this),this.setFromQuaternion(Df,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}}Xi.DEFAULT_ORDER="XYZ";class du{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 my=0;const Cf=new R,aa=new bs,Ii=new qe,mo=new R,or=new R,gy=new R,vy=new bs,Rf=new R(1,0,0),Pf=new R(0,1,0),Lf=new R(0,0,1),Nf={type:"added"},yy={type:"removed"},ra={type:"childadded",child:null},mc={type:"childremoved",child:null};class Tt extends Zs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:my++}),this.uuid=ti(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Tt.DEFAULT_UP.clone();const e=new R,t=new Xi,n=new bs,i=new R(1,1,1);function a(){n.setFromEuler(t,!1)}function r(){t.setFromQuaternion(n,void 0,!1)}t._onChange(a),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new qe},normalMatrix:{value:new Be}}),this.matrix=new qe,this.matrixWorld=new qe,this.matrixAutoUpdate=Tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new du,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 aa.setFromAxisAngle(e,t),this.quaternion.multiply(aa),this}rotateOnWorldAxis(e,t){return aa.setFromAxisAngle(e,t),this.quaternion.premultiply(aa),this}rotateX(e){return this.rotateOnAxis(Rf,e)}rotateY(e){return this.rotateOnAxis(Pf,e)}rotateZ(e){return this.rotateOnAxis(Lf,e)}translateOnAxis(e,t){return Cf.copy(e).applyQuaternion(this.quaternion),this.position.add(Cf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rf,e)}translateY(e){return this.translateOnAxis(Pf,e)}translateZ(e){return this.translateOnAxis(Lf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ii.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?mo.copy(e):mo.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ii.lookAt(or,mo,this.up):Ii.lookAt(mo,or,this.up),this.quaternion.setFromRotationMatrix(Ii),i&&(Ii.extractRotation(i.matrixWorld),aa.setFromRotationMatrix(Ii),this.quaternion.premultiply(aa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Fe("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(Nf),ra.child=e,this.dispatchEvent(ra),ra.child=null):Fe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(yy),mc.child=e,this.dispatchEvent(mc),mc.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),Ii.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ii.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ii),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Nf),ra.child=e,this.dispatchEvent(ra),ra.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 n=0,i=this.children.length;n<i;n++){const r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let a=0,r=i.length;a<r;a++)i[a].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,e,gy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,vy,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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,n=e.y,i=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*n-a[8]*i,a[13]+=n-a[1]*t-a[5]*n-a[9]*i,a[14]+=i-a[2]*t-a[6]*n-a[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 n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const a=this.children;for(let r=0,o=a.length;r<o;r++)a[r].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.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 a(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=a(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,h=l.length;c<h;c++){const d=l[c];a(e.shapes,d)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(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(a(e.materials,this.material[l]));i.material=o}else i.material=a(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(a(e.animations,l))}}if(t){const o=r(e.geometries),l=r(e.materials),c=r(e.textures),h=r(e.images),d=r(e.shapes),u=r(e.skeletons),f=r(e.animations),g=r(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Tt.DEFAULT_UP=new R(0,1,0);Tt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class cn extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const by={type:"move"};class gc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cn,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 cn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new cn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,a=null,r=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){r=!0;for(const v of e.hand.values()){const p=t.getJointPose(v,n),m=this._getHandJoint(c,v);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,g=.005;c.inputState.pinching&&u>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,n),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&a!==null&&(i=a),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(by)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=r!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new cn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Um={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},ns={h:0,s:0,l:0},go={h:0,s:0,l:0};function vc(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Qe.workingColorSpace){if(e=cu(e,1),t=Ke(t,0,1),n=Ke(n,0,1),t===0)this.r=this.g=this.b=n;else{const a=n<=.5?n*(1+t):n+t-n*t,r=2*n-a;this.r=vc(r,a,e+1/3),this.g=vc(r,a,e),this.b=vc(r,a,e-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(e,t=Nn){function n(a){a!==void 0&&parseFloat(a)<1&&Ee("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:Ee("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],r=a.length;if(r===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(a,16),t);Ee("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nn){const n=Um[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ee("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=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=Ba(e.r),this.g=Ba(e.g),this.b=Ba(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nn){return Qe.workingToColorSpace(an.copy(this),e),Math.round(Ke(an.r*255,0,255))*65536+Math.round(Ke(an.g*255,0,255))*256+Math.round(Ke(an.b*255,0,255))}getHexString(e=Nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(an.copy(this),t);const n=an.r,i=an.g,a=an.b,r=Math.max(n,i,a),o=Math.min(n,i,a);let l,c;const h=(o+r)/2;if(o===r)l=0,c=0;else{const d=r-o;switch(c=h<=.5?d/(r+o):d/(2-r-o),r){case n:l=(i-a)/d+(i<a?6:0);break;case i:l=(a-n)/d+2;break;case a:l=(n-i)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e=Nn){Qe.workingToColorSpace(an.copy(this),e);const t=an.r,n=an.g,i=an.b;return e!==Nn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ns),this.setHSL(ns.h+e,ns.s+t,ns.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ns),e.getHSL(go);const n=Nr(ns.h,go.h,t),i=Nr(ns.s,go.s,t),a=Nr(ns.l,go.l,t);return this.setHSL(n,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,a=e.elements;return this.r=a[0]*t+a[3]*n+a[6]*i,this.g=a[1]*t+a[4]*n+a[7]*i,this.b=a[2]*t+a[5]*n+a[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 an=new ve;ve.NAMES=Um;class uu{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new uu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Kl extends Tt{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 Xi,this.environmentIntensity=1,this.environmentRotation=new Xi,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 qn=new R,Di=new R,yc=new R,Ci=new R,oa=new R,la=new R,Of=new R,bc=new R,xc=new R,wc=new R,Mc=new ft,Sc=new ft,_c=new ft;class Gn{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),qn.subVectors(e,t),i.cross(qn);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,t,n,i,a){qn.subVectors(i,t),Di.subVectors(n,t),yc.subVectors(e,t);const r=qn.dot(qn),o=qn.dot(Di),l=qn.dot(yc),c=Di.dot(Di),h=Di.dot(yc),d=r*c-o*o;if(d===0)return a.set(0,0,0),null;const u=1/d,f=(c*l-o*h)*u,g=(r*h-o*l)*u;return a.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ci)===null?!1:Ci.x>=0&&Ci.y>=0&&Ci.x+Ci.y<=1}static getInterpolation(e,t,n,i,a,r,o,l){return this.getBarycoord(e,t,n,i,Ci)===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(a,Ci.x),l.addScaledVector(r,Ci.y),l.addScaledVector(o,Ci.z),l)}static getInterpolatedAttribute(e,t,n,i,a,r){return Mc.setScalar(0),Sc.setScalar(0),_c.setScalar(0),Mc.fromBufferAttribute(e,t),Sc.fromBufferAttribute(e,n),_c.fromBufferAttribute(e,i),r.setScalar(0),r.addScaledVector(Mc,a.x),r.addScaledVector(Sc,a.y),r.addScaledVector(_c,a.z),r}static isFrontFacing(e,t,n,i){return qn.subVectors(n,t),Di.subVectors(e,t),qn.cross(Di).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 qn.subVectors(this.c,this.b),Di.subVectors(this.a,this.b),qn.cross(Di).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Gn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,a){return Gn.getInterpolation(e,this.a,this.b,this.c,t,n,i,a)}containsPoint(e){return Gn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,a=this.c;let r,o;oa.subVectors(i,n),la.subVectors(a,n),bc.subVectors(e,n);const l=oa.dot(bc),c=la.dot(bc);if(l<=0&&c<=0)return t.copy(n);xc.subVectors(e,i);const h=oa.dot(xc),d=la.dot(xc);if(h>=0&&d<=h)return t.copy(i);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return r=l/(l-h),t.copy(n).addScaledVector(oa,r);wc.subVectors(e,a);const f=oa.dot(wc),g=la.dot(wc);if(g>=0&&f<=g)return t.copy(a);const v=f*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(la,o);const p=h*g-f*d;if(p<=0&&d-h>=0&&f-g>=0)return Of.subVectors(a,i),o=(d-h)/(d-h+(f-g)),t.copy(i).addScaledVector(Of,o);const m=1/(p+v+u);return r=v*m,o=u*m,t.copy(n).addScaledVector(oa,r).addScaledVector(la,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ti{constructor(e=new R(1/0,1/0,1/0),t=new R(-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,n=e.length;t<n;t+=3)this.expandByPoint(Yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){const a=n.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let r=0,o=a.count;r<o;r++)e.isMesh===!0?e.getVertexPosition(r,Yn):Yn.fromBufferAttribute(a,r),Yn.applyMatrix4(e.matrixWorld),this.expandByPoint(Yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),vo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),vo.copy(n.boundingBox)),vo.applyMatrix4(e.matrixWorld),this.union(vo)}const i=e.children;for(let a=0,r=i.length;a<r;a++)this.expandByObject(i[a],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,Yn),Yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),yo.subVectors(this.max,lr),ca.subVectors(e.a,lr),ha.subVectors(e.b,lr),da.subVectors(e.c,lr),is.subVectors(ha,ca),ss.subVectors(da,ha),Ss.subVectors(ca,da);let t=[0,-is.z,is.y,0,-ss.z,ss.y,0,-Ss.z,Ss.y,is.z,0,-is.x,ss.z,0,-ss.x,Ss.z,0,-Ss.x,-is.y,is.x,0,-ss.y,ss.x,0,-Ss.y,Ss.x,0];return!Ec(t,ca,ha,da,yo)||(t=[1,0,0,0,1,0,0,0,1],!Ec(t,ca,ha,da,yo))?!1:(bo.crossVectors(is,ss),t=[bo.x,bo.y,bo.z],Ec(t,ca,ha,da,yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yn).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:(Ri[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ri[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ri[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ri[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ri[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ri[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ri[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ri[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ri),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 Ri=[new R,new R,new R,new R,new R,new R,new R,new R],Yn=new R,vo=new Ti,ca=new R,ha=new R,da=new R,is=new R,ss=new R,Ss=new R,lr=new R,yo=new R,bo=new R,_s=new R;function Ec(s,e,t,n,i){for(let a=0,r=s.length-3;a<=r;a+=3){_s.fromArray(s,a);const o=i.x*Math.abs(_s.x)+i.y*Math.abs(_s.y)+i.z*Math.abs(_s.z),l=e.dot(_s),c=t.dot(_s),h=n.dot(_s);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Bi=xy();function xy(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const a=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,a[l]=c|h}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)r[l]=l<<23;r[31]=1199570944,r[32]=2147483648;for(let l=33;l<63;++l)r[l]=2147483648+(l-32<<23);r[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:a,exponentTable:r,offsetTable:o}}function wy(s){Math.abs(s)>65504&&Ee("DataUtils.toHalfFloat(): Value out of range."),s=Ke(s,-65504,65504),Bi.floatView[0]=s;const e=Bi.uint32View[0],t=e>>23&511;return Bi.baseTable[t]+((e&8388607)>>Bi.shiftTable[t])}function My(s){const e=s>>10;return Bi.uint32View[0]=Bi.mantissaTable[Bi.offsetTable[e]+(s&1023)]+Bi.exponentTable[e],Bi.floatView[0]}class ms{static toHalfFloat(e){return wy(e)}static fromHalfFloat(e){return My(e)}}const zt=new R,xo=new Re;let Sy=0;class gt extends Zs{constructor(e,t,n=!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:Sy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=vd,this.updateRanges=[],this.gpuType=Vn,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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xo.fromBufferAttribute(this,t),xo.applyMatrix3(e),this.setXY(t,xo.x,xo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ct(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Jn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ct(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Jn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ct(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=Jn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ct(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=Jn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ct(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array),i=ct(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,a){return e*=this.itemSize,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array),i=ct(i,this.array),a=ct(a,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=a,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!==vd&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Fm extends gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class fu extends gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class It extends gt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const _y=new Ti,cr=new R,Tc=new R;class Yi{constructor(e=new R,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 n=this.center;t!==void 0?n.copy(t):_y.setFromPoints(e).getCenter(n);let i=0;for(let a=0,r=e.length;a<r;a++)i=Math.max(i,n.distanceToSquared(e[a]));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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(cr,i/n),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):(Tc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Tc)),this.expandByPoint(cr.copy(e.center).sub(Tc))),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 Ey=0;const Bn=new qe,Ac=new Tt,ua=new R,Dn=new Ti,hr=new Ti,Kt=new R;class Dt extends Zs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=ti(),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(zv(e)?fu:Fm)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){const a=new Be().getNormalMatrix(e);n.applyNormalMatrix(a),n.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 Bn.makeRotationFromQuaternion(e),this.applyMatrix4(Bn),this}rotateX(e){return Bn.makeRotationX(e),this.applyMatrix4(Bn),this}rotateY(e){return Bn.makeRotationY(e),this.applyMatrix4(Bn),this}rotateZ(e){return Bn.makeRotationZ(e),this.applyMatrix4(Bn),this}translate(e,t,n){return Bn.makeTranslation(e,t,n),this.applyMatrix4(Bn),this}scale(e,t,n){return Bn.makeScale(e,t,n),this.applyMatrix4(Bn),this}lookAt(e){return Ac.lookAt(e),Ac.updateMatrix(),this.applyMatrix4(Ac.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ua).negate(),this.translate(ua.x,ua.y,ua.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,a=e.length;i<a;i++){const r=e[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new It(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const a=e[i];t.setXYZ(i,a.x,a.y,a.z||0)}e.length>t.count&&Ee("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 Ti);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const a=t[n];Dn.setFromBufferAttribute(a),this.morphTargetsRelative?(Kt.addVectors(this.boundingBox.min,Dn.min),this.boundingBox.expandByPoint(Kt),Kt.addVectors(this.boundingBox.max,Dn.max),this.boundingBox.expandByPoint(Kt)):(this.boundingBox.expandByPoint(Dn.min),this.boundingBox.expandByPoint(Dn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Fe('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 Yi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){const n=this.boundingSphere.center;if(Dn.setFromBufferAttribute(e),t)for(let a=0,r=t.length;a<r;a++){const o=t[a];hr.setFromBufferAttribute(o),this.morphTargetsRelative?(Kt.addVectors(Dn.min,hr.min),Dn.expandByPoint(Kt),Kt.addVectors(Dn.max,hr.max),Dn.expandByPoint(Kt)):(Dn.expandByPoint(hr.min),Dn.expandByPoint(hr.max))}Dn.getCenter(n);let i=0;for(let a=0,r=e.count;a<r;a++)Kt.fromBufferAttribute(e,a),i=Math.max(i,n.distanceToSquared(Kt));if(t)for(let a=0,r=t.length;a<r;a++){const o=t[a],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Kt.fromBufferAttribute(o,c),l&&(ua.fromBufferAttribute(e,c),Kt.add(ua)),i=Math.max(i,n.distanceToSquared(Kt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Fe('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){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,a=t.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==n.count)&&(r=new gt(new Float32Array(4*n.count),4),this.setAttribute("tangent",r));const o=[],l=[];for(let y=0;y<n.count;y++)o[y]=new R,l[y]=new R;const c=new R,h=new R,d=new R,u=new Re,f=new Re,g=new Re,v=new R,p=new R;function m(y,T,C){c.fromBufferAttribute(n,y),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,C),u.fromBufferAttribute(a,y),f.fromBufferAttribute(a,T),g.fromBufferAttribute(a,C),h.sub(c),d.sub(c),f.sub(u),g.sub(u);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(d,-f.y).multiplyScalar(D),p.copy(d).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[y].add(v),o[T].add(v),o[C].add(v),l[y].add(p),l[T].add(p),l[C].add(p))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let y=0,T=S.length;y<T;++y){const C=S[y],D=C.start,P=C.count;for(let V=D,q=D+P;V<q;V+=3)m(e.getX(V+0),e.getX(V+1),e.getX(V+2))}const _=new R,x=new R,M=new R,E=new R;function I(y){M.fromBufferAttribute(i,y),E.copy(M);const T=o[y];_.copy(T),_.sub(M.multiplyScalar(M.dot(T))).normalize(),x.crossVectors(E,T);const D=x.dot(l[y])<0?-1:1;r.setXYZW(y,_.x,_.y,_.z,D)}for(let y=0,T=S.length;y<T;++y){const C=S[y],D=C.start,P=C.count;for(let V=D,q=D+P;V<q;V+=3)I(e.getX(V+0)),I(e.getX(V+1)),I(e.getX(V+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);const i=new R,a=new R,r=new R,o=new R,l=new R,c=new R,h=new R,d=new R;if(e)for(let u=0,f=e.count;u<f;u+=3){const g=e.getX(u+0),v=e.getX(u+1),p=e.getX(u+2);i.fromBufferAttribute(t,g),a.fromBufferAttribute(t,v),r.fromBufferAttribute(t,p),h.subVectors(r,a),d.subVectors(i,a),h.cross(d),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)i.fromBufferAttribute(t,u+0),a.fromBufferAttribute(t,u+1),r.fromBufferAttribute(t,u+2),h.subVectors(r,a),d.subVectors(i,a),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Kt.fromBufferAttribute(e,t),Kt.normalize(),e.setXYZ(t,Kt.x,Kt.y,Kt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let f=0,g=0;for(let v=0,p=l.length;v<p;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*h;for(let m=0;m<h;m++)u[g++]=c[f++]}return new gt(u,h,d)}if(this.index===null)return Ee("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Dt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],f=e(u,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,l=r.length;o<l;o++){const c=r[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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(i[l]=h,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));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 n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const a=e.morphAttributes;for(const c in a){const h=[],d=a[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const r=e.groups;for(let c=0,h=r.length;c<h;c++){const d=r[c];this.addGroup(d.start,d.count,d.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 Ty{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=vd,this.updateRanges=[],this.version=0,this.uuid=ti()}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,n){e*=this.stride,n*=t.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=t.array[n+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=ti()),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]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=ti()),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 dn=new R;class Nl{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)dn.fromBufferAttribute(this,t),dn.applyMatrix4(e),this.setXYZ(t,dn.x,dn.y,dn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)dn.fromBufferAttribute(this,t),dn.applyNormalMatrix(e),this.setXYZ(t,dn.x,dn.y,dn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)dn.fromBufferAttribute(this,t),dn.transformDirection(e),this.setXYZ(t,dn.x,dn.y,dn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ct(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ct(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ct(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ct(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ct(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=Jn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Jn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Jn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Jn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array),i=ct(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=ct(t,this.array),n=ct(n,this.array),i=ct(i,this.array),a=ct(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){Ll("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[i+a])}return new gt(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 Nl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ll("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[i+a])}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 Ay=0;class Ki extends Zs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ay++}),this.uuid=ti(),this.name="",this.type="Material",this.blending=Ua,this.side=vs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ch,this.blendDst=Rh,this.blendEquation=Ns,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ve(0,0,0),this.blendAlpha=0,this.depthFunc=Za,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=na,this.stencilZFail=na,this.stencilZPass=na,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 n=e[t];if(n===void 0){Ee(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ee(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ua&&(n.blending=this.blending),this.side!==vs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ch&&(n.blendSrc=this.blendSrc),this.blendDst!==Rh&&(n.blendDst=this.blendDst),this.blendEquation!==Ns&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Za&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==na&&(n.stencilFail=this.stencilFail),this.stencilZFail!==na&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==na&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}if(t){const a=i(e.textures),r=i(e.images);a.length>0&&(n.textures=a),r.length>0&&(n.images=r)}return n}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 ve().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 n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Re().fromArray(n)}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 Re().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 n=null;if(t!==null){const i=t.length;n=new Array(i);for(let a=0;a!==i;++a)n[a]=t[a].clone()}return this.clippingPlanes=n,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 Ar extends Ki{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ve(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 fa;const dr=new R,pa=new R,ma=new R,ga=new Re,ur=new Re,Bm=new qe,wo=new R,fr=new R,Mo=new R,kf=new Re,Ic=new Re,Uf=new Re;class So extends Tt{constructor(e=new Ar){if(super(),this.isSprite=!0,this.type="Sprite",fa===void 0){fa=new Dt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Ty(t,5);fa.setIndex([0,1,2,0,2,3]),fa.setAttribute("position",new Nl(n,3,0,!1)),fa.setAttribute("uv",new Nl(n,2,3,!1))}this.geometry=fa,this.material=e,this.center=new Re(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),pa.setFromMatrixScale(this.matrixWorld),Bm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ma.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&pa.multiplyScalar(-ma.z);const n=this.material.rotation;let i,a;n!==0&&(a=Math.cos(n),i=Math.sin(n));const r=this.center;_o(wo.set(-.5,-.5,0),ma,r,pa,i,a),_o(fr.set(.5,-.5,0),ma,r,pa,i,a),_o(Mo.set(.5,.5,0),ma,r,pa,i,a),kf.set(0,0),Ic.set(1,0),Uf.set(1,1);let o=e.ray.intersectTriangle(wo,fr,Mo,!1,dr);if(o===null&&(_o(fr.set(-.5,.5,0),ma,r,pa,i,a),Ic.set(0,1),o=e.ray.intersectTriangle(wo,Mo,fr,!1,dr),o===null))return;const l=e.ray.origin.distanceTo(dr);l<e.near||l>e.far||t.push({distance:l,point:dr.clone(),uv:Gn.getInterpolation(dr,wo,fr,Mo,kf,Ic,Uf,new Re),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 _o(s,e,t,n,i,a){ga.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(ur.x=a*ga.x-i*ga.y,ur.y=i*ga.x+a*ga.y):ur.copy(ga),s.copy(e),s.x+=ur.x,s.y+=ur.y,s.applyMatrix4(Bm)}const Pi=new R,Dc=new R,Eo=new R,as=new R,Cc=new R,To=new R,Rc=new R;class jr{constructor(e=new R,t=new R(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,Pi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Pi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Pi.copy(this.origin).addScaledVector(this.direction,t),Pi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Dc.copy(e).add(t).multiplyScalar(.5),Eo.copy(t).sub(e).normalize(),as.copy(this.origin).sub(Dc);const a=e.distanceTo(t)*.5,r=-this.direction.dot(Eo),o=as.dot(this.direction),l=-as.dot(Eo),c=as.lengthSq(),h=Math.abs(1-r*r);let d,u,f,g;if(h>0)if(d=r*l-o,u=r*o-l,g=a*h,d>=0)if(u>=-g)if(u<=g){const v=1/h;d*=v,u*=v,f=d*(d+r*u+2*o)+u*(r*d+u+2*l)+c}else u=a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;else u=-a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-r*a+o)),u=d>0?-a:Math.min(Math.max(-a,-l),a),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-a,-l),a),f=u*(u+2*l)+c):(d=Math.max(0,-(r*a+o)),u=d>0?a:Math.min(Math.max(-a,-l),a),f=-d*d+u*(u+2*l)+c);else u=r>0?-a:a,d=Math.max(0,-(r*u+o)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(Dc).addScaledVector(Eo,u),f}intersectSphere(e,t){Pi.subVectors(e.center,this.origin);const n=Pi.dot(this.direction),i=Pi.dot(Pi)-n*n,a=e.radius*e.radius;if(i>a)return null;const r=Math.sqrt(a-i),o=n-r,l=n+r;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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,a,r,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),h>=0?(a=(e.min.y-u.y)*h,r=(e.max.y-u.y)*h):(a=(e.max.y-u.y)*h,r=(e.min.y-u.y)*h),n>r||a>i||((a>n||isNaN(n))&&(n=a),(r<i||isNaN(i))&&(i=r),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Pi)!==null}intersectTriangle(e,t,n,i,a){Cc.subVectors(t,e),To.subVectors(n,e),Rc.crossVectors(Cc,To);let r=this.direction.dot(Rc),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;as.subVectors(this.origin,e);const l=o*this.direction.dot(To.crossVectors(as,To));if(l<0)return null;const c=o*this.direction.dot(Cc.cross(as));if(c<0||l+c>r)return null;const h=-o*as.dot(Rc);return h<0?null:this.at(h/r,a)}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 Vi extends Ki{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(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 Xi,this.combine=Qd,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 Ff=new qe,Es=new jr,Ao=new Yi,Bf=new R,Io=new R,Do=new R,Co=new R,Pc=new R,Ro=new R,zf=new R,Po=new R;class Ze extends Tt{constructor(e=new Dt,t=new Vi){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,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,a=n.morphAttributes.position,r=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Ro.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const h=o[l],d=a[l];h!==0&&(Pc.fromBufferAttribute(d,e),r?Ro.addScaledVector(Pc,h):Ro.addScaledVector(Pc.sub(t),h))}t.add(Ro)}return t}raycast(e,t){const n=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ao.copy(n.boundingSphere),Ao.applyMatrix4(a),Es.copy(e.ray).recast(e.near),!(Ao.containsPoint(Es.origin)===!1&&(Es.intersectSphere(Ao,Bf)===null||Es.origin.distanceToSquared(Bf)>(e.far-e.near)**2))&&(Ff.copy(a).invert(),Es.copy(e.ray).applyMatrix4(Ff),!(n.boundingBox!==null&&Es.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Es)))}_computeIntersections(e,t,n){let i;const a=this.geometry,r=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,h=a.attributes.uv1,d=a.attributes.normal,u=a.groups,f=a.drawRange;if(o!==null)if(Array.isArray(r))for(let g=0,v=u.length;g<v;g++){const p=u[g],m=r[p.materialIndex],S=Math.max(p.start,f.start),_=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let x=S,M=_;x<M;x+=3){const E=o.getX(x),I=o.getX(x+1),y=o.getX(x+2);i=Lo(this,m,e,n,c,h,d,E,I,y),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const S=o.getX(p),_=o.getX(p+1),x=o.getX(p+2);i=Lo(this,r,e,n,c,h,d,S,_,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(r))for(let g=0,v=u.length;g<v;g++){const p=u[g],m=r[p.materialIndex],S=Math.max(p.start,f.start),_=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let x=S,M=_;x<M;x+=3){const E=x,I=x+1,y=x+2;i=Lo(this,m,e,n,c,h,d,E,I,y),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const S=p,_=p+1,x=p+2;i=Lo(this,r,e,n,c,h,d,S,_,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function Iy(s,e,t,n,i,a,r,o){let l;if(e.side===Vt?l=n.intersectTriangle(r,a,i,!0,o):l=n.intersectTriangle(i,a,r,e.side===vs,o),l===null)return null;Po.copy(o),Po.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Po);return c<t.near||c>t.far?null:{distance:c,point:Po.clone(),object:s}}function Lo(s,e,t,n,i,a,r,o,l,c){s.getVertexPosition(o,Io),s.getVertexPosition(l,Do),s.getVertexPosition(c,Co);const h=Iy(s,e,t,n,Io,Do,Co,zf);if(h){const d=new R;Gn.getBarycoord(zf,Io,Do,Co,d),i&&(h.uv=Gn.getInterpolatedAttribute(i,o,l,c,d,new Re)),a&&(h.uv1=Gn.getInterpolatedAttribute(a,o,l,c,d,new Re)),r&&(h.normal=Gn.getInterpolatedAttribute(r,o,l,c,d,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new R,materialIndex:0};Gn.getNormal(Io,Do,Co,u.normal),h.face=u,h.barycoord=d}return h}const pr=new ft,Hf=new ft,Gf=new ft,Dy=new ft,Vf=new qe,No=new R,Lc=new Yi,Wf=new qe,Nc=new jr;class eA extends Ze{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gf,this.bindMatrix=new qe,this.bindMatrixInverse=new qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ti),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,No),this.boundingBox.expandByPoint(No)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Yi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,No),this.boundingSphere.expandByPoint(No)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Lc.copy(this.boundingSphere),Lc.applyMatrix4(i),e.ray.intersectsSphere(Lc)!==!1&&(Wf.copy(i).invert(),Nc.copy(e.ray).applyMatrix4(Wf),!(this.boundingBox!==null&&Nc.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Nc)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new ft,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===gf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Dv?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ee("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Hf.fromBufferAttribute(i.attributes.skinIndex,e),Gf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(pr.copy(t),t.set(0,0,0,0)):(pr.set(...t,1),t.set(0,0,0)),pr.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){const r=Gf.getComponent(a);if(r!==0){const o=Hf.getComponent(a);Vf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Dy.copy(pr).applyMatrix4(Vf),r)}}return t.isVector4&&(t.w=pr.w),t.applyMatrix4(this.bindMatrixInverse)}}class Cy extends Tt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class nr extends tn{constructor(e=null,t=1,n=1,i,a,r,o,l,c=Wt,h=Wt,d,u){super(null,r,o,l,c,h,i,a,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xf=new qe,Ry=new qe;class zm{constructor(e=[],t=[]){this.uuid=ti(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ee("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let a=0,r=e.length;a<r;a++){const o=e[a]?e[a].matrixWorld:Ry;Xf.multiplyMatrices(o,t[a]),Xf.toArray(n,a*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new zm(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new nr(t,e,e,yn,Vn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const a=e.bones[n];let r=t[a];r===void 0&&(Ee("Skeleton: No bone found with UUID:",a),r=new Cy),this.bones.push(r),this.boneInverses.push(new qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,a=t.length;i<a;i++){const r=t[i];e.bones.push(r.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class qf extends gt{constructor(e,t,n,i=1){super(e,t,n),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 va=new qe,Yf=new qe,Oo=[],Kf=new Ti,Py=new qe,mr=new Ze,gr=new Yi;class tA extends Ze{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qf(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Py)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ti),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,va),Kf.copy(e.boundingBox).applyMatrix4(va),this.boundingBox.union(Kf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Yi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,va),gr.copy(e.boundingSphere).applyMatrix4(va),this.boundingSphere.union(gr)}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 n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,a=n.length+1,r=e*a+1;for(let o=0;o<n.length;o++)n[o]=i[r+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(mr.geometry=this.geometry,mr.material=this.material,mr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gr.copy(this.boundingSphere),gr.applyMatrix4(n),e.ray.intersectsSphere(gr)!==!1))for(let a=0;a<i;a++){this.getMatrixAt(a,va),Yf.multiplyMatrices(n,va),mr.matrixWorld=Yf,mr.raycast(e,Oo);for(let r=0,o=Oo.length;r<o;r++){const l=Oo[r];l.instanceId=a,l.object=this,t.push(l)}Oo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new qf(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 n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new nr(new Float32Array(i*this.count),i,this.count,iu,Vn));const a=this.morphTexture.source.data.data;let r=0;for(let c=0;c<n.length;c++)r+=n[c];const o=this.geometry.morphTargetsRelative?1:1-r,l=i*e;return a[l]=o,a.set(n,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Oc=new R,Ly=new R,Ny=new Be;class Rs{constructor(e=new R(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Oc.subVectors(n,t).cross(Ly.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,n=!0){const i=e.delta(Oc),a=this.normal.dot(i);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/a;return n===!0&&(r<0||r>1)?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Ny.getNormalMatrix(e),i=this.coplanarPoint(Oc).applyMatrix4(e),a=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(a),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 Ts=new Yi,Oy=new Re(.5,.5),ko=new R;class pu{constructor(e=new Rs,t=new Rs,n=new Rs,i=new Rs,a=new Rs,r=new Rs){this.planes=[e,t,n,i,a,r]}set(e,t,n,i,a,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(a),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=wi,n=!1){const i=this.planes,a=e.elements,r=a[0],o=a[1],l=a[2],c=a[3],h=a[4],d=a[5],u=a[6],f=a[7],g=a[8],v=a[9],p=a[10],m=a[11],S=a[12],_=a[13],x=a[14],M=a[15];if(i[0].setComponents(c-r,f-h,m-g,M-S).normalize(),i[1].setComponents(c+r,f+h,m+g,M+S).normalize(),i[2].setComponents(c+o,f+d,m+v,M+_).normalize(),i[3].setComponents(c-o,f-d,m-v,M-_).normalize(),n)i[4].setComponents(l,u,p,x).normalize(),i[5].setComponents(c-l,f-u,m-p,M-x).normalize();else if(i[4].setComponents(c-l,f-u,m-p,M-x).normalize(),t===wi)i[5].setComponents(c+l,f+u,m+p,M+x).normalize();else if(t===Kr)i[5].setComponents(l,u,p,x).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(),Ts.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ts.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ts)}intersectsSprite(e){Ts.center.set(0,0,0);const t=Oy.distanceTo(e.center);return Ts.radius=.7071067811865476+t,Ts.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ts)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ko.x=i.normal.x>0?e.max.x:e.min.x,ko.y=i.normal.y>0?e.max.y:e.min.y,ko.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ko)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ky extends Ki{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ve(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 Ol=new R,kl=new R,$f=new qe,vr=new jr,Uo=new Yi,kc=new R,Zf=new R;class Hm extends Tt{constructor(e=new Dt,t=new ky){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,n=[0];for(let i=1,a=t.count;i<a;i++)Ol.fromBufferAttribute(t,i-1),kl.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ol.distanceTo(kl);e.setAttribute("lineDistance",new It(n,1))}else Ee("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,r=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Uo.copy(n.boundingSphere),Uo.applyMatrix4(i),Uo.radius+=a,e.ray.intersectsSphere(Uo)===!1)return;$f.copy(i).invert(),vr.copy(e.ray).applyMatrix4($f);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){const f=Math.max(0,r.start),g=Math.min(h.count,r.start+r.count);for(let v=f,p=g-1;v<p;v+=c){const m=h.getX(v),S=h.getX(v+1),_=Fo(this,e,vr,l,m,S,v);_&&t.push(_)}if(this.isLineLoop){const v=h.getX(g-1),p=h.getX(f),m=Fo(this,e,vr,l,v,p,g-1);m&&t.push(m)}}else{const f=Math.max(0,r.start),g=Math.min(u.count,r.start+r.count);for(let v=f,p=g-1;v<p;v+=c){const m=Fo(this,e,vr,l,v,v+1,v);m&&t.push(m)}if(this.isLineLoop){const v=Fo(this,e,vr,l,g-1,f,g-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function Fo(s,e,t,n,i,a,r){const o=s.geometry.attributes.position;if(Ol.fromBufferAttribute(o,i),kl.fromBufferAttribute(o,a),t.distanceSqToSegment(Ol,kl,kc,Zf)>n)return;kc.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(kc);if(!(c<e.near||c>e.far))return{distance:c,point:Zf.clone().applyMatrix4(s.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:s}}const Jf=new R,jf=new R;class nA extends Hm{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,n=[];for(let i=0,a=t.count;i<a;i+=2)Jf.fromBufferAttribute(t,i),jf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jf.distanceTo(jf);e.setAttribute("lineDistance",new It(n,1))}else Ee("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class iA extends Hm{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Gm extends Ki{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ve(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 Qf=new qe,yd=new jr,Bo=new Yi,zo=new R;class ml extends Tt{constructor(e=new Dt,t=new Gm){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 n=this.geometry,i=this.matrixWorld,a=e.params.Points.threshold,r=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Bo.copy(n.boundingSphere),Bo.applyMatrix4(i),Bo.radius+=a,e.ray.intersectsSphere(Bo)===!1)return;Qf.copy(i).invert(),yd.copy(e.ray).applyMatrix4(Qf);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const u=Math.max(0,r.start),f=Math.min(c.count,r.start+r.count);for(let g=u,v=f;g<v;g++){const p=c.getX(g);zo.fromBufferAttribute(d,p),ep(zo,p,l,i,e,t,this)}}else{const u=Math.max(0,r.start),f=Math.min(d.count,r.start+r.count);for(let g=u,v=f;g<v;g++)zo.fromBufferAttribute(d,g),ep(zo,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=i.length;a<r;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function ep(s,e,t,n,i,a,r){const o=yd.distanceSqToPoint(s);if(o<t){const l=new R;yd.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}class Vm extends tn{constructor(e=[],t=qs,n,i,a,r,o,l,c,h){super(e,t,n,i,a,r,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ai extends tn{constructor(e,t,n,i,a,r,o,l,c){super(e,t,n,i,a,r,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends tn{constructor(e,t,n=ii,i,a,r,o=Wt,l=Wt,c,h=Wi,d=1){if(h!==Wi&&h!==zs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,i,a,r,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hu(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 Uy extends Ks{constructor(e,t=ii,n=qs,i,a,r=Wt,o=Wt,l,c=Wi){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,i,a,r,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Wm extends tn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Wn extends Dt{constructor(e=1,t=1,n=1,i=1,a=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:a,depthSegments:r};const o=this;i=Math.floor(i),a=Math.floor(a),r=Math.floor(r);const l=[],c=[],h=[],d=[];let u=0,f=0;g("z","y","x",-1,-1,n,t,e,r,a,0),g("z","y","x",1,-1,n,t,-e,r,a,1),g("x","z","y",1,1,e,n,t,i,r,2),g("x","z","y",1,-1,e,n,-t,i,r,3),g("x","y","z",1,-1,e,t,n,i,a,4),g("x","y","z",-1,-1,e,t,-n,i,a,5),this.setIndex(l),this.setAttribute("position",new It(c,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(d,2));function g(v,p,m,S,_,x,M,E,I,y,T){const C=x/I,D=M/y,P=x/2,V=M/2,q=E/2,O=I+1,W=y+1;let G=0,Z=0;const te=new R;for(let Q=0;Q<W;Q++){const ie=Q*D-V;for(let de=0;de<O;de++){const He=de*C-P;te[v]=He*S,te[p]=ie*_,te[m]=q,c.push(te.x,te.y,te.z),te[v]=0,te[p]=0,te[m]=E>0?1:-1,h.push(te.x,te.y,te.z),d.push(de/I),d.push(1-Q/y),G+=1}}for(let Q=0;Q<y;Q++)for(let ie=0;ie<I;ie++){const de=u+ie+O*Q,He=u+ie+O*(Q+1),Je=u+(ie+1)+O*(Q+1),ze=u+(ie+1)+O*Q;l.push(de,He,ze),l.push(He,Je,ze),Z+=6}o.addGroup(f,Z,T),f+=Z,u+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mu extends Dt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const a=[],r=[],o=[],l=[],c=new R,h=new Re;r.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const f=n+d/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),r.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(r[u]/e+1)/2,h.y=(r[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)a.push(d,d+1,0);this.setIndex(a),this.setAttribute("position",new It(r,3)),this.setAttribute("normal",new It(o,3)),this.setAttribute("uv",new It(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mu(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class $i extends Dt{constructor(e=1,t=1,n=1,i=32,a=1,r=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:a,openEnded:r,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),a=Math.floor(a);const h=[],d=[],u=[],f=[];let g=0;const v=[],p=n/2;let m=0;S(),r===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new It(d,3)),this.setAttribute("normal",new It(u,3)),this.setAttribute("uv",new It(f,2));function S(){const x=new R,M=new R;let E=0;const I=(t-e)/n;for(let y=0;y<=a;y++){const T=[],C=y/a,D=C*(t-e)+e;for(let P=0;P<=i;P++){const V=P/i,q=V*l+o,O=Math.sin(q),W=Math.cos(q);M.x=D*O,M.y=-C*n+p,M.z=D*W,d.push(M.x,M.y,M.z),x.set(O,I,W).normalize(),u.push(x.x,x.y,x.z),f.push(V,1-C),T.push(g++)}v.push(T)}for(let y=0;y<i;y++)for(let T=0;T<a;T++){const C=v[T][y],D=v[T+1][y],P=v[T+1][y+1],V=v[T][y+1];(e>0||T!==0)&&(h.push(C,D,V),E+=3),(t>0||T!==a-1)&&(h.push(D,P,V),E+=3)}c.addGroup(m,E,0),m+=E}function _(x){const M=g,E=new Re,I=new R;let y=0;const T=x===!0?e:t,C=x===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,p*C,0),u.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let P=0;P<=i;P++){const q=P/i*l+o,O=Math.cos(q),W=Math.sin(q);I.x=T*W,I.y=p*C,I.z=T*O,d.push(I.x,I.y,I.z),u.push(0,C,0),E.x=O*.5+.5,E.y=W*.5*C+.5,f.push(E.x,E.y),g++}for(let P=0;P<i;P++){const V=M+P,q=D+P;x===!0?h.push(q,q+1,V):h.push(q+1,q,V),y+=3}c.addGroup(m,y,x===!0?1:2),m+=y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qr extends $i{constructor(e=1,t=1,n=32,i=1,a=!1,r=0,o=Math.PI*2){super(0,e,t,n,i,a,r,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:a,thetaStart:r,thetaLength:o}}static fromJSON(e){return new Qr(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Zi extends Dt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const a=e/2,r=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,d=e/o,u=t/l,f=[],g=[],v=[],p=[];for(let m=0;m<h;m++){const S=m*u-r;for(let _=0;_<c;_++){const x=_*d-a;g.push(x,-S,0),v.push(0,0,1),p.push(_/o),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let S=0;S<o;S++){const _=S+c*m,x=S+c*(m+1),M=S+1+c*(m+1),E=S+1+c*m;f.push(_,x,E),f.push(x,M,E)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zi(e.width,e.height,e.widthSegments,e.heightSegments)}}class bn extends Dt{constructor(e=1,t=32,n=16,i=0,a=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:a,thetaStart:r,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(r+o,Math.PI);let c=0;const h=[],d=new R,u=new R,f=[],g=[],v=[],p=[];for(let m=0;m<=n;m++){const S=[],_=m/n,x=r+_*o,M=e*Math.cos(x),E=Math.sqrt(e*e-M*M);let I=0;m===0&&r===0?I=.5/t:m===n&&l===Math.PI&&(I=-.5/t);for(let y=0;y<=t;y++){const T=y/t,C=i+T*a;d.x=-E*Math.cos(C),d.y=M,d.z=E*Math.sin(C),g.push(d.x,d.y,d.z),u.copy(d).normalize(),v.push(u.x,u.y,u.z),p.push(T+I,1-_),S.push(c++)}h.push(S)}for(let m=0;m<n;m++)for(let S=0;S<t;S++){const _=h[m][S+1],x=h[m][S],M=h[m+1][S],E=h[m+1][S+1];(m!==0||r>0)&&f.push(_,x,E),(m!==n-1||l<Math.PI)&&f.push(x,M,E)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Qa(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(tp(i))i.isRenderTargetTexture?(Ee("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(tp(i[0])){const a=[];for(let r=0,o=i.length;r<o;r++)a[r]=i[r].clone();e[t][n]=a}else e[t][n]=i.slice();else e[t][n]=i}}return e}function un(s){const e={};for(let t=0;t<s.length;t++){const n=Qa(s[t]);for(const i in n)e[i]=n[i]}return e}function tp(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function Fy(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Xm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const By={clone:Qa,merge:un};var zy=`void main() {
1860
1870
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
1861
1871
  }`,Hy=`void main() {
1862
1872
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
1863
- }`;class Nt extends Ki{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=zy,this.fragmentShader=Hy,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=Qa(e.uniforms),this.uniformsGroups=Fy(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 r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ve().setHex(i.value);break;case"v2":this.uniforms[n].value=new Re().fromArray(i.value);break;case"v3":this.uniforms[n].value=new R().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Be().fromArray(i.value);break;case"m4":this.uniforms[n].value=new qe().fromArray(i.value);break;default:this.uniforms[n].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 n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Gy extends Nt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Vy extends Ki{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ve(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 ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Cl,this.normalScale=new Re(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 Xi,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 sA extends Vy{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Re(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ve(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ve(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ve(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class eo extends Ki{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Cl,this.normalScale=new Re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xi,this.combine=Qd,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.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.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.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.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,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 Wy extends Ki{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pv,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 Xy extends Ki{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}}function Ho(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function qy(s){function e(i,a){return s[i]-s[a]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function np(s,e,t){const n=s.length,i=new s.constructor(n);for(let a=0,r=0;r!==n;++a){const o=t[a]*e;for(let l=0;l!==e;++l)i[r++]=s[o+l]}return i}function Yy(s,e,t,n){let i=1,a=s[0];for(;a!==void 0&&a[n]===void 0;)a=s[i++];if(a===void 0)return;let r=a[n];if(r!==void 0)if(Array.isArray(r))do r=a[n],r!==void 0&&(e.push(a.time),t.push(...r)),a=s[i++];while(a!==void 0);else if(r.toArray!==void 0)do r=a[n],r!==void 0&&(e.push(a.time),r.toArray(t,t.length)),a=s[i++];while(a!==void 0);else do r=a[n],r!==void 0&&(e.push(a.time),t.push(r)),a=s[i++];while(a!==void 0)}class to{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],a=t[n-1];n:{e:{let r;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<a)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(a=i,i=t[++n],e<i)break e}r=t.length;break t}if(!(e>=a)){const o=t[1];e<o&&(n=2,a=o);for(let l=n-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=a,a=t[--n-1],e>=a)break e}r=n,n=0;break t}break n}for(;n<r;){const o=n+r>>>1;e<t[o]?r=o:n=o+1}if(i=t[n],a=t[n-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,a,i)}return this.interpolate_(n,a,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,a=e*i;for(let r=0;r!==i;++r)t[r]=n[a+r];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Ky extends to{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yf,endingEnd:yf}}intervalChanged_(e,t,n){const i=this.parameterPositions;let a=e-2,r=e+1,o=i[a],l=i[r];if(o===void 0)switch(this.getSettings_().endingStart){case bf:a=e,o=2*t-n;break;case xf:a=i.length-2,o=t+i[a]-i[a+1];break;default:a=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case bf:r=e,l=2*n-t;break;case xf:r=1,l=n+i[1]-i[0];break;default:r=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=a*h,this._offsetNext=r*h}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),v=g*g,p=v*g,m=-u*p+2*u*v-u*g,S=(1+u)*p+(-1.5-2*u)*v+(-.5+u)*g+1,_=(-1-f)*p+(1.5+f)*v+.5*g,x=f*p-f*v;for(let M=0;M!==o;++M)a[M]=m*r[h+M]+S*r[c+M]+_*r[l+M]+x*r[d+M];return a}}class $y extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),d=1-h;for(let u=0;u!==o;++u)a[u]=r[c+u]*d+r[l+u]*h;return a}}class Zy extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jy extends to{interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.inTangents,d=this.outTangents;if(!h||!d){const g=(n-t)/(i-t),v=1-g;for(let p=0;p!==o;++p)a[p]=r[c+p]*v+r[l+p]*g;return a}const u=o*2,f=e-1;for(let g=0;g!==o;++g){const v=r[c+g],p=r[l+g],m=f*u+g*2,S=d[m],_=d[m+1],x=e*u+g*2,M=h[x],E=h[x+1];let I=(n-t)/(i-t),y,T,C,D,P;for(let V=0;V<8;V++){y=I*I,T=y*I,C=1-I,D=C*C,P=D*C;const O=P*t+3*D*I*S+3*C*y*M+T*i-n;if(Math.abs(O)<1e-10)break;const W=3*D*(S-t)+6*C*I*(M-S)+3*y*(i-M);if(Math.abs(W)<1e-10)break;I=I-O/W,I=Math.max(0,Math.min(1,I))}a[g]=P*v+3*D*I*_+3*C*y*E+T*p}return a}}class ii{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ho(t,this.TimeBufferType),this.values=Ho(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ho(e.times,Array),values:Ho(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Zy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new $y(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ky(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Jy(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Dl:t=this.InterpolantFactoryMethodDiscrete;break;case gd:t=this.InterpolantFactoryMethodLinear;break;case hc:t=this.InterpolantFactoryMethodSmooth;break;case vf:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ee("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Dl;case this.InterpolantFactoryMethodLinear:return gd;case this.InterpolantFactoryMethodSmooth:return hc;case this.InterpolantFactoryMethodBezier:return vf}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let a=0,r=i-1;for(;a!==i&&n[a]<e;)++a;for(;r!==-1&&n[r]>t;)--r;if(++r,a!==0||r!==i){a>=r&&(r=Math.max(r,1),a=r-1);const o=this.getValueSize();this.times=n.slice(a,r),this.values=this.values.slice(a*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Fe("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,a=n.length;a===0&&(Fe("KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==a;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){Fe("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(r!==null&&r>l){Fe("KeyframeTrack: Out of order keys.",this,o,l,r),e=!1;break}r=l}if(i!==void 0&&Hv(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===hc,a=e.length-1;let r=1;for(let o=1;o<a;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(i)l=!0;else{const d=o*n,u=d-n,f=d+n;for(let g=0;g!==n;++g){const v=t[d+g];if(v!==t[u+g]||v!==t[f+g]){l=!0;break}}}if(l){if(o!==r){e[r]=e[o];const d=o*n,u=r*n;for(let f=0;f!==n;++f)t[u+f]=t[d+f]}++r}}if(a>0){e[r]=e[a];for(let o=a*n,l=r*n,c=0;c!==n;++c)t[l+c]=t[o+c];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ii.prototype.ValueTypeName="";ii.prototype.TimeBufferType=Float32Array;ii.prototype.ValueBufferType=Float32Array;ii.prototype.DefaultInterpolation=gd;class ir extends ii{constructor(e,t,n){super(e,t,n)}}ir.prototype.ValueTypeName="bool";ir.prototype.ValueBufferType=Array;ir.prototype.DefaultInterpolation=Dl;ir.prototype.InterpolantFactoryMethodLinear=void 0;ir.prototype.InterpolantFactoryMethodSmooth=void 0;class qm extends ii{constructor(e,t,n,i){super(e,t,n,i)}}qm.prototype.ValueTypeName="color";class gu extends ii{constructor(e,t,n,i){super(e,t,n,i)}}gu.prototype.ValueTypeName="number";class jy extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)bs.slerpFlat(a,0,r,c-o,r,c,l);return a}}class vu extends ii{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new jy(this.times,this.values,this.getValueSize(),e)}}vu.prototype.ValueTypeName="quaternion";vu.prototype.InterpolantFactoryMethodSmooth=void 0;class sr extends ii{constructor(e,t,n){super(e,t,n)}}sr.prototype.ValueTypeName="string";sr.prototype.ValueBufferType=Array;sr.prototype.DefaultInterpolation=Dl;sr.prototype.InterpolantFactoryMethodLinear=void 0;sr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ym extends ii{constructor(e,t,n,i){super(e,t,n,i)}}Ym.prototype.ValueTypeName="vector";class aA{constructor(e="",t=-1,n=[],i=Rv){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ei(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(eb(n[r]).scale(i));const a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a.userData=JSON.parse(e.userData||"{}"),a}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let a=0,r=n.length;a!==r;++a)t.push(ii.toJSON(n[a]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const a=t.length,r=[];for(let o=0;o<a;o++){let l=[],c=[];l.push((o+a-1)%a,o,(o+1)%a),c.push(0,1,0);const h=qy(l);l=np(l,1,h),c=np(c,1,h),!i&&l[0]===0&&(l.push(a),c.push(c[0])),r.push(new gu(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,r)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},a=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(a);if(h&&h.length>1){const d=h[1];let u=i[d];u||(i[d]=u=[]),u.push(c)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const a=this.tracks[n];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Qy(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gu;case"vector":case"vector2":case"vector3":case"vector4":return Ym;case"color":return qm;case"quaternion":return vu;case"bool":case"boolean":return ir;case"string":return sr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function eb(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Qy(s.type);if(s.times===void 0){const t=[],n=[];Yy(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Hi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(ip(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!ip(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function ip(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class tb{constructor(e,t,n){const i=this;let a=!1,r=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,a===!1&&i.onStart!==void 0&&i.onStart(h,r,o),a=!0},this.itemEnd=function(h){r++,i.onProgress!==void 0&&i.onProgress(h,r,o),r===o&&(a=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){const f=c[d],g=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const nb=new tb;class no{constructor(e){this.manager=e!==void 0?e:nb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,a){n.load(e,i,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}no.DEFAULT_MATERIAL_NAME="__DEFAULT";const Li={};class ib extends Error{constructor(e,t){super(e),this.response=t}}class rA extends no{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=Hi.get(`file:${e}`);if(a!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0);return}if(Li[e]!==void 0){Li[e].push({onLoad:t,onProgress:n,onError:i});return}Li[e]=[],Li[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(r).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ee("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Li[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,g=f!==0;let v=0;const p=new ReadableStream({start(m){S();function S(){d.read().then(({done:_,value:x})=>{if(_)m.close();else{v+=x.byteLength;const M=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let E=0,I=h.length;E<I;E++){const y=h[E];y.onProgress&&y.onProgress(M)}m.enqueue(x),S()}},_=>{m.error(_)})}}});return new Response(p)}else throw new ib(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Hi.add(`file:${e}`,c);const h=Li[e];delete Li[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=Li[e];if(h===void 0)throw this.manager.itemError(e),c;delete Li[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ya=new WeakMap;class sb extends no{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,r=Hi.get(`image:${e}`);if(r!==void 0){if(r.complete===!0)a.manager.itemStart(e),setTimeout(function(){t&&t(r),a.manager.itemEnd(e)},0);else{let d=ya.get(r);d===void 0&&(d=[],ya.set(r,d)),d.push({onLoad:t,onError:i})}return r}const o=$r("img");function l(){h(),t&&t(this);const d=ya.get(this)||[];for(let u=0;u<d.length;u++){const f=d[u];f.onLoad&&f.onLoad(this)}ya.delete(this),a.manager.itemEnd(e)}function c(d){h(),i&&i(d),Hi.remove(`image:${e}`);const u=ya.get(this)||[];for(let f=0;f<u.length;f++){const g=u[f];g.onError&&g.onError(d)}ya.delete(this),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Hi.add(`image:${e}`,o),a.manager.itemStart(e),o.src=e,o}}class oA extends no{constructor(e){super(e)}load(e,t,n,i){const a=new en,r=new sb(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,function(o){a.image=o,a.needsUpdate=!0,t!==void 0&&t(a)},n,i),a}}class $l extends Tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ve(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}}class ab extends $l{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Uc=new qe,sp=new R,ap=new R;class yu{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 Re(512,512),this.mapType=kn,this.map=null,this.mapPass=null,this.matrix=new qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pu,this._frameExtents=new Re(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;sp.setFromMatrixPosition(e.matrixWorld),t.position.copy(sp),ap.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ap),t.updateMatrixWorld(),Uc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uc,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Kr||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Uc)}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 Go=new R,Vo=new bs,oi=new R;class Km extends Tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=wi,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(Go,Vo,oi),oi.x===1&&oi.y===1&&oi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,oi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Go,Vo,oi),oi.x===1&&oi.y===1&&oi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,oi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const rs=new R,rp=new Re,op=new Re;class _n extends Km{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=ja*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Lr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ja*2*Math.atan(Math.tan(Lr*.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,n){rs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rs.x,rs.y).multiplyScalar(-e/rs.z),rs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rs.x,rs.y).multiplyScalar(-e/rs.z)}getViewSize(e,t){return this.getViewBounds(e,rp,op),t.subVectors(op,rp)}setViewOffset(e,t,n,i,a,r){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=n,this.view.offsetY=i,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Lr*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,a=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const l=r.fullWidth,c=r.fullHeight;a+=r.offsetX*i/l,t-=r.offsetY*n/c,i*=r.width/l,n*=r.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,t,t-n,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 rb extends yu{constructor(){super(new _n(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=ja*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,a=e.distance||t.far;(n!==t.fov||i!==t.aspect||a!==t.far)&&(t.fov=n,t.aspect=i,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class lA extends $l{constructor(e,t,n=0,i=Math.PI/3,a=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=n,this.angle=i,this.penumbra=a,this.decay=r,this.map=null,this.shadow=new rb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class ob extends yu{constructor(){super(new _n(90,1,.5,500)),this.isPointLightShadow=!0}}class lb extends $l{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new ob}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class ar extends Km{constructor(e=-1,t=1,n=1,i=-1,a=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=a,this.far=r,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,n,i,a,r){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=n,this.view.offsetY=i,this.view.width=a,this.view.height=r,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=n-e,r=n+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,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,r=a+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(a,r,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 cb extends yu{constructor(){super(new ar(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class hb extends $l{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new cb}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 cA{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Fc=new WeakMap;class hA extends no{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ee("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ee("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,r=Hi.get(`image-bitmap:${e}`);if(r!==void 0){if(a.manager.itemStart(e),r.then){r.then(c=>{Fc.has(r)===!0?(i&&i(Fc.get(r)),a.manager.itemError(e),a.manager.itemEnd(e)):(t&&t(c),a.manager.itemEnd(e))});return}setTimeout(function(){t&&t(r),a.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(a.options,{colorSpaceConversion:"none"}))}).then(function(c){Hi.add(`image-bitmap:${e}`,c),t&&t(c),a.manager.itemEnd(e)}).catch(function(c){i&&i(c),Fc.set(l,c),Hi.remove(`image-bitmap:${e}`),a.manager.itemError(e),a.manager.itemEnd(e)});Hi.add(`image-bitmap:${e}`,l),a.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ba=-90,xa=1;class db extends Tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new _n(ba,xa,e,t);i.layers=this.layers,this.add(i);const a=new _n(ba,xa,e,t);a.layers=this.layers,this.add(a);const r=new _n(ba,xa,e,t);r.layers=this.layers,this.add(r);const o=new _n(ba,xa,e,t);o.layers=this.layers,this.add(o);const l=new _n(ba,xa,e,t);l.layers=this.layers,this.add(l);const c=new _n(ba,xa,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,a,r,o,l]=t;for(const c of t)this.remove(c);if(e===wi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),r.up.set(0,0,1),r.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===Kr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),r.up.set(0,0,-1),r.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:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,r,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,1,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,2,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ub extends _n{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const bu="\\[\\]\\.:\\/",fb=new RegExp("["+bu+"]","g"),xu="[^"+bu+"]",pb="[^"+bu.replace("\\.","")+"]",mb=/((?:WC+[\/:])*)/.source.replace("WC",xu),gb=/(WCOD+)?/.source.replace("WCOD",pb),vb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xu),yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xu),bb=new RegExp("^"+mb+gb+vb+yb+"$"),xb=["material","materials","bones","map"];class wb{constructor(e,t,n){const i=n||ft.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,a=n.length;i!==a;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ft{constructor(e,t,n){this.path=t,this.parsedPath=n||ft.parseTrackName(t),this.node=ft.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ft.Composite(e,t,n):new ft(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fb,"")}static parseTrackName(e){const t=bb.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const a=n.nodeName.substring(i+1);xb.indexOf(a)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=a)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(a){for(let r=0;r<a.length;r++){const o=a[r];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let a=t.propertyIndex;if(e||(e=ft.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ee("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const r=e[i];if(r===void 0){const c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(a!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}l=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=a}else r.fromArray!==void 0&&r.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(l=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ft.Composite=wb;ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ft.prototype.GetterByBindingType=[ft.prototype._getValue_direct,ft.prototype._getValue_array,ft.prototype._getValue_arrayElement,ft.prototype._getValue_toArray];ft.prototype.SetterByBindingTypeAndVersioning=[[ft.prototype._setValue_direct,ft.prototype._setValue_direct_setNeedsUpdate,ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_array,ft.prototype._setValue_array_setNeedsUpdate,ft.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_arrayElement,ft.prototype._setValue_arrayElement_setNeedsUpdate,ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_fromArray,ft.prototype._setValue_fromArray_setNeedsUpdate,ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const lp=new qe;class Bc{constructor(e,t,n=0,i=1/0){this.ray=new jr(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new du,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):Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return lp.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(lp),this}intersectObject(e,t=!0,n=[]){return bd(e,this,n,t),n.sort(cp),n}intersectObjects(e,t=!0,n=[]){for(let i=0,a=e.length;i<a;i++)bd(e[i],this,n,t);return n.sort(cp),n}}function cp(s,e){return s.distance-e.distance}function bd(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const a=s.children;for(let r=0,o=a.length;r<o;r++)bd(a[r],e,t,!0)}}class $m{static{$m.prototype.isMatrix2=!0}constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const a=this.elements;return a[0]=e,a[2]=t,a[1]=n,a[3]=i,this}}function hp(s,e,t,n){const i=Mb(n);switch(t){case Lm:return s*e;case iu:return s*e/i.components*i.byteLength;case su:return s*e/i.components*i.byteLength;case Ys:return s*e*2/i.components*i.byteLength;case au:return s*e*2/i.components*i.byteLength;case Nm:return s*e*3/i.components*i.byteLength;case yn:return s*e*4/i.components*i.byteLength;case ru:return s*e*4/i.components*i.byteLength;case dl:case ul:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case fl:case pl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Hh:case Vh:return Math.max(s,16)*Math.max(e,8)/4;case zh:case Gh:return Math.max(s,8)*Math.max(e,8)/2;case Wh:case Xh:case Yh:case Kh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case qh:case Al:case $h:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Zh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case jh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case ed:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case td:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case nd:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case id:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case sd:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case ad:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case rd:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case od:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case ld:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case cd:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case hd:case dd:case ud:return Math.ceil(s/4)*Math.ceil(e/4)*16;case fd:case pd:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Il:case md:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Mb(s){switch(s){case kn:case Dm:return{byteLength:1,components:1};case qr:case Cm:case cn:return{byteLength:2,components:1};case tu:case nu:return{byteLength:2,components:4};case ni:case eu:case Vn:return{byteLength:4,components:1};case Rm:case Pm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jd}}));typeof window<"u"&&(window.__THREE__?Ee("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jd);/**
1873
+ }`;class Nt extends Ki{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=zy,this.fragmentShader=Hy,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=Qa(e.uniforms),this.uniformsGroups=Fy(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 r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ve().setHex(i.value);break;case"v2":this.uniforms[n].value=new Re().fromArray(i.value);break;case"v3":this.uniforms[n].value=new R().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Be().fromArray(i.value);break;case"m4":this.uniforms[n].value=new qe().fromArray(i.value);break;default:this.uniforms[n].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 n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Gy extends Nt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Vy extends Ki{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ve(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 ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Cl,this.normalScale=new Re(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 Xi,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 sA extends Vy{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Re(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ve(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ve(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ve(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class eo extends Ki{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Cl,this.normalScale=new Re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xi,this.combine=Qd,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.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.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.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.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,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 Wy extends Ki{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pv,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 Xy extends Ki{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}}function Ho(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function qy(s){function e(i,a){return s[i]-s[a]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function np(s,e,t){const n=s.length,i=new s.constructor(n);for(let a=0,r=0;r!==n;++a){const o=t[a]*e;for(let l=0;l!==e;++l)i[r++]=s[o+l]}return i}function Yy(s,e,t,n){let i=1,a=s[0];for(;a!==void 0&&a[n]===void 0;)a=s[i++];if(a===void 0)return;let r=a[n];if(r!==void 0)if(Array.isArray(r))do r=a[n],r!==void 0&&(e.push(a.time),t.push(...r)),a=s[i++];while(a!==void 0);else if(r.toArray!==void 0)do r=a[n],r!==void 0&&(e.push(a.time),r.toArray(t,t.length)),a=s[i++];while(a!==void 0);else do r=a[n],r!==void 0&&(e.push(a.time),t.push(r)),a=s[i++];while(a!==void 0)}class to{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],a=t[n-1];n:{e:{let r;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<a)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(a=i,i=t[++n],e<i)break e}r=t.length;break t}if(!(e>=a)){const o=t[1];e<o&&(n=2,a=o);for(let l=n-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=a,a=t[--n-1],e>=a)break e}r=n,n=0;break t}break n}for(;n<r;){const o=n+r>>>1;e<t[o]?r=o:n=o+1}if(i=t[n],a=t[n-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,a,i)}return this.interpolate_(n,a,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,a=e*i;for(let r=0;r!==i;++r)t[r]=n[a+r];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Ky extends to{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yf,endingEnd:yf}}intervalChanged_(e,t,n){const i=this.parameterPositions;let a=e-2,r=e+1,o=i[a],l=i[r];if(o===void 0)switch(this.getSettings_().endingStart){case bf:a=e,o=2*t-n;break;case xf:a=i.length-2,o=t+i[a]-i[a+1];break;default:a=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case bf:r=e,l=2*n-t;break;case xf:r=1,l=n+i[1]-i[0];break;default:r=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=a*h,this._offsetNext=r*h}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),v=g*g,p=v*g,m=-u*p+2*u*v-u*g,S=(1+u)*p+(-1.5-2*u)*v+(-.5+u)*g+1,_=(-1-f)*p+(1.5+f)*v+.5*g,x=f*p-f*v;for(let M=0;M!==o;++M)a[M]=m*r[h+M]+S*r[c+M]+_*r[l+M]+x*r[d+M];return a}}class $y extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),d=1-h;for(let u=0;u!==o;++u)a[u]=r[c+u]*d+r[l+u]*h;return a}}class Zy extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jy extends to{interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.inTangents,d=this.outTangents;if(!h||!d){const g=(n-t)/(i-t),v=1-g;for(let p=0;p!==o;++p)a[p]=r[c+p]*v+r[l+p]*g;return a}const u=o*2,f=e-1;for(let g=0;g!==o;++g){const v=r[c+g],p=r[l+g],m=f*u+g*2,S=d[m],_=d[m+1],x=e*u+g*2,M=h[x],E=h[x+1];let I=(n-t)/(i-t),y,T,C,D,P;for(let V=0;V<8;V++){y=I*I,T=y*I,C=1-I,D=C*C,P=D*C;const O=P*t+3*D*I*S+3*C*y*M+T*i-n;if(Math.abs(O)<1e-10)break;const W=3*D*(S-t)+6*C*I*(M-S)+3*y*(i-M);if(Math.abs(W)<1e-10)break;I=I-O/W,I=Math.max(0,Math.min(1,I))}a[g]=P*v+3*D*I*_+3*C*y*E+T*p}return a}}class si{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ho(t,this.TimeBufferType),this.values=Ho(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ho(e.times,Array),values:Ho(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Zy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new $y(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ky(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Jy(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Dl:t=this.InterpolantFactoryMethodDiscrete;break;case gd:t=this.InterpolantFactoryMethodLinear;break;case hc:t=this.InterpolantFactoryMethodSmooth;break;case vf:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ee("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Dl;case this.InterpolantFactoryMethodLinear:return gd;case this.InterpolantFactoryMethodSmooth:return hc;case this.InterpolantFactoryMethodBezier:return vf}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let a=0,r=i-1;for(;a!==i&&n[a]<e;)++a;for(;r!==-1&&n[r]>t;)--r;if(++r,a!==0||r!==i){a>=r&&(r=Math.max(r,1),a=r-1);const o=this.getValueSize();this.times=n.slice(a,r),this.values=this.values.slice(a*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Fe("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,a=n.length;a===0&&(Fe("KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==a;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){Fe("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(r!==null&&r>l){Fe("KeyframeTrack: Out of order keys.",this,o,l,r),e=!1;break}r=l}if(i!==void 0&&Hv(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===hc,a=e.length-1;let r=1;for(let o=1;o<a;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(i)l=!0;else{const d=o*n,u=d-n,f=d+n;for(let g=0;g!==n;++g){const v=t[d+g];if(v!==t[u+g]||v!==t[f+g]){l=!0;break}}}if(l){if(o!==r){e[r]=e[o];const d=o*n,u=r*n;for(let f=0;f!==n;++f)t[u+f]=t[d+f]}++r}}if(a>0){e[r]=e[a];for(let o=a*n,l=r*n,c=0;c!==n;++c)t[l+c]=t[o+c];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}si.prototype.ValueTypeName="";si.prototype.TimeBufferType=Float32Array;si.prototype.ValueBufferType=Float32Array;si.prototype.DefaultInterpolation=gd;class ir extends si{constructor(e,t,n){super(e,t,n)}}ir.prototype.ValueTypeName="bool";ir.prototype.ValueBufferType=Array;ir.prototype.DefaultInterpolation=Dl;ir.prototype.InterpolantFactoryMethodLinear=void 0;ir.prototype.InterpolantFactoryMethodSmooth=void 0;class qm extends si{constructor(e,t,n,i){super(e,t,n,i)}}qm.prototype.ValueTypeName="color";class gu extends si{constructor(e,t,n,i){super(e,t,n,i)}}gu.prototype.ValueTypeName="number";class jy extends to{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const a=this.resultBuffer,r=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)bs.slerpFlat(a,0,r,c-o,r,c,l);return a}}class vu extends si{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new jy(this.times,this.values,this.getValueSize(),e)}}vu.prototype.ValueTypeName="quaternion";vu.prototype.InterpolantFactoryMethodSmooth=void 0;class sr extends si{constructor(e,t,n){super(e,t,n)}}sr.prototype.ValueTypeName="string";sr.prototype.ValueBufferType=Array;sr.prototype.DefaultInterpolation=Dl;sr.prototype.InterpolantFactoryMethodLinear=void 0;sr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ym extends si{constructor(e,t,n,i){super(e,t,n,i)}}Ym.prototype.ValueTypeName="vector";class aA{constructor(e="",t=-1,n=[],i=Rv){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ti(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(eb(n[r]).scale(i));const a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a.userData=JSON.parse(e.userData||"{}"),a}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let a=0,r=n.length;a!==r;++a)t.push(si.toJSON(n[a]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const a=t.length,r=[];for(let o=0;o<a;o++){let l=[],c=[];l.push((o+a-1)%a,o,(o+1)%a),c.push(0,1,0);const h=qy(l);l=np(l,1,h),c=np(c,1,h),!i&&l[0]===0&&(l.push(a),c.push(c[0])),r.push(new gu(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,r)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},a=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(a);if(h&&h.length>1){const d=h[1];let u=i[d];u||(i[d]=u=[]),u.push(c)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const a=this.tracks[n];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Qy(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gu;case"vector":case"vector2":case"vector3":case"vector4":return Ym;case"color":return qm;case"quaternion":return vu;case"bool":case"boolean":return ir;case"string":return sr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function eb(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Qy(s.type);if(s.times===void 0){const t=[],n=[];Yy(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Hi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(ip(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!ip(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function ip(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class tb{constructor(e,t,n){const i=this;let a=!1,r=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,a===!1&&i.onStart!==void 0&&i.onStart(h,r,o),a=!0},this.itemEnd=function(h){r++,i.onProgress!==void 0&&i.onProgress(h,r,o),r===o&&(a=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){const f=c[d],g=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const nb=new tb;class no{constructor(e){this.manager=e!==void 0?e:nb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,a){n.load(e,i,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}no.DEFAULT_MATERIAL_NAME="__DEFAULT";const Li={};class ib extends Error{constructor(e,t){super(e),this.response=t}}class rA extends no{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=Hi.get(`file:${e}`);if(a!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0);return}if(Li[e]!==void 0){Li[e].push({onLoad:t,onProgress:n,onError:i});return}Li[e]=[],Li[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(r).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ee("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Li[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,g=f!==0;let v=0;const p=new ReadableStream({start(m){S();function S(){d.read().then(({done:_,value:x})=>{if(_)m.close();else{v+=x.byteLength;const M=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let E=0,I=h.length;E<I;E++){const y=h[E];y.onProgress&&y.onProgress(M)}m.enqueue(x),S()}},_=>{m.error(_)})}}});return new Response(p)}else throw new ib(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Hi.add(`file:${e}`,c);const h=Li[e];delete Li[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=Li[e];if(h===void 0)throw this.manager.itemError(e),c;delete Li[e];for(let d=0,u=h.length;d<u;d++){const f=h[d];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ya=new WeakMap;class sb extends no{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,r=Hi.get(`image:${e}`);if(r!==void 0){if(r.complete===!0)a.manager.itemStart(e),setTimeout(function(){t&&t(r),a.manager.itemEnd(e)},0);else{let d=ya.get(r);d===void 0&&(d=[],ya.set(r,d)),d.push({onLoad:t,onError:i})}return r}const o=$r("img");function l(){h(),t&&t(this);const d=ya.get(this)||[];for(let u=0;u<d.length;u++){const f=d[u];f.onLoad&&f.onLoad(this)}ya.delete(this),a.manager.itemEnd(e)}function c(d){h(),i&&i(d),Hi.remove(`image:${e}`);const u=ya.get(this)||[];for(let f=0;f<u.length;f++){const g=u[f];g.onError&&g.onError(d)}ya.delete(this),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Hi.add(`image:${e}`,o),a.manager.itemStart(e),o.src=e,o}}class oA extends no{constructor(e){super(e)}load(e,t,n,i){const a=new tn,r=new sb(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,function(o){a.image=o,a.needsUpdate=!0,t!==void 0&&t(a)},n,i),a}}class $l extends Tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ve(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}}class ab extends $l{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Uc=new qe,sp=new R,ap=new R;class yu{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 Re(512,512),this.mapType=kn,this.map=null,this.mapPass=null,this.matrix=new qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pu,this._frameExtents=new Re(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;sp.setFromMatrixPosition(e.matrixWorld),t.position.copy(sp),ap.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ap),t.updateMatrixWorld(),Uc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uc,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Kr||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Uc)}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 Go=new R,Vo=new bs,li=new R;class Km extends Tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=wi,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(Go,Vo,li),li.x===1&&li.y===1&&li.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,li.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Go,Vo,li),li.x===1&&li.y===1&&li.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,li.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const rs=new R,rp=new Re,op=new Re;class En extends Km{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=ja*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Lr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ja*2*Math.atan(Math.tan(Lr*.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,n){rs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rs.x,rs.y).multiplyScalar(-e/rs.z),rs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rs.x,rs.y).multiplyScalar(-e/rs.z)}getViewSize(e,t){return this.getViewBounds(e,rp,op),t.subVectors(op,rp)}setViewOffset(e,t,n,i,a,r){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=n,this.view.offsetY=i,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Lr*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,a=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const l=r.fullWidth,c=r.fullHeight;a+=r.offsetX*i/l,t-=r.offsetY*n/c,i*=r.width/l,n*=r.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,t,t-n,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 rb extends yu{constructor(){super(new En(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=ja*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,a=e.distance||t.far;(n!==t.fov||i!==t.aspect||a!==t.far)&&(t.fov=n,t.aspect=i,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class lA extends $l{constructor(e,t,n=0,i=Math.PI/3,a=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=n,this.angle=i,this.penumbra=a,this.decay=r,this.map=null,this.shadow=new rb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class ob extends yu{constructor(){super(new En(90,1,.5,500)),this.isPointLightShadow=!0}}class lb extends $l{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new ob}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class ar extends Km{constructor(e=-1,t=1,n=1,i=-1,a=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=a,this.far=r,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,n,i,a,r){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=n,this.view.offsetY=i,this.view.width=a,this.view.height=r,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=n-e,r=n+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,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,r=a+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(a,r,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 cb extends yu{constructor(){super(new ar(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class hb extends $l{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new cb}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 cA{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Fc=new WeakMap;class hA extends no{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ee("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ee("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,r=Hi.get(`image-bitmap:${e}`);if(r!==void 0){if(a.manager.itemStart(e),r.then){r.then(c=>{Fc.has(r)===!0?(i&&i(Fc.get(r)),a.manager.itemError(e),a.manager.itemEnd(e)):(t&&t(c),a.manager.itemEnd(e))});return}setTimeout(function(){t&&t(r),a.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(a.options,{colorSpaceConversion:"none"}))}).then(function(c){Hi.add(`image-bitmap:${e}`,c),t&&t(c),a.manager.itemEnd(e)}).catch(function(c){i&&i(c),Fc.set(l,c),Hi.remove(`image-bitmap:${e}`),a.manager.itemError(e),a.manager.itemEnd(e)});Hi.add(`image-bitmap:${e}`,l),a.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ba=-90,xa=1;class db extends Tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new En(ba,xa,e,t);i.layers=this.layers,this.add(i);const a=new En(ba,xa,e,t);a.layers=this.layers,this.add(a);const r=new En(ba,xa,e,t);r.layers=this.layers,this.add(r);const o=new En(ba,xa,e,t);o.layers=this.layers,this.add(o);const l=new En(ba,xa,e,t);l.layers=this.layers,this.add(l);const c=new En(ba,xa,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,a,r,o,l]=t;for(const c of t)this.remove(c);if(e===wi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),r.up.set(0,0,1),r.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===Kr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),r.up.set(0,0,-1),r.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:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,r,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,1,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,2,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ub extends En{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const bu="\\[\\]\\.:\\/",fb=new RegExp("["+bu+"]","g"),xu="[^"+bu+"]",pb="[^"+bu.replace("\\.","")+"]",mb=/((?:WC+[\/:])*)/.source.replace("WC",xu),gb=/(WCOD+)?/.source.replace("WCOD",pb),vb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xu),yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xu),bb=new RegExp("^"+mb+gb+vb+yb+"$"),xb=["material","materials","bones","map"];class wb{constructor(e,t,n){const i=n||ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,a=n.length;i!==a;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ut{constructor(e,t,n){this.path=t,this.parsedPath=n||ut.parseTrackName(t),this.node=ut.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ut.Composite(e,t,n):new ut(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fb,"")}static parseTrackName(e){const t=bb.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const a=n.nodeName.substring(i+1);xb.indexOf(a)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=a)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(a){for(let r=0;r<a.length;r++){const o=a[r];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,a=n.length;i!==a;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let a=t.propertyIndex;if(e||(e=ut.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ee("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const r=e[i];if(r===void 0){const c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(a!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}l=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=a}else r.fromArray!==void 0&&r.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(l=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ut.Composite=wb;ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ut.prototype.GetterByBindingType=[ut.prototype._getValue_direct,ut.prototype._getValue_array,ut.prototype._getValue_arrayElement,ut.prototype._getValue_toArray];ut.prototype.SetterByBindingTypeAndVersioning=[[ut.prototype._setValue_direct,ut.prototype._setValue_direct_setNeedsUpdate,ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_array,ut.prototype._setValue_array_setNeedsUpdate,ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_arrayElement,ut.prototype._setValue_arrayElement_setNeedsUpdate,ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_fromArray,ut.prototype._setValue_fromArray_setNeedsUpdate,ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const lp=new qe;class Bc{constructor(e,t,n=0,i=1/0){this.ray=new jr(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new du,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):Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return lp.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(lp),this}intersectObject(e,t=!0,n=[]){return bd(e,this,n,t),n.sort(cp),n}intersectObjects(e,t=!0,n=[]){for(let i=0,a=e.length;i<a;i++)bd(e[i],this,n,t);return n.sort(cp),n}}function cp(s,e){return s.distance-e.distance}function bd(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const a=s.children;for(let r=0,o=a.length;r<o;r++)bd(a[r],e,t,!0)}}class $m{static{$m.prototype.isMatrix2=!0}constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const a=this.elements;return a[0]=e,a[2]=t,a[1]=n,a[3]=i,this}}function hp(s,e,t,n){const i=Mb(n);switch(t){case Lm:return s*e;case iu:return s*e/i.components*i.byteLength;case su:return s*e/i.components*i.byteLength;case Ys:return s*e*2/i.components*i.byteLength;case au:return s*e*2/i.components*i.byteLength;case Nm:return s*e*3/i.components*i.byteLength;case yn:return s*e*4/i.components*i.byteLength;case ru:return s*e*4/i.components*i.byteLength;case dl:case ul:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case fl:case pl:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Hh:case Vh:return Math.max(s,16)*Math.max(e,8)/4;case zh:case Gh:return Math.max(s,8)*Math.max(e,8)/2;case Wh:case Xh:case Yh:case Kh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case qh:case Al:case $h:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Zh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case jh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case ed:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case td:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case nd:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case id:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case sd:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case ad:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case rd:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case od:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case ld:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case cd:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case hd:case dd:case ud:return Math.ceil(s/4)*Math.ceil(e/4)*16;case fd:case pd:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Il:case md:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Mb(s){switch(s){case kn:case Dm:return{byteLength:1,components:1};case qr:case Cm:case hn:return{byteLength:2,components:1};case tu:case nu:return{byteLength:2,components:4};case ii:case eu:case Vn:return{byteLength:4,components:1};case Rm:case Pm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jd}}));typeof window<"u"&&(window.__THREE__?Ee("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jd);/**
1864
1874
  * @license
1865
1875
  * Copyright 2010-2026 Three.js Authors
1866
1876
  * SPDX-License-Identifier: MIT
@@ -5530,7 +5540,7 @@ void main() {
5530
5540
  #include <tonemapping_fragment>
5531
5541
  #include <colorspace_fragment>
5532
5542
  #include <fog_fragment>
5533
- }`,Xe={alphahash_fragment:_b,alphahash_pars_fragment:Eb,alphamap_fragment:Tb,alphamap_pars_fragment:Ab,alphatest_fragment:Ib,alphatest_pars_fragment:Db,aomap_fragment:Cb,aomap_pars_fragment:Rb,batching_pars_vertex:Pb,batching_vertex:Lb,begin_vertex:Nb,beginnormal_vertex:Ob,bsdfs:kb,iridescence_fragment:Ub,bumpmap_pars_fragment:Fb,clipping_planes_fragment:Bb,clipping_planes_pars_fragment:zb,clipping_planes_pars_vertex:Hb,clipping_planes_vertex:Gb,color_fragment:Vb,color_pars_fragment:Wb,color_pars_vertex:Xb,color_vertex:qb,common:Yb,cube_uv_reflection_fragment:Kb,defaultnormal_vertex:$b,displacementmap_pars_vertex:Zb,displacementmap_vertex:Jb,emissivemap_fragment:jb,emissivemap_pars_fragment:Qb,colorspace_fragment:ex,colorspace_pars_fragment:tx,envmap_fragment:nx,envmap_common_pars_fragment:ix,envmap_pars_fragment:sx,envmap_pars_vertex:ax,envmap_physical_pars_fragment:gx,envmap_vertex:rx,fog_vertex:ox,fog_pars_vertex:lx,fog_fragment:cx,fog_pars_fragment:hx,gradientmap_pars_fragment:dx,lightmap_pars_fragment:ux,lights_lambert_fragment:fx,lights_lambert_pars_fragment:px,lights_pars_begin:mx,lights_toon_fragment:vx,lights_toon_pars_fragment:yx,lights_phong_fragment:bx,lights_phong_pars_fragment:xx,lights_physical_fragment:wx,lights_physical_pars_fragment:Mx,lights_fragment_begin:Sx,lights_fragment_maps:_x,lights_fragment_end:Ex,lightprobes_pars_fragment:Tx,logdepthbuf_fragment:Ax,logdepthbuf_pars_fragment:Ix,logdepthbuf_pars_vertex:Dx,logdepthbuf_vertex:Cx,map_fragment:Rx,map_pars_fragment:Px,map_particle_fragment:Lx,map_particle_pars_fragment:Nx,metalnessmap_fragment:Ox,metalnessmap_pars_fragment:kx,morphinstance_vertex:Ux,morphcolor_vertex:Fx,morphnormal_vertex:Bx,morphtarget_pars_vertex:zx,morphtarget_vertex:Hx,normal_fragment_begin:Gx,normal_fragment_maps:Vx,normal_pars_fragment:Wx,normal_pars_vertex:Xx,normal_vertex:qx,normalmap_pars_fragment:Yx,clearcoat_normal_fragment_begin:Kx,clearcoat_normal_fragment_maps:$x,clearcoat_pars_fragment:Zx,iridescence_pars_fragment:Jx,opaque_fragment:jx,packing:Qx,premultiplied_alpha_fragment:ew,project_vertex:tw,dithering_fragment:nw,dithering_pars_fragment:iw,roughnessmap_fragment:sw,roughnessmap_pars_fragment:aw,shadowmap_pars_fragment:rw,shadowmap_pars_vertex:ow,shadowmap_vertex:lw,shadowmask_pars_fragment:cw,skinbase_vertex:hw,skinning_pars_vertex:dw,skinning_vertex:uw,skinnormal_vertex:fw,specularmap_fragment:pw,specularmap_pars_fragment:mw,tonemapping_fragment:gw,tonemapping_pars_fragment:vw,transmission_fragment:yw,transmission_pars_fragment:bw,uv_pars_fragment:xw,uv_pars_vertex:ww,uv_vertex:Mw,worldpos_vertex:Sw,background_vert:_w,background_frag:Ew,backgroundCube_vert:Tw,backgroundCube_frag:Aw,cube_vert:Iw,cube_frag:Dw,depth_vert:Cw,depth_frag:Rw,distance_vert:Pw,distance_frag:Lw,equirect_vert:Nw,equirect_frag:Ow,linedashed_vert:kw,linedashed_frag:Uw,meshbasic_vert:Fw,meshbasic_frag:Bw,meshlambert_vert:zw,meshlambert_frag:Hw,meshmatcap_vert:Gw,meshmatcap_frag:Vw,meshnormal_vert:Ww,meshnormal_frag:Xw,meshphong_vert:qw,meshphong_frag:Yw,meshphysical_vert:Kw,meshphysical_frag:$w,meshtoon_vert:Zw,meshtoon_frag:Jw,points_vert:jw,points_frag:Qw,shadow_vert:e2,shadow_frag:t2,sprite_vert:n2,sprite_frag:i2},fe={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Be}},envmap:{envMap:{value:null},envMapRotation:{value:new Be},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Be}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Be}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Be},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Be},normalScale:{value:new Re(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Be},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Be}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Be}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Be}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(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 R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0},uvTransform:{value:new Be}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new Re(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}}},mi={basic:{uniforms:dn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:dn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},envMapIntensity:{value:1}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:dn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:dn([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:dn([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ve(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:dn([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:dn([fe.points,fe.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:dn([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:dn([fe.common,fe.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:dn([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.meshnormal_vert,fragmentShader:Xe.meshnormal_frag},sprite:{uniforms:dn([fe.sprite,fe.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new Be},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Be}},vertexShader:Xe.backgroundCube_vert,fragmentShader:Xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distance:{uniforms:dn([fe.common,fe.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xe.distance_vert,fragmentShader:Xe.distance_frag},shadow:{uniforms:dn([fe.lights,fe.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};mi.physical={uniforms:dn([mi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Be},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Be},clearcoatNormalScale:{value:new Re(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Be},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Be},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Be},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Be},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Be},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Be},transmissionSamplerSize:{value:new Re},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Be},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Be},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Be},anisotropyVector:{value:new Re},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Be}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};const Wo={r:0,b:0,g:0},s2=new qe,Jm=new Be;Jm.set(-1,0,0,0,1,0,0,0,1);function a2(s,e,t,n,i,a){const r=new ve(0);let o=i===!0?0:1,l,c,h=null,d=0,u=null;function f(S){let _=S.isScene===!0?S.background:null;if(_&&_.isTexture){const x=S.backgroundBlurriness>0;_=e.get(_,x)}return _}function g(S){let _=!1;const x=f(S);x===null?p(r,o):x&&x.isColor&&(p(x,1),_=!0);const M=s.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,a):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(s.autoClear||_)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,_){const x=f(_);x&&(x.isCubeTexture||x.mapping===Yl)?(c===void 0&&(c=new Ze(new Wn(1,1,1),new Nt({name:"BackgroundCubeMaterial",uniforms:Qa(mi.backgroundCube.uniforms),vertexShader:mi.backgroundCube.vertexShader,fragmentShader:mi.backgroundCube.fragmentShader,side:Vt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,E,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(s2.makeRotationFromEuler(_.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Jm),c.material.toneMapped=Qe.getTransfer(x.colorSpace)!==ot,(h!==x||d!==x.version||u!==s.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,u=s.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new Ze(new Zi(2,2),new Nt({name:"BackgroundMaterial",uniforms:Qa(mi.background.uniforms),vertexShader:mi.background.vertexShader,fragmentShader:mi.background.fragmentShader,side:vs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=Qe.getTransfer(x.colorSpace)!==ot,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,h=x,d=x.version,u=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function p(S,_){S.getRGB(Wo,Xm(s)),t.buffers.color.setClear(Wo.r,Wo.g,Wo.b,_,a)}function m(){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 r},setClearColor:function(S,_=1){r.set(S),o=_,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,p(r,o)},render:g,addToRenderList:v,dispose:m}}function r2(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=u(null);let a=i,r=!1;function o(D,P,V,q,O){let W=!1;const G=d(D,q,V,P);a!==G&&(a=G,c(a.object)),W=f(D,q,V,O),W&&g(D,q,V,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(W||r)&&(r=!1,x(D,P,V,q),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return s.createVertexArray()}function c(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function d(D,P,V,q){const O=q.wireframe===!0;let W=n[P.id];W===void 0&&(W={},n[P.id]=W);const G=D.isInstancedMesh===!0?D.id:0;let Z=W[G];Z===void 0&&(Z={},W[G]=Z);let te=Z[V.id];te===void 0&&(te={},Z[V.id]=te);let Q=te[O];return Q===void 0&&(Q=u(l()),te[O]=Q),Q}function u(D){const P=[],V=[],q=[];for(let O=0;O<t;O++)P[O]=0,V[O]=0,q[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:V,attributeDivisors:q,object:D,attributes:{},index:null}}function f(D,P,V,q){const O=a.attributes,W=P.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){const ie=O[te];let de=W[te];if(de===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(de=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(de=D.instanceColor)),ie===void 0||ie.attribute!==de||de&&ie.data!==de.data)return!0;G++}return a.attributesNum!==G||a.index!==q}function g(D,P,V,q){const O={},W=P.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){let ie=W[te];ie===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const de={};de.attribute=ie,ie&&ie.data&&(de.data=ie.data),O[te]=de,G++}a.attributes=O,a.attributesNum=G,a.index=q}function v(){const D=a.newAttributes;for(let P=0,V=D.length;P<V;P++)D[P]=0}function p(D){m(D,0)}function m(D,P){const V=a.newAttributes,q=a.enabledAttributes,O=a.attributeDivisors;V[D]=1,q[D]===0&&(s.enableVertexAttribArray(D),q[D]=1),O[D]!==P&&(s.vertexAttribDivisor(D,P),O[D]=P)}function S(){const D=a.newAttributes,P=a.enabledAttributes;for(let V=0,q=P.length;V<q;V++)P[V]!==D[V]&&(s.disableVertexAttribArray(V),P[V]=0)}function _(D,P,V,q,O,W,G){G===!0?s.vertexAttribIPointer(D,P,V,O,W):s.vertexAttribPointer(D,P,V,q,O,W)}function x(D,P,V,q){v();const O=q.attributes,W=V.getAttributes(),G=P.defaultAttributeValues;for(const Z in W){const te=W[Z];if(te.location>=0){let Q=O[Z];if(Q===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor)),Q!==void 0){const ie=Q.normalized,de=Q.itemSize,He=e.get(Q);if(He===void 0)continue;const Je=He.buffer,ze=He.type,Y=He.bytesPerElement,ae=ze===s.INT||ze===s.UNSIGNED_INT||Q.gpuType===eu;if(Q.isInterleavedBufferAttribute){const ne=Q.data,F=ne.stride,_e=Q.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<te.locationSize;Pe++)m(te.location+Pe,ne.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<te.locationSize;Pe++)p(te.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,Je);for(let Pe=0;Pe<te.locationSize;Pe++)_(te.location+Pe,de/te.locationSize,ze,ie,F*Y,(_e+de/te.locationSize*Pe)*Y,ae)}else{if(Q.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne,Q.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne);s.bindBuffer(s.ARRAY_BUFFER,Je);for(let ne=0;ne<te.locationSize;ne++)_(te.location+ne,de/te.locationSize,ze,ie,de*Y,de/te.locationSize*ne*Y,ae)}}else if(G!==void 0){const ie=G[Z];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(te.location,ie);break;case 3:s.vertexAttrib3fv(te.location,ie);break;case 4:s.vertexAttrib4fv(te.location,ie);break;default:s.vertexAttrib1fv(te.location,ie)}}}}S()}function M(){T();for(const D in n){const P=n[D];for(const V in P){const q=P[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D]}}function E(D){if(n[D.id]===void 0)return;const P=n[D.id];for(const V in P){const q=P[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D.id]}function I(D){for(const P in n){const V=n[P];for(const q in V){const O=V[q];if(O[D.id]===void 0)continue;const W=O[D.id];for(const G in W)h(W[G].object),delete W[G];delete O[D.id]}}}function y(D){for(const P in n){const V=n[P],q=D.isInstancedMesh===!0?D.id:0,O=V[q];if(O!==void 0){for(const W in O){const G=O[W];for(const Z in G)h(G[Z].object),delete G[Z];delete O[W]}delete V[q],Object.keys(V).length===0&&delete n[P]}}}function T(){C(),r=!0,a!==i&&(a=i,c(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:C,dispose:M,releaseStatesOfGeometry:E,releaseStatesOfObject:y,releaseStatesOfProgram:I,initAttributes:v,enableAttribute:p,disableUnusedAttributes:S}}function o2(s,e,t){let n;function i(l){n=l}function a(l,c){s.drawArrays(n,l,c),t.update(c,n,1)}function r(l,c,h){h!==0&&(s.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,n,1)}this.setMode=i,this.render=a,this.renderInstances=r,this.renderMultiDraw=o}function l2(s,e,t,n){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const I=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function r(I){return!(I!==yn&&n.convert(I)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(I){const y=I===cn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==kn&&n.convert(I)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&I!==Vn&&!y)}function l(I){if(I==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Ee("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Ee("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),x=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=s.getParameter(s.MAX_SAMPLES),E=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:r,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:S,maxVaryings:_,maxFragmentUniforms:x,maxSamples:M,samples:E}}function c2(s){const e=this;let t=null,n=0,i=!1,a=!1;const r=new Rs,o=new Be,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const f=d.length!==0||u||n!==0||i;return i=u,n=d.length,f},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){const g=d.clippingPlanes,v=d.clipIntersection,p=d.clipShadows,m=s.get(d);if(!i||g===null||g.length===0||a&&!p)a?h(null):c();else{const S=a?0:n,_=S*4;let x=m.clippingState||null;l.value=x,x=h(g,u,_,f);for(let M=0;M!==_;++M)x[M]=t[M];m.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){const v=d!==null?d.length:0;let p=null;if(v!==0){if(p=l.value,g!==!0||p===null){const m=f+v*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(p===null||p.length<m)&&(p=new Float32Array(m));for(let _=0,x=f;_!==v;++_,x+=4)r.copy(d[_]).applyMatrix4(S,o),r.normal.toArray(p,x),p[x+3]=r.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,p}}const fs=4,dp=[.125,.215,.35,.446,.526,.582],Os=20,h2=256,yr=new ar,up=new ve;let zc=null,Hc=0,Gc=0,Vc=!1;const d2=new R;class fp{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,n=.1,i=100,a={}){const{size:r=256,position:o=d2}=a;zc=this._renderer.getRenderTarget(),Hc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Vc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,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=gp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mp(),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(zc,Hc,Gc),this._renderer.xr.enabled=Vc,e.scissorTest=!1,wa(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===qs||e.mapping===Ja?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zc=this._renderer.getRenderTarget(),Hc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Vc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:At,minFilter:At,generateMipmaps:!1,type:cn,format:yn,colorSpace:Rl,depthBuffer:!1},i=pp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=pp(e,t,n);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=u2(a)),this._blurMaterial=p2(a,e,t),this._ggxMaterial=f2(a,e,t)}return i}_compileMaterial(e){const t=new Ze(new Dt,e);this._renderer.compile(t,yr)}_sceneToCubeUV(e,t,n,i,a){const l=new _n(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(up),d.toneMapping=_i,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(i),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ze(new Wn,new Vi({name:"PMREM.Background",side:Vt,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,p=v.material;let m=!1;const S=e.background;S?S.isColor&&(p.color.copy(S),e.background=null,m=!0):(p.color.copy(up),m=!0);for(let _=0;_<6;_++){const x=_%3;x===0?(l.up.set(0,c[_],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+h[_],a.y,a.z)):x===1?(l.up.set(0,0,c[_]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+h[_],a.z)):(l.up.set(0,c[_],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+h[_]));const M=this._cubeSize;wa(i,x*M,_>2?M:0,M,M),d.setRenderTarget(i),m&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=S}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===qs||e.mapping===Ja;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=gp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=mp());const a=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;wa(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(r,yr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,a=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[n];o.material=r;const l=r.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:g}=this,v=this._sizeLods[n],p=3*v*(n>g-fs?n-g+fs:0),m=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,wa(a,p,m,3*v,2*v),i.setRenderTarget(a),i.render(o,yr),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=g-n,wa(e,p,m,3*v,2*v),i.setRenderTarget(e),i.render(o,yr)}_blur(e,t,n,i,a){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,n,i,"latitudinal",a),this._halfBlur(r,e,n,n,i,"longitudinal",a)}_halfBlur(e,t,n,i,a,r,o){const l=this._renderer,c=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Fe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[i];d.material=c;const u=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(a)?Math.PI/(2*f):2*Math.PI/(2*Os-1),v=a/g,p=isFinite(a)?1+Math.floor(h*v):Os;p>Os&&Ee(`sigmaRadians, ${a}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Os}`);const m=[];let S=0;for(let I=0;I<Os;++I){const y=I/v,T=Math.exp(-y*y/2);m.push(T),I===0?S+=T:I<p&&(S+=2*T)}for(let I=0;I<m.length;I++)m[I]=m[I]/S;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value=r==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:_}=this;u.dTheta.value=g,u.mipInt.value=_-n;const x=this._sizeLods[i],M=3*x*(i>_-fs?i-_+fs:0),E=4*(this._cubeSize-x);wa(t,M,E,3*x,2*x),l.setRenderTarget(t),l.render(d,yr)}}function u2(s){const e=[],t=[],n=[];let i=s;const a=s-fs+1+dp.length;for(let r=0;r<a;r++){const o=Math.pow(2,i);e.push(o);let l=1/o;r>s-fs?l=dp[r-s+fs-1]:r===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,g=6,v=3,p=2,m=1,S=new Float32Array(v*g*f),_=new Float32Array(p*g*f),x=new Float32Array(m*g*f);for(let E=0;E<f;E++){const I=E%3*2/3-1,y=E>2?0:-1,T=[I,y,0,I+2/3,y,0,I+2/3,y+1,0,I,y,0,I+2/3,y+1,0,I,y+1,0];S.set(T,v*g*E),_.set(u,p*g*E);const C=[E,E,E,E,E,E];x.set(C,m*g*E)}const M=new Dt;M.setAttribute("position",new vt(S,v)),M.setAttribute("uv",new vt(_,p)),M.setAttribute("faceIndex",new vt(x,m)),n.push(new Ze(M,null)),i>fs&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function pp(s,e,t){const n=new En(s,e,t);return n.texture.mapping=Yl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function wa(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function f2(s,e,t){return new Nt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:h2,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Zl(),fragmentShader:`
5543
+ }`,Xe={alphahash_fragment:_b,alphahash_pars_fragment:Eb,alphamap_fragment:Tb,alphamap_pars_fragment:Ab,alphatest_fragment:Ib,alphatest_pars_fragment:Db,aomap_fragment:Cb,aomap_pars_fragment:Rb,batching_pars_vertex:Pb,batching_vertex:Lb,begin_vertex:Nb,beginnormal_vertex:Ob,bsdfs:kb,iridescence_fragment:Ub,bumpmap_pars_fragment:Fb,clipping_planes_fragment:Bb,clipping_planes_pars_fragment:zb,clipping_planes_pars_vertex:Hb,clipping_planes_vertex:Gb,color_fragment:Vb,color_pars_fragment:Wb,color_pars_vertex:Xb,color_vertex:qb,common:Yb,cube_uv_reflection_fragment:Kb,defaultnormal_vertex:$b,displacementmap_pars_vertex:Zb,displacementmap_vertex:Jb,emissivemap_fragment:jb,emissivemap_pars_fragment:Qb,colorspace_fragment:ex,colorspace_pars_fragment:tx,envmap_fragment:nx,envmap_common_pars_fragment:ix,envmap_pars_fragment:sx,envmap_pars_vertex:ax,envmap_physical_pars_fragment:gx,envmap_vertex:rx,fog_vertex:ox,fog_pars_vertex:lx,fog_fragment:cx,fog_pars_fragment:hx,gradientmap_pars_fragment:dx,lightmap_pars_fragment:ux,lights_lambert_fragment:fx,lights_lambert_pars_fragment:px,lights_pars_begin:mx,lights_toon_fragment:vx,lights_toon_pars_fragment:yx,lights_phong_fragment:bx,lights_phong_pars_fragment:xx,lights_physical_fragment:wx,lights_physical_pars_fragment:Mx,lights_fragment_begin:Sx,lights_fragment_maps:_x,lights_fragment_end:Ex,lightprobes_pars_fragment:Tx,logdepthbuf_fragment:Ax,logdepthbuf_pars_fragment:Ix,logdepthbuf_pars_vertex:Dx,logdepthbuf_vertex:Cx,map_fragment:Rx,map_pars_fragment:Px,map_particle_fragment:Lx,map_particle_pars_fragment:Nx,metalnessmap_fragment:Ox,metalnessmap_pars_fragment:kx,morphinstance_vertex:Ux,morphcolor_vertex:Fx,morphnormal_vertex:Bx,morphtarget_pars_vertex:zx,morphtarget_vertex:Hx,normal_fragment_begin:Gx,normal_fragment_maps:Vx,normal_pars_fragment:Wx,normal_pars_vertex:Xx,normal_vertex:qx,normalmap_pars_fragment:Yx,clearcoat_normal_fragment_begin:Kx,clearcoat_normal_fragment_maps:$x,clearcoat_pars_fragment:Zx,iridescence_pars_fragment:Jx,opaque_fragment:jx,packing:Qx,premultiplied_alpha_fragment:ew,project_vertex:tw,dithering_fragment:nw,dithering_pars_fragment:iw,roughnessmap_fragment:sw,roughnessmap_pars_fragment:aw,shadowmap_pars_fragment:rw,shadowmap_pars_vertex:ow,shadowmap_vertex:lw,shadowmask_pars_fragment:cw,skinbase_vertex:hw,skinning_pars_vertex:dw,skinning_vertex:uw,skinnormal_vertex:fw,specularmap_fragment:pw,specularmap_pars_fragment:mw,tonemapping_fragment:gw,tonemapping_pars_fragment:vw,transmission_fragment:yw,transmission_pars_fragment:bw,uv_pars_fragment:xw,uv_pars_vertex:ww,uv_vertex:Mw,worldpos_vertex:Sw,background_vert:_w,background_frag:Ew,backgroundCube_vert:Tw,backgroundCube_frag:Aw,cube_vert:Iw,cube_frag:Dw,depth_vert:Cw,depth_frag:Rw,distance_vert:Pw,distance_frag:Lw,equirect_vert:Nw,equirect_frag:Ow,linedashed_vert:kw,linedashed_frag:Uw,meshbasic_vert:Fw,meshbasic_frag:Bw,meshlambert_vert:zw,meshlambert_frag:Hw,meshmatcap_vert:Gw,meshmatcap_frag:Vw,meshnormal_vert:Ww,meshnormal_frag:Xw,meshphong_vert:qw,meshphong_frag:Yw,meshphysical_vert:Kw,meshphysical_frag:$w,meshtoon_vert:Zw,meshtoon_frag:Jw,points_vert:jw,points_frag:Qw,shadow_vert:e2,shadow_frag:t2,sprite_vert:n2,sprite_frag:i2},fe={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Be}},envmap:{envMap:{value:null},envMapRotation:{value:new Be},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Be}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Be}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Be},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Be},normalScale:{value:new Re(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Be},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Be}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Be}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Be}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(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 R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0},uvTransform:{value:new Be}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new Re(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}}},gi={basic:{uniforms:un([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:un([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},envMapIntensity:{value:1}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:un([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:un([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:un([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ve(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:un([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:un([fe.points,fe.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:un([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:un([fe.common,fe.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:un([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.meshnormal_vert,fragmentShader:Xe.meshnormal_frag},sprite:{uniforms:un([fe.sprite,fe.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new Be},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Be}},vertexShader:Xe.backgroundCube_vert,fragmentShader:Xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distance:{uniforms:un([fe.common,fe.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xe.distance_vert,fragmentShader:Xe.distance_frag},shadow:{uniforms:un([fe.lights,fe.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};gi.physical={uniforms:un([gi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Be},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Be},clearcoatNormalScale:{value:new Re(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Be},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Be},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Be},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Be},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Be},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Be},transmissionSamplerSize:{value:new Re},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Be},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Be},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Be},anisotropyVector:{value:new Re},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Be}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};const Wo={r:0,b:0,g:0},s2=new qe,Jm=new Be;Jm.set(-1,0,0,0,1,0,0,0,1);function a2(s,e,t,n,i,a){const r=new ve(0);let o=i===!0?0:1,l,c,h=null,d=0,u=null;function f(S){let _=S.isScene===!0?S.background:null;if(_&&_.isTexture){const x=S.backgroundBlurriness>0;_=e.get(_,x)}return _}function g(S){let _=!1;const x=f(S);x===null?p(r,o):x&&x.isColor&&(p(x,1),_=!0);const M=s.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,a):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(s.autoClear||_)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,_){const x=f(_);x&&(x.isCubeTexture||x.mapping===Yl)?(c===void 0&&(c=new Ze(new Wn(1,1,1),new Nt({name:"BackgroundCubeMaterial",uniforms:Qa(gi.backgroundCube.uniforms),vertexShader:gi.backgroundCube.vertexShader,fragmentShader:gi.backgroundCube.fragmentShader,side:Vt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,E,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(s2.makeRotationFromEuler(_.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Jm),c.material.toneMapped=Qe.getTransfer(x.colorSpace)!==lt,(h!==x||d!==x.version||u!==s.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,u=s.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new Ze(new Zi(2,2),new Nt({name:"BackgroundMaterial",uniforms:Qa(gi.background.uniforms),vertexShader:gi.background.vertexShader,fragmentShader:gi.background.fragmentShader,side:vs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=Qe.getTransfer(x.colorSpace)!==lt,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,h=x,d=x.version,u=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function p(S,_){S.getRGB(Wo,Xm(s)),t.buffers.color.setClear(Wo.r,Wo.g,Wo.b,_,a)}function m(){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 r},setClearColor:function(S,_=1){r.set(S),o=_,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,p(r,o)},render:g,addToRenderList:v,dispose:m}}function r2(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=u(null);let a=i,r=!1;function o(D,P,V,q,O){let W=!1;const G=d(D,q,V,P);a!==G&&(a=G,c(a.object)),W=f(D,q,V,O),W&&g(D,q,V,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(W||r)&&(r=!1,x(D,P,V,q),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return s.createVertexArray()}function c(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function d(D,P,V,q){const O=q.wireframe===!0;let W=n[P.id];W===void 0&&(W={},n[P.id]=W);const G=D.isInstancedMesh===!0?D.id:0;let Z=W[G];Z===void 0&&(Z={},W[G]=Z);let te=Z[V.id];te===void 0&&(te={},Z[V.id]=te);let Q=te[O];return Q===void 0&&(Q=u(l()),te[O]=Q),Q}function u(D){const P=[],V=[],q=[];for(let O=0;O<t;O++)P[O]=0,V[O]=0,q[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:V,attributeDivisors:q,object:D,attributes:{},index:null}}function f(D,P,V,q){const O=a.attributes,W=P.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){const ie=O[te];let de=W[te];if(de===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(de=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(de=D.instanceColor)),ie===void 0||ie.attribute!==de||de&&ie.data!==de.data)return!0;G++}return a.attributesNum!==G||a.index!==q}function g(D,P,V,q){const O={},W=P.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){let ie=W[te];ie===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const de={};de.attribute=ie,ie&&ie.data&&(de.data=ie.data),O[te]=de,G++}a.attributes=O,a.attributesNum=G,a.index=q}function v(){const D=a.newAttributes;for(let P=0,V=D.length;P<V;P++)D[P]=0}function p(D){m(D,0)}function m(D,P){const V=a.newAttributes,q=a.enabledAttributes,O=a.attributeDivisors;V[D]=1,q[D]===0&&(s.enableVertexAttribArray(D),q[D]=1),O[D]!==P&&(s.vertexAttribDivisor(D,P),O[D]=P)}function S(){const D=a.newAttributes,P=a.enabledAttributes;for(let V=0,q=P.length;V<q;V++)P[V]!==D[V]&&(s.disableVertexAttribArray(V),P[V]=0)}function _(D,P,V,q,O,W,G){G===!0?s.vertexAttribIPointer(D,P,V,O,W):s.vertexAttribPointer(D,P,V,q,O,W)}function x(D,P,V,q){v();const O=q.attributes,W=V.getAttributes(),G=P.defaultAttributeValues;for(const Z in W){const te=W[Z];if(te.location>=0){let Q=O[Z];if(Q===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor)),Q!==void 0){const ie=Q.normalized,de=Q.itemSize,He=e.get(Q);if(He===void 0)continue;const Je=He.buffer,ze=He.type,Y=He.bytesPerElement,ae=ze===s.INT||ze===s.UNSIGNED_INT||Q.gpuType===eu;if(Q.isInterleavedBufferAttribute){const ne=Q.data,F=ne.stride,_e=Q.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<te.locationSize;Pe++)m(te.location+Pe,ne.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<te.locationSize;Pe++)p(te.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,Je);for(let Pe=0;Pe<te.locationSize;Pe++)_(te.location+Pe,de/te.locationSize,ze,ie,F*Y,(_e+de/te.locationSize*Pe)*Y,ae)}else{if(Q.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne,Q.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne);s.bindBuffer(s.ARRAY_BUFFER,Je);for(let ne=0;ne<te.locationSize;ne++)_(te.location+ne,de/te.locationSize,ze,ie,de*Y,de/te.locationSize*ne*Y,ae)}}else if(G!==void 0){const ie=G[Z];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(te.location,ie);break;case 3:s.vertexAttrib3fv(te.location,ie);break;case 4:s.vertexAttrib4fv(te.location,ie);break;default:s.vertexAttrib1fv(te.location,ie)}}}}S()}function M(){T();for(const D in n){const P=n[D];for(const V in P){const q=P[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D]}}function E(D){if(n[D.id]===void 0)return;const P=n[D.id];for(const V in P){const q=P[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D.id]}function I(D){for(const P in n){const V=n[P];for(const q in V){const O=V[q];if(O[D.id]===void 0)continue;const W=O[D.id];for(const G in W)h(W[G].object),delete W[G];delete O[D.id]}}}function y(D){for(const P in n){const V=n[P],q=D.isInstancedMesh===!0?D.id:0,O=V[q];if(O!==void 0){for(const W in O){const G=O[W];for(const Z in G)h(G[Z].object),delete G[Z];delete O[W]}delete V[q],Object.keys(V).length===0&&delete n[P]}}}function T(){C(),r=!0,a!==i&&(a=i,c(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:C,dispose:M,releaseStatesOfGeometry:E,releaseStatesOfObject:y,releaseStatesOfProgram:I,initAttributes:v,enableAttribute:p,disableUnusedAttributes:S}}function o2(s,e,t){let n;function i(l){n=l}function a(l,c){s.drawArrays(n,l,c),t.update(c,n,1)}function r(l,c,h){h!==0&&(s.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,n,1)}this.setMode=i,this.render=a,this.renderInstances=r,this.renderMultiDraw=o}function l2(s,e,t,n){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const I=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function r(I){return!(I!==yn&&n.convert(I)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(I){const y=I===hn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==kn&&n.convert(I)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&I!==Vn&&!y)}function l(I){if(I==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Ee("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Ee("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),x=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=s.getParameter(s.MAX_SAMPLES),E=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:r,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:S,maxVaryings:_,maxFragmentUniforms:x,maxSamples:M,samples:E}}function c2(s){const e=this;let t=null,n=0,i=!1,a=!1;const r=new Rs,o=new Be,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const f=d.length!==0||u||n!==0||i;return i=u,n=d.length,f},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){const g=d.clippingPlanes,v=d.clipIntersection,p=d.clipShadows,m=s.get(d);if(!i||g===null||g.length===0||a&&!p)a?h(null):c();else{const S=a?0:n,_=S*4;let x=m.clippingState||null;l.value=x,x=h(g,u,_,f);for(let M=0;M!==_;++M)x[M]=t[M];m.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){const v=d!==null?d.length:0;let p=null;if(v!==0){if(p=l.value,g!==!0||p===null){const m=f+v*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(p===null||p.length<m)&&(p=new Float32Array(m));for(let _=0,x=f;_!==v;++_,x+=4)r.copy(d[_]).applyMatrix4(S,o),r.normal.toArray(p,x),p[x+3]=r.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,p}}const fs=4,dp=[.125,.215,.35,.446,.526,.582],Os=20,h2=256,yr=new ar,up=new ve;let zc=null,Hc=0,Gc=0,Vc=!1;const d2=new R;class fp{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,n=.1,i=100,a={}){const{size:r=256,position:o=d2}=a;zc=this._renderer.getRenderTarget(),Hc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Vc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,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=gp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mp(),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(zc,Hc,Gc),this._renderer.xr.enabled=Vc,e.scissorTest=!1,wa(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===qs||e.mapping===Ja?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zc=this._renderer.getRenderTarget(),Hc=this._renderer.getActiveCubeFace(),Gc=this._renderer.getActiveMipmapLevel(),Vc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:At,minFilter:At,generateMipmaps:!1,type:hn,format:yn,colorSpace:Rl,depthBuffer:!1},i=pp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=pp(e,t,n);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=u2(a)),this._blurMaterial=p2(a,e,t),this._ggxMaterial=f2(a,e,t)}return i}_compileMaterial(e){const t=new Ze(new Dt,e);this._renderer.compile(t,yr)}_sceneToCubeUV(e,t,n,i,a){const l=new En(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(up),d.toneMapping=_i,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(i),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ze(new Wn,new Vi({name:"PMREM.Background",side:Vt,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,p=v.material;let m=!1;const S=e.background;S?S.isColor&&(p.color.copy(S),e.background=null,m=!0):(p.color.copy(up),m=!0);for(let _=0;_<6;_++){const x=_%3;x===0?(l.up.set(0,c[_],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+h[_],a.y,a.z)):x===1?(l.up.set(0,0,c[_]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+h[_],a.z)):(l.up.set(0,c[_],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+h[_]));const M=this._cubeSize;wa(i,x*M,_>2?M:0,M,M),d.setRenderTarget(i),m&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=S}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===qs||e.mapping===Ja;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=gp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=mp());const a=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;wa(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(r,yr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,a=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[n];o.material=r;const l=r.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:g}=this,v=this._sizeLods[n],p=3*v*(n>g-fs?n-g+fs:0),m=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,wa(a,p,m,3*v,2*v),i.setRenderTarget(a),i.render(o,yr),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=g-n,wa(e,p,m,3*v,2*v),i.setRenderTarget(e),i.render(o,yr)}_blur(e,t,n,i,a){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,n,i,"latitudinal",a),this._halfBlur(r,e,n,n,i,"longitudinal",a)}_halfBlur(e,t,n,i,a,r,o){const l=this._renderer,c=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Fe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[i];d.material=c;const u=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(a)?Math.PI/(2*f):2*Math.PI/(2*Os-1),v=a/g,p=isFinite(a)?1+Math.floor(h*v):Os;p>Os&&Ee(`sigmaRadians, ${a}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Os}`);const m=[];let S=0;for(let I=0;I<Os;++I){const y=I/v,T=Math.exp(-y*y/2);m.push(T),I===0?S+=T:I<p&&(S+=2*T)}for(let I=0;I<m.length;I++)m[I]=m[I]/S;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value=r==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:_}=this;u.dTheta.value=g,u.mipInt.value=_-n;const x=this._sizeLods[i],M=3*x*(i>_-fs?i-_+fs:0),E=4*(this._cubeSize-x);wa(t,M,E,3*x,2*x),l.setRenderTarget(t),l.render(d,yr)}}function u2(s){const e=[],t=[],n=[];let i=s;const a=s-fs+1+dp.length;for(let r=0;r<a;r++){const o=Math.pow(2,i);e.push(o);let l=1/o;r>s-fs?l=dp[r-s+fs-1]:r===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,g=6,v=3,p=2,m=1,S=new Float32Array(v*g*f),_=new Float32Array(p*g*f),x=new Float32Array(m*g*f);for(let E=0;E<f;E++){const I=E%3*2/3-1,y=E>2?0:-1,T=[I,y,0,I+2/3,y,0,I+2/3,y+1,0,I,y,0,I+2/3,y+1,0,I,y+1,0];S.set(T,v*g*E),_.set(u,p*g*E);const C=[E,E,E,E,E,E];x.set(C,m*g*E)}const M=new Dt;M.setAttribute("position",new gt(S,v)),M.setAttribute("uv",new gt(_,p)),M.setAttribute("faceIndex",new gt(x,m)),n.push(new Ze(M,null)),i>fs&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function pp(s,e,t){const n=new Tn(s,e,t);return n.texture.mapping=Yl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function wa(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function f2(s,e,t){return new Nt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:h2,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Zl(),fragmentShader:`
5534
5544
 
5535
5545
  precision highp float;
5536
5546
  precision highp int;
@@ -5784,7 +5794,7 @@ void main() {
5784
5794
  gl_Position = vec4( position, 1.0 );
5785
5795
 
5786
5796
  }
5787
- `}class jm extends En{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Vm(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
5797
+ `}class jm extends Tn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Vm(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
5788
5798
 
5789
5799
  varying vec3 vWorldDirection;
5790
5800
 
@@ -5819,7 +5829,7 @@ void main() {
5819
5829
  gl_FragColor = texture2D( tEquirect, sampleUV );
5820
5830
 
5821
5831
  }
5822
- `},i=new Wn(5,5,5),a=new Nt({name:"CubemapFromEquirect",uniforms:Qa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Vt,blending:Si});a.uniforms.tEquirect.value=t;const r=new Ze(i,a),o=t.minFilter;return t.minFilter===Bs&&(t.minFilter=At),new db(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const a=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(a)}}function m2(s){let e=new WeakMap,t=new WeakMap,n=null;function i(u,f=!1){return u==null?null:f?r(u):a(u)}function a(u){if(u&&u.isTexture){const f=u.mapping;if(f===oc||f===lc)if(e.has(u)){const g=e.get(u).texture;return o(g,u.mapping)}else{const g=u.image;if(g&&g.height>0){const v=new jm(g.height);return v.fromEquirectangularTexture(s,u),e.set(u,v),u.addEventListener("dispose",c),o(v.texture,u.mapping)}else return null}}return u}function r(u){if(u&&u.isTexture){const f=u.mapping,g=f===oc||f===lc,v=f===qs||f===Ja;if(g||v){let p=t.get(u);const m=p!==void 0?p.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==m)return n===null&&(n=new fp(s)),p=g?n.fromEquirectangular(u,p):n.fromCubemap(u,p),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),p.texture;if(p!==void 0)return p.texture;{const S=u.image;return g&&S&&S.height>0||v&&S&&l(S)?(n===null&&(n=new fp(s)),p=g?n.fromEquirectangular(u):n.fromCubemap(u),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),u.addEventListener("dispose",h),p.texture):null}}}return u}function o(u,f){return f===oc?u.mapping=qs:f===lc&&(u.mapping=Ja),u}function l(u){let f=0;const g=6;for(let v=0;v<g;v++)u[v]!==void 0&&f++;return f===g}function c(u){const f=u.target;f.removeEventListener("dispose",c);const g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function h(u){const f=u.target;f.removeEventListener("dispose",h);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:d}}function g2(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&Fa("WebGLRenderer: "+n+" extension not supported."),i}}}function v2(s,e,t,n){const i={},a=new WeakMap;function r(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const g in u.attributes)e.remove(u.attributes[g]);u.removeEventListener("dispose",r),delete i[u.id];const f=a.get(u);f&&(e.remove(f),a.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return i[u.id]===!0||(u.addEventListener("dispose",r),i[u.id]=!0,t.memory.geometries++),u}function l(d){const u=d.attributes;for(const f in u)e.update(u[f],s.ARRAY_BUFFER)}function c(d){const u=[],f=d.index,g=d.attributes.position;let v=0;if(g===void 0)return;if(f!==null){const S=f.array;v=f.version;for(let _=0,x=S.length;_<x;_+=3){const M=S[_+0],E=S[_+1],I=S[_+2];u.push(M,E,E,I,I,M)}}else{const S=g.array;v=g.version;for(let _=0,x=S.length/3-1;_<x;_+=3){const M=_+0,E=_+1,I=_+2;u.push(M,E,E,I,I,M)}}const p=new(g.count>=65535?fu:Fm)(u,1);p.version=v;const m=a.get(d);m&&e.remove(m),a.set(d,p)}function h(d){const u=a.get(d);if(u){const f=d.index;f!==null&&u.version<f.version&&c(d)}else c(d);return a.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function y2(s,e,t){let n;function i(d){n=d}let a,r;function o(d){a=d.type,r=d.bytesPerElement}function l(d,u){s.drawElements(n,u,a,d*r),t.update(u,n,1)}function c(d,u,f){f!==0&&(s.drawElementsInstanced(n,u,a,d*r,f),t.update(u,n,f))}function h(d,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,a,d,0,f);let v=0;for(let p=0;p<f;p++)v+=u[p];t.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function b2(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(a,r,o){switch(t.calls++,r){case s.TRIANGLES:t.triangles+=o*(a/3);break;case s.LINES:t.lines+=o*(a/2);break;case s.LINE_STRIP:t.lines+=o*(a-1);break;case s.LINE_LOOP:t.lines+=o*a;break;case s.POINTS:t.points+=o*a;break;default:Fe("WebGLInfo: Unknown draw mode:",r);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function x2(s,e,t){const n=new WeakMap,i=new pt;function a(r,o,l){const c=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let u=n.get(o);if(u===void 0||u.count!==d){let T=function(){I.dispose(),n.delete(o),o.removeEventListener("dispose",T)};u!==void 0&&u.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let _=0;f===!0&&(_=1),g===!0&&(_=2),v===!0&&(_=3);let x=o.attributes.position.count*_,M=1;x>e.maxTextureSize&&(M=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const E=new Float32Array(x*M*4*d),I=new km(E,x,M,d);I.type=Vn,I.needsUpdate=!0;const y=_*4;for(let C=0;C<d;C++){const D=p[C],P=m[C],V=S[C],q=x*M*4*C;for(let O=0;O<D.count;O++){const W=O*y;f===!0&&(i.fromBufferAttribute(D,O),E[q+W+0]=i.x,E[q+W+1]=i.y,E[q+W+2]=i.z,E[q+W+3]=0),g===!0&&(i.fromBufferAttribute(P,O),E[q+W+4]=i.x,E[q+W+5]=i.y,E[q+W+6]=i.z,E[q+W+7]=0),v===!0&&(i.fromBufferAttribute(V,O),E[q+W+8]=i.x,E[q+W+9]=i.y,E[q+W+10]=i.z,E[q+W+11]=V.itemSize===4?i.w:1)}}u={count:d,texture:I,size:new Re(x,M)},n.set(o,u),o.addEventListener("dispose",T)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",r.morphTexture,t);else{let f=0;for(let v=0;v<c.length;v++)f+=c[v];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",u.size)}return{update:a}}function w2(s,e,t,n,i){let a=new WeakMap;function r(c){const h=i.render.frame,d=c.geometry,u=e.get(c,d);if(a.get(u)!==h&&(e.update(u),a.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),a.get(c)!==h&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),a.set(c,h))),c.isSkinnedMesh){const f=c.skeleton;a.get(f)!==h&&(f.update(),a.set(f,h))}return u}function o(){a=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:r,dispose:o}}const M2={[wm]:"LINEAR_TONE_MAPPING",[Mm]:"REINHARD_TONE_MAPPING",[Sm]:"CINEON_TONE_MAPPING",[_m]:"ACES_FILMIC_TONE_MAPPING",[Tm]:"AGX_TONE_MAPPING",[Am]:"NEUTRAL_TONE_MAPPING",[Em]:"CUSTOM_TONE_MAPPING"};function S2(s,e,t,n,i,a){const r=new En(e,t,{type:s,depthBuffer:i,stencilBuffer:a,samples:n?4:0,depthTexture:i?new Ks(e,t):void 0}),o=new En(e,t,{type:cn,depthBuffer:!1,stencilBuffer:!1}),l=new Dt;l.setAttribute("position",new It([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new It([0,2,0,0,2,0],2));const c=new Gy({uniforms:{tDiffuse:{value:null}},vertexShader:`
5832
+ `},i=new Wn(5,5,5),a=new Nt({name:"CubemapFromEquirect",uniforms:Qa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Vt,blending:Si});a.uniforms.tEquirect.value=t;const r=new Ze(i,a),o=t.minFilter;return t.minFilter===Bs&&(t.minFilter=At),new db(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const a=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(a)}}function m2(s){let e=new WeakMap,t=new WeakMap,n=null;function i(u,f=!1){return u==null?null:f?r(u):a(u)}function a(u){if(u&&u.isTexture){const f=u.mapping;if(f===oc||f===lc)if(e.has(u)){const g=e.get(u).texture;return o(g,u.mapping)}else{const g=u.image;if(g&&g.height>0){const v=new jm(g.height);return v.fromEquirectangularTexture(s,u),e.set(u,v),u.addEventListener("dispose",c),o(v.texture,u.mapping)}else return null}}return u}function r(u){if(u&&u.isTexture){const f=u.mapping,g=f===oc||f===lc,v=f===qs||f===Ja;if(g||v){let p=t.get(u);const m=p!==void 0?p.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==m)return n===null&&(n=new fp(s)),p=g?n.fromEquirectangular(u,p):n.fromCubemap(u,p),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),p.texture;if(p!==void 0)return p.texture;{const S=u.image;return g&&S&&S.height>0||v&&S&&l(S)?(n===null&&(n=new fp(s)),p=g?n.fromEquirectangular(u):n.fromCubemap(u),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),u.addEventListener("dispose",h),p.texture):null}}}return u}function o(u,f){return f===oc?u.mapping=qs:f===lc&&(u.mapping=Ja),u}function l(u){let f=0;const g=6;for(let v=0;v<g;v++)u[v]!==void 0&&f++;return f===g}function c(u){const f=u.target;f.removeEventListener("dispose",c);const g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function h(u){const f=u.target;f.removeEventListener("dispose",h);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:d}}function g2(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&Fa("WebGLRenderer: "+n+" extension not supported."),i}}}function v2(s,e,t,n){const i={},a=new WeakMap;function r(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const g in u.attributes)e.remove(u.attributes[g]);u.removeEventListener("dispose",r),delete i[u.id];const f=a.get(u);f&&(e.remove(f),a.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return i[u.id]===!0||(u.addEventListener("dispose",r),i[u.id]=!0,t.memory.geometries++),u}function l(d){const u=d.attributes;for(const f in u)e.update(u[f],s.ARRAY_BUFFER)}function c(d){const u=[],f=d.index,g=d.attributes.position;let v=0;if(g===void 0)return;if(f!==null){const S=f.array;v=f.version;for(let _=0,x=S.length;_<x;_+=3){const M=S[_+0],E=S[_+1],I=S[_+2];u.push(M,E,E,I,I,M)}}else{const S=g.array;v=g.version;for(let _=0,x=S.length/3-1;_<x;_+=3){const M=_+0,E=_+1,I=_+2;u.push(M,E,E,I,I,M)}}const p=new(g.count>=65535?fu:Fm)(u,1);p.version=v;const m=a.get(d);m&&e.remove(m),a.set(d,p)}function h(d){const u=a.get(d);if(u){const f=d.index;f!==null&&u.version<f.version&&c(d)}else c(d);return a.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function y2(s,e,t){let n;function i(d){n=d}let a,r;function o(d){a=d.type,r=d.bytesPerElement}function l(d,u){s.drawElements(n,u,a,d*r),t.update(u,n,1)}function c(d,u,f){f!==0&&(s.drawElementsInstanced(n,u,a,d*r,f),t.update(u,n,f))}function h(d,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,a,d,0,f);let v=0;for(let p=0;p<f;p++)v+=u[p];t.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function b2(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(a,r,o){switch(t.calls++,r){case s.TRIANGLES:t.triangles+=o*(a/3);break;case s.LINES:t.lines+=o*(a/2);break;case s.LINE_STRIP:t.lines+=o*(a-1);break;case s.LINE_LOOP:t.lines+=o*a;break;case s.POINTS:t.points+=o*a;break;default:Fe("WebGLInfo: Unknown draw mode:",r);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function x2(s,e,t){const n=new WeakMap,i=new ft;function a(r,o,l){const c=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let u=n.get(o);if(u===void 0||u.count!==d){let T=function(){I.dispose(),n.delete(o),o.removeEventListener("dispose",T)};u!==void 0&&u.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let _=0;f===!0&&(_=1),g===!0&&(_=2),v===!0&&(_=3);let x=o.attributes.position.count*_,M=1;x>e.maxTextureSize&&(M=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const E=new Float32Array(x*M*4*d),I=new km(E,x,M,d);I.type=Vn,I.needsUpdate=!0;const y=_*4;for(let C=0;C<d;C++){const D=p[C],P=m[C],V=S[C],q=x*M*4*C;for(let O=0;O<D.count;O++){const W=O*y;f===!0&&(i.fromBufferAttribute(D,O),E[q+W+0]=i.x,E[q+W+1]=i.y,E[q+W+2]=i.z,E[q+W+3]=0),g===!0&&(i.fromBufferAttribute(P,O),E[q+W+4]=i.x,E[q+W+5]=i.y,E[q+W+6]=i.z,E[q+W+7]=0),v===!0&&(i.fromBufferAttribute(V,O),E[q+W+8]=i.x,E[q+W+9]=i.y,E[q+W+10]=i.z,E[q+W+11]=V.itemSize===4?i.w:1)}}u={count:d,texture:I,size:new Re(x,M)},n.set(o,u),o.addEventListener("dispose",T)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",r.morphTexture,t);else{let f=0;for(let v=0;v<c.length;v++)f+=c[v];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",u.size)}return{update:a}}function w2(s,e,t,n,i){let a=new WeakMap;function r(c){const h=i.render.frame,d=c.geometry,u=e.get(c,d);if(a.get(u)!==h&&(e.update(u),a.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),a.get(c)!==h&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),a.set(c,h))),c.isSkinnedMesh){const f=c.skeleton;a.get(f)!==h&&(f.update(),a.set(f,h))}return u}function o(){a=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:r,dispose:o}}const M2={[wm]:"LINEAR_TONE_MAPPING",[Mm]:"REINHARD_TONE_MAPPING",[Sm]:"CINEON_TONE_MAPPING",[_m]:"ACES_FILMIC_TONE_MAPPING",[Tm]:"AGX_TONE_MAPPING",[Am]:"NEUTRAL_TONE_MAPPING",[Em]:"CUSTOM_TONE_MAPPING"};function S2(s,e,t,n,i,a){const r=new Tn(e,t,{type:s,depthBuffer:i,stencilBuffer:a,samples:n?4:0,depthTexture:i?new Ks(e,t):void 0}),o=new Tn(e,t,{type:hn,depthBuffer:!1,stencilBuffer:!1}),l=new Dt;l.setAttribute("position",new It([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new It([0,2,0,0,2,0],2));const c=new Gy({uniforms:{tDiffuse:{value:null}},vertexShader:`
5823
5833
  precision highp float;
5824
5834
 
5825
5835
  uniform mat4 modelViewMatrix;
@@ -5865,9 +5875,9 @@ void main() {
5865
5875
  #ifdef SRGB_TRANSFER
5866
5876
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
5867
5877
  #endif
5868
- }`,depthTest:!1,depthWrite:!1}),h=new Ze(l,c),d=new ar(-1,1,1,-1,0,1);let u=null,f=null,g=!1,v,p=null,m=[],S=!1;this.setSize=function(_,x){r.setSize(_,x),o.setSize(_,x);for(let M=0;M<m.length;M++){const E=m[M];E.setSize&&E.setSize(_,x)}},this.setEffects=function(_){m=_,S=m.length>0&&m[0].isRenderPass===!0;const x=r.width,M=r.height;for(let E=0;E<m.length;E++){const I=m[E];I.setSize&&I.setSize(x,M)}},this.begin=function(_,x){if(g||_.toneMapping===_i&&m.length===0)return!1;if(p=x,x!==null){const M=x.width,E=x.height;(r.width!==M||r.height!==E)&&this.setSize(M,E)}return S===!1&&_.setRenderTarget(r),v=_.toneMapping,_.toneMapping=_i,!0},this.hasRenderPass=function(){return S},this.end=function(_,x){_.toneMapping=v,g=!0;let M=r,E=o;for(let I=0;I<m.length;I++){const y=m[I];if(y.enabled!==!1&&(y.render(_,E,M,x),y.needsSwap!==!1)){const T=M;M=E,E=T}}if(u!==_.outputColorSpace||f!==_.toneMapping){u=_.outputColorSpace,f=_.toneMapping,c.defines={},Qe.getTransfer(u)===ot&&(c.defines.SRGB_TRANSFER="");const I=M2[f];I&&(c.defines[I]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=M.texture,_.setRenderTarget(p),_.render(h,d),p=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Qm=new en,xd=new Ks(1,1),eg=new km,tg=new uy,ng=new Vm,vp=[],yp=[],bp=new Float32Array(16),xp=new Float32Array(9),wp=new Float32Array(4);function rr(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let a=vp[i];if(a===void 0&&(a=new Float32Array(i),vp[i]=a),e!==0){n.toArray(a,0);for(let r=1,o=0;r!==e;++r)o+=t,s[r].toArray(a,o)}return a}function Xt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function qt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Jl(s,e){let t=yp[e];t===void 0&&(t=new Int32Array(e),yp[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function _2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function E2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2fv(this.addr,e),qt(t,e)}}function T2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Xt(t,e))return;s.uniform3fv(this.addr,e),qt(t,e)}}function A2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4fv(this.addr,e),qt(t,e)}}function I2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;wp.set(n),s.uniformMatrix2fv(this.addr,!1,wp),qt(t,n)}}function D2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;xp.set(n),s.uniformMatrix3fv(this.addr,!1,xp),qt(t,n)}}function C2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;bp.set(n),s.uniformMatrix4fv(this.addr,!1,bp),qt(t,n)}}function R2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function P2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2iv(this.addr,e),qt(t,e)}}function L2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;s.uniform3iv(this.addr,e),qt(t,e)}}function N2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4iv(this.addr,e),qt(t,e)}}function O2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function k2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2uiv(this.addr,e),qt(t,e)}}function U2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;s.uniform3uiv(this.addr,e),qt(t,e)}}function F2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4uiv(this.addr,e),qt(t,e)}}function B2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let a;this.type===s.SAMPLER_2D_SHADOW?(xd.compareFunction=t.isReversedDepthBuffer()?lu:ou,a=xd):a=Qm,t.setTexture2D(e||a,i)}function z2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||tg,i)}function H2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||ng,i)}function G2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||eg,i)}function V2(s){switch(s){case 5126:return _2;case 35664:return E2;case 35665:return T2;case 35666:return A2;case 35674:return I2;case 35675:return D2;case 35676:return C2;case 5124:case 35670:return R2;case 35667:case 35671:return P2;case 35668:case 35672:return L2;case 35669:case 35673:return N2;case 5125:return O2;case 36294:return k2;case 36295:return U2;case 36296:return F2;case 35678:case 36198:case 36298:case 36306:case 35682:return B2;case 35679:case 36299:case 36307:return z2;case 35680:case 36300:case 36308:case 36293:return H2;case 36289:case 36303:case 36311:case 36292:return G2}}function W2(s,e){s.uniform1fv(this.addr,e)}function X2(s,e){const t=rr(e,this.size,2);s.uniform2fv(this.addr,t)}function q2(s,e){const t=rr(e,this.size,3);s.uniform3fv(this.addr,t)}function Y2(s,e){const t=rr(e,this.size,4);s.uniform4fv(this.addr,t)}function K2(s,e){const t=rr(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function $2(s,e){const t=rr(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Z2(s,e){const t=rr(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function J2(s,e){s.uniform1iv(this.addr,e)}function j2(s,e){s.uniform2iv(this.addr,e)}function Q2(s,e){s.uniform3iv(this.addr,e)}function eM(s,e){s.uniform4iv(this.addr,e)}function tM(s,e){s.uniform1uiv(this.addr,e)}function nM(s,e){s.uniform2uiv(this.addr,e)}function iM(s,e){s.uniform3uiv(this.addr,e)}function sM(s,e){s.uniform4uiv(this.addr,e)}function aM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));let r;this.type===s.SAMPLER_2D_SHADOW?r=xd:r=Qm;for(let o=0;o!==i;++o)t.setTexture2D(e[o]||r,a[o])}function rM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTexture3D(e[r]||tg,a[r])}function oM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTextureCube(e[r]||ng,a[r])}function lM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTexture2DArray(e[r]||eg,a[r])}function cM(s){switch(s){case 5126:return W2;case 35664:return X2;case 35665:return q2;case 35666:return Y2;case 35674:return K2;case 35675:return $2;case 35676:return Z2;case 5124:case 35670:return J2;case 35667:case 35671:return j2;case 35668:case 35672:return Q2;case 35669:case 35673:return eM;case 5125:return tM;case 36294:return nM;case 36295:return iM;case 36296:return sM;case 35678:case 36198:case 36298:case 36306:case 35682:return aM;case 35679:case 36299:case 36307:return rM;case 35680:case 36300:case 36308:case 36293:return oM;case 36289:case 36303:case 36311:case 36292:return lM}}class hM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=V2(t.type)}}class dM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=cM(t.type)}}class uM{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let a=0,r=i.length;a!==r;++a){const o=i[a];o.setValue(e,t[o.id],n)}}}const Wc=/(\w+)(\])?(\[|\.)?/g;function Mp(s,e){s.seq.push(e),s.map[e.id]=e}function fM(s,e,t){const n=s.name,i=n.length;for(Wc.lastIndex=0;;){const a=Wc.exec(n),r=Wc.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&r+2===i){Mp(t,c===void 0?new hM(o,s,e):new dM(o,s,e));break}else{let d=t.map[o];d===void 0&&(d=new uM(o),Mp(t,d)),t=d}}}class gl{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const o=e.getActiveUniform(t,r),l=e.getUniformLocation(t,o.name);fM(o,l,this)}const i=[],a=[];for(const r of this.seq)r.type===e.SAMPLER_2D_SHADOW||r.type===e.SAMPLER_CUBE_SHADOW||r.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(r):a.push(r);i.length>0&&(this.seq=i.concat(a))}setValue(e,t,n,i){const a=this.map[t];a!==void 0&&a.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let a=0,r=t.length;a!==r;++a){const o=t[a],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,a=e.length;i!==a;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function Sp(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const pM=37297;let mM=0;function gM(s,e){const t=s.split(`
5878
+ }`,depthTest:!1,depthWrite:!1}),h=new Ze(l,c),d=new ar(-1,1,1,-1,0,1);let u=null,f=null,g=!1,v,p=null,m=[],S=!1;this.setSize=function(_,x){r.setSize(_,x),o.setSize(_,x);for(let M=0;M<m.length;M++){const E=m[M];E.setSize&&E.setSize(_,x)}},this.setEffects=function(_){m=_,S=m.length>0&&m[0].isRenderPass===!0;const x=r.width,M=r.height;for(let E=0;E<m.length;E++){const I=m[E];I.setSize&&I.setSize(x,M)}},this.begin=function(_,x){if(g||_.toneMapping===_i&&m.length===0)return!1;if(p=x,x!==null){const M=x.width,E=x.height;(r.width!==M||r.height!==E)&&this.setSize(M,E)}return S===!1&&_.setRenderTarget(r),v=_.toneMapping,_.toneMapping=_i,!0},this.hasRenderPass=function(){return S},this.end=function(_,x){_.toneMapping=v,g=!0;let M=r,E=o;for(let I=0;I<m.length;I++){const y=m[I];if(y.enabled!==!1&&(y.render(_,E,M,x),y.needsSwap!==!1)){const T=M;M=E,E=T}}if(u!==_.outputColorSpace||f!==_.toneMapping){u=_.outputColorSpace,f=_.toneMapping,c.defines={},Qe.getTransfer(u)===lt&&(c.defines.SRGB_TRANSFER="");const I=M2[f];I&&(c.defines[I]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=M.texture,_.setRenderTarget(p),_.render(h,d),p=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Qm=new tn,xd=new Ks(1,1),eg=new km,tg=new uy,ng=new Vm,vp=[],yp=[],bp=new Float32Array(16),xp=new Float32Array(9),wp=new Float32Array(4);function rr(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let a=vp[i];if(a===void 0&&(a=new Float32Array(i),vp[i]=a),e!==0){n.toArray(a,0);for(let r=1,o=0;r!==e;++r)o+=t,s[r].toArray(a,o)}return a}function Xt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function qt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Jl(s,e){let t=yp[e];t===void 0&&(t=new Int32Array(e),yp[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function _2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function E2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2fv(this.addr,e),qt(t,e)}}function T2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Xt(t,e))return;s.uniform3fv(this.addr,e),qt(t,e)}}function A2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4fv(this.addr,e),qt(t,e)}}function I2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;wp.set(n),s.uniformMatrix2fv(this.addr,!1,wp),qt(t,n)}}function D2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;xp.set(n),s.uniformMatrix3fv(this.addr,!1,xp),qt(t,n)}}function C2(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Xt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),qt(t,e)}else{if(Xt(t,n))return;bp.set(n),s.uniformMatrix4fv(this.addr,!1,bp),qt(t,n)}}function R2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function P2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2iv(this.addr,e),qt(t,e)}}function L2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;s.uniform3iv(this.addr,e),qt(t,e)}}function N2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4iv(this.addr,e),qt(t,e)}}function O2(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function k2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Xt(t,e))return;s.uniform2uiv(this.addr,e),qt(t,e)}}function U2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Xt(t,e))return;s.uniform3uiv(this.addr,e),qt(t,e)}}function F2(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Xt(t,e))return;s.uniform4uiv(this.addr,e),qt(t,e)}}function B2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let a;this.type===s.SAMPLER_2D_SHADOW?(xd.compareFunction=t.isReversedDepthBuffer()?lu:ou,a=xd):a=Qm,t.setTexture2D(e||a,i)}function z2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||tg,i)}function H2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||ng,i)}function G2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||eg,i)}function V2(s){switch(s){case 5126:return _2;case 35664:return E2;case 35665:return T2;case 35666:return A2;case 35674:return I2;case 35675:return D2;case 35676:return C2;case 5124:case 35670:return R2;case 35667:case 35671:return P2;case 35668:case 35672:return L2;case 35669:case 35673:return N2;case 5125:return O2;case 36294:return k2;case 36295:return U2;case 36296:return F2;case 35678:case 36198:case 36298:case 36306:case 35682:return B2;case 35679:case 36299:case 36307:return z2;case 35680:case 36300:case 36308:case 36293:return H2;case 36289:case 36303:case 36311:case 36292:return G2}}function W2(s,e){s.uniform1fv(this.addr,e)}function X2(s,e){const t=rr(e,this.size,2);s.uniform2fv(this.addr,t)}function q2(s,e){const t=rr(e,this.size,3);s.uniform3fv(this.addr,t)}function Y2(s,e){const t=rr(e,this.size,4);s.uniform4fv(this.addr,t)}function K2(s,e){const t=rr(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function $2(s,e){const t=rr(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Z2(s,e){const t=rr(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function J2(s,e){s.uniform1iv(this.addr,e)}function j2(s,e){s.uniform2iv(this.addr,e)}function Q2(s,e){s.uniform3iv(this.addr,e)}function eM(s,e){s.uniform4iv(this.addr,e)}function tM(s,e){s.uniform1uiv(this.addr,e)}function nM(s,e){s.uniform2uiv(this.addr,e)}function iM(s,e){s.uniform3uiv(this.addr,e)}function sM(s,e){s.uniform4uiv(this.addr,e)}function aM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));let r;this.type===s.SAMPLER_2D_SHADOW?r=xd:r=Qm;for(let o=0;o!==i;++o)t.setTexture2D(e[o]||r,a[o])}function rM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTexture3D(e[r]||tg,a[r])}function oM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTextureCube(e[r]||ng,a[r])}function lM(s,e,t){const n=this.cache,i=e.length,a=Jl(t,i);Xt(n,a)||(s.uniform1iv(this.addr,a),qt(n,a));for(let r=0;r!==i;++r)t.setTexture2DArray(e[r]||eg,a[r])}function cM(s){switch(s){case 5126:return W2;case 35664:return X2;case 35665:return q2;case 35666:return Y2;case 35674:return K2;case 35675:return $2;case 35676:return Z2;case 5124:case 35670:return J2;case 35667:case 35671:return j2;case 35668:case 35672:return Q2;case 35669:case 35673:return eM;case 5125:return tM;case 36294:return nM;case 36295:return iM;case 36296:return sM;case 35678:case 36198:case 36298:case 36306:case 35682:return aM;case 35679:case 36299:case 36307:return rM;case 35680:case 36300:case 36308:case 36293:return oM;case 36289:case 36303:case 36311:case 36292:return lM}}class hM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=V2(t.type)}}class dM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=cM(t.type)}}class uM{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let a=0,r=i.length;a!==r;++a){const o=i[a];o.setValue(e,t[o.id],n)}}}const Wc=/(\w+)(\])?(\[|\.)?/g;function Mp(s,e){s.seq.push(e),s.map[e.id]=e}function fM(s,e,t){const n=s.name,i=n.length;for(Wc.lastIndex=0;;){const a=Wc.exec(n),r=Wc.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&r+2===i){Mp(t,c===void 0?new hM(o,s,e):new dM(o,s,e));break}else{let d=t.map[o];d===void 0&&(d=new uM(o),Mp(t,d)),t=d}}}class gl{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const o=e.getActiveUniform(t,r),l=e.getUniformLocation(t,o.name);fM(o,l,this)}const i=[],a=[];for(const r of this.seq)r.type===e.SAMPLER_2D_SHADOW||r.type===e.SAMPLER_CUBE_SHADOW||r.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(r):a.push(r);i.length>0&&(this.seq=i.concat(a))}setValue(e,t,n,i){const a=this.map[t];a!==void 0&&a.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let a=0,r=t.length;a!==r;++a){const o=t[a],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,a=e.length;i!==a;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function Sp(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const pM=37297;let mM=0;function gM(s,e){const t=s.split(`
5869
5879
  `),n=[],i=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let r=i;r<a;r++){const o=r+1;n.push(`${o===e?">":" "} ${o}: ${t[r]}`)}return n.join(`
5870
- `)}const _p=new Be;function vM(s){Qe._getMatrix(_p,Qe.workingColorSpace,s);const e=`mat3( ${_p.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(s)){case Pl:return[e,"LinearTransferOETF"];case ot:return[e,"sRGBTransferOETF"];default:return Ee("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Ep(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),a=(s.getShaderInfoLog(e)||"").trim();if(n&&a==="")return"";const r=/ERROR: 0:(\d+)/.exec(a);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
5880
+ `)}const _p=new Be;function vM(s){Qe._getMatrix(_p,Qe.workingColorSpace,s);const e=`mat3( ${_p.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(s)){case Pl:return[e,"LinearTransferOETF"];case lt:return[e,"sRGBTransferOETF"];default:return Ee("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Ep(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),a=(s.getShaderInfoLog(e)||"").trim();if(n&&a==="")return"";const r=/ERROR: 0:(\d+)/.exec(a);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
5871
5881
 
5872
5882
  `+a+`
5873
5883
 
@@ -5916,7 +5926,7 @@ Material Type: `+D.type+`
5916
5926
 
5917
5927
  Program Info Log: `+O+`
5918
5928
  `+Q+`
5919
- `+ie)}else O!==""?Ee("WebGLProgram: Program Info Log:",O):(W===""||G==="")&&(te=!1);te&&(D.diagnostics={runnable:Z,programLog:O,vertexShader:{log:W,prefix:p},fragmentShader:{log:G,prefix:m}})}i.deleteShader(M),i.deleteShader(E),y=new gl(i,v),T=_M(i,v)}let y;this.getUniforms=function(){return y===void 0&&I(this),y};let T;this.getAttributes=function(){return T===void 0&&I(this),T};let C=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=i.getProgramParameter(v,pM)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=mM++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=E,this}let zM=0;class HM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new GM(e),t.set(e,n)),n}}class GM{constructor(e){this.id=zM++,this.code=e,this.usedTimes=0}}function VM(s){return s===Ys||s===Al||s===Il}function WM(s,e,t,n,i,a){const r=new du,o=new HM,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer;let u=n.precision;const f={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 g(y){return l.add(y),y===0?"uv":`uv${y}`}function v(y,T,C,D,P,V){const q=D.fog,O=P.geometry,W=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?D.environment:null,G=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,Z=e.get(y.envMap||W,G),te=Z&&Z.mapping===Yl?Z.image.height:null,Q=f[y.type];y.precision!==null&&(u=n.getMaxPrecision(y.precision),u!==y.precision&&Ee("WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));const ie=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,de=ie!==void 0?ie.length:0;let He=0;O.morphAttributes.position!==void 0&&(He=1),O.morphAttributes.normal!==void 0&&(He=2),O.morphAttributes.color!==void 0&&(He=3);let Je,ze,Y,ae;if(Q){const we=mi[Q];Je=we.vertexShader,ze=we.fragmentShader}else{Je=y.vertexShader,ze=y.fragmentShader;const we=o.getVertexShaderStage(y),Pt=o.getFragmentShaderStage(y);o.update(y,we,Pt),Y=we.id,ae=Pt.id}const ne=s.getRenderTarget(),F=s.state.buffers.depth.getReversed(),_e=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Ae=!!y.map,be=!!y.matcap,Ne=!!Z,Oe=!!y.aoMap,ke=!!y.lightMap,st=!!y.bumpMap&&y.wireframe===!1,at=!!y.normalMap,Ct=!!y.displacementMap,Mt=!!y.emissiveMap,Rt=!!y.metalnessMap,Bt=!!y.roughnessMap,N=y.anisotropy>0,wn=y.clearcoat>0,rt=y.dispersion>0,A=y.iridescence>0,b=y.sheen>0,U=y.transmission>0,H=N&&!!y.anisotropyMap,K=wn&&!!y.clearcoatMap,se=wn&&!!y.clearcoatNormalMap,oe=wn&&!!y.clearcoatRoughnessMap,$=A&&!!y.iridescenceMap,j=A&&!!y.iridescenceThicknessMap,le=b&&!!y.sheenColorMap,Ie=b&&!!y.sheenRoughnessMap,ue=!!y.specularMap,ce=!!y.specularColorMap,Le=!!y.specularIntensityMap,Ue=U&&!!y.transmissionMap,Ge=U&&!!y.thicknessMap,L=!!y.gradientMap,re=!!y.alphaMap,J=y.alphaTest>0,he=!!y.alphaHash,ge=!!y.extensions;let ee=_i;y.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=s.toneMapping);const Te={shaderID:Q,shaderType:y.type,shaderName:y.name,vertexShader:Je,fragmentShader:ze,defines:y.defines,customVertexShaderID:Y,customFragmentShaderID:ae,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:_e,instancingColor:_e&&P.instanceColor!==null,instancingMorph:_e&&P.morphTexture!==null,outputColorSpace:ne===null?s.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Ae,matcap:be,envMap:Ne,envMapMode:Ne&&Z.mapping,envMapCubeUVHeight:te,aoMap:Oe,lightMap:ke,bumpMap:st,normalMap:at,displacementMap:Ct,emissiveMap:Mt,normalMapObjectSpace:at&&y.normalMapType===Lv,normalMapTangentSpace:at&&y.normalMapType===Cl,packedNormalMap:at&&y.normalMapType===Cl&&VM(y.normalMap.format),metalnessMap:Rt,roughnessMap:Bt,anisotropy:N,anisotropyMap:H,clearcoat:wn,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:rt,iridescence:A,iridescenceMap:$,iridescenceThicknessMap:j,sheen:b,sheenColorMap:le,sheenRoughnessMap:Ie,specularMap:ue,specularColorMap:ce,specularIntensityMap:Le,transmission:U,transmissionMap:Ue,thicknessMap:Ge,gradientMap:L,opaque:y.transparent===!1&&y.blending===Ua&&y.alphaToCoverage===!1,alphaMap:re,alphaTest:J,alphaHash:he,combine:y.combine,mapUv:Ae&&g(y.map.channel),aoMapUv:Oe&&g(y.aoMap.channel),lightMapUv:ke&&g(y.lightMap.channel),bumpMapUv:st&&g(y.bumpMap.channel),normalMapUv:at&&g(y.normalMap.channel),displacementMapUv:Ct&&g(y.displacementMap.channel),emissiveMapUv:Mt&&g(y.emissiveMap.channel),metalnessMapUv:Rt&&g(y.metalnessMap.channel),roughnessMapUv:Bt&&g(y.roughnessMap.channel),anisotropyMapUv:H&&g(y.anisotropyMap.channel),clearcoatMapUv:K&&g(y.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(y.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(y.iridescenceMap.channel),iridescenceThicknessMapUv:j&&g(y.iridescenceThicknessMap.channel),sheenColorMapUv:le&&g(y.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&g(y.sheenRoughnessMap.channel),specularMapUv:ue&&g(y.specularMap.channel),specularColorMapUv:ce&&g(y.specularColorMap.channel),specularIntensityMapUv:Le&&g(y.specularIntensityMap.channel),transmissionMapUv:Ue&&g(y.transmissionMap.channel),thicknessMapUv:Ge&&g(y.thicknessMap.channel),alphaMapUv:re&&g(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(at||N),vertexNormals:!!O.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!O.attributes.uv&&(Ae||re),fog:!!q,useFog:y.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||O.attributes.normal===void 0&&at===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:F,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:He,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:V.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:s.shadowMap.enabled&&C.length>0,shadowMapType:s.shadowMap.type,toneMapping:ee,decodeVideoTexture:Ae&&y.map.isVideoTexture===!0&&Qe.getTransfer(y.map.colorSpace)===ot,decodeVideoTextureEmissive:Mt&&y.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(y.emissiveMap.colorSpace)===ot,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Zn,flipSided:y.side===Vt,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ge&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&y.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function p(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const C in y.defines)T.push(C),T.push(y.defines[C]);return y.isRawShaderMaterial===!1&&(m(T,y),S(T,y),T.push(s.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function m(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function S(y,T){r.disableAll(),T.instancing&&r.enable(0),T.instancingColor&&r.enable(1),T.instancingMorph&&r.enable(2),T.matcap&&r.enable(3),T.envMap&&r.enable(4),T.normalMapObjectSpace&&r.enable(5),T.normalMapTangentSpace&&r.enable(6),T.clearcoat&&r.enable(7),T.iridescence&&r.enable(8),T.alphaTest&&r.enable(9),T.vertexColors&&r.enable(10),T.vertexAlphas&&r.enable(11),T.vertexUv1s&&r.enable(12),T.vertexUv2s&&r.enable(13),T.vertexUv3s&&r.enable(14),T.vertexTangents&&r.enable(15),T.anisotropy&&r.enable(16),T.alphaHash&&r.enable(17),T.batching&&r.enable(18),T.dispersion&&r.enable(19),T.batchingColor&&r.enable(20),T.gradientMap&&r.enable(21),T.packedNormalMap&&r.enable(22),T.vertexNormals&&r.enable(23),y.push(r.mask),r.disableAll(),T.fog&&r.enable(0),T.useFog&&r.enable(1),T.flatShading&&r.enable(2),T.logarithmicDepthBuffer&&r.enable(3),T.reversedDepthBuffer&&r.enable(4),T.skinning&&r.enable(5),T.morphTargets&&r.enable(6),T.morphNormals&&r.enable(7),T.morphColors&&r.enable(8),T.premultipliedAlpha&&r.enable(9),T.shadowMapEnabled&&r.enable(10),T.doubleSided&&r.enable(11),T.flipSided&&r.enable(12),T.useDepthPacking&&r.enable(13),T.dithering&&r.enable(14),T.transmission&&r.enable(15),T.sheen&&r.enable(16),T.opaque&&r.enable(17),T.pointsUvs&&r.enable(18),T.decodeVideoTexture&&r.enable(19),T.decodeVideoTextureEmissive&&r.enable(20),T.alphaToCoverage&&r.enable(21),T.numLightProbeGrids>0&&r.enable(22),T.hasPositionAttribute&&r.enable(23),y.push(r.mask)}function _(y){const T=f[y.type];let C;if(T){const D=mi[T];C=By.clone(D.uniforms)}else C=y.uniforms;return C}function x(y,T){let C=h.get(T);return C!==void 0?++C.usedTimes:(C=new BM(s,T,y,i),c.push(C),h.set(T,C)),C}function M(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),h.delete(y.cacheKey),y.destroy()}}function E(y){o.remove(y)}function I(){o.dispose()}return{getParameters:v,getProgramCacheKey:p,getUniforms:_,acquireProgram:x,releaseProgram:M,releaseShaderCache:E,programs:c,dispose:I}}function XM(){let s=new WeakMap;function e(r){return s.has(r)}function t(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}function n(r){s.delete(r)}function i(r,o,l){s.get(r)[o]=l}function a(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:a}}function qM(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Cp(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Rp(){const s=[];let e=0;const t=[],n=[],i=[];function a(){e=0,t.length=0,n.length=0,i.length=0}function r(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,g,v,p,m){let S=s[e];return S===void 0?(S={id:u.id,object:u,geometry:f,material:g,materialVariant:r(u),groupOrder:v,renderOrder:u.renderOrder,z:p,group:m},s[e]=S):(S.id=u.id,S.object=u,S.geometry=f,S.material=g,S.materialVariant=r(u),S.groupOrder=v,S.renderOrder=u.renderOrder,S.z=p,S.group=m),e++,S}function l(u,f,g,v,p,m){const S=o(u,f,g,v,p,m);g.transmission>0?n.push(S):g.transparent===!0?i.push(S):t.push(S)}function c(u,f,g,v,p,m){const S=o(u,f,g,v,p,m);g.transmission>0?n.unshift(S):g.transparent===!0?i.unshift(S):t.unshift(S)}function h(u,f,g){t.length>1&&t.sort(u||qM),n.length>1&&n.sort(f||Cp),i.length>1&&i.sort(f||Cp),g&&(t.reverse(),n.reverse(),i.reverse())}function d(){for(let u=e,f=s.length;u<f;u++){const g=s[u];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:i,init:a,push:l,unshift:c,finish:d,sort:h}}function YM(){let s=new WeakMap;function e(n,i){const a=s.get(n);let r;return a===void 0?(r=new Rp,s.set(n,[r])):i>=a.length?(r=new Rp,a.push(r)):r=a[i],r}function t(){s=new WeakMap}return{get:e,dispose:t}}function KM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new ve};break;case"SpotLight":t={position:new R,direction:new R,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new R,halfWidth:new R,halfHeight:new R};break}return s[e.id]=t,t}}}function $M(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let ZM=0;function JM(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function jM(s){const e=new KM,t=$M(),n={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++)n.probe.push(new R);const i=new R,a=new qe,r=new qe;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let f=0,g=0,v=0,p=0,m=0,S=0,_=0,x=0,M=0,E=0,I=0;c.sort(JM);for(let T=0,C=c.length;T<C;T++){const D=c[T],P=D.color,V=D.intensity,q=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Ys?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=P.r*V,d+=P.g*V,u+=P.b*V;else if(D.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(D.sh.coefficients[W],V);I++}else if(D.isDirectionalLight){const W=e.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[f]=Z,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=W,f++}else if(D.isSpotLight){const W=e.get(D);W.position.setFromMatrixPosition(D.matrixWorld),W.color.copy(P).multiplyScalar(V),W.distance=q,W.coneCos=Math.cos(D.angle),W.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),W.decay=D.decay,n.spot[v]=W;const G=D.shadow;if(D.map&&(n.spotLightMap[M]=D.map,M++,G.updateMatrices(D),D.castShadow&&E++),n.spotLightMatrix[v]=G.matrix,D.castShadow){const Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[v]=Z,n.spotShadowMap[v]=O,x++}v++}else if(D.isRectAreaLight){const W=e.get(D);W.color.copy(P).multiplyScalar(V),W.halfWidth.set(D.width*.5,0,0),W.halfHeight.set(0,D.height*.5,0),n.rectArea[p]=W,p++}else if(D.isPointLight){const W=e.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),W.distance=D.distance,W.decay=D.decay,D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=D.shadow.matrix,_++}n.point[g]=W,g++}else if(D.isHemisphereLight){const W=e.get(D);W.skyColor.copy(D.color).multiplyScalar(V),W.groundColor.copy(D.groundColor).multiplyScalar(V),n.hemi[m]=W,m++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;const y=n.hash;(y.directionalLength!==f||y.pointLength!==g||y.spotLength!==v||y.rectAreaLength!==p||y.hemiLength!==m||y.numDirectionalShadows!==S||y.numPointShadows!==_||y.numSpotShadows!==x||y.numSpotMaps!==M||y.numLightProbes!==I)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=_,n.pointShadowMap.length=_,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=_,n.spotLightMatrix.length=x+M-E,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=I,y.directionalLength=f,y.pointLength=g,y.spotLength=v,y.rectAreaLength=p,y.hemiLength=m,y.numDirectionalShadows=S,y.numPointShadows=_,y.numSpotShadows=x,y.numSpotMaps=M,y.numLightProbes=I,n.version=ZM++)}function l(c,h){let d=0,u=0,f=0,g=0,v=0;const p=h.matrixWorldInverse;for(let m=0,S=c.length;m<S;m++){const _=c[m];if(_.isDirectionalLight){const x=n.directional[d];x.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),d++}else if(_.isSpotLight){const x=n.spot[f];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),x.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),f++}else if(_.isRectAreaLight){const x=n.rectArea[g];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),r.identity(),a.copy(_.matrixWorld),a.premultiply(p),r.extractRotation(a),x.halfWidth.set(_.width*.5,0,0),x.halfHeight.set(0,_.height*.5,0),x.halfWidth.applyMatrix4(r),x.halfHeight.applyMatrix4(r),g++}else if(_.isPointLight){const x=n.point[u];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),u++}else if(_.isHemisphereLight){const x=n.hemi[v];x.direction.setFromMatrixPosition(_.matrixWorld),x.direction.transformDirection(p),v++}}}return{setup:o,setupView:l,state:n}}function Pp(s){const e=new jM(s),t=[],n=[],i=[];function a(u){d.camera=u,t.length=0,n.length=0,i.length=0}function r(u){t.push(u)}function o(u){n.push(u)}function l(u){i.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:d,setupLights:c,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:l}}function QM(s){let e=new WeakMap;function t(i,a=0){const r=e.get(i);let o;return r===void 0?(o=new Pp(s),e.set(i,[o])):a>=r.length?(o=new Pp(s),r.push(o)):o=r[a],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const eS=`void main() {
5929
+ `+ie)}else O!==""?Ee("WebGLProgram: Program Info Log:",O):(W===""||G==="")&&(te=!1);te&&(D.diagnostics={runnable:Z,programLog:O,vertexShader:{log:W,prefix:p},fragmentShader:{log:G,prefix:m}})}i.deleteShader(M),i.deleteShader(E),y=new gl(i,v),T=_M(i,v)}let y;this.getUniforms=function(){return y===void 0&&I(this),y};let T;this.getAttributes=function(){return T===void 0&&I(this),T};let C=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=i.getProgramParameter(v,pM)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=mM++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=E,this}let zM=0;class HM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new GM(e),t.set(e,n)),n}}class GM{constructor(e){this.id=zM++,this.code=e,this.usedTimes=0}}function VM(s){return s===Ys||s===Al||s===Il}function WM(s,e,t,n,i,a){const r=new du,o=new HM,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer;let u=n.precision;const f={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 g(y){return l.add(y),y===0?"uv":`uv${y}`}function v(y,T,C,D,P,V){const q=D.fog,O=P.geometry,W=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?D.environment:null,G=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,Z=e.get(y.envMap||W,G),te=Z&&Z.mapping===Yl?Z.image.height:null,Q=f[y.type];y.precision!==null&&(u=n.getMaxPrecision(y.precision),u!==y.precision&&Ee("WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));const ie=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,de=ie!==void 0?ie.length:0;let He=0;O.morphAttributes.position!==void 0&&(He=1),O.morphAttributes.normal!==void 0&&(He=2),O.morphAttributes.color!==void 0&&(He=3);let Je,ze,Y,ae;if(Q){const we=gi[Q];Je=we.vertexShader,ze=we.fragmentShader}else{Je=y.vertexShader,ze=y.fragmentShader;const we=o.getVertexShaderStage(y),Pt=o.getFragmentShaderStage(y);o.update(y,we,Pt),Y=we.id,ae=Pt.id}const ne=s.getRenderTarget(),F=s.state.buffers.depth.getReversed(),_e=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Ae=!!y.map,be=!!y.matcap,Ne=!!Z,Oe=!!y.aoMap,ke=!!y.lightMap,at=!!y.bumpMap&&y.wireframe===!1,rt=!!y.normalMap,Ct=!!y.displacementMap,wt=!!y.emissiveMap,Rt=!!y.metalnessMap,Bt=!!y.roughnessMap,N=y.anisotropy>0,wn=y.clearcoat>0,ot=y.dispersion>0,A=y.iridescence>0,b=y.sheen>0,U=y.transmission>0,H=N&&!!y.anisotropyMap,K=wn&&!!y.clearcoatMap,se=wn&&!!y.clearcoatNormalMap,oe=wn&&!!y.clearcoatRoughnessMap,$=A&&!!y.iridescenceMap,j=A&&!!y.iridescenceThicknessMap,le=b&&!!y.sheenColorMap,Ie=b&&!!y.sheenRoughnessMap,ue=!!y.specularMap,ce=!!y.specularColorMap,Le=!!y.specularIntensityMap,Ue=U&&!!y.transmissionMap,Ge=U&&!!y.thicknessMap,L=!!y.gradientMap,re=!!y.alphaMap,J=y.alphaTest>0,he=!!y.alphaHash,ge=!!y.extensions;let ee=_i;y.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=s.toneMapping);const Te={shaderID:Q,shaderType:y.type,shaderName:y.name,vertexShader:Je,fragmentShader:ze,defines:y.defines,customVertexShaderID:Y,customFragmentShaderID:ae,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:_e,instancingColor:_e&&P.instanceColor!==null,instancingMorph:_e&&P.morphTexture!==null,outputColorSpace:ne===null?s.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Ae,matcap:be,envMap:Ne,envMapMode:Ne&&Z.mapping,envMapCubeUVHeight:te,aoMap:Oe,lightMap:ke,bumpMap:at,normalMap:rt,displacementMap:Ct,emissiveMap:wt,normalMapObjectSpace:rt&&y.normalMapType===Lv,normalMapTangentSpace:rt&&y.normalMapType===Cl,packedNormalMap:rt&&y.normalMapType===Cl&&VM(y.normalMap.format),metalnessMap:Rt,roughnessMap:Bt,anisotropy:N,anisotropyMap:H,clearcoat:wn,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:ot,iridescence:A,iridescenceMap:$,iridescenceThicknessMap:j,sheen:b,sheenColorMap:le,sheenRoughnessMap:Ie,specularMap:ue,specularColorMap:ce,specularIntensityMap:Le,transmission:U,transmissionMap:Ue,thicknessMap:Ge,gradientMap:L,opaque:y.transparent===!1&&y.blending===Ua&&y.alphaToCoverage===!1,alphaMap:re,alphaTest:J,alphaHash:he,combine:y.combine,mapUv:Ae&&g(y.map.channel),aoMapUv:Oe&&g(y.aoMap.channel),lightMapUv:ke&&g(y.lightMap.channel),bumpMapUv:at&&g(y.bumpMap.channel),normalMapUv:rt&&g(y.normalMap.channel),displacementMapUv:Ct&&g(y.displacementMap.channel),emissiveMapUv:wt&&g(y.emissiveMap.channel),metalnessMapUv:Rt&&g(y.metalnessMap.channel),roughnessMapUv:Bt&&g(y.roughnessMap.channel),anisotropyMapUv:H&&g(y.anisotropyMap.channel),clearcoatMapUv:K&&g(y.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(y.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(y.iridescenceMap.channel),iridescenceThicknessMapUv:j&&g(y.iridescenceThicknessMap.channel),sheenColorMapUv:le&&g(y.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&g(y.sheenRoughnessMap.channel),specularMapUv:ue&&g(y.specularMap.channel),specularColorMapUv:ce&&g(y.specularColorMap.channel),specularIntensityMapUv:Le&&g(y.specularIntensityMap.channel),transmissionMapUv:Ue&&g(y.transmissionMap.channel),thicknessMapUv:Ge&&g(y.thicknessMap.channel),alphaMapUv:re&&g(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(rt||N),vertexNormals:!!O.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!O.attributes.uv&&(Ae||re),fog:!!q,useFog:y.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||O.attributes.normal===void 0&&rt===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:F,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:He,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:V.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:s.shadowMap.enabled&&C.length>0,shadowMapType:s.shadowMap.type,toneMapping:ee,decodeVideoTexture:Ae&&y.map.isVideoTexture===!0&&Qe.getTransfer(y.map.colorSpace)===lt,decodeVideoTextureEmissive:wt&&y.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(y.emissiveMap.colorSpace)===lt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Zn,flipSided:y.side===Vt,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ge&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&y.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function p(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const C in y.defines)T.push(C),T.push(y.defines[C]);return y.isRawShaderMaterial===!1&&(m(T,y),S(T,y),T.push(s.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function m(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function S(y,T){r.disableAll(),T.instancing&&r.enable(0),T.instancingColor&&r.enable(1),T.instancingMorph&&r.enable(2),T.matcap&&r.enable(3),T.envMap&&r.enable(4),T.normalMapObjectSpace&&r.enable(5),T.normalMapTangentSpace&&r.enable(6),T.clearcoat&&r.enable(7),T.iridescence&&r.enable(8),T.alphaTest&&r.enable(9),T.vertexColors&&r.enable(10),T.vertexAlphas&&r.enable(11),T.vertexUv1s&&r.enable(12),T.vertexUv2s&&r.enable(13),T.vertexUv3s&&r.enable(14),T.vertexTangents&&r.enable(15),T.anisotropy&&r.enable(16),T.alphaHash&&r.enable(17),T.batching&&r.enable(18),T.dispersion&&r.enable(19),T.batchingColor&&r.enable(20),T.gradientMap&&r.enable(21),T.packedNormalMap&&r.enable(22),T.vertexNormals&&r.enable(23),y.push(r.mask),r.disableAll(),T.fog&&r.enable(0),T.useFog&&r.enable(1),T.flatShading&&r.enable(2),T.logarithmicDepthBuffer&&r.enable(3),T.reversedDepthBuffer&&r.enable(4),T.skinning&&r.enable(5),T.morphTargets&&r.enable(6),T.morphNormals&&r.enable(7),T.morphColors&&r.enable(8),T.premultipliedAlpha&&r.enable(9),T.shadowMapEnabled&&r.enable(10),T.doubleSided&&r.enable(11),T.flipSided&&r.enable(12),T.useDepthPacking&&r.enable(13),T.dithering&&r.enable(14),T.transmission&&r.enable(15),T.sheen&&r.enable(16),T.opaque&&r.enable(17),T.pointsUvs&&r.enable(18),T.decodeVideoTexture&&r.enable(19),T.decodeVideoTextureEmissive&&r.enable(20),T.alphaToCoverage&&r.enable(21),T.numLightProbeGrids>0&&r.enable(22),T.hasPositionAttribute&&r.enable(23),y.push(r.mask)}function _(y){const T=f[y.type];let C;if(T){const D=gi[T];C=By.clone(D.uniforms)}else C=y.uniforms;return C}function x(y,T){let C=h.get(T);return C!==void 0?++C.usedTimes:(C=new BM(s,T,y,i),c.push(C),h.set(T,C)),C}function M(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),h.delete(y.cacheKey),y.destroy()}}function E(y){o.remove(y)}function I(){o.dispose()}return{getParameters:v,getProgramCacheKey:p,getUniforms:_,acquireProgram:x,releaseProgram:M,releaseShaderCache:E,programs:c,dispose:I}}function XM(){let s=new WeakMap;function e(r){return s.has(r)}function t(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}function n(r){s.delete(r)}function i(r,o,l){s.get(r)[o]=l}function a(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:a}}function qM(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Cp(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Rp(){const s=[];let e=0;const t=[],n=[],i=[];function a(){e=0,t.length=0,n.length=0,i.length=0}function r(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,g,v,p,m){let S=s[e];return S===void 0?(S={id:u.id,object:u,geometry:f,material:g,materialVariant:r(u),groupOrder:v,renderOrder:u.renderOrder,z:p,group:m},s[e]=S):(S.id=u.id,S.object=u,S.geometry=f,S.material=g,S.materialVariant=r(u),S.groupOrder=v,S.renderOrder=u.renderOrder,S.z=p,S.group=m),e++,S}function l(u,f,g,v,p,m){const S=o(u,f,g,v,p,m);g.transmission>0?n.push(S):g.transparent===!0?i.push(S):t.push(S)}function c(u,f,g,v,p,m){const S=o(u,f,g,v,p,m);g.transmission>0?n.unshift(S):g.transparent===!0?i.unshift(S):t.unshift(S)}function h(u,f,g){t.length>1&&t.sort(u||qM),n.length>1&&n.sort(f||Cp),i.length>1&&i.sort(f||Cp),g&&(t.reverse(),n.reverse(),i.reverse())}function d(){for(let u=e,f=s.length;u<f;u++){const g=s[u];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:i,init:a,push:l,unshift:c,finish:d,sort:h}}function YM(){let s=new WeakMap;function e(n,i){const a=s.get(n);let r;return a===void 0?(r=new Rp,s.set(n,[r])):i>=a.length?(r=new Rp,a.push(r)):r=a[i],r}function t(){s=new WeakMap}return{get:e,dispose:t}}function KM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new ve};break;case"SpotLight":t={position:new R,direction:new R,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new R,halfWidth:new R,halfHeight:new R};break}return s[e.id]=t,t}}}function $M(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let ZM=0;function JM(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function jM(s){const e=new KM,t=$M(),n={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++)n.probe.push(new R);const i=new R,a=new qe,r=new qe;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let f=0,g=0,v=0,p=0,m=0,S=0,_=0,x=0,M=0,E=0,I=0;c.sort(JM);for(let T=0,C=c.length;T<C;T++){const D=c[T],P=D.color,V=D.intensity,q=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Ys?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=P.r*V,d+=P.g*V,u+=P.b*V;else if(D.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(D.sh.coefficients[W],V);I++}else if(D.isDirectionalLight){const W=e.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[f]=Z,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=W,f++}else if(D.isSpotLight){const W=e.get(D);W.position.setFromMatrixPosition(D.matrixWorld),W.color.copy(P).multiplyScalar(V),W.distance=q,W.coneCos=Math.cos(D.angle),W.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),W.decay=D.decay,n.spot[v]=W;const G=D.shadow;if(D.map&&(n.spotLightMap[M]=D.map,M++,G.updateMatrices(D),D.castShadow&&E++),n.spotLightMatrix[v]=G.matrix,D.castShadow){const Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[v]=Z,n.spotShadowMap[v]=O,x++}v++}else if(D.isRectAreaLight){const W=e.get(D);W.color.copy(P).multiplyScalar(V),W.halfWidth.set(D.width*.5,0,0),W.halfHeight.set(0,D.height*.5,0),n.rectArea[p]=W,p++}else if(D.isPointLight){const W=e.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),W.distance=D.distance,W.decay=D.decay,D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=D.shadow.matrix,_++}n.point[g]=W,g++}else if(D.isHemisphereLight){const W=e.get(D);W.skyColor.copy(D.color).multiplyScalar(V),W.groundColor.copy(D.groundColor).multiplyScalar(V),n.hemi[m]=W,m++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;const y=n.hash;(y.directionalLength!==f||y.pointLength!==g||y.spotLength!==v||y.rectAreaLength!==p||y.hemiLength!==m||y.numDirectionalShadows!==S||y.numPointShadows!==_||y.numSpotShadows!==x||y.numSpotMaps!==M||y.numLightProbes!==I)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=_,n.pointShadowMap.length=_,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=_,n.spotLightMatrix.length=x+M-E,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=I,y.directionalLength=f,y.pointLength=g,y.spotLength=v,y.rectAreaLength=p,y.hemiLength=m,y.numDirectionalShadows=S,y.numPointShadows=_,y.numSpotShadows=x,y.numSpotMaps=M,y.numLightProbes=I,n.version=ZM++)}function l(c,h){let d=0,u=0,f=0,g=0,v=0;const p=h.matrixWorldInverse;for(let m=0,S=c.length;m<S;m++){const _=c[m];if(_.isDirectionalLight){const x=n.directional[d];x.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),d++}else if(_.isSpotLight){const x=n.spot[f];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),x.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),f++}else if(_.isRectAreaLight){const x=n.rectArea[g];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),r.identity(),a.copy(_.matrixWorld),a.premultiply(p),r.extractRotation(a),x.halfWidth.set(_.width*.5,0,0),x.halfHeight.set(0,_.height*.5,0),x.halfWidth.applyMatrix4(r),x.halfHeight.applyMatrix4(r),g++}else if(_.isPointLight){const x=n.point[u];x.position.setFromMatrixPosition(_.matrixWorld),x.position.applyMatrix4(p),u++}else if(_.isHemisphereLight){const x=n.hemi[v];x.direction.setFromMatrixPosition(_.matrixWorld),x.direction.transformDirection(p),v++}}}return{setup:o,setupView:l,state:n}}function Pp(s){const e=new jM(s),t=[],n=[],i=[];function a(u){d.camera=u,t.length=0,n.length=0,i.length=0}function r(u){t.push(u)}function o(u){n.push(u)}function l(u){i.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:d,setupLights:c,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:l}}function QM(s){let e=new WeakMap;function t(i,a=0){const r=e.get(i);let o;return r===void 0?(o=new Pp(s),e.set(i,[o])):a>=r.length?(o=new Pp(s),r.push(o)):o=r[a],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const eS=`void main() {
5920
5930
  gl_Position = vec4( position, 1.0 );
5921
5931
  }`,tS=`uniform sampler2D shadow_pass;
5922
5932
  uniform vec2 resolution;
@@ -5943,7 +5953,7 @@ void main() {
5943
5953
  squared_mean = squared_mean / samples;
5944
5954
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
5945
5955
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
5946
- }`,nS=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],iS=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Lp=new qe,br=new R,Xc=new R;function sS(s,e,t){let n=new pu;const i=new Re,a=new Re,r=new pt,o=new Wy,l=new Xy,c={},h=t.maxTextureSize,d={[vs]:Vt,[Vt]:vs,[Zn]:Zn},u=new Nt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:eS,fragmentShader:tS}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const g=new Dt;g.setAttribute("position",new vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ze(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Pr;let m=this.type;this.render=function(E,I,y){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;this.type===lv&&(Ee("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Pr);const T=s.getRenderTarget(),C=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Si),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const V=m!==this.type;V&&I.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(O=>O.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,O=E.length;q<O;q++){const W=E[q],G=W.shadow;if(G===void 0){Ee("WebGLShadowMap:",W,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();i.multiply(Z),a.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(a.x=Math.floor(h/Z.x),i.x=a.x*Z.x,G.mapSize.x=a.x),i.y>h&&(a.y=Math.floor(h/Z.y),i.y=a.y*Z.y,G.mapSize.y=a.y));const te=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=te,G.map===null||V===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Tr){if(W.isPointLight){Ee("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new En(i.x,i.y,{format:Ys,type:cn,minFilter:At,magFilter:At,generateMipmaps:!1}),G.map.texture.name=W.name+".shadowMap",G.map.depthTexture=new Ks(i.x,i.y,Vn),G.map.depthTexture.name=W.name+".shadowMapDepth",G.map.depthTexture.format=Wi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wt,G.map.depthTexture.magFilter=Wt}else W.isPointLight?(G.map=new jm(i.x),G.map.depthTexture=new Uy(i.x,ni)):(G.map=new En(i.x,i.y),G.map.depthTexture=new Ks(i.x,i.y,ni)),G.map.depthTexture.name=W.name+".shadowMap",G.map.depthTexture.format=Wi,this.type===Pr?(G.map.depthTexture.compareFunction=te?lu:ou,G.map.depthTexture.minFilter=At,G.map.depthTexture.magFilter=At):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wt,G.map.depthTexture.magFilter=Wt);G.camera.updateProjectionMatrix()}const Q=G.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<Q;ie++){if(G.map.isWebGLCubeRenderTarget)s.setRenderTarget(G.map,ie),s.clear();else{ie===0&&(s.setRenderTarget(G.map),s.clear());const de=G.getViewport(ie);r.set(a.x*de.x,a.y*de.y,a.x*de.z,a.y*de.w),P.viewport(r)}if(W.isPointLight){const de=G.camera,He=G.matrix,Je=W.distance||de.far;Je!==de.far&&(de.far=Je,de.updateProjectionMatrix()),br.setFromMatrixPosition(W.matrixWorld),de.position.copy(br),Xc.copy(de.position),Xc.add(nS[ie]),de.up.copy(iS[ie]),de.lookAt(Xc),de.updateMatrixWorld(),He.makeTranslation(-br.x,-br.y,-br.z),Lp.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),G._frustum.setFromProjectionMatrix(Lp,de.coordinateSystem,de.reversedDepth)}else G.updateMatrices(W);n=G.getFrustum(),x(I,y,G.camera,W,this.type)}G.isPointLightShadow!==!0&&this.type===Tr&&S(G,y),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,s.setRenderTarget(T,C,D)};function S(E,I){const y=e.update(v);u.defines.VSM_SAMPLES!==E.blurSamples&&(u.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new En(i.x,i.y,{format:Ys,type:cn})),u.uniforms.shadow_pass.value=E.map.depthTexture,u.uniforms.resolution.value=E.mapSize,u.uniforms.radius.value=E.radius,s.setRenderTarget(E.mapPass),s.clear(),s.renderBufferDirect(I,null,y,u,v,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,s.setRenderTarget(E.map),s.clear(),s.renderBufferDirect(I,null,y,f,v,null)}function _(E,I,y,T){let C=null;const D=y.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)C=D;else if(C=y.isPointLight===!0?l:o,s.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){const P=C.uuid,V=I.uuid;let q=c[P];q===void 0&&(q={},c[P]=q);let O=q[V];O===void 0&&(O=C.clone(),q[V]=O,I.addEventListener("dispose",M)),C=O}if(C.visible=I.visible,C.wireframe=I.wireframe,T===Tr?C.side=I.shadowSide!==null?I.shadowSide:I.side:C.side=I.shadowSide!==null?I.shadowSide:d[I.side],C.alphaMap=I.alphaMap,C.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,C.map=I.map,C.clipShadows=I.clipShadows,C.clippingPlanes=I.clippingPlanes,C.clipIntersection=I.clipIntersection,C.displacementMap=I.displacementMap,C.displacementScale=I.displacementScale,C.displacementBias=I.displacementBias,C.wireframeLinewidth=I.wireframeLinewidth,C.linewidth=I.linewidth,y.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const P=s.properties.get(C);P.light=y}return C}function x(E,I,y,T,C){if(E.visible===!1)return;if(E.layers.test(I.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&C===Tr)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,E.matrixWorld);const V=e.update(E),q=E.material;if(Array.isArray(q)){const O=V.groups;for(let W=0,G=O.length;W<G;W++){const Z=O[W],te=q[Z.materialIndex];if(te&&te.visible){const Q=_(E,te,T,C);E.onBeforeShadow(s,E,I,y,V,Q,Z),s.renderBufferDirect(y,null,V,Q,E,Z),E.onAfterShadow(s,E,I,y,V,Q,Z)}}}else if(q.visible){const O=_(E,q,T,C);E.onBeforeShadow(s,E,I,y,V,O,null),s.renderBufferDirect(y,null,V,O,E,null),E.onAfterShadow(s,E,I,y,V,O,null)}}const P=E.children;for(let V=0,q=P.length;V<q;V++)x(P[V],I,y,T,C)}function M(E){E.target.removeEventListener("dispose",M);for(const y in c){const T=c[y],C=E.target.uuid;C in T&&(T[C].dispose(),delete T[C])}}}function aS(s,e){function t(){let L=!1;const re=new pt;let J=null;const he=new pt(0,0,0,0);return{setMask:function(ge){J!==ge&&!L&&(s.colorMask(ge,ge,ge,ge),J=ge)},setLocked:function(ge){L=ge},setClear:function(ge,ee,Te,we,Pt){Pt===!0&&(ge*=we,ee*=we,Te*=we),re.set(ge,ee,Te,we),he.equals(re)===!1&&(s.clearColor(ge,ee,Te,we),he.copy(re))},reset:function(){L=!1,J=null,he.set(-1,0,0,0)}}}function n(){let L=!1,re=!1,J=null,he=null,ge=null;return{setReversed:function(ee){if(re!==ee){const Te=e.get("EXT_clip_control");ee?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),re=ee;const we=ge;ge=null,this.setClear(we)}},getReversed:function(){return re},setTest:function(ee){ee?ne(s.DEPTH_TEST):F(s.DEPTH_TEST)},setMask:function(ee){J!==ee&&!L&&(s.depthMask(ee),J=ee)},setFunc:function(ee){if(re&&(ee=Wv[ee]),he!==ee){switch(ee){case Ph:s.depthFunc(s.NEVER);break;case Lh:s.depthFunc(s.ALWAYS);break;case Nh:s.depthFunc(s.LESS);break;case Za:s.depthFunc(s.LEQUAL);break;case Oh:s.depthFunc(s.EQUAL);break;case kh:s.depthFunc(s.GEQUAL);break;case Uh:s.depthFunc(s.GREATER);break;case Fh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}he=ee}},setLocked:function(ee){L=ee},setClear:function(ee){ge!==ee&&(ge=ee,re&&(ee=1-ee),s.clearDepth(ee))},reset:function(){L=!1,J=null,he=null,ge=null,re=!1}}}function i(){let L=!1,re=null,J=null,he=null,ge=null,ee=null,Te=null,we=null,Pt=null;return{setTest:function(yt){L||(yt?ne(s.STENCIL_TEST):F(s.STENCIL_TEST))},setMask:function(yt){re!==yt&&!L&&(s.stencilMask(yt),re=yt)},setFunc:function(yt,si,ai){(J!==yt||he!==si||ge!==ai)&&(s.stencilFunc(yt,si,ai),J=yt,he=si,ge=ai)},setOp:function(yt,si,ai){(ee!==yt||Te!==si||we!==ai)&&(s.stencilOp(yt,si,ai),ee=yt,Te=si,we=ai)},setLocked:function(yt){L=yt},setClear:function(yt){Pt!==yt&&(s.clearStencil(yt),Pt=yt)},reset:function(){L=!1,re=null,J=null,he=null,ge=null,ee=null,Te=null,we=null,Pt=null}}}const a=new t,r=new n,o=new i,l=new WeakMap,c=new WeakMap;let h={},d={},u={},f=new WeakMap,g=[],v=null,p=!1,m=null,S=null,_=null,x=null,M=null,E=null,I=null,y=new ve(0,0,0),T=0,C=!1,D=null,P=null,V=null,q=null,O=null;const W=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,Z=0;const te=s.getParameter(s.VERSION);te.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(te)[1]),G=Z>=1):te.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),G=Z>=2);let Q=null,ie={};const de=s.getParameter(s.SCISSOR_BOX),He=s.getParameter(s.VIEWPORT),Je=new pt().fromArray(de),ze=new pt().fromArray(He);function Y(L,re,J,he){const ge=new Uint8Array(4),ee=s.createTexture();s.bindTexture(L,ee),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<J;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(re,0,s.RGBA,1,1,he,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(re+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return ee}const ae={};ae[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),ae[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ae[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),a.setClear(0,0,0,1),r.setClear(1),o.setClear(0),ne(s.DEPTH_TEST),r.setFunc(Za),st(!1),at(ff),ne(s.CULL_FACE),Oe(Si);function ne(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function F(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function _e(L,re){return u[L]!==re?(s.bindFramebuffer(L,re),u[L]=re,L===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=re),L===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=re),!0):!1}function Pe(L,re){let J=g,he=!1;if(L){J=f.get(re),J===void 0&&(J=[],f.set(re,J));const ge=L.textures;if(J.length!==ge.length||J[0]!==s.COLOR_ATTACHMENT0){for(let ee=0,Te=ge.length;ee<Te;ee++)J[ee]=s.COLOR_ATTACHMENT0+ee;J.length=ge.length,he=!0}}else J[0]!==s.BACK&&(J[0]=s.BACK,he=!0);he&&s.drawBuffers(J)}function Ae(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const be={[Ns]:s.FUNC_ADD,[hv]:s.FUNC_SUBTRACT,[dv]:s.FUNC_REVERSE_SUBTRACT};be[uv]=s.MIN,be[fv]=s.MAX;const Ne={[pv]:s.ZERO,[mv]:s.ONE,[gv]:s.SRC_COLOR,[Ch]:s.SRC_ALPHA,[Mv]:s.SRC_ALPHA_SATURATE,[xv]:s.DST_COLOR,[yv]:s.DST_ALPHA,[vv]:s.ONE_MINUS_SRC_COLOR,[Rh]:s.ONE_MINUS_SRC_ALPHA,[wv]:s.ONE_MINUS_DST_COLOR,[bv]:s.ONE_MINUS_DST_ALPHA,[Sv]:s.CONSTANT_COLOR,[_v]:s.ONE_MINUS_CONSTANT_COLOR,[Ev]:s.CONSTANT_ALPHA,[Tv]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,re,J,he,ge,ee,Te,we,Pt,yt){if(L===Si){p===!0&&(F(s.BLEND),p=!1);return}if(p===!1&&(ne(s.BLEND),p=!0),L!==cv){if(L!==m||yt!==C){if((S!==Ns||M!==Ns)&&(s.blendEquation(s.FUNC_ADD),S=Ns,M=Ns),yt)switch(L){case Ua:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ti:s.blendFunc(s.ONE,s.ONE);break;case pf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case mf:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Fe("WebGLState: Invalid blending: ",L);break}else switch(L){case Ua:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ti:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case pf:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mf:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",L);break}_=null,x=null,E=null,I=null,y.set(0,0,0),T=0,m=L,C=yt}return}ge=ge||re,ee=ee||J,Te=Te||he,(re!==S||ge!==M)&&(s.blendEquationSeparate(be[re],be[ge]),S=re,M=ge),(J!==_||he!==x||ee!==E||Te!==I)&&(s.blendFuncSeparate(Ne[J],Ne[he],Ne[ee],Ne[Te]),_=J,x=he,E=ee,I=Te),(we.equals(y)===!1||Pt!==T)&&(s.blendColor(we.r,we.g,we.b,Pt),y.copy(we),T=Pt),m=L,C=!1}function ke(L,re){L.side===Zn?F(s.CULL_FACE):ne(s.CULL_FACE);let J=L.side===Vt;re&&(J=!J),st(J),L.blending===Ua&&L.transparent===!1?Oe(Si):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),r.setFunc(L.depthFunc),r.setTest(L.depthTest),r.setMask(L.depthWrite),a.setMask(L.colorWrite);const he=L.stencilWrite;o.setTest(he),he&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Mt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(s.SAMPLE_ALPHA_TO_COVERAGE):F(s.SAMPLE_ALPHA_TO_COVERAGE)}function st(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function at(L){L!==rv?(ne(s.CULL_FACE),L!==P&&(L===ff?s.cullFace(s.BACK):L===ov?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):F(s.CULL_FACE),P=L}function Ct(L){L!==V&&(G&&s.lineWidth(L),V=L)}function Mt(L,re,J){L?(ne(s.POLYGON_OFFSET_FILL),(q!==re||O!==J)&&(q=re,O=J,r.getReversed()&&(re=-re),s.polygonOffset(re,J))):F(s.POLYGON_OFFSET_FILL)}function Rt(L){L?ne(s.SCISSOR_TEST):F(s.SCISSOR_TEST)}function Bt(L){L===void 0&&(L=s.TEXTURE0+W-1),Q!==L&&(s.activeTexture(L),Q=L)}function N(L,re,J){J===void 0&&(Q===null?J=s.TEXTURE0+W-1:J=Q);let he=ie[J];he===void 0&&(he={type:void 0,texture:void 0},ie[J]=he),(he.type!==L||he.texture!==re)&&(Q!==J&&(s.activeTexture(J),Q=J),s.bindTexture(L,re||ae[L]),he.type=L,he.texture=re)}function wn(){const L=ie[Q];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function rt(){try{s.compressedTexImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function A(){try{s.compressedTexImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function b(){try{s.texSubImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function U(){try{s.texSubImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function H(){try{s.compressedTexSubImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function K(){try{s.compressedTexSubImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function oe(){try{s.texStorage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function $(){try{s.texImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function j(){try{s.texImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function le(L){return d[L]!==void 0?d[L]:s.getParameter(L)}function Ie(L,re){d[L]!==re&&(s.pixelStorei(L,re),d[L]=re)}function ue(L){Je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),Je.copy(L))}function ce(L){ze.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),ze.copy(L))}function Le(L,re){let J=c.get(re);J===void 0&&(J=new WeakMap,c.set(re,J));let he=J.get(L);he===void 0&&(he=s.getUniformBlockIndex(re,L.name),J.set(L,he))}function Ue(L,re){const he=c.get(re).get(L);l.get(re)!==he&&(s.uniformBlockBinding(re,he,L.__bindingPointIndex),l.set(re,he))}function Ge(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),r.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},d={},Q=null,ie={},u={},f=new WeakMap,g=[],v=null,p=!1,m=null,S=null,_=null,x=null,M=null,E=null,I=null,y=new ve(0,0,0),T=0,C=!1,D=null,P=null,V=null,q=null,O=null,Je.set(0,0,s.canvas.width,s.canvas.height),ze.set(0,0,s.canvas.width,s.canvas.height),a.reset(),r.reset(),o.reset()}return{buffers:{color:a,depth:r,stencil:o},enable:ne,disable:F,bindFramebuffer:_e,drawBuffers:Pe,useProgram:Ae,setBlending:Oe,setMaterial:ke,setFlipSided:st,setCullFace:at,setLineWidth:Ct,setPolygonOffset:Mt,setScissorTest:Rt,activeTexture:Bt,bindTexture:N,unbindTexture:wn,compressedTexImage2D:rt,compressedTexImage3D:A,texImage2D:$,texImage3D:j,pixelStorei:Ie,getParameter:le,updateUBOMapping:Le,uniformBlockBinding:Ue,texStorage2D:se,texStorage3D:oe,texSubImage2D:b,texSubImage3D:U,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:ue,viewport:ce,reset:Ge}}function rS(s,e,t,n,i,a,r){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 Re,h=new WeakMap,d=new Set;let u;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(A,b){return g?new OffscreenCanvas(A,b):$r("canvas")}function p(A,b,U){let H=1;const K=rt(A);if((K.width>U||K.height>U)&&(H=U/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const se=Math.floor(H*K.width),oe=Math.floor(H*K.height);u===void 0&&(u=v(se,oe));const $=b?v(se,oe):u;return $.width=se,$.height=oe,$.getContext("2d").drawImage(A,0,0,se,oe),Ee("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),$}else return"data"in A&&Ee("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),A;return A}function m(A){return A.generateMipmaps}function S(A){s.generateMipmap(A)}function _(A){return A.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?s.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function x(A,b,U,H,K,se=!1){if(A!==null){if(s[A]!==void 0)return s[A];Ee("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let oe;H&&(oe=e.get("EXT_texture_norm16"),oe||Ee("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=b;if(b===s.RED&&(U===s.FLOAT&&($=s.R32F),U===s.HALF_FLOAT&&($=s.R16F),U===s.UNSIGNED_BYTE&&($=s.R8),U===s.UNSIGNED_SHORT&&oe&&($=oe.R16_EXT),U===s.SHORT&&oe&&($=oe.R16_SNORM_EXT)),b===s.RED_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.R8UI),U===s.UNSIGNED_SHORT&&($=s.R16UI),U===s.UNSIGNED_INT&&($=s.R32UI),U===s.BYTE&&($=s.R8I),U===s.SHORT&&($=s.R16I),U===s.INT&&($=s.R32I)),b===s.RG&&(U===s.FLOAT&&($=s.RG32F),U===s.HALF_FLOAT&&($=s.RG16F),U===s.UNSIGNED_BYTE&&($=s.RG8),U===s.UNSIGNED_SHORT&&oe&&($=oe.RG16_EXT),U===s.SHORT&&oe&&($=oe.RG16_SNORM_EXT)),b===s.RG_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RG8UI),U===s.UNSIGNED_SHORT&&($=s.RG16UI),U===s.UNSIGNED_INT&&($=s.RG32UI),U===s.BYTE&&($=s.RG8I),U===s.SHORT&&($=s.RG16I),U===s.INT&&($=s.RG32I)),b===s.RGB_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RGB8UI),U===s.UNSIGNED_SHORT&&($=s.RGB16UI),U===s.UNSIGNED_INT&&($=s.RGB32UI),U===s.BYTE&&($=s.RGB8I),U===s.SHORT&&($=s.RGB16I),U===s.INT&&($=s.RGB32I)),b===s.RGBA_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RGBA8UI),U===s.UNSIGNED_SHORT&&($=s.RGBA16UI),U===s.UNSIGNED_INT&&($=s.RGBA32UI),U===s.BYTE&&($=s.RGBA8I),U===s.SHORT&&($=s.RGBA16I),U===s.INT&&($=s.RGBA32I)),b===s.RGB&&(U===s.UNSIGNED_SHORT&&oe&&($=oe.RGB16_EXT),U===s.SHORT&&oe&&($=oe.RGB16_SNORM_EXT),U===s.UNSIGNED_INT_5_9_9_9_REV&&($=s.RGB9_E5),U===s.UNSIGNED_INT_10F_11F_11F_REV&&($=s.R11F_G11F_B10F)),b===s.RGBA){const j=se?Pl:Qe.getTransfer(K);U===s.FLOAT&&($=s.RGBA32F),U===s.HALF_FLOAT&&($=s.RGBA16F),U===s.UNSIGNED_BYTE&&($=j===ot?s.SRGB8_ALPHA8:s.RGBA8),U===s.UNSIGNED_SHORT&&oe&&($=oe.RGBA16_EXT),U===s.SHORT&&oe&&($=oe.RGBA16_SNORM_EXT),U===s.UNSIGNED_SHORT_4_4_4_4&&($=s.RGBA4),U===s.UNSIGNED_SHORT_5_5_5_1&&($=s.RGB5_A1)}return($===s.R16F||$===s.R32F||$===s.RG16F||$===s.RG32F||$===s.RGBA16F||$===s.RGBA32F)&&e.get("EXT_color_buffer_float"),$}function M(A,b){let U;return A?b===null||b===ni||b===Yr?U=s.DEPTH24_STENCIL8:b===Vn?U=s.DEPTH32F_STENCIL8:b===qr&&(U=s.DEPTH24_STENCIL8,Ee("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===ni||b===Yr?U=s.DEPTH_COMPONENT24:b===Vn?U=s.DEPTH_COMPONENT32F:b===qr&&(U=s.DEPTH_COMPONENT16),U}function E(A,b){return m(A)===!0||A.isFramebufferTexture&&A.minFilter!==Wt&&A.minFilter!==At?Math.log2(Math.max(b.width,b.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?b.mipmaps.length:1}function I(A){const b=A.target;b.removeEventListener("dispose",I),T(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function y(A){const b=A.target;b.removeEventListener("dispose",y),D(b)}function T(A){const b=n.get(A);if(b.__webglInit===void 0)return;const U=A.source,H=f.get(U);if(H){const K=H[b.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(A),Object.keys(H).length===0&&f.delete(U)}n.remove(A)}function C(A){const b=n.get(A);s.deleteTexture(b.__webglTexture);const U=A.source,H=f.get(U);delete H[b.__cacheKey],r.memory.textures--}function D(A){const b=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(b.__webglFramebuffer[H]))for(let K=0;K<b.__webglFramebuffer[H].length;K++)s.deleteFramebuffer(b.__webglFramebuffer[H][K]);else s.deleteFramebuffer(b.__webglFramebuffer[H]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[H])}else{if(Array.isArray(b.__webglFramebuffer))for(let H=0;H<b.__webglFramebuffer.length;H++)s.deleteFramebuffer(b.__webglFramebuffer[H]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let H=0;H<b.__webglColorRenderbuffer.length;H++)b.__webglColorRenderbuffer[H]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[H]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const U=A.textures;for(let H=0,K=U.length;H<K;H++){const se=n.get(U[H]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),r.memory.textures--),n.remove(U[H])}n.remove(A)}let P=0;function V(){P=0}function q(){return P}function O(A){P=A}function W(){const A=P;return A>=i.maxTextures&&Ee("WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+i.maxTextures),P+=1,A}function G(A){const b=[];return b.push(A.wrapS),b.push(A.wrapT),b.push(A.wrapR||0),b.push(A.magFilter),b.push(A.minFilter),b.push(A.anisotropy),b.push(A.internalFormat),b.push(A.format),b.push(A.type),b.push(A.generateMipmaps),b.push(A.premultiplyAlpha),b.push(A.flipY),b.push(A.unpackAlignment),b.push(A.colorSpace),b.join()}function Z(A,b){const U=n.get(A);if(A.isVideoTexture&&N(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&U.__version!==A.version){const H=A.image;if(H===null)Ee("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ee("WebGLRenderer: Texture marked for update but image is incomplete");else{F(U,A,b);return}}else A.isExternalTexture&&(U.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,U.__webglTexture,s.TEXTURE0+b)}function te(A,b){const U=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){F(U,A,b);return}else A.isExternalTexture&&(U.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,U.__webglTexture,s.TEXTURE0+b)}function Q(A,b){const U=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){F(U,A,b);return}t.bindTexture(s.TEXTURE_3D,U.__webglTexture,s.TEXTURE0+b)}function ie(A,b){const U=n.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&U.__version!==A.version){_e(U,A,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,U.__webglTexture,s.TEXTURE0+b)}const de={[Tl]:s.REPEAT,[vn]:s.CLAMP_TO_EDGE,[Bh]:s.MIRRORED_REPEAT},He={[Wt]:s.NEAREST,[Cv]:s.NEAREST_MIPMAP_NEAREST,[fo]:s.NEAREST_MIPMAP_LINEAR,[At]:s.LINEAR,[cc]:s.LINEAR_MIPMAP_NEAREST,[Bs]:s.LINEAR_MIPMAP_LINEAR},Je={[Nv]:s.NEVER,[Bv]:s.ALWAYS,[Ov]:s.LESS,[ou]:s.LEQUAL,[kv]:s.EQUAL,[lu]:s.GEQUAL,[Uv]:s.GREATER,[Fv]:s.NOTEQUAL};function ze(A,b){if(b.type===Vn&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===At||b.magFilter===cc||b.magFilter===fo||b.magFilter===Bs||b.minFilter===At||b.minFilter===cc||b.minFilter===fo||b.minFilter===Bs)&&Ee("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(A,s.TEXTURE_WRAP_S,de[b.wrapS]),s.texParameteri(A,s.TEXTURE_WRAP_T,de[b.wrapT]),(A===s.TEXTURE_3D||A===s.TEXTURE_2D_ARRAY)&&s.texParameteri(A,s.TEXTURE_WRAP_R,de[b.wrapR]),s.texParameteri(A,s.TEXTURE_MAG_FILTER,He[b.magFilter]),s.texParameteri(A,s.TEXTURE_MIN_FILTER,He[b.minFilter]),b.compareFunction&&(s.texParameteri(A,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(A,s.TEXTURE_COMPARE_FUNC,Je[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Wt||b.minFilter!==fo&&b.minFilter!==Bs||b.type===Vn&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const U=e.get("EXT_texture_filter_anisotropic");s.texParameterf(A,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,i.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function Y(A,b){let U=!1;A.__webglInit===void 0&&(A.__webglInit=!0,b.addEventListener("dispose",I));const H=b.source;let K=f.get(H);K===void 0&&(K={},f.set(H,K));const se=G(b);if(se!==A.__cacheKey){K[se]===void 0&&(K[se]={texture:s.createTexture(),usedTimes:0},r.memory.textures++,U=!0),K[se].usedTimes++;const oe=K[A.__cacheKey];oe!==void 0&&(K[A.__cacheKey].usedTimes--,oe.usedTimes===0&&C(b)),A.__cacheKey=se,A.__webglTexture=K[se].texture}return U}function ae(A,b,U){return Math.floor(Math.floor(A/U)/b)}function ne(A,b,U,H){const se=A.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,U,H,b.data);else{se.sort((Ie,ue)=>Ie.start-ue.start);let oe=0;for(let Ie=1;Ie<se.length;Ie++){const ue=se[oe],ce=se[Ie],Le=ue.start+ue.count,Ue=ae(ce.start,b.width,4),Ge=ae(ue.start,b.width,4);ce.start<=Le+1&&Ue===Ge&&ae(ce.start+ce.count-1,b.width,4)===Ue?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++oe,se[oe]=ce)}se.length=oe+1;const $=t.getParameter(s.UNPACK_ROW_LENGTH),j=t.getParameter(s.UNPACK_SKIP_PIXELS),le=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let Ie=0,ue=se.length;Ie<ue;Ie++){const ce=se[Ie],Le=Math.floor(ce.start/4),Ue=Math.ceil(ce.count/4),Ge=Le%b.width,L=Math.floor(Le/b.width),re=Ue,J=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Ge),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Ge,L,re,J,U,H,b.data)}A.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,$),t.pixelStorei(s.UNPACK_SKIP_PIXELS,j),t.pixelStorei(s.UNPACK_SKIP_ROWS,le)}}function F(A,b,U){let H=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(H=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(H=s.TEXTURE_3D);const K=Y(A,b),se=b.source;t.bindTexture(H,A.__webglTexture,s.TEXTURE0+U);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(s.TEXTURE0+U),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){const J=Qe.getPrimaries(Qe.workingColorSpace),he=b.colorSpace===us?null:Qe.getPrimaries(b.colorSpace),ge=b.colorSpace===us||J===he?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment);let j=p(b.image,!1,i.maxTextureSize);j=wn(b,j);const le=a.convert(b.format,b.colorSpace),Ie=a.convert(b.type);let ue=x(b.internalFormat,le,Ie,b.normalized,b.colorSpace,b.isVideoTexture);ze(H,b);let ce;const Le=b.mipmaps,Ue=b.isVideoTexture!==!0,Ge=oe.__version===void 0||K===!0,L=se.dataReady,re=E(b,j);if(b.isDepthTexture)ue=M(b.format===zs,b.type),Ge&&(Ue?t.texStorage2D(s.TEXTURE_2D,1,ue,j.width,j.height):t.texImage2D(s.TEXTURE_2D,0,ue,j.width,j.height,0,le,Ie,null));else if(b.isDataTexture)if(Le.length>0){Ue&&Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)ce=Le[J],Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Ie,ce.data):t.texImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,le,Ie,ce.data);b.generateMipmaps=!1}else Ue?(Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,j.width,j.height),L&&ne(b,j,le,Ie)):t.texImage2D(s.TEXTURE_2D,0,ue,j.width,j.height,0,le,Ie,j.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Ue&&Ge&&t.texStorage3D(s.TEXTURE_2D_ARRAY,re,ue,Le[0].width,Le[0].height,j.depth);for(let J=0,he=Le.length;J<he;J++)if(ce=Le[J],b.format!==yn)if(le!==null)if(Ue){if(L)if(b.layerUpdates.size>0){const ge=hp(ce.width,ce.height,b.format,b.type);for(const ee of b.layerUpdates){const Te=ce.data.subarray(ee*ge/ce.data.BYTES_PER_ELEMENT,(ee+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,ee,ce.width,ce.height,1,le,Te)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,j.depth,le,ce.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,J,ue,ce.width,ce.height,j.depth,0,ce.data,0,0);else Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ue?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,j.depth,le,Ie,ce.data):t.texImage3D(s.TEXTURE_2D_ARRAY,J,ue,ce.width,ce.height,j.depth,0,le,Ie,ce.data)}else{Ue&&Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)ce=Le[J],b.format!==yn?le!==null?Ue?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,ce.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Ie,ce.data):t.texImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,le,Ie,ce.data)}else if(b.isDataArrayTexture)if(Ue){if(Ge&&t.texStorage3D(s.TEXTURE_2D_ARRAY,re,ue,j.width,j.height,j.depth),L)if(b.layerUpdates.size>0){const J=hp(j.width,j.height,b.format,b.type);for(const he of b.layerUpdates){const ge=j.data.subarray(he*J/j.data.BYTES_PER_ELEMENT,(he+1)*J/j.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,he,j.width,j.height,1,le,Ie,ge)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,le,Ie,j.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ue,j.width,j.height,j.depth,0,le,Ie,j.data);else if(b.isData3DTexture)Ue?(Ge&&t.texStorage3D(s.TEXTURE_3D,re,ue,j.width,j.height,j.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,le,Ie,j.data)):t.texImage3D(s.TEXTURE_3D,0,ue,j.width,j.height,j.depth,0,le,Ie,j.data);else if(b.isFramebufferTexture){if(Ge)if(Ue)t.texStorage2D(s.TEXTURE_2D,re,ue,j.width,j.height);else{let J=j.width,he=j.height;for(let ge=0;ge<re;ge++)t.texImage2D(s.TEXTURE_2D,ge,ue,J,he,0,le,Ie,null),J>>=1,he>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in s){const J=s.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),j.parentNode!==J){J.appendChild(j),d.add(b),J.onpaint=he=>{const ge=he.changedElements;for(const ee of d)ge.includes(ee.image)&&(ee.needsUpdate=!0)},J.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,j);else{const ge=s.RGBA,ee=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ge,ee,Te,j)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Ue&&Ge){const J=rt(Le[0]);t.texStorage2D(s.TEXTURE_2D,re,ue,J.width,J.height)}for(let J=0,he=Le.length;J<he;J++)ce=Le[J],Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,le,Ie,ce):t.texImage2D(s.TEXTURE_2D,J,ue,le,Ie,ce);b.generateMipmaps=!1}else if(Ue){if(Ge){const J=rt(j);t.texStorage2D(s.TEXTURE_2D,re,ue,J.width,J.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,le,Ie,j)}else t.texImage2D(s.TEXTURE_2D,0,ue,le,Ie,j);m(b)&&S(H),oe.__version=se.version,b.onUpdate&&b.onUpdate(b)}A.__version=b.version}function _e(A,b,U){if(b.image.length!==6)return;const H=Y(A,b),K=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,A.__webglTexture,s.TEXTURE0+U);const se=n.get(K);if(K.version!==se.__version||H===!0){t.activeTexture(s.TEXTURE0+U);const oe=Qe.getPrimaries(Qe.workingColorSpace),$=b.colorSpace===us?null:Qe.getPrimaries(b.colorSpace),j=b.colorSpace===us||oe===$?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,j);const le=b.isCompressedTexture||b.image[0].isCompressedTexture,Ie=b.image[0]&&b.image[0].isDataTexture,ue=[];for(let ee=0;ee<6;ee++)!le&&!Ie?ue[ee]=p(b.image[ee],!0,i.maxCubemapSize):ue[ee]=Ie?b.image[ee].image:b.image[ee],ue[ee]=wn(b,ue[ee]);const ce=ue[0],Le=a.convert(b.format,b.colorSpace),Ue=a.convert(b.type),Ge=x(b.internalFormat,Le,Ue,b.normalized,b.colorSpace),L=b.isVideoTexture!==!0,re=se.__version===void 0||H===!0,J=K.dataReady;let he=E(b,ce);ze(s.TEXTURE_CUBE_MAP,b);let ge;if(le){L&&re&&t.texStorage2D(s.TEXTURE_CUBE_MAP,he,Ge,ce.width,ce.height);for(let ee=0;ee<6;ee++){ge=ue[ee].mipmaps;for(let Te=0;Te<ge.length;Te++){const we=ge[Te];b.format!==yn?Le!==null?L?J&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,0,0,we.width,we.height,Le,we.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,Ge,we.width,we.height,0,we.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,0,0,we.width,we.height,Le,Ue,we.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,Ge,we.width,we.height,0,Le,Ue,we.data)}}}else{if(ge=b.mipmaps,L&&re){ge.length>0&&he++;const ee=rt(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,he,Ge,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Ie){L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ue[ee].width,ue[ee].height,Le,Ue,ue[ee].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,ue[ee].width,ue[ee].height,0,Le,Ue,ue[ee].data);for(let Te=0;Te<ge.length;Te++){const Pt=ge[Te].image[ee].image;L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,0,0,Pt.width,Pt.height,Le,Ue,Pt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,Ge,Pt.width,Pt.height,0,Le,Ue,Pt.data)}}else{L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Le,Ue,ue[ee]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,Le,Ue,ue[ee]);for(let Te=0;Te<ge.length;Te++){const we=ge[Te];L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,0,0,Le,Ue,we.image[ee]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,Ge,Le,Ue,we.image[ee])}}}m(b)&&S(s.TEXTURE_CUBE_MAP),se.__version=K.version,b.onUpdate&&b.onUpdate(b)}A.__version=b.version}function Pe(A,b,U,H,K,se){const oe=a.convert(U.format,U.colorSpace),$=a.convert(U.type),j=x(U.internalFormat,oe,$,U.normalized,U.colorSpace),le=n.get(b),Ie=n.get(U);if(Ie.__renderTarget=b,!le.__hasExternalTextures){const ue=Math.max(1,b.width>>se),ce=Math.max(1,b.height>>se);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,se,j,ue,ce,b.depth,0,oe,$,null):t.texImage2D(K,se,j,ue,ce,0,oe,$,null)}t.bindFramebuffer(s.FRAMEBUFFER,A),Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,H,K,Ie.__webglTexture,0,Rt(b)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,H,K,Ie.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ae(A,b,U){if(s.bindRenderbuffer(s.RENDERBUFFER,A),b.depthBuffer){const H=b.depthTexture,K=H&&H.isDepthTexture?H.type:null,se=M(b.stencilBuffer,K),oe=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Bt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Rt(b),se,b.width,b.height):U?s.renderbufferStorageMultisample(s.RENDERBUFFER,Rt(b),se,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,se,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,oe,s.RENDERBUFFER,A)}else{const H=b.textures;for(let K=0;K<H.length;K++){const se=H[K],oe=a.convert(se.format,se.colorSpace),$=a.convert(se.type),j=x(se.internalFormat,oe,$,se.normalized,se.colorSpace);Bt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Rt(b),j,b.width,b.height):U?s.renderbufferStorageMultisample(s.RENDERBUFFER,Rt(b),j,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,j,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function be(A,b,U){const H=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,A),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(b.depthTexture);if(K.__renderTarget=b,(!K.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),H){if(K.__webglInit===void 0&&(K.__webglInit=!0,b.depthTexture.addEventListener("dispose",I)),K.__webglTexture===void 0){K.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),ze(s.TEXTURE_CUBE_MAP,b.depthTexture);const le=a.convert(b.depthTexture.format),Ie=a.convert(b.depthTexture.type);let ue;b.depthTexture.format===Wi?ue=s.DEPTH_COMPONENT24:b.depthTexture.format===zs&&(ue=s.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,b.width,b.height,0,le,Ie,null)}}else Z(b.depthTexture,0);const se=K.__webglTexture,oe=Rt(b),$=H?s.TEXTURE_CUBE_MAP_POSITIVE_X+U:s.TEXTURE_2D,j=b.depthTexture.format===zs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(b.depthTexture.format===Wi)Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,j,$,se,0,oe):s.framebufferTexture2D(s.FRAMEBUFFER,j,$,se,0);else if(b.depthTexture.format===zs)Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,j,$,se,0,oe):s.framebufferTexture2D(s.FRAMEBUFFER,j,$,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(A){const b=n.get(A),U=A.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==A.depthTexture){const H=A.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),H){const K=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),b.__depthDisposeCallback=K}b.__boundDepthTexture=H}if(A.depthTexture&&!b.__autoAllocateDepthBuffer)if(U)for(let H=0;H<6;H++)be(b.__webglFramebuffer[H],A,H);else{const H=A.texture.mipmaps;H&&H.length>0?be(b.__webglFramebuffer[0],A,0):be(b.__webglFramebuffer,A,0)}else if(U){b.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[H]),b.__webglDepthbuffer[H]===void 0)b.__webglDepthbuffer[H]=s.createRenderbuffer(),Ae(b.__webglDepthbuffer[H],A,!1);else{const K=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer[H];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,se)}}else{const H=A.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),Ae(b.__webglDepthbuffer,A,!1);else{const K=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(A,b,U){const H=n.get(A);b!==void 0&&Pe(H.__webglFramebuffer,A,A.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),U!==void 0&&Ne(A)}function ke(A){const b=A.texture,U=n.get(A),H=n.get(b);A.addEventListener("dispose",y);const K=A.textures,se=A.isWebGLCubeRenderTarget===!0,oe=K.length>1;if(oe||(H.__webglTexture===void 0&&(H.__webglTexture=s.createTexture()),H.__version=b.version,r.memory.textures++),se){U.__webglFramebuffer=[];for(let $=0;$<6;$++)if(b.mipmaps&&b.mipmaps.length>0){U.__webglFramebuffer[$]=[];for(let j=0;j<b.mipmaps.length;j++)U.__webglFramebuffer[$][j]=s.createFramebuffer()}else U.__webglFramebuffer[$]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){U.__webglFramebuffer=[];for(let $=0;$<b.mipmaps.length;$++)U.__webglFramebuffer[$]=s.createFramebuffer()}else U.__webglFramebuffer=s.createFramebuffer();if(oe)for(let $=0,j=K.length;$<j;$++){const le=n.get(K[$]);le.__webglTexture===void 0&&(le.__webglTexture=s.createTexture(),r.memory.textures++)}if(A.samples>0&&Bt(A)===!1){U.__webglMultisampledFramebuffer=s.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const j=K[$];U.__webglColorRenderbuffer[$]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,U.__webglColorRenderbuffer[$]);const le=a.convert(j.format,j.colorSpace),Ie=a.convert(j.type),ue=x(j.internalFormat,le,Ie,j.normalized,j.colorSpace,A.isXRRenderTarget===!0),ce=Rt(A);s.renderbufferStorageMultisample(s.RENDERBUFFER,ce,ue,A.width,A.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+$,s.RENDERBUFFER,U.__webglColorRenderbuffer[$])}s.bindRenderbuffer(s.RENDERBUFFER,null),A.depthBuffer&&(U.__webglDepthRenderbuffer=s.createRenderbuffer(),Ae(U.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,H.__webglTexture),ze(s.TEXTURE_CUBE_MAP,b);for(let $=0;$<6;$++)if(b.mipmaps&&b.mipmaps.length>0)for(let j=0;j<b.mipmaps.length;j++)Pe(U.__webglFramebuffer[$][j],A,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,j);else Pe(U.__webglFramebuffer[$],A,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);m(b)&&S(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let $=0,j=K.length;$<j;$++){const le=K[$],Ie=n.get(le);let ue=s.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ue=A.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,Ie.__webglTexture),ze(ue,le),Pe(U.__webglFramebuffer,A,le,s.COLOR_ATTACHMENT0+$,ue,0),m(le)&&S(ue)}t.unbindTexture()}else{let $=s.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&($=A.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture($,H.__webglTexture),ze($,b),b.mipmaps&&b.mipmaps.length>0)for(let j=0;j<b.mipmaps.length;j++)Pe(U.__webglFramebuffer[j],A,b,s.COLOR_ATTACHMENT0,$,j);else Pe(U.__webglFramebuffer,A,b,s.COLOR_ATTACHMENT0,$,0);m(b)&&S($),t.unbindTexture()}A.depthBuffer&&Ne(A)}function st(A){const b=A.textures;for(let U=0,H=b.length;U<H;U++){const K=b[U];if(m(K)){const se=_(A),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),S(se),t.unbindTexture()}}}const at=[],Ct=[];function Mt(A){if(A.samples>0){if(Bt(A)===!1){const b=A.textures,U=A.width,H=A.height;let K=s.COLOR_BUFFER_BIT;const se=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,oe=n.get(A),$=b.length>1;if($)for(let le=0;le<b.length;le++)t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const j=A.texture.mipmaps;j&&j.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let le=0;le<b.length;le++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),$){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Ie=n.get(b[le]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Ie,0)}s.blitFramebuffer(0,0,U,H,0,0,U,H,K,s.NEAREST),l===!0&&(at.length=0,Ct.length=0,at.push(s.COLOR_ATTACHMENT0+le),A.depthBuffer&&A.resolveDepthBuffer===!1&&(at.push(se),Ct.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ct)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,at))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),$)for(let le=0;le<b.length;le++){t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Ie=n.get(b[le]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,Ie,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const b=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function Rt(A){return Math.min(i.maxSamples,A.samples)}function Bt(A){const b=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function N(A){const b=r.render.frame;h.get(A)!==b&&(h.set(A,b),A.update())}function wn(A,b){const U=A.colorSpace,H=A.format,K=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||U!==Rl&&U!==us&&(Qe.getTransfer(U)===ot?(H!==yn||K!==kn)&&Ee("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Fe("WebGLTextures: Unsupported texture color space:",U)),b}function rt(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=V,this.getTextureUnits=q,this.setTextureUnits=O,this.setTexture2D=Z,this.setTexture2DArray=te,this.setTexture3D=Q,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=Mt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Bt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function oS(s,e){function t(n,i=us){let a;const r=Qe.getTransfer(i);if(n===kn)return s.UNSIGNED_BYTE;if(n===tu)return s.UNSIGNED_SHORT_4_4_4_4;if(n===nu)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Rm)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Pm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Dm)return s.BYTE;if(n===Cm)return s.SHORT;if(n===qr)return s.UNSIGNED_SHORT;if(n===eu)return s.INT;if(n===ni)return s.UNSIGNED_INT;if(n===Vn)return s.FLOAT;if(n===cn)return s.HALF_FLOAT;if(n===Lm)return s.ALPHA;if(n===Nm)return s.RGB;if(n===yn)return s.RGBA;if(n===Wi)return s.DEPTH_COMPONENT;if(n===zs)return s.DEPTH_STENCIL;if(n===iu)return s.RED;if(n===su)return s.RED_INTEGER;if(n===Ys)return s.RG;if(n===au)return s.RG_INTEGER;if(n===ru)return s.RGBA_INTEGER;if(n===dl||n===ul||n===fl||n===pl)if(r===ot)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(n===dl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ul)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===fl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===pl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(n===dl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ul)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===fl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===pl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===zh||n===Hh||n===Gh||n===Vh)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(n===zh)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Hh)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Gh)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Vh)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Wh||n===Xh||n===qh||n===Yh||n===Kh||n===Al||n===$h)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(n===Wh||n===Xh)return r===ot?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===qh)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(n===Yh)return a.COMPRESSED_R11_EAC;if(n===Kh)return a.COMPRESSED_SIGNED_R11_EAC;if(n===Al)return a.COMPRESSED_RG11_EAC;if(n===$h)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Zh||n===Jh||n===jh||n===Qh||n===ed||n===td||n===nd||n===id||n===sd||n===ad||n===rd||n===od||n===ld||n===cd)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(n===Zh)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Jh)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===jh)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Qh)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ed)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===td)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===nd)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===id)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===sd)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ad)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===rd)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===od)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ld)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===cd)return r===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===hd||n===dd||n===ud)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(n===hd)return r===ot?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===dd)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ud)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===fd||n===pd||n===Il||n===md)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(n===fd)return a.COMPRESSED_RED_RGTC1_EXT;if(n===pd)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Il)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===md)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Yr?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const lS=`
5956
+ }`,nS=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],iS=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Lp=new qe,br=new R,Xc=new R;function sS(s,e,t){let n=new pu;const i=new Re,a=new Re,r=new ft,o=new Wy,l=new Xy,c={},h=t.maxTextureSize,d={[vs]:Vt,[Vt]:vs,[Zn]:Zn},u=new Nt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:eS,fragmentShader:tS}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const g=new Dt;g.setAttribute("position",new gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ze(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Pr;let m=this.type;this.render=function(E,I,y){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;this.type===lv&&(Ee("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Pr);const T=s.getRenderTarget(),C=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Si),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const V=m!==this.type;V&&I.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(O=>O.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,O=E.length;q<O;q++){const W=E[q],G=W.shadow;if(G===void 0){Ee("WebGLShadowMap:",W,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();i.multiply(Z),a.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(a.x=Math.floor(h/Z.x),i.x=a.x*Z.x,G.mapSize.x=a.x),i.y>h&&(a.y=Math.floor(h/Z.y),i.y=a.y*Z.y,G.mapSize.y=a.y));const te=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=te,G.map===null||V===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Tr){if(W.isPointLight){Ee("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Tn(i.x,i.y,{format:Ys,type:hn,minFilter:At,magFilter:At,generateMipmaps:!1}),G.map.texture.name=W.name+".shadowMap",G.map.depthTexture=new Ks(i.x,i.y,Vn),G.map.depthTexture.name=W.name+".shadowMapDepth",G.map.depthTexture.format=Wi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wt,G.map.depthTexture.magFilter=Wt}else W.isPointLight?(G.map=new jm(i.x),G.map.depthTexture=new Uy(i.x,ii)):(G.map=new Tn(i.x,i.y),G.map.depthTexture=new Ks(i.x,i.y,ii)),G.map.depthTexture.name=W.name+".shadowMap",G.map.depthTexture.format=Wi,this.type===Pr?(G.map.depthTexture.compareFunction=te?lu:ou,G.map.depthTexture.minFilter=At,G.map.depthTexture.magFilter=At):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wt,G.map.depthTexture.magFilter=Wt);G.camera.updateProjectionMatrix()}const Q=G.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<Q;ie++){if(G.map.isWebGLCubeRenderTarget)s.setRenderTarget(G.map,ie),s.clear();else{ie===0&&(s.setRenderTarget(G.map),s.clear());const de=G.getViewport(ie);r.set(a.x*de.x,a.y*de.y,a.x*de.z,a.y*de.w),P.viewport(r)}if(W.isPointLight){const de=G.camera,He=G.matrix,Je=W.distance||de.far;Je!==de.far&&(de.far=Je,de.updateProjectionMatrix()),br.setFromMatrixPosition(W.matrixWorld),de.position.copy(br),Xc.copy(de.position),Xc.add(nS[ie]),de.up.copy(iS[ie]),de.lookAt(Xc),de.updateMatrixWorld(),He.makeTranslation(-br.x,-br.y,-br.z),Lp.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),G._frustum.setFromProjectionMatrix(Lp,de.coordinateSystem,de.reversedDepth)}else G.updateMatrices(W);n=G.getFrustum(),x(I,y,G.camera,W,this.type)}G.isPointLightShadow!==!0&&this.type===Tr&&S(G,y),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,s.setRenderTarget(T,C,D)};function S(E,I){const y=e.update(v);u.defines.VSM_SAMPLES!==E.blurSamples&&(u.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Tn(i.x,i.y,{format:Ys,type:hn})),u.uniforms.shadow_pass.value=E.map.depthTexture,u.uniforms.resolution.value=E.mapSize,u.uniforms.radius.value=E.radius,s.setRenderTarget(E.mapPass),s.clear(),s.renderBufferDirect(I,null,y,u,v,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,s.setRenderTarget(E.map),s.clear(),s.renderBufferDirect(I,null,y,f,v,null)}function _(E,I,y,T){let C=null;const D=y.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)C=D;else if(C=y.isPointLight===!0?l:o,s.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){const P=C.uuid,V=I.uuid;let q=c[P];q===void 0&&(q={},c[P]=q);let O=q[V];O===void 0&&(O=C.clone(),q[V]=O,I.addEventListener("dispose",M)),C=O}if(C.visible=I.visible,C.wireframe=I.wireframe,T===Tr?C.side=I.shadowSide!==null?I.shadowSide:I.side:C.side=I.shadowSide!==null?I.shadowSide:d[I.side],C.alphaMap=I.alphaMap,C.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,C.map=I.map,C.clipShadows=I.clipShadows,C.clippingPlanes=I.clippingPlanes,C.clipIntersection=I.clipIntersection,C.displacementMap=I.displacementMap,C.displacementScale=I.displacementScale,C.displacementBias=I.displacementBias,C.wireframeLinewidth=I.wireframeLinewidth,C.linewidth=I.linewidth,y.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const P=s.properties.get(C);P.light=y}return C}function x(E,I,y,T,C){if(E.visible===!1)return;if(E.layers.test(I.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&C===Tr)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,E.matrixWorld);const V=e.update(E),q=E.material;if(Array.isArray(q)){const O=V.groups;for(let W=0,G=O.length;W<G;W++){const Z=O[W],te=q[Z.materialIndex];if(te&&te.visible){const Q=_(E,te,T,C);E.onBeforeShadow(s,E,I,y,V,Q,Z),s.renderBufferDirect(y,null,V,Q,E,Z),E.onAfterShadow(s,E,I,y,V,Q,Z)}}}else if(q.visible){const O=_(E,q,T,C);E.onBeforeShadow(s,E,I,y,V,O,null),s.renderBufferDirect(y,null,V,O,E,null),E.onAfterShadow(s,E,I,y,V,O,null)}}const P=E.children;for(let V=0,q=P.length;V<q;V++)x(P[V],I,y,T,C)}function M(E){E.target.removeEventListener("dispose",M);for(const y in c){const T=c[y],C=E.target.uuid;C in T&&(T[C].dispose(),delete T[C])}}}function aS(s,e){function t(){let L=!1;const re=new ft;let J=null;const he=new ft(0,0,0,0);return{setMask:function(ge){J!==ge&&!L&&(s.colorMask(ge,ge,ge,ge),J=ge)},setLocked:function(ge){L=ge},setClear:function(ge,ee,Te,we,Pt){Pt===!0&&(ge*=we,ee*=we,Te*=we),re.set(ge,ee,Te,we),he.equals(re)===!1&&(s.clearColor(ge,ee,Te,we),he.copy(re))},reset:function(){L=!1,J=null,he.set(-1,0,0,0)}}}function n(){let L=!1,re=!1,J=null,he=null,ge=null;return{setReversed:function(ee){if(re!==ee){const Te=e.get("EXT_clip_control");ee?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),re=ee;const we=ge;ge=null,this.setClear(we)}},getReversed:function(){return re},setTest:function(ee){ee?ne(s.DEPTH_TEST):F(s.DEPTH_TEST)},setMask:function(ee){J!==ee&&!L&&(s.depthMask(ee),J=ee)},setFunc:function(ee){if(re&&(ee=Wv[ee]),he!==ee){switch(ee){case Ph:s.depthFunc(s.NEVER);break;case Lh:s.depthFunc(s.ALWAYS);break;case Nh:s.depthFunc(s.LESS);break;case Za:s.depthFunc(s.LEQUAL);break;case Oh:s.depthFunc(s.EQUAL);break;case kh:s.depthFunc(s.GEQUAL);break;case Uh:s.depthFunc(s.GREATER);break;case Fh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}he=ee}},setLocked:function(ee){L=ee},setClear:function(ee){ge!==ee&&(ge=ee,re&&(ee=1-ee),s.clearDepth(ee))},reset:function(){L=!1,J=null,he=null,ge=null,re=!1}}}function i(){let L=!1,re=null,J=null,he=null,ge=null,ee=null,Te=null,we=null,Pt=null;return{setTest:function(vt){L||(vt?ne(s.STENCIL_TEST):F(s.STENCIL_TEST))},setMask:function(vt){re!==vt&&!L&&(s.stencilMask(vt),re=vt)},setFunc:function(vt,ai,ri){(J!==vt||he!==ai||ge!==ri)&&(s.stencilFunc(vt,ai,ri),J=vt,he=ai,ge=ri)},setOp:function(vt,ai,ri){(ee!==vt||Te!==ai||we!==ri)&&(s.stencilOp(vt,ai,ri),ee=vt,Te=ai,we=ri)},setLocked:function(vt){L=vt},setClear:function(vt){Pt!==vt&&(s.clearStencil(vt),Pt=vt)},reset:function(){L=!1,re=null,J=null,he=null,ge=null,ee=null,Te=null,we=null,Pt=null}}}const a=new t,r=new n,o=new i,l=new WeakMap,c=new WeakMap;let h={},d={},u={},f=new WeakMap,g=[],v=null,p=!1,m=null,S=null,_=null,x=null,M=null,E=null,I=null,y=new ve(0,0,0),T=0,C=!1,D=null,P=null,V=null,q=null,O=null;const W=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,Z=0;const te=s.getParameter(s.VERSION);te.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(te)[1]),G=Z>=1):te.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),G=Z>=2);let Q=null,ie={};const de=s.getParameter(s.SCISSOR_BOX),He=s.getParameter(s.VIEWPORT),Je=new ft().fromArray(de),ze=new ft().fromArray(He);function Y(L,re,J,he){const ge=new Uint8Array(4),ee=s.createTexture();s.bindTexture(L,ee),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<J;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(re,0,s.RGBA,1,1,he,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(re+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return ee}const ae={};ae[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),ae[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ae[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),a.setClear(0,0,0,1),r.setClear(1),o.setClear(0),ne(s.DEPTH_TEST),r.setFunc(Za),at(!1),rt(ff),ne(s.CULL_FACE),Oe(Si);function ne(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function F(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function _e(L,re){return u[L]!==re?(s.bindFramebuffer(L,re),u[L]=re,L===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=re),L===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=re),!0):!1}function Pe(L,re){let J=g,he=!1;if(L){J=f.get(re),J===void 0&&(J=[],f.set(re,J));const ge=L.textures;if(J.length!==ge.length||J[0]!==s.COLOR_ATTACHMENT0){for(let ee=0,Te=ge.length;ee<Te;ee++)J[ee]=s.COLOR_ATTACHMENT0+ee;J.length=ge.length,he=!0}}else J[0]!==s.BACK&&(J[0]=s.BACK,he=!0);he&&s.drawBuffers(J)}function Ae(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const be={[Ns]:s.FUNC_ADD,[hv]:s.FUNC_SUBTRACT,[dv]:s.FUNC_REVERSE_SUBTRACT};be[uv]=s.MIN,be[fv]=s.MAX;const Ne={[pv]:s.ZERO,[mv]:s.ONE,[gv]:s.SRC_COLOR,[Ch]:s.SRC_ALPHA,[Mv]:s.SRC_ALPHA_SATURATE,[xv]:s.DST_COLOR,[yv]:s.DST_ALPHA,[vv]:s.ONE_MINUS_SRC_COLOR,[Rh]:s.ONE_MINUS_SRC_ALPHA,[wv]:s.ONE_MINUS_DST_COLOR,[bv]:s.ONE_MINUS_DST_ALPHA,[Sv]:s.CONSTANT_COLOR,[_v]:s.ONE_MINUS_CONSTANT_COLOR,[Ev]:s.CONSTANT_ALPHA,[Tv]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,re,J,he,ge,ee,Te,we,Pt,vt){if(L===Si){p===!0&&(F(s.BLEND),p=!1);return}if(p===!1&&(ne(s.BLEND),p=!0),L!==cv){if(L!==m||vt!==C){if((S!==Ns||M!==Ns)&&(s.blendEquation(s.FUNC_ADD),S=Ns,M=Ns),vt)switch(L){case Ua:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ni:s.blendFunc(s.ONE,s.ONE);break;case pf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case mf:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Fe("WebGLState: Invalid blending: ",L);break}else switch(L){case Ua:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ni:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case pf:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mf:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",L);break}_=null,x=null,E=null,I=null,y.set(0,0,0),T=0,m=L,C=vt}return}ge=ge||re,ee=ee||J,Te=Te||he,(re!==S||ge!==M)&&(s.blendEquationSeparate(be[re],be[ge]),S=re,M=ge),(J!==_||he!==x||ee!==E||Te!==I)&&(s.blendFuncSeparate(Ne[J],Ne[he],Ne[ee],Ne[Te]),_=J,x=he,E=ee,I=Te),(we.equals(y)===!1||Pt!==T)&&(s.blendColor(we.r,we.g,we.b,Pt),y.copy(we),T=Pt),m=L,C=!1}function ke(L,re){L.side===Zn?F(s.CULL_FACE):ne(s.CULL_FACE);let J=L.side===Vt;re&&(J=!J),at(J),L.blending===Ua&&L.transparent===!1?Oe(Si):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),r.setFunc(L.depthFunc),r.setTest(L.depthTest),r.setMask(L.depthWrite),a.setMask(L.colorWrite);const he=L.stencilWrite;o.setTest(he),he&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),wt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(s.SAMPLE_ALPHA_TO_COVERAGE):F(s.SAMPLE_ALPHA_TO_COVERAGE)}function at(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function rt(L){L!==rv?(ne(s.CULL_FACE),L!==P&&(L===ff?s.cullFace(s.BACK):L===ov?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):F(s.CULL_FACE),P=L}function Ct(L){L!==V&&(G&&s.lineWidth(L),V=L)}function wt(L,re,J){L?(ne(s.POLYGON_OFFSET_FILL),(q!==re||O!==J)&&(q=re,O=J,r.getReversed()&&(re=-re),s.polygonOffset(re,J))):F(s.POLYGON_OFFSET_FILL)}function Rt(L){L?ne(s.SCISSOR_TEST):F(s.SCISSOR_TEST)}function Bt(L){L===void 0&&(L=s.TEXTURE0+W-1),Q!==L&&(s.activeTexture(L),Q=L)}function N(L,re,J){J===void 0&&(Q===null?J=s.TEXTURE0+W-1:J=Q);let he=ie[J];he===void 0&&(he={type:void 0,texture:void 0},ie[J]=he),(he.type!==L||he.texture!==re)&&(Q!==J&&(s.activeTexture(J),Q=J),s.bindTexture(L,re||ae[L]),he.type=L,he.texture=re)}function wn(){const L=ie[Q];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ot(){try{s.compressedTexImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function A(){try{s.compressedTexImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function b(){try{s.texSubImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function U(){try{s.texSubImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function H(){try{s.compressedTexSubImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function K(){try{s.compressedTexSubImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function oe(){try{s.texStorage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function $(){try{s.texImage2D(...arguments)}catch(L){Fe("WebGLState:",L)}}function j(){try{s.texImage3D(...arguments)}catch(L){Fe("WebGLState:",L)}}function le(L){return d[L]!==void 0?d[L]:s.getParameter(L)}function Ie(L,re){d[L]!==re&&(s.pixelStorei(L,re),d[L]=re)}function ue(L){Je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),Je.copy(L))}function ce(L){ze.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),ze.copy(L))}function Le(L,re){let J=c.get(re);J===void 0&&(J=new WeakMap,c.set(re,J));let he=J.get(L);he===void 0&&(he=s.getUniformBlockIndex(re,L.name),J.set(L,he))}function Ue(L,re){const he=c.get(re).get(L);l.get(re)!==he&&(s.uniformBlockBinding(re,he,L.__bindingPointIndex),l.set(re,he))}function Ge(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),r.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},d={},Q=null,ie={},u={},f=new WeakMap,g=[],v=null,p=!1,m=null,S=null,_=null,x=null,M=null,E=null,I=null,y=new ve(0,0,0),T=0,C=!1,D=null,P=null,V=null,q=null,O=null,Je.set(0,0,s.canvas.width,s.canvas.height),ze.set(0,0,s.canvas.width,s.canvas.height),a.reset(),r.reset(),o.reset()}return{buffers:{color:a,depth:r,stencil:o},enable:ne,disable:F,bindFramebuffer:_e,drawBuffers:Pe,useProgram:Ae,setBlending:Oe,setMaterial:ke,setFlipSided:at,setCullFace:rt,setLineWidth:Ct,setPolygonOffset:wt,setScissorTest:Rt,activeTexture:Bt,bindTexture:N,unbindTexture:wn,compressedTexImage2D:ot,compressedTexImage3D:A,texImage2D:$,texImage3D:j,pixelStorei:Ie,getParameter:le,updateUBOMapping:Le,uniformBlockBinding:Ue,texStorage2D:se,texStorage3D:oe,texSubImage2D:b,texSubImage3D:U,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:ue,viewport:ce,reset:Ge}}function rS(s,e,t,n,i,a,r){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 Re,h=new WeakMap,d=new Set;let u;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(A,b){return g?new OffscreenCanvas(A,b):$r("canvas")}function p(A,b,U){let H=1;const K=ot(A);if((K.width>U||K.height>U)&&(H=U/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const se=Math.floor(H*K.width),oe=Math.floor(H*K.height);u===void 0&&(u=v(se,oe));const $=b?v(se,oe):u;return $.width=se,$.height=oe,$.getContext("2d").drawImage(A,0,0,se,oe),Ee("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),$}else return"data"in A&&Ee("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),A;return A}function m(A){return A.generateMipmaps}function S(A){s.generateMipmap(A)}function _(A){return A.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?s.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function x(A,b,U,H,K,se=!1){if(A!==null){if(s[A]!==void 0)return s[A];Ee("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let oe;H&&(oe=e.get("EXT_texture_norm16"),oe||Ee("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=b;if(b===s.RED&&(U===s.FLOAT&&($=s.R32F),U===s.HALF_FLOAT&&($=s.R16F),U===s.UNSIGNED_BYTE&&($=s.R8),U===s.UNSIGNED_SHORT&&oe&&($=oe.R16_EXT),U===s.SHORT&&oe&&($=oe.R16_SNORM_EXT)),b===s.RED_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.R8UI),U===s.UNSIGNED_SHORT&&($=s.R16UI),U===s.UNSIGNED_INT&&($=s.R32UI),U===s.BYTE&&($=s.R8I),U===s.SHORT&&($=s.R16I),U===s.INT&&($=s.R32I)),b===s.RG&&(U===s.FLOAT&&($=s.RG32F),U===s.HALF_FLOAT&&($=s.RG16F),U===s.UNSIGNED_BYTE&&($=s.RG8),U===s.UNSIGNED_SHORT&&oe&&($=oe.RG16_EXT),U===s.SHORT&&oe&&($=oe.RG16_SNORM_EXT)),b===s.RG_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RG8UI),U===s.UNSIGNED_SHORT&&($=s.RG16UI),U===s.UNSIGNED_INT&&($=s.RG32UI),U===s.BYTE&&($=s.RG8I),U===s.SHORT&&($=s.RG16I),U===s.INT&&($=s.RG32I)),b===s.RGB_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RGB8UI),U===s.UNSIGNED_SHORT&&($=s.RGB16UI),U===s.UNSIGNED_INT&&($=s.RGB32UI),U===s.BYTE&&($=s.RGB8I),U===s.SHORT&&($=s.RGB16I),U===s.INT&&($=s.RGB32I)),b===s.RGBA_INTEGER&&(U===s.UNSIGNED_BYTE&&($=s.RGBA8UI),U===s.UNSIGNED_SHORT&&($=s.RGBA16UI),U===s.UNSIGNED_INT&&($=s.RGBA32UI),U===s.BYTE&&($=s.RGBA8I),U===s.SHORT&&($=s.RGBA16I),U===s.INT&&($=s.RGBA32I)),b===s.RGB&&(U===s.UNSIGNED_SHORT&&oe&&($=oe.RGB16_EXT),U===s.SHORT&&oe&&($=oe.RGB16_SNORM_EXT),U===s.UNSIGNED_INT_5_9_9_9_REV&&($=s.RGB9_E5),U===s.UNSIGNED_INT_10F_11F_11F_REV&&($=s.R11F_G11F_B10F)),b===s.RGBA){const j=se?Pl:Qe.getTransfer(K);U===s.FLOAT&&($=s.RGBA32F),U===s.HALF_FLOAT&&($=s.RGBA16F),U===s.UNSIGNED_BYTE&&($=j===lt?s.SRGB8_ALPHA8:s.RGBA8),U===s.UNSIGNED_SHORT&&oe&&($=oe.RGBA16_EXT),U===s.SHORT&&oe&&($=oe.RGBA16_SNORM_EXT),U===s.UNSIGNED_SHORT_4_4_4_4&&($=s.RGBA4),U===s.UNSIGNED_SHORT_5_5_5_1&&($=s.RGB5_A1)}return($===s.R16F||$===s.R32F||$===s.RG16F||$===s.RG32F||$===s.RGBA16F||$===s.RGBA32F)&&e.get("EXT_color_buffer_float"),$}function M(A,b){let U;return A?b===null||b===ii||b===Yr?U=s.DEPTH24_STENCIL8:b===Vn?U=s.DEPTH32F_STENCIL8:b===qr&&(U=s.DEPTH24_STENCIL8,Ee("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===ii||b===Yr?U=s.DEPTH_COMPONENT24:b===Vn?U=s.DEPTH_COMPONENT32F:b===qr&&(U=s.DEPTH_COMPONENT16),U}function E(A,b){return m(A)===!0||A.isFramebufferTexture&&A.minFilter!==Wt&&A.minFilter!==At?Math.log2(Math.max(b.width,b.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?b.mipmaps.length:1}function I(A){const b=A.target;b.removeEventListener("dispose",I),T(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function y(A){const b=A.target;b.removeEventListener("dispose",y),D(b)}function T(A){const b=n.get(A);if(b.__webglInit===void 0)return;const U=A.source,H=f.get(U);if(H){const K=H[b.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(A),Object.keys(H).length===0&&f.delete(U)}n.remove(A)}function C(A){const b=n.get(A);s.deleteTexture(b.__webglTexture);const U=A.source,H=f.get(U);delete H[b.__cacheKey],r.memory.textures--}function D(A){const b=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(b.__webglFramebuffer[H]))for(let K=0;K<b.__webglFramebuffer[H].length;K++)s.deleteFramebuffer(b.__webglFramebuffer[H][K]);else s.deleteFramebuffer(b.__webglFramebuffer[H]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[H])}else{if(Array.isArray(b.__webglFramebuffer))for(let H=0;H<b.__webglFramebuffer.length;H++)s.deleteFramebuffer(b.__webglFramebuffer[H]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let H=0;H<b.__webglColorRenderbuffer.length;H++)b.__webglColorRenderbuffer[H]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[H]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const U=A.textures;for(let H=0,K=U.length;H<K;H++){const se=n.get(U[H]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),r.memory.textures--),n.remove(U[H])}n.remove(A)}let P=0;function V(){P=0}function q(){return P}function O(A){P=A}function W(){const A=P;return A>=i.maxTextures&&Ee("WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+i.maxTextures),P+=1,A}function G(A){const b=[];return b.push(A.wrapS),b.push(A.wrapT),b.push(A.wrapR||0),b.push(A.magFilter),b.push(A.minFilter),b.push(A.anisotropy),b.push(A.internalFormat),b.push(A.format),b.push(A.type),b.push(A.generateMipmaps),b.push(A.premultiplyAlpha),b.push(A.flipY),b.push(A.unpackAlignment),b.push(A.colorSpace),b.join()}function Z(A,b){const U=n.get(A);if(A.isVideoTexture&&N(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&U.__version!==A.version){const H=A.image;if(H===null)Ee("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ee("WebGLRenderer: Texture marked for update but image is incomplete");else{F(U,A,b);return}}else A.isExternalTexture&&(U.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,U.__webglTexture,s.TEXTURE0+b)}function te(A,b){const U=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){F(U,A,b);return}else A.isExternalTexture&&(U.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,U.__webglTexture,s.TEXTURE0+b)}function Q(A,b){const U=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&U.__version!==A.version){F(U,A,b);return}t.bindTexture(s.TEXTURE_3D,U.__webglTexture,s.TEXTURE0+b)}function ie(A,b){const U=n.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&U.__version!==A.version){_e(U,A,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,U.__webglTexture,s.TEXTURE0+b)}const de={[Tl]:s.REPEAT,[vn]:s.CLAMP_TO_EDGE,[Bh]:s.MIRRORED_REPEAT},He={[Wt]:s.NEAREST,[Cv]:s.NEAREST_MIPMAP_NEAREST,[fo]:s.NEAREST_MIPMAP_LINEAR,[At]:s.LINEAR,[cc]:s.LINEAR_MIPMAP_NEAREST,[Bs]:s.LINEAR_MIPMAP_LINEAR},Je={[Nv]:s.NEVER,[Bv]:s.ALWAYS,[Ov]:s.LESS,[ou]:s.LEQUAL,[kv]:s.EQUAL,[lu]:s.GEQUAL,[Uv]:s.GREATER,[Fv]:s.NOTEQUAL};function ze(A,b){if(b.type===Vn&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===At||b.magFilter===cc||b.magFilter===fo||b.magFilter===Bs||b.minFilter===At||b.minFilter===cc||b.minFilter===fo||b.minFilter===Bs)&&Ee("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(A,s.TEXTURE_WRAP_S,de[b.wrapS]),s.texParameteri(A,s.TEXTURE_WRAP_T,de[b.wrapT]),(A===s.TEXTURE_3D||A===s.TEXTURE_2D_ARRAY)&&s.texParameteri(A,s.TEXTURE_WRAP_R,de[b.wrapR]),s.texParameteri(A,s.TEXTURE_MAG_FILTER,He[b.magFilter]),s.texParameteri(A,s.TEXTURE_MIN_FILTER,He[b.minFilter]),b.compareFunction&&(s.texParameteri(A,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(A,s.TEXTURE_COMPARE_FUNC,Je[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Wt||b.minFilter!==fo&&b.minFilter!==Bs||b.type===Vn&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const U=e.get("EXT_texture_filter_anisotropic");s.texParameterf(A,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,i.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function Y(A,b){let U=!1;A.__webglInit===void 0&&(A.__webglInit=!0,b.addEventListener("dispose",I));const H=b.source;let K=f.get(H);K===void 0&&(K={},f.set(H,K));const se=G(b);if(se!==A.__cacheKey){K[se]===void 0&&(K[se]={texture:s.createTexture(),usedTimes:0},r.memory.textures++,U=!0),K[se].usedTimes++;const oe=K[A.__cacheKey];oe!==void 0&&(K[A.__cacheKey].usedTimes--,oe.usedTimes===0&&C(b)),A.__cacheKey=se,A.__webglTexture=K[se].texture}return U}function ae(A,b,U){return Math.floor(Math.floor(A/U)/b)}function ne(A,b,U,H){const se=A.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,U,H,b.data);else{se.sort((Ie,ue)=>Ie.start-ue.start);let oe=0;for(let Ie=1;Ie<se.length;Ie++){const ue=se[oe],ce=se[Ie],Le=ue.start+ue.count,Ue=ae(ce.start,b.width,4),Ge=ae(ue.start,b.width,4);ce.start<=Le+1&&Ue===Ge&&ae(ce.start+ce.count-1,b.width,4)===Ue?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++oe,se[oe]=ce)}se.length=oe+1;const $=t.getParameter(s.UNPACK_ROW_LENGTH),j=t.getParameter(s.UNPACK_SKIP_PIXELS),le=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let Ie=0,ue=se.length;Ie<ue;Ie++){const ce=se[Ie],Le=Math.floor(ce.start/4),Ue=Math.ceil(ce.count/4),Ge=Le%b.width,L=Math.floor(Le/b.width),re=Ue,J=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Ge),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Ge,L,re,J,U,H,b.data)}A.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,$),t.pixelStorei(s.UNPACK_SKIP_PIXELS,j),t.pixelStorei(s.UNPACK_SKIP_ROWS,le)}}function F(A,b,U){let H=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(H=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(H=s.TEXTURE_3D);const K=Y(A,b),se=b.source;t.bindTexture(H,A.__webglTexture,s.TEXTURE0+U);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(s.TEXTURE0+U),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){const J=Qe.getPrimaries(Qe.workingColorSpace),he=b.colorSpace===us?null:Qe.getPrimaries(b.colorSpace),ge=b.colorSpace===us||J===he?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment);let j=p(b.image,!1,i.maxTextureSize);j=wn(b,j);const le=a.convert(b.format,b.colorSpace),Ie=a.convert(b.type);let ue=x(b.internalFormat,le,Ie,b.normalized,b.colorSpace,b.isVideoTexture);ze(H,b);let ce;const Le=b.mipmaps,Ue=b.isVideoTexture!==!0,Ge=oe.__version===void 0||K===!0,L=se.dataReady,re=E(b,j);if(b.isDepthTexture)ue=M(b.format===zs,b.type),Ge&&(Ue?t.texStorage2D(s.TEXTURE_2D,1,ue,j.width,j.height):t.texImage2D(s.TEXTURE_2D,0,ue,j.width,j.height,0,le,Ie,null));else if(b.isDataTexture)if(Le.length>0){Ue&&Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)ce=Le[J],Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Ie,ce.data):t.texImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,le,Ie,ce.data);b.generateMipmaps=!1}else Ue?(Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,j.width,j.height),L&&ne(b,j,le,Ie)):t.texImage2D(s.TEXTURE_2D,0,ue,j.width,j.height,0,le,Ie,j.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Ue&&Ge&&t.texStorage3D(s.TEXTURE_2D_ARRAY,re,ue,Le[0].width,Le[0].height,j.depth);for(let J=0,he=Le.length;J<he;J++)if(ce=Le[J],b.format!==yn)if(le!==null)if(Ue){if(L)if(b.layerUpdates.size>0){const ge=hp(ce.width,ce.height,b.format,b.type);for(const ee of b.layerUpdates){const Te=ce.data.subarray(ee*ge/ce.data.BYTES_PER_ELEMENT,(ee+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,ee,ce.width,ce.height,1,le,Te)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,j.depth,le,ce.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,J,ue,ce.width,ce.height,j.depth,0,ce.data,0,0);else Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ue?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,j.depth,le,Ie,ce.data):t.texImage3D(s.TEXTURE_2D_ARRAY,J,ue,ce.width,ce.height,j.depth,0,le,Ie,ce.data)}else{Ue&&Ge&&t.texStorage2D(s.TEXTURE_2D,re,ue,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)ce=Le[J],b.format!==yn?le!==null?Ue?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,ce.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Ie,ce.data):t.texImage2D(s.TEXTURE_2D,J,ue,ce.width,ce.height,0,le,Ie,ce.data)}else if(b.isDataArrayTexture)if(Ue){if(Ge&&t.texStorage3D(s.TEXTURE_2D_ARRAY,re,ue,j.width,j.height,j.depth),L)if(b.layerUpdates.size>0){const J=hp(j.width,j.height,b.format,b.type);for(const he of b.layerUpdates){const ge=j.data.subarray(he*J/j.data.BYTES_PER_ELEMENT,(he+1)*J/j.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,he,j.width,j.height,1,le,Ie,ge)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,le,Ie,j.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ue,j.width,j.height,j.depth,0,le,Ie,j.data);else if(b.isData3DTexture)Ue?(Ge&&t.texStorage3D(s.TEXTURE_3D,re,ue,j.width,j.height,j.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,le,Ie,j.data)):t.texImage3D(s.TEXTURE_3D,0,ue,j.width,j.height,j.depth,0,le,Ie,j.data);else if(b.isFramebufferTexture){if(Ge)if(Ue)t.texStorage2D(s.TEXTURE_2D,re,ue,j.width,j.height);else{let J=j.width,he=j.height;for(let ge=0;ge<re;ge++)t.texImage2D(s.TEXTURE_2D,ge,ue,J,he,0,le,Ie,null),J>>=1,he>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in s){const J=s.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),j.parentNode!==J){J.appendChild(j),d.add(b),J.onpaint=he=>{const ge=he.changedElements;for(const ee of d)ge.includes(ee.image)&&(ee.needsUpdate=!0)},J.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,j);else{const ge=s.RGBA,ee=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ge,ee,Te,j)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Ue&&Ge){const J=ot(Le[0]);t.texStorage2D(s.TEXTURE_2D,re,ue,J.width,J.height)}for(let J=0,he=Le.length;J<he;J++)ce=Le[J],Ue?L&&t.texSubImage2D(s.TEXTURE_2D,J,0,0,le,Ie,ce):t.texImage2D(s.TEXTURE_2D,J,ue,le,Ie,ce);b.generateMipmaps=!1}else if(Ue){if(Ge){const J=ot(j);t.texStorage2D(s.TEXTURE_2D,re,ue,J.width,J.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,le,Ie,j)}else t.texImage2D(s.TEXTURE_2D,0,ue,le,Ie,j);m(b)&&S(H),oe.__version=se.version,b.onUpdate&&b.onUpdate(b)}A.__version=b.version}function _e(A,b,U){if(b.image.length!==6)return;const H=Y(A,b),K=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,A.__webglTexture,s.TEXTURE0+U);const se=n.get(K);if(K.version!==se.__version||H===!0){t.activeTexture(s.TEXTURE0+U);const oe=Qe.getPrimaries(Qe.workingColorSpace),$=b.colorSpace===us?null:Qe.getPrimaries(b.colorSpace),j=b.colorSpace===us||oe===$?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,j);const le=b.isCompressedTexture||b.image[0].isCompressedTexture,Ie=b.image[0]&&b.image[0].isDataTexture,ue=[];for(let ee=0;ee<6;ee++)!le&&!Ie?ue[ee]=p(b.image[ee],!0,i.maxCubemapSize):ue[ee]=Ie?b.image[ee].image:b.image[ee],ue[ee]=wn(b,ue[ee]);const ce=ue[0],Le=a.convert(b.format,b.colorSpace),Ue=a.convert(b.type),Ge=x(b.internalFormat,Le,Ue,b.normalized,b.colorSpace),L=b.isVideoTexture!==!0,re=se.__version===void 0||H===!0,J=K.dataReady;let he=E(b,ce);ze(s.TEXTURE_CUBE_MAP,b);let ge;if(le){L&&re&&t.texStorage2D(s.TEXTURE_CUBE_MAP,he,Ge,ce.width,ce.height);for(let ee=0;ee<6;ee++){ge=ue[ee].mipmaps;for(let Te=0;Te<ge.length;Te++){const we=ge[Te];b.format!==yn?Le!==null?L?J&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,0,0,we.width,we.height,Le,we.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,Ge,we.width,we.height,0,we.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,0,0,we.width,we.height,Le,Ue,we.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te,Ge,we.width,we.height,0,Le,Ue,we.data)}}}else{if(ge=b.mipmaps,L&&re){ge.length>0&&he++;const ee=ot(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,he,Ge,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Ie){L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ue[ee].width,ue[ee].height,Le,Ue,ue[ee].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,ue[ee].width,ue[ee].height,0,Le,Ue,ue[ee].data);for(let Te=0;Te<ge.length;Te++){const Pt=ge[Te].image[ee].image;L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,0,0,Pt.width,Pt.height,Le,Ue,Pt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,Ge,Pt.width,Pt.height,0,Le,Ue,Pt.data)}}else{L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Le,Ue,ue[ee]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,Le,Ue,ue[ee]);for(let Te=0;Te<ge.length;Te++){const we=ge[Te];L?J&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,0,0,Le,Ue,we.image[ee]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Te+1,Ge,Le,Ue,we.image[ee])}}}m(b)&&S(s.TEXTURE_CUBE_MAP),se.__version=K.version,b.onUpdate&&b.onUpdate(b)}A.__version=b.version}function Pe(A,b,U,H,K,se){const oe=a.convert(U.format,U.colorSpace),$=a.convert(U.type),j=x(U.internalFormat,oe,$,U.normalized,U.colorSpace),le=n.get(b),Ie=n.get(U);if(Ie.__renderTarget=b,!le.__hasExternalTextures){const ue=Math.max(1,b.width>>se),ce=Math.max(1,b.height>>se);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,se,j,ue,ce,b.depth,0,oe,$,null):t.texImage2D(K,se,j,ue,ce,0,oe,$,null)}t.bindFramebuffer(s.FRAMEBUFFER,A),Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,H,K,Ie.__webglTexture,0,Rt(b)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,H,K,Ie.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ae(A,b,U){if(s.bindRenderbuffer(s.RENDERBUFFER,A),b.depthBuffer){const H=b.depthTexture,K=H&&H.isDepthTexture?H.type:null,se=M(b.stencilBuffer,K),oe=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Bt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Rt(b),se,b.width,b.height):U?s.renderbufferStorageMultisample(s.RENDERBUFFER,Rt(b),se,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,se,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,oe,s.RENDERBUFFER,A)}else{const H=b.textures;for(let K=0;K<H.length;K++){const se=H[K],oe=a.convert(se.format,se.colorSpace),$=a.convert(se.type),j=x(se.internalFormat,oe,$,se.normalized,se.colorSpace);Bt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Rt(b),j,b.width,b.height):U?s.renderbufferStorageMultisample(s.RENDERBUFFER,Rt(b),j,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,j,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function be(A,b,U){const H=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,A),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(b.depthTexture);if(K.__renderTarget=b,(!K.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),H){if(K.__webglInit===void 0&&(K.__webglInit=!0,b.depthTexture.addEventListener("dispose",I)),K.__webglTexture===void 0){K.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),ze(s.TEXTURE_CUBE_MAP,b.depthTexture);const le=a.convert(b.depthTexture.format),Ie=a.convert(b.depthTexture.type);let ue;b.depthTexture.format===Wi?ue=s.DEPTH_COMPONENT24:b.depthTexture.format===zs&&(ue=s.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,b.width,b.height,0,le,Ie,null)}}else Z(b.depthTexture,0);const se=K.__webglTexture,oe=Rt(b),$=H?s.TEXTURE_CUBE_MAP_POSITIVE_X+U:s.TEXTURE_2D,j=b.depthTexture.format===zs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(b.depthTexture.format===Wi)Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,j,$,se,0,oe):s.framebufferTexture2D(s.FRAMEBUFFER,j,$,se,0);else if(b.depthTexture.format===zs)Bt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,j,$,se,0,oe):s.framebufferTexture2D(s.FRAMEBUFFER,j,$,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(A){const b=n.get(A),U=A.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==A.depthTexture){const H=A.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),H){const K=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),b.__depthDisposeCallback=K}b.__boundDepthTexture=H}if(A.depthTexture&&!b.__autoAllocateDepthBuffer)if(U)for(let H=0;H<6;H++)be(b.__webglFramebuffer[H],A,H);else{const H=A.texture.mipmaps;H&&H.length>0?be(b.__webglFramebuffer[0],A,0):be(b.__webglFramebuffer,A,0)}else if(U){b.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[H]),b.__webglDepthbuffer[H]===void 0)b.__webglDepthbuffer[H]=s.createRenderbuffer(),Ae(b.__webglDepthbuffer[H],A,!1);else{const K=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer[H];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,se)}}else{const H=A.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),Ae(b.__webglDepthbuffer,A,!1);else{const K=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(A,b,U){const H=n.get(A);b!==void 0&&Pe(H.__webglFramebuffer,A,A.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),U!==void 0&&Ne(A)}function ke(A){const b=A.texture,U=n.get(A),H=n.get(b);A.addEventListener("dispose",y);const K=A.textures,se=A.isWebGLCubeRenderTarget===!0,oe=K.length>1;if(oe||(H.__webglTexture===void 0&&(H.__webglTexture=s.createTexture()),H.__version=b.version,r.memory.textures++),se){U.__webglFramebuffer=[];for(let $=0;$<6;$++)if(b.mipmaps&&b.mipmaps.length>0){U.__webglFramebuffer[$]=[];for(let j=0;j<b.mipmaps.length;j++)U.__webglFramebuffer[$][j]=s.createFramebuffer()}else U.__webglFramebuffer[$]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){U.__webglFramebuffer=[];for(let $=0;$<b.mipmaps.length;$++)U.__webglFramebuffer[$]=s.createFramebuffer()}else U.__webglFramebuffer=s.createFramebuffer();if(oe)for(let $=0,j=K.length;$<j;$++){const le=n.get(K[$]);le.__webglTexture===void 0&&(le.__webglTexture=s.createTexture(),r.memory.textures++)}if(A.samples>0&&Bt(A)===!1){U.__webglMultisampledFramebuffer=s.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const j=K[$];U.__webglColorRenderbuffer[$]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,U.__webglColorRenderbuffer[$]);const le=a.convert(j.format,j.colorSpace),Ie=a.convert(j.type),ue=x(j.internalFormat,le,Ie,j.normalized,j.colorSpace,A.isXRRenderTarget===!0),ce=Rt(A);s.renderbufferStorageMultisample(s.RENDERBUFFER,ce,ue,A.width,A.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+$,s.RENDERBUFFER,U.__webglColorRenderbuffer[$])}s.bindRenderbuffer(s.RENDERBUFFER,null),A.depthBuffer&&(U.__webglDepthRenderbuffer=s.createRenderbuffer(),Ae(U.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,H.__webglTexture),ze(s.TEXTURE_CUBE_MAP,b);for(let $=0;$<6;$++)if(b.mipmaps&&b.mipmaps.length>0)for(let j=0;j<b.mipmaps.length;j++)Pe(U.__webglFramebuffer[$][j],A,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,j);else Pe(U.__webglFramebuffer[$],A,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);m(b)&&S(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let $=0,j=K.length;$<j;$++){const le=K[$],Ie=n.get(le);let ue=s.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ue=A.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,Ie.__webglTexture),ze(ue,le),Pe(U.__webglFramebuffer,A,le,s.COLOR_ATTACHMENT0+$,ue,0),m(le)&&S(ue)}t.unbindTexture()}else{let $=s.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&($=A.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture($,H.__webglTexture),ze($,b),b.mipmaps&&b.mipmaps.length>0)for(let j=0;j<b.mipmaps.length;j++)Pe(U.__webglFramebuffer[j],A,b,s.COLOR_ATTACHMENT0,$,j);else Pe(U.__webglFramebuffer,A,b,s.COLOR_ATTACHMENT0,$,0);m(b)&&S($),t.unbindTexture()}A.depthBuffer&&Ne(A)}function at(A){const b=A.textures;for(let U=0,H=b.length;U<H;U++){const K=b[U];if(m(K)){const se=_(A),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),S(se),t.unbindTexture()}}}const rt=[],Ct=[];function wt(A){if(A.samples>0){if(Bt(A)===!1){const b=A.textures,U=A.width,H=A.height;let K=s.COLOR_BUFFER_BIT;const se=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,oe=n.get(A),$=b.length>1;if($)for(let le=0;le<b.length;le++)t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const j=A.texture.mipmaps;j&&j.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let le=0;le<b.length;le++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),$){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Ie=n.get(b[le]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Ie,0)}s.blitFramebuffer(0,0,U,H,0,0,U,H,K,s.NEAREST),l===!0&&(rt.length=0,Ct.length=0,rt.push(s.COLOR_ATTACHMENT0+le),A.depthBuffer&&A.resolveDepthBuffer===!1&&(rt.push(se),Ct.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ct)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,rt))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),$)for(let le=0;le<b.length;le++){t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Ie=n.get(b[le]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,oe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,Ie,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const b=A.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function Rt(A){return Math.min(i.maxSamples,A.samples)}function Bt(A){const b=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function N(A){const b=r.render.frame;h.get(A)!==b&&(h.set(A,b),A.update())}function wn(A,b){const U=A.colorSpace,H=A.format,K=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||U!==Rl&&U!==us&&(Qe.getTransfer(U)===lt?(H!==yn||K!==kn)&&Ee("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Fe("WebGLTextures: Unsupported texture color space:",U)),b}function ot(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=V,this.getTextureUnits=q,this.setTextureUnits=O,this.setTexture2D=Z,this.setTexture2DArray=te,this.setTexture3D=Q,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=wt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Bt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function oS(s,e){function t(n,i=us){let a;const r=Qe.getTransfer(i);if(n===kn)return s.UNSIGNED_BYTE;if(n===tu)return s.UNSIGNED_SHORT_4_4_4_4;if(n===nu)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Rm)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Pm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Dm)return s.BYTE;if(n===Cm)return s.SHORT;if(n===qr)return s.UNSIGNED_SHORT;if(n===eu)return s.INT;if(n===ii)return s.UNSIGNED_INT;if(n===Vn)return s.FLOAT;if(n===hn)return s.HALF_FLOAT;if(n===Lm)return s.ALPHA;if(n===Nm)return s.RGB;if(n===yn)return s.RGBA;if(n===Wi)return s.DEPTH_COMPONENT;if(n===zs)return s.DEPTH_STENCIL;if(n===iu)return s.RED;if(n===su)return s.RED_INTEGER;if(n===Ys)return s.RG;if(n===au)return s.RG_INTEGER;if(n===ru)return s.RGBA_INTEGER;if(n===dl||n===ul||n===fl||n===pl)if(r===lt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(n===dl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ul)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===fl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===pl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(n===dl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ul)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===fl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===pl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===zh||n===Hh||n===Gh||n===Vh)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(n===zh)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Hh)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Gh)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Vh)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Wh||n===Xh||n===qh||n===Yh||n===Kh||n===Al||n===$h)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(n===Wh||n===Xh)return r===lt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===qh)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(n===Yh)return a.COMPRESSED_R11_EAC;if(n===Kh)return a.COMPRESSED_SIGNED_R11_EAC;if(n===Al)return a.COMPRESSED_RG11_EAC;if(n===$h)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Zh||n===Jh||n===jh||n===Qh||n===ed||n===td||n===nd||n===id||n===sd||n===ad||n===rd||n===od||n===ld||n===cd)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(n===Zh)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Jh)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===jh)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Qh)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ed)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===td)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===nd)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===id)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===sd)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ad)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===rd)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===od)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ld)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===cd)return r===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===hd||n===dd||n===ud)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(n===hd)return r===lt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===dd)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ud)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===fd||n===pd||n===Il||n===md)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(n===fd)return a.COMPRESSED_RED_RGTC1_EXT;if(n===pd)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Il)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===md)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Yr?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const lS=`
5947
5957
  void main() {
5948
5958
 
5949
5959
  gl_Position = vec4( position, 1.0 );
@@ -5967,14 +5977,14 @@ void main() {
5967
5977
 
5968
5978
  }
5969
5979
 
5970
- }`;class hS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Nt({vertexShader:lS,fragmentShader:cS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ze(new Zi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dS extends Zs{constructor(e,t){super();const n=this;let i=null,a=1,r=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null;const v=typeof XRWebGLBinding<"u",p=new hS,m={},S=t.getContextAttributes();let _=null,x=null;const M=[],E=[],I=new Re;let y=null;const T=new _n;T.viewport=new pt;const C=new _n;C.viewport=new pt;const D=[T,C],P=new ub;let V=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getGripSpace()},this.getHand=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getHandSpace()};function O(Y){const ae=E.indexOf(Y.inputSource);if(ae===-1)return;const ne=M[ae];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,c||r),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<M.length;Y++){const ae=E[Y];ae!==null&&(E[Y]=null,M[Y].disconnect(ae))}V=null,q=null,p.reset();for(const Y in m)delete m[Y];e.setRenderTarget(_),f=null,u=null,d=null,i=null,x=null,ze.stop(),n.isPresenting=!1,e.setPixelRatio(y),e.setSize(I.width,I.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){a=Y,n.isPresenting===!0&&Ee("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ee("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||r},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(i,t)),d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(_=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",W),i.addEventListener("inputsourceschange",G),S.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(I),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,F=null,_e=null;S.depth&&(_e=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=S.stencil?zs:Wi,F=S.stencil?Yr:ni);const Pe={colorFormat:t.RGBA8,depthFormat:_e,scaleFactor:a};d=this.getBinding(),u=d.createProjectionLayer(Pe),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),x=new En(u.textureWidth,u.textureHeight,{format:yn,type:kn,depthTexture:new Ks(u.textureWidth,u.textureHeight,F,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(i,t,ne),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new En(f.framebufferWidth,f.framebufferHeight,{format:yn,type:kn,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,r=await i.requestReferenceSpace(o),ze.setContext(i),ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function G(Y){for(let ae=0;ae<Y.removed.length;ae++){const ne=Y.removed[ae],F=E.indexOf(ne);F>=0&&(E[F]=null,M[F].disconnect(ne))}for(let ae=0;ae<Y.added.length;ae++){const ne=Y.added[ae];let F=E.indexOf(ne);if(F===-1){for(let Pe=0;Pe<M.length;Pe++)if(Pe>=E.length){E.push(ne),F=Pe;break}else if(E[Pe]===null){E[Pe]=ne,F=Pe;break}if(F===-1)break}const _e=M[F];_e&&_e.connect(ne)}}const Z=new R,te=new R;function Q(Y,ae,ne){Z.setFromMatrixPosition(ae.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const F=Z.distanceTo(te),_e=ae.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Ae=_e[14]/(_e[10]-1),be=_e[14]/(_e[10]+1),Ne=(_e[9]+1)/_e[5],Oe=(_e[9]-1)/_e[5],ke=(_e[8]-1)/_e[0],st=(Pe[8]+1)/Pe[0],at=Ae*ke,Ct=Ae*st,Mt=F/(-ke+st),Rt=Mt*-ke;if(ae.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Rt),Y.translateZ(Mt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),_e[10]===-1)Y.projectionMatrix.copy(ae.projectionMatrix),Y.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{const Bt=Ae+Mt,N=be+Mt,wn=at-Rt,rt=Ct+(F-Rt),A=Ne*be/N*Bt,b=Oe*be/N*Bt;Y.projectionMatrix.makePerspective(wn,rt,A,b,Bt,N),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ie(Y,ae){ae===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(ae.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let ae=Y.near,ne=Y.far;p.texture!==null&&(p.depthNear>0&&(ae=p.depthNear),p.depthFar>0&&(ne=p.depthFar)),P.near=C.near=T.near=ae,P.far=C.far=T.far=ne,(V!==P.near||q!==P.far)&&(i.updateRenderState({depthNear:P.near,depthFar:P.far}),V=P.near,q=P.far),P.layers.mask=Y.layers.mask|6,T.layers.mask=P.layers.mask&-5,C.layers.mask=P.layers.mask&-3;const F=Y.parent,_e=P.cameras;ie(P,F);for(let Pe=0;Pe<_e.length;Pe++)ie(_e[Pe],F);_e.length===2?Q(P,T,C):P.projectionMatrix.copy(T.projectionMatrix),de(Y,P,F)};function de(Y,ae,ne){ne===null?Y.matrix.copy(ae.matrixWorld):(Y.matrix.copy(ne.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(ae.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(ae.projectionMatrix),Y.projectionMatrixInverse.copy(ae.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ja*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(Y){l=Y,u!==null&&(u.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(P)},this.getCameraTexture=function(Y){return m[Y]};let He=null;function Je(Y,ae){if(h=ae.getViewerPose(c||r),g=ae,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let F=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,F=!0);for(let be=0;be<ne.length;be++){const Ne=ne[be];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const st=d.getViewSubImage(u,Ne);Oe=st.viewport,be===0&&(e.setRenderTargetTextures(x,st.colorTexture,st.depthStencilTexture),e.setRenderTarget(x))}let ke=D[be];ke===void 0&&(ke=new _n,ke.layers.enable(be),ke.viewport=new pt,D[be]=ke),ke.matrix.fromArray(Ne.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray(Ne.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),be===0&&(P.matrix.copy(ke.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),F===!0&&P.cameras.push(ke)}const _e=i.enabledFeatures;if(_e&&_e.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){d=n.getBinding();const be=d.getDepthInformation(ne[0]);be&&be.isValid&&be.texture&&p.init(be,i.renderState)}if(_e&&_e.includes("camera-access")&&v){e.state.unbindTexture(),d=n.getBinding();for(let be=0;be<ne.length;be++){const Ne=ne[be].camera;if(Ne){let Oe=m[Ne];Oe||(Oe=new Wm,m[Ne]=Oe);const ke=d.getCameraImage(Ne);Oe.sourceTexture=ke}}}}for(let ne=0;ne<M.length;ne++){const F=E[ne],_e=M[ne];F!==null&&_e!==void 0&&_e.update(F,ae,c||r)}He&&He(Y,ae),ae.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ae}),g=null}const ze=new Zm;ze.setAnimationLoop(Je),this.setAnimationLoop=function(Y){He=Y},this.dispose=function(){}}}const uS=new qe,ig=new Be;ig.set(-1,0,0,0,1,0,0,0,1);function fS(s,e){function t(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Xm(s)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function i(p,m,S,_,x){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?a(p,m):m.isMeshLambertMaterial?(a(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(a(p,m),d(p,m)):m.isMeshPhongMaterial?(a(p,m),h(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(a(p,m),u(p,m),m.isMeshPhysicalMaterial&&f(p,m,x)):m.isMeshMatcapMaterial?(a(p,m),g(p,m)):m.isMeshDepthMaterial?a(p,m):m.isMeshDistanceMaterial?(a(p,m),v(p,m)):m.isMeshNormalMaterial?a(p,m):m.isLineBasicMaterial?(r(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?l(p,m,S,_):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,t(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Vt&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,t(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Vt&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,t(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,t(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const S=e.get(m),_=S.envMap,x=S.envMapRotation;_&&(p.envMap.value=_,p.envMapRotation.value.setFromMatrix4(uS.makeRotationFromEuler(x)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(ig),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,p.aoMapTransform))}function r(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,S,_){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*S,p.scale.value=_*.5,m.map&&(p.map.value=m.map,t(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function d(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function u(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,S){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Vt&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function v(p,m){const S=e.get(m).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function pS(s,e,t,n){let i={},a={},r=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,M){const E=M.program;n.uniformBlockBinding(x,E)}function c(x,M){let E=i[x.id];E===void 0&&(p(x),E=h(x),i[x.id]=E,x.addEventListener("dispose",S));const I=M.program;n.updateUBOMapping(x,I);const y=e.render.frame;a[x.id]!==y&&(u(x),a[x.id]=y)}function h(x){const M=d();x.__bindingPointIndex=M;const E=s.createBuffer(),I=x.__size,y=x.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,I,y),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,M,E),E}function d(){for(let x=0;x<o;x++)if(r.indexOf(x)===-1)return r.push(x),x;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){const M=i[x.id],E=x.uniforms,I=x.__cache;s.bindBuffer(s.UNIFORM_BUFFER,M);for(let y=0,T=E.length;y<T;y++){const C=E[y];if(Array.isArray(C))for(let D=0,P=C.length;D<P;D++)f(C[D],y,D,I);else f(C,y,0,I)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(x,M,E,I){if(v(x,M,E,I)===!0){const y=x.__offset,T=x.value;if(Array.isArray(T)){let C=0;for(let D=0;D<T.length;D++){const P=T[D],V=m(P);g(P,x.__data,C),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(T,x.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,y,x.__data)}}function g(x,M,E){typeof x=="number"||typeof x=="boolean"?M[0]=x:x.isMatrix3?(M[0]=x.elements[0],M[1]=x.elements[1],M[2]=x.elements[2],M[3]=0,M[4]=x.elements[3],M[5]=x.elements[4],M[6]=x.elements[5],M[7]=0,M[8]=x.elements[6],M[9]=x.elements[7],M[10]=x.elements[8],M[11]=0):ArrayBuffer.isView(x)?M.set(new x.constructor(x.buffer,x.byteOffset,M.length)):x.toArray(M,E)}function v(x,M,E,I){const y=x.value,T=M+"_"+E;if(I[T]===void 0)return typeof y=="number"||typeof y=="boolean"?I[T]=y:ArrayBuffer.isView(y)?I[T]=y.slice():I[T]=y.clone(),!0;{const C=I[T];if(typeof y=="number"||typeof y=="boolean"){if(C!==y)return I[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(C.equals(y)===!1)return C.copy(y),!0}}return!1}function p(x){const M=x.uniforms;let E=0;const I=16;for(let T=0,C=M.length;T<C;T++){const D=Array.isArray(M[T])?M[T]:[M[T]];for(let P=0,V=D.length;P<V;P++){const q=D[P],O=Array.isArray(q.value)?q.value:[q.value];for(let W=0,G=O.length;W<G;W++){const Z=O[W],te=m(Z),Q=E%I,ie=Q%te.boundary,de=Q+ie;E+=ie,de!==0&&I-de<te.storage&&(E+=I-de),q.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=E,E+=te.storage}}}const y=E%I;return y>0&&(E+=I-y),x.__size=E,x.__cache={},this}function m(x){const M={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(M.boundary=4,M.storage=4):x.isVector2?(M.boundary=8,M.storage=8):x.isVector3||x.isColor?(M.boundary=16,M.storage=12):x.isVector4?(M.boundary=16,M.storage=16):x.isMatrix3?(M.boundary=48,M.storage=48):x.isMatrix4?(M.boundary=64,M.storage=64):x.isTexture?Ee("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(M.boundary=16,M.storage=x.byteLength):Ee("WebGLRenderer: Unsupported uniform value type.",x),M}function S(x){const M=x.target;M.removeEventListener("dispose",S);const E=r.indexOf(M.__bindingPointIndex);r.splice(E,1),s.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function _(){for(const x in i)s.deleteBuffer(i[x]);r=[],i={},a={}}return{bind:l,update:c,dispose:_}}const mS=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 li=null;function gS(){return li===null&&(li=new nr(mS,16,16,Ys,cn),li.name="DFG_LUT",li.minFilter=At,li.magFilter=At,li.wrapS=vn,li.wrapT=vn,li.generateMipmaps=!1,li.needsUpdate=!0),li}class vS{constructor(e={}){const{canvas:t=Gv(),context:n=null,depth:i=!0,stencil:a=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=kn}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=r;const v=f,p=new Set([ru,au,su]),m=new Set([kn,ni,qr,Yr,tu,nu]),S=new Uint32Array(4),_=new Int32Array(4),x=new R;let M=null,E=null;const I=[],y=[];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=_i,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,P=null,V=null,q=null,O=null;this._outputColorSpace=Nn;let W=0,G=0,Z=null,te=-1,Q=null;const ie=new pt,de=new pt;let He=null;const Je=new ve(0);let ze=0,Y=t.width,ae=t.height,ne=1,F=null,_e=null;const Pe=new pt(0,0,Y,ae),Ae=new pt(0,0,Y,ae);let be=!1;const Ne=new pu;let Oe=!1,ke=!1;const st=new qe,at=new R,Ct=new pt,Mt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Rt=!1;function Bt(){return Z===null?ne:1}let N=n;function wn(w,k){return t.getContext(w,k)}try{const w={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${jd}`),t.addEventListener("webglcontextlost",Pt,!1),t.addEventListener("webglcontextrestored",yt,!1),t.addEventListener("webglcontextcreationerror",si,!1),N===null){const k="webgl2";if(N=wn(k,w),N===null)throw wn(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(w){throw Fe("WebGLRenderer: "+w.message),w}let rt,A,b,U,H,K,se,oe,$,j,le,Ie,ue,ce,Le,Ue,Ge,L,re,J,he,ge,ee;function Te(){rt=new g2(N),rt.init(),he=new oS(N,rt),A=new l2(N,rt,e,he),b=new aS(N,rt),A.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),V=N.createFramebuffer(),q=N.createFramebuffer(),O=N.createFramebuffer(),U=new b2(N),H=new XM,K=new rS(N,rt,b,H,A,he,U),se=new m2(C),oe=new Sb(N),ge=new r2(N,oe),$=new v2(N,oe,U,ge),j=new w2(N,$,oe,ge,U),L=new x2(N,A,K),Le=new c2(H),le=new WM(C,se,rt,A,ge,Le),Ie=new fS(C,H),ue=new YM,ce=new QM(rt),Ge=new a2(C,se,b,j,g,l),Ue=new sS(C,j,A),ee=new pS(N,U,A,b),re=new o2(N,rt,U),J=new y2(N,rt,U),U.programs=le.programs,C.capabilities=A,C.extensions=rt,C.properties=H,C.renderLists=ue,C.shadowMap=Ue,C.state=b,C.info=U}Te(),v!==kn&&(T=new S2(v,t.width,t.height,o,i,a));const we=new dS(C,N);this.xr=we,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const w=rt.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=rt.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(w){w!==void 0&&(ne=w,this.setSize(Y,ae,!1))},this.getSize=function(w){return w.set(Y,ae)},this.setSize=function(w,k,X=!0){if(we.isPresenting){Ee("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=w,ae=k,t.width=Math.floor(w*ne),t.height=Math.floor(k*ne),X===!0&&(t.style.width=w+"px",t.style.height=k+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,w,k)},this.getDrawingBufferSize=function(w){return w.set(Y*ne,ae*ne).floor()},this.setDrawingBufferSize=function(w,k,X){Y=w,ae=k,ne=X,t.width=Math.floor(w*X),t.height=Math.floor(k*X),this.setViewport(0,0,w,k)},this.setEffects=function(w){if(v===kn){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(w){for(let k=0;k<w.length;k++)if(w[k].isOutputPass===!0){Ee("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(w||[])},this.getCurrentViewport=function(w){return w.copy(ie)},this.getViewport=function(w){return w.copy(Pe)},this.setViewport=function(w,k,X,B){w.isVector4?Pe.set(w.x,w.y,w.z,w.w):Pe.set(w,k,X,B),b.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(w){return w.copy(Ae)},this.setScissor=function(w,k,X,B){w.isVector4?Ae.set(w.x,w.y,w.z,w.w):Ae.set(w,k,X,B),b.scissor(de.copy(Ae).multiplyScalar(ne).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(w){b.setScissorTest(be=w)},this.setOpaqueSort=function(w){F=w},this.setTransparentSort=function(w){_e=w},this.getClearColor=function(w){return w.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor(...arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha(...arguments)},this.clear=function(w=!0,k=!0,X=!0){let B=0;if(w){let z=!1;if(Z!==null){const me=Z.texture.format;z=p.has(me)}if(z){const me=Z.texture.type,xe=m.has(me),pe=Ge.getClearColor(),Se=Ge.getClearAlpha(),De=pe.r,Ve=pe.g,Ye=pe.b;xe?(S[0]=De,S[1]=Ve,S[2]=Ye,S[3]=Se,N.clearBufferuiv(N.COLOR,0,S)):(_[0]=De,_[1]=Ve,_[2]=Ye,_[3]=Se,N.clearBufferiv(N.COLOR,0,_))}else B|=N.COLOR_BUFFER_BIT}k&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),X&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.clear(B)},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(w){w.setRenderer(this),P=w},this.dispose=function(){t.removeEventListener("webglcontextlost",Pt,!1),t.removeEventListener("webglcontextrestored",yt,!1),t.removeEventListener("webglcontextcreationerror",si,!1),Ge.dispose(),ue.dispose(),ce.dispose(),H.dispose(),se.dispose(),j.dispose(),ge.dispose(),ee.dispose(),le.dispose(),we.dispose(),we.removeEventListener("sessionstart",Ru),we.removeEventListener("sessionend",Pu),xs.stop()};function Pt(w){w.preventDefault(),Ll("WebGLRenderer: Context Lost."),D=!0}function yt(){Ll("WebGLRenderer: Context Restored."),D=!1;const w=U.autoReset,k=Ue.enabled,X=Ue.autoUpdate,B=Ue.needsUpdate,z=Ue.type;Te(),U.autoReset=w,Ue.enabled=k,Ue.autoUpdate=X,Ue.needsUpdate=B,Ue.type=z}function si(w){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function ai(w){const k=w.target;k.removeEventListener("dispose",ai),Vg(k)}function Vg(w){Wg(w),H.remove(w)}function Wg(w){const k=H.get(w).programs;k!==void 0&&(k.forEach(function(X){le.releaseProgram(X)}),w.isShaderMaterial&&le.releaseShaderCache(w))}this.renderBufferDirect=function(w,k,X,B,z,me){k===null&&(k=Mt);const xe=z.isMesh&&z.matrixWorld.determinantAffine()<0,pe=Yg(w,k,X,B,z);b.setMaterial(B,xe);let Se=X.index,De=1;if(B.wireframe===!0){if(Se=$.getWireframeAttribute(X),Se===void 0)return;De=2}const Ve=X.drawRange,Ye=X.attributes.position;let Ce=Ve.start*De,dt=(Ve.start+Ve.count)*De;me!==null&&(Ce=Math.max(Ce,me.start*De),dt=Math.min(dt,(me.start+me.count)*De)),Se!==null?(Ce=Math.max(Ce,0),dt=Math.min(dt,Se.count)):Ye!=null&&(Ce=Math.max(Ce,0),dt=Math.min(dt,Ye.count));const Ot=dt-Ce;if(Ot<0||Ot===1/0)return;ge.setup(z,B,pe,X,Se);let Lt,mt=re;if(Se!==null&&(Lt=oe.get(Se),mt=J,mt.setIndex(Lt)),z.isMesh)B.wireframe===!0?(b.setLineWidth(B.wireframeLinewidth*Bt()),mt.setMode(N.LINES)):mt.setMode(N.TRIANGLES);else if(z.isLine){let tn=B.linewidth;tn===void 0&&(tn=1),b.setLineWidth(tn*Bt()),z.isLineSegments?mt.setMode(N.LINES):z.isLineLoop?mt.setMode(N.LINE_LOOP):mt.setMode(N.LINE_STRIP)}else z.isPoints?mt.setMode(N.POINTS):z.isSprite&&mt.setMode(N.TRIANGLES);if(z.isBatchedMesh)if(rt.get("WEBGL_multi_draw"))mt.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const tn=z._multiDrawStarts,ye=z._multiDrawCounts,Tn=z._multiDrawCount,et=Se?oe.get(Se).bytesPerElement:1,Un=H.get(B).currentProgram.getUniforms();for(let ri=0;ri<Tn;ri++)Un.setValue(N,"_gl_DrawID",ri),mt.render(tn[ri]/et,ye[ri])}else if(z.isInstancedMesh)mt.renderInstances(Ce,Ot,z.count);else if(X.isInstancedBufferGeometry){const tn=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,ye=Math.min(X.instanceCount,tn);mt.renderInstances(Ce,Ot,ye)}else mt.render(Ce,Ot)};function Cu(w,k,X){w.transparent===!0&&w.side===Zn&&w.forceSinglePass===!1?(w.side=Vt,w.needsUpdate=!0,ro(w,k,X),w.side=vs,w.needsUpdate=!0,ro(w,k,X),w.side=Zn):ro(w,k,X)}this.compile=function(w,k,X=null){X===null&&(X=w),E=ce.get(X),E.init(k),y.push(E),X.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),w!==X&&w.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),E.setupLights();const B=new Set;return w.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const me=z.material;if(me)if(Array.isArray(me))for(let xe=0;xe<me.length;xe++){const pe=me[xe];Cu(pe,X,z),B.add(pe)}else Cu(me,X,z),B.add(me)}),E=y.pop(),B},this.compileAsync=function(w,k,X=null){const B=this.compile(w,k,X);return new Promise(z=>{function me(){if(B.forEach(function(xe){H.get(xe).currentProgram.isReady()&&B.delete(xe)}),B.size===0){z(w);return}setTimeout(me,10)}rt.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let tc=null;function Xg(w){tc&&tc(w)}function Ru(){xs.stop()}function Pu(){xs.start()}const xs=new Zm;xs.setAnimationLoop(Xg),typeof self<"u"&&xs.setContext(self),this.setAnimationLoop=function(w){tc=w,we.setAnimationLoop(w),w===null?xs.stop():xs.start()},we.addEventListener("sessionstart",Ru),we.addEventListener("sessionend",Pu),this.render=function(w,k){if(k!==void 0&&k.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;P!==null&&P.renderStart(w,k);const X=we.enabled===!0&&we.isPresenting===!0,B=T!==null&&(Z===null||X)&&T.begin(C,Z);if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(we.cameraAutoUpdate===!0&&we.updateCamera(k),k=we.getCamera()),w.isScene===!0&&w.onBeforeRender(C,w,k,Z),E=ce.get(w,y.length),E.init(k),E.state.textureUnits=K.getTextureUnits(),y.push(E),st.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Ne.setFromProjectionMatrix(st,wi,k.reversedDepth),ke=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,ke),M=ue.get(w,I.length),M.init(),I.push(M),we.enabled===!0&&we.isPresenting===!0){const xe=C.xr.getDepthSensingMesh();xe!==null&&nc(xe,k,-1/0,C.sortObjects)}nc(w,k,0,C.sortObjects),M.finish(),C.sortObjects===!0&&M.sort(F,_e,k.reversedDepth),Rt=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,Rt&&Ge.addToRenderList(M,w),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const z=E.state.shadowsArray;if(Ue.render(z,w,k),Oe===!0&&Le.endShadows(),(B&&T.hasRenderPass())===!1){const xe=M.opaque,pe=M.transmissive;if(E.setupLights(),k.isArrayCamera){const Se=k.cameras;if(pe.length>0)for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De];Nu(xe,pe,w,Ye)}Rt&&Ge.render(w);for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De];Lu(M,w,Ye,Ye.viewport)}}else pe.length>0&&Nu(xe,pe,w,k),Rt&&Ge.render(w),Lu(M,w,k)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&T.end(C),w.isScene===!0&&w.onAfterRender(C,w,k),ge.resetDefaultState(),te=-1,Q=null,y.pop(),y.length>0?(E=y[y.length-1],K.setTextureUnits(E.state.textureUnits),Oe===!0&&Le.setGlobalState(C.clippingPlanes,E.state.camera)):E=null,I.pop(),I.length>0?M=I[I.length-1]:M=null,P!==null&&P.renderEnd()};function nc(w,k,X,B){if(w.visible===!1)return;if(w.layers.test(k.layers)){if(w.isGroup)X=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(k);else if(w.isLightProbeGrid)E.pushLightProbeGrid(w);else if(w.isLight)E.pushLight(w),w.castShadow&&E.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||Ne.intersectsSprite(w)){B&&Ct.setFromMatrixPosition(w.matrixWorld).applyMatrix4(st);const xe=j.update(w),pe=w.material;pe.visible&&M.push(w,xe,pe,X,Ct.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||Ne.intersectsObject(w))){const xe=j.update(w),pe=w.material;if(B&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Ct.copy(w.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),Ct.copy(xe.boundingSphere.center)),Ct.applyMatrix4(w.matrixWorld).applyMatrix4(st)),Array.isArray(pe)){const Se=xe.groups;for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De],Ce=pe[Ye.materialIndex];Ce&&Ce.visible&&M.push(w,xe,Ce,X,Ct.z,Ye)}}else pe.visible&&M.push(w,xe,pe,X,Ct.z,null)}}const me=w.children;for(let xe=0,pe=me.length;xe<pe;xe++)nc(me[xe],k,X,B)}function Lu(w,k,X,B){const{opaque:z,transmissive:me,transparent:xe}=w;E.setupLightsView(X),Oe===!0&&Le.setGlobalState(C.clippingPlanes,X),B&&b.viewport(ie.copy(B)),z.length>0&&ao(z,k,X),me.length>0&&ao(me,k,X),xe.length>0&&ao(xe,k,X),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function Nu(w,k,X,B){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[B.id]===void 0){const Ce=rt.has("EXT_color_buffer_half_float")||rt.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[B.id]=new En(1,1,{generateMipmaps:!0,type:Ce?cn:kn,minFilter:Bs,samples:Math.max(4,A.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}const me=E.state.transmissionRenderTarget[B.id],xe=B.viewport||ie;me.setSize(xe.z*C.transmissionResolutionScale,xe.w*C.transmissionResolutionScale);const pe=C.getRenderTarget(),Se=C.getActiveCubeFace(),De=C.getActiveMipmapLevel();C.setRenderTarget(me),C.getClearColor(Je),ze=C.getClearAlpha(),ze<1&&C.setClearColor(16777215,.5),C.clear(),Rt&&Ge.render(X);const Ve=C.toneMapping;C.toneMapping=_i;const Ye=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),E.setupLightsView(B),Oe===!0&&Le.setGlobalState(C.clippingPlanes,B),ao(w,X,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),rt.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let dt=0,Ot=k.length;dt<Ot;dt++){const Lt=k[dt],{object:mt,geometry:tn,material:ye,group:Tn}=Lt;if(ye.side===Zn&&mt.layers.test(B.layers)){const et=ye.side;ye.side=Vt,ye.needsUpdate=!0,Ou(mt,X,B,tn,ye,Tn),ye.side=et,ye.needsUpdate=!0,Ce=!0}}Ce===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}C.setRenderTarget(pe,Se,De),C.setClearColor(Je,ze),Ye!==void 0&&(B.viewport=Ye),C.toneMapping=Ve}function ao(w,k,X){const B=k.isScene===!0?k.overrideMaterial:null;for(let z=0,me=w.length;z<me;z++){const xe=w[z],{object:pe,geometry:Se,group:De}=xe;let Ve=xe.material;Ve.allowOverride===!0&&B!==null&&(Ve=B),pe.layers.test(X.layers)&&Ou(pe,k,X,Se,Ve,De)}}function Ou(w,k,X,B,z,me){w.onBeforeRender(C,k,X,B,z,me),w.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),z.onBeforeRender(C,k,X,B,w,me),z.transparent===!0&&z.side===Zn&&z.forceSinglePass===!1?(z.side=Vt,z.needsUpdate=!0,C.renderBufferDirect(X,k,B,z,w,me),z.side=vs,z.needsUpdate=!0,C.renderBufferDirect(X,k,B,z,w,me),z.side=Zn):C.renderBufferDirect(X,k,B,z,w,me),w.onAfterRender(C,k,X,B,z,me)}function ro(w,k,X){k.isScene!==!0&&(k=Mt);const B=H.get(w),z=E.state.lights,me=E.state.shadowsArray,xe=z.state.version,pe=le.getParameters(w,z.state,me,k,X,E.state.lightProbeGridArray),Se=le.getProgramCacheKey(pe);let De=B.programs;B.environment=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?k.environment:null,B.fog=k.fog;const Ve=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap;B.envMap=se.get(w.envMap||B.environment,Ve),B.envMapRotation=B.environment!==null&&w.envMap===null?k.environmentRotation:w.envMapRotation,De===void 0&&(w.addEventListener("dispose",ai),De=new Map,B.programs=De);let Ye=De.get(Se);if(Ye!==void 0){if(B.currentProgram===Ye&&B.lightsStateVersion===xe)return Uu(w,pe),Ye}else pe.uniforms=le.getUniforms(w),P!==null&&w.isNodeMaterial&&P.build(w,X,pe),w.onBeforeCompile(pe,C),Ye=le.acquireProgram(pe,Se),De.set(Se,Ye),B.uniforms=pe.uniforms;const Ce=B.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(Ce.clippingPlanes=Le.uniform),Uu(w,pe),B.needsLights=$g(w),B.lightsStateVersion=xe,B.needsLights&&(Ce.ambientLightColor.value=z.state.ambient,Ce.lightProbe.value=z.state.probe,Ce.directionalLights.value=z.state.directional,Ce.directionalLightShadows.value=z.state.directionalShadow,Ce.spotLights.value=z.state.spot,Ce.spotLightShadows.value=z.state.spotShadow,Ce.rectAreaLights.value=z.state.rectArea,Ce.ltc_1.value=z.state.rectAreaLTC1,Ce.ltc_2.value=z.state.rectAreaLTC2,Ce.pointLights.value=z.state.point,Ce.pointLightShadows.value=z.state.pointShadow,Ce.hemisphereLights.value=z.state.hemi,Ce.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Ce.spotLightMatrix.value=z.state.spotLightMatrix,Ce.spotLightMap.value=z.state.spotLightMap,Ce.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=E.state.lightProbeGridArray.length>0,B.currentProgram=Ye,B.uniformsList=null,Ye}function ku(w){if(w.uniformsList===null){const k=w.currentProgram.getUniforms();w.uniformsList=gl.seqWithValue(k.seq,w.uniforms)}return w.uniformsList}function Uu(w,k){const X=H.get(w);X.outputColorSpace=k.outputColorSpace,X.batching=k.batching,X.batchingColor=k.batchingColor,X.instancing=k.instancing,X.instancingColor=k.instancingColor,X.instancingMorph=k.instancingMorph,X.skinning=k.skinning,X.morphTargets=k.morphTargets,X.morphNormals=k.morphNormals,X.morphColors=k.morphColors,X.morphTargetsCount=k.morphTargetsCount,X.numClippingPlanes=k.numClippingPlanes,X.numIntersection=k.numClipIntersection,X.vertexAlphas=k.vertexAlphas,X.vertexTangents=k.vertexTangents,X.toneMapping=k.toneMapping}function qg(w,k){if(w.length===0)return null;if(w.length===1)return w[0].texture!==null?w[0]:null;x.setFromMatrixPosition(k.matrixWorld);for(let X=0,B=w.length;X<B;X++){const z=w[X];if(z.texture!==null&&z.boundingBox.containsPoint(x))return z}return null}function Yg(w,k,X,B,z){k.isScene!==!0&&(k=Mt),K.resetTextureUnits();const me=k.fog,xe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?k.environment:null,pe=Z===null?C.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Qe.workingColorSpace,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,De=se.get(B.envMap||xe,Se),Ve=B.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ye=!!X.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!X.morphAttributes.position,dt=!!X.morphAttributes.normal,Ot=!!X.morphAttributes.color;let Lt=_i;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Lt=C.toneMapping);const mt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,tn=mt!==void 0?mt.length:0,ye=H.get(B),Tn=E.state.lights;if(Oe===!0&&(ke===!0||w!==Q)){const bt=w===Q&&B.id===te;Le.setState(B,w,bt)}let et=!1;B.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Tn.state.version||ye.outputColorSpace!==pe||z.isBatchedMesh&&ye.batching===!1||!z.isBatchedMesh&&ye.batching===!0||z.isBatchedMesh&&ye.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&ye.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&ye.instancing===!1||!z.isInstancedMesh&&ye.instancing===!0||z.isSkinnedMesh&&ye.skinning===!1||!z.isSkinnedMesh&&ye.skinning===!0||z.isInstancedMesh&&ye.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&ye.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&ye.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&ye.instancingMorph===!1&&z.morphTexture!==null||ye.envMap!==De||B.fog===!0&&ye.fog!==me||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Le.numPlanes||ye.numIntersection!==Le.numIntersection)||ye.vertexAlphas!==Ve||ye.vertexTangents!==Ye||ye.morphTargets!==Ce||ye.morphNormals!==dt||ye.morphColors!==Ot||ye.toneMapping!==Lt||ye.morphTargetsCount!==tn||!!ye.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(et=!0):(et=!0,ye.__version=B.version);let Un=ye.currentProgram;et===!0&&(Un=ro(B,k,z),P&&B.isNodeMaterial&&P.onUpdateProgram(B,Un,ye));let ri=!1,Ji=!1,Js=!1;const gt=Un.getUniforms(),kt=ye.uniforms;if(b.useProgram(Un.program)&&(ri=!0,Ji=!0,Js=!0),B.id!==te&&(te=B.id,Ji=!0),ye.needsLights){const bt=qg(E.state.lightProbeGridArray,z);ye.lightProbeGrid!==bt&&(ye.lightProbeGrid=bt,Ji=!0)}if(ri||Q!==w){b.buffers.depth.getReversed()&&w.reversedDepth!==!0&&(w._reversedDepth=!0,w.updateProjectionMatrix()),gt.setValue(N,"projectionMatrix",w.projectionMatrix),gt.setValue(N,"viewMatrix",w.matrixWorldInverse);const Qi=gt.map.cameraPosition;Qi!==void 0&&Qi.setValue(N,at.setFromMatrixPosition(w.matrixWorld)),A.logarithmicDepthBuffer&&gt.setValue(N,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&gt.setValue(N,"isOrthographic",w.isOrthographicCamera===!0),Q!==w&&(Q=w,Ji=!0,Js=!0)}if(ye.needsLights&&(Tn.state.directionalShadowMap.length>0&&gt.setValue(N,"directionalShadowMap",Tn.state.directionalShadowMap,K),Tn.state.spotShadowMap.length>0&&gt.setValue(N,"spotShadowMap",Tn.state.spotShadowMap,K),Tn.state.pointShadowMap.length>0&&gt.setValue(N,"pointShadowMap",Tn.state.pointShadowMap,K)),z.isSkinnedMesh){gt.setOptional(N,z,"bindMatrix"),gt.setOptional(N,z,"bindMatrixInverse");const bt=z.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),gt.setValue(N,"boneTexture",bt.boneTexture,K))}z.isBatchedMesh&&(gt.setOptional(N,z,"batchingTexture"),gt.setValue(N,"batchingTexture",z._matricesTexture,K),gt.setOptional(N,z,"batchingIdTexture"),gt.setValue(N,"batchingIdTexture",z._indirectTexture,K),gt.setOptional(N,z,"batchingColorTexture"),z._colorsTexture!==null&&gt.setValue(N,"batchingColorTexture",z._colorsTexture,K));const ji=X.morphAttributes;if((ji.position!==void 0||ji.normal!==void 0||ji.color!==void 0)&&L.update(z,X,Un),(Ji||ye.receiveShadow!==z.receiveShadow)&&(ye.receiveShadow=z.receiveShadow,gt.setValue(N,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&k.environment!==null&&(kt.envMapIntensity.value=k.environmentIntensity),kt.dfgLUT!==void 0&&(kt.dfgLUT.value=gS()),Ji){if(gt.setValue(N,"toneMappingExposure",C.toneMappingExposure),ye.needsLights&&Kg(kt,Js),me&&B.fog===!0&&Ie.refreshFogUniforms(kt,me),Ie.refreshMaterialUniforms(kt,B,ne,ae,E.state.transmissionRenderTarget[w.id]),ye.needsLights&&ye.lightProbeGrid){const bt=ye.lightProbeGrid;kt.probesSH.value=bt.texture,kt.probesMin.value.copy(bt.boundingBox.min),kt.probesMax.value.copy(bt.boundingBox.max),kt.probesResolution.value.copy(bt.resolution)}gl.upload(N,ku(ye),kt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(gl.upload(N,ku(ye),kt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&gt.setValue(N,"center",z.center),gt.setValue(N,"modelViewMatrix",z.modelViewMatrix),gt.setValue(N,"normalMatrix",z.normalMatrix),gt.setValue(N,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const bt=B.uniformsGroups;for(let Qi=0,js=bt.length;Qi<js;Qi++){const Fu=bt[Qi];ee.update(Fu,Un),ee.bind(Fu,Un)}}return Un}function Kg(w,k){w.ambientLightColor.needsUpdate=k,w.lightProbe.needsUpdate=k,w.directionalLights.needsUpdate=k,w.directionalLightShadows.needsUpdate=k,w.pointLights.needsUpdate=k,w.pointLightShadows.needsUpdate=k,w.spotLights.needsUpdate=k,w.spotLightShadows.needsUpdate=k,w.rectAreaLights.needsUpdate=k,w.hemisphereLights.needsUpdate=k}function $g(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(w,k,X){const B=H.get(w);B.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(w.texture).__webglTexture=k,H.get(w.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:X,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,k){const X=H.get(w);X.__webglFramebuffer=k,X.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(w,k=0,X=0){Z=w,W=k,G=X;let B=null,z=!1,me=!1;if(w){const pe=H.get(w);if(pe.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(N.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(w.viewport),de.copy(w.scissor),He=w.scissorTest,b.viewport(ie),b.scissor(de),b.setScissorTest(He),te=-1;return}else if(pe.__webglFramebuffer===void 0)K.setupRenderTarget(w);else if(pe.__hasExternalTextures)K.rebindTextures(w,H.get(w.texture).__webglTexture,H.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const Ve=w.depthTexture;if(pe.__boundDepthTexture!==Ve){if(Ve!==null&&H.has(Ve)&&(w.width!==Ve.image.width||w.height!==Ve.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(w)}}const Se=w.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(me=!0);const De=H.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(De[k])?B=De[k][X]:B=De[k],z=!0):w.samples>0&&K.useMultisampledRTT(w)===!1?B=H.get(w).__webglMultisampledFramebuffer:Array.isArray(De)?B=De[X]:B=De,ie.copy(w.viewport),de.copy(w.scissor),He=w.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),de.copy(Ae).multiplyScalar(ne).floor(),He=be;if(X!==0&&(B=V),b.bindFramebuffer(N.FRAMEBUFFER,B)&&b.drawBuffers(w,B),b.viewport(ie),b.scissor(de),b.setScissorTest(He),z){const pe=H.get(w.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+k,pe.__webglTexture,X)}else if(me){const pe=k;for(let Se=0;Se<w.textures.length;Se++){const De=H.get(w.textures[Se]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Se,De.__webglTexture,X,pe)}}else if(w!==null&&X!==0){const pe=H.get(w.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pe.__webglTexture,X)}te=-1},this.readRenderTargetPixels=function(w,k,X,B,z,me,xe,pe=0){if(!(w&&w.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=H.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se){b.bindFramebuffer(N.FRAMEBUFFER,Se);try{const De=w.textures[pe],Ve=De.format,Ye=De.type;if(w.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!A.textureFormatReadable(Ve)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!A.textureTypeReadable(Ye)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=w.width-B&&X>=0&&X<=w.height-z&&N.readPixels(k,X,B,z,he.convert(Ve),he.convert(Ye),me)}finally{const De=Z!==null?H.get(Z).__webglFramebuffer:null;b.bindFramebuffer(N.FRAMEBUFFER,De)}}},this.readRenderTargetPixelsAsync=async function(w,k,X,B,z,me,xe,pe=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=H.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se)if(k>=0&&k<=w.width-B&&X>=0&&X<=w.height-z){b.bindFramebuffer(N.FRAMEBUFFER,Se);const De=w.textures[pe],Ve=De.format,Ye=De.type;if(w.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!A.textureFormatReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!A.textureTypeReadable(Ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ce=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.bufferData(N.PIXEL_PACK_BUFFER,me.byteLength,N.STREAM_READ),N.readPixels(k,X,B,z,he.convert(Ve),he.convert(Ye),0);const dt=Z!==null?H.get(Z).__webglFramebuffer:null;b.bindFramebuffer(N.FRAMEBUFFER,dt);const Ot=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Vv(N,Ot,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,me),N.deleteBuffer(Ce),N.deleteSync(Ot),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,k=null,X=0){const B=Math.pow(2,-X),z=Math.floor(w.image.width*B),me=Math.floor(w.image.height*B),xe=k!==null?k.x:0,pe=k!==null?k.y:0;K.setTexture2D(w,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,xe,pe,z,me),b.unbindTexture()},this.copyTextureToTexture=function(w,k,X=null,B=null,z=0,me=0){let xe,pe,Se,De,Ve,Ye,Ce,dt,Ot;const Lt=w.isCompressedTexture?w.mipmaps[me]:w.image;if(X!==null)xe=X.max.x-X.min.x,pe=X.max.y-X.min.y,Se=X.isBox3?X.max.z-X.min.z:1,De=X.min.x,Ve=X.min.y,Ye=X.isBox3?X.min.z:0;else{const kt=Math.pow(2,-z);xe=Math.floor(Lt.width*kt),pe=Math.floor(Lt.height*kt),w.isDataArrayTexture?Se=Lt.depth:w.isData3DTexture?Se=Math.floor(Lt.depth*kt):Se=1,De=0,Ve=0,Ye=0}B!==null?(Ce=B.x,dt=B.y,Ot=B.z):(Ce=0,dt=0,Ot=0);const mt=he.convert(k.format),tn=he.convert(k.type);let ye;k.isData3DTexture?(K.setTexture3D(k,0),ye=N.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(K.setTexture2DArray(k,0),ye=N.TEXTURE_2D_ARRAY):(K.setTexture2D(k,0),ye=N.TEXTURE_2D),b.activeTexture(N.TEXTURE0),b.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,k.flipY),b.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),b.pixelStorei(N.UNPACK_ALIGNMENT,k.unpackAlignment);const Tn=b.getParameter(N.UNPACK_ROW_LENGTH),et=b.getParameter(N.UNPACK_IMAGE_HEIGHT),Un=b.getParameter(N.UNPACK_SKIP_PIXELS),ri=b.getParameter(N.UNPACK_SKIP_ROWS),Ji=b.getParameter(N.UNPACK_SKIP_IMAGES);b.pixelStorei(N.UNPACK_ROW_LENGTH,Lt.width),b.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Lt.height),b.pixelStorei(N.UNPACK_SKIP_PIXELS,De),b.pixelStorei(N.UNPACK_SKIP_ROWS,Ve),b.pixelStorei(N.UNPACK_SKIP_IMAGES,Ye);const Js=w.isDataArrayTexture||w.isData3DTexture,gt=k.isDataArrayTexture||k.isData3DTexture;if(w.isDepthTexture){const kt=H.get(w),ji=H.get(k),bt=H.get(kt.__renderTarget),Qi=H.get(ji.__renderTarget);b.bindFramebuffer(N.READ_FRAMEBUFFER,bt.__webglFramebuffer),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,Qi.__webglFramebuffer);for(let js=0;js<Se;js++)Js&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(w).__webglTexture,z,Ye+js),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(k).__webglTexture,me,Ot+js)),N.blitFramebuffer(De,Ve,xe,pe,Ce,dt,xe,pe,N.DEPTH_BUFFER_BIT,N.NEAREST);b.bindFramebuffer(N.READ_FRAMEBUFFER,null),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(z!==0||w.isRenderTargetTexture||H.has(w)){const kt=H.get(w),ji=H.get(k);b.bindFramebuffer(N.READ_FRAMEBUFFER,q),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let bt=0;bt<Se;bt++)Js?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,kt.__webglTexture,z,Ye+bt):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,kt.__webglTexture,z),gt?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ji.__webglTexture,me,Ot+bt):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ji.__webglTexture,me),z!==0?N.blitFramebuffer(De,Ve,xe,pe,Ce,dt,xe,pe,N.COLOR_BUFFER_BIT,N.NEAREST):gt?N.copyTexSubImage3D(ye,me,Ce,dt,Ot+bt,De,Ve,xe,pe):N.copyTexSubImage2D(ye,me,Ce,dt,De,Ve,xe,pe);b.bindFramebuffer(N.READ_FRAMEBUFFER,null),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else gt?w.isDataTexture||w.isData3DTexture?N.texSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,mt,tn,Lt.data):k.isCompressedArrayTexture?N.compressedTexSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,mt,Lt.data):N.texSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,mt,tn,Lt):w.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,me,Ce,dt,xe,pe,mt,tn,Lt.data):w.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,me,Ce,dt,Lt.width,Lt.height,mt,Lt.data):N.texSubImage2D(N.TEXTURE_2D,me,Ce,dt,xe,pe,mt,tn,Lt);b.pixelStorei(N.UNPACK_ROW_LENGTH,Tn),b.pixelStorei(N.UNPACK_IMAGE_HEIGHT,et),b.pixelStorei(N.UNPACK_SKIP_PIXELS,Un),b.pixelStorei(N.UNPACK_SKIP_ROWS,ri),b.pixelStorei(N.UNPACK_SKIP_IMAGES,Ji),me===0&&k.generateMipmaps&&N.generateMipmap(ye),b.unbindTexture()},this.initRenderTarget=function(w){H.get(w).__webglFramebuffer===void 0&&K.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?K.setTextureCube(w,0):w.isData3DTexture?K.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?K.setTexture2DArray(w,0):K.setTexture2D(w,0),b.unbindTexture()},this.resetState=function(){W=0,G=0,Z=null,b.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return wi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}const jl=`
5980
+ }`;class hS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Nt({vertexShader:lS,fragmentShader:cS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ze(new Zi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dS extends Zs{constructor(e,t){super();const n=this;let i=null,a=1,r=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null;const v=typeof XRWebGLBinding<"u",p=new hS,m={},S=t.getContextAttributes();let _=null,x=null;const M=[],E=[],I=new Re;let y=null;const T=new En;T.viewport=new ft;const C=new En;C.viewport=new ft;const D=[T,C],P=new ub;let V=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getGripSpace()},this.getHand=function(Y){let ae=M[Y];return ae===void 0&&(ae=new gc,M[Y]=ae),ae.getHandSpace()};function O(Y){const ae=E.indexOf(Y.inputSource);if(ae===-1)return;const ne=M[ae];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,c||r),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<M.length;Y++){const ae=E[Y];ae!==null&&(E[Y]=null,M[Y].disconnect(ae))}V=null,q=null,p.reset();for(const Y in m)delete m[Y];e.setRenderTarget(_),f=null,u=null,d=null,i=null,x=null,ze.stop(),n.isPresenting=!1,e.setPixelRatio(y),e.setSize(I.width,I.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){a=Y,n.isPresenting===!0&&Ee("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ee("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||r},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(i,t)),d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(_=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",W),i.addEventListener("inputsourceschange",G),S.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(I),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,F=null,_e=null;S.depth&&(_e=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=S.stencil?zs:Wi,F=S.stencil?Yr:ii);const Pe={colorFormat:t.RGBA8,depthFormat:_e,scaleFactor:a};d=this.getBinding(),u=d.createProjectionLayer(Pe),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),x=new Tn(u.textureWidth,u.textureHeight,{format:yn,type:kn,depthTexture:new Ks(u.textureWidth,u.textureHeight,F,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(i,t,ne),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new Tn(f.framebufferWidth,f.framebufferHeight,{format:yn,type:kn,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,r=await i.requestReferenceSpace(o),ze.setContext(i),ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function G(Y){for(let ae=0;ae<Y.removed.length;ae++){const ne=Y.removed[ae],F=E.indexOf(ne);F>=0&&(E[F]=null,M[F].disconnect(ne))}for(let ae=0;ae<Y.added.length;ae++){const ne=Y.added[ae];let F=E.indexOf(ne);if(F===-1){for(let Pe=0;Pe<M.length;Pe++)if(Pe>=E.length){E.push(ne),F=Pe;break}else if(E[Pe]===null){E[Pe]=ne,F=Pe;break}if(F===-1)break}const _e=M[F];_e&&_e.connect(ne)}}const Z=new R,te=new R;function Q(Y,ae,ne){Z.setFromMatrixPosition(ae.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const F=Z.distanceTo(te),_e=ae.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Ae=_e[14]/(_e[10]-1),be=_e[14]/(_e[10]+1),Ne=(_e[9]+1)/_e[5],Oe=(_e[9]-1)/_e[5],ke=(_e[8]-1)/_e[0],at=(Pe[8]+1)/Pe[0],rt=Ae*ke,Ct=Ae*at,wt=F/(-ke+at),Rt=wt*-ke;if(ae.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Rt),Y.translateZ(wt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),_e[10]===-1)Y.projectionMatrix.copy(ae.projectionMatrix),Y.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{const Bt=Ae+wt,N=be+wt,wn=rt-Rt,ot=Ct+(F-Rt),A=Ne*be/N*Bt,b=Oe*be/N*Bt;Y.projectionMatrix.makePerspective(wn,ot,A,b,Bt,N),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ie(Y,ae){ae===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(ae.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let ae=Y.near,ne=Y.far;p.texture!==null&&(p.depthNear>0&&(ae=p.depthNear),p.depthFar>0&&(ne=p.depthFar)),P.near=C.near=T.near=ae,P.far=C.far=T.far=ne,(V!==P.near||q!==P.far)&&(i.updateRenderState({depthNear:P.near,depthFar:P.far}),V=P.near,q=P.far),P.layers.mask=Y.layers.mask|6,T.layers.mask=P.layers.mask&-5,C.layers.mask=P.layers.mask&-3;const F=Y.parent,_e=P.cameras;ie(P,F);for(let Pe=0;Pe<_e.length;Pe++)ie(_e[Pe],F);_e.length===2?Q(P,T,C):P.projectionMatrix.copy(T.projectionMatrix),de(Y,P,F)};function de(Y,ae,ne){ne===null?Y.matrix.copy(ae.matrixWorld):(Y.matrix.copy(ne.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(ae.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(ae.projectionMatrix),Y.projectionMatrixInverse.copy(ae.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ja*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(Y){l=Y,u!==null&&(u.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(P)},this.getCameraTexture=function(Y){return m[Y]};let He=null;function Je(Y,ae){if(h=ae.getViewerPose(c||r),g=ae,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let F=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,F=!0);for(let be=0;be<ne.length;be++){const Ne=ne[be];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const at=d.getViewSubImage(u,Ne);Oe=at.viewport,be===0&&(e.setRenderTargetTextures(x,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(x))}let ke=D[be];ke===void 0&&(ke=new En,ke.layers.enable(be),ke.viewport=new ft,D[be]=ke),ke.matrix.fromArray(Ne.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray(Ne.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),be===0&&(P.matrix.copy(ke.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),F===!0&&P.cameras.push(ke)}const _e=i.enabledFeatures;if(_e&&_e.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){d=n.getBinding();const be=d.getDepthInformation(ne[0]);be&&be.isValid&&be.texture&&p.init(be,i.renderState)}if(_e&&_e.includes("camera-access")&&v){e.state.unbindTexture(),d=n.getBinding();for(let be=0;be<ne.length;be++){const Ne=ne[be].camera;if(Ne){let Oe=m[Ne];Oe||(Oe=new Wm,m[Ne]=Oe);const ke=d.getCameraImage(Ne);Oe.sourceTexture=ke}}}}for(let ne=0;ne<M.length;ne++){const F=E[ne],_e=M[ne];F!==null&&_e!==void 0&&_e.update(F,ae,c||r)}He&&He(Y,ae),ae.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ae}),g=null}const ze=new Zm;ze.setAnimationLoop(Je),this.setAnimationLoop=function(Y){He=Y},this.dispose=function(){}}}const uS=new qe,ig=new Be;ig.set(-1,0,0,0,1,0,0,0,1);function fS(s,e){function t(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Xm(s)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function i(p,m,S,_,x){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?a(p,m):m.isMeshLambertMaterial?(a(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(a(p,m),d(p,m)):m.isMeshPhongMaterial?(a(p,m),h(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(a(p,m),u(p,m),m.isMeshPhysicalMaterial&&f(p,m,x)):m.isMeshMatcapMaterial?(a(p,m),g(p,m)):m.isMeshDepthMaterial?a(p,m):m.isMeshDistanceMaterial?(a(p,m),v(p,m)):m.isMeshNormalMaterial?a(p,m):m.isLineBasicMaterial?(r(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?l(p,m,S,_):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,t(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Vt&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,t(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Vt&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,t(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,t(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const S=e.get(m),_=S.envMap,x=S.envMapRotation;_&&(p.envMap.value=_,p.envMapRotation.value.setFromMatrix4(uS.makeRotationFromEuler(x)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(ig),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,p.aoMapTransform))}function r(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,S,_){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*S,p.scale.value=_*.5,m.map&&(p.map.value=m.map,t(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function d(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function u(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,S){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Vt&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function v(p,m){const S=e.get(m).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function pS(s,e,t,n){let i={},a={},r=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,M){const E=M.program;n.uniformBlockBinding(x,E)}function c(x,M){let E=i[x.id];E===void 0&&(p(x),E=h(x),i[x.id]=E,x.addEventListener("dispose",S));const I=M.program;n.updateUBOMapping(x,I);const y=e.render.frame;a[x.id]!==y&&(u(x),a[x.id]=y)}function h(x){const M=d();x.__bindingPointIndex=M;const E=s.createBuffer(),I=x.__size,y=x.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,I,y),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,M,E),E}function d(){for(let x=0;x<o;x++)if(r.indexOf(x)===-1)return r.push(x),x;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){const M=i[x.id],E=x.uniforms,I=x.__cache;s.bindBuffer(s.UNIFORM_BUFFER,M);for(let y=0,T=E.length;y<T;y++){const C=E[y];if(Array.isArray(C))for(let D=0,P=C.length;D<P;D++)f(C[D],y,D,I);else f(C,y,0,I)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(x,M,E,I){if(v(x,M,E,I)===!0){const y=x.__offset,T=x.value;if(Array.isArray(T)){let C=0;for(let D=0;D<T.length;D++){const P=T[D],V=m(P);g(P,x.__data,C),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(T,x.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,y,x.__data)}}function g(x,M,E){typeof x=="number"||typeof x=="boolean"?M[0]=x:x.isMatrix3?(M[0]=x.elements[0],M[1]=x.elements[1],M[2]=x.elements[2],M[3]=0,M[4]=x.elements[3],M[5]=x.elements[4],M[6]=x.elements[5],M[7]=0,M[8]=x.elements[6],M[9]=x.elements[7],M[10]=x.elements[8],M[11]=0):ArrayBuffer.isView(x)?M.set(new x.constructor(x.buffer,x.byteOffset,M.length)):x.toArray(M,E)}function v(x,M,E,I){const y=x.value,T=M+"_"+E;if(I[T]===void 0)return typeof y=="number"||typeof y=="boolean"?I[T]=y:ArrayBuffer.isView(y)?I[T]=y.slice():I[T]=y.clone(),!0;{const C=I[T];if(typeof y=="number"||typeof y=="boolean"){if(C!==y)return I[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(C.equals(y)===!1)return C.copy(y),!0}}return!1}function p(x){const M=x.uniforms;let E=0;const I=16;for(let T=0,C=M.length;T<C;T++){const D=Array.isArray(M[T])?M[T]:[M[T]];for(let P=0,V=D.length;P<V;P++){const q=D[P],O=Array.isArray(q.value)?q.value:[q.value];for(let W=0,G=O.length;W<G;W++){const Z=O[W],te=m(Z),Q=E%I,ie=Q%te.boundary,de=Q+ie;E+=ie,de!==0&&I-de<te.storage&&(E+=I-de),q.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=E,E+=te.storage}}}const y=E%I;return y>0&&(E+=I-y),x.__size=E,x.__cache={},this}function m(x){const M={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(M.boundary=4,M.storage=4):x.isVector2?(M.boundary=8,M.storage=8):x.isVector3||x.isColor?(M.boundary=16,M.storage=12):x.isVector4?(M.boundary=16,M.storage=16):x.isMatrix3?(M.boundary=48,M.storage=48):x.isMatrix4?(M.boundary=64,M.storage=64):x.isTexture?Ee("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(M.boundary=16,M.storage=x.byteLength):Ee("WebGLRenderer: Unsupported uniform value type.",x),M}function S(x){const M=x.target;M.removeEventListener("dispose",S);const E=r.indexOf(M.__bindingPointIndex);r.splice(E,1),s.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function _(){for(const x in i)s.deleteBuffer(i[x]);r=[],i={},a={}}return{bind:l,update:c,dispose:_}}const mS=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 ci=null;function gS(){return ci===null&&(ci=new nr(mS,16,16,Ys,hn),ci.name="DFG_LUT",ci.minFilter=At,ci.magFilter=At,ci.wrapS=vn,ci.wrapT=vn,ci.generateMipmaps=!1,ci.needsUpdate=!0),ci}class vS{constructor(e={}){const{canvas:t=Gv(),context:n=null,depth:i=!0,stencil:a=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=kn}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=r;const v=f,p=new Set([ru,au,su]),m=new Set([kn,ii,qr,Yr,tu,nu]),S=new Uint32Array(4),_=new Int32Array(4),x=new R;let M=null,E=null;const I=[],y=[];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=_i,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,P=null,V=null,q=null,O=null;this._outputColorSpace=Nn;let W=0,G=0,Z=null,te=-1,Q=null;const ie=new ft,de=new ft;let He=null;const Je=new ve(0);let ze=0,Y=t.width,ae=t.height,ne=1,F=null,_e=null;const Pe=new ft(0,0,Y,ae),Ae=new ft(0,0,Y,ae);let be=!1;const Ne=new pu;let Oe=!1,ke=!1;const at=new qe,rt=new R,Ct=new ft,wt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Rt=!1;function Bt(){return Z===null?ne:1}let N=n;function wn(w,k){return t.getContext(w,k)}try{const w={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${jd}`),t.addEventListener("webglcontextlost",Pt,!1),t.addEventListener("webglcontextrestored",vt,!1),t.addEventListener("webglcontextcreationerror",ai,!1),N===null){const k="webgl2";if(N=wn(k,w),N===null)throw wn(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(w){throw Fe("WebGLRenderer: "+w.message),w}let ot,A,b,U,H,K,se,oe,$,j,le,Ie,ue,ce,Le,Ue,Ge,L,re,J,he,ge,ee;function Te(){ot=new g2(N),ot.init(),he=new oS(N,ot),A=new l2(N,ot,e,he),b=new aS(N,ot),A.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),V=N.createFramebuffer(),q=N.createFramebuffer(),O=N.createFramebuffer(),U=new b2(N),H=new XM,K=new rS(N,ot,b,H,A,he,U),se=new m2(C),oe=new Sb(N),ge=new r2(N,oe),$=new v2(N,oe,U,ge),j=new w2(N,$,oe,ge,U),L=new x2(N,A,K),Le=new c2(H),le=new WM(C,se,ot,A,ge,Le),Ie=new fS(C,H),ue=new YM,ce=new QM(ot),Ge=new a2(C,se,b,j,g,l),Ue=new sS(C,j,A),ee=new pS(N,U,A,b),re=new o2(N,ot,U),J=new y2(N,ot,U),U.programs=le.programs,C.capabilities=A,C.extensions=ot,C.properties=H,C.renderLists=ue,C.shadowMap=Ue,C.state=b,C.info=U}Te(),v!==kn&&(T=new S2(v,t.width,t.height,o,i,a));const we=new dS(C,N);this.xr=we,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const w=ot.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=ot.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(w){w!==void 0&&(ne=w,this.setSize(Y,ae,!1))},this.getSize=function(w){return w.set(Y,ae)},this.setSize=function(w,k,X=!0){if(we.isPresenting){Ee("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=w,ae=k,t.width=Math.floor(w*ne),t.height=Math.floor(k*ne),X===!0&&(t.style.width=w+"px",t.style.height=k+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,w,k)},this.getDrawingBufferSize=function(w){return w.set(Y*ne,ae*ne).floor()},this.setDrawingBufferSize=function(w,k,X){Y=w,ae=k,ne=X,t.width=Math.floor(w*X),t.height=Math.floor(k*X),this.setViewport(0,0,w,k)},this.setEffects=function(w){if(v===kn){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(w){for(let k=0;k<w.length;k++)if(w[k].isOutputPass===!0){Ee("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(w||[])},this.getCurrentViewport=function(w){return w.copy(ie)},this.getViewport=function(w){return w.copy(Pe)},this.setViewport=function(w,k,X,B){w.isVector4?Pe.set(w.x,w.y,w.z,w.w):Pe.set(w,k,X,B),b.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(w){return w.copy(Ae)},this.setScissor=function(w,k,X,B){w.isVector4?Ae.set(w.x,w.y,w.z,w.w):Ae.set(w,k,X,B),b.scissor(de.copy(Ae).multiplyScalar(ne).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(w){b.setScissorTest(be=w)},this.setOpaqueSort=function(w){F=w},this.setTransparentSort=function(w){_e=w},this.getClearColor=function(w){return w.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor(...arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha(...arguments)},this.clear=function(w=!0,k=!0,X=!0){let B=0;if(w){let z=!1;if(Z!==null){const me=Z.texture.format;z=p.has(me)}if(z){const me=Z.texture.type,xe=m.has(me),pe=Ge.getClearColor(),Se=Ge.getClearAlpha(),De=pe.r,Ve=pe.g,Ye=pe.b;xe?(S[0]=De,S[1]=Ve,S[2]=Ye,S[3]=Se,N.clearBufferuiv(N.COLOR,0,S)):(_[0]=De,_[1]=Ve,_[2]=Ye,_[3]=Se,N.clearBufferiv(N.COLOR,0,_))}else B|=N.COLOR_BUFFER_BIT}k&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),X&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.clear(B)},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(w){w.setRenderer(this),P=w},this.dispose=function(){t.removeEventListener("webglcontextlost",Pt,!1),t.removeEventListener("webglcontextrestored",vt,!1),t.removeEventListener("webglcontextcreationerror",ai,!1),Ge.dispose(),ue.dispose(),ce.dispose(),H.dispose(),se.dispose(),j.dispose(),ge.dispose(),ee.dispose(),le.dispose(),we.dispose(),we.removeEventListener("sessionstart",Ru),we.removeEventListener("sessionend",Pu),xs.stop()};function Pt(w){w.preventDefault(),Ll("WebGLRenderer: Context Lost."),D=!0}function vt(){Ll("WebGLRenderer: Context Restored."),D=!1;const w=U.autoReset,k=Ue.enabled,X=Ue.autoUpdate,B=Ue.needsUpdate,z=Ue.type;Te(),U.autoReset=w,Ue.enabled=k,Ue.autoUpdate=X,Ue.needsUpdate=B,Ue.type=z}function ai(w){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function ri(w){const k=w.target;k.removeEventListener("dispose",ri),Vg(k)}function Vg(w){Wg(w),H.remove(w)}function Wg(w){const k=H.get(w).programs;k!==void 0&&(k.forEach(function(X){le.releaseProgram(X)}),w.isShaderMaterial&&le.releaseShaderCache(w))}this.renderBufferDirect=function(w,k,X,B,z,me){k===null&&(k=wt);const xe=z.isMesh&&z.matrixWorld.determinantAffine()<0,pe=Yg(w,k,X,B,z);b.setMaterial(B,xe);let Se=X.index,De=1;if(B.wireframe===!0){if(Se=$.getWireframeAttribute(X),Se===void 0)return;De=2}const Ve=X.drawRange,Ye=X.attributes.position;let Ce=Ve.start*De,dt=(Ve.start+Ve.count)*De;me!==null&&(Ce=Math.max(Ce,me.start*De),dt=Math.min(dt,(me.start+me.count)*De)),Se!==null?(Ce=Math.max(Ce,0),dt=Math.min(dt,Se.count)):Ye!=null&&(Ce=Math.max(Ce,0),dt=Math.min(dt,Ye.count));const Ot=dt-Ce;if(Ot<0||Ot===1/0)return;ge.setup(z,B,pe,X,Se);let Lt,pt=re;if(Se!==null&&(Lt=oe.get(Se),pt=J,pt.setIndex(Lt)),z.isMesh)B.wireframe===!0?(b.setLineWidth(B.wireframeLinewidth*Bt()),pt.setMode(N.LINES)):pt.setMode(N.TRIANGLES);else if(z.isLine){let nn=B.linewidth;nn===void 0&&(nn=1),b.setLineWidth(nn*Bt()),z.isLineSegments?pt.setMode(N.LINES):z.isLineLoop?pt.setMode(N.LINE_LOOP):pt.setMode(N.LINE_STRIP)}else z.isPoints?pt.setMode(N.POINTS):z.isSprite&&pt.setMode(N.TRIANGLES);if(z.isBatchedMesh)if(ot.get("WEBGL_multi_draw"))pt.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const nn=z._multiDrawStarts,ye=z._multiDrawCounts,An=z._multiDrawCount,tt=Se?oe.get(Se).bytesPerElement:1,Un=H.get(B).currentProgram.getUniforms();for(let oi=0;oi<An;oi++)Un.setValue(N,"_gl_DrawID",oi),pt.render(nn[oi]/tt,ye[oi])}else if(z.isInstancedMesh)pt.renderInstances(Ce,Ot,z.count);else if(X.isInstancedBufferGeometry){const nn=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,ye=Math.min(X.instanceCount,nn);pt.renderInstances(Ce,Ot,ye)}else pt.render(Ce,Ot)};function Cu(w,k,X){w.transparent===!0&&w.side===Zn&&w.forceSinglePass===!1?(w.side=Vt,w.needsUpdate=!0,ro(w,k,X),w.side=vs,w.needsUpdate=!0,ro(w,k,X),w.side=Zn):ro(w,k,X)}this.compile=function(w,k,X=null){X===null&&(X=w),E=ce.get(X),E.init(k),y.push(E),X.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),w!==X&&w.traverseVisible(function(z){z.isLight&&z.layers.test(k.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),E.setupLights();const B=new Set;return w.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const me=z.material;if(me)if(Array.isArray(me))for(let xe=0;xe<me.length;xe++){const pe=me[xe];Cu(pe,X,z),B.add(pe)}else Cu(me,X,z),B.add(me)}),E=y.pop(),B},this.compileAsync=function(w,k,X=null){const B=this.compile(w,k,X);return new Promise(z=>{function me(){if(B.forEach(function(xe){H.get(xe).currentProgram.isReady()&&B.delete(xe)}),B.size===0){z(w);return}setTimeout(me,10)}ot.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let tc=null;function Xg(w){tc&&tc(w)}function Ru(){xs.stop()}function Pu(){xs.start()}const xs=new Zm;xs.setAnimationLoop(Xg),typeof self<"u"&&xs.setContext(self),this.setAnimationLoop=function(w){tc=w,we.setAnimationLoop(w),w===null?xs.stop():xs.start()},we.addEventListener("sessionstart",Ru),we.addEventListener("sessionend",Pu),this.render=function(w,k){if(k!==void 0&&k.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;P!==null&&P.renderStart(w,k);const X=we.enabled===!0&&we.isPresenting===!0,B=T!==null&&(Z===null||X)&&T.begin(C,Z);if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(we.cameraAutoUpdate===!0&&we.updateCamera(k),k=we.getCamera()),w.isScene===!0&&w.onBeforeRender(C,w,k,Z),E=ce.get(w,y.length),E.init(k),E.state.textureUnits=K.getTextureUnits(),y.push(E),at.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Ne.setFromProjectionMatrix(at,wi,k.reversedDepth),ke=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,ke),M=ue.get(w,I.length),M.init(),I.push(M),we.enabled===!0&&we.isPresenting===!0){const xe=C.xr.getDepthSensingMesh();xe!==null&&nc(xe,k,-1/0,C.sortObjects)}nc(w,k,0,C.sortObjects),M.finish(),C.sortObjects===!0&&M.sort(F,_e,k.reversedDepth),Rt=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,Rt&&Ge.addToRenderList(M,w),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const z=E.state.shadowsArray;if(Ue.render(z,w,k),Oe===!0&&Le.endShadows(),(B&&T.hasRenderPass())===!1){const xe=M.opaque,pe=M.transmissive;if(E.setupLights(),k.isArrayCamera){const Se=k.cameras;if(pe.length>0)for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De];Nu(xe,pe,w,Ye)}Rt&&Ge.render(w);for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De];Lu(M,w,Ye,Ye.viewport)}}else pe.length>0&&Nu(xe,pe,w,k),Rt&&Ge.render(w),Lu(M,w,k)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&T.end(C),w.isScene===!0&&w.onAfterRender(C,w,k),ge.resetDefaultState(),te=-1,Q=null,y.pop(),y.length>0?(E=y[y.length-1],K.setTextureUnits(E.state.textureUnits),Oe===!0&&Le.setGlobalState(C.clippingPlanes,E.state.camera)):E=null,I.pop(),I.length>0?M=I[I.length-1]:M=null,P!==null&&P.renderEnd()};function nc(w,k,X,B){if(w.visible===!1)return;if(w.layers.test(k.layers)){if(w.isGroup)X=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(k);else if(w.isLightProbeGrid)E.pushLightProbeGrid(w);else if(w.isLight)E.pushLight(w),w.castShadow&&E.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||Ne.intersectsSprite(w)){B&&Ct.setFromMatrixPosition(w.matrixWorld).applyMatrix4(at);const xe=j.update(w),pe=w.material;pe.visible&&M.push(w,xe,pe,X,Ct.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||Ne.intersectsObject(w))){const xe=j.update(w),pe=w.material;if(B&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Ct.copy(w.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),Ct.copy(xe.boundingSphere.center)),Ct.applyMatrix4(w.matrixWorld).applyMatrix4(at)),Array.isArray(pe)){const Se=xe.groups;for(let De=0,Ve=Se.length;De<Ve;De++){const Ye=Se[De],Ce=pe[Ye.materialIndex];Ce&&Ce.visible&&M.push(w,xe,Ce,X,Ct.z,Ye)}}else pe.visible&&M.push(w,xe,pe,X,Ct.z,null)}}const me=w.children;for(let xe=0,pe=me.length;xe<pe;xe++)nc(me[xe],k,X,B)}function Lu(w,k,X,B){const{opaque:z,transmissive:me,transparent:xe}=w;E.setupLightsView(X),Oe===!0&&Le.setGlobalState(C.clippingPlanes,X),B&&b.viewport(ie.copy(B)),z.length>0&&ao(z,k,X),me.length>0&&ao(me,k,X),xe.length>0&&ao(xe,k,X),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function Nu(w,k,X,B){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[B.id]===void 0){const Ce=ot.has("EXT_color_buffer_half_float")||ot.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[B.id]=new Tn(1,1,{generateMipmaps:!0,type:Ce?hn:kn,minFilter:Bs,samples:Math.max(4,A.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}const me=E.state.transmissionRenderTarget[B.id],xe=B.viewport||ie;me.setSize(xe.z*C.transmissionResolutionScale,xe.w*C.transmissionResolutionScale);const pe=C.getRenderTarget(),Se=C.getActiveCubeFace(),De=C.getActiveMipmapLevel();C.setRenderTarget(me),C.getClearColor(Je),ze=C.getClearAlpha(),ze<1&&C.setClearColor(16777215,.5),C.clear(),Rt&&Ge.render(X);const Ve=C.toneMapping;C.toneMapping=_i;const Ye=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),E.setupLightsView(B),Oe===!0&&Le.setGlobalState(C.clippingPlanes,B),ao(w,X,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),ot.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let dt=0,Ot=k.length;dt<Ot;dt++){const Lt=k[dt],{object:pt,geometry:nn,material:ye,group:An}=Lt;if(ye.side===Zn&&pt.layers.test(B.layers)){const tt=ye.side;ye.side=Vt,ye.needsUpdate=!0,Ou(pt,X,B,nn,ye,An),ye.side=tt,ye.needsUpdate=!0,Ce=!0}}Ce===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}C.setRenderTarget(pe,Se,De),C.setClearColor(Je,ze),Ye!==void 0&&(B.viewport=Ye),C.toneMapping=Ve}function ao(w,k,X){const B=k.isScene===!0?k.overrideMaterial:null;for(let z=0,me=w.length;z<me;z++){const xe=w[z],{object:pe,geometry:Se,group:De}=xe;let Ve=xe.material;Ve.allowOverride===!0&&B!==null&&(Ve=B),pe.layers.test(X.layers)&&Ou(pe,k,X,Se,Ve,De)}}function Ou(w,k,X,B,z,me){w.onBeforeRender(C,k,X,B,z,me),w.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),z.onBeforeRender(C,k,X,B,w,me),z.transparent===!0&&z.side===Zn&&z.forceSinglePass===!1?(z.side=Vt,z.needsUpdate=!0,C.renderBufferDirect(X,k,B,z,w,me),z.side=vs,z.needsUpdate=!0,C.renderBufferDirect(X,k,B,z,w,me),z.side=Zn):C.renderBufferDirect(X,k,B,z,w,me),w.onAfterRender(C,k,X,B,z,me)}function ro(w,k,X){k.isScene!==!0&&(k=wt);const B=H.get(w),z=E.state.lights,me=E.state.shadowsArray,xe=z.state.version,pe=le.getParameters(w,z.state,me,k,X,E.state.lightProbeGridArray),Se=le.getProgramCacheKey(pe);let De=B.programs;B.environment=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?k.environment:null,B.fog=k.fog;const Ve=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap;B.envMap=se.get(w.envMap||B.environment,Ve),B.envMapRotation=B.environment!==null&&w.envMap===null?k.environmentRotation:w.envMapRotation,De===void 0&&(w.addEventListener("dispose",ri),De=new Map,B.programs=De);let Ye=De.get(Se);if(Ye!==void 0){if(B.currentProgram===Ye&&B.lightsStateVersion===xe)return Uu(w,pe),Ye}else pe.uniforms=le.getUniforms(w),P!==null&&w.isNodeMaterial&&P.build(w,X,pe),w.onBeforeCompile(pe,C),Ye=le.acquireProgram(pe,Se),De.set(Se,Ye),B.uniforms=pe.uniforms;const Ce=B.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(Ce.clippingPlanes=Le.uniform),Uu(w,pe),B.needsLights=$g(w),B.lightsStateVersion=xe,B.needsLights&&(Ce.ambientLightColor.value=z.state.ambient,Ce.lightProbe.value=z.state.probe,Ce.directionalLights.value=z.state.directional,Ce.directionalLightShadows.value=z.state.directionalShadow,Ce.spotLights.value=z.state.spot,Ce.spotLightShadows.value=z.state.spotShadow,Ce.rectAreaLights.value=z.state.rectArea,Ce.ltc_1.value=z.state.rectAreaLTC1,Ce.ltc_2.value=z.state.rectAreaLTC2,Ce.pointLights.value=z.state.point,Ce.pointLightShadows.value=z.state.pointShadow,Ce.hemisphereLights.value=z.state.hemi,Ce.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Ce.spotLightMatrix.value=z.state.spotLightMatrix,Ce.spotLightMap.value=z.state.spotLightMap,Ce.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=E.state.lightProbeGridArray.length>0,B.currentProgram=Ye,B.uniformsList=null,Ye}function ku(w){if(w.uniformsList===null){const k=w.currentProgram.getUniforms();w.uniformsList=gl.seqWithValue(k.seq,w.uniforms)}return w.uniformsList}function Uu(w,k){const X=H.get(w);X.outputColorSpace=k.outputColorSpace,X.batching=k.batching,X.batchingColor=k.batchingColor,X.instancing=k.instancing,X.instancingColor=k.instancingColor,X.instancingMorph=k.instancingMorph,X.skinning=k.skinning,X.morphTargets=k.morphTargets,X.morphNormals=k.morphNormals,X.morphColors=k.morphColors,X.morphTargetsCount=k.morphTargetsCount,X.numClippingPlanes=k.numClippingPlanes,X.numIntersection=k.numClipIntersection,X.vertexAlphas=k.vertexAlphas,X.vertexTangents=k.vertexTangents,X.toneMapping=k.toneMapping}function qg(w,k){if(w.length===0)return null;if(w.length===1)return w[0].texture!==null?w[0]:null;x.setFromMatrixPosition(k.matrixWorld);for(let X=0,B=w.length;X<B;X++){const z=w[X];if(z.texture!==null&&z.boundingBox.containsPoint(x))return z}return null}function Yg(w,k,X,B,z){k.isScene!==!0&&(k=wt),K.resetTextureUnits();const me=k.fog,xe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?k.environment:null,pe=Z===null?C.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Qe.workingColorSpace,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,De=se.get(B.envMap||xe,Se),Ve=B.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ye=!!X.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!X.morphAttributes.position,dt=!!X.morphAttributes.normal,Ot=!!X.morphAttributes.color;let Lt=_i;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Lt=C.toneMapping);const pt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,nn=pt!==void 0?pt.length:0,ye=H.get(B),An=E.state.lights;if(Oe===!0&&(ke===!0||w!==Q)){const yt=w===Q&&B.id===te;Le.setState(B,w,yt)}let tt=!1;B.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==An.state.version||ye.outputColorSpace!==pe||z.isBatchedMesh&&ye.batching===!1||!z.isBatchedMesh&&ye.batching===!0||z.isBatchedMesh&&ye.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&ye.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&ye.instancing===!1||!z.isInstancedMesh&&ye.instancing===!0||z.isSkinnedMesh&&ye.skinning===!1||!z.isSkinnedMesh&&ye.skinning===!0||z.isInstancedMesh&&ye.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&ye.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&ye.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&ye.instancingMorph===!1&&z.morphTexture!==null||ye.envMap!==De||B.fog===!0&&ye.fog!==me||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Le.numPlanes||ye.numIntersection!==Le.numIntersection)||ye.vertexAlphas!==Ve||ye.vertexTangents!==Ye||ye.morphTargets!==Ce||ye.morphNormals!==dt||ye.morphColors!==Ot||ye.toneMapping!==Lt||ye.morphTargetsCount!==nn||!!ye.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,ye.__version=B.version);let Un=ye.currentProgram;tt===!0&&(Un=ro(B,k,z),P&&B.isNodeMaterial&&P.onUpdateProgram(B,Un,ye));let oi=!1,Ji=!1,Js=!1;const mt=Un.getUniforms(),kt=ye.uniforms;if(b.useProgram(Un.program)&&(oi=!0,Ji=!0,Js=!0),B.id!==te&&(te=B.id,Ji=!0),ye.needsLights){const yt=qg(E.state.lightProbeGridArray,z);ye.lightProbeGrid!==yt&&(ye.lightProbeGrid=yt,Ji=!0)}if(oi||Q!==w){b.buffers.depth.getReversed()&&w.reversedDepth!==!0&&(w._reversedDepth=!0,w.updateProjectionMatrix()),mt.setValue(N,"projectionMatrix",w.projectionMatrix),mt.setValue(N,"viewMatrix",w.matrixWorldInverse);const Qi=mt.map.cameraPosition;Qi!==void 0&&Qi.setValue(N,rt.setFromMatrixPosition(w.matrixWorld)),A.logarithmicDepthBuffer&&mt.setValue(N,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&mt.setValue(N,"isOrthographic",w.isOrthographicCamera===!0),Q!==w&&(Q=w,Ji=!0,Js=!0)}if(ye.needsLights&&(An.state.directionalShadowMap.length>0&&mt.setValue(N,"directionalShadowMap",An.state.directionalShadowMap,K),An.state.spotShadowMap.length>0&&mt.setValue(N,"spotShadowMap",An.state.spotShadowMap,K),An.state.pointShadowMap.length>0&&mt.setValue(N,"pointShadowMap",An.state.pointShadowMap,K)),z.isSkinnedMesh){mt.setOptional(N,z,"bindMatrix"),mt.setOptional(N,z,"bindMatrixInverse");const yt=z.skeleton;yt&&(yt.boneTexture===null&&yt.computeBoneTexture(),mt.setValue(N,"boneTexture",yt.boneTexture,K))}z.isBatchedMesh&&(mt.setOptional(N,z,"batchingTexture"),mt.setValue(N,"batchingTexture",z._matricesTexture,K),mt.setOptional(N,z,"batchingIdTexture"),mt.setValue(N,"batchingIdTexture",z._indirectTexture,K),mt.setOptional(N,z,"batchingColorTexture"),z._colorsTexture!==null&&mt.setValue(N,"batchingColorTexture",z._colorsTexture,K));const ji=X.morphAttributes;if((ji.position!==void 0||ji.normal!==void 0||ji.color!==void 0)&&L.update(z,X,Un),(Ji||ye.receiveShadow!==z.receiveShadow)&&(ye.receiveShadow=z.receiveShadow,mt.setValue(N,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&k.environment!==null&&(kt.envMapIntensity.value=k.environmentIntensity),kt.dfgLUT!==void 0&&(kt.dfgLUT.value=gS()),Ji){if(mt.setValue(N,"toneMappingExposure",C.toneMappingExposure),ye.needsLights&&Kg(kt,Js),me&&B.fog===!0&&Ie.refreshFogUniforms(kt,me),Ie.refreshMaterialUniforms(kt,B,ne,ae,E.state.transmissionRenderTarget[w.id]),ye.needsLights&&ye.lightProbeGrid){const yt=ye.lightProbeGrid;kt.probesSH.value=yt.texture,kt.probesMin.value.copy(yt.boundingBox.min),kt.probesMax.value.copy(yt.boundingBox.max),kt.probesResolution.value.copy(yt.resolution)}gl.upload(N,ku(ye),kt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(gl.upload(N,ku(ye),kt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&mt.setValue(N,"center",z.center),mt.setValue(N,"modelViewMatrix",z.modelViewMatrix),mt.setValue(N,"normalMatrix",z.normalMatrix),mt.setValue(N,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const yt=B.uniformsGroups;for(let Qi=0,js=yt.length;Qi<js;Qi++){const Fu=yt[Qi];ee.update(Fu,Un),ee.bind(Fu,Un)}}return Un}function Kg(w,k){w.ambientLightColor.needsUpdate=k,w.lightProbe.needsUpdate=k,w.directionalLights.needsUpdate=k,w.directionalLightShadows.needsUpdate=k,w.pointLights.needsUpdate=k,w.pointLightShadows.needsUpdate=k,w.spotLights.needsUpdate=k,w.spotLightShadows.needsUpdate=k,w.rectAreaLights.needsUpdate=k,w.hemisphereLights.needsUpdate=k}function $g(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(w,k,X){const B=H.get(w);B.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(w.texture).__webglTexture=k,H.get(w.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:X,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,k){const X=H.get(w);X.__webglFramebuffer=k,X.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(w,k=0,X=0){Z=w,W=k,G=X;let B=null,z=!1,me=!1;if(w){const pe=H.get(w);if(pe.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(N.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(w.viewport),de.copy(w.scissor),He=w.scissorTest,b.viewport(ie),b.scissor(de),b.setScissorTest(He),te=-1;return}else if(pe.__webglFramebuffer===void 0)K.setupRenderTarget(w);else if(pe.__hasExternalTextures)K.rebindTextures(w,H.get(w.texture).__webglTexture,H.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const Ve=w.depthTexture;if(pe.__boundDepthTexture!==Ve){if(Ve!==null&&H.has(Ve)&&(w.width!==Ve.image.width||w.height!==Ve.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(w)}}const Se=w.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(me=!0);const De=H.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(De[k])?B=De[k][X]:B=De[k],z=!0):w.samples>0&&K.useMultisampledRTT(w)===!1?B=H.get(w).__webglMultisampledFramebuffer:Array.isArray(De)?B=De[X]:B=De,ie.copy(w.viewport),de.copy(w.scissor),He=w.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),de.copy(Ae).multiplyScalar(ne).floor(),He=be;if(X!==0&&(B=V),b.bindFramebuffer(N.FRAMEBUFFER,B)&&b.drawBuffers(w,B),b.viewport(ie),b.scissor(de),b.setScissorTest(He),z){const pe=H.get(w.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+k,pe.__webglTexture,X)}else if(me){const pe=k;for(let Se=0;Se<w.textures.length;Se++){const De=H.get(w.textures[Se]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Se,De.__webglTexture,X,pe)}}else if(w!==null&&X!==0){const pe=H.get(w.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pe.__webglTexture,X)}te=-1},this.readRenderTargetPixels=function(w,k,X,B,z,me,xe,pe=0){if(!(w&&w.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=H.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se){b.bindFramebuffer(N.FRAMEBUFFER,Se);try{const De=w.textures[pe],Ve=De.format,Ye=De.type;if(w.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!A.textureFormatReadable(Ve)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!A.textureTypeReadable(Ye)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=w.width-B&&X>=0&&X<=w.height-z&&N.readPixels(k,X,B,z,he.convert(Ve),he.convert(Ye),me)}finally{const De=Z!==null?H.get(Z).__webglFramebuffer:null;b.bindFramebuffer(N.FRAMEBUFFER,De)}}},this.readRenderTargetPixelsAsync=async function(w,k,X,B,z,me,xe,pe=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=H.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se)if(k>=0&&k<=w.width-B&&X>=0&&X<=w.height-z){b.bindFramebuffer(N.FRAMEBUFFER,Se);const De=w.textures[pe],Ve=De.format,Ye=De.type;if(w.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!A.textureFormatReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!A.textureTypeReadable(Ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ce=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.bufferData(N.PIXEL_PACK_BUFFER,me.byteLength,N.STREAM_READ),N.readPixels(k,X,B,z,he.convert(Ve),he.convert(Ye),0);const dt=Z!==null?H.get(Z).__webglFramebuffer:null;b.bindFramebuffer(N.FRAMEBUFFER,dt);const Ot=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Vv(N,Ot,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,me),N.deleteBuffer(Ce),N.deleteSync(Ot),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,k=null,X=0){const B=Math.pow(2,-X),z=Math.floor(w.image.width*B),me=Math.floor(w.image.height*B),xe=k!==null?k.x:0,pe=k!==null?k.y:0;K.setTexture2D(w,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,xe,pe,z,me),b.unbindTexture()},this.copyTextureToTexture=function(w,k,X=null,B=null,z=0,me=0){let xe,pe,Se,De,Ve,Ye,Ce,dt,Ot;const Lt=w.isCompressedTexture?w.mipmaps[me]:w.image;if(X!==null)xe=X.max.x-X.min.x,pe=X.max.y-X.min.y,Se=X.isBox3?X.max.z-X.min.z:1,De=X.min.x,Ve=X.min.y,Ye=X.isBox3?X.min.z:0;else{const kt=Math.pow(2,-z);xe=Math.floor(Lt.width*kt),pe=Math.floor(Lt.height*kt),w.isDataArrayTexture?Se=Lt.depth:w.isData3DTexture?Se=Math.floor(Lt.depth*kt):Se=1,De=0,Ve=0,Ye=0}B!==null?(Ce=B.x,dt=B.y,Ot=B.z):(Ce=0,dt=0,Ot=0);const pt=he.convert(k.format),nn=he.convert(k.type);let ye;k.isData3DTexture?(K.setTexture3D(k,0),ye=N.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(K.setTexture2DArray(k,0),ye=N.TEXTURE_2D_ARRAY):(K.setTexture2D(k,0),ye=N.TEXTURE_2D),b.activeTexture(N.TEXTURE0),b.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,k.flipY),b.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),b.pixelStorei(N.UNPACK_ALIGNMENT,k.unpackAlignment);const An=b.getParameter(N.UNPACK_ROW_LENGTH),tt=b.getParameter(N.UNPACK_IMAGE_HEIGHT),Un=b.getParameter(N.UNPACK_SKIP_PIXELS),oi=b.getParameter(N.UNPACK_SKIP_ROWS),Ji=b.getParameter(N.UNPACK_SKIP_IMAGES);b.pixelStorei(N.UNPACK_ROW_LENGTH,Lt.width),b.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Lt.height),b.pixelStorei(N.UNPACK_SKIP_PIXELS,De),b.pixelStorei(N.UNPACK_SKIP_ROWS,Ve),b.pixelStorei(N.UNPACK_SKIP_IMAGES,Ye);const Js=w.isDataArrayTexture||w.isData3DTexture,mt=k.isDataArrayTexture||k.isData3DTexture;if(w.isDepthTexture){const kt=H.get(w),ji=H.get(k),yt=H.get(kt.__renderTarget),Qi=H.get(ji.__renderTarget);b.bindFramebuffer(N.READ_FRAMEBUFFER,yt.__webglFramebuffer),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,Qi.__webglFramebuffer);for(let js=0;js<Se;js++)Js&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(w).__webglTexture,z,Ye+js),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(k).__webglTexture,me,Ot+js)),N.blitFramebuffer(De,Ve,xe,pe,Ce,dt,xe,pe,N.DEPTH_BUFFER_BIT,N.NEAREST);b.bindFramebuffer(N.READ_FRAMEBUFFER,null),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(z!==0||w.isRenderTargetTexture||H.has(w)){const kt=H.get(w),ji=H.get(k);b.bindFramebuffer(N.READ_FRAMEBUFFER,q),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let yt=0;yt<Se;yt++)Js?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,kt.__webglTexture,z,Ye+yt):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,kt.__webglTexture,z),mt?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ji.__webglTexture,me,Ot+yt):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ji.__webglTexture,me),z!==0?N.blitFramebuffer(De,Ve,xe,pe,Ce,dt,xe,pe,N.COLOR_BUFFER_BIT,N.NEAREST):mt?N.copyTexSubImage3D(ye,me,Ce,dt,Ot+yt,De,Ve,xe,pe):N.copyTexSubImage2D(ye,me,Ce,dt,De,Ve,xe,pe);b.bindFramebuffer(N.READ_FRAMEBUFFER,null),b.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else mt?w.isDataTexture||w.isData3DTexture?N.texSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,pt,nn,Lt.data):k.isCompressedArrayTexture?N.compressedTexSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,pt,Lt.data):N.texSubImage3D(ye,me,Ce,dt,Ot,xe,pe,Se,pt,nn,Lt):w.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,me,Ce,dt,xe,pe,pt,nn,Lt.data):w.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,me,Ce,dt,Lt.width,Lt.height,pt,Lt.data):N.texSubImage2D(N.TEXTURE_2D,me,Ce,dt,xe,pe,pt,nn,Lt);b.pixelStorei(N.UNPACK_ROW_LENGTH,An),b.pixelStorei(N.UNPACK_IMAGE_HEIGHT,tt),b.pixelStorei(N.UNPACK_SKIP_PIXELS,Un),b.pixelStorei(N.UNPACK_SKIP_ROWS,oi),b.pixelStorei(N.UNPACK_SKIP_IMAGES,Ji),me===0&&k.generateMipmaps&&N.generateMipmap(ye),b.unbindTexture()},this.initRenderTarget=function(w){H.get(w).__webglFramebuffer===void 0&&K.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?K.setTextureCube(w,0):w.isData3DTexture?K.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?K.setTexture2DArray(w,0):K.setTexture2D(w,0),b.unbindTexture()},this.resetState=function(){W=0,G=0,Z=null,b.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return wi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}const jl=`
5971
5981
  vec3 encodeSrgb(vec3 linear) {
5972
5982
  vec3 clamped = max(linear, vec3(0.0));
5973
5983
  vec3 low = clamped * 12.92;
5974
5984
  vec3 high = 1.055 * pow(clamped, vec3(1.0 / 2.4)) - 0.055;
5975
5985
  return mix(low, high, step(vec3(0.0031308), clamped));
5976
5986
  }
5977
- `;class yS{frameTarget;filmTarget;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);addMaterial;developMaterial;quad;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget=new En(this.width,this.height,{type:cn}),this.filmTarget=new En(this.width,this.height,{type:cn});const n=`
5987
+ `;class yS{frameTarget;filmTarget;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);addMaterial;developMaterial;quad;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget=new Tn(this.width,this.height,{type:hn}),this.filmTarget=new Tn(this.width,this.height,{type:hn});const n=`
5978
5988
  varying vec2 vUv;
5979
5989
  void main() {
5980
5990
  vUv = position.xy * 0.5 + 0.5;
@@ -5988,7 +5998,7 @@ vec3 encodeSrgb(vec3 linear) {
5988
5998
  void main() {
5989
5999
  gl_FragColor = vec4(texture2D(uSource, vUv).rgb * uShare, 1.0);
5990
6000
  }
5991
- `,blending:ti,depthTest:!1,depthWrite:!1}),this.developMaterial=new Nt({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
6001
+ `,blending:ni,depthTest:!1,depthWrite:!1}),this.developMaterial=new Nt({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
5992
6002
  precision highp float;
5993
6003
  ${jl}
5994
6004
  varying vec2 vUv;
@@ -5997,7 +6007,7 @@ vec3 encodeSrgb(vec3 linear) {
5997
6007
  void main() {
5998
6008
  gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
5999
6009
  }
6000
- `,blending:Si,depthTest:!1,depthWrite:!1}),this.quad=new Ze(new Zi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const n=e.getRenderTarget(),i=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),e.render(this.quadScene,this.quadCamera),e.setRenderTarget(n),e.autoClear=i}develop(e,t=1){this.developMaterial.uniforms.uGain.value=t,this.quad.material=this.developMaterial,e.setRenderTarget(null),e.render(this.quadScene,this.quadCamera)}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const Md=Math.PI/180,Np=180/Math.PI;function io(s,e,t){return Math.max(e,Math.min(t,s))}const os=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function qc(s,e,t){return s+(e-s)*t}function Ul(s,e,t){return[qc(s[0],e[0],t),qc(s[1],e[1],t),qc(s[2],e[2],t)]}function Sd(s){const e=Math.max(os[0].altitudeDeg,Math.min(os[os.length-1].altitudeDeg,s));for(let n=0;n<os.length-1;n++){const i=os[n],a=os[n+1];if(e>=i.altitudeDeg&&e<=a.altitudeDeg){const r=(e-i.altitudeDeg)/(a.altitudeDeg-i.altitudeDeg);return{zenith:Ul(i.zenith,a.zenith,r),horizon:Ul(i.horizon,a.horizon,r)}}}const t=os[os.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Op=-18,kp=-4,bS=1.8;function Or(s,e=0){if(s<=Op)return vl+e;if(s>=0)return kp+e;const t=s/Op;return vl-(vl-kp)*(1-t)**bS+e}const Up=-1.5,vl=6.5,xS=1.6;function Yc(s,e=vl){const t=Math.max(e,Up+1),n=(t-s)/(t-Up);return io(n,0,1)**xS}function fn(s,e,t){const n=s*Md,i=e*Md,a=t*Math.cos(n);return{x:a*Math.sin(i),y:t*Math.sin(n),z:-a*Math.cos(i)}}function wS(s,e,t){const n=Math.sqrt(s*s+e*e+t*t),i=n===0?0:Math.asin(io(e/n,-1,1))*Np,a=(Math.atan2(s,-t)*Np+360)%360;return{altitudeDeg:i,azimuthDeg:a}}function MS(s,e){const t=Math.abs(s-e)%360;return t>180?360-t:t}function SS(s,e,t,n){const i=Math.max(0,1-MS(s,t)/_S),a=Math.exp(-Math.max(0,e)/ES),r=n>0?Math.max(0,1-n/TS):Math.max(0,1-Math.abs(n+AS)/IS);return i*a*r}const _S=90,ES=12,TS=8,AS=2,IS=12;function DS(s,e,t,n){const{zenith:i,horizon:a}=Sd(n),r=io((s+90)/180,0,1),o=Ul(a,i,r),l=SS(e,s,t,n);if(l<=0)return o;const c=Sd(n+CS).horizon,h=[Math.max(a[0],c[0]),Math.max(a[1],c[1]),Math.max(a[2],c[2])];return Ul(o,h,l)}const CS=6;function Kc(s){return .12+.88*s}const RS=-4;function PS(s){return Math.max(0,RS-s)}const LS=6,NS=60;function OS(s){return Math.min(NS,LS*Math.sqrt(s))}const kS=3,US=.55;function FS(s){return US*io(s/kS,0,1)}function sg(s){const e=Math.max(s,-4),t=Math.sin(e*Md)+.50572*Math.pow(e+6.07995,-1.6364);return io(1/t,1,40)}function As(s){const e=sg(s)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function BS(s){return HS*(sg(Math.max(s,0))-1)}function zS(s){return Math.pow(10,-.4*BS(s))}const HS=5/37,ag=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function GS(s){return ag.findIndex(e=>s<=e.maxBrightness)}const VS=.25,Fp=.3,WS=2.2;function XS(s,{phase:e,speedFactor:t},n){const a=1+VS*(Fp+(1-Fp)*s)*Math.sin(n*WS*t+e);return Math.min(1,Math.max(0,a))}/**
6010
+ `,blending:Si,depthTest:!1,depthWrite:!1}),this.quad=new Ze(new Zi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const n=e.getRenderTarget(),i=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),e.render(this.quadScene,this.quadCamera),e.setRenderTarget(n),e.autoClear=i}develop(e,t=1){this.developMaterial.uniforms.uGain.value=t,this.quad.material=this.developMaterial,e.setRenderTarget(null),e.render(this.quadScene,this.quadCamera)}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const Md=Math.PI/180,Np=180/Math.PI;function io(s,e,t){return Math.max(e,Math.min(t,s))}const os=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function qc(s,e,t){return s+(e-s)*t}function Ul(s,e,t){return[qc(s[0],e[0],t),qc(s[1],e[1],t),qc(s[2],e[2],t)]}function Sd(s){const e=Math.max(os[0].altitudeDeg,Math.min(os[os.length-1].altitudeDeg,s));for(let n=0;n<os.length-1;n++){const i=os[n],a=os[n+1];if(e>=i.altitudeDeg&&e<=a.altitudeDeg){const r=(e-i.altitudeDeg)/(a.altitudeDeg-i.altitudeDeg);return{zenith:Ul(i.zenith,a.zenith,r),horizon:Ul(i.horizon,a.horizon,r)}}}const t=os[os.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Op=-18,kp=-4,bS=1.8;function Or(s,e=0){if(s<=Op)return vl+e;if(s>=0)return kp+e;const t=s/Op;return vl-(vl-kp)*(1-t)**bS+e}const Up=-1.5,vl=6.5,xS=1.6;function Yc(s,e=vl){const t=Math.max(e,Up+1),n=(t-s)/(t-Up);return io(n,0,1)**xS}function pn(s,e,t){const n=s*Md,i=e*Md,a=t*Math.cos(n);return{x:a*Math.sin(i),y:t*Math.sin(n),z:-a*Math.cos(i)}}function wS(s,e,t){const n=Math.sqrt(s*s+e*e+t*t),i=n===0?0:Math.asin(io(e/n,-1,1))*Np,a=(Math.atan2(s,-t)*Np+360)%360;return{altitudeDeg:i,azimuthDeg:a}}function MS(s,e){const t=Math.abs(s-e)%360;return t>180?360-t:t}function SS(s,e,t,n){const i=Math.max(0,1-MS(s,t)/_S),a=Math.exp(-Math.max(0,e)/ES),r=n>0?Math.max(0,1-n/TS):Math.max(0,1-Math.abs(n+AS)/IS);return i*a*r}const _S=90,ES=12,TS=8,AS=2,IS=12;function DS(s,e,t,n){const{zenith:i,horizon:a}=Sd(n),r=io((s+90)/180,0,1),o=Ul(a,i,r),l=SS(e,s,t,n);if(l<=0)return o;const c=Sd(n+CS).horizon,h=[Math.max(a[0],c[0]),Math.max(a[1],c[1]),Math.max(a[2],c[2])];return Ul(o,h,l)}const CS=6;function Kc(s){return .12+.88*s}const RS=-4;function PS(s){return Math.max(0,RS-s)}const LS=6,NS=60;function OS(s){return Math.min(NS,LS*Math.sqrt(s))}const kS=3,US=.55;function FS(s){return US*io(s/kS,0,1)}function sg(s){const e=Math.max(s,-4),t=Math.sin(e*Md)+.50572*Math.pow(e+6.07995,-1.6364);return io(1/t,1,40)}function As(s){const e=sg(s)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function BS(s){return HS*(sg(Math.max(s,0))-1)}function zS(s){return Math.pow(10,-.4*BS(s))}const HS=5/37,ag=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function GS(s){return ag.findIndex(e=>s<=e.maxBrightness)}const VS=.25,Fp=.3,WS=2.2;function XS(s,{phase:e,speedFactor:t},n){const a=1+VS*(Fp+(1-Fp)*s)*Math.sin(n*WS*t+e);return Math.min(1,Math.max(0,a))}/**
6001
6011
  @preserve
6002
6012
 
6003
6013
  Astronomy library for JavaScript (browser and Node.js).
@@ -6028,11 +6038,11 @@ vec3 encodeSrgb(vec3 linear) {
6028
6038
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
6029
6039
  * @author Don Cross <cosinekitty@gmail.com>
6030
6040
  * @license MIT
6031
- */const wu=173.1446326846693,ks=14959787069098932e-8,ct=.017453292519943295,Bp=.26179938779914946,Ei=57.29577951308232,rg=3.819718634205488,qS=365.24217,zp=new Date("2000-01-01T12:00:00Z"),Ni=2*Math.PI,ls=3600*(180/Math.PI),Pa=484813681109536e-20,og=10800*60,YS=2*og,Hp=7292115e-11,KS=og/Math.PI,$S=-.17-5*Math.log10(KS),_d=.996647180302104,ZS=_d*_d,Ed=6378.1366,JS=Ed/ks,lg=81.30056,Mu=.0002959122082855911,Td=2825345909524226e-22,Ad=8459715185680659e-23,Id=1292024916781969e-23,Dd=1524358900784276e-23;function Fl(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function jt(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function Ma(s){return s-Math.floor(s)}function jS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*n);return i<=-1?180:i>=1?0:Ei*Math.acos(i)}var Me;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Me||(Me={}));const QS=[Me.Star1,Me.Star2,Me.Star3,Me.Star4,Me.Star5,Me.Star6,Me.Star7,Me.Star8],e_=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function t_(s){const e=QS.indexOf(s);return e>=0?e_[e]:null}function Su(s){const e=t_(s);return e&&e.dist>0?e:null}var xn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(xn||(xn={}));const Mi={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function n_(s){var e,t,n,i,a,r,o;const l=2e3+(s-14)/qS;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*i+.022174192*a+.0090316521*r):l<1600?(e=(l-1e3)/100,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*i-.005050998*a+.0083572073*r):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,i=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-i/1174e3):l<1860?(e=l-1800,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,o=n*i,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*i+121272e-10*a-1699e-10*r+875e-12*o):l<1900?(e=l-1860,t=e*e,n=e*t,i=t*t,a=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*i+a/233174):l<1920?(e=l-1900,t=e*e,n=e*t,i=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*i):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-2e3,t=e*e,n=e*t,i=t*t,a=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*i+2373599e-11*a):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let i_=n_;function Gp(s){return s+i_(s)/86400}class za{constructor(e){if(e instanceof za){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-zp.getTime())/t,this.tt=Gp(this.ut);return}if(Number.isFinite(e)){this.date=new Date(zp.getTime()+e*t),this.ut=e,this.tt=Gp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new za(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new za(this.ut+e)}}function Yt(s){return s instanceof za?s:new za(s)}function s_(s){function e(u){return u%YS*Pa}const t=s.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),i=e(335779.526232+t*17395272628478e-4),a=e(107226070369e-5+t*1602961601209e-3),r=e(450160.398036-t*69628905431e-4);let o=Math.sin(r),l=Math.cos(r),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,d=2*(i-a+r);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,d=2*(i+r),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,d=2*r,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function cg(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var qo;function so(s){if(!qo||Math.abs(qo.tt-s.tt)>1e-6){const e=s_(s),t=cg(s),n=t+e.deps/3600;qo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ct)/15,mobl:t,tobl:n}}return qo}function a_(s,e){const t=s*ct,n=Math.cos(t),i=Math.sin(t);return[e[0],e[1]*n-e[2]*i,e[1]*i+e[2]*n]}function r_(s,e){return a_(cg(s),e)}function o_(s){const e=s.tt/36525;function t(Ae,be){const Ne=[];let Oe;for(Oe=0;Oe<=be-Ae;++Oe)Ne.push(0);return{min:Ae,array:Ne}}function n(Ae,be,Ne,Oe){const ke=[];for(let st=0;st<=be-Ae;++st)ke.push(t(Ne,Oe));return{min:Ae,array:ke}}function i(Ae,be,Ne){const Oe=Ae.array[be-Ae.min];return Oe.array[Ne-Oe.min]}function a(Ae,be,Ne,Oe){const ke=Ae.array[be-Ae.min];ke.array[Ne-ke.min]=Oe}let r,o,l,c,h,d,u,f,g,v,p,m,S,_,x,M,E,I,y,T,C,D,P,V=n(-6,6,1,4),q=n(-6,6,1,4);function O(Ae,be){return i(V,Ae,be)}function W(Ae,be){return i(q,Ae,be)}function G(Ae,be,Ne){return a(V,Ae,be,Ne)}function Z(Ae,be,Ne){return a(q,Ae,be,Ne)}function te(Ae,be,Ne,Oe,ke){ke(Ae*Ne-be*Oe,be*Ne+Ae*Oe)}function Q(Ae){return Math.sin(Ni*Ae)}u=e*e,g=0,P=0,p=0,m=3422.7;var ie=Q(.19833+.05611*e),de=Q(.27869+.04508*e),He=Q(.16827-.36903*e),Je=Q(.34734-5.37261*e),ze=Q(.10498-5.37899*e),Y=Q(.42681-.41855*e),ae=Q(.14943-5.37511*e);for(I=.84*ie+.31*de+14.27*He+7.26*Je+.28*ze+.24*Y,y=2.94*ie+.31*de+14.27*He+9.34*Je+1.12*ze+.83*Y,T=-6.4*ie-1.89*Y,C=.21*ie+.31*de+14.27*He-88.7*Je-15.3*ze+.24*Y-1.86*ae,D=I-T,f=-3332e-9*Q(.59734-5.37261*e)-539e-9*Q(.35498-5.37899*e)-64e-9*Q(.39943-5.37511*e),S=Ni*Ma(.60643382+1336.85522467*e-313e-8*u)+I/ls,_=Ni*Ma(.37489701+1325.55240982*e+2565e-8*u)+y/ls,x=Ni*Ma(.99312619+99.99735956*e-44e-8*u)+T/ls,M=Ni*Ma(.25909118+1342.2278298*e-892e-8*u)+C/ls,E=Ni*Ma(.82736186+1236.85308708*e-397e-8*u)+D/ls,h=1;h<=4;++h){switch(h){case 1:l=_,o=4,c=1.000002208;break;case 2:l=x,o=3,c=.997504612-.002495388*e;break;case 3:l=M,o=4,c=1.000002708+139.978*f;break;case 4:l=E,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(l)*c),Z(0,h,0),Z(1,h,Math.sin(l)*c),d=2;d<=o;++d)te(O(d-1,h),W(d-1,h),O(1,h),W(1,h),(Ae,be)=>(G(d,h,Ae),Z(d,h,be)));for(d=1;d<=o;++d)G(-d,h,O(d,h)),Z(-d,h,-W(d,h))}function ne(Ae,be,Ne,Oe){for(var ke={x:1,y:0},st=[0,Ae,be,Ne,Oe],at=1;at<=4;++at)st[at]!==0&&te(ke.x,ke.y,O(st[at],at),W(st[at],at),(Ct,Mt)=>(ke.x=Ct,ke.y=Mt));return ke}function F(Ae,be,Ne,Oe,ke,st,at,Ct){var Mt=ne(ke,st,at,Ct);g+=Ae*Mt.y,P+=be*Mt.y,p+=Ne*Mt.x,m+=Oe*Mt.x}F(13.902,14.06,-.001,.2607,0,0,0,4),F(.403,-4.01,.394,.0023,0,0,0,3),F(2369.912,2373.36,.601,28.2333,0,0,0,2),F(-125.154,-112.79,-.725,-.9781,0,0,0,1),F(1.979,6.98,-.445,.0433,1,0,0,4),F(191.953,192.72,.029,3.0861,1,0,0,2),F(-8.466,-13.51,.455,-.1093,1,0,0,1),F(22639.5,22609.07,.079,186.5398,1,0,0,0),F(18.609,3.59,-.094,.0118,1,0,0,-1),F(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),F(3.215,5.44,.192,-.0386,1,0,0,-3),F(-38.428,-38.64,.001,.6008,1,0,0,-4),F(-.393,-1.43,-.092,.0086,1,0,0,-6),F(-.289,-1.59,.123,-.0053,0,1,0,4),F(-24.42,-25.1,.04,-.3,0,1,0,2),F(18.023,17.93,.007,.1494,0,1,0,1),F(-668.146,-126.98,-1.302,-.3997,0,1,0,0),F(.56,.32,-.001,-.0037,0,1,0,-1),F(-165.145,-165.06,.054,1.9178,0,1,0,-2),F(-1.877,-6.46,-.416,.0339,0,1,0,-4),F(.213,1.02,-.074,.0054,2,0,0,4),F(14.387,14.78,-.017,.2833,2,0,0,2),F(-.586,-1.2,.054,-.01,2,0,0,1),F(769.016,767.96,.107,10.1657,2,0,0,0),F(1.75,2.01,-.018,.0155,2,0,0,-1),F(-211.656,-152.53,5.679,-.3039,2,0,0,-2),F(1.225,.91,-.03,-.0088,2,0,0,-3),F(-30.773,-34.07,-.308,.3722,2,0,0,-4),F(-.57,-1.4,-.074,.0109,2,0,0,-6),F(-2.921,-11.75,.787,-.0484,1,1,0,2),F(1.267,1.52,-.022,.0164,1,1,0,1),F(-109.673,-115.18,.461,-.949,1,1,0,0),F(-205.962,-182.36,2.056,1.4437,1,1,0,-2),F(.233,.36,.012,-.0025,1,1,0,-3),F(-4.391,-9.66,-.471,.0673,1,1,0,-4),F(.283,1.53,-.111,.006,1,-1,0,4),F(14.577,31.7,-1.54,.2302,1,-1,0,2),F(147.687,138.76,.679,1.1528,1,-1,0,0),F(-1.089,.55,.021,0,1,-1,0,-1),F(28.475,23.59,-.443,-.2257,1,-1,0,-2),F(-.276,-.38,-.006,-.0036,1,-1,0,-3),F(.636,2.27,.146,-.0102,1,-1,0,-4),F(-.189,-1.68,.131,-.0028,0,2,0,2),F(-7.486,-.66,-.037,-.0086,0,2,0,0),F(-8.096,-16.35,-.74,.0918,0,2,0,-2),F(-5.741,-.04,0,-9e-4,0,0,2,2),F(.255,0,0,0,0,0,2,1),F(-411.608,-.2,0,-.0124,0,0,2,0),F(.584,.84,0,.0071,0,0,2,-1),F(-55.173,-52.14,0,-.1052,0,0,2,-2),F(.254,.25,0,-.0017,0,0,2,-3),F(.025,-1.67,0,.0031,0,0,2,-4),F(1.06,2.96,-.166,.0243,3,0,0,2),F(36.124,50.64,-1.3,.6215,3,0,0,0),F(-13.193,-16.4,.258,-.1187,3,0,0,-2),F(-1.187,-.74,.042,.0074,3,0,0,-4),F(-.293,-.31,-.002,.0046,3,0,0,-6),F(-.29,-1.45,.116,-.0051,2,1,0,2),F(-7.649,-10.56,.259,-.1038,2,1,0,0),F(-8.627,-7.59,.078,-.0192,2,1,0,-2),F(-2.74,-2.54,.022,.0324,2,1,0,-4),F(1.181,3.32,-.212,.0213,2,-1,0,2),F(9.703,11.67,-.151,.1268,2,-1,0,0),F(-.352,-.37,.001,-.0028,2,-1,0,-1),F(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),F(.36,.2,-.012,-.0043,2,-1,0,-4),F(-1.167,-1.25,.008,-.0106,1,2,0,0),F(-7.412,-6.12,.117,.0484,1,2,0,-2),F(-.311,-.65,-.032,.0044,1,2,0,-4),F(.757,1.82,-.105,.0112,1,-2,0,2),F(2.58,2.32,.027,.0196,1,-2,0,0),F(2.533,2.4,-.014,-.0212,1,-2,0,-2),F(-.344,-.57,-.025,.0036,0,3,0,-2),F(-.992,-.02,0,0,1,0,2,2),F(-45.099,-.02,0,-.001,1,0,2,0),F(-.179,-9.52,0,-.0833,1,0,2,-2),F(-.301,-.33,0,.0014,1,0,2,-4),F(-6.382,-3.37,0,-.0481,1,0,-2,2),F(39.528,85.13,0,-.7136,1,0,-2,0),F(9.366,.71,0,-.0112,1,0,-2,-2),F(.202,.02,0,0,1,0,-2,-4),F(.415,.1,0,.0013,0,1,2,0),F(-2.152,-2.26,0,-.0066,0,1,2,-2),F(-1.44,-1.3,0,.0014,0,1,-2,2),F(.384,-.04,0,0,0,1,-2,-2),F(1.938,3.6,-.145,.0401,4,0,0,0),F(-.952,-1.58,.052,-.013,4,0,0,-2),F(-.551,-.94,.032,-.0097,3,1,0,0),F(-.482,-.57,.005,-.0045,3,1,0,-2),F(.681,.96,-.026,.0115,3,-1,0,0),F(-.297,-.27,.002,-9e-4,2,2,0,-2),F(.254,.21,-.003,0,2,-2,0,-2),F(-.25,-.22,.004,.0014,1,3,0,-2),F(-3.996,0,0,4e-4,2,0,2,0),F(.557,-.75,0,-.009,2,0,2,-2),F(-.459,-.38,0,-.0053,2,0,-2,2),F(-1.298,.74,0,4e-4,2,0,-2,0),F(.538,1.14,0,-.0141,2,0,-2,-2),F(.263,.02,0,0,1,1,2,0),F(.426,.07,0,-6e-4,1,1,-2,-2),F(-.304,.03,0,3e-4,1,-1,2,0),F(-.372,-.19,0,-.0027,1,-1,-2,2),F(.418,0,0,0,0,0,4,0),F(-.33,-.04,0,0,3,0,2,0);function _e(Ae,be,Ne,Oe,ke){return Ae*ne(be,Ne,Oe,ke).y}v=0,v+=_e(-526.069,0,0,1,-2),v+=_e(-3.352,0,0,1,-4),v+=_e(44.297,1,0,1,-2),v+=_e(-6,1,0,1,-4),v+=_e(20.599,-1,0,1,0),v+=_e(-30.598,-1,0,1,-2),v+=_e(-24.649,-2,0,1,0),v+=_e(-2,-2,0,1,-2),v+=_e(-22.571,0,1,1,-2),v+=_e(10.985,0,-1,1,-2),g+=.82*Q(.7736-62.5512*e)+.31*Q(.0466-125.1025*e)+.35*Q(.5785-25.1042*e)+.66*Q(.4591+1335.8075*e)+.64*Q(.313-91.568*e)+1.14*Q(.148+1331.2898*e)+.21*Q(.5918+1056.5859*e)+.44*Q(.5784+1322.8595*e)+.24*Q(.2275-5.7374*e)+.28*Q(.2965+2.6929*e)+.33*Q(.3132+6.3368*e),r=M+P/ls;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+p)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:Ni*Ma((S+g/ls)/Ni),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:ls*JS/(.999953253*m)}}function hg(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function Bl(s,e,t){const n=dg(e,t);return hg(n,s)}function dg(s,e){const t=s.tt/36525;let n=84381.406,i=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,a=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,r=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Pa,i*=Pa,a*=Pa,r*=Pa;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-i),h=Math.cos(-i),d=Math.sin(-a),u=Math.cos(-a),f=Math.sin(r),g=Math.cos(r),v=g*h-c*f*u,p=g*c*l+f*u*h*l-o*f*d,m=g*c*o+f*u*h*o+l*f*d,S=-f*h-c*g*u,_=-f*c*l+g*u*h*l-o*g*d,x=-f*c*o+g*u*h*o+l*g*d,M=c*d,E=-d*h*l-o*u,I=-d*h*o+u*l;if(e===xn.Into2000)return new ys([[v,p,m],[S,_,x],[M,E,I]]);if(e===xn.From2000)return new ys([[v,S,M],[p,_,E],[m,x,I]]);throw"Invalid precess direction"}function l_(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Yo;function _u(s){if(!Yo||Yo.tt!==s.tt){const e=s.tt/36525;let t=15*so(s).ee;const n=l_(s);let a=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;a<0&&(a+=24),Yo={tt:s.tt,st:a}}return Yo.st}function ug(s,e){const t=s.latitude*ct,n=Math.sin(t),i=Math.cos(t),a=1/Math.hypot(i,_d*n),r=ZS*a,o=s.height/1e3,l=Ed*a+o,c=Ed*r+o,h=(15*e+s.longitude)*ct,d=Math.sin(h),u=Math.cos(h);return{pos:[l*i*u/ks,l*i*d/ks,c*n/ks],vel:[-Hp*l*i*d*86400/ks,Hp*l*i*u*86400/ks,0]}}function Cd(s,e,t){const n=fg(e,t);return hg(n,s)}function fg(s,e){const t=so(s),n=t.mobl*ct,i=t.tobl*ct,a=t.dpsi*Pa,r=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(a),d=Math.sin(a),u=h,f=-d*r,g=-d*o,v=d*l,p=h*r*l+o*c,m=h*o*l-r*c,S=d*c,_=h*r*c-o*l,x=h*o*c+r*l;if(e===xn.From2000)return new ys([[u,v,S],[f,p,_],[g,m,x]]);if(e===xn.Into2000)return new ys([[u,f,g],[v,p,m],[S,_,x]]);throw"Invalid precess direction"}function Eu(s,e,t){return t===xn.Into2000?Bl(Cd(s,e,t),e,t):Cd(Bl(s,e,t),e,t)}function c_(s,e){const t=_u(s),n=ug(e,t).pos;return Eu(n,s,xn.Into2000)}class wt{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class ps{constructor(e,t,n,i,a,r,o){this.x=e,this.y=t,this.z=n,this.vx=i,this.vy=a,this.vz=r,this.t=o}}class Tu{constructor(e,t,n){this.lat=jt(e),this.lon=jt(t),this.dist=jt(n)}}class Rd{constructor(e,t,n,i){this.ra=jt(e),this.dec=jt(t),this.dist=jt(n),this.vec=i}}class ys{constructor(e){this.rot=e}}class h_{constructor(e,t,n,i){this.azimuth=jt(e),this.altitude=jt(t),this.ra=jt(n),this.dec=jt(i)}}class d_{constructor(e,t,n){this.vec=e,this.elat=jt(t),this.elon=jt(n)}}function pg(s,e){return new wt(s[0],s[1],s[2],e)}function u_(s,e){const t=pg(s,e),n=t.x*t.x+t.y*t.y,i=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Rd(0,t.z<0?-90:90,i,t)}let a=rg*Math.atan2(t.y,t.x);a<0&&(a+=24);const r=Ei*Math.atan2(s[2],Math.sqrt(n));return new Rd(a,r,i,t)}function $c(s,e){const t=s*ct,n=Math.cos(t),i=Math.sin(t);return[n*e[0]+i*e[1],n*e[1]-i*e[0],e[2]]}function mg(s,e,t,n,i){let a=Yt(s);Au(e),jt(t),jt(n);const r=Math.sin(e.latitude*ct),o=Math.cos(e.latitude*ct),l=Math.sin(e.longitude*ct),c=Math.cos(e.longitude*ct),h=Math.sin(n*ct),d=Math.cos(n*ct),u=Math.sin(t*Bp),f=Math.cos(t*Bp);let g=[o*c,o*l,r],v=[-r*c,-r*l,o],p=[l,-c,0];const m=-15*_u(a);let S=$c(m,g),_=$c(m,v),x=$c(m,p),M=[d*f,d*u,h];const E=M[0]*S[0]+M[1]*S[1]+M[2]*S[2],I=M[0]*_[0]+M[1]*_[1]+M[2]*_[2],y=M[0]*x[0]+M[1]*x[1]+M[2]*x[2];let T=Math.hypot(I,y),C;T>0?(C=-Ei*Math.atan2(y,I),C<0&&(C+=360)):C=0;let D=Ei*Math.atan2(T,E),P=t,V=n;if(i){let q=D,O=k_(i,90-D);if(D-=O,O>0&&D>3e-4){const W=Math.sin(D*ct),G=Math.cos(D*ct),Z=Math.sin(q*ct),te=Math.cos(q*ct),Q=[];for(let ie=0;ie<3;++ie)Q.push((M[ie]-te*S[ie])/Z*W+S[ie]*G);T=Math.hypot(Q[0],Q[1]),T>0?(P=rg*Math.atan2(Q[1],Q[0]),P<0&&(P+=24)):P=0,V=Ei*Math.atan2(Q[2],T)}}return new h_(C,90-D,P,V)}function Au(s){if(!(s instanceof Iu))throw`Not an instance of the Observer class: ${s}`;if(jt(s.latitude),jt(s.longitude),jt(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Iu{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Au(this)}}function f_(s){const e=Yt(s).AddDays(-1/wu),t=Ga(Mi.Earth,e),n=[-t.x,-t.y,-t.z],[i,a,r]=Eu(n,e,xn.From2000),o=ct*so(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new wt(i,a,r,e);return gg(h,l,c)}function p_(s,e,t,n,i){Au(t),Fl(n),Fl(i);const a=Yt(e),r=c_(a,t),o=Hd(s,a,i),l=[o.x-r[0],o.y-r[1],o.z-r[2]],c=Eu(l,a,xn.From2000);return u_(c,a)}function m_(s,e,t){const n=Yt(s),i=_u(n);let a=ug(e,i).pos;return pg(a,n)}function gg(s,e,t){const n=s.x,i=s.y*e+s.z*t,a=-s.y*t+s.z*e,r=Math.hypot(n,i);let o=0;r>0&&(o=Ei*Math.atan2(i,n),o<0&&(o+=360));let l=Ei*Math.atan2(a,r),c=new wt(n,i,a,s.t);return new d_(c,l,o)}function Pd(s){const e=so(s.t),t=[s.x,s.y,s.z],n=Bl(t,s.t,xn.From2000),[i,a,r]=Cd(n,s.t,xn.From2000),o=new wt(i,a,r,s.t),l=e.tobl*ct;return gg(o,Math.cos(l),Math.sin(l))}function er(s){const e=Yt(s),t=o_(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),i=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],a=r_(e,i),r=Bl(a,e,xn.Into2000);return new wt(r[0],r[1],r[2],e)}function vg(s){const e=Yt(s),t=1e-5,n=e.AddDays(-t),i=e.AddDays(+t),a=er(n),r=er(i);return new ps((a.x+r.x)/2,(a.y+r.y)/2,(a.z+r.z)/2,(r.x-a.x)/(2*t),(r.y-a.y)/(2*t),(r.z-a.z)/(2*t),e)}function g_(s){const e=Yt(s),t=vg(e),n=1+lg;return new ps(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Ha(s,e,t){let n=1,i=0;for(let a of s){let r=0;for(let[l,c,h]of a)r+=l*Math.cos(c+e*h);let o=n*r;t&&(o%=Ni),i+=o,n*=e}return i}function Zc(s,e){let t=1,n=0,i=0,a=0;for(let r of s){let o=0,l=0;for(let[c,h,d]of r){let u=h+e*d;o+=c*d*Math.sin(u),a>0&&(l+=c*Math.cos(u))}i+=a*n*l-t*o,n=t,t*=e,++a}return i}const Dr=365250,Ld=0,Nd=1,Od=2;function kd(s){return new rn(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function yg(s,e,t){const n=t*Math.cos(e),i=Math.cos(s),a=Math.sin(s);return[n*i,n*a,t*Math.sin(e)]}function Ga(s,e){const t=e.tt/Dr,n=Ha(s[Ld],t,!0),i=Ha(s[Nd],t,!1),a=Ha(s[Od],t,!1),r=yg(n,i,a);return kd(r).ToAstroVector(e)}function Ud(s,e){const t=e/Dr,n=Ha(s[Ld],t,!0),i=Ha(s[Nd],t,!1),a=Ha(s[Od],t,!1),r=Zc(s[Ld],t),o=Zc(s[Nd],t),l=Zc(s[Od],t),c=Math.cos(n),h=Math.sin(n),d=Math.cos(i),u=Math.sin(i),f=+(l*d*c)-a*u*c*o-a*d*h*r,g=+(l*d*h)-a*u*h*o+a*d*c*r,v=+(l*u)+a*d*o,p=yg(n,i,a),m=[f/Dr,g/Dr,v/Dr],S=kd(p),_=kd(m);return new $s(e,S,_)}function Ko(s,e,t,n){const i=n/(n+Mu),a=Ga(Mi[t],e);s.x+=i*a.x,s.y+=i*a.y,s.z+=i*a.z}function v_(s){const e=new wt(0,0,0,s);return Ko(e,s,Me.Jupiter,Td),Ko(e,s,Me.Saturn,Ad),Ko(e,s,Me.Uranus,Id),Ko(e,s,Me.Neptune,Dd),e}const Fd=51,y_=29200,La=146,Oi=201,Hs=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class rn{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new rn(this.x,this.y,this.z)}ToAstroVector(e){return new wt(this.x,this.y,this.z,e)}static zero(){return new rn(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new rn(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new rn(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new rn(e*this.x,e*this.y,e*this.z)}div(e){return new rn(this.x/e,this.y/e,this.z/e)}mean(e){return new rn((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new rn(-this.x,-this.y,-this.z)}}class $s{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new $s(this.tt,this.r,this.v)}sub(e){return new $s(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function b_(s){let[e,[t,n,i],[a,r,o]]=s;return new $s(e,new rn(t,n,i),new rn(a,r,o))}function $o(s,e,t,n){const i=n/(n+Mu),a=Ud(Mi[t],e);return s.r.incr(a.r.mul(i)),s.v.incr(a.v.mul(i)),a}function xr(s,e,t){const n=t.sub(s),i=n.quadrature();return n.mul(e/(i*Math.sqrt(i)))}class Ql{constructor(e){let t=new $s(e,new rn(0,0,0),new rn(0,0,0));this.Jupiter=$o(t,e,Me.Jupiter,Td),this.Saturn=$o(t,e,Me.Saturn,Ad),this.Uranus=$o(t,e,Me.Uranus,Id),this.Neptune=$o(t,e,Me.Neptune,Dd),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new $s(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=xr(e,Mu,this.Sun.r);return t.incr(xr(e,Td,this.Jupiter.r)),t.incr(xr(e,Ad,this.Saturn.r)),t.incr(xr(e,Id,this.Uranus.r)),t.incr(xr(e,Dd,this.Neptune.r)),t}}class ec{constructor(e,t,n,i){this.tt=e,this.r=t,this.v=n,this.a=i}clone(){return new ec(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class bg{constructor(e,t){this.bary=e,this.grav=t}}function zl(s,e,t,n){return new rn(e.x+s*(t.x+s*n.x/2),e.y+s*(t.y+s*n.y/2),e.z+s*(t.z+s*n.z/2))}function Vp(s,e,t){return new rn(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Bd(s,e){const t=s-e.tt,n=new Ql(s),i=zl(t,e.r,e.v,e.a),a=n.Acceleration(i).mean(e.a),r=zl(t,e.r,e.v,a),o=e.v.add(a.mul(t)),l=n.Acceleration(r),c=new ec(s,r,o,l);return new bg(n,c)}const x_=[];function xg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function zd(s){const e=b_(s),t=new Ql(e.tt),n=e.r.add(t.Sun.r),i=e.v.add(t.Sun.v),a=t.Acceleration(n),r=new ec(e.tt,n,i,a);return new bg(t,r)}function w_(s,e){const t=Hs[0][0];if(e<t||e>Hs[Fd-1][0])return null;const n=xg((e-t)/y_,Fd-1);if(!s[n]){const a=s[n]=[];a[0]=zd(Hs[n]).grav,a[Oi-1]=zd(Hs[n+1]).grav;let r,o=a[0].tt;for(r=1;r<Oi-1;++r)a[r]=Bd(o+=La,a[r-1]).grav;o=a[Oi-1].tt;var i=[];for(i[Oi-1]=a[Oi-1],r=Oi-2;r>0;--r)i[r]=Bd(o-=La,i[r+1]).grav;for(r=Oi-2;r>0;--r){const l=r/(Oi-1);a[r].r=a[r].r.mul(1-l).add(i[r].r.mul(l)),a[r].v=a[r].v.mul(1-l).add(i[r].v.mul(l)),a[r].a=a[r].a.mul(1-l).add(i[r].a.mul(l))}}return s[n]}function Wp(s,e,t){let n=zd(s);const i=Math.ceil((e-n.grav.tt)/t);for(let a=0;a<i;++a)n=Bd(a+1===i?e:n.grav.tt+t,n.grav);return n}function wg(s,e){let t,n,i;const a=w_(x_,s.tt);if(a){const r=xg((s.tt-a[0].tt)/La,Oi-1),o=a[r],l=a[r+1],c=o.a.mean(l.a),h=zl(s.tt-o.tt,o.r,o.v,c),d=Vp(s.tt-o.tt,o.v,c),u=zl(s.tt-l.tt,l.r,l.v,c),f=Vp(s.tt-l.tt,l.v,c),g=(s.tt-o.tt)/La;t=h.mul(1-g).add(u.mul(g)),n=d.mul(1-g).add(f.mul(g))}else{let r;s.tt<Hs[0][0]?r=Wp(Hs[0],s.tt,-La):r=Wp(Hs[Fd-1],s.tt,+La),t=r.grav.r,n=r.grav.v,i=r.bary}return i||(i=new Ql(s.tt)),t=t.sub(i.Sun.r),n=n.sub(i.Sun.v),new ps(t.x,t.y,t.z,n.x,n.y,n.z,s)}function gs(s,e){var t=Yt(e);if(s in Mi)return Ga(Mi[s],t);if(s===Me.Pluto){const r=wg(t);return new wt(r.x,r.y,r.z,t)}if(s===Me.Sun)return new wt(0,0,0,t);if(s===Me.Moon){var n=Ga(Mi.Earth,t),i=er(t);return new wt(n.x+i.x,n.y+i.y,n.z+i.z,t)}if(s===Me.EMB){const r=Ga(Mi.Earth,t),o=er(t),l=1+lg;return new wt(r.x+o.x/l,r.y+o.y/l,r.z+o.z/l,t)}if(s===Me.SSB)return v_(t);const a=Su(s);if(a){const r=new Tu(a.dec,15*a.ra,a.dist);return Sg(r,t)}throw`HelioVector: Unknown body "${s}"`}function M_(s,e){let t=e,n=0;for(let i=0;i<10;++i){const a=s(t),r=a.Length()/wu;if(r>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-r);if(n=Math.abs(o.tt-t.tt),n<1e-9)return a;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class S_{constructor(e,t,n,i){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=i}Position(e){this.aberration&&(this.observerPos=gs(this.observerBody,e));const t=gs(this.targetBody,e);return new wt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function __(s,e,t,n){Fl(n);const i=Yt(s);if(Su(t)){const o=gs(t,i);if(n){const c=T_(e,i),h=new wt(o.x-c.x,o.y-c.y,o.z-c.z,i),d=wu/h.Length();return new wt(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,i)}const l=gs(e,i);return new wt(o.x-l.x,o.y-l.y,o.z-l.z,i)}let a;n?a=new wt(0,0,0,i):a=gs(e,i);const r=new S_(e,t,n,a);return M_(o=>r.Position(o),i)}function Hd(s,e,t){Fl(t);const n=Yt(e);switch(s){case Me.Earth:return new wt(0,0,0,n);case Me.Moon:return er(n);default:const i=__(n,Me.Earth,s,t);return i.t=n,i}}function E_(s,e){return new ps(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function T_(s,e){const t=Yt(e);switch(s){case Me.Sun:return new ps(0,0,0,0,0,0,t);case Me.SSB:const n=new Ql(t.tt);return new ps(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Me.Mercury:case Me.Venus:case Me.Earth:case Me.Mars:case Me.Jupiter:case Me.Saturn:case Me.Uranus:case Me.Neptune:const i=Ud(Mi[s],t.tt);return E_(i,t);case Me.Pluto:return wg(t);case Me.Moon:case Me.EMB:const a=Ud(Mi.Earth,t.tt),r=s==Me.Moon?vg(t):g_(t);return new ps(r.x+a.r.x,r.y+a.r.y,r.z+a.r.z,r.vx+a.v.x,r.vy+a.v.y,r.vz+a.v.z,t);default:if(Su(s)){const o=gs(s,t);return new ps(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function A_(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function I_(s,e,t){if(s===Me.Earth||e===Me.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Yt(t),i=Hd(s,n,!1),a=Pd(i),r=Hd(e,n,!1),o=Pd(r);return A_(a.elon-o.elon)}function D_(s,e,t,n){let i,a=0,r=0,o=0;switch(s){case Me.Mercury:i=-.6,a=4.98,r=-4.88,o=3.02;break;case Me.Venus:e<163.6?(i=-4.47,a=1.03,r=.57,o=.13):(i=.98,a=-1.02);break;case Me.Mars:i=-1.52,a=1.6;break;case Me.Jupiter:i=-9.4,a=.5;break;case Me.Uranus:i=-7.19,a=.25;break;case Me.Neptune:i=-6.87;break;case Me.Pluto:i=-1,a=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const l=e/100;let c=i+l*(a+l*(r+l*o));return c+=5*Math.log10(t*n),c}function C_(s,e,t,n,i){const a=Pd(n),r=ct*28.06,o=ct*(169.51+382e-7*i.tt),l=ct*a.elat,c=ct*a.elon,h=Math.asin(Math.sin(l)*Math.cos(r)-Math.cos(l)*Math.sin(r)*Math.sin(c-o)),d=Math.sin(Math.abs(h));let u=-9+.044*s;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:Ei*h}}function R_(s,e,t){let n=s*ct,i=n*n,a=i*i,r=-12.717+1.49*Math.abs(n)+.0431*a;const o=385000.6/ks;let l=t/o;return r+=5*Math.log10(e*l),r}class P_{constructor(e,t,n,i,a,r,o,l){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=i,this.geo_dist=a,this.gc=r,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(ct*n))/2}}function Mg(s,e){if(s===Me.Earth)throw"The illumination of the Earth is not defined.";const t=Yt(e),n=Ga(Mi.Earth,t);let i,a,r,o;s===Me.Sun?(r=new wt(-n.x,-n.y,-n.z,t),a=new wt(0,0,0,t),i=0):(s===Me.Moon?(r=er(t),a=new wt(n.x+r.x,n.y+r.y,n.z+r.z,t)):(a=gs(s,e),r=new wt(a.x-n.x,a.y-n.y,a.z-n.z,t)),i=jS(r,a));let l=r.Length(),c=a.Length(),h;if(s===Me.Sun)o=$S+5*Math.log10(l);else if(s===Me.Moon)o=R_(i,c,l);else if(s===Me.Saturn){const d=C_(i,c,l,r,t);o=d.mag,h=d.ring_tilt}else o=D_(s,i,c,l);return new P_(t,o,i,c,l,r,a,h)}function L_(s){return I_(Me.Moon,Me.Sun,s)}var Xp;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Xp||(Xp={}));function N_(s,e){return new ys([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Sg(s,e){e=Yt(e);const t=s.lat*ct,n=s.lon*ct,i=s.dist*Math.cos(t);return new wt(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(t),e)}function _g(s){const e=O_(s);return new Rd(e.lon/15,e.lat,e.dist,s)}function O_(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let n,i;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=Ei*Math.atan2(s.y,s.x),i<0&&(i+=360),n=Ei*Math.atan2(s.z,Math.sqrt(e));return new Tu(n,i,t)}function k_(s,e){let t;if(jt(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*ct)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function yl(s,e){return new wt(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function U_(){return new ys([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function F_(){return new ys([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function B_(s){s=Yt(s);const e=dg(s,xn.From2000),t=fg(s,xn.From2000);return N_(e,t)}function z_(s){const t=so(Yt(s)).tobl*ct,n=Math.cos(t),i=Math.sin(t);return new ys([[1,0,0],[0,+n,+i],[0,-i,+n]])}var qp;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(qp||(qp={}));var Yp;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Yp||(Yp={}));const H_=["Venus","Mars","Jupiter","Saturn"];function Eg(s){return new Iu(s.lat,s.lng,s.elevationM)}function tr(s,e,t,n,i=!0){const a=mg(t,Eg(n),s,e,i?"normal":void 0);return{altitudeDeg:a.altitude,azimuthDeg:a.azimuth}}function On(s,e,t){const n=Eg(t),i=p_(Me[s],e,n,!0,!0),a=mg(e,n,i.ra,i.dec,"normal");return{altitudeDeg:a.altitude,azimuthDeg:a.azimuth}}function Jc(s,e){return Mg(Me[s],e).mag}function Hl(s){const e=L_(s),t=Mg(Me.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const G_=2e3,V_=3,W_=20;function Va(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??G_,a=s.month??(n?1:V_),r=s.day??(n?1:W_),o=t??Math.round(e/15);return new Date(Date.UTC(i,a-1,r,(s.hour??12)-o,s.minute??0,s.second??0))}class Us{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Us.patch(t.fragmentShader)}}static patch(e){return e.replace(Us.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
6041
+ */const wu=173.1446326846693,ks=14959787069098932e-8,ht=.017453292519943295,Bp=.26179938779914946,Ei=57.29577951308232,rg=3.819718634205488,qS=365.24217,zp=new Date("2000-01-01T12:00:00Z"),Ni=2*Math.PI,ls=3600*(180/Math.PI),Pa=484813681109536e-20,og=10800*60,YS=2*og,Hp=7292115e-11,KS=og/Math.PI,$S=-.17-5*Math.log10(KS),_d=.996647180302104,ZS=_d*_d,Ed=6378.1366,JS=Ed/ks,lg=81.30056,Mu=.0002959122082855911,Td=2825345909524226e-22,Ad=8459715185680659e-23,Id=1292024916781969e-23,Dd=1524358900784276e-23;function Fl(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function jt(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function Ma(s){return s-Math.floor(s)}function jS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*n);return i<=-1?180:i>=1?0:Ei*Math.acos(i)}var Me;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Me||(Me={}));const QS=[Me.Star1,Me.Star2,Me.Star3,Me.Star4,Me.Star5,Me.Star6,Me.Star7,Me.Star8],e_=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function t_(s){const e=QS.indexOf(s);return e>=0?e_[e]:null}function Su(s){const e=t_(s);return e&&e.dist>0?e:null}var xn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(xn||(xn={}));const Mi={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function n_(s){var e,t,n,i,a,r,o;const l=2e3+(s-14)/qS;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*i+.022174192*a+.0090316521*r):l<1600?(e=(l-1e3)/100,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*i-.005050998*a+.0083572073*r):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,i=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-i/1174e3):l<1860?(e=l-1800,t=e*e,n=e*t,i=t*t,a=t*n,r=n*n,o=n*i,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*i+121272e-10*a-1699e-10*r+875e-12*o):l<1900?(e=l-1860,t=e*e,n=e*t,i=t*t,a=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*i+a/233174):l<1920?(e=l-1900,t=e*e,n=e*t,i=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*i):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-2e3,t=e*e,n=e*t,i=t*t,a=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*i+2373599e-11*a):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let i_=n_;function Gp(s){return s+i_(s)/86400}class za{constructor(e){if(e instanceof za){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-zp.getTime())/t,this.tt=Gp(this.ut);return}if(Number.isFinite(e)){this.date=new Date(zp.getTime()+e*t),this.ut=e,this.tt=Gp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new za(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new za(this.ut+e)}}function Yt(s){return s instanceof za?s:new za(s)}function s_(s){function e(u){return u%YS*Pa}const t=s.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),i=e(335779.526232+t*17395272628478e-4),a=e(107226070369e-5+t*1602961601209e-3),r=e(450160.398036-t*69628905431e-4);let o=Math.sin(r),l=Math.cos(r),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,d=2*(i-a+r);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,d=2*(i+r),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,d=2*r,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function cg(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var qo;function so(s){if(!qo||Math.abs(qo.tt-s.tt)>1e-6){const e=s_(s),t=cg(s),n=t+e.deps/3600;qo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ht)/15,mobl:t,tobl:n}}return qo}function a_(s,e){const t=s*ht,n=Math.cos(t),i=Math.sin(t);return[e[0],e[1]*n-e[2]*i,e[1]*i+e[2]*n]}function r_(s,e){return a_(cg(s),e)}function o_(s){const e=s.tt/36525;function t(Ae,be){const Ne=[];let Oe;for(Oe=0;Oe<=be-Ae;++Oe)Ne.push(0);return{min:Ae,array:Ne}}function n(Ae,be,Ne,Oe){const ke=[];for(let at=0;at<=be-Ae;++at)ke.push(t(Ne,Oe));return{min:Ae,array:ke}}function i(Ae,be,Ne){const Oe=Ae.array[be-Ae.min];return Oe.array[Ne-Oe.min]}function a(Ae,be,Ne,Oe){const ke=Ae.array[be-Ae.min];ke.array[Ne-ke.min]=Oe}let r,o,l,c,h,d,u,f,g,v,p,m,S,_,x,M,E,I,y,T,C,D,P,V=n(-6,6,1,4),q=n(-6,6,1,4);function O(Ae,be){return i(V,Ae,be)}function W(Ae,be){return i(q,Ae,be)}function G(Ae,be,Ne){return a(V,Ae,be,Ne)}function Z(Ae,be,Ne){return a(q,Ae,be,Ne)}function te(Ae,be,Ne,Oe,ke){ke(Ae*Ne-be*Oe,be*Ne+Ae*Oe)}function Q(Ae){return Math.sin(Ni*Ae)}u=e*e,g=0,P=0,p=0,m=3422.7;var ie=Q(.19833+.05611*e),de=Q(.27869+.04508*e),He=Q(.16827-.36903*e),Je=Q(.34734-5.37261*e),ze=Q(.10498-5.37899*e),Y=Q(.42681-.41855*e),ae=Q(.14943-5.37511*e);for(I=.84*ie+.31*de+14.27*He+7.26*Je+.28*ze+.24*Y,y=2.94*ie+.31*de+14.27*He+9.34*Je+1.12*ze+.83*Y,T=-6.4*ie-1.89*Y,C=.21*ie+.31*de+14.27*He-88.7*Je-15.3*ze+.24*Y-1.86*ae,D=I-T,f=-3332e-9*Q(.59734-5.37261*e)-539e-9*Q(.35498-5.37899*e)-64e-9*Q(.39943-5.37511*e),S=Ni*Ma(.60643382+1336.85522467*e-313e-8*u)+I/ls,_=Ni*Ma(.37489701+1325.55240982*e+2565e-8*u)+y/ls,x=Ni*Ma(.99312619+99.99735956*e-44e-8*u)+T/ls,M=Ni*Ma(.25909118+1342.2278298*e-892e-8*u)+C/ls,E=Ni*Ma(.82736186+1236.85308708*e-397e-8*u)+D/ls,h=1;h<=4;++h){switch(h){case 1:l=_,o=4,c=1.000002208;break;case 2:l=x,o=3,c=.997504612-.002495388*e;break;case 3:l=M,o=4,c=1.000002708+139.978*f;break;case 4:l=E,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(l)*c),Z(0,h,0),Z(1,h,Math.sin(l)*c),d=2;d<=o;++d)te(O(d-1,h),W(d-1,h),O(1,h),W(1,h),(Ae,be)=>(G(d,h,Ae),Z(d,h,be)));for(d=1;d<=o;++d)G(-d,h,O(d,h)),Z(-d,h,-W(d,h))}function ne(Ae,be,Ne,Oe){for(var ke={x:1,y:0},at=[0,Ae,be,Ne,Oe],rt=1;rt<=4;++rt)at[rt]!==0&&te(ke.x,ke.y,O(at[rt],rt),W(at[rt],rt),(Ct,wt)=>(ke.x=Ct,ke.y=wt));return ke}function F(Ae,be,Ne,Oe,ke,at,rt,Ct){var wt=ne(ke,at,rt,Ct);g+=Ae*wt.y,P+=be*wt.y,p+=Ne*wt.x,m+=Oe*wt.x}F(13.902,14.06,-.001,.2607,0,0,0,4),F(.403,-4.01,.394,.0023,0,0,0,3),F(2369.912,2373.36,.601,28.2333,0,0,0,2),F(-125.154,-112.79,-.725,-.9781,0,0,0,1),F(1.979,6.98,-.445,.0433,1,0,0,4),F(191.953,192.72,.029,3.0861,1,0,0,2),F(-8.466,-13.51,.455,-.1093,1,0,0,1),F(22639.5,22609.07,.079,186.5398,1,0,0,0),F(18.609,3.59,-.094,.0118,1,0,0,-1),F(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),F(3.215,5.44,.192,-.0386,1,0,0,-3),F(-38.428,-38.64,.001,.6008,1,0,0,-4),F(-.393,-1.43,-.092,.0086,1,0,0,-6),F(-.289,-1.59,.123,-.0053,0,1,0,4),F(-24.42,-25.1,.04,-.3,0,1,0,2),F(18.023,17.93,.007,.1494,0,1,0,1),F(-668.146,-126.98,-1.302,-.3997,0,1,0,0),F(.56,.32,-.001,-.0037,0,1,0,-1),F(-165.145,-165.06,.054,1.9178,0,1,0,-2),F(-1.877,-6.46,-.416,.0339,0,1,0,-4),F(.213,1.02,-.074,.0054,2,0,0,4),F(14.387,14.78,-.017,.2833,2,0,0,2),F(-.586,-1.2,.054,-.01,2,0,0,1),F(769.016,767.96,.107,10.1657,2,0,0,0),F(1.75,2.01,-.018,.0155,2,0,0,-1),F(-211.656,-152.53,5.679,-.3039,2,0,0,-2),F(1.225,.91,-.03,-.0088,2,0,0,-3),F(-30.773,-34.07,-.308,.3722,2,0,0,-4),F(-.57,-1.4,-.074,.0109,2,0,0,-6),F(-2.921,-11.75,.787,-.0484,1,1,0,2),F(1.267,1.52,-.022,.0164,1,1,0,1),F(-109.673,-115.18,.461,-.949,1,1,0,0),F(-205.962,-182.36,2.056,1.4437,1,1,0,-2),F(.233,.36,.012,-.0025,1,1,0,-3),F(-4.391,-9.66,-.471,.0673,1,1,0,-4),F(.283,1.53,-.111,.006,1,-1,0,4),F(14.577,31.7,-1.54,.2302,1,-1,0,2),F(147.687,138.76,.679,1.1528,1,-1,0,0),F(-1.089,.55,.021,0,1,-1,0,-1),F(28.475,23.59,-.443,-.2257,1,-1,0,-2),F(-.276,-.38,-.006,-.0036,1,-1,0,-3),F(.636,2.27,.146,-.0102,1,-1,0,-4),F(-.189,-1.68,.131,-.0028,0,2,0,2),F(-7.486,-.66,-.037,-.0086,0,2,0,0),F(-8.096,-16.35,-.74,.0918,0,2,0,-2),F(-5.741,-.04,0,-9e-4,0,0,2,2),F(.255,0,0,0,0,0,2,1),F(-411.608,-.2,0,-.0124,0,0,2,0),F(.584,.84,0,.0071,0,0,2,-1),F(-55.173,-52.14,0,-.1052,0,0,2,-2),F(.254,.25,0,-.0017,0,0,2,-3),F(.025,-1.67,0,.0031,0,0,2,-4),F(1.06,2.96,-.166,.0243,3,0,0,2),F(36.124,50.64,-1.3,.6215,3,0,0,0),F(-13.193,-16.4,.258,-.1187,3,0,0,-2),F(-1.187,-.74,.042,.0074,3,0,0,-4),F(-.293,-.31,-.002,.0046,3,0,0,-6),F(-.29,-1.45,.116,-.0051,2,1,0,2),F(-7.649,-10.56,.259,-.1038,2,1,0,0),F(-8.627,-7.59,.078,-.0192,2,1,0,-2),F(-2.74,-2.54,.022,.0324,2,1,0,-4),F(1.181,3.32,-.212,.0213,2,-1,0,2),F(9.703,11.67,-.151,.1268,2,-1,0,0),F(-.352,-.37,.001,-.0028,2,-1,0,-1),F(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),F(.36,.2,-.012,-.0043,2,-1,0,-4),F(-1.167,-1.25,.008,-.0106,1,2,0,0),F(-7.412,-6.12,.117,.0484,1,2,0,-2),F(-.311,-.65,-.032,.0044,1,2,0,-4),F(.757,1.82,-.105,.0112,1,-2,0,2),F(2.58,2.32,.027,.0196,1,-2,0,0),F(2.533,2.4,-.014,-.0212,1,-2,0,-2),F(-.344,-.57,-.025,.0036,0,3,0,-2),F(-.992,-.02,0,0,1,0,2,2),F(-45.099,-.02,0,-.001,1,0,2,0),F(-.179,-9.52,0,-.0833,1,0,2,-2),F(-.301,-.33,0,.0014,1,0,2,-4),F(-6.382,-3.37,0,-.0481,1,0,-2,2),F(39.528,85.13,0,-.7136,1,0,-2,0),F(9.366,.71,0,-.0112,1,0,-2,-2),F(.202,.02,0,0,1,0,-2,-4),F(.415,.1,0,.0013,0,1,2,0),F(-2.152,-2.26,0,-.0066,0,1,2,-2),F(-1.44,-1.3,0,.0014,0,1,-2,2),F(.384,-.04,0,0,0,1,-2,-2),F(1.938,3.6,-.145,.0401,4,0,0,0),F(-.952,-1.58,.052,-.013,4,0,0,-2),F(-.551,-.94,.032,-.0097,3,1,0,0),F(-.482,-.57,.005,-.0045,3,1,0,-2),F(.681,.96,-.026,.0115,3,-1,0,0),F(-.297,-.27,.002,-9e-4,2,2,0,-2),F(.254,.21,-.003,0,2,-2,0,-2),F(-.25,-.22,.004,.0014,1,3,0,-2),F(-3.996,0,0,4e-4,2,0,2,0),F(.557,-.75,0,-.009,2,0,2,-2),F(-.459,-.38,0,-.0053,2,0,-2,2),F(-1.298,.74,0,4e-4,2,0,-2,0),F(.538,1.14,0,-.0141,2,0,-2,-2),F(.263,.02,0,0,1,1,2,0),F(.426,.07,0,-6e-4,1,1,-2,-2),F(-.304,.03,0,3e-4,1,-1,2,0),F(-.372,-.19,0,-.0027,1,-1,-2,2),F(.418,0,0,0,0,0,4,0),F(-.33,-.04,0,0,3,0,2,0);function _e(Ae,be,Ne,Oe,ke){return Ae*ne(be,Ne,Oe,ke).y}v=0,v+=_e(-526.069,0,0,1,-2),v+=_e(-3.352,0,0,1,-4),v+=_e(44.297,1,0,1,-2),v+=_e(-6,1,0,1,-4),v+=_e(20.599,-1,0,1,0),v+=_e(-30.598,-1,0,1,-2),v+=_e(-24.649,-2,0,1,0),v+=_e(-2,-2,0,1,-2),v+=_e(-22.571,0,1,1,-2),v+=_e(10.985,0,-1,1,-2),g+=.82*Q(.7736-62.5512*e)+.31*Q(.0466-125.1025*e)+.35*Q(.5785-25.1042*e)+.66*Q(.4591+1335.8075*e)+.64*Q(.313-91.568*e)+1.14*Q(.148+1331.2898*e)+.21*Q(.5918+1056.5859*e)+.44*Q(.5784+1322.8595*e)+.24*Q(.2275-5.7374*e)+.28*Q(.2965+2.6929*e)+.33*Q(.3132+6.3368*e),r=M+P/ls;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+p)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:Ni*Ma((S+g/ls)/Ni),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:ls*JS/(.999953253*m)}}function hg(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function Bl(s,e,t){const n=dg(e,t);return hg(n,s)}function dg(s,e){const t=s.tt/36525;let n=84381.406,i=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,a=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,r=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Pa,i*=Pa,a*=Pa,r*=Pa;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-i),h=Math.cos(-i),d=Math.sin(-a),u=Math.cos(-a),f=Math.sin(r),g=Math.cos(r),v=g*h-c*f*u,p=g*c*l+f*u*h*l-o*f*d,m=g*c*o+f*u*h*o+l*f*d,S=-f*h-c*g*u,_=-f*c*l+g*u*h*l-o*g*d,x=-f*c*o+g*u*h*o+l*g*d,M=c*d,E=-d*h*l-o*u,I=-d*h*o+u*l;if(e===xn.Into2000)return new ys([[v,p,m],[S,_,x],[M,E,I]]);if(e===xn.From2000)return new ys([[v,S,M],[p,_,E],[m,x,I]]);throw"Invalid precess direction"}function l_(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Yo;function _u(s){if(!Yo||Yo.tt!==s.tt){const e=s.tt/36525;let t=15*so(s).ee;const n=l_(s);let a=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;a<0&&(a+=24),Yo={tt:s.tt,st:a}}return Yo.st}function ug(s,e){const t=s.latitude*ht,n=Math.sin(t),i=Math.cos(t),a=1/Math.hypot(i,_d*n),r=ZS*a,o=s.height/1e3,l=Ed*a+o,c=Ed*r+o,h=(15*e+s.longitude)*ht,d=Math.sin(h),u=Math.cos(h);return{pos:[l*i*u/ks,l*i*d/ks,c*n/ks],vel:[-Hp*l*i*d*86400/ks,Hp*l*i*u*86400/ks,0]}}function Cd(s,e,t){const n=fg(e,t);return hg(n,s)}function fg(s,e){const t=so(s),n=t.mobl*ht,i=t.tobl*ht,a=t.dpsi*Pa,r=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(a),d=Math.sin(a),u=h,f=-d*r,g=-d*o,v=d*l,p=h*r*l+o*c,m=h*o*l-r*c,S=d*c,_=h*r*c-o*l,x=h*o*c+r*l;if(e===xn.From2000)return new ys([[u,v,S],[f,p,_],[g,m,x]]);if(e===xn.Into2000)return new ys([[u,f,g],[v,p,m],[S,_,x]]);throw"Invalid precess direction"}function Eu(s,e,t){return t===xn.Into2000?Bl(Cd(s,e,t),e,t):Cd(Bl(s,e,t),e,t)}function c_(s,e){const t=_u(s),n=ug(e,t).pos;return Eu(n,s,xn.Into2000)}class xt{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class ps{constructor(e,t,n,i,a,r,o){this.x=e,this.y=t,this.z=n,this.vx=i,this.vy=a,this.vz=r,this.t=o}}class Tu{constructor(e,t,n){this.lat=jt(e),this.lon=jt(t),this.dist=jt(n)}}class Rd{constructor(e,t,n,i){this.ra=jt(e),this.dec=jt(t),this.dist=jt(n),this.vec=i}}class ys{constructor(e){this.rot=e}}class h_{constructor(e,t,n,i){this.azimuth=jt(e),this.altitude=jt(t),this.ra=jt(n),this.dec=jt(i)}}class d_{constructor(e,t,n){this.vec=e,this.elat=jt(t),this.elon=jt(n)}}function pg(s,e){return new xt(s[0],s[1],s[2],e)}function u_(s,e){const t=pg(s,e),n=t.x*t.x+t.y*t.y,i=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Rd(0,t.z<0?-90:90,i,t)}let a=rg*Math.atan2(t.y,t.x);a<0&&(a+=24);const r=Ei*Math.atan2(s[2],Math.sqrt(n));return new Rd(a,r,i,t)}function $c(s,e){const t=s*ht,n=Math.cos(t),i=Math.sin(t);return[n*e[0]+i*e[1],n*e[1]-i*e[0],e[2]]}function mg(s,e,t,n,i){let a=Yt(s);Au(e),jt(t),jt(n);const r=Math.sin(e.latitude*ht),o=Math.cos(e.latitude*ht),l=Math.sin(e.longitude*ht),c=Math.cos(e.longitude*ht),h=Math.sin(n*ht),d=Math.cos(n*ht),u=Math.sin(t*Bp),f=Math.cos(t*Bp);let g=[o*c,o*l,r],v=[-r*c,-r*l,o],p=[l,-c,0];const m=-15*_u(a);let S=$c(m,g),_=$c(m,v),x=$c(m,p),M=[d*f,d*u,h];const E=M[0]*S[0]+M[1]*S[1]+M[2]*S[2],I=M[0]*_[0]+M[1]*_[1]+M[2]*_[2],y=M[0]*x[0]+M[1]*x[1]+M[2]*x[2];let T=Math.hypot(I,y),C;T>0?(C=-Ei*Math.atan2(y,I),C<0&&(C+=360)):C=0;let D=Ei*Math.atan2(T,E),P=t,V=n;if(i){let q=D,O=k_(i,90-D);if(D-=O,O>0&&D>3e-4){const W=Math.sin(D*ht),G=Math.cos(D*ht),Z=Math.sin(q*ht),te=Math.cos(q*ht),Q=[];for(let ie=0;ie<3;++ie)Q.push((M[ie]-te*S[ie])/Z*W+S[ie]*G);T=Math.hypot(Q[0],Q[1]),T>0?(P=rg*Math.atan2(Q[1],Q[0]),P<0&&(P+=24)):P=0,V=Ei*Math.atan2(Q[2],T)}}return new h_(C,90-D,P,V)}function Au(s){if(!(s instanceof Iu))throw`Not an instance of the Observer class: ${s}`;if(jt(s.latitude),jt(s.longitude),jt(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Iu{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Au(this)}}function f_(s){const e=Yt(s).AddDays(-1/wu),t=Ga(Mi.Earth,e),n=[-t.x,-t.y,-t.z],[i,a,r]=Eu(n,e,xn.From2000),o=ht*so(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new xt(i,a,r,e);return gg(h,l,c)}function p_(s,e,t,n,i){Au(t),Fl(n),Fl(i);const a=Yt(e),r=c_(a,t),o=Hd(s,a,i),l=[o.x-r[0],o.y-r[1],o.z-r[2]],c=Eu(l,a,xn.From2000);return u_(c,a)}function m_(s,e,t){const n=Yt(s),i=_u(n);let a=ug(e,i).pos;return pg(a,n)}function gg(s,e,t){const n=s.x,i=s.y*e+s.z*t,a=-s.y*t+s.z*e,r=Math.hypot(n,i);let o=0;r>0&&(o=Ei*Math.atan2(i,n),o<0&&(o+=360));let l=Ei*Math.atan2(a,r),c=new xt(n,i,a,s.t);return new d_(c,l,o)}function Pd(s){const e=so(s.t),t=[s.x,s.y,s.z],n=Bl(t,s.t,xn.From2000),[i,a,r]=Cd(n,s.t,xn.From2000),o=new xt(i,a,r,s.t),l=e.tobl*ht;return gg(o,Math.cos(l),Math.sin(l))}function er(s){const e=Yt(s),t=o_(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),i=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],a=r_(e,i),r=Bl(a,e,xn.Into2000);return new xt(r[0],r[1],r[2],e)}function vg(s){const e=Yt(s),t=1e-5,n=e.AddDays(-t),i=e.AddDays(+t),a=er(n),r=er(i);return new ps((a.x+r.x)/2,(a.y+r.y)/2,(a.z+r.z)/2,(r.x-a.x)/(2*t),(r.y-a.y)/(2*t),(r.z-a.z)/(2*t),e)}function g_(s){const e=Yt(s),t=vg(e),n=1+lg;return new ps(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Ha(s,e,t){let n=1,i=0;for(let a of s){let r=0;for(let[l,c,h]of a)r+=l*Math.cos(c+e*h);let o=n*r;t&&(o%=Ni),i+=o,n*=e}return i}function Zc(s,e){let t=1,n=0,i=0,a=0;for(let r of s){let o=0,l=0;for(let[c,h,d]of r){let u=h+e*d;o+=c*d*Math.sin(u),a>0&&(l+=c*Math.cos(u))}i+=a*n*l-t*o,n=t,t*=e,++a}return i}const Dr=365250,Ld=0,Nd=1,Od=2;function kd(s){return new ln(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function yg(s,e,t){const n=t*Math.cos(e),i=Math.cos(s),a=Math.sin(s);return[n*i,n*a,t*Math.sin(e)]}function Ga(s,e){const t=e.tt/Dr,n=Ha(s[Ld],t,!0),i=Ha(s[Nd],t,!1),a=Ha(s[Od],t,!1),r=yg(n,i,a);return kd(r).ToAstroVector(e)}function Ud(s,e){const t=e/Dr,n=Ha(s[Ld],t,!0),i=Ha(s[Nd],t,!1),a=Ha(s[Od],t,!1),r=Zc(s[Ld],t),o=Zc(s[Nd],t),l=Zc(s[Od],t),c=Math.cos(n),h=Math.sin(n),d=Math.cos(i),u=Math.sin(i),f=+(l*d*c)-a*u*c*o-a*d*h*r,g=+(l*d*h)-a*u*h*o+a*d*c*r,v=+(l*u)+a*d*o,p=yg(n,i,a),m=[f/Dr,g/Dr,v/Dr],S=kd(p),_=kd(m);return new $s(e,S,_)}function Ko(s,e,t,n){const i=n/(n+Mu),a=Ga(Mi[t],e);s.x+=i*a.x,s.y+=i*a.y,s.z+=i*a.z}function v_(s){const e=new xt(0,0,0,s);return Ko(e,s,Me.Jupiter,Td),Ko(e,s,Me.Saturn,Ad),Ko(e,s,Me.Uranus,Id),Ko(e,s,Me.Neptune,Dd),e}const Fd=51,y_=29200,La=146,Oi=201,Hs=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class ln{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new ln(this.x,this.y,this.z)}ToAstroVector(e){return new xt(this.x,this.y,this.z,e)}static zero(){return new ln(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new ln(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new ln(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new ln(e*this.x,e*this.y,e*this.z)}div(e){return new ln(this.x/e,this.y/e,this.z/e)}mean(e){return new ln((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new ln(-this.x,-this.y,-this.z)}}class $s{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new $s(this.tt,this.r,this.v)}sub(e){return new $s(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function b_(s){let[e,[t,n,i],[a,r,o]]=s;return new $s(e,new ln(t,n,i),new ln(a,r,o))}function $o(s,e,t,n){const i=n/(n+Mu),a=Ud(Mi[t],e);return s.r.incr(a.r.mul(i)),s.v.incr(a.v.mul(i)),a}function xr(s,e,t){const n=t.sub(s),i=n.quadrature();return n.mul(e/(i*Math.sqrt(i)))}class Ql{constructor(e){let t=new $s(e,new ln(0,0,0),new ln(0,0,0));this.Jupiter=$o(t,e,Me.Jupiter,Td),this.Saturn=$o(t,e,Me.Saturn,Ad),this.Uranus=$o(t,e,Me.Uranus,Id),this.Neptune=$o(t,e,Me.Neptune,Dd),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new $s(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=xr(e,Mu,this.Sun.r);return t.incr(xr(e,Td,this.Jupiter.r)),t.incr(xr(e,Ad,this.Saturn.r)),t.incr(xr(e,Id,this.Uranus.r)),t.incr(xr(e,Dd,this.Neptune.r)),t}}class ec{constructor(e,t,n,i){this.tt=e,this.r=t,this.v=n,this.a=i}clone(){return new ec(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class bg{constructor(e,t){this.bary=e,this.grav=t}}function zl(s,e,t,n){return new ln(e.x+s*(t.x+s*n.x/2),e.y+s*(t.y+s*n.y/2),e.z+s*(t.z+s*n.z/2))}function Vp(s,e,t){return new ln(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Bd(s,e){const t=s-e.tt,n=new Ql(s),i=zl(t,e.r,e.v,e.a),a=n.Acceleration(i).mean(e.a),r=zl(t,e.r,e.v,a),o=e.v.add(a.mul(t)),l=n.Acceleration(r),c=new ec(s,r,o,l);return new bg(n,c)}const x_=[];function xg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function zd(s){const e=b_(s),t=new Ql(e.tt),n=e.r.add(t.Sun.r),i=e.v.add(t.Sun.v),a=t.Acceleration(n),r=new ec(e.tt,n,i,a);return new bg(t,r)}function w_(s,e){const t=Hs[0][0];if(e<t||e>Hs[Fd-1][0])return null;const n=xg((e-t)/y_,Fd-1);if(!s[n]){const a=s[n]=[];a[0]=zd(Hs[n]).grav,a[Oi-1]=zd(Hs[n+1]).grav;let r,o=a[0].tt;for(r=1;r<Oi-1;++r)a[r]=Bd(o+=La,a[r-1]).grav;o=a[Oi-1].tt;var i=[];for(i[Oi-1]=a[Oi-1],r=Oi-2;r>0;--r)i[r]=Bd(o-=La,i[r+1]).grav;for(r=Oi-2;r>0;--r){const l=r/(Oi-1);a[r].r=a[r].r.mul(1-l).add(i[r].r.mul(l)),a[r].v=a[r].v.mul(1-l).add(i[r].v.mul(l)),a[r].a=a[r].a.mul(1-l).add(i[r].a.mul(l))}}return s[n]}function Wp(s,e,t){let n=zd(s);const i=Math.ceil((e-n.grav.tt)/t);for(let a=0;a<i;++a)n=Bd(a+1===i?e:n.grav.tt+t,n.grav);return n}function wg(s,e){let t,n,i;const a=w_(x_,s.tt);if(a){const r=xg((s.tt-a[0].tt)/La,Oi-1),o=a[r],l=a[r+1],c=o.a.mean(l.a),h=zl(s.tt-o.tt,o.r,o.v,c),d=Vp(s.tt-o.tt,o.v,c),u=zl(s.tt-l.tt,l.r,l.v,c),f=Vp(s.tt-l.tt,l.v,c),g=(s.tt-o.tt)/La;t=h.mul(1-g).add(u.mul(g)),n=d.mul(1-g).add(f.mul(g))}else{let r;s.tt<Hs[0][0]?r=Wp(Hs[0],s.tt,-La):r=Wp(Hs[Fd-1],s.tt,+La),t=r.grav.r,n=r.grav.v,i=r.bary}return i||(i=new Ql(s.tt)),t=t.sub(i.Sun.r),n=n.sub(i.Sun.v),new ps(t.x,t.y,t.z,n.x,n.y,n.z,s)}function gs(s,e){var t=Yt(e);if(s in Mi)return Ga(Mi[s],t);if(s===Me.Pluto){const r=wg(t);return new xt(r.x,r.y,r.z,t)}if(s===Me.Sun)return new xt(0,0,0,t);if(s===Me.Moon){var n=Ga(Mi.Earth,t),i=er(t);return new xt(n.x+i.x,n.y+i.y,n.z+i.z,t)}if(s===Me.EMB){const r=Ga(Mi.Earth,t),o=er(t),l=1+lg;return new xt(r.x+o.x/l,r.y+o.y/l,r.z+o.z/l,t)}if(s===Me.SSB)return v_(t);const a=Su(s);if(a){const r=new Tu(a.dec,15*a.ra,a.dist);return Sg(r,t)}throw`HelioVector: Unknown body "${s}"`}function M_(s,e){let t=e,n=0;for(let i=0;i<10;++i){const a=s(t),r=a.Length()/wu;if(r>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-r);if(n=Math.abs(o.tt-t.tt),n<1e-9)return a;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class S_{constructor(e,t,n,i){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=i}Position(e){this.aberration&&(this.observerPos=gs(this.observerBody,e));const t=gs(this.targetBody,e);return new xt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function __(s,e,t,n){Fl(n);const i=Yt(s);if(Su(t)){const o=gs(t,i);if(n){const c=T_(e,i),h=new xt(o.x-c.x,o.y-c.y,o.z-c.z,i),d=wu/h.Length();return new xt(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,i)}const l=gs(e,i);return new xt(o.x-l.x,o.y-l.y,o.z-l.z,i)}let a;n?a=new xt(0,0,0,i):a=gs(e,i);const r=new S_(e,t,n,a);return M_(o=>r.Position(o),i)}function Hd(s,e,t){Fl(t);const n=Yt(e);switch(s){case Me.Earth:return new xt(0,0,0,n);case Me.Moon:return er(n);default:const i=__(n,Me.Earth,s,t);return i.t=n,i}}function E_(s,e){return new ps(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function T_(s,e){const t=Yt(e);switch(s){case Me.Sun:return new ps(0,0,0,0,0,0,t);case Me.SSB:const n=new Ql(t.tt);return new ps(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Me.Mercury:case Me.Venus:case Me.Earth:case Me.Mars:case Me.Jupiter:case Me.Saturn:case Me.Uranus:case Me.Neptune:const i=Ud(Mi[s],t.tt);return E_(i,t);case Me.Pluto:return wg(t);case Me.Moon:case Me.EMB:const a=Ud(Mi.Earth,t.tt),r=s==Me.Moon?vg(t):g_(t);return new ps(r.x+a.r.x,r.y+a.r.y,r.z+a.r.z,r.vx+a.v.x,r.vy+a.v.y,r.vz+a.v.z,t);default:if(Su(s)){const o=gs(s,t);return new ps(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function A_(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function I_(s,e,t){if(s===Me.Earth||e===Me.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Yt(t),i=Hd(s,n,!1),a=Pd(i),r=Hd(e,n,!1),o=Pd(r);return A_(a.elon-o.elon)}function D_(s,e,t,n){let i,a=0,r=0,o=0;switch(s){case Me.Mercury:i=-.6,a=4.98,r=-4.88,o=3.02;break;case Me.Venus:e<163.6?(i=-4.47,a=1.03,r=.57,o=.13):(i=.98,a=-1.02);break;case Me.Mars:i=-1.52,a=1.6;break;case Me.Jupiter:i=-9.4,a=.5;break;case Me.Uranus:i=-7.19,a=.25;break;case Me.Neptune:i=-6.87;break;case Me.Pluto:i=-1,a=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const l=e/100;let c=i+l*(a+l*(r+l*o));return c+=5*Math.log10(t*n),c}function C_(s,e,t,n,i){const a=Pd(n),r=ht*28.06,o=ht*(169.51+382e-7*i.tt),l=ht*a.elat,c=ht*a.elon,h=Math.asin(Math.sin(l)*Math.cos(r)-Math.cos(l)*Math.sin(r)*Math.sin(c-o)),d=Math.sin(Math.abs(h));let u=-9+.044*s;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:Ei*h}}function R_(s,e,t){let n=s*ht,i=n*n,a=i*i,r=-12.717+1.49*Math.abs(n)+.0431*a;const o=385000.6/ks;let l=t/o;return r+=5*Math.log10(e*l),r}class P_{constructor(e,t,n,i,a,r,o,l){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=i,this.geo_dist=a,this.gc=r,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(ht*n))/2}}function Mg(s,e){if(s===Me.Earth)throw"The illumination of the Earth is not defined.";const t=Yt(e),n=Ga(Mi.Earth,t);let i,a,r,o;s===Me.Sun?(r=new xt(-n.x,-n.y,-n.z,t),a=new xt(0,0,0,t),i=0):(s===Me.Moon?(r=er(t),a=new xt(n.x+r.x,n.y+r.y,n.z+r.z,t)):(a=gs(s,e),r=new xt(a.x-n.x,a.y-n.y,a.z-n.z,t)),i=jS(r,a));let l=r.Length(),c=a.Length(),h;if(s===Me.Sun)o=$S+5*Math.log10(l);else if(s===Me.Moon)o=R_(i,c,l);else if(s===Me.Saturn){const d=C_(i,c,l,r,t);o=d.mag,h=d.ring_tilt}else o=D_(s,i,c,l);return new P_(t,o,i,c,l,r,a,h)}function L_(s){return I_(Me.Moon,Me.Sun,s)}var Xp;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Xp||(Xp={}));function N_(s,e){return new ys([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Sg(s,e){e=Yt(e);const t=s.lat*ht,n=s.lon*ht,i=s.dist*Math.cos(t);return new xt(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(t),e)}function _g(s){const e=O_(s);return new Rd(e.lon/15,e.lat,e.dist,s)}function O_(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let n,i;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=Ei*Math.atan2(s.y,s.x),i<0&&(i+=360),n=Ei*Math.atan2(s.z,Math.sqrt(e));return new Tu(n,i,t)}function k_(s,e){let t;if(jt(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*ht)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function yl(s,e){return new xt(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function U_(){return new ys([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function F_(){return new ys([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function B_(s){s=Yt(s);const e=dg(s,xn.From2000),t=fg(s,xn.From2000);return N_(e,t)}function z_(s){const t=so(Yt(s)).tobl*ht,n=Math.cos(t),i=Math.sin(t);return new ys([[1,0,0],[0,+n,+i],[0,-i,+n]])}var qp;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(qp||(qp={}));var Yp;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Yp||(Yp={}));const H_=["Venus","Mars","Jupiter","Saturn"];function Eg(s){return new Iu(s.lat,s.lng,s.elevationM)}function tr(s,e,t,n,i=!0){const a=mg(t,Eg(n),s,e,i?"normal":void 0);return{altitudeDeg:a.altitude,azimuthDeg:a.azimuth}}function On(s,e,t){const n=Eg(t),i=p_(Me[s],e,n,!0,!0),a=mg(e,n,i.ra,i.dec,"normal");return{altitudeDeg:a.altitude,azimuthDeg:a.azimuth}}function Jc(s,e){return Mg(Me[s],e).mag}function Hl(s){const e=L_(s),t=Mg(Me.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const G_=2e3,V_=3,W_=20;function Va(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??G_,a=s.month??(n?1:V_),r=s.day??(n?1:W_),o=t??Math.round(e/15);return new Date(Date.UTC(i,a-1,r,(s.hour??12)-o,s.minute??0,s.second??0))}class Us{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Us.patch(t.fragmentShader)}}static patch(e){return e.replace(Us.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
6032
6042
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
6033
6043
  if ( distanceFromCentre > ${Us.RIM.toFixed(2)} ) discard;
6034
6044
  float glare = 1.0 - smoothstep( ${Us.CORE.toFixed(2)}, ${Us.RIM.toFixed(2)}, distanceFromCentre );
6035
- vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const X_=[{name:{en:"Sirius",fr:"Sirius"},raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:{en:"Canopus",fr:"Canopus"},raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:{en:"Arcturus",fr:"Arcturus"},raHours:14.261,decDeg:19.1824,mag:-.05},{name:{en:"Rigil Kentaurus",fr:"Rigil Kentaurus"},raHours:14.6608,decDeg:-60.834,mag:-.01},{name:{en:"Vega",fr:"Véga"},raHours:18.6156,decDeg:38.7837,mag:.03},{name:{en:"Capella",fr:"Capella"},raHours:5.2782,decDeg:45.998,mag:.08},{name:{en:"Rigel",fr:"Rigel"},raHours:5.2423,decDeg:-8.2016,mag:.18},{name:{en:"Procyon",fr:"Procyon"},raHours:7.655,decDeg:5.225,mag:.4},{name:{en:"Achernar",fr:"Achernar"},raHours:1.6286,decDeg:-57.2368,mag:.45},{name:{en:"Betelgeuse",fr:"Bételgeuse"},raHours:5.9195,decDeg:7.4071,mag:.45},{name:{en:"Hadar",fr:"Hadar"},raHours:14.0637,decDeg:-60.373,mag:.61},{name:{en:"Altair",fr:"Altaïr"},raHours:19.8464,decDeg:8.8683,mag:.76},{name:{en:"Acrux",fr:"Acrux"},raHours:12.4433,decDeg:-63.0991,mag:.77},{name:{en:"Aldebaran",fr:"Aldébaran"},raHours:4.5987,decDeg:16.5093,mag:.87},{name:{en:"Spica",fr:"Spica"},raHours:13.4199,decDeg:-11.1613,mag:.98},{name:{en:"Antares",fr:"Antarès"},raHours:16.4901,decDeg:-26.432,mag:1.06},{name:{en:"Pollux",fr:"Pollux"},raHours:7.7553,decDeg:28.0262,mag:1.16},{name:{en:"Fomalhaut",fr:"Fomalhaut"},raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:{en:"Mimosa",fr:"Mimosa"},raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:{en:"Deneb",fr:"Deneb"},raHours:20.6905,decDeg:45.2803,mag:1.25},{name:{en:"Toliman",fr:"Toliman"},raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:{en:"Regulus",fr:"Régulus"},raHours:10.1395,decDeg:11.9672,mag:1.36},{name:{en:"Adhara",fr:"Adhara"},raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:{en:"Castor",fr:"Castor"},raHours:7.5766,decDeg:31.8883,mag:1.58},{name:{en:"Gacrux",fr:"Gacrux"},raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:{en:"Shaula",fr:"Shaula"},raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:{en:"Bellatrix",fr:"Bellatrix"},raHours:5.4189,decDeg:6.3497,mag:1.64},{name:{en:"Elnath",fr:"Elnath"},raHours:5.4382,decDeg:28.6075,mag:1.65},{name:{en:"Miaplacidus",fr:"Miaplacidus"},raHours:9.22,decDeg:-69.7172,mag:1.67},{name:{en:"Alnilam",fr:"Alnilam"},raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:{en:"Alnair",fr:"Alnair"},raHours:22.1372,decDeg:-46.961,mag:1.73},{name:{en:"Alnitak",fr:"Alnitak"},raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:{en:"γ² Velorum",fr:"γ² Velorum"},raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:{en:"Alioth",fr:"Alioth"},raHours:12.9005,decDeg:55.9598,mag:1.76},{name:{en:"Mirfak",fr:"Mirfak"},raHours:3.4054,decDeg:49.8612,mag:1.79},{name:{en:"Kaus Australis",fr:"Kaus Australis"},raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:{en:"Dubhe",fr:"Dubhe"},raHours:11.0622,decDeg:61.751,mag:1.81},{name:{en:"Wezen",fr:"Wezen"},raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:{en:"Alkaid",fr:"Alkaid"},raHours:13.7924,decDeg:49.3133,mag:1.85},{name:{en:"Avior",fr:"Avior"},raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:{en:"Sargas",fr:"Sargas"},raHours:17.622,decDeg:-42.9978,mag:1.86},{name:{en:"Menkalinan",fr:"Menkalinan"},raHours:5.9921,decDeg:44.9474,mag:1.9},{name:{en:"Atria",fr:"Atria"},raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:{en:"Alhena",fr:"Alhena"},raHours:6.6285,decDeg:16.3993,mag:1.93},{name:{en:"Alsephina",fr:"Alsephina"},raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:{en:"Peacock",fr:"Peacock"},raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:{en:"Polaris",fr:"Polaris"},raHours:2.5297,decDeg:89.2641,mag:1.97},{name:{en:"Mirzam",fr:"Mirzam"},raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:{en:"Alphard",fr:"Alphard"},raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:{en:"Hamal",fr:"Hamal"},raHours:2.1196,decDeg:23.4624,mag:2.01},{name:{en:"Algieba",fr:"Algieba"},raHours:10.3329,decDeg:19.8415,mag:2.01},{name:{en:"Diphda",fr:"Diphda"},raHours:.7265,decDeg:-17.9866,mag:2.04},{name:{en:"Nunki",fr:"Nunki"},raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:{en:"Menkent",fr:"Menkent"},raHours:14.1114,decDeg:-36.37,mag:2.06},{name:{en:"Alpheratz",fr:"Alpheratz"},raHours:.1398,decDeg:29.0904,mag:2.07},{name:{en:"Mirach",fr:"Mirach"},raHours:1.1622,decDeg:35.6206,mag:2.07},{name:{en:"Saiph",fr:"Saiph"},raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:{en:"Kochab",fr:"Kochab"},raHours:14.8451,decDeg:74.1555,mag:2.07},{name:{en:"Tiaki",fr:"Tiaki"},raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:{en:"Rasalhague",fr:"Rasalhague"},raHours:17.5822,decDeg:12.56,mag:2.08},{name:{en:"Algol",fr:"Algol"},raHours:3.1361,decDeg:40.9556,mag:2.09},{name:{en:"Almach",fr:"Almach"},raHours:2.065,decDeg:42.3297,mag:2.1},{name:{en:"Denebola",fr:"Denebola"},raHours:11.8177,decDeg:14.5721,mag:2.14},{name:{en:"Cih",fr:"Cih"},raHours:.9451,decDeg:60.7167,mag:2.15},{name:{en:"γ Centauri",fr:"γ Centauri"},raHours:12.692,decDeg:-48.9599,mag:2.2},{name:{en:"Naos",fr:"Naos"},raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:{en:"Aspidiske",fr:"Aspidiske"},raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:{en:"Alphecca",fr:"Alphecca"},raHours:15.5781,decDeg:26.7147,mag:2.22},{name:{en:"Suhail",fr:"Suhail"},raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:{en:"Mizar",fr:"Mizar"},raHours:13.3987,decDeg:54.9254,mag:2.23},{name:{en:"Sadr",fr:"Sadr"},raHours:20.3705,decDeg:40.2567,mag:2.23},{name:{en:"Schedar",fr:"Schedar"},raHours:.6751,decDeg:56.5373,mag:2.24},{name:{en:"Eltanin",fr:"Eltanin"},raHours:17.9434,decDeg:51.4889,mag:2.24},{name:{en:"Mintaka",fr:"Mintaka"},raHours:5.5334,decDeg:-.2991,mag:2.25},{name:{en:"Caph",fr:"Caph"},raHours:.1529,decDeg:59.1498,mag:2.28},{name:{en:"ε Centauri",fr:"ε Centauri"},raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:{en:"Dschubba",fr:"Dschubba"},raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:{en:"Larawag",fr:"Larawag"},raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:{en:"α Lupi",fr:"α Lupi"},raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:{en:"η Centauri",fr:"η Centauri"},raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:{en:"Merak",fr:"Merak"},raHours:11.0307,decDeg:56.3824,mag:2.34},{name:{en:"Izar",fr:"Izar"},raHours:14.7498,decDeg:27.0742,mag:2.35},{name:{en:"Enif",fr:"Enif"},raHours:21.7364,decDeg:9.875,mag:2.38},{name:{en:"κ Scorpii",fr:"κ Scorpii"},raHours:17.7081,decDeg:-39.03,mag:2.39},{name:{en:"Ankaa",fr:"Ankaa"},raHours:.4381,decDeg:-42.306,mag:2.4},{name:{en:"Phecda",fr:"Phecda"},raHours:11.8972,decDeg:53.6948,mag:2.41},{name:{en:"Sabik",fr:"Sabik"},raHours:17.173,decDeg:-15.7249,mag:2.43},{name:{en:"Scheat",fr:"Scheat"},raHours:23.0629,decDeg:28.0828,mag:2.44},{name:{en:"Aludra",fr:"Aludra"},raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:{en:"Alderamin",fr:"Alderamin"},raHours:21.3096,decDeg:62.5856,mag:2.45},{name:{en:"Markeb",fr:"Markeb"},raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:{en:"Aljanah",fr:"Aljanah"},raHours:20.7702,decDeg:33.9703,mag:2.48},{name:{en:"Markab",fr:"Markab"},raHours:23.0793,decDeg:15.2053,mag:2.49},{name:{en:"Menkar",fr:"Menkar"},raHours:3.038,decDeg:4.0897,mag:2.54},{name:{en:"ζ Ophiuchi",fr:"ζ Ophiuchi"},raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:{en:"ζ Centauri",fr:"ζ Centauri"},raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:{en:"Zosma",fr:"Zosma"},raHours:11.2351,decDeg:20.5237,mag:2.56},{name:{en:"Acrab",fr:"Acrab"},raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:{en:"Arneb",fr:"Arneb"},raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:{en:"δ Centauri",fr:"δ Centauri"},raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:{en:"Gienah",fr:"Gienah"},raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:{en:"Ascella",fr:"Ascella"},raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:{en:"Zubeneschamali",fr:"Zubeneschamali"},raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:{en:"Unukalhai",fr:"Unukalhai"},raHours:15.7378,decDeg:6.4256,mag:2.63},{name:{en:"Sheratan",fr:"Sheratan"},raHours:1.9107,decDeg:20.808,mag:2.64},{name:{en:"Phact",fr:"Phact"},raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:{en:"Mahasim",fr:"Mahasim"},raHours:5.9954,decDeg:37.2126,mag:2.65},{name:{en:"Kraz",fr:"Kraz"},raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:{en:"Ruchbah",fr:"Ruchbah"},raHours:1.4302,decDeg:60.2353,mag:2.66},{name:{en:"Muphrid",fr:"Muphrid"},raHours:13.9114,decDeg:18.3977,mag:2.68},{name:{en:"β Lupi",fr:"β Lupi"},raHours:14.9755,decDeg:-43.134,mag:2.68},{name:{en:"Hassaleh",fr:"Hassaleh"},raHours:4.9499,decDeg:33.1661,mag:2.69},{name:{en:"μ Velorum",fr:"μ Velorum"},raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:{en:"α Muscae",fr:"α Muscae"},raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:{en:"Lesath",fr:"Lesath"},raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:{en:"π Puppis",fr:"π Puppis"},raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:{en:"Kaus Media",fr:"Kaus Media"},raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:{en:"Tarazed",fr:"Tarazed"},raHours:19.771,decDeg:10.6133,mag:2.72},{name:{en:"Yed Prior",fr:"Yed Prior"},raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:{en:"Athebyne",fr:"Athebyne"},raHours:16.3999,decDeg:61.5142,mag:2.73},{name:{en:"θ Carinae",fr:"θ Carinae"},raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:{en:"Porrima",fr:"Porrima"},raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:{en:"Hatysa",fr:"Hatysa"},raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:{en:"ι Centauri",fr:"ι Centauri"},raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:{en:"Zubenelgenubi",fr:"Zubenelgenubi"},raHours:14.848,decDeg:-16.0418,mag:2.75},{name:{en:"Cebalrai",fr:"Cebalrai"},raHours:17.7245,decDeg:4.5673,mag:2.76},{name:{en:"Cursa",fr:"Cursa"},raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:{en:"Kornephoros",fr:"Kornephoros"},raHours:16.5037,decDeg:21.4896,mag:2.78},{name:{en:"Rasalgethi",fr:"Rasalgethi"},raHours:17.2441,decDeg:14.3903,mag:2.78},{name:{en:"Imai",fr:"Imai"},raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:{en:"Rastaban",fr:"Rastaban"},raHours:17.5072,decDeg:52.3014,mag:2.79},{name:{en:"γ Lupi",fr:"γ Lupi"},raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:{en:"Nihal",fr:"Nihal"},raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:{en:"ζ Herculis",fr:"ζ Herculis"},raHours:16.6881,decDeg:31.6027,mag:2.81},{name:{en:"β Hydri",fr:"β Hydri"},raHours:.4279,decDeg:-77.2542,mag:2.82},{name:{en:"Paikauhale",fr:"Paikauhale"},raHours:16.598,decDeg:-28.216,mag:2.82},{name:{en:"Kaus Borealis",fr:"Kaus Borealis"},raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:{en:"Algenib",fr:"Algenib"},raHours:.2206,decDeg:15.1836,mag:2.83},{name:{en:"Tureis",fr:"Tureis"},raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:{en:"β Trianguli Australis",fr:"β Trianguli Australis"},raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:{en:"ζ Persei",fr:"ζ Persei"},raHours:3.9022,decDeg:31.8836,mag:2.84},{name:{en:"β Arae",fr:"β Arae"},raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:{en:"α Arae",fr:"α Arae"},raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:{en:"Alcyone",fr:"Alcyone"},raHours:3.7914,decDeg:24.1051,mag:2.85},{name:{en:"Vindemiatrix",fr:"Vindemiatrix"},raHours:13.0363,decDeg:10.9591,mag:2.85},{name:{en:"Deneb Algedi",fr:"Deneb Algedi"},raHours:21.784,decDeg:-16.1273,mag:2.85},{name:{en:"Castor B",fr:"Castor B"},raHours:7.5768,decDeg:31.8905,mag:2.85},{name:{en:"α Hydri",fr:"α Hydri"},raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:{en:"Fawaris",fr:"Fawaris"},raHours:19.7496,decDeg:45.1308,mag:2.86},{name:{en:"Tejat",fr:"Tejat"},raHours:6.3827,decDeg:22.5136,mag:2.87},{name:{en:"γ Trianguli Australis",fr:"γ Trianguli Australis"},raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:{en:"α Tucanae",fr:"α Tucanae"},raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:{en:"Acamar",fr:"Acamar"},raHours:2.971,decDeg:-40.3047,mag:2.88},{name:{en:"Albaldah",fr:"Albaldah"},raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:{en:"Gomeisa",fr:"Gomeisa"},raHours:7.4525,decDeg:8.2893,mag:2.89},{name:{en:"Cor Caroli",fr:"Cor Caroli"},raHours:12.9338,decDeg:38.3184,mag:2.89},{name:{en:"Fang",fr:"Fang"},raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:{en:"ε Persei",fr:"ε Persei"},raHours:3.9642,decDeg:40.0102,mag:2.9},{name:{en:"Alniyat",fr:"Alniyat"},raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:{en:"Sadalsuud",fr:"Sadalsuud"},raHours:21.526,decDeg:-5.5712,mag:2.9},{name:{en:"γ Persei",fr:"γ Persei"},raHours:3.0799,decDeg:53.5064,mag:2.91},{name:{en:"υ Carinae",fr:"υ Carinae"},raHours:9.785,decDeg:-65.072,mag:2.92},{name:{en:"Matar",fr:"Matar"},raHours:22.7167,decDeg:30.2212,mag:2.93},{name:{en:"τ Puppis",fr:"τ Puppis"},raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:{en:"Algorab",fr:"Algorab"},raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:{en:"Sadalmelik",fr:"Sadalmelik"},raHours:22.0964,decDeg:-.3199,mag:2.95},{name:{en:"Zaurak",fr:"Zaurak"},raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:{en:"Tianguan",fr:"Tianguan"},raHours:5.6274,decDeg:21.1425,mag:2.97},{name:{en:"Ras Elased Australis",fr:"Ras Elased Australis"},raHours:9.7642,decDeg:23.7743,mag:2.97},{name:{en:"Alnasl",fr:"Alnasl"},raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:{en:"γ Hydrae",fr:"γ Hydrae"},raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:{en:"ι¹ Scorpii",fr:"ι¹ Scorpii"},raHours:17.7931,decDeg:-40.127,mag:2.99},{name:{en:"Okab",fr:"Okab"},raHours:19.0902,decDeg:13.8635,mag:2.99},{name:{en:"β Trianguli",fr:"β Trianguli"},raHours:2.1591,decDeg:34.9873,mag:3},{name:{en:"ψ Ursae Majoris",fr:"ψ Ursae Majoris"},raHours:11.1611,decDeg:44.4985,mag:3},{name:{en:"Pherkad",fr:"Pherkad"},raHours:15.3455,decDeg:71.834,mag:3},{name:{en:"Xamidimura",fr:"Xamidimura"},raHours:16.8645,decDeg:-38.0474,mag:3},{name:{en:"Aldhanab",fr:"Aldhanab"},raHours:21.8988,decDeg:-37.3649,mag:3}],Cr=64,$t=Cr+1,Kp=512,q_=900,Y_=700/900,K_=0,$_=.01;function Z_(s,e,t){return{north:zi(0,-t,s,e).lat,south:zi(0,t,s,e).lat,east:zi(t,0,s,e).lng,west:zi(-t,0,s,e).lng}}async function J_(s,e,t,n=q_){const i=n,a=n*Y_,r=Z_(s,e,i),o={width:$t,height:$t},[l,c]=await Promise.all([t.elevation.getElevationGrid(r,o),t.imagery.getImageryTexture(r,{width:Kp,height:Kp})]),h=Math.floor($t/2),d=l.heights[h*$t+h],u=new Float32Array($t*$t*3),f=new Float32Array($t*$t*2),g=new Float32Array($t*$t*4);for(let M=0;M<$t;M++){const E=M/($t-1),I=r.north+(r.south-r.north)*E;for(let y=0;y<$t;y++){const T=y/($t-1),C=r.west+(r.east-r.west)*T,{x:D,z:P}=gn(I,C,s,e),V=l.heights[M*$t+y],q=K_+$_+(V-d),O=M*$t+y;u[O*3]=D,u[O*3+1]=q,u[O*3+2]=P;const W=mm(c.bounds,C,I);f[O*2]=W.x,f[O*2+1]=W.y;const G=Math.max(Math.abs(D),Math.abs(P)),Z=1-j_((G-a)/(i-a),0,1);g[O*4]=1,g[O*4+1]=1,g[O*4+2]=1,g[O*4+3]=Z}}const v=new Uint16Array(Cr*Cr*6);let p=0;for(let M=0;M<Cr;M++)for(let E=0;E<Cr;E++){const I=M*$t+E,y=I+1,T=I+$t,C=T+1;v[p++]=I,v[p++]=T,v[p++]=y,v[p++]=y,v[p++]=T,v[p++]=C}const m=new Dt;m.setAttribute("position",new vt(u,3)),m.setAttribute("uv",new vt(f,2)),m.setAttribute("color",new vt(g,4)),m.setIndex(new vt(v,1)),m.computeVertexNormals();const S=new Ai(c.source);S.flipY=!1;const _=new eo({map:S,color:new ve(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),x=new Ze(m,_);return x.receiveShadow=!0,x.castShadow=!0,{mesh:x,attribution:t.imagery.attribution}}function j_(s,e,t){return Math.max(e,Math.min(t,s))}const Q_=18,eE=.55,tE=.5,nE=`
6045
+ vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const X_=[{name:{en:"Sirius",fr:"Sirius"},raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:{en:"Canopus",fr:"Canopus"},raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:{en:"Arcturus",fr:"Arcturus"},raHours:14.261,decDeg:19.1824,mag:-.05},{name:{en:"Rigil Kentaurus",fr:"Rigil Kentaurus"},raHours:14.6608,decDeg:-60.834,mag:-.01},{name:{en:"Vega",fr:"Véga"},raHours:18.6156,decDeg:38.7837,mag:.03},{name:{en:"Capella",fr:"Capella"},raHours:5.2782,decDeg:45.998,mag:.08},{name:{en:"Rigel",fr:"Rigel"},raHours:5.2423,decDeg:-8.2016,mag:.18},{name:{en:"Procyon",fr:"Procyon"},raHours:7.655,decDeg:5.225,mag:.4},{name:{en:"Achernar",fr:"Achernar"},raHours:1.6286,decDeg:-57.2368,mag:.45},{name:{en:"Betelgeuse",fr:"Bételgeuse"},raHours:5.9195,decDeg:7.4071,mag:.45},{name:{en:"Hadar",fr:"Hadar"},raHours:14.0637,decDeg:-60.373,mag:.61},{name:{en:"Altair",fr:"Altaïr"},raHours:19.8464,decDeg:8.8683,mag:.76},{name:{en:"Acrux",fr:"Acrux"},raHours:12.4433,decDeg:-63.0991,mag:.77},{name:{en:"Aldebaran",fr:"Aldébaran"},raHours:4.5987,decDeg:16.5093,mag:.87},{name:{en:"Spica",fr:"Spica"},raHours:13.4199,decDeg:-11.1613,mag:.98},{name:{en:"Antares",fr:"Antarès"},raHours:16.4901,decDeg:-26.432,mag:1.06},{name:{en:"Pollux",fr:"Pollux"},raHours:7.7553,decDeg:28.0262,mag:1.16},{name:{en:"Fomalhaut",fr:"Fomalhaut"},raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:{en:"Mimosa",fr:"Mimosa"},raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:{en:"Deneb",fr:"Deneb"},raHours:20.6905,decDeg:45.2803,mag:1.25},{name:{en:"Toliman",fr:"Toliman"},raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:{en:"Regulus",fr:"Régulus"},raHours:10.1395,decDeg:11.9672,mag:1.36},{name:{en:"Adhara",fr:"Adhara"},raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:{en:"Castor",fr:"Castor"},raHours:7.5766,decDeg:31.8883,mag:1.58},{name:{en:"Gacrux",fr:"Gacrux"},raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:{en:"Shaula",fr:"Shaula"},raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:{en:"Bellatrix",fr:"Bellatrix"},raHours:5.4189,decDeg:6.3497,mag:1.64},{name:{en:"Elnath",fr:"Elnath"},raHours:5.4382,decDeg:28.6075,mag:1.65},{name:{en:"Miaplacidus",fr:"Miaplacidus"},raHours:9.22,decDeg:-69.7172,mag:1.67},{name:{en:"Alnilam",fr:"Alnilam"},raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:{en:"Alnair",fr:"Alnair"},raHours:22.1372,decDeg:-46.961,mag:1.73},{name:{en:"Alnitak",fr:"Alnitak"},raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:{en:"γ² Velorum",fr:"γ² Velorum"},raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:{en:"Alioth",fr:"Alioth"},raHours:12.9005,decDeg:55.9598,mag:1.76},{name:{en:"Mirfak",fr:"Mirfak"},raHours:3.4054,decDeg:49.8612,mag:1.79},{name:{en:"Kaus Australis",fr:"Kaus Australis"},raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:{en:"Dubhe",fr:"Dubhe"},raHours:11.0622,decDeg:61.751,mag:1.81},{name:{en:"Wezen",fr:"Wezen"},raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:{en:"Alkaid",fr:"Alkaid"},raHours:13.7924,decDeg:49.3133,mag:1.85},{name:{en:"Avior",fr:"Avior"},raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:{en:"Sargas",fr:"Sargas"},raHours:17.622,decDeg:-42.9978,mag:1.86},{name:{en:"Menkalinan",fr:"Menkalinan"},raHours:5.9921,decDeg:44.9474,mag:1.9},{name:{en:"Atria",fr:"Atria"},raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:{en:"Alhena",fr:"Alhena"},raHours:6.6285,decDeg:16.3993,mag:1.93},{name:{en:"Alsephina",fr:"Alsephina"},raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:{en:"Peacock",fr:"Peacock"},raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:{en:"Polaris",fr:"Polaris"},raHours:2.5297,decDeg:89.2641,mag:1.97},{name:{en:"Mirzam",fr:"Mirzam"},raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:{en:"Alphard",fr:"Alphard"},raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:{en:"Hamal",fr:"Hamal"},raHours:2.1196,decDeg:23.4624,mag:2.01},{name:{en:"Algieba",fr:"Algieba"},raHours:10.3329,decDeg:19.8415,mag:2.01},{name:{en:"Diphda",fr:"Diphda"},raHours:.7265,decDeg:-17.9866,mag:2.04},{name:{en:"Nunki",fr:"Nunki"},raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:{en:"Menkent",fr:"Menkent"},raHours:14.1114,decDeg:-36.37,mag:2.06},{name:{en:"Alpheratz",fr:"Alpheratz"},raHours:.1398,decDeg:29.0904,mag:2.07},{name:{en:"Mirach",fr:"Mirach"},raHours:1.1622,decDeg:35.6206,mag:2.07},{name:{en:"Saiph",fr:"Saiph"},raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:{en:"Kochab",fr:"Kochab"},raHours:14.8451,decDeg:74.1555,mag:2.07},{name:{en:"Tiaki",fr:"Tiaki"},raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:{en:"Rasalhague",fr:"Rasalhague"},raHours:17.5822,decDeg:12.56,mag:2.08},{name:{en:"Algol",fr:"Algol"},raHours:3.1361,decDeg:40.9556,mag:2.09},{name:{en:"Almach",fr:"Almach"},raHours:2.065,decDeg:42.3297,mag:2.1},{name:{en:"Denebola",fr:"Denebola"},raHours:11.8177,decDeg:14.5721,mag:2.14},{name:{en:"Cih",fr:"Cih"},raHours:.9451,decDeg:60.7167,mag:2.15},{name:{en:"γ Centauri",fr:"γ Centauri"},raHours:12.692,decDeg:-48.9599,mag:2.2},{name:{en:"Naos",fr:"Naos"},raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:{en:"Aspidiske",fr:"Aspidiske"},raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:{en:"Alphecca",fr:"Alphecca"},raHours:15.5781,decDeg:26.7147,mag:2.22},{name:{en:"Suhail",fr:"Suhail"},raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:{en:"Mizar",fr:"Mizar"},raHours:13.3987,decDeg:54.9254,mag:2.23},{name:{en:"Sadr",fr:"Sadr"},raHours:20.3705,decDeg:40.2567,mag:2.23},{name:{en:"Schedar",fr:"Schedar"},raHours:.6751,decDeg:56.5373,mag:2.24},{name:{en:"Eltanin",fr:"Eltanin"},raHours:17.9434,decDeg:51.4889,mag:2.24},{name:{en:"Mintaka",fr:"Mintaka"},raHours:5.5334,decDeg:-.2991,mag:2.25},{name:{en:"Caph",fr:"Caph"},raHours:.1529,decDeg:59.1498,mag:2.28},{name:{en:"ε Centauri",fr:"ε Centauri"},raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:{en:"Dschubba",fr:"Dschubba"},raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:{en:"Larawag",fr:"Larawag"},raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:{en:"α Lupi",fr:"α Lupi"},raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:{en:"η Centauri",fr:"η Centauri"},raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:{en:"Merak",fr:"Merak"},raHours:11.0307,decDeg:56.3824,mag:2.34},{name:{en:"Izar",fr:"Izar"},raHours:14.7498,decDeg:27.0742,mag:2.35},{name:{en:"Enif",fr:"Enif"},raHours:21.7364,decDeg:9.875,mag:2.38},{name:{en:"κ Scorpii",fr:"κ Scorpii"},raHours:17.7081,decDeg:-39.03,mag:2.39},{name:{en:"Ankaa",fr:"Ankaa"},raHours:.4381,decDeg:-42.306,mag:2.4},{name:{en:"Phecda",fr:"Phecda"},raHours:11.8972,decDeg:53.6948,mag:2.41},{name:{en:"Sabik",fr:"Sabik"},raHours:17.173,decDeg:-15.7249,mag:2.43},{name:{en:"Scheat",fr:"Scheat"},raHours:23.0629,decDeg:28.0828,mag:2.44},{name:{en:"Aludra",fr:"Aludra"},raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:{en:"Alderamin",fr:"Alderamin"},raHours:21.3096,decDeg:62.5856,mag:2.45},{name:{en:"Markeb",fr:"Markeb"},raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:{en:"Aljanah",fr:"Aljanah"},raHours:20.7702,decDeg:33.9703,mag:2.48},{name:{en:"Markab",fr:"Markab"},raHours:23.0793,decDeg:15.2053,mag:2.49},{name:{en:"Menkar",fr:"Menkar"},raHours:3.038,decDeg:4.0897,mag:2.54},{name:{en:"ζ Ophiuchi",fr:"ζ Ophiuchi"},raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:{en:"ζ Centauri",fr:"ζ Centauri"},raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:{en:"Zosma",fr:"Zosma"},raHours:11.2351,decDeg:20.5237,mag:2.56},{name:{en:"Acrab",fr:"Acrab"},raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:{en:"Arneb",fr:"Arneb"},raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:{en:"δ Centauri",fr:"δ Centauri"},raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:{en:"Gienah",fr:"Gienah"},raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:{en:"Ascella",fr:"Ascella"},raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:{en:"Zubeneschamali",fr:"Zubeneschamali"},raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:{en:"Unukalhai",fr:"Unukalhai"},raHours:15.7378,decDeg:6.4256,mag:2.63},{name:{en:"Sheratan",fr:"Sheratan"},raHours:1.9107,decDeg:20.808,mag:2.64},{name:{en:"Phact",fr:"Phact"},raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:{en:"Mahasim",fr:"Mahasim"},raHours:5.9954,decDeg:37.2126,mag:2.65},{name:{en:"Kraz",fr:"Kraz"},raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:{en:"Ruchbah",fr:"Ruchbah"},raHours:1.4302,decDeg:60.2353,mag:2.66},{name:{en:"Muphrid",fr:"Muphrid"},raHours:13.9114,decDeg:18.3977,mag:2.68},{name:{en:"β Lupi",fr:"β Lupi"},raHours:14.9755,decDeg:-43.134,mag:2.68},{name:{en:"Hassaleh",fr:"Hassaleh"},raHours:4.9499,decDeg:33.1661,mag:2.69},{name:{en:"μ Velorum",fr:"μ Velorum"},raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:{en:"α Muscae",fr:"α Muscae"},raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:{en:"Lesath",fr:"Lesath"},raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:{en:"π Puppis",fr:"π Puppis"},raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:{en:"Kaus Media",fr:"Kaus Media"},raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:{en:"Tarazed",fr:"Tarazed"},raHours:19.771,decDeg:10.6133,mag:2.72},{name:{en:"Yed Prior",fr:"Yed Prior"},raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:{en:"Athebyne",fr:"Athebyne"},raHours:16.3999,decDeg:61.5142,mag:2.73},{name:{en:"θ Carinae",fr:"θ Carinae"},raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:{en:"Porrima",fr:"Porrima"},raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:{en:"Hatysa",fr:"Hatysa"},raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:{en:"ι Centauri",fr:"ι Centauri"},raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:{en:"Zubenelgenubi",fr:"Zubenelgenubi"},raHours:14.848,decDeg:-16.0418,mag:2.75},{name:{en:"Cebalrai",fr:"Cebalrai"},raHours:17.7245,decDeg:4.5673,mag:2.76},{name:{en:"Cursa",fr:"Cursa"},raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:{en:"Kornephoros",fr:"Kornephoros"},raHours:16.5037,decDeg:21.4896,mag:2.78},{name:{en:"Rasalgethi",fr:"Rasalgethi"},raHours:17.2441,decDeg:14.3903,mag:2.78},{name:{en:"Imai",fr:"Imai"},raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:{en:"Rastaban",fr:"Rastaban"},raHours:17.5072,decDeg:52.3014,mag:2.79},{name:{en:"γ Lupi",fr:"γ Lupi"},raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:{en:"Nihal",fr:"Nihal"},raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:{en:"ζ Herculis",fr:"ζ Herculis"},raHours:16.6881,decDeg:31.6027,mag:2.81},{name:{en:"β Hydri",fr:"β Hydri"},raHours:.4279,decDeg:-77.2542,mag:2.82},{name:{en:"Paikauhale",fr:"Paikauhale"},raHours:16.598,decDeg:-28.216,mag:2.82},{name:{en:"Kaus Borealis",fr:"Kaus Borealis"},raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:{en:"Algenib",fr:"Algenib"},raHours:.2206,decDeg:15.1836,mag:2.83},{name:{en:"Tureis",fr:"Tureis"},raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:{en:"β Trianguli Australis",fr:"β Trianguli Australis"},raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:{en:"ζ Persei",fr:"ζ Persei"},raHours:3.9022,decDeg:31.8836,mag:2.84},{name:{en:"β Arae",fr:"β Arae"},raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:{en:"α Arae",fr:"α Arae"},raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:{en:"Alcyone",fr:"Alcyone"},raHours:3.7914,decDeg:24.1051,mag:2.85},{name:{en:"Vindemiatrix",fr:"Vindemiatrix"},raHours:13.0363,decDeg:10.9591,mag:2.85},{name:{en:"Deneb Algedi",fr:"Deneb Algedi"},raHours:21.784,decDeg:-16.1273,mag:2.85},{name:{en:"Castor B",fr:"Castor B"},raHours:7.5768,decDeg:31.8905,mag:2.85},{name:{en:"α Hydri",fr:"α Hydri"},raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:{en:"Fawaris",fr:"Fawaris"},raHours:19.7496,decDeg:45.1308,mag:2.86},{name:{en:"Tejat",fr:"Tejat"},raHours:6.3827,decDeg:22.5136,mag:2.87},{name:{en:"γ Trianguli Australis",fr:"γ Trianguli Australis"},raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:{en:"α Tucanae",fr:"α Tucanae"},raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:{en:"Acamar",fr:"Acamar"},raHours:2.971,decDeg:-40.3047,mag:2.88},{name:{en:"Albaldah",fr:"Albaldah"},raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:{en:"Gomeisa",fr:"Gomeisa"},raHours:7.4525,decDeg:8.2893,mag:2.89},{name:{en:"Cor Caroli",fr:"Cor Caroli"},raHours:12.9338,decDeg:38.3184,mag:2.89},{name:{en:"Fang",fr:"Fang"},raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:{en:"ε Persei",fr:"ε Persei"},raHours:3.9642,decDeg:40.0102,mag:2.9},{name:{en:"Alniyat",fr:"Alniyat"},raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:{en:"Sadalsuud",fr:"Sadalsuud"},raHours:21.526,decDeg:-5.5712,mag:2.9},{name:{en:"γ Persei",fr:"γ Persei"},raHours:3.0799,decDeg:53.5064,mag:2.91},{name:{en:"υ Carinae",fr:"υ Carinae"},raHours:9.785,decDeg:-65.072,mag:2.92},{name:{en:"Matar",fr:"Matar"},raHours:22.7167,decDeg:30.2212,mag:2.93},{name:{en:"τ Puppis",fr:"τ Puppis"},raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:{en:"Algorab",fr:"Algorab"},raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:{en:"Sadalmelik",fr:"Sadalmelik"},raHours:22.0964,decDeg:-.3199,mag:2.95},{name:{en:"Zaurak",fr:"Zaurak"},raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:{en:"Tianguan",fr:"Tianguan"},raHours:5.6274,decDeg:21.1425,mag:2.97},{name:{en:"Ras Elased Australis",fr:"Ras Elased Australis"},raHours:9.7642,decDeg:23.7743,mag:2.97},{name:{en:"Alnasl",fr:"Alnasl"},raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:{en:"γ Hydrae",fr:"γ Hydrae"},raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:{en:"ι¹ Scorpii",fr:"ι¹ Scorpii"},raHours:17.7931,decDeg:-40.127,mag:2.99},{name:{en:"Okab",fr:"Okab"},raHours:19.0902,decDeg:13.8635,mag:2.99},{name:{en:"β Trianguli",fr:"β Trianguli"},raHours:2.1591,decDeg:34.9873,mag:3},{name:{en:"ψ Ursae Majoris",fr:"ψ Ursae Majoris"},raHours:11.1611,decDeg:44.4985,mag:3},{name:{en:"Pherkad",fr:"Pherkad"},raHours:15.3455,decDeg:71.834,mag:3},{name:{en:"Xamidimura",fr:"Xamidimura"},raHours:16.8645,decDeg:-38.0474,mag:3},{name:{en:"Aldhanab",fr:"Aldhanab"},raHours:21.8988,decDeg:-37.3649,mag:3}],Cr=64,$t=Cr+1,Kp=512,q_=900,Y_=700/900,K_=0,$_=.01;function Z_(s,e,t){return{north:zi(0,-t,s,e).lat,south:zi(0,t,s,e).lat,east:zi(t,0,s,e).lng,west:zi(-t,0,s,e).lng}}async function J_(s,e,t,n=q_){const i=n,a=n*Y_,r=Z_(s,e,i),o={width:$t,height:$t},[l,c]=await Promise.all([t.elevation.getElevationGrid(r,o),t.imagery.getImageryTexture(r,{width:Kp,height:Kp})]),h=Math.floor($t/2),d=l.heights[h*$t+h],u=new Float32Array($t*$t*3),f=new Float32Array($t*$t*2),g=new Float32Array($t*$t*4);for(let M=0;M<$t;M++){const E=M/($t-1),I=r.north+(r.south-r.north)*E;for(let y=0;y<$t;y++){const T=y/($t-1),C=r.west+(r.east-r.west)*T,{x:D,z:P}=gn(I,C,s,e),V=l.heights[M*$t+y],q=K_+$_+(V-d),O=M*$t+y;u[O*3]=D,u[O*3+1]=q,u[O*3+2]=P;const W=mm(c.bounds,C,I);f[O*2]=W.x,f[O*2+1]=W.y;const G=Math.max(Math.abs(D),Math.abs(P)),Z=1-j_((G-a)/(i-a),0,1);g[O*4]=1,g[O*4+1]=1,g[O*4+2]=1,g[O*4+3]=Z}}const v=new Uint16Array(Cr*Cr*6);let p=0;for(let M=0;M<Cr;M++)for(let E=0;E<Cr;E++){const I=M*$t+E,y=I+1,T=I+$t,C=T+1;v[p++]=I,v[p++]=T,v[p++]=y,v[p++]=y,v[p++]=T,v[p++]=C}const m=new Dt;m.setAttribute("position",new gt(u,3)),m.setAttribute("uv",new gt(f,2)),m.setAttribute("color",new gt(g,4)),m.setIndex(new gt(v,1)),m.computeVertexNormals();const S=new Ai(c.source);S.flipY=!1;const _=new eo({map:S,color:new ve(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),x=new Ze(m,_);return x.receiveShadow=!0,x.castShadow=!0,{mesh:x,attribution:t.imagery.attribution}}function j_(s,e,t){return Math.max(e,Math.min(t,s))}const Q_=18,eE=.55,tE=.5,nE=`
6036
6046
  attribute float aSpeed;
6037
6047
  uniform float uTime;
6038
6048
  uniform float uOverallSpeed;
@@ -6132,7 +6142,7 @@ void main() {
6132
6142
  float blur = max(vNearBlur, vHaze);
6133
6143
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${tE.toFixed(2)}));
6134
6144
  }
6135
- `;function sE(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const aE=.14,$p=4.5;let Zo;function rE(){if(Zo)return Zo;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createImageData(s,s),i=s/2,a=s*aE,r=s-a;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=l+.5-i,h=o+.5<a?o+.5-a:o+.5>r?o+.5-r:0,d=Math.hypot(c,h),u=Math.exp(-(d*d)/(2*$p*$p)),f=(o*s+l)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,u))}return t.putImageData(n,0,0),Zo=new Ai(e),Zo}function oE(s){const e=sE(s.seed),t=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let c=0;c<s.count;c++){const h=e()*Math.PI*2,d=Math.sqrt(e())*s.radiusM;t[c*3]=Math.cos(h)*d,t[c*3+1]=e()*s.heightM,t[c*3+2]=Math.sin(h)*d,n[c]=.85+e()*.3}const a=new Dt;a.setAttribute("position",new vt(t,3)),a.setAttribute("aSpeed",new vt(n,1)),a.setDrawRange(0,s.visibleCount);const r={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Re(0,0)},uDropVelocity:{value:new R(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:rE()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Nt({uniforms:r,vertexShader:nE,fragmentShader:iE,transparent:!0,depthWrite:!1,depthTest:!0}),l=new ml(a,o);return l.frustumCulled=!1,{points:l,uniforms:r}}const lE=`
6145
+ `;function sE(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const aE=.14,$p=4.5;let Zo;function rE(){if(Zo)return Zo;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createImageData(s,s),i=s/2,a=s*aE,r=s-a;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=l+.5-i,h=o+.5<a?o+.5-a:o+.5>r?o+.5-r:0,d=Math.hypot(c,h),u=Math.exp(-(d*d)/(2*$p*$p)),f=(o*s+l)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,u))}return t.putImageData(n,0,0),Zo=new Ai(e),Zo}function oE(s){const e=sE(s.seed),t=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let c=0;c<s.count;c++){const h=e()*Math.PI*2,d=Math.sqrt(e())*s.radiusM;t[c*3]=Math.cos(h)*d,t[c*3+1]=e()*s.heightM,t[c*3+2]=Math.sin(h)*d,n[c]=.85+e()*.3}const a=new Dt;a.setAttribute("position",new gt(t,3)),a.setAttribute("aSpeed",new gt(n,1)),a.setDrawRange(0,s.visibleCount);const r={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Re(0,0)},uDropVelocity:{value:new R(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:rE()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Nt({uniforms:r,vertexShader:nE,fragmentShader:iE,transparent:!0,depthWrite:!1,depthTest:!0}),l=new ml(a,o);return l.frustumCulled=!1,{points:l,uniforms:r}}const lE=`
6136
6146
  varying vec3 vDir;
6137
6147
 
6138
6148
  void main() {
@@ -6424,7 +6434,7 @@ void main() {
6424
6434
  vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
6425
6435
  gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
6426
6436
  }
6427
- `,transparent:!0,blending:ti,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(Kn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,n,i){const a=new nr(e,t,n,yn,cn);return a.minFilter=At,a.magFilter=At,a.wrapS=i,a.wrapT=vn,a.needsUpdate=!0,a}set onReady(e){this.repaint=e}update(e){if(We.moonlessMagPerArcsec2(e.sunAltitudeDeg)<Kn.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(e.galactic),n.uEclipticPole.value.copy(e.eclipticPole).normalize(),n.uSunLongitude.value.copy(e.sunLongitude).normalize(),n.uMoonDirection.value.copy(e.moon.direction).normalize(),n.uSunDirection.value.copy(e.sunDirection).normalize(),n.uMoonOutput.value=We.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),n.uTwilightOutput.value=We.twilightOutput(e.sunAltitudeDeg),n.uSkyColor.value.copy(e.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(e){this.material.uniforms.uEncodeDestination.value=e?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const t=performance.now()+Kn.WORK_BUDGET_MS;for(;performance.now()<t&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Kn.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Kn.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(e,t){for(let n=0;n<t.data.length;n++)e[n*4]=ms.toHalfFloat(We.nanolambertsOfS10(t.data[n])),e[n*4+3]=ms.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ln{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(e,t){return{centre:Ln.at(Ln.GALACTIC_CENTRE,e,t),rotation:Ln.at(Ln.GALACTIC_ROTATION,e,t),pole:Ln.at(Ln.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return Ln.at(Ln.ECLIPTIC_POLE,e,t)}static at(e,t,n){return tr(e.raHours,e.decDeg,t,n,!1)}}const uE=`
6437
+ `,transparent:!0,blending:ni,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(Kn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,n,i){const a=new nr(e,t,n,yn,hn);return a.minFilter=At,a.magFilter=At,a.wrapS=i,a.wrapT=vn,a.needsUpdate=!0,a}set onReady(e){this.repaint=e}update(e){if(We.moonlessMagPerArcsec2(e.sunAltitudeDeg)<Kn.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(e.galactic),n.uEclipticPole.value.copy(e.eclipticPole).normalize(),n.uSunLongitude.value.copy(e.sunLongitude).normalize(),n.uMoonDirection.value.copy(e.moon.direction).normalize(),n.uSunDirection.value.copy(e.sunDirection).normalize(),n.uMoonOutput.value=We.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),n.uTwilightOutput.value=We.twilightOutput(e.sunAltitudeDeg),n.uSkyColor.value.copy(e.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(e){this.material.uniforms.uEncodeDestination.value=e?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const t=performance.now()+Kn.WORK_BUDGET_MS;for(;performance.now()<t&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Kn.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Kn.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(e,t){for(let n=0;n<t.data.length;n++)e[n*4]=ms.toHalfFloat(We.nanolambertsOfS10(t.data[n])),e[n*4+3]=ms.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ln{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(e,t){return{centre:Ln.at(Ln.GALACTIC_CENTRE,e,t),rotation:Ln.at(Ln.GALACTIC_ROTATION,e,t),pole:Ln.at(Ln.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return Ln.at(Ln.ECLIPTIC_POLE,e,t)}static at(e,t,n){return tr(e.raHours,e.decDeg,t,n,!1)}}const uE=`
6428
6438
  varying vec2 vUv;
6429
6439
  void main() {
6430
6440
  vUv = uv;
@@ -6860,7 +6870,7 @@ void main()
6860
6870
  // stays what it always was for the optional artifacts.
6861
6871
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
6862
6872
  }
6863
- `;let Jo;function pE(){if(Jo)return Jo;const s=256,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,s,s);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[i,a,r,o]of n){const l=t.createRadialGradient(i*s,a*s,0,i*s,a*s,r*s);l.addColorStop(0,`rgba(200,200,200,${o})`),l.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=l,t.fillRect(0,0,s,s)}return Jo=new Ai(e),Jo}function mE(){const s={uTime:{value:0},uResolution:{value:new Re(1,1)},uLensPosition:{value:new Re(0,0)},uColorGain:{value:new ve(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new ve(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:pE()}},e=new Nt({uniforms:s,vertexShader:uE,fragmentShader:fE,transparent:!0,depthWrite:!1,depthTest:!1,blending:ti,fog:!1,name:"LensFlareShader"}),t=new Ze(new Zi(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:s}}class kr{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target=new En(this.width,this.height,{type:cn}),this.material=new Nt({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Re(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
6873
+ `;let Jo;function pE(){if(Jo)return Jo;const s=256,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,s,s);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[i,a,r,o]of n){const l=t.createRadialGradient(i*s,a*s,0,i*s,a*s,r*s);l.addColorStop(0,`rgba(200,200,200,${o})`),l.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=l,t.fillRect(0,0,s,s)}return Jo=new Ai(e),Jo}function mE(){const s={uTime:{value:0},uResolution:{value:new Re(1,1)},uLensPosition:{value:new Re(0,0)},uColorGain:{value:new ve(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new ve(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:pE()}},e=new Nt({uniforms:s,vertexShader:uE,fragmentShader:fE,transparent:!0,depthWrite:!1,depthTest:!1,blending:ni,fog:!1,name:"LensFlareShader"}),t=new Ze(new Zi(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:s}}class kr{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target=new Tn(this.width,this.height,{type:hn}),this.material=new Nt({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Re(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
6864
6874
  varying vec2 vNdc;
6865
6875
  void main() {
6866
6876
  vNdc = position.xy;
@@ -6900,7 +6910,7 @@ void main()
6900
6910
  vec3 colour = texture2D(uSource, src * 0.5 + 0.5).rgb;
6901
6911
  gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
6902
6912
  }
6903
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Ze(new Zi(2,2),this.material))}directionFor(e,t,n){const i=this.width/this.height,a=n/2*Math.PI/180,r=e*i*a,o=t*a,l=Math.hypot(r,o);if(l<1e-6)return{x:0,y:0,z:-1};const c=Math.sin(l);return{x:r/l*c,y:o/l*c,z:-Math.cos(l)}}static ndcFor(e,t,n){const i=Math.hypot(e.x,e.y,e.z);if(i===0||e.z>=0)return;const a=t/2*Math.PI/180,r=Math.acos(Math.min(1,-e.z/i)),o=Math.sin(r),l=o<1e-9?1:r/o,c=e.x/i*l,h=e.y/i*l;return{ndcX:c/(n*a),ndcY:h/a}}static cornerHalfAngleDeg(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(e,t,n,i,a,r){const o=this.width/this.height;this.material.uniforms.uHalfFovRad.value=i/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(i,o);const l=n.fov;n.fov=this.sourceFovDeg(i,o),n.updateProjectionMatrix(),a?.();const c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),r?.(),e.setRenderTarget(c),n.fov=l,n.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const n=kr.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(n)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class Ur{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t);const n=new Ks(this.width,this.height,ni);n.minFilter=Wt,n.magFilter=Wt,this.target=new En(this.width,this.height,{type:cn,depthTexture:n}),this.material=new Nt({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Re(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:Ur.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
6913
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Ze(new Zi(2,2),this.material))}directionFor(e,t,n){const i=this.width/this.height,a=n/2*Math.PI/180,r=e*i*a,o=t*a,l=Math.hypot(r,o);if(l<1e-6)return{x:0,y:0,z:-1};const c=Math.sin(l);return{x:r/l*c,y:o/l*c,z:-Math.cos(l)}}static ndcFor(e,t,n){const i=Math.hypot(e.x,e.y,e.z);if(i===0||e.z>=0)return;const a=t/2*Math.PI/180,r=Math.acos(Math.min(1,-e.z/i)),o=Math.sin(r),l=o<1e-9?1:r/o,c=e.x/i*l,h=e.y/i*l;return{ndcX:c/(n*a),ndcY:h/a}}static cornerHalfAngleDeg(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(e,t,n,i,a,r){const o=this.width/this.height;this.material.uniforms.uHalfFovRad.value=i/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(i,o);const l=n.fov;n.fov=this.sourceFovDeg(i,o),n.updateProjectionMatrix(),a?.();const c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),r?.(),e.setRenderTarget(c),n.fov=l,n.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const n=kr.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(n)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class Ur{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Kl;quadCamera=new ar(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t);const n=new Ks(this.width,this.height,ii);n.minFilter=Wt,n.magFilter=Wt,this.target=new Tn(this.width,this.height,{type:hn,depthTexture:n}),this.material=new Nt({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Re(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:Ur.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
6904
6914
  varying vec2 vUv;
6905
6915
  void main() {
6906
6916
  vUv = position.xy * 0.5 + 0.5;
@@ -6977,7 +6987,7 @@ void main()
6977
6987
  // values — and encoded only at the very end. See colorSpace.ts.
6978
6988
  gl_FragColor = vec4(forDestination(total / weight), colour.a);
6979
6989
  }
6980
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Ze(new Zi(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,i){const a=this.material.uniforms;a.uApertureMm2.value=e*e/Math.max(.1,t),a.uFocusDistance.value=Math.max(0,n),a.uFocalLengthMm.value=e,a.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n,i){const a=this.material.uniforms;a.uNear.value=n.near,a.uFar.value=n.far;const r=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),i?.(),e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class je{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const e=je.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,i=t*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/i}static parheliaAzimuthDeg(e,t=je.ICE_INDEX_RED){const n=je.minimumDeviationDeg(je.SIDE_PRISM_ANGLE_DEG,je.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=je.ICE_INDEX_RED){const n=je.parheliaAzimuthDeg(e,t);if(n===void 0)return;const i=e*Math.PI/180,a=Math.sin(i)**2,r=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,a+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=je.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=je.ICE_INDEX_RED){if(e<0||e>90-je.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),i=Math.sqrt(t*t-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return je.ringOf("halo22",je.SIDE_PRISM_ANGLE_DEG)}static halo46(){return je.ringOf("halo46",je.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=je.minimumDeviationDeg(t,je.ICE_INDEX_RED),i=je.minimumDeviationDeg(t,je.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(e,t,n=90,i=0){const a=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return a*r*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[je.halo22(),je.halo46()],i=e>0?je.parheliaDistanceDeg(e):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:je.parheliaDistanceDeg(e,je.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:je.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const a=je.circumzenithalAltitudeDeg(e);return a!==void 0&&n.push({id:"circumzenithal",angleDeg:a}),e>je.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<je.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Gl{static reflectance(e,t,n){const a=t/n*Math.sqrt(Math.max(0,1-e*e));if(a>=1)return 1;const r=Math.sqrt(Math.max(0,1-a*a)),o=(n*e-t*r)/(n*e+t*r),l=(t*e-n*r)/(t*e+n*r);return(o*o+l*l)/2}}class Jt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Jt.ANCHOR_BLUE-Jt.ANCHOR_RED)/(1/(Jt.BLUE_NM*Jt.BLUE_NM)-1/(Jt.RED_NM*Jt.RED_NM));static A=Jt.ANCHOR_RED-Jt.B/(Jt.RED_NM*Jt.RED_NM);static indexAt(e){return Jt.A+Jt.B/(e*e)}}class Wa{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),i=Math.sqrt(Math.max(0,1-n*n)),a=n/this.index,r=Math.sqrt(Math.max(0,1-a*a)),o=Math.asin(n),l=Math.asin(a),c=Gl.reflectance(i,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Wa.folded(Math.PI-2*o),t[h].weight=c,h++;const d=Gl.reflectance(r,this.index,1);let u=1-c;for(let f=1;f<=Wa.MAX_CHORDS&&h<t.length;f++){const g=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=Wa.folded(g),t[h].weight=u*(1-d),h++,u*=d}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class Qt{static get WATER_INDEX_RED(){return Jt.indexAt(Jt.RED_NM)}static get WATER_INDEX_BLUE(){return Jt.indexAt(Jt.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),a=Math.asin(Math.sin(i)/t),r=2*(i-a)+(e-1)*(Math.PI-2*a),o=2*Math.PI;let l=r%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return Qt.bowOf("primary",2,0)}static secondary(){return Qt.bowOf("secondary",3,0)}static bowOf(e,t,n){const i=Qt.radiusDeg(t,Qt.WATER_INDEX_RED),a=Qt.radiusDeg(t,Qt.WATER_INDEX_BLUE),r=(i+a)/2;return{id:e,radiusDeg:r,redRadiusDeg:i,violetRadiusDeg:a,topAltitudeDeg:r-n}}static alexandersBandDeg(){return{fromDeg:Qt.primary().redRadiusDeg,toDeg:Qt.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Qt.bowOf("primary",2,e),Qt.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-Qt.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t)));return i*a}}class Rn{constructor(e){this.radius=e;const t=Rn.SEGMENTS*Rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new Dt;n.setAttribute("position",new vt(this.positions,3)),n.setAttribute("color",new vt(this.colors,3)),n.setDrawRange(0,0),this.object=new Ze(n,new Vi({vertexColors:!0,transparent:!0,blending:ti,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(e,t,n){this.head=e&&fn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&fn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const i=this.angleBetween(t,n);if(i<=0){e.setDrawRange(0,0);return}const a=i*Rn.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(Rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+a*h),l=h=>this.brightness*(1-h)**Rn.FADE_POWER;let c=0;for(let h=1;h<Rn.POINTS;h++){const d=(h-1)/Rn.SEGMENTS,u=h/Rn.SEGMENTS;c=this.pushBand(c,r(d),r(u),o(d),o(u),l(d),l(u))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,i,a,r,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<Rn.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,i,h),f=this.across(n,l,a,h),g=this.across(t,l,i,d),v=this.across(n,l,a,d),p=(m,S)=>m===0?S:0;e=this.push(e,u,p(h,r)),e=this.push(e,f,p(h,o)),e=this.push(e,g,p(d,r)),e=this.push(e,f,p(h,o)),e=this.push(e,v,p(d,o)),e=this.push(e,g,p(d,r))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const a=Math.max(0,Math.min(1,n));return this.colors[i]=a*.55,this.colors[i+1]=a*.75,this.colors[i+2]=a,e+1}slerp(e,t,n){const i=this.angleBetweenRadians(e,t);if(i<1e-9)return e;const a=Math.sin(i),r=Math.sin((1-n)*i)/a,o=Math.sin(n*i)/a;return{x:e.x*r+t.x*o,y:e.y*r+t.y*o,z:e.z*r+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Mn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Mn.ANCHOR_BLUE-Mn.ANCHOR_RED)/(1/(Mn.BLUE_NM*Mn.BLUE_NM)-1/(Mn.RED_NM*Mn.RED_NM));static A=Mn.ANCHOR_RED-Mn.B/(Mn.RED_NM*Mn.RED_NM);static indexAt(e){return Mn.A+Mn.B/(e*e)}}class Zr{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,i,a,r){let o=0,l=0,c=0;Math.abs(n)<.9?(o=-t,l=e,c=0):(o=0,l=-n,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const d=t*c-n*l,u=n*o-e*c,f=e*l-t*o,g=a/2,v=r/2;for(let p=0;p<6;p++){const m=i+p*Math.PI/3,S=Math.cos(m),_=Math.sin(m);this.normals[p*3]=o*S+d*_,this.normals[p*3+1]=l*S+u*_,this.normals[p*3+2]=c*S+f*_,this.offsets[p]=g}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(g,v)}get aimRadius(){return this.radius}trace(e,t,n,i,a,r,o){let l=-t,c=e,h=0,d=Math.hypot(l,c,h);d<1e-6&&(l=1,c=0,h=0,d=1),l/=d,c/=d,h/=d;const u=t*h-n*c,f=n*l-e*h,g=e*c-t*l,v=l*i+u*a-e*this.radius*2,p=c*i+f*a-t*this.radius*2,m=h*i+g*a-n*this.radius*2;let S=-1,_=-1/0,x=1/0;for(let Q=0;Q<8;Q++){const ie=this.normals[Q*3],de=this.normals[Q*3+1],He=this.normals[Q*3+2],Je=ie*e+de*t+He*n,ze=this.offsets[Q]-(ie*v+de*p+He*m);if(Je>1e-9){const Y=ze/Je;Y<x&&(x=Y)}else if(Je<-1e-9){const Y=ze/Je;Y>_&&(_=Y,S=Q)}else if(ze<0)return 0}if(S<0||_>=x)return 0;let M=0;const E=this.normals[S*3],I=this.normals[S*3+1],y=this.normals[S*3+2],T=-(E*e+I*t+y*n),C=Gl.reflectance(T,1,r);o[M].x=e+2*T*E,o[M].y=t+2*T*I,o[M].z=n+2*T*y,o[M].weight=C,M++;const D=1/r,P=Math.sqrt(Math.max(0,1-D*D*(1-T*T)));let V=D*e+(D*T-P)*E,q=D*t+(D*T-P)*I,O=D*n+(D*T-P)*y,W=v+e*_,G=p+t*_,Z=m+n*_,te=1-C;for(let Q=0;Q<Zr.MAX_BOUNCES&&te>Zr.MIN_WEIGHT;Q++){let ie=-1,de=1/0;for(let F=0;F<8;F++){const _e=this.normals[F*3],Pe=this.normals[F*3+1],Ae=this.normals[F*3+2],be=_e*V+Pe*q+Ae*O;if(be<=1e-9)continue;const Ne=(this.offsets[F]-(_e*W+Pe*G+Ae*Z))/be;Ne>1e-9&&Ne<de&&(de=Ne,ie=F)}if(ie<0)break;const He=this.normals[ie*3],Je=this.normals[ie*3+1],ze=this.normals[ie*3+2],Y=He*V+Je*q+ze*O,ae=r*Math.sqrt(Math.max(0,1-Y*Y));if(W+=V*de,G+=q*de,Z+=O*de,ae<1){const F=Math.sqrt(Math.max(0,1-ae*ae)),_e=Gl.reflectance(Y,r,1);if(o[M].x=r*V-(r*Y-F)*He,o[M].y=r*q-(r*Y-F)*Je,o[M].z=r*O-(r*Y-F)*ze,o[M].weight=te*(1-_e),M++,M>=o.length)return M;te*=_e}const ne=2*Y;V-=ne*He,q-=ne*Je,O-=ne*ze}return M}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class jn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=jn.build(24);static build(e){const t=[];let n=0,i=0,a=0;for(let r=0;r<e;r++){const o=jn.VIOLET_NM+(r+.5)/e*(jn.DEEP_RED_NM-jn.VIOLET_NM),[l,c,h]=jn.colourMatching(o),d={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+1.057*h)};n+=d.r,i+=d.g,a+=d.b,t.push(d)}for(const r of t)r.r/=n,r.g/=i,r.b/=a;return t}static colourMatching(e){const t=(n,i,a)=>{const r=(e-n)/(e<n?i:a);return Math.exp(-.5*r*r)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class St{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new Zr;emergent=Array.from({length:Zr.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);radiance=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);scratch=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const i=St.WORST_TILT_DEG*(St.BEST_TILT_DEG/St.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(e){const t=St.AZIMUTH_BINS,n=St.ALTITUDE_BINS,i=this.tally,a=St.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(St.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,this.tilt);const h=this.random()*2*Math.PI,d=a*Math.sqrt(this.random()),u=o+d*Math.sin(h),f=d*Math.cos(h)/Math.max(.05,Math.cos(o)),g=-Math.cos(u)*Math.cos(f),v=-Math.cos(u)*Math.sin(f),p=-Math.sin(u),m=this.crystal.aimRadius,S=(this.random()*2-1)*m,_=(this.random()*2-1)*m,x=4*m*m,M=jn.SAMPLES[this.random()*jn.SAMPLES.length|0],E=this.crystal.trace(g,v,p,S,_,Mn.indexAt(M.wavelengthNm),this.emergent);for(let I=0;I<E;I++){const y=this.emergent[I],T=Math.hypot(y.x,y.y,y.z);if(T<1e-9||y.weight<=0)continue;const C=y.x/T,D=y.y/T,P=y.z/T;if(C*g+D*v+P*p>r)continue;const V=Math.asin(Math.max(-1,Math.min(1,-P))),q=Math.abs(Math.atan2(-D,-C)),O=Math.min(t-1,q/Math.PI*t|0),G=(Math.min(n-1,(V+Math.PI/2)/Math.PI*n|0)*t+O)*3,Z=y.weight*x*jn.SAMPLES.length;i[G]+=Z*M.r,i[G+1]+=Z*M.g,i[G+2]+=Z*M.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=St.AZIMUTH_BINS,t=St.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,i){return this.begin(e,t,i),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,i=Math.max(1,this.traced),a=4*St.REFERENCE_MICRONS*St.REFERENCE_MICRONS;for(let r=0;r<t;r++){const o=Math.sin(r/t*Math.PI-Math.PI/2),l=Math.sin((r+1)/t*Math.PI-Math.PI/2),c=1/(n*(l-o)*i*a);for(let h=0;h<e;h++){const d=(r*e+h)*3;this.radiance[d]=this.tally[d]*c,this.radiance[d+1]=this.tally[d+1]*c,this.radiance[d+2]=this.tally[d+2]*c}}}static REFERENCE_MICRONS=50;smooth(e,t){const n=this.scratch,i=this.radiance;n.set(i);for(let r=0;r<t;r++){const o=r*e*3;for(let l=0;l<3;l++){let c=n[o+l];for(let h=0;h<e;h++){const d=o+h*3+l,u=h+1<e?n[d+3]:n[d];i[d]=(c+2*n[d]+u)/4,c=n[d]}}}n.set(i);const a=e*3;for(let r=0;r<t;r++){const o=r>0?-a:0,l=r+1<t?a:0,c=r*a;for(let h=c;h<c+a;h++)i[h]=(n[h+o]+2*n[h]+n[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of St.POPULATIONS)if(t+=n.share,e<=t)return n;return St.POPULATIONS[St.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,a=0,r=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n),e.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(a,r,o,i,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class hi{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;object;material;sky=new St;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=hi.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=St.AZIMUTH_BINS,t=St.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new nr(this.texels,e,t,yn,cn),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=vn,this.texture.wrapT=vn,this.texture.needsUpdate=!0,this.material=new Nt({uniforms:{uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:hi.GAIN}},vertexShader:`
6990
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Ze(new Zi(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,i){const a=this.material.uniforms;a.uApertureMm2.value=e*e/Math.max(.1,t),a.uFocusDistance.value=Math.max(0,n),a.uFocalLengthMm.value=e,a.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n,i){const a=this.material.uniforms;a.uNear.value=n.near,a.uFar.value=n.far;const r=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),i?.(),e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class je{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const e=je.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,i=t*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/i}static parheliaAzimuthDeg(e,t=je.ICE_INDEX_RED){const n=je.minimumDeviationDeg(je.SIDE_PRISM_ANGLE_DEG,je.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=je.ICE_INDEX_RED){const n=je.parheliaAzimuthDeg(e,t);if(n===void 0)return;const i=e*Math.PI/180,a=Math.sin(i)**2,r=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,a+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=je.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=je.ICE_INDEX_RED){if(e<0||e>90-je.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),i=Math.sqrt(t*t-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return je.ringOf("halo22",je.SIDE_PRISM_ANGLE_DEG)}static halo46(){return je.ringOf("halo46",je.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=je.minimumDeviationDeg(t,je.ICE_INDEX_RED),i=je.minimumDeviationDeg(t,je.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(e,t,n=90,i=0){const a=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return a*r*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[je.halo22(),je.halo46()],i=e>0?je.parheliaDistanceDeg(e):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:je.parheliaDistanceDeg(e,je.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:je.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const a=je.circumzenithalAltitudeDeg(e);return a!==void 0&&n.push({id:"circumzenithal",angleDeg:a}),e>je.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<je.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Gl{static reflectance(e,t,n){const a=t/n*Math.sqrt(Math.max(0,1-e*e));if(a>=1)return 1;const r=Math.sqrt(Math.max(0,1-a*a)),o=(n*e-t*r)/(n*e+t*r),l=(t*e-n*r)/(t*e+n*r);return(o*o+l*l)/2}}class Jt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Jt.ANCHOR_BLUE-Jt.ANCHOR_RED)/(1/(Jt.BLUE_NM*Jt.BLUE_NM)-1/(Jt.RED_NM*Jt.RED_NM));static A=Jt.ANCHOR_RED-Jt.B/(Jt.RED_NM*Jt.RED_NM);static indexAt(e){return Jt.A+Jt.B/(e*e)}}class Wa{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),i=Math.sqrt(Math.max(0,1-n*n)),a=n/this.index,r=Math.sqrt(Math.max(0,1-a*a)),o=Math.asin(n),l=Math.asin(a),c=Gl.reflectance(i,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Wa.folded(Math.PI-2*o),t[h].weight=c,h++;const d=Gl.reflectance(r,this.index,1);let u=1-c;for(let f=1;f<=Wa.MAX_CHORDS&&h<t.length;f++){const g=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=Wa.folded(g),t[h].weight=u*(1-d),h++,u*=d}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class Qt{static get WATER_INDEX_RED(){return Jt.indexAt(Jt.RED_NM)}static get WATER_INDEX_BLUE(){return Jt.indexAt(Jt.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),a=Math.asin(Math.sin(i)/t),r=2*(i-a)+(e-1)*(Math.PI-2*a),o=2*Math.PI;let l=r%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return Qt.bowOf("primary",2,0)}static secondary(){return Qt.bowOf("secondary",3,0)}static bowOf(e,t,n){const i=Qt.radiusDeg(t,Qt.WATER_INDEX_RED),a=Qt.radiusDeg(t,Qt.WATER_INDEX_BLUE),r=(i+a)/2;return{id:e,radiusDeg:r,redRadiusDeg:i,violetRadiusDeg:a,topAltitudeDeg:r-n}}static alexandersBandDeg(){return{fromDeg:Qt.primary().redRadiusDeg,toDeg:Qt.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Qt.bowOf("primary",2,e),Qt.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-Qt.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t)));return i*a}}class Rn{constructor(e){this.radius=e;const t=Rn.SEGMENTS*Rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new Dt;n.setAttribute("position",new gt(this.positions,3)),n.setAttribute("color",new gt(this.colors,3)),n.setDrawRange(0,0),this.object=new Ze(n,new Vi({vertexColors:!0,transparent:!0,blending:ni,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(e,t,n){this.head=e&&pn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&pn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const i=this.angleBetween(t,n);if(i<=0){e.setDrawRange(0,0);return}const a=i*Rn.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(Rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+a*h),l=h=>this.brightness*(1-h)**Rn.FADE_POWER;let c=0;for(let h=1;h<Rn.POINTS;h++){const d=(h-1)/Rn.SEGMENTS,u=h/Rn.SEGMENTS;c=this.pushBand(c,r(d),r(u),o(d),o(u),l(d),l(u))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,i,a,r,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<Rn.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,i,h),f=this.across(n,l,a,h),g=this.across(t,l,i,d),v=this.across(n,l,a,d),p=(m,S)=>m===0?S:0;e=this.push(e,u,p(h,r)),e=this.push(e,f,p(h,o)),e=this.push(e,g,p(d,r)),e=this.push(e,f,p(h,o)),e=this.push(e,v,p(d,o)),e=this.push(e,g,p(d,r))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const a=Math.max(0,Math.min(1,n));return this.colors[i]=a*.55,this.colors[i+1]=a*.75,this.colors[i+2]=a,e+1}slerp(e,t,n){const i=this.angleBetweenRadians(e,t);if(i<1e-9)return e;const a=Math.sin(i),r=Math.sin((1-n)*i)/a,o=Math.sin(n*i)/a;return{x:e.x*r+t.x*o,y:e.y*r+t.y*o,z:e.z*r+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Sn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Sn.ANCHOR_BLUE-Sn.ANCHOR_RED)/(1/(Sn.BLUE_NM*Sn.BLUE_NM)-1/(Sn.RED_NM*Sn.RED_NM));static A=Sn.ANCHOR_RED-Sn.B/(Sn.RED_NM*Sn.RED_NM);static indexAt(e){return Sn.A+Sn.B/(e*e)}}class Zr{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,i,a,r){let o=0,l=0,c=0;Math.abs(n)<.9?(o=-t,l=e,c=0):(o=0,l=-n,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const d=t*c-n*l,u=n*o-e*c,f=e*l-t*o,g=a/2,v=r/2;for(let p=0;p<6;p++){const m=i+p*Math.PI/3,S=Math.cos(m),_=Math.sin(m);this.normals[p*3]=o*S+d*_,this.normals[p*3+1]=l*S+u*_,this.normals[p*3+2]=c*S+f*_,this.offsets[p]=g}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(g,v)}get aimRadius(){return this.radius}trace(e,t,n,i,a,r,o){let l=-t,c=e,h=0,d=Math.hypot(l,c,h);d<1e-6&&(l=1,c=0,h=0,d=1),l/=d,c/=d,h/=d;const u=t*h-n*c,f=n*l-e*h,g=e*c-t*l,v=l*i+u*a-e*this.radius*2,p=c*i+f*a-t*this.radius*2,m=h*i+g*a-n*this.radius*2;let S=-1,_=-1/0,x=1/0;for(let Q=0;Q<8;Q++){const ie=this.normals[Q*3],de=this.normals[Q*3+1],He=this.normals[Q*3+2],Je=ie*e+de*t+He*n,ze=this.offsets[Q]-(ie*v+de*p+He*m);if(Je>1e-9){const Y=ze/Je;Y<x&&(x=Y)}else if(Je<-1e-9){const Y=ze/Je;Y>_&&(_=Y,S=Q)}else if(ze<0)return 0}if(S<0||_>=x)return 0;let M=0;const E=this.normals[S*3],I=this.normals[S*3+1],y=this.normals[S*3+2],T=-(E*e+I*t+y*n),C=Gl.reflectance(T,1,r);o[M].x=e+2*T*E,o[M].y=t+2*T*I,o[M].z=n+2*T*y,o[M].weight=C,M++;const D=1/r,P=Math.sqrt(Math.max(0,1-D*D*(1-T*T)));let V=D*e+(D*T-P)*E,q=D*t+(D*T-P)*I,O=D*n+(D*T-P)*y,W=v+e*_,G=p+t*_,Z=m+n*_,te=1-C;for(let Q=0;Q<Zr.MAX_BOUNCES&&te>Zr.MIN_WEIGHT;Q++){let ie=-1,de=1/0;for(let F=0;F<8;F++){const _e=this.normals[F*3],Pe=this.normals[F*3+1],Ae=this.normals[F*3+2],be=_e*V+Pe*q+Ae*O;if(be<=1e-9)continue;const Ne=(this.offsets[F]-(_e*W+Pe*G+Ae*Z))/be;Ne>1e-9&&Ne<de&&(de=Ne,ie=F)}if(ie<0)break;const He=this.normals[ie*3],Je=this.normals[ie*3+1],ze=this.normals[ie*3+2],Y=He*V+Je*q+ze*O,ae=r*Math.sqrt(Math.max(0,1-Y*Y));if(W+=V*de,G+=q*de,Z+=O*de,ae<1){const F=Math.sqrt(Math.max(0,1-ae*ae)),_e=Gl.reflectance(Y,r,1);if(o[M].x=r*V-(r*Y-F)*He,o[M].y=r*q-(r*Y-F)*Je,o[M].z=r*O-(r*Y-F)*ze,o[M].weight=te*(1-_e),M++,M>=o.length)return M;te*=_e}const ne=2*Y;V-=ne*He,q-=ne*Je,O-=ne*ze}return M}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class jn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=jn.build(24);static build(e){const t=[];let n=0,i=0,a=0;for(let r=0;r<e;r++){const o=jn.VIOLET_NM+(r+.5)/e*(jn.DEEP_RED_NM-jn.VIOLET_NM),[l,c,h]=jn.colourMatching(o),d={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+1.057*h)};n+=d.r,i+=d.g,a+=d.b,t.push(d)}for(const r of t)r.r/=n,r.g/=i,r.b/=a;return t}static colourMatching(e){const t=(n,i,a)=>{const r=(e-n)/(e<n?i:a);return Math.exp(-.5*r*r)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class St{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new Zr;emergent=Array.from({length:Zr.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);radiance=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);scratch=new Float32Array(St.AZIMUTH_BINS*St.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const i=St.WORST_TILT_DEG*(St.BEST_TILT_DEG/St.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(e){const t=St.AZIMUTH_BINS,n=St.ALTITUDE_BINS,i=this.tally,a=St.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(St.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,this.tilt);const h=this.random()*2*Math.PI,d=a*Math.sqrt(this.random()),u=o+d*Math.sin(h),f=d*Math.cos(h)/Math.max(.05,Math.cos(o)),g=-Math.cos(u)*Math.cos(f),v=-Math.cos(u)*Math.sin(f),p=-Math.sin(u),m=this.crystal.aimRadius,S=(this.random()*2-1)*m,_=(this.random()*2-1)*m,x=4*m*m,M=jn.SAMPLES[this.random()*jn.SAMPLES.length|0],E=this.crystal.trace(g,v,p,S,_,Sn.indexAt(M.wavelengthNm),this.emergent);for(let I=0;I<E;I++){const y=this.emergent[I],T=Math.hypot(y.x,y.y,y.z);if(T<1e-9||y.weight<=0)continue;const C=y.x/T,D=y.y/T,P=y.z/T;if(C*g+D*v+P*p>r)continue;const V=Math.asin(Math.max(-1,Math.min(1,-P))),q=Math.abs(Math.atan2(-D,-C)),O=Math.min(t-1,q/Math.PI*t|0),G=(Math.min(n-1,(V+Math.PI/2)/Math.PI*n|0)*t+O)*3,Z=y.weight*x*jn.SAMPLES.length;i[G]+=Z*M.r,i[G+1]+=Z*M.g,i[G+2]+=Z*M.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=St.AZIMUTH_BINS,t=St.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,i){return this.begin(e,t,i),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,i=Math.max(1,this.traced),a=4*St.REFERENCE_MICRONS*St.REFERENCE_MICRONS;for(let r=0;r<t;r++){const o=Math.sin(r/t*Math.PI-Math.PI/2),l=Math.sin((r+1)/t*Math.PI-Math.PI/2),c=1/(n*(l-o)*i*a);for(let h=0;h<e;h++){const d=(r*e+h)*3;this.radiance[d]=this.tally[d]*c,this.radiance[d+1]=this.tally[d+1]*c,this.radiance[d+2]=this.tally[d+2]*c}}}static REFERENCE_MICRONS=50;smooth(e,t){const n=this.scratch,i=this.radiance;n.set(i);for(let r=0;r<t;r++){const o=r*e*3;for(let l=0;l<3;l++){let c=n[o+l];for(let h=0;h<e;h++){const d=o+h*3+l,u=h+1<e?n[d+3]:n[d];i[d]=(c+2*n[d]+u)/4,c=n[d]}}}n.set(i);const a=e*3;for(let r=0;r<t;r++){const o=r>0?-a:0,l=r+1<t?a:0,c=r*a;for(let h=c;h<c+a;h++)i[h]=(n[h+o]+2*n[h]+n[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of St.POPULATIONS)if(t+=n.share,e<=t)return n;return St.POPULATIONS[St.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,a=0,r=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));a=l*Math.cos(n),r=l*Math.sin(n),e.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(a,r,o,i,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class di{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;object;material;sky=new St;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=di.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=St.AZIMUTH_BINS,t=St.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new nr(this.texels,e,t,yn,hn),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=vn,this.texture.wrapT=vn,this.texture.needsUpdate=!0,this.material=new Nt({uniforms:{uSource:{value:new R(0,1,0)},uUp:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:di.GAIN}},vertexShader:`
6981
6991
  varying vec3 vDirection;
6982
6992
  void main() {
6983
6993
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -7027,7 +7037,7 @@ void main()
7027
7037
  // display fades at the edge of a fibre instead of ending on a cut line.
7028
7038
  gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
7029
7039
  }
7030
- `,transparent:!0,blending:ti,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(hi.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(e){this.onRepaint=e}update(e,t,n,i,a,r){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(e.x,e.y,e.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=a.cover,o.uIceHeight.value=a.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(t,r)}requestMap(e,t){!(!(Math.abs(e-this.mappedAltitudeDeg)<hi.ALTITUDE_STEP_DEG)||t!==this.mappedAlignment)||this.tracingFor(e,t)||(this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.nextGlimpse=hi.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<hi.ALTITUDE_STEP_DEG&&t===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(hi.RAYS_PER_FRAME);const t=this.sky.tracedRays>=hi.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(t||n)&&this.publish(),t){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const t=this.sky.harvest().data;for(let n=0,i=0;i<t.length;n+=4,i+=3)this.texels[n]=ms.toHalfFloat(t[i]),this.texels[n+1]=ms.toHalfFloat(t[i+1]),this.texels[n+2]=ms.toHalfFloat(t[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ut{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Wa;previous=Ut.emergences();current=Ut.emergences();tally=new Float32Array(Ut.BINS*3);radiance=new Float32Array(Ut.BINS*3);scratch=new Float32Array(Ut.BINS*3);static emergences(){return Array.from({length:Wa.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of jn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ut.BINS,data:this.radiance,binDeg:180/Ut.BINS}}sweep(e){this.drop.refractiveIndex=Jt.indexAt(e.wavelengthNm);const t=Ut.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/t;for(let a=1;a<=t;a++){const r=this.drop.trace(Math.sqrt(a/t),this.current);for(let o=0;o<Math.min(r,n);o++){const l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.weight)/2*i,e)}n=r,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,i){if(n<=0)return;const a=Ut.BINS,r=Math.PI/a,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(a-1,Math.max(0,Math.floor(o/r))),d=Math.min(a-1,Math.max(0,Math.floor(l/r)));if(c<=0||h===d){this.add(h,n,i);return}for(let u=h;u<=d;u++){const f=Math.min(l,(u+1)*r)-Math.max(o,u*r);f>0&&this.add(u,n*f/c,i)}}add(e,t,n){const i=e*3,a=t*jn.SAMPLES.length;this.tally[i]+=a*n.r,this.tally[i+1]+=a*n.g,this.tally[i+2]+=a*n.b}toRadiance(){const e=Ut.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const i=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),a=i>0?this.backwardShare((n+.5)*(180/e))/i:0,r=n*3;this.radiance[r]=this.tally[r]*a,this.radiance[r+1]=this.tally[r+1]*a,this.radiance[r+2]=this.tally[r+2]*a}}backwardShare(e){const t=180-e;if(t<=Ut.FULL_UNTIL_DEG)return 1;if(t>=Ut.FADED_BY_DEG)return 0;const n=(t-Ut.FULL_UNTIL_DEG)/(Ut.FADED_BY_DEG-Ut.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=Ut.BINS,t=Ut.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),i=[];let a=0;for(let r=-n;r<=n;r++){const o=Math.max(0,t*t-r*r),l=Math.sqrt(o);i.push(l),a+=l}if(!(a<=0)){this.scratch.set(this.radiance);for(let r=0;r<e;r++){let o=0,l=0,c=0;for(let d=-n;d<=n;d++){const u=Math.min(e-1,Math.max(0,r+d))*3,f=i[d+n];o+=this.scratch[u]*f,l+=this.scratch[u+1]*f,c+=this.scratch[u+2]*f}const h=r*3;this.radiance[h]=o/a,this.radiance[h+1]=l/a,this.radiance[h+2]=c/a}}}}class Fr{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ut;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ut.BINS*4),this.texture=new nr(this.texels,Ut.BINS,1,yn,cn),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=vn,this.texture.wrapT=vn,this.texture.needsUpdate=!0,this.material=new Nt({uniforms:{uSource:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Fr.GAIN}},vertexShader:`
7040
+ `,transparent:!0,blending:ni,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(di.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(e){this.onRepaint=e}update(e,t,n,i,a,r){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(e.x,e.y,e.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=a.cover,o.uIceHeight.value=a.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(t,r)}requestMap(e,t){!(!(Math.abs(e-this.mappedAltitudeDeg)<di.ALTITUDE_STEP_DEG)||t!==this.mappedAlignment)||this.tracingFor(e,t)||(this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.nextGlimpse=di.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<di.ALTITUDE_STEP_DEG&&t===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(di.RAYS_PER_FRAME);const t=this.sky.tracedRays>=di.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(t||n)&&this.publish(),t){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const t=this.sky.harvest().data;for(let n=0,i=0;i<t.length;n+=4,i+=3)this.texels[n]=ms.toHalfFloat(t[i]),this.texels[n+1]=ms.toHalfFloat(t[i+1]),this.texels[n+2]=ms.toHalfFloat(t[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ut{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Wa;previous=Ut.emergences();current=Ut.emergences();tally=new Float32Array(Ut.BINS*3);radiance=new Float32Array(Ut.BINS*3);scratch=new Float32Array(Ut.BINS*3);static emergences(){return Array.from({length:Wa.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of jn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ut.BINS,data:this.radiance,binDeg:180/Ut.BINS}}sweep(e){this.drop.refractiveIndex=Jt.indexAt(e.wavelengthNm);const t=Ut.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/t;for(let a=1;a<=t;a++){const r=this.drop.trace(Math.sqrt(a/t),this.current);for(let o=0;o<Math.min(r,n);o++){const l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.weight)/2*i,e)}n=r,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,i){if(n<=0)return;const a=Ut.BINS,r=Math.PI/a,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(a-1,Math.max(0,Math.floor(o/r))),d=Math.min(a-1,Math.max(0,Math.floor(l/r)));if(c<=0||h===d){this.add(h,n,i);return}for(let u=h;u<=d;u++){const f=Math.min(l,(u+1)*r)-Math.max(o,u*r);f>0&&this.add(u,n*f/c,i)}}add(e,t,n){const i=e*3,a=t*jn.SAMPLES.length;this.tally[i]+=a*n.r,this.tally[i+1]+=a*n.g,this.tally[i+2]+=a*n.b}toRadiance(){const e=Ut.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const i=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),a=i>0?this.backwardShare((n+.5)*(180/e))/i:0,r=n*3;this.radiance[r]=this.tally[r]*a,this.radiance[r+1]=this.tally[r+1]*a,this.radiance[r+2]=this.tally[r+2]*a}}backwardShare(e){const t=180-e;if(t<=Ut.FULL_UNTIL_DEG)return 1;if(t>=Ut.FADED_BY_DEG)return 0;const n=(t-Ut.FULL_UNTIL_DEG)/(Ut.FADED_BY_DEG-Ut.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=Ut.BINS,t=Ut.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),i=[];let a=0;for(let r=-n;r<=n;r++){const o=Math.max(0,t*t-r*r),l=Math.sqrt(o);i.push(l),a+=l}if(!(a<=0)){this.scratch.set(this.radiance);for(let r=0;r<e;r++){let o=0,l=0,c=0;for(let d=-n;d<=n;d++){const u=Math.min(e-1,Math.max(0,r+d))*3,f=i[d+n];o+=this.scratch[u]*f,l+=this.scratch[u+1]*f,c+=this.scratch[u+2]*f}const h=r*3;this.radiance[h]=o/a,this.radiance[h+1]=l/a,this.radiance[h+2]=c/a}}}}class Fr{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ut;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ut.BINS*4),this.texture=new nr(this.texels,Ut.BINS,1,yn,hn),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=vn,this.texture.wrapT=vn,this.texture.needsUpdate=!0,this.material=new Nt({uniforms:{uSource:{value:new R(0,1,0)},uStrength:{value:0},uTint:{value:new R(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Fr.GAIN}},vertexShader:`
7031
7041
  varying vec3 vDirection;
7032
7042
  void main() {
7033
7043
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -7055,7 +7065,7 @@ void main()
7055
7065
  light = mix(vec3(grey), light, uSaturation);
7056
7066
  gl_FragColor = vec4(light * uStrength, 1.0);
7057
7067
  }
7058
- `,transparent:!0,blending:ti,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(Fr.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,n,i){const a=this.material.uniforms;if(t<=0){a.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),a.uSource.value.set(e.x,e.y,e.z).normalize(),a.uStrength.value=t,a.uTint.value.set(n[0],n[1],n[2]),a.uSaturation.value=i?1:Fr.MOON_SATURATION,this.object.visible=!0}publish(){const t=this.sky.compute().data;for(let n=0,i=0;i<t.length;n+=4,i+=3)this.texels[n]=ms.toHalfFloat(t[i]),this.texels[n+1]=ms.toHalfFloat(t[i+1]),this.texels[n+2]=ms.toHalfFloat(t[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ag{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class Xs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:i,seed:a}=e;if(t<=0||n<=0)return[];const r=t*n/36e5,o=new Ag(a),l=Math.floor(r),c=l+(o.next()<r-l?1:0),h=[];for(let d=0;d<c;d++){const u=Math.min(1,Math.max(0,(i-20)/52)),f=Xs.MAX_DURATION_MS-u*(Xs.MAX_DURATION_MS-Xs.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+u),brightness:o.next()**3}),h.sort((v,p)=>v.t-p.t)}return h}static aliveAt(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class Zt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Zt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zt.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const e=Zt.MAX_CONCURRENT*Zt.SEGMENTS*Zt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new Dt;t.setAttribute("position",new vt(this.positions,3)),t.setAttribute("color",new vt(this.colors,3)),t.setDrawRange(0,0),this.object=new Ze(t,new Vi({vertexColors:!0,transparent:!0,blending:ti,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,n){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=n}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const n=Xs.aliveAt(this.meteors,e).slice(0,Zt.MAX_CONCURRENT);let i=0;for(const{meteor:a,progress:r}of n){const o=this.radiantOf(a);if(!o)continue;const l=fn(o.altitudeDeg,o.azimuthDeg,1),[c,h]=this.basisAround(l),d=a.fromRadiantDeg+r*a.lengthDeg,u=Math.max(a.fromRadiantDeg,d-a.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),g=this.turn(c,h,a.bearingDeg),v=(.15+.85*a.brightness)*f,p=_=>v*_**1.6,m=_=>this.onSphere(l,g,u+(d-u)*_),S=_=>Zt.RADIUS*((Zt.MIN_HALF_WIDTH_DEG+Zt.BRIGHT_HALF_WIDTH_DEG*a.brightness*_)*Math.PI/180);for(let _=1;_<Zt.POINTS;_++){const x=(_-1)/Zt.SEGMENTS,M=_/Zt.SEGMENTS;i=this.pushRibbon(i,m(x),m(M),S(x),S(M),p(x),p(M))}}t.setDrawRange(0,i),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const n=fn(t.altitudeDeg,t.azimuthDeg,1),[i,a]=this.basisAround(n),r=this.turn(i,a,e.bearingDeg),o=this.onSphere(n,r,e.fromRadiantDeg+e.lengthDeg/2),l=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/l)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,n,i,a,r,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<Zt.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,i,h),f=this.across(n,l,a,h),g=this.across(t,l,i,d),v=this.across(n,l,a,d),p=(m,S)=>m===0?S:0;e=this.push(e,u,p(h,r)),e=this.push(e,f,p(h,o)),e=this.push(e,g,p(d,r)),e=this.push(e,f,p(h,o)),e=this.push(e,v,p(d,o)),e=this.push(e,g,p(d,r))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const a=Math.max(0,Math.min(1,n));return this.colors[i]=a*.9,this.colors[i+1]=a*.95,this.colors[i+2]=a,e+1}turn(e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i);return{x:e.x*a+t.x*r,y:e.y*a+t.y*r,z:e.z*a+t.z*r}}onSphere(e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i);return{x:(e.x*a+t.x*r)*Zt.RADIUS,y:(e.y*a+t.y*r)*Zt.RADIUS,z:(e.z*a+t.z*r)*Zt.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(e,t));return[n,this.normalise(this.cross(e,n))]}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const jc=Math.PI/180;function Ft(s,e,t,n,i=!1){const a=i?new Vi({color:new ve(...t)}):new eo({color:new ve(...t)}),r=new Ze(e,a);return r.position.y=n,r.userData={emissive:i},r.castShadow=!i,r.receiveShadow=!i,s.add(r),r}const jp=.25,gE=.002,vE=20;function yE(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return[1,1,1];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const Ig=[.32,.32,.3],Dg=[1,.85,.5],Cg=[.25,.25,.25],Rg=[1,.97,.85],bE=[.55,.68,.72],gi=.03,vi=.05,Pg={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function pn(s,e){return s?.[e]}function yi(s,e,t,n,i,a,r,o){if(o===void 0)return;const l=new eo({color:new ve(...bE),transparent:!0,opacity:o/100}),c=new Ze(new Wn(e,t,n),l);c.position.set(i,a,r),s.add(c)}const Hn=.05,Qc=[.6,.58,.53],Qp=[.5,.5,.48];function Na(s,e,t,n,i,a,r,o){const l=new eo({color:new ve(...o),side:Vt}),c=new Ze(new Wn(e,t,n),l);c.position.set(i,a,r),s.add(c)}function xE(s,e,t,n,i,a,r,o,l){const c=(n-a)/2,h=(g,v,p,m)=>{g<=0||(e?Na(s,g,v,Hn,p,o+m,r,l):Na(s,Hn,v,g,r,o+m,p,l))};h(t,c,0,n/2-c/2),h(t,c,0,-(n/2-c/2));const d=[...i].sort((g,v)=>g.center-v.center);let u=-t/2;for(const g of d){const p=g.center-g.main/2-u;h(p,a,u+p/2,0),u=g.center+g.main/2}const f=t/2-u;h(f,a,u+f/2,0)}function Lg(s,e,t,n,i,a,r,o,l,c){const h=(n+i)/2,d=i-n,u=(f,g,v,p)=>{f.length===0?g?Na(s,v,d,Hn,0,h,p,Qc):Na(s,Hn,d,v,p,h,0,Qc):xE(s,g,v,d,f,a,p,h,Qc)};u(r,!0,e*2,-t+Hn),u(o,!0,e*2,t-Hn),u(l,!1,t*2,-e+Hn),u(c,!1,t*2,e-Hn),Na(s,e*2,Hn,t*2,0,n+Hn,0,Qp),Na(s,e*2,Hn,t*2,0,i-Hn,0,Qp)}function Gd(s,e,t,n){switch(s){case"front":return{x:0,z:-(t-n)};case"behind":return{x:0,z:t-n};case"left":return{x:-(e-n),z:0};case"right":return{x:e-n,z:0};case"front-left":return{x:-(e-n),z:-bi};case"front-right":return{x:e-n,z:-bi};case"behind-left":return{x:-(e-n),z:bi};case"behind-right":return{x:e-n,z:bi}}}function Ng(s,e,t,n,i,a,r){const o=Xd();o.scale.setScalar(n),o.rotation.y=Pg[e];const{x:l,z:c}=Gd(e,i,a,r);o.position.set(l,t,c),s.add(o)}const Vd=6,Wd=6,ds=3,wr=1.4,Mr=ds*.5,Og=1.2,kg=.35,wE=.75,ME=1.6;function e0(s,e,t,n){const i=new ln,a=Math.max(1,s+1),r=a*ds;Ft(i,new Wn(Vd,r,Wd),[.55,.54,.5],r/2);const o=Vd/2,l=Wd/2;for(let c=0;c<a;c++){const h=c*ds+ds/2;yi(i,wr,Mr,vi,0,h,-l-gi,pn(e,"front")),yi(i,wr,Mr,vi,0,h,l+gi,pn(e,"behind")),yi(i,vi,Mr,wr,-o-gi,h,0,pn(e,"left")),yi(i,vi,Mr,wr,o+gi,h,0,pn(e,"right"))}if(t){const c=Math.min(Math.max(n??0,0),a-1);Ng(i,t,c*ds,.72,o,l,Og);const h=d=>pn(e,d)!==void 0?[{main:wr,center:0}]:[];Lg(i,o,l,c*ds,(c+1)*ds,Mr,h("front"),h("behind"),h("left"),h("right"))}return i}function t0(){const s=new ln;return Ft(s,new $i(.15,.22,2,8),[.32,.22,.14],1),Ft(s,new Qr(1.4,3,8),[.16,.32,.14],3.5),s}const n0=.275,SE=.35,_E=.9,EE=34,TE=8,AE=1.4;function i0(){const s=new ln,e=new bn(n0,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,SE/n0,1);const t=mn.repeatOnGrid(e,EE,_E,TE,AE),n=Ft(s,t,[.26,.28,.22],0);return n.castShadow=!1,e.dispose(),s}function s0(){const s=new ln,e=new bn(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ft(s,e,[.38,.36,.32],0),s}function a0(s){const e=new ln;return Ft(e,new $i(.05,.08,5,8),[.28,.28,.3],2.5),Ft(e,new bn(.25,12,8),s?Dg:Ig,5.1,!0),e}const IE=[.08,.08,.08],hs=.8,Ia=1,ci=1.7,eh=.6,Is=.4,jo=1.2,Sa=.7,bi=.5,DE=ci;function r0(s,e,t){const n=new ln;Ft(n,new Wn(1.8,1.4,4.2),[.45,.14,.14],.7),Ft(n,new Wn(hs*2,eh,Ia*2),[.4,.12,.12],ci);for(const a of[-1.4,1.4])for(const r of[-.95,.95]){const o=Ft(n,new $i(.4,.4,.3,12),IE,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=a}const i=s?Rg:Cg;for(const a of[-.7,.7])Ft(n,new bn(.15,8,6),i,.7,!0).position.set(a,.7,-2.1);if(yi(n,jo,Is,vi,0,ci,-Ia-gi,pn(e,"front")),yi(n,jo,Is,vi,0,ci,Ia+gi,pn(e,"behind")),yi(n,vi,Is,Sa,-hs-gi,ci,-bi,pn(e,"front-left")),yi(n,vi,Is,Sa,-hs-gi,ci,bi,pn(e,"behind-left")),yi(n,vi,Is,Sa,hs+gi,ci,-bi,pn(e,"front-right")),yi(n,vi,Is,Sa,hs+gi,ci,bi,pn(e,"behind-right")),t){Ng(n,t,wE,.5,hs,Ia,kg);const a=(l,c)=>{const h=[];return pn(e,l)!==void 0&&h.push({main:Sa,center:-bi}),pn(e,c)!==void 0&&h.push({main:Sa,center:bi}),h},r=pn(e,"front")!==void 0?[{main:jo,center:0}]:[],o=pn(e,"behind")!==void 0?[{main:jo,center:0}]:[];Lg(n,hs,Ia,ci-eh/2,ci+eh/2,Is,r,o,a("front-left","behind-left"),a("front-right","behind-right"))}return n}const o0=new Map;function l0(s,e){if(!s)return;const t=[[s.lengthM,e.lengthM],[s.heightM,e.heightM],[s.widthM,e.widthM]];for(const[n,i]of t)if(n!==void 0&&i>1e-6)return n/i}function th(s,e){return e>1e-6?s/e:1}const Ug=[.95,.9,.82],c0=[.72,.74,.78];function h0(){const s=new ln;Ft(s,new $i(.25,.3,1.5,10),c0,.75),Ft(s,new bn(.26,10,8),c0,1.74);const e=Ft(s,new Qr(.07,.16,8),Ug,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,s}function Xd(){const s=new ln;Ft(s,new $i(.25,.3,1.5,10),[.3,.3,.35],.75),Ft(s,new bn(.22,10,8),[.62,.52,.46],1.72);const e=Ft(s,new Qr(.07,.16,8),Ug,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,s}const CE=17,d0=18.5,nh=[.16,.16,.18];function u0(){const s=new ln,e=Ft(s,new $i(1.8,1.8,d0*2,10),nh,0);e.rotation.x=Math.PI/2,Ft(s,new Wn(CE*2,.5,4.5),nh,0);const t=Ft(s,new Wn(.4,5.5,4),nh,3);return t.position.z=-d0+2,s}class mn{static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=e.kind==="vehicle"?Gd(t,hs,Ia,kg):Gd(t,Vd/2,Wd/2,Og),a=e.kind==="vehicle"?DE:(e.occupiedFloor??0)*ds+ME,r=(e.headingDeg??0)-Pg[t]/jc,o=this.scaleFor(e);return{x:n*o.x,z:i*o.z,eyeY:a*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(mn.BODY_NAME)??e}static repeatOnGrid(e,t,n,i,a){const r=e.getAttribute("position"),o=e.getAttribute("normal"),l=e.getIndex();if(!l)throw new Error("repeatOnGrid needs an indexed geometry");const c=r.count,h=t*i,d=new Float32Array(c*h*3),u=new Float32Array(c*h*3),f=new Uint32Array(l.count*h),g=-((t-1)*n)/2,v=-((i-1)*a)/2;let p=0;for(let S=0;S<i;S++)for(let _=0;_<t;_++,p++){const x=v+S*a,M=g+_*n;for(let E=0;E<c;E++){const I=(p*c+E)*3;d[I]=r.getX(E)+x,d[I+1]=r.getY(E),d[I+2]=r.getZ(E)+M,u[I]=o.getX(E),u[I+1]=o.getY(E),u[I+2]=o.getZ(E)}for(let E=0;E<l.count;E++)f[p*l.count+E]=l.getX(E)+p*c}const m=new Dt;return m.setAttribute("position",new It(d,3)),m.setAttribute("normal",new It(u,3)),m.setIndex(new fu(f,1)),m}static paint(e,t){e.traverse(n=>{const i=n,a=i.userData;if(!i.isMesh||a?.emissive)return;const r=i.material;r?.color&&r.color.set(t)})}static build(e,t){const n=e.kind==="building"?e0(e.floors??Oa,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?t0():e.kind==="crop"?i0():e.kind==="mound"?s0():e.kind==="streetlight"?a0(t):e.kind==="vehicle"?r0(t,e.windows,e.witnessSide):e.kind==="aircraft"?u0():e.kind==="entity"?h0():Xd();e.color&&this.paint(n,e.color);const i=this.scaleFor(e),a=new ln;return n.name=mn.BODY_NAME,n.scale.copy(i),a.add(n),e.headingDeg!==void 0&&(a.rotation.y=-e.headingDeg*jc),this.addLights(a,e.lights),e.kind==="aircraft"&&this.exemptFromFog(a),a}static scaleFor(e){const t=e.sizeM;if(!t)return new R(1,1,1);const n=this.naturalSize(e.kind,e.floors);return new R(t.widthM===void 0?1:th(t.widthM,n.widthM),t.heightM===void 0?1:th(t.heightM,n.heightM),t.lengthM===void 0?1:th(t.lengthM,n.lengthM))}static naturalSize(e,t){const n=e==="building"?Math.max(1,(t??Oa)+1):0,i=`${e}:${n}`,a=o0.get(i);if(a)return a;const r=e==="building"?e0(n-1,void 0,void 0,void 0):e==="tree"?t0():e==="crop"?i0():e==="mound"?s0():e==="streetlight"?a0(!1):e==="vehicle"?r0(!1,void 0,void 0):e==="aircraft"?u0():e==="entity"?h0():Xd(),o=new Ti().setFromObject(r),l={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),o0.set(i,l),l}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Ra(e.kind))}static applyModel(e,t,n,i={}){const a=this.bodyOf(e),r=new ln;r.name=mn.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*jc,n.updateMatrixWorld(!0);const o=new Ti().setFromObject(n),l={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},c=l0(t.sizeM,l)??l0(i.depictedSizeM,l)??1;n.scale.multiplyScalar(c);const h=o.getCenter(new R).multiplyScalar(c);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=t.kind==="aircraft"?h.y:o.min.y*c,n.traverse(d=>{d instanceof Ze&&(d.castShadow=!0,d.receiveShadow=!0)}),r.add(n),a.parent?(a.parent.add(r),a.removeFromParent()):e.add(r),this.dispose(a)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static exemptFromFog(e){e.traverse(t=>{if(!(t instanceof Ze))return;const n=t.material;n.fog=!1,n.needsUpdate=!0})}static addLights(e,t){for(const n of t??[]){const i=yE(n.color),a=Ft(e,new bn(jp,8,6),i,n.offsetM.y,!0);a.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),a.userData={emissive:!0,lightId:n.id,lightColor:i},a.visible=!1}}static setLights(e,t,n,i,a=0){if(!t||t.length===0)return;const r=new Map(t.map(l=>[l.id,l])),o=Math.max(1,i*gE/jp);for(const l of e.children){if(!(l instanceof Ze))continue;const c=l.userData.lightId;if(!c)continue;const h=r.get(c);if(!h)continue;const d=a>0?am(h,n,n+a):s1(h,n)?1:0;l.visible=d>0;const u=l.material,f=l.userData.lightColor;if(f){const g=a>0?d*vE*(h.intensity??1):d;u.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}l.scale.setScalar(o)}}static setLit(e,t,n){const i=t==="streetlight"?n?Dg:Ig:n?Rg:Cg;e.traverse(a=>{const r=a.userData;!(a instanceof Ze)||!r.emissive||r.lightId||a.material.color.setRGB(...i)})}static dispose(e){e.traverse(t=>{if(!(t instanceof Ze))return;t.geometry.dispose();const n=t.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const ih="https://ufoathome.org/models/index.json";class RE{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??PE()}async entries(e){const t=await this.load();return e?t.filter(n=>n.kind===e):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const n=await t.json();return Array.isArray(n?.models)?n.models.map(({file:i,...a})=>({...a,url:new URL(i,e).href})):void 0}catch{return}}}function PE(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==ih?[s,ih]:[ih]}const bl=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new RE}];async function LE(s){const{GLTFLoader:e}=await Qn(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BeVCsKtR.js");return{GLTFLoader:n}},[],import.meta.url),t=new e;return new Promise((n,i)=>{t.load(s,a=>n(a.scene),void 0,a=>i(new Error(`Could not load 3D model ${s}: ${a instanceof Error?a.message:String(a)}`)))})}const Fg=2,NE=5,OE=2048;class $n{constructor(e){this.scene=e}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new R;up=new R;lookAt=new qe;vertex=new R;centre=new R;right=new R;above=new R;set(e,t){this.placed=e,this.frame=t;const n=new Set(e.map(i=>i.sourceId));for(const[i,a]of this.meshes)n.has(i)||(this.dispose(a),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of e){let a=this.meshes.get(i.sourceId);a||(a=new Ze(new Zi(1,1,$n.SEGMENTS,$n.SEGMENTS),new Vi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),a.frustumCulled=!1,a.layers.set(Fg),this.scene.add(a),this.meshes.set(i.sourceId,a)),a.renderOrder=NE+i.renderOrder,a.visible=!i.hidden&&i.shape.transparency<1,a.visible&&this.paint(a,i,t)}}place(e,t,n){const i=this.frame;if(i)for(const a of this.placed){const r=this.meshes.get(a.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(a.sourceId);if(!o)continue;const{bounds:l}=a.shape;let c=l.x+l.width/2,h=l.y+l.height/2,d=!0;if(a.aim){const u=n($n.directionOf(a.aim,this.direction));u&&Math.abs(u.ndcX)<$n.FURTHEST_NDC&&Math.abs(u.ndcY)<$n.FURTHEST_NDC?(c=(u.ndcX+1)/2*i.canvasWidthPx,h=(1-u.ndcY)/2*i.canvasHeightPx):d=!1}d?this.curve(r,e,t,i,o,c,h,a.distanceM):this.flat(r,e,i,o,a.distanceM)}}static FURTHEST_NDC=4;curve(e,t,n,i,a,r,o,l){const c=r-a.width/2,h=o-a.height/2,d=e.geometry.attributes.position,u=$n.SEGMENTS;let f=0;for(let g=0;g<=u;g++){const v=h+g/u*a.height;for(let p=0;p<=u;p++){const m=c+p/u*a.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,l),d.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}d.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(ht.sizeMAt(l,i.projection.pxToDeg(a.width)),ht.sizeMAt(l,i.projection.pxToDeg(a.height)),1)}flat(e,t,n,i,a){const r=e.geometry.attributes.position,o=$n.SEGMENTS,l=ht.sizeMAt(a,n.projection.pxToDeg(i.width)),c=ht.sizeMAt(a,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,a),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let d=0;d<=o;d++){const u=.5-d/o;for(let f=0;f<=o;f++){const g=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,g*l).addScaledVector(this.above,u*c),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(l,c,1)}static SEGMENTS=16;static directionOf(e,t){const n=e.azimuthDeg*Math.PI/180,i=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,n){const{shape:i}=t,a=wh.paintExtent(i);this.extents.set(t.sourceId,a);const r=$n.signatureOf(i,n);if(this.signatures.get(t.sourceId)===r&&e.material.map)return;this.signatures.set(t.sourceId,r);const o=Math.min(n.scale,OE/Math.max(a.width,a.height,1)),l=Math.max(1,Math.ceil(a.width*o)),c=Math.max(1,Math.ceil(a.height*o)),h=e.material.map,d=h?.image??document.createElement("canvas"),u=d.width!==l||d.height!==c;u&&(d.width=l,d.height=c);const f=d.getContext("2d");if(!f)return;f.clearRect(0,0,l,c);const g=new wh(f);if(g.setStarPoints(n.starPoints),g.setRoll(n.rollRad),g.paintInto(i,a,o),h&&!u){h.needsUpdate=!0;return}h?.dispose();const v=new Ai(d);v.colorSpace=Nn,v.minFilter=At,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:n}=e;return JSON.stringify([e.kind,Math.round(n.width*10),Math.round(n.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function kE(s,e){return s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const Qo=900,sh=1,f0=.5,Rr=900,UE=6371e3,FE=3e4;function p0(s){const e=Math.sqrt(2*UE*Math.max(s,0));return Math.max(Rr,Math.min(e,FE))}const ah=.5,m0=850,BE=.03,el=850,rh=4,g0=1.5,v0=-1,zE=6,qd=-4,y0=.2,tl=2600,HE=.97,GE=.38,b0=qd,VE=3,WE=.15,XE=.6,qE=40,YE=30,KE=[0,45,90,135,180,225,270,315],$E={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},ZE=["en","fr"],JE=880,oh=40,jE=60,QE=10,e3=1,t3=150,n3=55,i3=.5,s3=2.05,x0=.265,w0=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*x0,Math.sin(t)*x0]})],M0=700,a3=250/om,r3=12,S0=5,lh=6,Ds=[.92,.92,.95],ch=[.15,.15,.19],_0={snow:{fallSpeedMPerS:2,size:.3,color:new ve(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new ve(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Da=0,hh=0,o3=150,E0=3e3,Sr=20,l3=15,T0=Da,c3=40,A0=1,h3=9;function I0(s){return A0+(h3-A0)*s}const d3=new ve(.75,.82,.92),u3=10,f3=.5;function p3(s){return Vl(s/u3,f3,1)}const _a=200,D0=.18,C0=.32,m3=.35,g3=new ve(.85,.9,.98),R0=5,P0=.85,L0=.01;function dh(s,e){return Math.round(s*(L0+(1-L0)*e))}const N0=230,O0=.7,k0=.05,v3=.6,y3=.7,b3=.15,U0=.35,x3=3,w3=1/12,M3=.5,F0=8,B0=25,z0=.12,S3={Venus:new ve(1,.96,.85),Mars:new ve(1,.55,.4),Jupiter:new ve(.95,.87,.72),Saturn:new ve(.92,.86,.68)};class di{renderer;scene=new Kl;phenomena=new $n(this.scene);camera;celestialGroup=new ln;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=bl[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new hb(16777215,0);celestialLightTarget=new Tt;skyLight=new ab(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Bc;weather=lm;observerElevationM=0;groundRadius=Rr;terrainRadius=Rr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new Re;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new Bc;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new Bc;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(e,t=nv(),n){this.renderer=new vS({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Pr,this.camera=new _n(60,e.width/Math.max(e.height,1),.1,Qo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Dn,n=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Dn;if(e.headingDeg!==void 0?this.camera.rotation.set(n,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Dn,t,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(p0(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Rr),this.camera.far=Math.max(Qo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const i=gn(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:l,z:c}=gn(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(l*l+c*c)<t3*(i/Rr))return}const a=this.terrainOrigin,r=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=i;const o=++this.terrainBuildToken;J_(e,t,this.terrainProviders,i).then(({mesh:l,attribution:c})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,d=a?gn(e,t,a.lat,a.lng):void 0;h&&d&&Math.hypot(d.x,d.z)<=r&&(l.position.y=h.position.y+this.groundYOfPatch(h,d.x,d.z)),this.disposeMesh(this.terrainMesh),l.renderOrder=e3,this.terrainMesh=l,this.terrainAttribution=c,this.scene.add(l),this.applyGroundDepthWrite(),this.render(),n?.()}).catch(l=>{console.warn("Terrain build failed, keeping the flat ground fallback:",l),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=n3*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=zS(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=As(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=s3**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;for(const t of this.compassSprites)t.visible=e;this.render()}setWeather(e){kE(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=M3,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),mn.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=mn.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const n=e.model;if(!(!n||!mn.usesModel(e)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,a=n.url??i?.url,r=n.credit??i?.credit;if(!a||!r)return;const o=await LE(a);if(t!==this.decorModelToken)return;const l=this.decorGroups.get(e.id);if(!l)return;mn.applyModel(l,e,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(e.id,r),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${e.id}":`,i)}}updateDecorAnchoring(e,t,n=0){const i=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?gn(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},a=this.decorObjects.find(c=>c.witnessSide!==void 0&&Ra(c.kind));a||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(a){const c=mn.occupantView(a),h=-(a.headingDeg??0)*Dn,d=c.x*Math.cos(h)+c.z*Math.sin(h),u=-c.x*Math.sin(h)+c.z*Math.cos(h),f=a.eastM+i.x,g=-a.northM+i.z;r.x=-(f+d),r.z=-(g+u),this.camera.position.y=this.groundYUnder(f,g)+c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Dn,-(c.headingDeg+this.indoorLookYawDeg)*Dn,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const d=Ya(c,n),u=d.eastM+i.x+r.x,f=-d.northM+i.z+r.z;h.position.set(u,this.groundYUnder(u,f)+d.altitudeM,f),c.kind==="crop"&&(h.visible=Math.hypot(u,f)<=o3),d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*Dn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(Qo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,e-n.position.x,t-n.position.z):hh}groundYOfPatch(e,t,n){const i=e.geometry.getAttribute("position"),a=Math.round(Math.sqrt(i.count));if(a<2||a*a!==i.count)return hh;const r=i.getX(0),o=i.getX(a-1),l=i.getZ(0),c=i.getZ((a-1)*a),h=Vl((t-r)/(o-r)*(a-1),0,a-1),d=Vl((n-l)/(c-l)*(a-1),0,a-1);if(!Number.isFinite(h)||!Number.isFinite(d))return hh;const u=Math.min(Math.floor(h),a-2),f=Math.min(Math.floor(d),a-2),g=h-u,v=d-f,p=(_,x)=>i.getY(_*a+x),m=p(f,u)*(1-g)+p(f,u+1)*g,S=p(f+1,u)*(1-g)+p(f+1,u+1)*g;return m*(1-v)+S*v}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&mn.setLights(i,n.lights,e,i.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const r=Ml(n,e);mn.setLit(a,n.kind,r);const o=this.streetlightLights.get(n.id);o&&(o.visible=r)}}addStreetlightLight(e,t){const n=mn.bodyOf(t),i=n.children.find(r=>r.userData.emissive);if(!i)return;const a=new lb(16764006,qE,YE);a.position.copy(i.position).multiply(n.scale),a.castShadow=!0,a.shadow.mapSize.set(512,512),a.shadow.bias=-.002,t.add(a),this.streetlightLights.set(e,a)}setAstronomy(e){const t=Sd(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=n,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(),this.updateCloudLighting(e.sun,n),this.updateCelestialLight(e,t.zenith,n);const i=Or(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,i),this.setBodyMesh("sun",e.sun,rh,new ve(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,i),this.buildPlanets(e.planets,i),this.buildComet(e.comet,i),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.buildSkyGlow(e,t.zenith),this.scene.fog=new uu(new ve(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=XE;const i=e.sun.altitudeDeg>=b0,a=!i&&e.moon.altitudeDeg>=b0;if(!i&&!a){this.celestialLight.intensity=0;return}const r=i?e.sun:e.moon,{x:o,y:l,z:c}=fn(r.altitudeDeg,r.azimuthDeg,el);this.celestialLight.position.set(o,l,c);const h=As(r.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Dn));this.celestialLight.intensity=(i?VE:WE)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Zt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=it.starPointsOf(e),n=it.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(e){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){const t=this.usableEquidistantPass();this.phenomena.place(this.camera,(a,r,o)=>this.directionAtScreenPoint(a,r,o),a=>this.screenPointOf(a));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!a),e&&this.renderer.setRenderTarget(e),a?a.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),e&&this.renderer.setRenderTarget(i);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),e&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&di.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(sh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(Fg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new Vi({colorWrite:!1});static markDecorDepth(e,t){e.traverse(n=>{if(!(n instanceof Ze))return;const i=Array.isArray(n.material)?n.material[0]:n.material;t&&i.depthWrite!==!1&&i.blending!==ti?n.layers.enable(sh):n.layers.disable(sh)})}startExposure(){this.cancelExposure();const e=this.renderer.getDrawingBufferSize(new Re),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new yS(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants,i=performance.now()+di.EXPOSURE_BUDGET_MS;do this.restateAt(e,this.exposureInstantsDone),this.renderOnce(t.instantTarget),t.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i);this.restateAt(e,0),t.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Re),n=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ur(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Re);if(kr.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new kr(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){e.setFromCamera(new Re(t,n),this.camera);return}const a=i.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(a.x,a.y,a.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}directionAtScreenPoint(e,t,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return kr.ndcFor(t,this.camera.fov,i);const a=Math.tan(this.camera.fov/2*Dn);return{ndcX:t.x/-t.z/(i*a),ndcY:t.y/-t.z/a}}screenPointScratch=new R;screenPointQuaternion=new bs;screenPointSize=new Re;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,a=this.renderer.domElement.height;e.uniforms.uResolution.value.set(i,a),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let e=0;for(const t of w0)this.isSunOccluded(t[0],t[1])||e++;return e/w0.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const n=this.decorGroups.get(t.id);n&&e.push(n)}return e}isSunOccluded(e=0,t=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.raycastableDecor())n.push(o);if(n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),a=i.length();if(i.normalize(),e!==0||t!==0){const o=Math.PI/180,l=this.sunOcclusionRightScratch.set(i.z,0,-i.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,i).normalize();i.addScaledVector(l,e*o).addScaledVector(c,t*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,i);const r=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return r!==void 0&&r.distance<a}get lowerCloudUp(){return this.cloudMesh!==void 0&&this.lowerCloudCover()>0}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=f0;let i,a;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(r.occludesSourceIds?.includes(n)?i=i===void 0?l.distance:Math.max(i,l.distance):a=a===void 0?l.distance:Math.min(a,l.distance))}return{behindM:i,inFrontM:a}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a))[0];if(i&&!this.groundHides(e,t))return n.find(([,a])=>a===i.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,i=Math.cos(BE*this.camera.fov*Math.PI/180);let a,r=i;for(const o of this.namedStars){const l=o.direction.dot(n);l>r&&(r=l,a={star:o.star,altitudeDeg:o.altitudeDeg})}return a&&this.groundHides(e,t)?void 0:a}groundHides(e,t){const n=[this.terrainMesh,this.groundMesh].filter(i=>i!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=f0,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r),!0)[0];if(!i)return;let a=i.object;for(;a&&!n.some(([,r])=>r===a);)a=a.parent;return n.find(([,r])=>r===a)?.[0]}dispose(){this.stopTwinkle(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())mn.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let e;const t=n=>{const i=e===void 0?0:Math.min((n-e)/1e3,w3);e=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,i),this.updateRain(i),this.updateLightning(n/1e3,i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(e){e!==this.animationsRunning&&(this.animationsRunning=e,e?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),e||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){this.disposeMesh(this.skyMesh);const t=new bn(Qo,32,16),n=t.attributes.position,i=[];for(let r=0;r<n.count;r++){const{altitudeDeg:o,azimuthDeg:l}=wS(n.getX(r),n.getY(r),n.getZ(r)),c=DS(o,l,e.azimuthDeg,e.altitudeDeg);i.push(c[0],c[1],c[2])}t.setAttribute("color",new It(i,3));const a=new Vi({vertexColors:!0,side:Vt,fog:!1,depthWrite:!1});this.skyMesh=new Ze(t,a),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=p0(this.observerElevationM);const e=new mu(this.groundRadius,48),t=new eo({color:new ve(ah,ah,ah),fog:!0});this.groundMesh=new Ze(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=fn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ht.alphaAt(t,Math.abs(this.cloudLayerOffset()),i)*HE);const a=this.weather.highCloudCover??0;return a>0&&(n*=1-Ht.alphaAt(t,tl,a)*GE),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,i,a){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<qd){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:l}=fn(t.altitudeDeg,t.azimuthDeg,el),c=As(t.altitudeDeg),h=this.cloudTransmission(t),d=new ve(i.r*c[0]*h,i.g*c[1]*h,i.b*c[2]*h),u=new bn(n,16,16),f=new Vi({color:d,fog:!1}),g=new Ze(u,f);g.position.set(r,o,l),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,r,o,l,n);const v=a-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,r,o,l,v,d),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,l*p),this.lensFlare||(this.lensFlare=mE(),this.lensFlare.uniforms.uOpacity.value=i3,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<qd){this.bodyMeshes.delete(n);return}const{x:i,y:a,z:r}=fn(e.altitudeDeg,e.azimuthDeg,el),o=As(e.altitudeDeg),l=new ve(o[0],o[1],o[2]),c=new Ar({map:L3(e.phase),color:l,fog:!1}),h=new So(c);h.position.set(i,a,r);const d=rh*2;h.scale.set(d,d,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,i,a,r,rh),this.setGlare(n,i,a,r,e.magnitude,l)}setHitArea(e,t,n,i,a){const r=new Ar({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new So(r);o.position.set(t,n,i);const l=a*zE;o.scale.set(l,l,1),this.celestialGroup.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,i,a,r){const o=PS(a);if(o<=0){this.disposeGlare(e);return}const l=OS(o),c=this.glareSprites.get(e),h=c??new So(new Ar({map:P3(),transparent:!0,blending:ti,depthWrite:!1,fog:!1}));h.material.color.copy(r),h.material.opacity=FS(o),h.position.set(t,n,i),h.scale.set(l*2,l*2,1),c||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=Yc(e.magnitude,t),a=Kc(i);this.cometKey=n,this.setBodyMesh(n,e.position,g0*(.5+.5*i),new ve(a,a,a),e.magnitude),this.cometTail||(this.cometTail=new Rn(el),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,i)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new hi,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:tl},0);return}const i=this.weather.lowerCloudCover??this.weather.cloudCover,a=je.deckLitUntilDeg(je.DECK_HEIGHT_M),r=e.altitudeDeg>-a?e:t,o=je.strength(n,i,r.altitudeDeg,a)*(r===e?1:y0),{x:l,y:c,z:h}=fn(r.altitudeDeg,r.azimuthDeg,1),d=As(r.altitudeDeg);this.iceHalos.update({x:l,y:c,z:h},r.altitudeDeg,o,[d[0],d[1],d[2]],{cover:n,layerHeight:tl},this.weather.iceCrystalAlignment??_h)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Fr,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=e.altitudeDeg>0,a=i?e:t,r=this.weather.lowerCloudCover??this.weather.cloudCover,o=y0*Qt.moonlightShare(t.magnitude),l=Qt.strength(n,r,a.altitudeDeg)*(i?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:d}=fn(a.altitudeDeg,a.azimuthDeg,1),u=As(a.altitudeDeg);this.rainbow.update({x:c,y:h,z:d},l,[u[0],u[1],u[2]],i)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Kn,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=e.frame,a=Ln.galactic(n,i),r=di.directionOf(a.centre),o=di.directionOf(a.rotation),l=di.directionOf(a.pole),c=new Be().set(r.x,r.y,r.z,o.x,o.y,o.z,l.x,l.y,l.z),h=di.directionOf(Ln.eclipticPole(n,i)),d=di.directionOf(e.sun),u=d.clone().addScaledVector(h,-d.dot(h)).normalize();this.skyGlow.update({galactic:c,eclipticPole:h,sunLongitude:u,sunDirection:d,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:di.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:We.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new R(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:i}=fn(e.altitudeDeg,e.azimuthDeg,1);return new R(t,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of e){if(i.magnitude>t)continue;n.add(i.body);const a=Yc(i.magnitude,t),r=Kc(a),o=S3[i.body]??new ve(1,1,1),l=new ve(o.r*r,o.g*r,o.b*r),c=g0*(.5+.5*a);this.setBodyMesh(i.body,i.position,c,l,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(e,t){if(this.disposeStarTiers(),this.namedStars=[],!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:i,observer:a}=e,r=uh(1337),o=[];for(let l=0;l<n.count;l++){const c=n.mag[l];if(c>t)break;const{altitudeDeg:h,azimuthDeg:d}=tr(n.ra[l],n.dec[l],i,a);if(h<v0)continue;const{x:u,y:f,z:g}=fn(h,d,m0);o.push({x:u,y:f,z:g,brightness:Yc(c,t),phase:r()*Math.PI*2,speedFactor:.7+r()*.6})}for(const l of X_){if(l.mag>t)continue;const{altitudeDeg:c,azimuthDeg:h}=tr(l.raHours,l.decDeg,i,a);if(c<v0)continue;const{x:d,y:u,z:f}=fn(c,h,m0);this.namedStars.push({star:l,direction:new R(d,u,f).normalize(),altitudeDeg:c})}this.starTiers=ag.map((l,c)=>{const h=o.filter(_=>GS(_.brightness)===c),d=new Float32Array(h.length*3),u=new Float32Array(h.length),f=new Float32Array(h.length),g=new Float32Array(h.length);h.forEach((_,x)=>{d[x*3]=_.x,d[x*3+1]=_.y,d[x*3+2]=_.z,u[x]=_.brightness,f[x]=_.phase,g[x]=_.speedFactor});const v=new Dt;v.setAttribute("position",new vt(d,3));const p=new vt(new Float32Array(h.length*3),3);v.setAttribute("color",p);const m=new Gm({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Us.apply(m);const S=new ml(v,m);return this.celestialGroup.add(S),{points:S,colorAttribute:p,brightness:u,phase:f,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let i=0;i<t.brightness.length;i++){const a=XS(t.brightness[i],{phase:t.phase[i],speedFactor:t.speedFactor[i]},e),r=Kc(t.brightness[i])*a;n[i*3]=r,n[i*3+1]=r,n[i*3+2]=r}t.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const e=this.lowerCloudCover();if(e<=0)return;const t=this.weather.cloudDarkness,n=new ve(Ds[0]+(ch[0]-Ds[0])*t,Ds[1]+(ch[1]-Ds[1])*t,Ds[2]+(ch[2]-Ds[2])*t),{material:i,uniforms:a}=Zp(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=a,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=Jp(M0);this.cloudMesh=new Ze(r,i),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=S0,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const e=this.weather.highCloudCover??0;if(e<=0)return;const{material:t,uniforms:n}=Zp(new ve(...Ds),e,tl,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Ze(Jp(M0*1.04),t),this.cirrusMesh.renderOrder=S0-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&(this.cloudMesh.scale.y=e<0?-1:1)}cloudLayerOffset(){const t=((this.weather.cloudBaseM??om)-this.observerElevationM)*a3;return Math.sign(t||1)*Math.max(Math.abs(t),r3)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(c=>c!==void 0);if(n.length===0)return;const{x:i,y:a,z:r}=fn(e.altitudeDeg,e.azimuthDeg,1),o=As(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Dn));for(const c of n)c.sunDir.value.set(i,a,r),c.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),c.ambientColor.value.setRGB(t[0],t[1],t[2])}disposeCloudSystem(){this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=_0[e],n=t.poolSize,i=uh(9001),a=new Float32Array(n*3),r=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=new Float32Array(n),h=new Float32Array(n),d=new Float32Array(n),u=new Float32Array(n),f=new Float32Array(n),g=new Float32Array(n);for(let _=0;_<n;_++){const x=i()*Math.PI*2,M=i()*t.radiusM;a[_*3]=Math.cos(x)*M,a[_*3+1]=Da+i()*(t.topYM-Da),a[_*3+2]=Math.sin(x)*M,r[_]=i()*Math.PI*2,o[_]=.7+i()*.6,l[_]=.6+i()*.8,c[_]=.4+i()*1.2}const v=new Dt;v.setAttribute("position",new vt(a,3)),v.setDrawRange(0,dh(n,this.weather.precipitationIntensity));const p={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new ve(...this.baseFogColor)},uTexture:{value:_3(e)},uNearFocusDistance:{value:R0},uHazeDistance:{value:t.radiusM*P0}},m=new Nt({uniforms:p,vertexShader:C3,fragmentShader:R3,transparent:!0,depthWrite:!1});this.precipitationUniforms=p;const S=new ml(v,m);S.renderOrder=lh,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=a,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=g}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=_0[n],a=this.weather.windDirectionDeg*Dn,r=Math.sin(a)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(a)*this.weather.windSpeed*i.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,v=this.precipitationBounceDuration,p=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,S=n==="snow"&&d&&u,_=n==="hail"&&f&&g&&v&&p&&m;for(let x=0,M=0;x<l.length;x+=3,M++){if(_&&f[M]>0){if(f[M]-=t,f[M]<=0){const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*i.radiusM;l[x]=Math.cos(y)*T,l[x+1]=i.topYM,l[x+2]=Math.sin(y)*T,f[M]=0}else{const y=1-f[M]/v[M];l[x+1]=Da+Math.sin(Math.PI*y)*g[M],l[x]=il(l[x]+(r+p[M])*t,i.radiusM),l[x+2]=il(l[x+2]+(o+m[M])*t,i.radiusM)}continue}let E=0,I=0;if(S){const y=v3*d[M],T=y3*u[M];E=Math.sin(e*y*Math.PI*2+c[M])*T,I=Math.sin(e*y*Math.PI*2+c[M]+Math.PI/2)*T}if(l[x]+=(r+E)*t,l[x+1]-=i.fallSpeedMPerS*h[M]*t,l[x+2]+=(o+I)*t,l[x]=il(l[x],i.radiusM),l[x+2]=il(l[x+2],i.radiusM),l[x+1]<Da){if(_){g[M]=U0*(.2+Math.random()*1.6),v[M]=b3*(.5+Math.random()),f[M]=v[M];const C=Math.random()*Math.PI*2,D=x3*(g[M]/U0);p[M]=Math.cos(C)*D,m[M]=Math.sin(C)*D,l[x+1]=Da;continue}const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*i.radiusM;l[x]=Math.cos(y)*T,l[x+1]=i.topYM,l[x+2]=Math.sin(y)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=I0(this.weather.precipitationIntensity);this.rainSystem=oE({count:E0,radiusM:Sr,heightM:l3,bottomYM:T0,overallSpeed:c3,color:d3,opacity:.85,visibleCount:dh(E0,this.weather.precipitationIntensity),speedStreak:p3(e),pixelSize:N0,seed:9001,nearFocusDistanceM:R0,hazeDistanceM:Sr*P0,hazeColor:new ve(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=lh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=uh(4242),t=new Float32Array(_a*3),n=new Float32Array(_a),i=new Float32Array(_a),a=new Float32Array(_a);for(let h=0;h<_a;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*Sr;t[h*3]=Math.cos(d)*u,t[h*3+1]=T0,t[h*3+2]=Math.sin(d)*u,i[h]=nl(D0,C0),n[h]=e()*i[h],a[h]=n[h]/i[h]}const r=new Dt;r.setAttribute("position",new vt(t,3));const o=new vt(a,1);r.setAttribute("aLife",o),r.setDrawRange(0,dh(_a,this.weather.precipitationIntensity));const l=new Nt({uniforms:{uMaxSize:{value:m3},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:g3},uTexture:{value:A3()}},vertexShader:I3,fragmentShader:D3,transparent:!0,depthWrite:!1}),c=new ml(r,l);c.renderOrder=lh,this.scene.add(c),this.rainSplashSystem={points:c,positions:t,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*Dn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-I0(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*Dn,i=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,r=Sr,o=c=>(c%(r*2)+r*3)%(r*2)-r;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+i*e),o(t.uniforms.uWindOffset.value.y+a*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=O0+(1-O0)*(1-l),h=k0+(1-k0)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=N0*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:i,duration:a,lifeAttribute:r}=t,o=r.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(i[c]+=e,i[c]>=a[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*Sr;n[l]=Math.cos(h)*d,n[l+2]=Math.sin(h)*d,a[c]=nl(D0,C0),i[c]=0}o[c]=i[c]/a[c]}t.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/z0;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=e+nl(F0,B0);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=z0,this.nextLightningAtS=e+nl(F0,B0),this.onLightningFlash?.())}}buildCompassLabels(){const e=Xr(navigator.languages,ZE),t=$E[e];this.compassSprites=KE.map((n,i)=>{const a=t[i],r=new Ar({map:N3(a),depthTest:!1,fog:!1}),o=new So(r),{x:l,y:c,z:h}=fn(0,n,JE);return o.position.set(l,c,h),o.scale.set(oh,oh,1),o.renderOrder=QE,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=jE*Math.PI/360,n=oh*Math.tan(e)/Math.tan(t);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const i=n.map;i&&i.dispose(),n.dispose()}}}const Dn=Math.PI/180;function Vl(s,e,t){return Math.max(e,Math.min(t,s))}function nl(s,e){return s+Math.random()*(e-s)}function il(s,e){return(s%(e*2)+e*3)%(e*2)-e}let sl,al;function _3(s){switch(s){case"snow":return E3();case"hail":return T3()}}function E3(){if(sl)return sl;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),sl=new Ai(e),sl}function T3(){if(al)return al;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),al=new Ai(e),al}let rl;function A3(){if(rl)return rl;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),rl=new Ai(e),rl}const I3=`
7068
+ `,transparent:!0,blending:ni,depthWrite:!1,side:Vt,fog:!1}),this.object=new Ze(new bn(Fr.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,n,i){const a=this.material.uniforms;if(t<=0){a.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),a.uSource.value.set(e.x,e.y,e.z).normalize(),a.uStrength.value=t,a.uTint.value.set(n[0],n[1],n[2]),a.uSaturation.value=i?1:Fr.MOON_SATURATION,this.object.visible=!0}publish(){const t=this.sky.compute().data;for(let n=0,i=0;i<t.length;n+=4,i+=3)this.texels[n]=ms.toHalfFloat(t[i]),this.texels[n+1]=ms.toHalfFloat(t[i+1]),this.texels[n+2]=ms.toHalfFloat(t[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Ag{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class Xs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:i,seed:a}=e;if(t<=0||n<=0)return[];const r=t*n/36e5,o=new Ag(a),l=Math.floor(r),c=l+(o.next()<r-l?1:0),h=[];for(let d=0;d<c;d++){const u=Math.min(1,Math.max(0,(i-20)/52)),f=Xs.MAX_DURATION_MS-u*(Xs.MAX_DURATION_MS-Xs.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+u),brightness:o.next()**3}),h.sort((v,p)=>v.t-p.t)}return h}static aliveAt(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class Zt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Zt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zt.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const e=Zt.MAX_CONCURRENT*Zt.SEGMENTS*Zt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new Dt;t.setAttribute("position",new gt(this.positions,3)),t.setAttribute("color",new gt(this.colors,3)),t.setDrawRange(0,0),this.object=new Ze(t,new Vi({vertexColors:!0,transparent:!0,blending:ni,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,n){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=n}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const n=Xs.aliveAt(this.meteors,e).slice(0,Zt.MAX_CONCURRENT);let i=0;for(const{meteor:a,progress:r}of n){const o=this.radiantOf(a);if(!o)continue;const l=pn(o.altitudeDeg,o.azimuthDeg,1),[c,h]=this.basisAround(l),d=a.fromRadiantDeg+r*a.lengthDeg,u=Math.max(a.fromRadiantDeg,d-a.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),g=this.turn(c,h,a.bearingDeg),v=(.15+.85*a.brightness)*f,p=_=>v*_**1.6,m=_=>this.onSphere(l,g,u+(d-u)*_),S=_=>Zt.RADIUS*((Zt.MIN_HALF_WIDTH_DEG+Zt.BRIGHT_HALF_WIDTH_DEG*a.brightness*_)*Math.PI/180);for(let _=1;_<Zt.POINTS;_++){const x=(_-1)/Zt.SEGMENTS,M=_/Zt.SEGMENTS;i=this.pushRibbon(i,m(x),m(M),S(x),S(M),p(x),p(M))}}t.setDrawRange(0,i),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const n=pn(t.altitudeDeg,t.azimuthDeg,1),[i,a]=this.basisAround(n),r=this.turn(i,a,e.bearingDeg),o=this.onSphere(n,r,e.fromRadiantDeg+e.lengthDeg/2),l=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/l)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,n,i,a,r,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<Zt.ACROSS-1;c++){const h=c-1,d=c,u=this.across(t,l,i,h),f=this.across(n,l,a,h),g=this.across(t,l,i,d),v=this.across(n,l,a,d),p=(m,S)=>m===0?S:0;e=this.push(e,u,p(h,r)),e=this.push(e,f,p(h,o)),e=this.push(e,g,p(d,r)),e=this.push(e,f,p(h,o)),e=this.push(e,v,p(d,o)),e=this.push(e,g,p(d,r))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const a=Math.max(0,Math.min(1,n));return this.colors[i]=a*.9,this.colors[i+1]=a*.95,this.colors[i+2]=a,e+1}turn(e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i);return{x:e.x*a+t.x*r,y:e.y*a+t.y*r,z:e.z*a+t.z*r}}onSphere(e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i);return{x:(e.x*a+t.x*r)*Zt.RADIUS,y:(e.y*a+t.y*r)*Zt.RADIUS,z:(e.z*a+t.z*r)*Zt.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(e,t));return[n,this.normalise(this.cross(e,n))]}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const jc=Math.PI/180;function Ft(s,e,t,n,i=!1){const a=i?new Vi({color:new ve(...t)}):new eo({color:new ve(...t)}),r=new Ze(e,a);return r.position.y=n,r.userData={emissive:i},r.castShadow=!i,r.receiveShadow=!i,s.add(r),r}const jp=.25,gE=.002,vE=20;function yE(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return[1,1,1];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const Ig=[.32,.32,.3],Dg=[1,.85,.5],Cg=[.25,.25,.25],Rg=[1,.97,.85],bE=[.55,.68,.72],vi=.03,yi=.05,Pg={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function mn(s,e){return s?.[e]}function bi(s,e,t,n,i,a,r,o){if(o===void 0)return;const l=new eo({color:new ve(...bE),transparent:!0,opacity:o/100}),c=new Ze(new Wn(e,t,n),l);c.position.set(i,a,r),s.add(c)}const Hn=.05,Qc=[.6,.58,.53],Qp=[.5,.5,.48];function Na(s,e,t,n,i,a,r,o){const l=new eo({color:new ve(...o),side:Vt}),c=new Ze(new Wn(e,t,n),l);c.position.set(i,a,r),s.add(c)}function xE(s,e,t,n,i,a,r,o,l){const c=(n-a)/2,h=(g,v,p,m)=>{g<=0||(e?Na(s,g,v,Hn,p,o+m,r,l):Na(s,Hn,v,g,r,o+m,p,l))};h(t,c,0,n/2-c/2),h(t,c,0,-(n/2-c/2));const d=[...i].sort((g,v)=>g.center-v.center);let u=-t/2;for(const g of d){const p=g.center-g.main/2-u;h(p,a,u+p/2,0),u=g.center+g.main/2}const f=t/2-u;h(f,a,u+f/2,0)}function Lg(s,e,t,n,i,a,r,o,l,c){const h=(n+i)/2,d=i-n,u=(f,g,v,p)=>{f.length===0?g?Na(s,v,d,Hn,0,h,p,Qc):Na(s,Hn,d,v,p,h,0,Qc):xE(s,g,v,d,f,a,p,h,Qc)};u(r,!0,e*2,-t+Hn),u(o,!0,e*2,t-Hn),u(l,!1,t*2,-e+Hn),u(c,!1,t*2,e-Hn),Na(s,e*2,Hn,t*2,0,n+Hn,0,Qp),Na(s,e*2,Hn,t*2,0,i-Hn,0,Qp)}function Gd(s,e,t,n){switch(s){case"front":return{x:0,z:-(t-n)};case"behind":return{x:0,z:t-n};case"left":return{x:-(e-n),z:0};case"right":return{x:e-n,z:0};case"front-left":return{x:-(e-n),z:-xi};case"front-right":return{x:e-n,z:-xi};case"behind-left":return{x:-(e-n),z:xi};case"behind-right":return{x:e-n,z:xi}}}function Ng(s,e,t,n,i,a,r){const o=Xd();o.scale.setScalar(n),o.rotation.y=Pg[e];const{x:l,z:c}=Gd(e,i,a,r);o.position.set(l,t,c),s.add(o)}const Vd=6,Wd=6,ds=3,wr=1.4,Mr=ds*.5,Og=1.2,kg=.35,wE=.75,ME=1.6;function e0(s,e,t,n){const i=new cn,a=Math.max(1,s+1),r=a*ds;Ft(i,new Wn(Vd,r,Wd),[.55,.54,.5],r/2);const o=Vd/2,l=Wd/2;for(let c=0;c<a;c++){const h=c*ds+ds/2;bi(i,wr,Mr,yi,0,h,-l-vi,mn(e,"front")),bi(i,wr,Mr,yi,0,h,l+vi,mn(e,"behind")),bi(i,yi,Mr,wr,-o-vi,h,0,mn(e,"left")),bi(i,yi,Mr,wr,o+vi,h,0,mn(e,"right"))}if(t){const c=Math.min(Math.max(n??0,0),a-1);Ng(i,t,c*ds,.72,o,l,Og);const h=d=>mn(e,d)!==void 0?[{main:wr,center:0}]:[];Lg(i,o,l,c*ds,(c+1)*ds,Mr,h("front"),h("behind"),h("left"),h("right"))}return i}function t0(){const s=new cn;return Ft(s,new $i(.15,.22,2,8),[.32,.22,.14],1),Ft(s,new Qr(1.4,3,8),[.16,.32,.14],3.5),s}const n0=.275,SE=.35,_E=.9,EE=34,TE=8,AE=1.4;function i0(){const s=new cn,e=new bn(n0,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,SE/n0,1);const t=on.repeatOnGrid(e,EE,_E,TE,AE),n=Ft(s,t,[.26,.28,.22],0);return n.castShadow=!1,e.dispose(),s}function s0(){const s=new cn,e=new bn(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ft(s,e,[.38,.36,.32],0),s}function a0(s){const e=new cn;return Ft(e,new $i(.05,.08,5,8),[.28,.28,.3],2.5),Ft(e,new bn(.25,12,8),s?Dg:Ig,5.1,!0),e}const IE=[.08,.08,.08],hs=.8,Ia=1,hi=1.7,eh=.6,Is=.4,jo=1.2,Sa=.7,xi=.5,DE=hi;function r0(s,e,t){const n=new cn;Ft(n,new Wn(1.8,1.4,4.2),[.45,.14,.14],.7),Ft(n,new Wn(hs*2,eh,Ia*2),[.4,.12,.12],hi);for(const a of[-1.4,1.4])for(const r of[-.95,.95]){const o=Ft(n,new $i(.4,.4,.3,12),IE,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=a}const i=s?Rg:Cg;for(const a of[-.7,.7])Ft(n,new bn(.15,8,6),i,.7,!0).position.set(a,.7,-2.1);if(bi(n,jo,Is,yi,0,hi,-Ia-vi,mn(e,"front")),bi(n,jo,Is,yi,0,hi,Ia+vi,mn(e,"behind")),bi(n,yi,Is,Sa,-hs-vi,hi,-xi,mn(e,"front-left")),bi(n,yi,Is,Sa,-hs-vi,hi,xi,mn(e,"behind-left")),bi(n,yi,Is,Sa,hs+vi,hi,-xi,mn(e,"front-right")),bi(n,yi,Is,Sa,hs+vi,hi,xi,mn(e,"behind-right")),t){Ng(n,t,wE,.5,hs,Ia,kg);const a=(l,c)=>{const h=[];return mn(e,l)!==void 0&&h.push({main:Sa,center:-xi}),mn(e,c)!==void 0&&h.push({main:Sa,center:xi}),h},r=mn(e,"front")!==void 0?[{main:jo,center:0}]:[],o=mn(e,"behind")!==void 0?[{main:jo,center:0}]:[];Lg(n,hs,Ia,hi-eh/2,hi+eh/2,Is,r,o,a("front-left","behind-left"),a("front-right","behind-right"))}return n}const o0=new Map;function l0(s,e){if(!s)return;const t=[[s.lengthM,e.lengthM],[s.heightM,e.heightM],[s.widthM,e.widthM]];for(const[n,i]of t)if(n!==void 0&&i>1e-6)return n/i}function th(s,e){return e>1e-6?s/e:1}const Ug=[.95,.9,.82],c0=[.72,.74,.78];function h0(){const s=new cn;Ft(s,new $i(.25,.3,1.5,10),c0,.75),Ft(s,new bn(.26,10,8),c0,1.74);const e=Ft(s,new Qr(.07,.16,8),Ug,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,s}function Xd(){const s=new cn;Ft(s,new $i(.25,.3,1.5,10),[.3,.3,.35],.75),Ft(s,new bn(.22,10,8),[.62,.52,.46],1.72);const e=Ft(s,new Qr(.07,.16,8),Ug,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,s}const CE=17,d0=18.5,nh=[.16,.16,.18];function u0(){const s=new cn,e=Ft(s,new $i(1.8,1.8,d0*2,10),nh,0);e.rotation.x=Math.PI/2,Ft(s,new Wn(CE*2,.5,4.5),nh,0);const t=Ft(s,new Wn(.4,5.5,4),nh,3);return t.position.z=-d0+2,s}class on{static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=e.kind==="vehicle"?Gd(t,hs,Ia,kg):Gd(t,Vd/2,Wd/2,Og),a=e.kind==="vehicle"?DE:(e.occupiedFloor??0)*ds+ME,r=(e.headingDeg??0)-Pg[t]/jc,o=this.scaleFor(e);return{x:n*o.x,z:i*o.z,eyeY:a*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(on.BODY_NAME)??e}static repeatOnGrid(e,t,n,i,a){const r=e.getAttribute("position"),o=e.getAttribute("normal"),l=e.getIndex();if(!l)throw new Error("repeatOnGrid needs an indexed geometry");const c=r.count,h=t*i,d=new Float32Array(c*h*3),u=new Float32Array(c*h*3),f=new Uint32Array(l.count*h),g=-((t-1)*n)/2,v=-((i-1)*a)/2;let p=0;for(let S=0;S<i;S++)for(let _=0;_<t;_++,p++){const x=v+S*a,M=g+_*n;for(let E=0;E<c;E++){const I=(p*c+E)*3;d[I]=r.getX(E)+x,d[I+1]=r.getY(E),d[I+2]=r.getZ(E)+M,u[I]=o.getX(E),u[I+1]=o.getY(E),u[I+2]=o.getZ(E)}for(let E=0;E<l.count;E++)f[p*l.count+E]=l.getX(E)+p*c}const m=new Dt;return m.setAttribute("position",new It(d,3)),m.setAttribute("normal",new It(u,3)),m.setIndex(new fu(f,1)),m}static paint(e,t){e.traverse(n=>{const i=n,a=i.userData;if(!i.isMesh||a?.emissive)return;const r=i.material;r?.color&&r.color.set(t)})}static build(e,t){const n=e.kind==="building"?e0(e.floors??Oa,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?t0():e.kind==="crop"?i0():e.kind==="mound"?s0():e.kind==="streetlight"?a0(t):e.kind==="vehicle"?r0(t,e.windows,e.witnessSide):e.kind==="aircraft"?u0():e.kind==="entity"?h0():Xd();e.color&&this.paint(n,e.color);const i=this.scaleFor(e),a=new cn;return n.name=on.BODY_NAME,n.scale.copy(i),a.add(n),e.headingDeg!==void 0&&(a.rotation.y=-e.headingDeg*jc),this.addLights(a,e.lights),e.kind==="aircraft"&&this.exemptFromFog(a),a}static scaleFor(e){const t=e.sizeM;if(!t)return new R(1,1,1);const n=this.naturalSize(e.kind,e.floors);return new R(t.widthM===void 0?1:th(t.widthM,n.widthM),t.heightM===void 0?1:th(t.heightM,n.heightM),t.lengthM===void 0?1:th(t.lengthM,n.lengthM))}static naturalSize(e,t){const n=e==="building"?Math.max(1,(t??Oa)+1):0,i=`${e}:${n}`,a=o0.get(i);if(a)return a;const r=e==="building"?e0(n-1,void 0,void 0,void 0):e==="tree"?t0():e==="crop"?i0():e==="mound"?s0():e==="streetlight"?a0(!1):e==="vehicle"?r0(!1,void 0,void 0):e==="aircraft"?u0():e==="entity"?h0():Xd(),o=new Ti().setFromObject(r),l={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),o0.set(i,l),l}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Ra(e.kind))}static applyModel(e,t,n,i={}){const a=this.bodyOf(e),r=new cn;r.name=on.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*jc,n.updateMatrixWorld(!0);const o=new Ti().setFromObject(n),l={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},c=l0(t.sizeM,l)??l0(i.depictedSizeM,l)??1;n.scale.multiplyScalar(c);const h=o.getCenter(new R).multiplyScalar(c);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=t.kind==="aircraft"?h.y:o.min.y*c,n.traverse(d=>{d instanceof Ze&&(d.castShadow=!0,d.receiveShadow=!0)}),r.add(n),a.parent?(a.parent.add(r),a.removeFromParent()):e.add(r),this.dispose(a)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static exemptFromFog(e){e.traverse(t=>{if(!(t instanceof Ze))return;const n=t.material;n.fog=!1,n.needsUpdate=!0})}static addLights(e,t){for(const n of t??[]){const i=yE(n.color),a=Ft(e,new bn(jp,8,6),i,n.offsetM.y,!0);a.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),a.userData={emissive:!0,lightId:n.id,lightColor:i},a.visible=!1}}static setLights(e,t,n,i,a=0){if(!t||t.length===0)return;const r=new Map(t.map(l=>[l.id,l])),o=Math.max(1,i*gE/jp);for(const l of e.children){if(!(l instanceof Ze))continue;const c=l.userData.lightId;if(!c)continue;const h=r.get(c);if(!h)continue;const d=a>0?am(h,n,n+a):s1(h,n)?1:0;l.visible=d>0;const u=l.material,f=l.userData.lightColor;if(f){const g=a>0?d*vE*(h.intensity??1):d;u.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}l.scale.setScalar(o)}}static setLit(e,t,n){const i=t==="streetlight"?n?Dg:Ig:n?Rg:Cg;e.traverse(a=>{const r=a.userData;!(a instanceof Ze)||!r.emissive||r.lightId||a.material.color.setRGB(...i)})}static dispose(e){e.traverse(t=>{if(!(t instanceof Ze))return;t.geometry.dispose();const n=t.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const ih="https://ufoathome.org/models/index.json";class RE{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??PE()}async entries(e){const t=await this.load();return e?t.filter(n=>n.kind===e):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const n=await t.json();return Array.isArray(n?.models)?n.models.map(({file:i,...a})=>({...a,url:new URL(i,e).href})):void 0}catch{return}}}function PE(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==ih?[s,ih]:[ih]}const bl=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new RE}];async function LE(s){const{GLTFLoader:e}=await ei(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BeVCsKtR.js");return{GLTFLoader:n}},[],import.meta.url),t=new e;return new Promise((n,i)=>{t.load(s,a=>n(a.scene),void 0,a=>i(new Error(`Could not load 3D model ${s}: ${a instanceof Error?a.message:String(a)}`)))})}const Fg=2,NE=5,OE=2048;class $n{constructor(e){this.scene=e}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new R;up=new R;lookAt=new qe;vertex=new R;centre=new R;right=new R;above=new R;set(e,t){this.placed=e,this.frame=t;const n=new Set(e.map(i=>i.sourceId));for(const[i,a]of this.meshes)n.has(i)||(this.dispose(a),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of e){let a=this.meshes.get(i.sourceId);a||(a=new Ze(new Zi(1,1,$n.SEGMENTS,$n.SEGMENTS),new Vi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),a.frustumCulled=!1,a.layers.set(Fg),this.scene.add(a),this.meshes.set(i.sourceId,a)),a.renderOrder=NE+i.renderOrder,a.visible=!i.hidden&&i.shape.transparency<1,a.visible&&this.paint(a,i,t)}}place(e,t,n){const i=this.frame;if(i)for(const a of this.placed){const r=this.meshes.get(a.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(a.sourceId);if(!o)continue;const{bounds:l}=a.shape;let c=l.x+l.width/2,h=l.y+l.height/2,d=!0;if(a.aim){const u=n($n.directionOf(a.aim,this.direction));u&&Math.abs(u.ndcX)<$n.FURTHEST_NDC&&Math.abs(u.ndcY)<$n.FURTHEST_NDC?(c=(u.ndcX+1)/2*i.canvasWidthPx,h=(1-u.ndcY)/2*i.canvasHeightPx):d=!1}d?this.curve(r,e,t,i,o,c,h,a.distanceM):this.flat(r,e,i,o,a.distanceM)}}static FURTHEST_NDC=4;curve(e,t,n,i,a,r,o,l){const c=r-a.width/2,h=o-a.height/2,d=e.geometry.attributes.position,u=$n.SEGMENTS;let f=0;for(let g=0;g<=u;g++){const v=h+g/u*a.height;for(let p=0;p<=u;p++){const m=c+p/u*a.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,l),d.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}d.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(et.sizeMAt(l,i.projection.pxToDeg(a.width)),et.sizeMAt(l,i.projection.pxToDeg(a.height)),1)}flat(e,t,n,i,a){const r=e.geometry.attributes.position,o=$n.SEGMENTS,l=et.sizeMAt(a,n.projection.pxToDeg(i.width)),c=et.sizeMAt(a,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,a),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let d=0;d<=o;d++){const u=.5-d/o;for(let f=0;f<=o;f++){const g=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,g*l).addScaledVector(this.above,u*c),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(l,c,1)}static SEGMENTS=16;static directionOf(e,t){const n=e.azimuthDeg*Math.PI/180,i=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,n){const{shape:i}=t,a=wh.paintExtent(i);this.extents.set(t.sourceId,a);const r=$n.signatureOf(i,n);if(this.signatures.get(t.sourceId)===r&&e.material.map)return;this.signatures.set(t.sourceId,r);const o=Math.min(n.scale,OE/Math.max(a.width,a.height,1)),l=Math.max(1,Math.ceil(a.width*o)),c=Math.max(1,Math.ceil(a.height*o)),h=e.material.map,d=h?.image??document.createElement("canvas"),u=d.width!==l||d.height!==c;u&&(d.width=l,d.height=c);const f=d.getContext("2d");if(!f)return;f.clearRect(0,0,l,c);const g=new wh(f);if(g.setStarPoints(n.starPoints),g.setRoll(n.rollRad),g.paintInto(i,a,o),h&&!u){h.needsUpdate=!0;return}h?.dispose();const v=new Ai(d);v.colorSpace=Nn,v.minFilter=At,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:n}=e;return JSON.stringify([e.kind,Math.round(n.width*10),Math.round(n.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function kE(s,e){return s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const Qo=900,sh=1,f0=.5,Rr=900,UE=6371e3,FE=3e4;function p0(s){const e=Math.sqrt(2*UE*Math.max(s,0));return Math.max(Rr,Math.min(e,FE))}const ah=.5,m0=850,BE=.03,el=850,rh=4,g0=1.5,v0=-1,zE=6,qd=-4,y0=.2,tl=2600,HE=.97,GE=.38,b0=qd,VE=3,WE=.15,XE=.6,qE=40,YE=30,KE=[0,45,90,135,180,225,270,315],$E={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},ZE=["en","fr"],JE=880,oh=40,jE=60,QE=10,e3=1,t3=150,n3=55,i3=.5,s3=2.05,x0=.265,w0=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*x0,Math.sin(t)*x0]})],M0=700,a3=250/om,r3=12,S0=5,lh=6,Ds=[.92,.92,.95],ch=[.15,.15,.19],_0={snow:{fallSpeedMPerS:2,size:.3,color:new ve(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new ve(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Da=0,hh=0,o3=150,E0=3e3,Sr=20,l3=15,T0=Da,c3=40,A0=1,h3=9;function I0(s){return A0+(h3-A0)*s}const d3=new ve(.75,.82,.92),u3=10,f3=.5;function p3(s){return Vl(s/u3,f3,1)}const _a=200,D0=.18,C0=.32,m3=.35,g3=new ve(.85,.9,.98),R0=5,P0=.85,L0=.01;function dh(s,e){return Math.round(s*(L0+(1-L0)*e))}const N0=230,O0=.7,k0=.05,v3=.6,y3=.7,b3=.15,U0=.35,x3=3,w3=1/12,M3=.5,F0=8,B0=25,z0=.12,S3={Venus:new ve(1,.96,.85),Mars:new ve(1,.55,.4),Jupiter:new ve(.95,.87,.72),Saturn:new ve(.92,.86,.68)};class ui{renderer;scene=new Kl;phenomena=new $n(this.scene);camera;celestialGroup=new cn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=bl[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new hb(16777215,0);celestialLightTarget=new Tt;skyLight=new ab(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Bc;weather=lm;observerElevationM=0;groundRadius=Rr;terrainRadius=Rr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new Re;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new Bc;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new Bc;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(e,t=nv(),n){this.renderer=new vS({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Pr,this.camera=new En(60,e.width/Math.max(e.height,1),.1,Qo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Mn,n=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Mn;if(e.headingDeg!==void 0?this.camera.rotation.set(n,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Mn,t,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(p0(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Rr),this.camera.far=Math.max(Qo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const i=gn(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:l,z:c}=gn(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(l*l+c*c)<t3*(i/Rr))return}const a=this.terrainOrigin,r=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=i;const o=++this.terrainBuildToken;J_(e,t,this.terrainProviders,i).then(({mesh:l,attribution:c})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,d=a?gn(e,t,a.lat,a.lng):void 0;h&&d&&Math.hypot(d.x,d.z)<=r&&(l.position.y=h.position.y+this.groundYOfPatch(h,d.x,d.z)),this.disposeMesh(this.terrainMesh),l.renderOrder=e3,this.terrainMesh=l,this.terrainAttribution=c,this.scene.add(l),this.applyGroundDepthWrite(),this.render(),n?.()}).catch(l=>{console.warn("Terrain build failed, keeping the flat ground fallback:",l),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=n3*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=zS(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=As(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=s3**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;for(const t of this.compassSprites)t.visible=e;this.render()}setWeather(e){kE(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=M3,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),on.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=on.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const n=e.model;if(!(!n||!on.usesModel(e)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,a=n.url??i?.url,r=n.credit??i?.credit;if(!a||!r)return;const o=await LE(a);if(t!==this.decorModelToken)return;const l=this.decorGroups.get(e.id);if(!l)return;on.applyModel(l,e,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(e.id,r),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${e.id}":`,i)}}updateDecorAnchoring(e,t,n=0){const i=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?gn(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},a=this.decorObjects.find(c=>c.witnessSide!==void 0&&Ra(c.kind));a||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(a){const c=on.occupantView(a),h=-(a.headingDeg??0)*Mn,d=c.x*Math.cos(h)+c.z*Math.sin(h),u=-c.x*Math.sin(h)+c.z*Math.cos(h),f=a.eastM+i.x,g=-a.northM+i.z;r.x=-(f+d),r.z=-(g+u),this.camera.position.y=this.groundYUnder(f,g)+c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Mn,-(c.headingDeg+this.indoorLookYawDeg)*Mn,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const d=Ya(c,n),u=d.eastM+i.x+r.x,f=-d.northM+i.z+r.z;h.position.set(u,this.groundUnderFootprint(c,u,f,d.headingDeg)+d.altitudeM,f),c.kind==="crop"&&(h.visible=Math.hypot(u,f)<=o3),d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*Mn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(Qo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,e-n.position.x,t-n.position.z):hh}groundYOfPatch(e,t,n){const i=e.geometry.getAttribute("position"),a=Math.round(Math.sqrt(i.count));if(a<2||a*a!==i.count)return hh;const r=i.getX(0),o=i.getX(a-1),l=i.getZ(0),c=i.getZ((a-1)*a),h=Vl((t-r)/(o-r)*(a-1),0,a-1),d=Vl((n-l)/(c-l)*(a-1),0,a-1);if(!Number.isFinite(h)||!Number.isFinite(d))return hh;const u=Math.min(Math.floor(h),a-2),f=Math.min(Math.floor(d),a-2),g=h-u,v=d-f,p=(_,x)=>i.getY(_*a+x),m=p(f,u)*(1-g)+p(f,u+1)*g,S=p(f+1,u)*(1-g)+p(f+1,u+1)*g;return m*(1-v)+S*v}groundUnderFootprint(e,t,n,i){const a=on.sizeOf(e),r=(i??0)*Mn,o=Math.sin(r)*(a.lengthM/2),l=-Math.cos(r)*(a.lengthM/2),c=Math.cos(r)*(a.widthM/2),h=Math.sin(r)*(a.widthM/2);let d=this.groundYUnder(t,n);for(const[u,f]of[[1,1],[1,-1],[-1,1],[-1,-1]])d=Math.max(d,this.groundYUnder(t+u*o+f*c,n+u*l+f*h));return d}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&on.setLights(i,n.lights,e,i.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const r=Ml(n,e);on.setLit(a,n.kind,r);const o=this.streetlightLights.get(n.id);o&&(o.visible=r)}}addStreetlightLight(e,t){const n=on.bodyOf(t),i=n.children.find(r=>r.userData.emissive);if(!i)return;const a=new lb(16764006,qE,YE);a.position.copy(i.position).multiply(n.scale),a.castShadow=!0,a.shadow.mapSize.set(512,512),a.shadow.bias=-.002,t.add(a),this.streetlightLights.set(e,a)}setAstronomy(e){const t=Sd(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=n,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(),this.updateCloudLighting(e.sun,n),this.updateCelestialLight(e,t.zenith,n);const i=Or(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,i),this.setBodyMesh("sun",e.sun,rh,new ve(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,i),this.buildPlanets(e.planets,i),this.buildComet(e.comet,i),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.buildSkyGlow(e,t.zenith),this.scene.fog=new uu(new ve(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=XE;const i=e.sun.altitudeDeg>=b0,a=!i&&e.moon.altitudeDeg>=b0;if(!i&&!a){this.celestialLight.intensity=0;return}const r=i?e.sun:e.moon,{x:o,y:l,z:c}=pn(r.altitudeDeg,r.azimuthDeg,el);this.celestialLight.position.set(o,l,c);const h=As(r.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Mn));this.celestialLight.intensity=(i?VE:WE)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Zt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=st.starPointsOf(e),n=st.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(e){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){const t=this.usableEquidistantPass();this.phenomena.place(this.camera,(a,r,o)=>this.directionAtScreenPoint(a,r,o),a=>this.screenPointOf(a));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!a),e&&this.renderer.setRenderTarget(e),a?a.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),e&&this.renderer.setRenderTarget(i);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),e&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&ui.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(sh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(Fg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new Vi({colorWrite:!1});static markDecorDepth(e,t){e.traverse(n=>{if(!(n instanceof Ze))return;const i=Array.isArray(n.material)?n.material[0]:n.material;t&&i.depthWrite!==!1&&i.blending!==ni?n.layers.enable(sh):n.layers.disable(sh)})}startExposure(){this.cancelExposure();const e=this.renderer.getDrawingBufferSize(new Re),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new yS(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants,i=performance.now()+ui.EXPOSURE_BUDGET_MS;do this.restateAt(e,this.exposureInstantsDone),this.renderOnce(t.instantTarget),t.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i);this.restateAt(e,0),t.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Re),n=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ur(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Re);if(kr.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new kr(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){e.setFromCamera(new Re(t,n),this.camera);return}const a=i.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(a.x,a.y,a.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}directionAtScreenPoint(e,t,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return kr.ndcFor(t,this.camera.fov,i);const a=Math.tan(this.camera.fov/2*Mn);return{ndcX:t.x/-t.z/(i*a),ndcY:t.y/-t.z/a}}screenPointScratch=new R;screenPointQuaternion=new bs;screenPointSize=new Re;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,a=this.renderer.domElement.height;e.uniforms.uResolution.value.set(i,a),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let e=0;for(const t of w0)this.isSunOccluded(t[0],t[1])||e++;return e/w0.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const n=this.decorGroups.get(t.id);n&&e.push(n)}return e}isSunOccluded(e=0,t=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.raycastableDecor())n.push(o);if(n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),a=i.length();if(i.normalize(),e!==0||t!==0){const o=Math.PI/180,l=this.sunOcclusionRightScratch.set(i.z,0,-i.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,i).normalize();i.addScaledVector(l,e*o).addScaledVector(c,t*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,i);const r=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return r!==void 0&&r.distance<a}get lowerCloudUp(){return this.cloudMesh!==void 0&&this.lowerCloudCover()>0}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=f0;let i,a;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(r.occludesSourceIds?.includes(n)?i=i===void 0?l.distance:Math.max(i,l.distance):a=a===void 0?l.distance:Math.min(a,l.distance))}return{behindM:i,inFrontM:a}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a))[0];if(i&&!this.groundHides(e,t))return n.find(([,a])=>a===i.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,i=Math.cos(BE*this.camera.fov*Math.PI/180);let a,r=i;for(const o of this.namedStars){const l=o.direction.dot(n);l>r&&(r=l,a={star:o.star,altitudeDeg:o.altitudeDeg})}return a&&this.groundHides(e,t)?void 0:a}groundHides(e,t){const n=[this.terrainMesh,this.groundMesh].filter(i=>i!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=f0,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r),!0)[0];if(!i)return;let a=i.object;for(;a&&!n.some(([,r])=>r===a);)a=a.parent;return n.find(([,r])=>r===a)?.[0]}dispose(){this.stopTwinkle(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())on.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let e;const t=n=>{const i=e===void 0?0:Math.min((n-e)/1e3,w3);e=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,i),this.updateRain(i),this.updateLightning(n/1e3,i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(e){e!==this.animationsRunning&&(this.animationsRunning=e,e?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),e||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){this.disposeMesh(this.skyMesh);const t=new bn(Qo,32,16),n=t.attributes.position,i=[];for(let r=0;r<n.count;r++){const{altitudeDeg:o,azimuthDeg:l}=wS(n.getX(r),n.getY(r),n.getZ(r)),c=DS(o,l,e.azimuthDeg,e.altitudeDeg);i.push(c[0],c[1],c[2])}t.setAttribute("color",new It(i,3));const a=new Vi({vertexColors:!0,side:Vt,fog:!1,depthWrite:!1});this.skyMesh=new Ze(t,a),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=p0(this.observerElevationM);const e=new mu(this.groundRadius,48),t=new eo({color:new ve(ah,ah,ah),fog:!0});this.groundMesh=new Ze(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=pn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ht.alphaAt(t,Math.abs(this.cloudLayerOffset()),i)*HE);const a=this.weather.highCloudCover??0;return a>0&&(n*=1-Ht.alphaAt(t,tl,a)*GE),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,i,a){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<qd){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:l}=pn(t.altitudeDeg,t.azimuthDeg,el),c=As(t.altitudeDeg),h=this.cloudTransmission(t),d=new ve(i.r*c[0]*h,i.g*c[1]*h,i.b*c[2]*h),u=new bn(n,16,16),f=new Vi({color:d,fog:!1}),g=new Ze(u,f);g.position.set(r,o,l),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,r,o,l,n);const v=a-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,r,o,l,v,d),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,l*p),this.lensFlare||(this.lensFlare=mE(),this.lensFlare.uniforms.uOpacity.value=i3,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<qd){this.bodyMeshes.delete(n);return}const{x:i,y:a,z:r}=pn(e.altitudeDeg,e.azimuthDeg,el),o=As(e.altitudeDeg),l=new ve(o[0],o[1],o[2]),c=new Ar({map:L3(e.phase),color:l,fog:!1}),h=new So(c);h.position.set(i,a,r);const d=rh*2;h.scale.set(d,d,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,i,a,r,rh),this.setGlare(n,i,a,r,e.magnitude,l)}setHitArea(e,t,n,i,a){const r=new Ar({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new So(r);o.position.set(t,n,i);const l=a*zE;o.scale.set(l,l,1),this.celestialGroup.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,i,a,r){const o=PS(a);if(o<=0){this.disposeGlare(e);return}const l=OS(o),c=this.glareSprites.get(e),h=c??new So(new Ar({map:P3(),transparent:!0,blending:ni,depthWrite:!1,fog:!1}));h.material.color.copy(r),h.material.opacity=FS(o),h.position.set(t,n,i),h.scale.set(l*2,l*2,1),c||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=Yc(e.magnitude,t),a=Kc(i);this.cometKey=n,this.setBodyMesh(n,e.position,g0*(.5+.5*i),new ve(a,a,a),e.magnitude),this.cometTail||(this.cometTail=new Rn(el),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,i)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new di,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:tl},0);return}const i=this.weather.lowerCloudCover??this.weather.cloudCover,a=je.deckLitUntilDeg(je.DECK_HEIGHT_M),r=e.altitudeDeg>-a?e:t,o=je.strength(n,i,r.altitudeDeg,a)*(r===e?1:y0),{x:l,y:c,z:h}=pn(r.altitudeDeg,r.azimuthDeg,1),d=As(r.altitudeDeg);this.iceHalos.update({x:l,y:c,z:h},r.altitudeDeg,o,[d[0],d[1],d[2]],{cover:n,layerHeight:tl},this.weather.iceCrystalAlignment??_h)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Fr,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=e.altitudeDeg>0,a=i?e:t,r=this.weather.lowerCloudCover??this.weather.cloudCover,o=y0*Qt.moonlightShare(t.magnitude),l=Qt.strength(n,r,a.altitudeDeg)*(i?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:d}=pn(a.altitudeDeg,a.azimuthDeg,1),u=As(a.altitudeDeg);this.rainbow.update({x:c,y:h,z:d},l,[u[0],u[1],u[2]],i)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Kn,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=e.frame,a=Ln.galactic(n,i),r=ui.directionOf(a.centre),o=ui.directionOf(a.rotation),l=ui.directionOf(a.pole),c=new Be().set(r.x,r.y,r.z,o.x,o.y,o.z,l.x,l.y,l.z),h=ui.directionOf(Ln.eclipticPole(n,i)),d=ui.directionOf(e.sun),u=d.clone().addScaledVector(h,-d.dot(h)).normalize();this.skyGlow.update({galactic:c,eclipticPole:h,sunLongitude:u,sunDirection:d,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:ui.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:We.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new R(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:i}=pn(e.altitudeDeg,e.azimuthDeg,1);return new R(t,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of e){if(i.magnitude>t)continue;n.add(i.body);const a=Yc(i.magnitude,t),r=Kc(a),o=S3[i.body]??new ve(1,1,1),l=new ve(o.r*r,o.g*r,o.b*r),c=g0*(.5+.5*a);this.setBodyMesh(i.body,i.position,c,l,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(e,t){if(this.disposeStarTiers(),this.namedStars=[],!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:i,observer:a}=e,r=uh(1337),o=[];for(let l=0;l<n.count;l++){const c=n.mag[l];if(c>t)break;const{altitudeDeg:h,azimuthDeg:d}=tr(n.ra[l],n.dec[l],i,a);if(h<v0)continue;const{x:u,y:f,z:g}=pn(h,d,m0);o.push({x:u,y:f,z:g,brightness:Yc(c,t),phase:r()*Math.PI*2,speedFactor:.7+r()*.6})}for(const l of X_){if(l.mag>t)continue;const{altitudeDeg:c,azimuthDeg:h}=tr(l.raHours,l.decDeg,i,a);if(c<v0)continue;const{x:d,y:u,z:f}=pn(c,h,m0);this.namedStars.push({star:l,direction:new R(d,u,f).normalize(),altitudeDeg:c})}this.starTiers=ag.map((l,c)=>{const h=o.filter(_=>GS(_.brightness)===c),d=new Float32Array(h.length*3),u=new Float32Array(h.length),f=new Float32Array(h.length),g=new Float32Array(h.length);h.forEach((_,x)=>{d[x*3]=_.x,d[x*3+1]=_.y,d[x*3+2]=_.z,u[x]=_.brightness,f[x]=_.phase,g[x]=_.speedFactor});const v=new Dt;v.setAttribute("position",new gt(d,3));const p=new gt(new Float32Array(h.length*3),3);v.setAttribute("color",p);const m=new Gm({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Us.apply(m);const S=new ml(v,m);return this.celestialGroup.add(S),{points:S,colorAttribute:p,brightness:u,phase:f,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let i=0;i<t.brightness.length;i++){const a=XS(t.brightness[i],{phase:t.phase[i],speedFactor:t.speedFactor[i]},e),r=Kc(t.brightness[i])*a;n[i*3]=r,n[i*3+1]=r,n[i*3+2]=r}t.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const e=this.lowerCloudCover();if(e<=0)return;const t=this.weather.cloudDarkness,n=new ve(Ds[0]+(ch[0]-Ds[0])*t,Ds[1]+(ch[1]-Ds[1])*t,Ds[2]+(ch[2]-Ds[2])*t),{material:i,uniforms:a}=Zp(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=a,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=Jp(M0);this.cloudMesh=new Ze(r,i),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=S0,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const e=this.weather.highCloudCover??0;if(e<=0)return;const{material:t,uniforms:n}=Zp(new ve(...Ds),e,tl,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Ze(Jp(M0*1.04),t),this.cirrusMesh.renderOrder=S0-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&(this.cloudMesh.scale.y=e<0?-1:1)}cloudLayerOffset(){const t=((this.weather.cloudBaseM??om)-this.observerElevationM)*a3;return Math.sign(t||1)*Math.max(Math.abs(t),r3)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(c=>c!==void 0);if(n.length===0)return;const{x:i,y:a,z:r}=pn(e.altitudeDeg,e.azimuthDeg,1),o=As(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Mn));for(const c of n)c.sunDir.value.set(i,a,r),c.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),c.ambientColor.value.setRGB(t[0],t[1],t[2])}disposeCloudSystem(){this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=_0[e],n=t.poolSize,i=uh(9001),a=new Float32Array(n*3),r=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=new Float32Array(n),h=new Float32Array(n),d=new Float32Array(n),u=new Float32Array(n),f=new Float32Array(n),g=new Float32Array(n);for(let _=0;_<n;_++){const x=i()*Math.PI*2,M=i()*t.radiusM;a[_*3]=Math.cos(x)*M,a[_*3+1]=Da+i()*(t.topYM-Da),a[_*3+2]=Math.sin(x)*M,r[_]=i()*Math.PI*2,o[_]=.7+i()*.6,l[_]=.6+i()*.8,c[_]=.4+i()*1.2}const v=new Dt;v.setAttribute("position",new gt(a,3)),v.setDrawRange(0,dh(n,this.weather.precipitationIntensity));const p={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new ve(...this.baseFogColor)},uTexture:{value:_3(e)},uNearFocusDistance:{value:R0},uHazeDistance:{value:t.radiusM*P0}},m=new Nt({uniforms:p,vertexShader:C3,fragmentShader:R3,transparent:!0,depthWrite:!1});this.precipitationUniforms=p;const S=new ml(v,m);S.renderOrder=lh,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=a,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=g}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=_0[n],a=this.weather.windDirectionDeg*Mn,r=Math.sin(a)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(a)*this.weather.windSpeed*i.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,v=this.precipitationBounceDuration,p=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,S=n==="snow"&&d&&u,_=n==="hail"&&f&&g&&v&&p&&m;for(let x=0,M=0;x<l.length;x+=3,M++){if(_&&f[M]>0){if(f[M]-=t,f[M]<=0){const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*i.radiusM;l[x]=Math.cos(y)*T,l[x+1]=i.topYM,l[x+2]=Math.sin(y)*T,f[M]=0}else{const y=1-f[M]/v[M];l[x+1]=Da+Math.sin(Math.PI*y)*g[M],l[x]=il(l[x]+(r+p[M])*t,i.radiusM),l[x+2]=il(l[x+2]+(o+m[M])*t,i.radiusM)}continue}let E=0,I=0;if(S){const y=v3*d[M],T=y3*u[M];E=Math.sin(e*y*Math.PI*2+c[M])*T,I=Math.sin(e*y*Math.PI*2+c[M]+Math.PI/2)*T}if(l[x]+=(r+E)*t,l[x+1]-=i.fallSpeedMPerS*h[M]*t,l[x+2]+=(o+I)*t,l[x]=il(l[x],i.radiusM),l[x+2]=il(l[x+2],i.radiusM),l[x+1]<Da){if(_){g[M]=U0*(.2+Math.random()*1.6),v[M]=b3*(.5+Math.random()),f[M]=v[M];const C=Math.random()*Math.PI*2,D=x3*(g[M]/U0);p[M]=Math.cos(C)*D,m[M]=Math.sin(C)*D,l[x+1]=Da;continue}const y=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*i.radiusM;l[x]=Math.cos(y)*T,l[x+1]=i.topYM,l[x+2]=Math.sin(y)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=I0(this.weather.precipitationIntensity);this.rainSystem=oE({count:E0,radiusM:Sr,heightM:l3,bottomYM:T0,overallSpeed:c3,color:d3,opacity:.85,visibleCount:dh(E0,this.weather.precipitationIntensity),speedStreak:p3(e),pixelSize:N0,seed:9001,nearFocusDistanceM:R0,hazeDistanceM:Sr*P0,hazeColor:new ve(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=lh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=uh(4242),t=new Float32Array(_a*3),n=new Float32Array(_a),i=new Float32Array(_a),a=new Float32Array(_a);for(let h=0;h<_a;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*Sr;t[h*3]=Math.cos(d)*u,t[h*3+1]=T0,t[h*3+2]=Math.sin(d)*u,i[h]=nl(D0,C0),n[h]=e()*i[h],a[h]=n[h]/i[h]}const r=new Dt;r.setAttribute("position",new gt(t,3));const o=new gt(a,1);r.setAttribute("aLife",o),r.setDrawRange(0,dh(_a,this.weather.precipitationIntensity));const l=new Nt({uniforms:{uMaxSize:{value:m3},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:g3},uTexture:{value:A3()}},vertexShader:I3,fragmentShader:D3,transparent:!0,depthWrite:!1}),c=new ml(r,l);c.renderOrder=lh,this.scene.add(c),this.rainSplashSystem={points:c,positions:t,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*Mn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-I0(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*Mn,i=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,r=Sr,o=c=>(c%(r*2)+r*3)%(r*2)-r;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+i*e),o(t.uniforms.uWindOffset.value.y+a*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=O0+(1-O0)*(1-l),h=k0+(1-k0)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=N0*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:i,duration:a,lifeAttribute:r}=t,o=r.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(i[c]+=e,i[c]>=a[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*Sr;n[l]=Math.cos(h)*d,n[l+2]=Math.sin(h)*d,a[c]=nl(D0,C0),i[c]=0}o[c]=i[c]/a[c]}t.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/z0;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=e+nl(F0,B0);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=z0,this.nextLightningAtS=e+nl(F0,B0),this.onLightningFlash?.())}}buildCompassLabels(){const e=Xr(navigator.languages,ZE),t=$E[e];this.compassSprites=KE.map((n,i)=>{const a=t[i],r=new Ar({map:N3(a),depthTest:!1,fog:!1}),o=new So(r),{x:l,y:c,z:h}=pn(0,n,JE);return o.position.set(l,c,h),o.scale.set(oh,oh,1),o.renderOrder=QE,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=jE*Math.PI/360,n=oh*Math.tan(e)/Math.tan(t);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const i=n.map;i&&i.dispose(),n.dispose()}}}const Mn=Math.PI/180;function Vl(s,e,t){return Math.max(e,Math.min(t,s))}function nl(s,e){return s+Math.random()*(e-s)}function il(s,e){return(s%(e*2)+e*3)%(e*2)-e}let sl,al;function _3(s){switch(s){case"snow":return E3();case"hail":return T3()}}function E3(){if(sl)return sl;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),sl=new Ai(e),sl}function T3(){if(al)return al;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),al=new Ai(e),al}let rl;function A3(){if(rl)return rl;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),rl=new Ai(e),rl}const I3=`
7059
7069
  uniform float uMaxSize;
7060
7070
  uniform float uScale;
7061
7071
  attribute float aLife;
@@ -7120,5 +7130,5 @@ void main() {
7120
7130
  float blur = max(vNearBlur, vHaze);
7121
7131
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
7122
7132
  }
7123
- `;let ol;function P3(){if(ol)return ol;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),ol=new Ai(e),ol}function L3(s){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.getContext("2d"),i=128/2-2,a=128/2,r=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(a,r,i,0,Math.PI*2),n.fill();const c=Vl(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,d=i*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(a,r,i,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(a,r,i,-Math.PI/2,Math.PI/2,!1),n.ellipse(a,r,d,i,0,Math.PI/2,-Math.PI/2,u)):(n.arc(a,r,i,Math.PI/2,-Math.PI/2,!1),n.ellipse(a,r,d,i,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new Ai(t)}function N3(s){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(s,64,68),new Ai(e)}function uh(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const fh=7.5,Br=9;class ui{static cache=new Map;static load(e){let t=ui.cache.get(e);return t||(t=fetch(e).then(n=>n.arrayBuffer()).then(n=>ui.parse(n)),ui.cache.set(e,t)),t}static upTo(e,t){const n=e.filter((r,o)=>o===0||e[o-1].magnitudeLimit<t);if(n.length<=1)return ui.load(e[0].url);const i=n.map(r=>r.url).join(`
7124
- `);let a=ui.cache.get(i);return a||(a=Promise.all(n.map(r=>ui.load(r.url))).then(r=>r.reduce((o,l)=>ui.concat(o,l))),ui.cache.set(i,a)),a}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*n,t),dec:new Float32Array(e,1*n,t),mag:new Float32Array(e,2*n,t),ci:new Float32Array(e,3*n,t)}}static concat(e,t){const n=(i,a)=>{const r=new Float32Array(i.length+a.length);return r.set(i,0),r.set(a,i.length),r};return{count:e.count+t.count,ra:n(e.ra,t.ra),dec:n(e.dec,t.dec),mag:n(e.mag,t.mag),ci:n(e.ci,t.ci)}}}const O3=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,k3=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,U3=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,F3=20,B3=1;class z3{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,n){if(this.requested={type:e,intensity:t,windSpeed:n},!this.context)return;this.paused&&(e="none",t=0,n=0);const i=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=i==="hail"?Math.min(1,t*1.3+.2):i==="rain"?t:0,i!==this.ambientKey){this.ambientKey=i;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(O3,this.ambientVolume).then(o=>this.applyIfCurrent(o,r,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/F3,1);const a=n>B3;if(a!==this.windActive){this.windActive=a;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,a&&this.startLoop(k3,this.windVolume).then(o=>this.applyIfCurrent(o,r,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:i}=this.requested;this.setAmbient(t,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(U3,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(e,t,n,i){if(t!==n()){e?.source.stop();return}i(e)}async startLoop(e,t){const n=this.context;if(n)try{const i=await this.getBuffer(e),a=n.createBufferSource();a.buffer=i,a.loop=!0;const r=n.createGain();return r.gain.value=t,a.connect(r).connect(n.destination),a.start(),{source:a,gain:r}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(e,t){const n=this.context;if(n)try{const i=await this.getBuffer(e),a=n.createBufferSource();a.buffer=i;const r=n.createGain();r.gain.value=t,a.connect(r).connect(n.destination),a.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${e}`);return i.arrayBuffer()}).then(i=>t.decodeAudioData(i)),this.buffers.set(e,n)),n}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class ki{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[i,a]=this.perifocalAxes(),r=Math.sqrt(ki.SUN_GM_AU3_PER_DAY2*(1+t)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(a,r),this.inverseSemiMajorAxis=(1-t)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,n=this.universalAnomaly(t),i=this.inverseSemiMajorAxis*n*n,a=this.elements.perihelionAu,r=1-n*n/a*ki.stumpffC(i),o=t-n*n*n/Math.sqrt(ki.SUN_GM_AU3_PER_DAY2)*ki.stumpffS(i);return{x:r*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:r*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),n=Math.sqrt(ki.SUN_GM_AU3_PER_DAY2)*Math.abs(e),i=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*ki.stumpffS(l)+c*o};let a=Math.max(1,n/this.elements.perihelionAu);for(;i(a)<n;)a*=2;let r=0;for(let o=0;o<ki.MAX_ITERATIONS&&a-r>1e-13*Math.max(1,a);o++){const l=(r+a)/2;i(l)<n?r=l:a=l}return t*(r+a)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(e),a=Math.sin(e),r=Math.cos(t),o=Math.sin(t),l=Math.cos(n),c=Math.sin(n);return[{x:i*r-a*o*l,y:a*r+i*o*l,z:o*c},{x:-i*o-a*r*l,y:-a*o+i*r*l,z:r*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const n=Math.sqrt(e);return(n-Math.sin(n))/(n*n*n)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const Bg=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class xl{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return Bg.filter(n=>Math.abs(t-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(n=>this.appearanceOf(n,e,t)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(e,t,n){const i=Yt(t),a=this.earthPositionAt(i),r=this.apparentPositionOf(e,2451545+i.tt,a),o=this.subtract(r,a),l=this.length(r),c=this.length(o),h=this.tailEndAt(e,r,a,l,i,t,n),d=this.horizontalOf(o,i,t,n);return{apparition:e,position:d,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},a)),magnitude:this.magnitudeAt(e,l,c)}}static magnitudeAt(e,t,n){const i=e.absoluteMagnitude+5*Math.log10(n)+2.5*e.activityExponent*Math.log10(t);return Math.max(i,e.peakMagnitude)}static tailEndAt(e,t,n,i,a,r,o){if(e.tailLengthAu===void 0)return{};const l=1+e.tailLengthAu/i,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(c,a,r,o),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,n){const i=this.orbitOf(e);let a=i.positionAt(t);for(let r=0;r<2;r++){const o=this.length(this.subtract(a,n))/this.LIGHT_SPEED_AU_PER_DAY;a=i.positionAt(t-o)}return a}static horizontalOf(e,t,n,i){const a=yl(F_(),new wt(e.x,e.y,e.z,t)),r=yl(B_(t),a),o=m_(t,new Iu(i.lat,i.lng,i.elevationM)),l=new wt(r.x-o.x,r.y-o.y,r.z-o.z,t),c=_g(l);return tr(c.ra,c.dec,n,i)}static earthPositionAt(e){return yl(U_(),gs(Me.Earth,e))}static julianDayOf(e){return 2451545+Yt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new ki(e.orbit);return this.orbits.set(e.id,n),n}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const n=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const H3=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Jr=6.5;class Xa{static activeAt(e){return H3.flatMap(t=>{const n=this.nearness(t,e);return n<=0?[]:[{shower:t,zhr:t.peakZhr*n,nearness:n}]})}static nearness(e,t){const n=this.dayOfYear(t),i=this.dayOfYear(this.asDate(e.start)),a=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(n,a),l=this.wrappedDelta(a,i),c=this.wrappedDelta(r,a);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,n,i=Jr){if(t<=0)return 0;const a=Jr-i;return e*Math.sin(t*Math.PI/180)/Math.pow(n,a)}static radiantPosition(e,t,n){return tr(e.radiantRaHours,e.radiantDecDeg,t,n)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const n=e-t;return n>182?n-365:n<-182?n+365:n}}class Et{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Yt(e),i=new Tu(0,f_(e).elon-90,1),a=yl(z_(n),Sg(i,n)),r=_g(a);return tr(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=Jr){const n=Et.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),i=Jr-t;return(Et.QUIET_RATE_PER_HOUR+n)/Math.pow(Et.POPULATION_INDEX,i)}static schedule(e){const t=new Ag(e.seed^1542469173);return Xs.schedule(e).map(n=>{const i=Et.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),a=n.fromRadiantDeg*Math.PI/180,r=Et.turnAround(i,t.between(0,360)),o={x:i.x*Math.cos(a)+r.x*Math.sin(a),y:i.y*Math.cos(a)+r.y*Math.sin(a),z:i.z*Math.cos(a)+r.z*Math.sin(a)};return{...n,radiant:Et.toHorizontal(o),bearingDeg:Et.bearingFrom(o,i)}})}static turnAround(e,t){const[n,i]=Et.basisAround(e),a=t*Math.PI/180;return{x:n.x*Math.cos(a)+i.x*Math.sin(a),y:n.y*Math.cos(a)+i.y*Math.sin(a),z:n.z*Math.cos(a)+i.z*Math.sin(a)}}static bearingFrom(e,t){const[n,i]=Et.basisAround(e),a=e.x*t.x+e.y*t.y+e.z*t.z,r=Et.normalise({x:t.x-e.x*a,y:t.y-e.y*a,z:t.z-e.z*a});return(Math.atan2(r.x*i.x+r.y*i.y+r.z*i.z,r.x*n.x+r.y*n.y+r.z*n.z)*180/Math.PI%360+360)%360}static basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Et.normalise(Et.cross(e,t));return[n,Et.normalise(Et.cross(e,n))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=Et.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Et.turnAround(t,e.bearingDeg),i=e.fromRadiantDeg*Math.PI/180;return Et.toHorizontal({x:t.x*Math.cos(i)+n.x*Math.sin(i),y:t.y*Math.cos(i)+n.y*Math.sin(i),z:t.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,i=Math.cos(t);return{x:i*Math.sin(n),y:Math.sin(t),z:-i*Math.cos(n)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}class G3{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=ht.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=ht.sizeMAt(t.inFrontM,e);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:ht.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:ht.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class qa{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*qa.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const n=qa.degOver(e)/t;return n<1?1:Math.min(qa.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class an{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return qa.DEG_PER_SECOND*3600}static graspOf(e,t={}){const n=t.exposureSeconds??e.exposureSeconds,i=t.fNumber??e.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return an.EYE;const a=t.focalLengthMm??e.frame?.focalLengthMm??an.UNKNOWN_CAMERA_FOCAL_MM,r=a/i,o=an.resolutionArcsec(e,a,r);return{apertureMm:r,exposureSeconds:Math.min(n,an.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,n){const a=(e.detailUm??an.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*an.ARCSEC_PER_RADIAN,r=1.22*an.WAVELENGTH_M/(n/1e3)*an.ARCSEC_PER_RADIAN;return Math.max(a,r)}static trailLimitedSeconds(e){return e/an.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const n=an.graspOf(e,t),i=an.EYE,a=(n.apertureMm/i.apertureMm)**2,r=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(a*r*o)}static gainFor(e,t){const n=t.fieldOfViewDeg===void 0?void 0:it.focalLengthMmFor(e,t.fieldOfViewDeg);return an.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:n,exposureSeconds:t.exposureSeconds})}}class Ui{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(e,t,n,i,a){if(!(i>0))return 1;const r=a>0?Ui.travelDegOver(e,t,n,n+i*1e3)/a/Ui.PIXELS_PER_INSTANT:0,o=Ui.flashesOver(e,i)*Ui.INSTANTS_PER_FLASH,l=Math.ceil(Math.max(r,o));return l<2?1:Math.min(Ui.MAX_INSTANTS,l)}static travelDegOver(e,t,n,i){let a=0;for(const r of e){if(!r.track||r.track.length<2)continue;const o=Ui.directionAt(r,t,n),l=Ui.directionAt(r,t,i),c=Math.min(1,Math.max(-1,o.x*l.x+o.y*l.y+o.z*l.z));a=Math.max(a,Math.acos(c)*180/Math.PI)}return a}static flashesOver(e,t){let n=0;for(const i of e)for(const a of i.lights??[])a.pattern.kind==="flash"&&(n=Math.max(n,a.pattern.perMinute));return n/60*t}static directionAt(e,t,n){const i=Ya(e,n),a=i.eastM,r=i.altitudeM-t,o=i.northM,l=Math.hypot(a,r,o);return l===0?{x:0,y:1,z:0}:{x:a/l,y:r/l,z:o/l}}}const H0=111320,_r=Math.PI/180,V3=1.02,W3=1;class zr{static of(e,t){const n=zr.sightings(e,t);if(n.length<2)return;const i=zr.baseline(n);if(!i)return;const{near:a,far:r,closedM:o}=i,l=Math.tan(r.widthDeg/2*_r)===0?0:Math.tan(a.widthDeg/2*_r)/Math.tan(r.widthDeg/2*_r);if(l<V3)return;const c=o/(l-1),h=ht.sizeMAt(c,a.widthDeg),d=n.map(u=>({t:u.t,m:ht.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:r.t,toT:a.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===t)?.shape,a=i?.angular?.widthDeg,r=xt(e,n.t);return a===void 0||a<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:n.t,widthDeg:a,lat:r.lat,lng:r.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??r.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(e){let t;for(const n of e)for(const i of e){if(n.t>=i.t)continue;const a=zr.closedAlongSight(n,i),[r,o,l]=a>=0?[i,n,a]:[n,i,-a];l<W3||r.widthDeg<=o.widthDeg||(!t||l>t.closedM)&&(t={near:r,far:o,closedM:l})}return t}static closedAlongSight(e,t){const n=(t.lat-e.lat)*H0,i=(t.lng-e.lng)*H0*Math.cos(e.lat*_r),a=(e.sightAzimuthDeg??0)*_r;return n*Math.cos(a)+i*Math.sin(a)}}class un{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:un.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:un.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:un.atLeastNearest(e.derivedM),basis:"derived"};const t=un.largest(e.range?.minM,e.crossing?.behindM),n=un.smallest(e.range?.maxM,e.crossing?.inFrontM),i=t===void 0?void 0:t*un.MARGIN,a=n===void 0?void 0:n/un.MARGIN;return i!==void 0&&a!==void 0?{distanceM:un.atLeastNearest(i<=a?Math.sqrt(i*a):i),basis:"bounded"}:i!==void 0?{distanceM:un.atLeastNearest(i),basis:"bounded"}:a!==void 0&&a<un.CONVENTIONAL_M?{distanceM:un.atLeastNearest(a),basis:"bounded"}:{distanceM:un.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(un.NEAREST_M,e)}static largest(...e){const t=e.filter(n=>n!==void 0&&n>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(n=>n!==void 0&&n>0);return t.length===0?void 0:Math.min(...t)}}ql();const X3={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},q3=["en","fr"],Y3={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},K3={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},G0="comet:",$3={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},Z3=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,J3=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,j3=-18,Q3={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},ph={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class eT extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass",Ws,ka]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new z3;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(e.clientX-n.left)/n.width*t.width,a=(e.clientY-n.top)/n.height*t.height;if(this.ufoElement.hasVisibleShapeAt(i,a)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-n.left)/n.width*2-1,o=-((e.clientY-n.top)/n.height*2-1),l=Xr(Vs.preferencesFor(this),q3),c=this.sceneRenderer.pickBodyAt(r,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));return}const h=this.sceneRenderer.pickDecorAt(r,o),d=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(d){this.showHoverTooltip(e,this.said.read(d.title)||$3[d.kind][l]);return}const u=this.sceneRenderer.pickStarAt(r,o);if(u){const f=u.star.mag,g=u.altitudeDeg,v=(g<0?K3:Y3)[l];this.showHoverTooltip(e,v.replace("{name}",u.star.name[l]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(G0)?e.slice(G0.length):void 0;return(n?Bg.find(a=>a.id===n):void 0)?.name[t]??X3[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const e=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),e)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Fs(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs)};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${av}</style>${sv}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new di(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Dh),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",t=>this.lookToward(t.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&n!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&n!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),(e===Ws||e===ka)&&n!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[Ws,ka])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=xt(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=gn(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const a=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((a-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Kd.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=ht.CANVAS_HEIGHT_PX,n=it.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=n,this.sceneRenderer.resize(t,n)}async loadStars(){const e=[{magnitudeLimit:fh,url:this.getAttribute("star-catalog-src")??Z3},{magnitudeLimit:Br,url:this.getAttribute("deep-star-catalog-src")??J3}],t=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=t>fh?Br:fh;const i=await ui.upTo(e,t);n===this.starCatalogRequest&&(this.starCatalog=i,this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Br||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=an.gainFor(e.instrument,{fNumber:xt(e,0)?.fNumber,fieldOfViewDeg:on.fovOf(e,0),exposureSeconds:e.exposure});return Or(j3,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=this.exposureSeconds(),n=this.degreesPerPixelAt(e),i=qa.instants(t,n),a=Math.max(i,this.ufoElement.exposureTimes(e).length,Ui.instants(this.ufoElement.sighting.decor,xt(this.ufoElement.sighting,e)?.elevationM??0,e,t,n));if(a<=1){this.sceneRenderer.setExposure(1);return}const r=t*1e3;this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e+r*o/a,{sky:Math.floor(o*i/a)!==Math.floor((o-1)*i/a),stepMs:r/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:on.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const n=this.ufoElement.sighting;this.setWeather(Fs(n,e)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,e),this.sceneRenderer.setDecor(n.decor);const i=xt(n,e);if(this.sceneRenderer.setObserverPose(i??ph),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(an.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:on.fovOf(n,e),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Gt.of(n)?.offsetAt(e)??Gt.STILL),this.sceneRenderer.updateDecorAnchoring(xt(n,0),i,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(e),t&&!t.sky)return;const a=i?.lat??ph.lat,r=i?.lng??ph.lng,o=Va(n.event.time??{},r,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(Q3);return}const l=new Date(o.getTime()+e),c={lat:a,lng:r,elevationM:i?.elevationM??0},h=`${l.getTime()}|${a}|${r}|${c.elevationM}|${this.starCatalog?this.starCatalogDepth:0}`;if(h===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=h;const d={...On("Sun",l,c),magnitude:Jc("Sun",l)},u={...On("Moon",l,c),phase:Hl(l),magnitude:Jc("Moon",l)},f=H_.map(g=>({body:g,position:On(g,l,c),magnitude:Jc(g,l)}));this.sceneRenderer.setAstronomy({sun:d,moon:u,planets:f,comet:this.cometAt(l,c),stars:this.starCatalog?{catalog:this.starCatalog,date:l,observer:c}:void 0,frame:{date:l,observer:c}}),this.ufoElement.setSunAltitude(d.altitudeDeg)}cometAt(e,t){const n=xl.brightestAt(e,t);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const n=t.timeline,i=this.ufoElement.canvasElement,a=this.ufoElement.frameShiftPx,r=this.projectionAt(e),o=new Map,l=new Map,c=new Set;for(const v of n.sourceIds){const p=n.getInterpolatedShapeAt(e,v);if(!p)continue;const m={...p,bounds:{...p.bounds,x:p.bounds.x+a.x,y:p.bounds.y+a.y}};o.set(v,m);const S=p.aim?this.sceneRenderer.screenPointOf($n.directionOf(p.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/i.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/i.height*2-1)},_=S!==void 0&&Math.abs(S.ndcX)<=1&&Math.abs(S.ndcY)<=1,x=_?this.sceneRenderer.decorDistancesAt(S.ndcX,S.ndcY,v):{};c.add(v),(_||p.aim)&&c.delete(v);const M=p.angular?.widthDeg??r.pxToDeg(p.bounds.width),E=this.sizeEstimateOf(v);E.add(M,x);const I=zr.of(t,v);l.set(v,un.resolve({hypothesisM:this.distanceHypotheses.get(v),derivedM:I&&M>0?ht.distanceMAt(I.widthM,M):void 0,range:E.distanceRangeAt(M),crossing:x}))}for(const[v,p]of o)for(const[m,S]of o){if(m===v||S.transparency>=1||S.bounds.width*S.bounds.height<=p.bounds.width*p.bounds.height||!(p.bounds.x>=S.bounds.x&&p.bounds.y>=S.bounds.y&&p.bounds.x+p.bounds.width<=S.bounds.x+S.bounds.width&&p.bounds.y+p.bounds.height<=S.bounds.y+S.bounds.height))continue;const x=l.get(m);x&&l.set(v,{distanceM:x.distanceM*.999,basis:x.basis});break}this.depths=l;const h=n.sourceIds,d=this.sceneRenderer.lowerCloudUp,u=[];for(const[v,p]of o)u.push({sourceId:v,shape:p,distanceM:l.get(v).distanceM,renderOrder:h.indexOf(v),aim:p.aim,hidden:p.behindCloud===!0&&d||c.has(v)});const g=(xt(t,e)?.rollDeg??0)+(Gt.of(t)?.offsetAt(e)??Gt.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:r,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:it.starPointsOf(t.instrument),rollRad:g*Math.PI/180})}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(t).pxToDeg(n.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(i)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],n=e.event.time;return JSON.stringify([t?.lat,t?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],n=e.event.time,i=t?.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?Va(n,t.lng,e.event.utcOffsetHours):void 0;if(!i||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const a={lat:t.lat,lng:t.lng,elevationM:0},r=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(t.lat*1e3),l=Et.schedule({ratePerHour:Et.observedRatePerHour(Et.apexPosition(i,a).altitudeDeg),durationMs:r,velocityKmS:Et.TYPICAL_VELOCITY_KM_S,seed:o}),c=Xa.activeAt(i).map(d=>{const u=Xa.radiantPosition(d.shower,i,a);return{entry:d,position:u,rate:Xa.observedRatePerHour(d.zhr,u.altitudeDeg,d.shower.populationIndex)}}).sort((d,u)=>u.rate-d.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=Xs.schedule({ratePerHour:c.rate,durationMs:r,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(a=>a.t+a.durationMs<=this.ufoElement.seekableDuration).sort((a,r)=>r.brightness-a.brightness);if(t.length===0)return;const n=t[e%t.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(e){const t=this.ufoElement.sighting,n=t.instrument,i=n.frame,a=xt(t,e),r=a?.fNumber??n.fNumber;if(!i||r===void 0)return;const o=it.focalLengthMmFor(n,on.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:r,focusDistance:a?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return xi.of(t.instrument,ht.CANVAS_HEIGHT_PX,on.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new G3,this.sizeEstimates.set(e,t)),t}}const Yd="rr0-scene";function tT(){ql(),customElements.get(Yd)||customElements.define(Yd,eT)}class nT{constructor(e,t){this.timeline=e,this.clock=t}currentPointer=null;shapePrototype=null;sourceId="";start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.clock.start(n=>this.recordSample(n))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop()}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=rm(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}])}}class iT{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const n=performance.now()-this.startTime;n-this.lastTick>=this.intervalMs&&(this.lastTick=n,e(n)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const sT=[{id:"echo",name:{en:"the Echo balloons",fr:"les ballons Echo"},from:"1960-08-12",to:"1969-06-07",peakMagnitude:-1,note:"Echo 1 and 2 were 30- and 40-metre reflective balloons, as bright as the brightest stars and moving slowly enough to be watched — deliberately visible, widely announced in newspapers, and the first objects most people ever saw crossing the night sky. They fall squarely inside the sighting waves this project reconstructs."},{id:"iridium-flares",name:{en:"the Iridium flares",fr:"les flashes d'Iridium"},from:"1997-05-05",to:"2019-12-27",peakMagnitude:-8,note:"The original Iridium satellites carried flat, mirror-finish antennas that threw a sunbeam a few kilometres wide across the ground: a still point of sky flaring to magnitude -8 over five seconds and vanishing again. Nothing else in the sky does that."},{id:"iss",name:{en:"the International Space Station",fr:"la Station spatiale internationale"},from:"1998-11-20",peakMagnitude:-5.9,note:"Since its first module, and much brighter as it grew: at its best it outshines everything in the sky but the Sun and the Moon, crossing in a straight silent line in about four minutes."},{id:"starlink-trains",name:{en:"the Starlink trains",fr:"les trains de Starlink"},from:"2019-05-24",peakMagnitude:1,note:"In the days after a launch, satellites still bunched in their deployment string cross as an evenly spaced line of lights — the most reported 'formation of UFOs' of the era. They spread out within weeks, so a train is a fact about the days after a launch rather than about the year."}],aT=23493,V0=[2,3,2,1,2,5,4,6,5,6,6,6,6,6,6,6,9,9,9,9,9,9,14,14,15,16,16,16,16,16,18,22,25,24,29,28,29,33,34,35,40,40,42,42,43,46,48,48,49,53,53,54,58,61,70,70,74,78,79,83,92,92,99,97,101,102,109,115,126,125,123,125,127,130,139,153,157,156,161,156,165,174,193,193,201,203,212,215,224,244,255,263,262,281,293,307,312,327,339,336,343,353,359,369,386,396,405,410,421,419,424,434,443,450,460,480,492,504,509,516,519,524,527,530,527,535,543,549,564,571,573,576,582,584,600,600,608,618,625,632,637,642,648,654,661,667,669,667,671,671,697,692,703,697,710,714,724,731,747,755,764,770,782,802,801,815,819,837,846,856,878,881,877,900,906,907,917,932,932,936,954,973,989,986,991,990,1002,1009,1021,1024,1040,1038,1058,1078,1098,1092,1094,1099,1122,1132,1140,1151,1154,1161,1176,1185,1202,1206,1227,1228,1243,1265,1281,1288,1296,1325,1328,1336,1354,1373,1375,1393,1398,1411,1432,1457,1462,1476,1487,1485,1506,1509,1521,1524,1537,1543,1563,1586,1598,1614,1621,1620,1640,1658,1660,1673,1670,1686,1708,1715,1726,1726,1745,1749,1767,1774,1790,1798,1803,1805,1815,1818,1819,1820,1833,1822,1821,1819,1838,1835,1845,1841,1851,1869,1865,1868,1871,1870,1879,1882,1886,1900,1899,1908,1921,1928,1954,1966,1976,1986,1999,2007,2015,2030,2036,2057,2067,2072,2077,2088,2101,2106,2112,2119,2127,2142,2171,2176,2203,2226,2242,2241,2244,2254,2263,2284,2300,2320,2327,2345,2364,2367,2402,2423,2425,2434,2443,2461,2476,2495,2505,2520,2531,2535,2556,2567,2599,2608,2625,2639,2660,2663,2668,2681,2695,2702,2709,2719,2720,2738,2746,2763,2778,2788,2796,2807,2822,2831,2831,2853,2863,2866,2883,2892,2895,2921,2919,2937,2941,2947,2964,2987,2992,2987,2995,3002,3021,3025,3026,3036,3052,3049,3059,3077,3075,3083,3086,3107,3123,3124,3146,3155,3168,3179,3204,3205,3211,3233,3252,3253,3276,3287,3294,3293,3297,3314,3326,3335,3338,3355,3362,3358,3365,3364,3376,3375,3382,3418,3429,3432,3455,3463,3483,3490,3502,3509,3521,3532,3542,3544,3553,3571,3580,3588,3596,3603,3633,3639,3649,3655,3660,3670,3699,3699,3707,3723,3747,3752,3754,3766,3772,3778,3781,3798,3815,3814,3824,3832,3853,3859,3879,3885,3899,3912,3910,3924,3937,3951,3951,3961,3963,3961,3976,3977,3988,4004,4018,4025,4047,4074,4086,4108,4133,4136,4159,4168,4182,4192,4200,4215,4230,4239,4257,4678,4698,4694,4713,4719,4739,4750,4756,4764,4771,4788,4792,4790,4809,4821,4829,4834,4836,4843,4853,4863,4872,4881,4890,4898,4901,4897,4895,4884,4886,4886,4894,4897,4905,4905,4909,4907,4925,4918,4920,4929,4925,4928,4936,4943,4944,4951,4955,4952,4974,4976,4975,4981,4994,4997,5022,5023,5032,5043,5048,5051,5066,5062,5068,5075,5082,5082,5098,5102,5110,5113,5119,5123,5138,5138,5145,5149,5157,5165,5166,5169,5178,5183,5190,5192,5203,5204,5207,5214,5228,5234,5245,5249,5256,5262,5275,5278,5305,5303,5315,5321,5348,5358,5369,5369,5372,5385,5402,5409,5427,5429,5429,5439,5456,5464,5481,5485,5494,5509,5520,5526,5543,5555,5568,5575,5585,5596,5602,5620,5627,5644,5647,5660,5678,5680,5684,5692,5700,5711,5727,5733,5736,5756,5776,5797,5805,5804,5807,5800,5808,5814,5822,5839,5856,5869,5889,5902,5919,5921,5936,5937,5936,5957,5961,5975,5981,6002,6015,6027,6035,6042,6059,6062,6080,6081,6092,6097,6106,6127,6129,6198,6227,6231,6243,6249,6262,6255,6279,6304,6315,6326,6330,6334,6361,6358,6359,6379,6381,6389,6388,6404,6404,6443,6465,6473,6497,6500,6513,6524,6532,6538,6578,6572,6576,6584,6582,6608,6639,6656,6761,6764,6768,6772,6836,6905,6916,6925,6951,6984,7009,7072,7092,7110,7122,7140,7148,7170,7168,7180,7194,7247,7374,7391,7393,7382,7425,7485,7530,7568,7587,7602,7602,7715,7771,7900,8004,8103,8153,8162,8296,8319,8437,8566,8746,8860,8913,9128,9275,9585,9739,10014,10123,10167,10203,10288,10323,10398,10544,10721,10883,11044,11157,11442,11515,11787,12070,12269,12468,12484,12619,12883,13008,13264,13317,13549,13859,14049,14175,14360,14498,14687,14843,14984,15093,15279,15431,15623,15741,15788,15966,16025,16132,16419,16568,16791,16892,17060,17269,17598,17959,18194,18482,18804,19136,19564,19990,20249,20509,20943,21248,21539,21845,22196,22412];class fi{static FIRST_ORBIT="1957-10-04";static EARTH_RADIUS_KM=6371;static LOW_ORBIT_KM=500;static shadowHeightKm(e){if(e>=0)return 0;const t=-e*Math.PI/180;return fi.EARTH_RADIUS_KM*(1/Math.cos(t)-1)}static isLitOverhead(e,t){return e>fi.shadowHeightKm(t)}static classesAt(e){const t=e.getTime();return sT.filter(n=>{const i=Date.parse(`${n.from}T00:00:00Z`),a=n.to===void 0?1/0:Date.parse(`${n.to}T23:59:59Z`);return t>=i&&t<=a})}static trackedInOrbitAt(e){const t=e.getUTCFullYear()*12+e.getUTCMonth()-aT;if(!(t<0))return V0[Math.min(t,V0.length-1)]}static visibilityAt(e,t){const n=On("Sun",e,t).altitudeDeg;return{sunAltitudeDeg:n,shadowHeightKm:fi.shadowHeightKm(n),lowOrbitLit:fi.isLitOverhead(fi.LOW_ORBIT_KM,n),classes:fi.classesAt(e),trackedObjects:fi.trackedInOrbitAt(e),anythingInOrbit:e.getTime()>=Date.parse(`${fi.FIRST_ORBIT}T00:00:00Z`)}}}const rT={en:["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"],fr:["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSO","SO","OSO","O","ONO","NO","NNO"]};class Gs{static POINT_DEG=360/16;static point(e,t){const n=(e%360+360)%360,i=Math.round(n/Gs.POINT_DEG)%16;return rT[t][i]}static towards(e,t){const n=Gs.point(e,t);return t==="en"?`to the ${n}`:oT.test(n)?`à l'${n}`:`au ${n}`}}const oT=/^[EO]/;class tt{static COARSE_STEP_DEG=10;static FINE_STEP_DEG=2;static FINE_SPAN_DEG=10;static LOWEST_DEG=5;static THRESHOLD_CONTRAST=.5;static CONE_SEPARATION_DEG=60;galaxy=new $e;dust=new _t;assess(e,t){const n=On("Sun",e,t),i=On("Moon",e,t),a={altitudeDeg:i.altitudeDeg,phaseAngleDeg:We.phaseAngleOf(Hl(e).illuminatedFraction)},r=Ln.galactic(e,t),o=tt.unit(r.centre),l=tt.unit(r.rotation),c=tt.unit(r.pole),h=tt.unit(Ln.eclipticPole(e,t)),d=tt.unit(n),u=tt.unit(i),f=tt.normalize(tt.reject(d,h));let g,v,p=0;const m=(S,_)=>{const x=tt.unit({altitudeDeg:S,azimuthDeg:_}),M=tt.between(x,d),E=We.magPerArcsec2({altitudeDeg:n.altitudeDeg,separationDeg:M},{...a,separationDeg:tt.between(x,u)},S);E>p&&(p=E);const I=qi.fromMagPerArcsec2(E),y=10**(-.4*We.EXTINCTION_PER_AIR_MASS*(We.airMass(S)-1)),T=this.galaxy.surfaceBrightnessS10(Math.atan2(tt.dot(x,l),tt.dot(x,o))*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,tt.dot(x,c))))*180/Math.PI)*y;g=tt.better(g,T,I,E,S,_,M);const C=Math.max(-1,Math.min(1,tt.dot(x,h))),D=tt.normalize(tt.reject(x,h)),P=this.dust.surfaceBrightnessS10(tt.between(D,f),Math.asin(C)*180/Math.PI)*y;v=tt.better(v,P,I,E,S,_,M)};for(let S=tt.LOWEST_DEG;S<=90;S+=tt.COARSE_STEP_DEG)for(let _=0;_<360;_+=tt.COARSE_STEP_DEG)m(S,_);for(const S of[g,v]){if(!S)continue;const _=tt.FINE_SPAN_DEG,x=tt.FINE_STEP_DEG;for(let M=S.altitudeDeg-_;M<=S.altitudeDeg+_;M+=x)if(!(M<tt.LOWEST_DEG||M>90))for(let E=S.azimuthDeg-_;E<=S.azimuthDeg+_;E+=x)m(M,(E+360)%360)}return{milkyWay:g&&g.contrast>=tt.THRESHOLD_CONTRAST?g:void 0,zodiacal:v&&v.contrast>=tt.THRESHOLD_CONTRAST?v:void 0,darkestSkyMagPerArcsec2:p}}static better(e,t,n,i,a,r,o){const l=t/n;return e&&e.contrast>=l?e:{contrast:l,altitudeDeg:a,azimuthDeg:r,magPerArcsec2:qi.toMagPerArcsec2(t),skyMagPerArcsec2:i,sunSeparationDeg:o}}static unit(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,i=Math.cos(t);return[i*Math.sin(n),Math.sin(t),-i*Math.cos(n)]}static dot(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}static between(e,t){return Math.acos(Math.max(-1,Math.min(1,tt.dot(e,t))))*180/Math.PI}static reject(e,t){const n=tt.dot(e,t);return[e[0]-n*t[0],e[1]-n*t[1],e[2]-n*t[2]]}static normalize(e){const t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]}}const ll=36e5,W0=25;class mh{constructor(e){this.provider=e}async infer(e){const t=this.questionOf(e);if(!t)return{status:"incomplete"};const{origin:n,start:i}=t,a=Ka(e.event)??0,r=this.sampleTimings(e,i,a);let o;try{o=await this.provider.getWeather({points:r.map(l=>this.pointAt(e,l,n))})}catch{return{status:"failed",at:i}}return o?{status:"inferred",at:i,source:o.source,keyframes:o.samples.map((l,c)=>({t:r[c].t,weather:l.weather}))}:{status:"unavailable",at:i}}applyTo(e,t){if(!(t.status!=="inferred"||!t.keyframes||!t.source)){e.weatherTrack.clear();for(const n of t.keyframes)e.weatherTrack.addKeyframe(n.t,n.weather);e.weatherSource=t.source}}sampleTimes(e,t){const n=[e],i=e.getTime()+t;let a=Math.floor(e.getTime()/ll)*ll+ll;for(;a<=i&&n.length<W0;)n.push(new Date(a)),a+=ll;return t>0&&n[n.length-1].getTime()!==i&&n.length<W0&&n.push(new Date(i)),n}sampleTimings(e,t,n){const i=e.timeline.duration>0?e.timeline.duration:n;return n<=0||i<=0?[{time:t,t:0}]:this.sampleTimes(t,n).map(a=>{const r=(a.getTime()-t.getTime())/n;return{time:a,t:Math.round(i*Math.max(0,Math.min(1,r)))}})}canInfer(e){return this.questionOf(e)!==void 0}questionOf(e){const t=this.originOf(e);if(!t)return;const n=e.event.time;if(n?.year===void 0||n.month===void 0||n.day===void 0)return;const i=Va(n,t.lng,e.event.utcOffsetHours);return i?{origin:t,start:i}:void 0}originOf(e){const t=xt(e,0),n=e.event.place?.[0],i=t?.lat??n?.lat,a=t?.lng??n?.lng;return i===void 0||a===void 0?void 0:{lat:i,lng:a}}pointAt(e,t,n){const i=xt(e,t.t);return{lat:i?.lat??n.lat,lng:i?.lng??n.lng,time:t.time}}}const lT=Date.UTC(1940,0,1),X0=36e5,q0=.25,cT=.7,hT=.45,dT=.1,uT=2,fT=.3,pT=.2,mT=8,gh=.125,gT=.05,vT=125,yT=100,bT=2500,Y0=3500,K0=8e3,xT=95,wT=99,MT=[96,99],ST=["cloud_cover","cloud_cover_low","cloud_cover_mid","cloud_cover_high","precipitation","snowfall","weather_code","wind_speed_10m","wind_direction_10m","temperature_2m","dew_point_2m"];class zg{fetchImpl;baseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://archive-api.open-meteo.com/v1/archive"}async getWeather(e){if(e.points.length===0)return;const t=e.points.map(f=>f.time.getTime()),n=Math.min(...t);if(n<lT)return;const i=new Map;for(const f of e.points){const g=this.cellKey(f);i.has(g)||i.set(g,{lat:f.lat,lng:f.lng,index:i.size})}const a=this.requestUrl([...i.values()],new Date(n),new Date(Math.max(...t))),r=this.cache.get(a);if(r)return r;const o=await this.fetchImpl(a);if(!o.ok)throw new Error(`Open-Meteo HTTP ${o.status}`);const l=await o.json(),c=Array.isArray(l)?l:[l];if(c.length<i.size||c.some(f=>f.error||!f.hourly))return;const h={id:"era5",name:"ERA5 (Open-Meteo)",url:a},d=e.points.map(f=>this.sampleAt(c[i.get(this.cellKey(f)).index].hourly,f.time));if(d.some(f=>f===void 0))return;const u={samples:d,source:h};return this.cache.set(a,u),u}cellKey(e){return`${Math.round(e.lat/q0)},${Math.round(e.lng/q0)}`}requestUrl(e,t,n){const i=new URLSearchParams({latitude:e.map(a=>a.lat).join(","),longitude:e.map(a=>a.lng).join(","),start_date:this.isoDate(t),end_date:this.isoDate(n),hourly:ST.join(","),wind_speed_unit:"ms",timezone:"UTC"});return`${this.baseUrl}?${i}`}isoDate(e){return e.toISOString().slice(0,10)}sampleAt(e,t){const n=this.recordAt(e,t);return n&&{time:t,weather:this.toWeather(n)}}recordAt(e,t){const n=e.time.map(o=>Date.parse(`${o}Z`)),i=t.getTime();if(n.length===0||i<n[0]-X0||i>n[n.length-1]+X0)return;if(i<=n[0])return this.recordFrom(e,0);if(i>=n[n.length-1])return this.recordFrom(e,n.length-1);let a=0;for(;a+1<n.length&&n[a+1]<=i;)a++;const r=n[a+1]-n[a];return this.blendRecords(this.recordFrom(e,a),this.recordFrom(e,a+1),r>0?(i-n[a])/r:0)}recordFrom(e,t){const n={cloudCover:e.cloud_cover[t]/100,cloudCoverLow:e.cloud_cover_low[t]/100,cloudCoverMid:e.cloud_cover_mid[t]/100,cloudCoverHigh:e.cloud_cover_high[t]/100,precipitationMm:e.precipitation[t],snowfallCm:e.snowfall[t],weatherCode:e.weather_code[t],windSpeedMs:e.wind_speed_10m[t],windFromDeg:e.wind_direction_10m[t],temperatureC:e.temperature_2m[t],dewPointC:e.dew_point_2m[t]};return Object.values(n).some(i=>i===void 0||Number.isNaN(i))?void 0:n}blendRecords(e,t,n){if(!e||!t)return e??t;const i=(r,o)=>r+(o-r)*n,a=((t.windFromDeg-e.windFromDeg)%360+540)%360-180;return{cloudCover:i(e.cloudCover,t.cloudCover),cloudCoverLow:i(e.cloudCoverLow,t.cloudCoverLow),cloudCoverMid:i(e.cloudCoverMid,t.cloudCoverMid),cloudCoverHigh:i(e.cloudCoverHigh,t.cloudCoverHigh),precipitationMm:i(e.precipitationMm,t.precipitationMm),snowfallCm:i(e.snowfallCm,t.snowfallCm),weatherCode:n<.5?e.weatherCode:t.weatherCode,windSpeedMs:i(e.windSpeedMs,t.windSpeedMs),windFromDeg:((e.windFromDeg+a*n)%360+360)%360,temperatureC:i(e.temperatureC,t.temperatureC),dewPointC:i(e.dewPointC,t.dewPointC)}}toWeather(e){const t=e.weatherCode>=xT&&e.weatherCode<=wT,n=this.precipitationTypeFrom(e);return{cloudCover:this.clamp(e.cloudCover,0,1),cloudDarkness:this.cloudDarknessFrom(e,t),cloudBaseM:this.cloudBaseFrom(e),highCloudCover:e.cloudCoverHigh,lowerCloudCover:Math.max(e.cloudCoverLow,e.cloudCoverMid),precipitationType:n,precipitationIntensity:n==="none"?0:this.clamp(Math.sqrt(e.precipitationMm/mT),0,1),windDirectionDeg:(e.windFromDeg+180)%360,windSpeed:e.windSpeedMs,storm:t}}precipitationTypeFrom(e){return e.snowfallCm>0?"snow":MT.includes(e.weatherCode)?"hail":e.precipitationMm>0?"rain":"none"}cloudDarknessFrom(e,t){const n=e.cloudCoverLow+e.cloudCoverMid+e.cloudCoverHigh;if(n<=0)return 0;const i=(cT*e.cloudCoverLow+hT*e.cloudCoverMid+dT*e.cloudCoverHigh)/n,a=Math.min(1,e.precipitationMm/uT);return this.clamp(i+fT*a+(t?pT:0),0,1)}cloudBaseFrom(e){if(e.cloudCover<gT)return;const t=this.clamp(vT*(e.temperatureC-e.dewPointC),yT,bT);if(e.cloudCoverLow>=gh)return Math.round(t);if(e.cloudCoverMid>=gh)return Y0;if(e.cloudCoverHigh>=gh)return K0;const n=Math.max(e.cloudCoverLow,e.cloudCoverMid,e.cloudCoverHigh);if(!(n<=0))return n===e.cloudCoverLow?Math.round(t):n===e.cloudCoverMid?Y0:K0}clamp(e,t,n){return Math.max(t,Math.min(n,e))}}function _T(){return new zg}const ET=5;class Hg{attribution={text:"© OpenStreetMap",url:"https://osm.org/copyright"};fetchImpl;baseUrl;reverseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://nominatim.openstreetmap.org/search",this.reverseUrl=e.reverseUrl??"https://nominatim.openstreetmap.org/reverse"}async reverse(e,t,n={}){const i=new URLSearchParams({lat:String(e),lon:String(t),format:"jsonv2"});n.language&&i.set("accept-language",n.language);const a=`${this.reverseUrl}?${i}`,r=this.cache.get(a);if(r)return r[0];const o=await this.fetchImpl(a,{signal:n.signal});if(!o.ok)throw new Error(`Nominatim HTTP ${o.status}`);const l=await o.json(),c=l.error?void 0:this.toMatch(l);return this.cache.set(a,c?[c]:[]),c}async search(e,t={}){const n=e.trim();if(n==="")return[];const i=this.requestUrl(n,t),a=this.cache.get(i);if(a)return a;const r=await this.fetchImpl(i,{signal:t.signal});if(!r.ok)throw new Error(`Nominatim HTTP ${r.status}`);const o=await r.json(),l=(Array.isArray(o)?o:[]).map(c=>this.toMatch(c)).filter(c=>c!==void 0);return this.cache.set(i,l),l}requestUrl(e,t){const n=new URLSearchParams({q:e,format:"jsonv2",limit:String(t.limit??ET)});return t.language&&n.set("accept-language",t.language),`${this.baseUrl}?${n}`}toMatch(e){const t=e.display_name??e.name,n=this.coordinate(e.lat),i=this.coordinate(e.lon);return t&&n!==void 0&&i!==void 0?{name:t,lat:n,lng:i}:void 0}coordinate(e){if(e===void 0||e.trim()==="")return;const t=Number(e);return Number.isFinite(t)?t:void 0}}function TT(){return new Hg}const AT=[{id:"nominatim",name:"Nominatim",credit:"© OpenStreetMap",creditUrl:"https://osm.org/copyright",create:()=>new Hg}],IT=[{id:"era5",name:"ERA5 (Open-Meteo)",credit:"© Copernicus/ECMWF",creditUrl:"https://open-meteo.com/en/docs/historical-weather-api",create:()=>new zg}];class DT{attribution;fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis);const t=e.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${t}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${t})`}async getImageryTexture(e,t){return ym(e,t,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}const vh=[{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new vm}],$0=[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:()=>new bm},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:()=>new DT}];class Du{constructor(e){this.provider=e}static SPAN_DEG=.002;async at(e,t){const n=Du.SPAN_DEG;try{const a=(await this.provider.getElevationGrid({south:e-n,north:e+n,west:t-n,east:t+n},{width:2,height:2})).heights[0];return Number.isFinite(a)?a:void 0}catch{return}}}class CT{available(){const e=Intl.supportedValuesOf;return e?[...e.call(Intl,"timeZone")].sort():[]}offsetHoursAt(e,t){if(t.year===void 0)return;const n=Date.UTC(t.year,(t.month??1)-1,t.day??1,t.hour??12,t.minute??0,t.second??0),i=this.zoneOffsetHours(e,new Date(n));if(i!==void 0)return this.zoneOffsetHours(e,new Date(n-i*36e5))??i}zoneOffsetHours(e,t){let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(a=>a.type==="timeZoneName")?.value??""}catch{return}const i=/^GMT(?:([+-])(\d{2}):(\d{2}))?$/.exec(n);if(i)return i[1]?(i[1]==="-"?-1:1)*(Number(i[2])+Number(i[3])/60):0}}function Ea(s,e){return s.find(t=>t.id===e)??s[0]}class RT{constructor(e="https://api.open-meteo.com/v1/forecast"){this.endpoint=e}async zoneAt(e,t){const n=new URL(this.endpoint);n.searchParams.set("latitude",String(e)),n.searchParams.set("longitude",String(t)),n.searchParams.set("timezone","auto"),n.searchParams.set("forecast_days","1");try{const i=await fetch(n.toString());if(!i.ok)return;const a=await i.json();return a.timezone&&a.timezone!=="GMT"?a.timezone:void 0}catch{return}}}const PT=[{id:"open-meteo",name:"Open-Meteo",credit:"© Open-Meteo",creditUrl:"https://open-meteo.com/en/docs",create:()=>new RT}],LT={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",assessmentGroup:"Assessment",assessmentNames:{coverage:"Witness info"},assessmentVerdicts:{"hynek.nl":"NL — nocturnal light","hynek.dd":"DD — daylight disc","hynek.rv":"RV — radar-visual","hynek.ce1":"CE1 — close encounter","hynek.ce2":"CE2 — with a physical trace","hynek.ce3":"CE3 — with entities"},witnessGroup:"Witness",witnessId:"ID",witnessTitle:"Title",witnessLastName:"Last name",witnessFirstNames:"First names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorEntity:"Being",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Environment",decorBuilding:"Building",decorTree:"Tree",decorCrop:"Crop row",decorMound:"Stone heap",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorColor:"Colour",decorLit:"Lit",decorTitle:"Name",milestones:"Moments",milestoneLabel:"Label",milestoneNote:"What happens",addMilestone:"Name this moment",deleteMilestone:"Delete moment",confirmAccept:"Delete",confirmDecline:"Cancel",decorWidth:"Width",decorLength:"Length",decorHeight:"Height",decorModel:"3D model",decorModelNone:"Built-in shape",decorModelAdvanced:"Model from an address",decorModelUrl:"glTF/GLB address",decorModelTitle:"Model name",decorModelAuthor:"Author",decorModelLicense:"Licence",decorModelSource:"Where it came from",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},Gg={...LT,oval:"Oval",polygon:"Polygon",addVertex:"Add vertex",deleteVertex:"Delete vertex",notAPolygon:"Select a single polygon shape",tooFewVertices:"A shape needs at least 3 points",shape:"Shape",objectSize:"Try a size",objectDistance:"at a distance of",apparentSize:"i.e. {deg}° — {moons}× the Moon",utcOffsetPlaceholder:"from longitude",objectSizePlaceholder:"assumed width",objectDistancePlaceholder:"assumed distance",realSizeBetween:"Real width: between {min} and {max} m, from what it crosses",realSizeAtLeast:"Real width: at least {min} m, from what it passes behind",realSizeAtMost:"Real width: at most {max} m, from what it passes in front of",realSizeUnknown:"Real width unknown: nothing in the scene crosses its line of sight",blurBound:"Blurred through this lens: nearer than {max} m",blurBoundNoInstrument:"Blur through the naked eye bounds no distance — an eye has no aperture to be out of focus with",blurBoundNotAtInfinity:"Blur bounds a distance only for a lens focused at infinity: this one is focused at {focus} m, which blurs on both sides of it",realSizeContradiction:"Contradiction: the declared crossings cannot all be true",realDistanceHere:" — i.e. between {min} and {max} m here",distanceHypothesis:"Show it at",clearDistanceHypothesis:"Back to what the recording establishes",depthStated:"Drawn at {m} m, as the recording states",depthHypothesis:"Drawn at {m} m: your hypothesis — what the decor hides of it is what a thing that far would lose",depthDerived:"Drawn at {m} m, from the witness's own walk",depthBounded:"Drawn at {m} m, from what it passes behind and in front of",depthConventional:"Drawn at {m} m by convention: nothing in the recording establishes a distance",addShape:"Add shape",deleteShape:"Delete shape",play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",group:"Group",ungroup:"Ungroup",bringToFront:"Bring to front",sendToBack:"Send to back",contextMenuDelete:"Delete",confirmDeleteShape:"Delete {name}? This can't be undone.",confirmDeleteShapes:"Delete {count} shapes? This can't be undone.",confirmDeleteMilestone:"Stop naming moment {name}? The recording itself is unchanged.",onlyOneShape:"There is only one shape",alreadyAtFront:"This shape is already at the front",alreadyAtBack:"This shape is already at the back",needTwoShapesToGroup:"Select at least two shapes to group them",notGrouped:"This shape isn't part of a group",multipleShapesSelected:"Multiple shapes selected — select just one to edit this",samplingRate:"Sampling rate",currentPosition:"Current position",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",durationPlaceholder:"observation length",durationImprecise:"These dates don't precisely enough determine a duration — enter it manually.",export:"Export",importFile:"Load JSON file",importUrl:"Or load from URL",importUrlPlaceholder:"https://…/sighting.json",importButton:"Load",importError:"Couldn't load that recording — check the file or URL and try again.",importErrorCors:'That address answers, but the browser is not allowed to read it from this page. The file itself is fine — its server needs to send the header "Access-Control-Allow-Origin: *" with it. If it is not your server, that is what to ask its administrator for.',importErrorMixedContent:"A secure page cannot load an address starting with http://. Use https:// if that server offers it.",importErrorUnreachable:"Nothing answered at that address. Check the spelling, and that you are online.",importErrorStatus:"That server answered with an error ({status}). The address is probably wrong, or the file has moved.",importErrorMalformed:"That address answered, but what came back is not a recording.",record:"Record",stop:"Stop",according:"according to",sourceElevation:"Relief",sourceImagery:"Imagery",placeNamePlaceholder:"Valensole, France",searchPlace:"Locate",placeMatch:"Matches",placeSearching:"Looking up the place…",placeMatchFound:"place found",placeMatchesFound:"places found",placeNotFound:"No place by that name",placeSearchFailed:"Place search temporarily unavailable",utcOffsetImplausible:"This time zone doesn't match the longitude entered, whose own solar time is UTC{solar} — yet the scene and the weather record both obey what is declared here. Clear the field to derive it from the longitude.",timeZoneManual:"offset entered",altitudeAboveSeaLevel:"The witness's altitude above sea level — the ground at the location entered sets its floor: a witness in the Alps is not at 0 m.",groundAt:"ground at {m} m",headingPlaceholder:"unknown",edtfInvalid:"Not a valid EDTF date/time (e.g. 1965-07-01T05:00, 2025-06?, 2025~).",edtfPlaceholder:"YYYY-MM-DDThh:mm[?~%] or hh:mm",observationTimeHint:"EDTF — e.g. 1965-07-01T05:00, 2025-06? (uncertain), 2025~ (approximate), or just 05:00 if the date isn't known",observationEndTimeHint:"EDTF — e.g. 1965-07-01T05:10, 2025-06? (uncertain), 2025~ (approximate), or just 05:10 if the date isn't known",presetsGroupLabel:"UFO shape",witnessDirName:"Dir name",description:"Description",tagsPlaceholder:"comma-separated",weather:"Weather",shapeGroup:"Phenomenon",soundGroup:"Sound",temporalGroup:"Moment",timeQualifierExact:"Exact",timeQualifierApproximate:"Approximate",timeQualifierUncertain:"Uncertain",timeQualifierBoth:"Uncertain and approximate",edtfModeTitle:"Type an imprecise date instead: a year alone, a month, a time with no date",locationGroup:"Location",observationGroup:"Observation",weatherWhilePlaying:"Pause the recording to state the weather — while it plays, the instant these would be written at is moving",weatherInferred:"From weather records",weatherInferredTitle:"Weather isn't testimony: it's a measurable fact, on record for the observation's own date, time and place. Uncheck to state the conditions the witness reported, which then override the record.",weatherLookingUp:"Looking up the record…",weatherNeedsDateAndPlace:"A full date and a place are needed to look up the record",weatherNoRecord:"No record for this date and place",weatherLookupFailed:"Weather records temporarily unreachable",instrumentOutOfPeriod:"{name} — not of this date",unitMillimetres:"mm",unitDegrees:"°",soundSrcPlaceholder:"URL of a real recording",skyLine:"Sky: {parts}",skyStarsEye:"stars down to magnitude {limit}, which is as faint as an eye went under this sky",skyStarsDeeper:"stars down to magnitude {limit} through a {device} — {gain} magnitudes past the {eye} the witness's own eyes reached",skyStarsShallower:"stars down to magnitude {limit} through a {device} — {gain} magnitudes short of the {eye} the witness's own eyes reached",skyStarsCatalogue:", drawn to {catalogue}, where this project's catalogue stops",skyStarsNone:"no star could be picked out of a sky this bright",skyDetails:"Show the records in full",skyDetailsHide:"Hide the records",skyShowerActive:"{name} — radiant {altitude}° above the horizon, {bearing} — about {rate}/h under this sky, over a sporadic background of {sporadic}/h",skyShowerBelowHorizon:"{name} is active, but its radiant is below the horizon — it can have produced nothing",skyNothingActive:"no meteor shower active on this date — a sporadic background of about {sporadic}/h",showMeteor:"Show me one",skyComet:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}, tail {tail}° long",skyCometNoTail:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyCometBelowHorizon:"{name} was there at magnitude {magnitude}, but below the horizon — nobody here saw it",skyCometInDaylight:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} — but only {elongation}° from the Sun",showComet:"Show me the comet",skyOpticsPossible:"ice cloud enough, around the {source}, for {forms}",skyOpticsAlignment:" — everything but the rings needs crystals falling level, stated here at {alignment}% since no record holds it",skyOpticsHalo22:"a {angle}° ring",skyOpticsHalo46:"a {angle}° ring",skyOpticsParhelia:"sundogs {angle}° to either side",skyOpticsTangentArc:"an arc tangent on top of it",skyOpticsParhelicCircle:"a white circle right round the sky at its own height",skyOpticsCircumzenithal:"a circumzenithal arc {angle}° up",skyOpticsCircumhorizontal:"a circumhorizontal arc far below it",skyOpticsPillar:"a pillar standing over it",skyOpticsNoIce:"no ice cloud: no halo and no sundogs",skyOpticsHidden:"ice cloud above, but a lower deck between it and the witness",skyOpticsSun:"Sun",skyOpticsMoon:"Moon",skyBowPossible:"rain and sunlight enough for {forms}",skyBowMoon:"rain under a Moon {lit}% lit, enough for {forms} — a moonbow, which the eye sees as a white arc",skyGlowBand:"the Milky Way {contrast}× the sky behind it, {altitude}° up {bearing}",skyGlowCone:"the zodiacal light {contrast}× the sky behind it, {altitude}° up {bearing}, {elongation}° from the Sun — a leaning cone with no edge, gone within the hour",skyGlowZodiacalBand:"the zodiacal band {contrast}× the sky behind it, {altitude}° up {bearing} — the whole ecliptic faintly alight, which is not the sight people report",skyGlowMoon:"no Milky Way and no zodiacal light: a Moon {lit}% lit held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowTwilight:"no Milky Way and no zodiacal light: twilight still held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowNothingUp:"sky dark enough ({sky} magnitudes a square arcsecond) but neither the galactic plane nor the ecliptic stood high enough in it",skyBowPrimary:"a bow {radius}° across, its top {top}° up",skyBowSecondary:"a second, fainter one at {radius}° with its colours reversed",skyBowSourceTooHigh:"rain, but with the source {altitude}° up no bow could clear the horizon: they stand {radius}° from the point opposite it",skyBowHidden:"rain, but an unbroken deck between it and the light: no bow",skyBowNoSource:"rain, and nothing lit to make a bow of it",skySatellitesLit:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month",skySatellitesLitWith:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month, among them {eras}",skySatellitesShadowed:"the Earth's shadow stood {height} km above the witness: of the {count} tracked objects in orbit that month, nothing in low orbit was lit",skySatellitesNotYet:"nothing had been put in orbit yet",skySatellitesDaylight:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skySatellitesDaylightOne:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skyUnknown:"cannot be worked out without a date and a place",lookAtDecor:"Look at it",addDecor:"Add",deleteDecor:"Delete decor",decorSightingUrl:"Their own recording URL",viewTestimony:"View testimony",noWitnessRecording:"No recording URL set for this witness",masks:"Masks",addWitness:"Add witness",narrativePlaceholder:"What the witness reported, in their own words",narrativeKey:"{source} API key",narrativeNeedsKey:"Enter your own {source} API key to generate a reconstruction from the account",narrativeKeyUnlikely:"This does not look like a Claude API key: they begin with sk-ant-",narrativeWorkspace:"Workspace ID",narrativeWorkspacePlaceholder:"only if your key spans several",narrativeWorkspaceHint:"Only for a key whose scope is the whole organisation. Simpler: leave this empty and create a key scoped to one workspace instead.",narrativeNeedsAsk:"Nothing to send yet",narrativeRemember:"Remember on this device",narrativeDraft:"Generate reconstruction",narrativeStop:"Stop",narrativeWorking:"Reading the account…",narrativeApplied:"{count} fields written into the editor",narrativeUnchanged:"The account states nothing the recording can hold yet",narrativeStated:"What the witness said",narrativeDerived:"Worked out from the account",narrativeAssumed:"Guessed, so the reconstruction runs — check these",narrativeGaps:"What nothing could settle",narrativeErrorCredential:"No key, or one that was refused — check it at console.anthropic.com",narrativeErrorRateLimited:"Too many requests on your account: wait a moment and ask again",narrativeErrorRefused:"The account was not answered. Rephrasing may help; asking again will not",narrativeErrorMalformed:"The answer was not a usable draft — worth asking once more",narrativeErrorUnreachable:"Nothing answered: check the connection",narrativeErrorRejected:"Refused: {detail}",witnessAge:"Age then",witnessOccupation:"Occupation",testimonySource:"Account obtained",testimonySourceUnknown:"unknown",testimonySourceOnSite:"on-site investigation",testimonySourceInterview:"interview in person",testimonySourceTelephone:"by telephone",testimonySourceQuestionnaire:"questionnaire",testimonySourceLetter:"the witness wrote it",testimonySourcePress:"press or broadcast",testimonyFollowedUp:"Followed up",testimonyUnknown:"unknown",testimonyYes:"yes",testimonyNo:"no",questionUnanswered:"Nothing in this recording answers one of the questions a reconstruction needs settled",durationRequired:"The observation needs a length to be replayed at all — state one, or an end time, which may be approximate",questionsUnanswered:"{count} of the questions a full reconstruction answers are unanswered here"},NT=Object.freeze(Object.defineProperty({__proto__:null,sightingEditorMessages_en:Gg},Symbol.toStringTag,{value:"Module"})),Z0=new Set;ql();tT();const Ta={width:48,height:28},OT=2500,kT=600,J0=900,Aa=2e-4,UT=900,FT=-1.46,BT=3,j0=.2,zT=.01,HT=1.6,yh=2e3,GT=250,Q0=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),cs=4,cl="ufo-1",em=["oval","polygon"],VT={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5,blur:0,brightness:0};function WT(s){return s.kind==="oval"?"oval":"polygon"}const XT=-6,qT=21;class ut extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;presetsGroup;colorInput;transparencyInput;haloScaleInput;blurInput;brightnessInput;blurBoundOutput;sourceSelect;shapeTitleInput;utcOffsetInput;timeZoneSelect;timeZoneProvider=PT[0].create();timeZoneLookupTimer;timeZoneLookedUpAt;autoFilledTimeZone;timeZones=new CT;objectSizeInput;objectDistanceInput;apparentSizeOutput;realSizeOutput;distanceHypothesisInput;distanceHypothesisValue;clearDistanceHypothesisButton;labelDistanceHypothesis;depthBasisOutput;addShapeButton;deleteShapeButton;contextMenu;contextGroupButton;contextUngroupButton;contextBringToFrontButton;contextSendToBackButton;contextDeleteButton;contextAddVertexButton;contextDeleteVertexButton;decorContextMenu;contextViewTestimonyButton;contextMasksSubmenu;labelContextMasks;playPauseButton;seekInput;timeStartLabel;timeEndLabel;loopButton;durationInput;exportButton;importFileInput;importUrlInput;importUrlButton;narrativeKeyInput;narrativeWorkspaceInput;narrativeRememberInput;narrativeDraftButton;narrativeStopButton;narrativeCreditLink;narrativeStatus;narrativeReport;placeNameInput;searchPlaceButton;placeMatchRow;placeMatchSelect;placeStatusText;placeProvider=TT();placeMatches=[];placeSearchToken=0;placeReverseTimer;namedCoordinates;latInput;lngInput;headingInput;pitchInput;rollInput;elevationInput;groundElevationOutput;weatherFromRecords=!0;groundElevationM;groundElevationFor;groundElevationTimer;groundElevationToken=0;obsTimeInput;obsTimeNativeInput;obsEndTimeNativeInput;obsTimeQualifier;obsEndTimeQualifier;edtfModeButton;edtfMode=!1;obsEndTimeInput;witnessIdInput;witnessDirNameInput;witnessTitleInput;witnessLastNameInput;witnessFirstNamesInput;witnessAgeInput;witnessOccupationInput;testimonySourceSelect;testimonyFollowedUpSelect;caseIdInput;descriptionInput;tagsInput;cloudCoverInput;cloudDarknessInput;cloudBaseInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;stormInput;weatherInferredInput;weatherSourceText;skyCandidatesOutput;showMeteorButton;showCometButton;weatherSourceLink;weatherFields;weatherInference=new mh(_T());weatherLookupTimer;weatherLookupToken=0;weatherLookupPending=!1;weatherLookupResult;weatherTrackSpan;soundKindSelect;soundVolumeInput;soundPitchInput;soundPitchValue;soundSrcInput;soundFields;soundKindOptions=new Map;soundPreviewTimer;instrumentSelect;focalLengthInput;labelFocalLength;unitFocalLength;labelFNumber;labelExposure;labelFocusDistance;fNumberInput;exposureInput;focusDistanceInput;labelColor;labelTransparency;labelHalo;labelBlur;labelBrightness;labelShape;labelShapeTitle;labelUtcOffset;labelObjectSize;labelObjectDistance;labelSamplingRate;labelDuration;placeSourceRow;weatherSourceRow;terrainSourceRows;chosenSourceId=new Map;labelPlaceName;labelPlaceMatch;labelLatitude;labelLongitude;labelHeading;labelPitch;labelRoll;labelElevation;labelObservationTime;labelObservationEndTime;labelWitnessId;labelWitnessDirName;labelWitnessTitle;labelWitnessLastName;labelWitnessFirstNames;labelWitnessAge;labelWitnessOccupation;labelTestimonySource;labelTestimonyFollowedUp;labelCaseId;labelDescription;labelTags;labelImportFile;labelImportUrl;labelNarrativeKey;labelNarrativeWorkspace;labelNarrativeRemember;groupTabs;groupPanels;paramSummary;paramSummaryBuilder;paramSummarySignature="";labelShapeGroup;labelTemporalGroup;labelLocationGroup;labelObservationGroup;labelWitnessGroup;skyDetailsButton;clampedLines;labelWeatherGroup;labelCloudCover;labelHighCloud;labelIceAlignment;highCloudCoverInput;iceCrystalAlignmentInput;labelCloudDarkness;labelCloudBase;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelStorm;labelWeatherInferred;labelSoundGroup;labelSoundKind;labelSoundVolume;labelSoundPitch;labelSoundSrc;labelInstrument;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;decorKindSelect;addDecorWitnessButton;addDecorBuildingButton;deleteDecorButton;decorSelect;decorTitleInput;decorEastInput;decorNorthInput;decorHeadingInput;decorColorInput;decorLitInput;decorLightRigSelect;lookAtDecorButton;decorAltitudeInput;labelDecorAltitude;decorSightingUrlInput;decorModelProvider=bl[0].create();confirmOverlay;confirmMessage;confirmAcceptButton;confirmDeclineButton;confirmAnswer;milestoneSelect;milestoneLabelInput;milestoneNoteInput;addMilestoneButton;deleteMilestoneButton;currentMilestoneT;decorWidthInput;decorLengthInput;decorHeightInput;decorModelSelect;decorModelAdvanced;decorModelUrlInput;decorModelTitleInput;decorModelAuthorInput;decorModelLicenseInput;decorModelSourceInput;decorFloorsInput;decorOccupiedFloorInput;decorWitnessSideSelect;decorWindowInputs;labelDecorSide;optionWitnessSide;labelDecor;labelDecorGroup;labelDecorTitle;labelDecorEast;labelDecorNorth;labelDecorHeading;labelDecorColor;labelDecorLit;labelDecorSightingUrl;labelMilestones;labelMilestoneLabel;labelMilestoneNote;labelDecorWidth;labelDecorLength;labelDecorHeight;labelDecorModel;labelDecorModelAdvanced;labelDecorModelUrl;labelDecorModelTitle;labelDecorModelAuthor;labelDecorModelLicense;labelDecorModelSource;labelDecorFloors;labelDecorOccupiedFloor;labelDecorWitnessSide;labelDecorWindows;optionWitnessSideNone;optionDecorBuilding;optionDecorTree;optionDecorCrop;optionDecorMound;optionDecorStreetlight;optionDecorVehicle;optionDecorAircraft;optionDecorEntity;labelDecorLights;optionDecorWitness;recorder;isRecording=!1;messages=Gg;currentAppearance={...VT};currentSourceId=cl;selectedSourceIds=new Set([cl]);currentDecorId;contextMenuDecorId;contextMenuPoint;dragState;cameraDragState;hoverCursor;indoorLookYawDeg=0;indoorLookPitchDeg=0;lastInhabitedKey;handleKeyDown=e=>{if(e.key==="Escape"&&(this.isRecording&&this.toggleRecording(),this.confirmOverlay.hidden||this.answerConfirm(!1),this.contextMenu.hidden||this.hideContextMenu(),this.decorContextMenu.hidden||this.hideDecorContextMenu()),Q0.has(e.key)||e.key==="Delete"||e.key==="Backspace"){const t=e.composedPath()[0];if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;Q0.has(e.key)?this.moveOrResizeSelectedShapes(e):this.deleteShape()}};handleDragPointerMove=e=>this.onDragPointerMove(e);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${o1}</style>${r1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Yd),this.sceneElement.setAttribute("show-compass",""),this.sceneElement.setAttribute(Ws,""),this.sceneElement.animateWhilePaused=!0,this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.ufoElement.showToolbar=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetsGroup=this.shadow.getElementById("presets-group"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),polygon:this.shadow.getElementById("preset-polygon")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.blurInput=this.shadow.getElementById("blur"),this.brightnessInput=this.shadow.getElementById("brightness"),this.blurBoundOutput=this.shadow.getElementById("blur-bound"),this.sourceSelect=this.shadow.getElementById("source"),this.shapeTitleInput=this.shadow.getElementById("shapeTitle"),this.utcOffsetInput=this.shadow.getElementById("utcOffsetHours"),this.timeZoneSelect=this.shadow.getElementById("timeZone"),this.objectSizeInput=this.shadow.getElementById("objectSize"),this.objectDistanceInput=this.shadow.getElementById("objectDistance"),this.apparentSizeOutput=this.shadow.getElementById("apparent-size"),this.realSizeOutput=this.shadow.getElementById("real-size"),this.distanceHypothesisInput=this.shadow.getElementById("distanceHypothesis"),this.distanceHypothesisValue=this.shadow.getElementById("distance-hypothesis-value"),this.clearDistanceHypothesisButton=this.shadow.getElementById("clear-distance-hypothesis"),this.labelDistanceHypothesis=this.shadow.getElementById("label-distance-hypothesis"),this.depthBasisOutput=this.shadow.getElementById("depth-basis"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.deleteShapeButton=this.shadow.getElementById("delete-shape"),this.contextMenu=this.shadow.getElementById("context-menu"),this.contextGroupButton=this.shadow.getElementById("context-group"),this.contextUngroupButton=this.shadow.getElementById("context-ungroup"),this.contextBringToFrontButton=this.shadow.getElementById("context-bring-to-front"),this.contextSendToBackButton=this.shadow.getElementById("context-send-to-back"),this.contextDeleteButton=this.shadow.getElementById("context-delete"),this.contextAddVertexButton=this.shadow.getElementById("context-add-vertex"),this.contextDeleteVertexButton=this.shadow.getElementById("context-delete-vertex"),this.decorContextMenu=this.shadow.getElementById("decor-context-menu"),this.contextViewTestimonyButton=this.shadow.getElementById("context-view-testimony"),this.contextMasksSubmenu=this.shadow.getElementById("context-masks-submenu"),this.labelContextMasks=this.shadow.getElementById("label-context-masks"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.switchTimeDisplay()),t.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.switchTimeDisplay())});this.loopButton=this.shadow.getElementById("loop"),this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.importFileInput=this.shadow.getElementById("import-file"),this.importUrlInput=this.shadow.getElementById("import-url"),this.importUrlButton=this.shadow.getElementById("import-url-button"),this.narrativeKeyInput=this.shadow.getElementById("narrativeKey"),this.narrativeWorkspaceInput=this.shadow.getElementById("narrativeWorkspace"),this.narrativeRememberInput=this.shadow.getElementById("narrativeRemember"),this.narrativeDraftButton=this.shadow.getElementById("narrative-draft"),this.narrativeStopButton=this.shadow.getElementById("narrative-stop"),this.narrativeCreditLink=this.shadow.getElementById("narrative-credit"),this.narrativeStatus=this.shadow.getElementById("narrative-status"),this.narrativeReport=this.shadow.getElementById("narrative-report"),this.placeNameInput=this.shadow.getElementById("placeName"),this.searchPlaceButton=this.shadow.getElementById("search-place"),this.placeMatchRow=this.shadow.getElementById("place-match-row"),this.placeMatchSelect=this.shadow.getElementById("placeMatch"),this.placeStatusText=this.shadow.getElementById("place-status-text"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.pitchInput=this.shadow.getElementById("pitch"),this.rollInput=this.shadow.getElementById("roll"),this.elevationInput=this.shadow.getElementById("elevation"),this.groundElevationOutput=this.shadow.getElementById("ground-elevation"),this.obsTimeInput=this.shadow.getElementById("obs-time"),this.obsEndTimeInput=this.shadow.getElementById("obs-end-time"),this.obsTimeNativeInput=this.shadow.getElementById("obs-time-native"),this.obsEndTimeNativeInput=this.shadow.getElementById("obs-end-time-native"),this.obsTimeQualifier=this.shadow.getElementById("obs-time-qualifier"),this.obsEndTimeQualifier=this.shadow.getElementById("obs-end-time-qualifier"),this.edtfModeButton=this.shadow.getElementById("edtf-mode"),this.witnessIdInput=this.shadow.getElementById("witnessId"),this.witnessDirNameInput=this.shadow.getElementById("witnessDirName"),this.witnessTitleInput=this.shadow.getElementById("witnessTitle"),this.witnessLastNameInput=this.shadow.getElementById("witnessLastName"),this.witnessFirstNamesInput=this.shadow.getElementById("witnessFirstNames"),this.witnessAgeInput=this.shadow.getElementById("witnessAge"),this.witnessOccupationInput=this.shadow.getElementById("witnessOccupation"),this.testimonySourceSelect=this.shadow.getElementById("testimonySource"),this.testimonyFollowedUpSelect=this.shadow.getElementById("testimonyFollowedUp"),this.caseIdInput=this.shadow.getElementById("caseId"),this.descriptionInput=this.shadow.getElementById("description"),this.tagsInput=this.shadow.getElementById("tags"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.highCloudCoverInput=this.shadow.getElementById("highCloudCover"),this.iceCrystalAlignmentInput=this.shadow.getElementById("iceCrystalAlignment"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.cloudBaseInput=this.shadow.getElementById("cloudBase"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.stormInput=this.shadow.getElementById("storm"),this.weatherInferredInput=this.shadow.getElementById("weatherInferred"),this.weatherSourceText=this.shadow.getElementById("weather-source-text"),this.skyCandidatesOutput=this.shadow.getElementById("sky-candidates"),this.showMeteorButton=this.shadow.getElementById("show-meteor"),this.showCometButton=this.shadow.getElementById("show-comet"),this.weatherSourceLink=this.shadow.getElementById("weather-source-link"),this.weatherFields=[this.cloudCoverInput,this.highCloudCoverInput,this.iceCrystalAlignmentInput,this.cloudDarknessInput,this.cloudBaseInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.stormInput],this.soundKindSelect=this.shadow.getElementById("soundKind"),this.soundVolumeInput=this.shadow.getElementById("soundVolume"),this.soundPitchInput=this.shadow.getElementById("soundPitch"),this.soundPitchValue=this.shadow.getElementById("sound-pitch-value"),this.soundSrcInput=this.shadow.getElementById("soundSrc"),this.soundFields=[this.soundKindSelect,this.soundVolumeInput,this.soundPitchInput,this.soundSrcInput],this.buildSoundKindOptions(),this.instrumentSelect=this.shadow.getElementById("instrument"),this.focalLengthInput=this.shadow.getElementById("focalLength"),this.labelFocalLength=this.shadow.getElementById("label-focal-length"),this.unitFocalLength=this.shadow.getElementById("unit-focal-length"),this.labelFNumber=this.shadow.getElementById("label-f-number"),this.labelExposure=this.shadow.getElementById("label-exposure"),this.fNumberInput=this.shadow.getElementById("fNumber"),this.exposureInput=this.shadow.getElementById("exposureSeconds"),this.focusDistanceInput=this.shadow.getElementById("focusDistance"),this.labelFocusDistance=this.shadow.getElementById("label-focus-distance"),this.refreshInstrumentOptions(),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelBlur=this.shadow.getElementById("label-blur"),this.labelBrightness=this.shadow.getElementById("label-brightness"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelShapeTitle=this.shadow.getElementById("label-shape-title"),this.labelUtcOffset=this.shadow.getElementById("label-utc-offset"),this.labelObjectSize=this.shadow.getElementById("label-object-size"),this.labelObjectDistance=this.shadow.getElementById("label-object-distance"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelSoundGroup=this.shadow.getElementById("label-sound-group"),this.labelSoundKind=this.shadow.getElementById("label-sound-kind"),this.labelSoundVolume=this.shadow.getElementById("label-sound-volume"),this.labelSoundPitch=this.shadow.getElementById("label-sound-pitch"),this.labelSoundSrc=this.shadow.getElementById("label-sound-src"),this.labelDuration=this.shadow.getElementById("label-duration"),this.placeSourceRow=this.shadow.getElementById("place-source-row"),this.weatherSourceRow=this.shadow.getElementById("weather-source-row"),this.terrainSourceRows=this.shadow.getElementById("terrain-source-rows"),this.labelPlaceName=this.shadow.getElementById("label-place-name"),this.labelPlaceMatch=this.shadow.getElementById("label-place-match"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelRoll=this.shadow.getElementById("label-roll"),this.labelElevation=this.shadow.getElementById("label-elevation"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelObservationEndTime=this.shadow.getElementById("label-observation-end-time"),this.labelWitnessId=this.shadow.getElementById("label-witness-id"),this.labelWitnessDirName=this.shadow.getElementById("label-witness-dir-name"),this.labelWitnessTitle=this.shadow.getElementById("label-witness-title"),this.labelWitnessLastName=this.shadow.getElementById("label-witness-last-name"),this.labelWitnessFirstNames=this.shadow.getElementById("label-witness-first-names"),this.labelWitnessAge=this.shadow.getElementById("label-witness-age"),this.labelWitnessOccupation=this.shadow.getElementById("label-witness-occupation"),this.labelTestimonySource=this.shadow.getElementById("label-testimony-source"),this.labelTestimonyFollowedUp=this.shadow.getElementById("label-testimony-followed-up"),this.labelCaseId=this.shadow.getElementById("label-case-id"),this.labelDescription=this.shadow.getElementById("label-description"),this.labelTags=this.shadow.getElementById("label-tags"),this.labelImportFile=this.shadow.getElementById("label-import-file"),this.labelImportUrl=this.shadow.getElementById("label-import-url"),this.labelNarrativeKey=this.shadow.getElementById("label-narrative-key"),this.labelNarrativeWorkspace=this.shadow.getElementById("label-narrative-workspace"),this.labelNarrativeRemember=this.shadow.getElementById("label-narrative-remember"),this.labelShapeGroup=this.shadow.getElementById("label-shape-group"),this.labelTemporalGroup=this.shadow.getElementById("label-temporal-group"),this.labelLocationGroup=this.shadow.getElementById("label-location-group"),this.labelObservationGroup=this.shadow.getElementById("label-observation-group"),this.labelWitnessGroup=this.shadow.getElementById("label-witness-group"),this.labelWeatherGroup=this.shadow.getElementById("label-weather-group"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelHighCloud=this.shadow.getElementById("label-high-cloud"),this.labelIceAlignment=this.shadow.getElementById("label-ice-alignment"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelCloudBase=this.shadow.getElementById("label-cloud-base"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelStorm=this.shadow.getElementById("label-storm"),this.labelWeatherInferred=this.shadow.getElementById("label-weather-inferred"),this.labelInstrument=this.shadow.getElementById("label-instrument"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.decorKindSelect=this.shadow.getElementById("decorKind"),this.addDecorWitnessButton=this.shadow.getElementById("add-decor-witness"),this.addDecorBuildingButton=this.shadow.getElementById("add-decor-building"),this.deleteDecorButton=this.shadow.getElementById("delete-decor"),this.decorSelect=this.shadow.getElementById("decor"),this.decorTitleInput=this.shadow.getElementById("decorTitle"),this.decorEastInput=this.shadow.getElementById("decorEast"),this.decorNorthInput=this.shadow.getElementById("decorNorth"),this.decorHeadingInput=this.shadow.getElementById("decorHeading"),this.decorColorInput=this.shadow.getElementById("decorColor"),this.decorLitInput=this.shadow.getElementById("decorLit"),this.decorLightRigSelect=this.shadow.getElementById("decorLightRig"),this.lookAtDecorButton=this.shadow.getElementById("look-at-decor"),this.decorAltitudeInput=this.shadow.getElementById("decorAltitude"),this.labelDecorAltitude=this.shadow.getElementById("label-decor-altitude"),this.decorSightingUrlInput=this.shadow.getElementById("decorSightingUrl"),this.confirmOverlay=this.shadow.getElementById("confirm-overlay"),this.confirmMessage=this.shadow.getElementById("confirm-message"),this.confirmAcceptButton=this.shadow.getElementById("confirm-ok"),this.confirmDeclineButton=this.shadow.getElementById("confirm-cancel"),this.milestoneSelect=this.shadow.getElementById("milestone"),this.milestoneLabelInput=this.shadow.getElementById("milestoneLabel"),this.milestoneNoteInput=this.shadow.getElementById("milestoneNote"),this.addMilestoneButton=this.shadow.getElementById("add-milestone"),this.deleteMilestoneButton=this.shadow.getElementById("delete-milestone"),this.decorWidthInput=this.shadow.getElementById("decorWidth"),this.decorLengthInput=this.shadow.getElementById("decorLength"),this.decorHeightInput=this.shadow.getElementById("decorHeight"),this.decorModelSelect=this.shadow.getElementById("decorModel"),this.decorModelAdvanced=this.shadow.getElementById("decor-model-advanced"),this.decorModelUrlInput=this.shadow.getElementById("decorModelUrl"),this.decorModelTitleInput=this.shadow.getElementById("decorModelTitle"),this.decorModelAuthorInput=this.shadow.getElementById("decorModelAuthor"),this.decorModelLicenseInput=this.shadow.getElementById("decorModelLicense"),this.decorModelSourceInput=this.shadow.getElementById("decorModelSource"),this.decorFloorsInput=this.shadow.getElementById("decorFloors"),this.decorOccupiedFloorInput=this.shadow.getElementById("decorOccupiedFloor"),this.decorWitnessSideSelect=this.shadow.getElementById("decorWitnessSide"),this.decorWindowInputs={front:this.shadow.getElementById("decorWindowFront"),behind:this.shadow.getElementById("decorWindowBehind"),left:this.shadow.getElementById("decorWindowLeft"),right:this.shadow.getElementById("decorWindowRight"),"front-left":this.shadow.getElementById("decorWindowFrontLeft"),"front-right":this.shadow.getElementById("decorWindowFrontRight"),"behind-left":this.shadow.getElementById("decorWindowBehindLeft"),"behind-right":this.shadow.getElementById("decorWindowBehindRight")},this.labelDecorSide={front:this.shadow.getElementById("label-decor-window-front"),behind:this.shadow.getElementById("label-decor-window-behind"),left:this.shadow.getElementById("label-decor-window-left"),right:this.shadow.getElementById("label-decor-window-right"),"front-left":this.shadow.getElementById("label-decor-window-front-left"),"front-right":this.shadow.getElementById("label-decor-window-front-right"),"behind-left":this.shadow.getElementById("label-decor-window-behind-left"),"behind-right":this.shadow.getElementById("label-decor-window-behind-right")},this.optionWitnessSide={front:this.shadow.getElementById("option-witness-side-front"),behind:this.shadow.getElementById("option-witness-side-behind"),left:this.shadow.getElementById("option-witness-side-left"),right:this.shadow.getElementById("option-witness-side-right"),"front-left":this.shadow.getElementById("option-witness-side-front-left"),"front-right":this.shadow.getElementById("option-witness-side-front-right"),"behind-left":this.shadow.getElementById("option-witness-side-behind-left"),"behind-right":this.shadow.getElementById("option-witness-side-behind-right")},this.optionWitnessSideNone=this.shadow.getElementById("option-witness-side-none"),this.labelDecor=this.shadow.getElementById("label-decor"),this.labelDecorGroup=this.shadow.getElementById("label-decor-group"),this.labelDecorTitle=this.shadow.getElementById("label-decor-title"),this.labelDecorEast=this.shadow.getElementById("label-decor-east"),this.labelDecorNorth=this.shadow.getElementById("label-decor-north"),this.labelDecorHeading=this.shadow.getElementById("label-decor-heading"),this.labelDecorColor=this.shadow.getElementById("label-decor-color"),this.labelDecorLit=this.shadow.getElementById("label-decor-lit"),this.labelDecorSightingUrl=this.shadow.getElementById("label-decor-sighting-url"),this.labelMilestones=this.shadow.getElementById("label-milestones"),this.labelMilestoneLabel=this.shadow.getElementById("label-milestone-label"),this.labelMilestoneNote=this.shadow.getElementById("label-milestone-note"),this.labelDecorWidth=this.shadow.getElementById("label-decor-width"),this.labelDecorLength=this.shadow.getElementById("label-decor-length"),this.labelDecorHeight=this.shadow.getElementById("label-decor-height"),this.labelDecorModel=this.shadow.getElementById("label-decor-model"),this.labelDecorModelAdvanced=this.shadow.getElementById("label-decor-model-advanced"),this.labelDecorModelUrl=this.shadow.getElementById("label-decor-model-url"),this.labelDecorModelTitle=this.shadow.getElementById("label-decor-model-title"),this.labelDecorModelAuthor=this.shadow.getElementById("label-decor-model-author"),this.labelDecorModelLicense=this.shadow.getElementById("label-decor-model-license"),this.labelDecorModelSource=this.shadow.getElementById("label-decor-model-source"),this.labelDecorFloors=this.shadow.getElementById("label-decor-floors"),this.labelDecorOccupiedFloor=this.shadow.getElementById("label-decor-occupied-floor"),this.labelDecorWitnessSide=this.shadow.getElementById("label-decor-witness-side"),this.labelDecorWindows=this.shadow.getElementById("label-decor-windows"),this.optionDecorBuilding=this.shadow.getElementById("option-decor-building"),this.optionDecorTree=this.shadow.getElementById("option-decor-tree"),this.optionDecorCrop=this.shadow.getElementById("option-decor-crop"),this.optionDecorMound=this.shadow.getElementById("option-decor-mound"),this.optionDecorStreetlight=this.shadow.getElementById("option-decor-streetlight"),this.optionDecorVehicle=this.shadow.getElementById("option-decor-vehicle"),this.optionDecorAircraft=this.shadow.getElementById("option-decor-aircraft"),this.optionDecorEntity=this.shadow.getElementById("option-decor-entity"),this.labelDecorLights=this.shadow.getElementById("label-decor-lights"),this.optionDecorWitness=this.shadow.getElementById("option-decor-witness"),this.ufoElement.canvasElement.addEventListener("pointerdown",t=>{this.focus({preventScroll:!0}),this.onPointerDown(t)}),this.ufoElement.canvasElement.addEventListener("pointermove",t=>this.onPointerMove(t)),this.ufoElement.canvasElement.addEventListener("contextmenu",t=>this.onContextMenu(t)),this.contextGroupButton.addEventListener("click",()=>this.groupSelected()),this.contextUngroupButton.addEventListener("click",()=>this.ungroupSelected()),this.contextBringToFrontButton.addEventListener("click",()=>this.bringSelectedToFront()),this.contextSendToBackButton.addEventListener("click",()=>this.sendSelectedToBack()),this.contextDeleteButton.addEventListener("click",()=>{this.hideContextMenu(),this.deleteShape()}),this.contextAddVertexButton.addEventListener("click",()=>this.addVertexAtContextMenu()),this.contextDeleteVertexButton.addEventListener("click",()=>this.deleteVertexAtContextMenu()),this.contextViewTestimonyButton.addEventListener("click",()=>this.viewWitnessTestimony()),this.playPauseButton.addEventListener("click",()=>{this.ufoElement.togglePlayPause(),this.syncPlaybackControls()}),this.loopButton.addEventListener("click",()=>{this.ufoElement.toggleLoop(),this.syncPlaybackControls()}),this.seekInput.addEventListener("input",()=>this.ufoElement.currentTime=Number(this.seekInput.value)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.deleteShapeButton.addEventListener("click",()=>this.deleteShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.importFileInput.addEventListener("change",()=>this.importFromFile()),this.importUrlButton.addEventListener("click",()=>this.importFromUrl()),this.testimonySourceSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.testimonyFollowedUpSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.narrativeDraftButton.addEventListener("click",()=>this.draftFromDescription()),this.narrativeStopButton.addEventListener("click",()=>this.narrativeAbort?.abort()),this.narrativeRememberInput.addEventListener("change",()=>this.rememberNarrativeKey()),this.narrativeWorkspaceInput.addEventListener("input",()=>this.rememberNarrativeKey()),this.narrativeKeyInput.addEventListener("input",()=>{this.rememberNarrativeKey(),this.syncNarrativeEnabled()}),this.narrativeCreditLink.textContent=`${ws[0].name} — ${ws[0].credit}`,this.narrativeCreditLink.href=ws[0].creditUrl,this.labelNarrativeKey.textContent=this.messages.narrativeKey.replace("{source}",ws[0].name),this.narrativeWorkspaceInput.title=this.messages.narrativeWorkspaceHint,this.restoreNarrativeKey(),this.syncNarrativeEnabled(),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh(),this.updateDurationValidity(),this.scheduleWeatherLookup()}),this.sourceSelect.addEventListener("change",()=>this.selectUnit(this.sourceSelect.value)),this.shapeTitleInput.addEventListener("input",()=>this.updateShapeTitle());for(const t of[this.objectSizeInput,this.objectDistanceInput])t.addEventListener("input",()=>this.applySizeHypothesis());this.distanceHypothesisInput.addEventListener("input",()=>this.applyDistanceHypothesis()),this.clearDistanceHypothesisButton.addEventListener("click",()=>this.clearDistanceHypothesis()),this.addDecorWitnessButton.addEventListener("click",()=>this.addDecor("witness")),this.addDecorBuildingButton.addEventListener("click",()=>this.addDecor()),this.deleteDecorButton.addEventListener("click",()=>this.deleteDecor()),this.decorSelect.addEventListener("change",()=>this.selectDecor(this.decorSelect.value));for(const t of[this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorAltitudeInput,this.decorHeadingInput,this.decorColorInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput])t.addEventListener("input",()=>this.updateDecor());this.decorWitnessSideSelect.addEventListener("change",()=>this.updateDecor()),this.decorModelSelect.addEventListener("change",()=>this.updateDecorModelChoice()),this.addMilestoneButton.addEventListener("click",()=>this.addMilestone()),this.deleteMilestoneButton.addEventListener("click",()=>this.deleteMilestone()),this.milestoneSelect.addEventListener("change",()=>this.selectMilestone(Number(this.milestoneSelect.value)));for(const t of[this.milestoneLabelInput,this.milestoneNoteInput])t.addEventListener("input",()=>this.updateMilestone());this.confirmAcceptButton.addEventListener("click",()=>this.answerConfirm(!0)),this.confirmDeclineButton.addEventListener("click",()=>this.answerConfirm(!1)),this.confirmOverlay.addEventListener("click",t=>{t.target===this.confirmOverlay&&this.answerConfirm(!1)});for(const t of Qs)this.decorWindowInputs[t].addEventListener("input",()=>this.updateDecorWindows());this.decorLitInput.addEventListener("input",()=>this.updateDecorLit()),this.decorLightRigSelect.addEventListener("change",()=>this.updateDecorLightRig()),this.lookAtDecorButton.addEventListener("click",()=>this.lookAtDecor()),this.showMeteorButton.addEventListener("click",()=>this.showNextMeteor()),this.showCometButton.addEventListener("click",()=>this.lookAtComet()),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.syncPlaybackControls(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.addEventListener("keydown",this.handleKeyDown);for(const t of em)this.presetButtons[t].addEventListener("click",()=>this.setAppearance({presetId:t}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.brightnessInput.addEventListener("input",()=>this.setAppearance({brightness:Number(this.brightnessInput.value)})),this.blurInput.addEventListener("input",()=>{this.setAppearance({blur:Number(this.blurInput.value)}),this.refreshBlurDistanceBound()}),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const t of[this.latInput,this.lngInput,this.headingInput,this.pitchInput,this.rollInput,this.elevationInput])t.addEventListener("input",()=>this.updateObserver());for(const t of[this.focalLengthInput,this.fNumberInput,this.exposureInput,this.focusDistanceInput])t.addEventListener("input",()=>this.updateObserver());this.searchPlaceButton.addEventListener("click",()=>void this.searchPlace()),this.placeNameInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.searchPlace())}),this.placeMatchSelect.addEventListener("change",()=>this.applyPlaceMatch(this.placeMatchSelect.selectedIndex)),this.placeNameInput.addEventListener("input",()=>this.updatePlaceName()),this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1)),this.instrumentSelect.addEventListener("change",()=>{const t=this.ufoElement.sighting.instrument;this.ufoElement.sighting.instrumentId=this.instrumentSelect.value;const n=new Map(this.ufoElement.sighting.timeline.allKeyframes.map(i=>[i.t,on.fovOf(this.ufoElement.sighting,i.t)]));this.retuneFieldOfView(t),this.retuneExposure(t),on.reproject(this.ufoElement.sighting,t,n),this.sceneElement.applyFrameFormat(),this.syncOpticsFromInstrument(),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.utcOffsetInput.addEventListener("input",()=>this.updateUtcOffset()),this.timeZoneSelect.addEventListener("change",()=>{this.autoFilledTimeZone=void 0,this.updateTimeZone()}),this.obsTimeInput.addEventListener("input",()=>this.updateObservationTime()),this.obsEndTimeInput.addEventListener("input",()=>this.updateObservationEndTime()),this.obsTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.obsTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.edtfModeButton.addEventListener("click",()=>this.setEdtfMode(!this.edtfMode)),this.obsTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsTimeInput)),this.obsEndTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsEndTimeInput));for(const t of[this.witnessIdInput,this.witnessDirNameInput,this.witnessTitleInput,this.witnessLastNameInput,this.witnessFirstNamesInput,this.witnessAgeInput,this.witnessOccupationInput,this.caseIdInput])t.addEventListener("input",()=>this.updateWitnessMetadata());this.descriptionInput.addEventListener("input",()=>{this.updateDescription(),this.syncNarrativeEnabled()}),this.tagsInput.addEventListener("input",()=>this.updateTags());for(const t of this.weatherFields){if(t===this.iceCrystalAlignmentInput){t.addEventListener("input",()=>this.applyIceAlignmentAtPlayhead());continue}t.addEventListener("input",()=>this.applyWeatherAtPlayhead())}for(const t of this.soundFields)t.addEventListener("input",()=>this.applySoundAtPlayhead());this.weatherInferredInput.addEventListener("change",()=>this.onWeatherInferredToggled()),this.skyDetailsButton=this.shadow.getElementById("sky-details"),this.clampedLines=[this.shadow.getElementById("weather-source"),this.shadow.getElementById("sky-candidates")],this.skyDetailsButton.addEventListener("click",()=>this.toggleSkyDetails()),this.groupTabs=[...this.shadow.querySelectorAll(".group-tab")],this.groupPanels=this.groupTabs.map(t=>this.shadow.getElementById(t.getAttribute("aria-controls")));for(const t of this.groupTabs)t.addEventListener("click",()=>this.toggleGroup(t,!this.isGroupOpen(t)));this.paramSummary=this.shadow.getElementById("param-summary"),this.paramSummaryBuilder=new tf(this.messages,this.showerLanguage(),this.said,this.tagNames),this.paramSummary.addEventListener("click",t=>this.onParamSummaryClick(t)),this.toggleGroup(this.groupTabs[this.groupTabs.length-1],!0),this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncPlaybackControls(),this.refreshSourceRows(),this.refreshTimeQualifierOptions(),this.refreshTimeZoneOptions(),this.syncWeatherSourceState(),this.loadLocaleMessages()}static get observedAttributes(){return["src"]}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=-1);const e=this.getAttribute("src");e&&this.importFromUrl(e)}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.importFromUrl(n)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideContextMenuClick),this.endDrag()}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.endDrag(),this.ufoElement.sightingData=e,this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??cl,this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncObservationTimeFields(),this.syncObservationEndTimeFields(),this.chooseTimeInputMode(),this.syncWitnessMetadataFields(),this.refreshTimeZoneOptions(),this.utcOffsetInput.readOnly=this.ufoElement.sighting.event.timeZone!==void 0,this.syncUtcOffsetField(),this.syncPlaceNameField(),this.syncGroundElevationField(),this.syncWeatherOwnership()}exportJson(){const e=this.sightingData,t=`${e.witness?.id??"sighting"}-sighting.json`,n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),i=URL.createObjectURL(n),a=document.createElement("a");a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}async importFromFile(){const e=this.importFileInput.files?.[0];if(e)try{const t=await new Promise((n,i)=>{const a=new FileReader;a.onload=()=>n(a.result),a.onerror=()=>i(a.error),a.readAsText(e)});this.sightingData=JSON.parse(t)}catch{window.alert(this.messages.importError)}finally{this.importFileInput.value=""}}async importFromUrl(e=this.importUrlInput.value.trim()){if(e)try{this.sightingData=await Kd.json(e)}catch(t){window.alert(this.importErrorFor(t))}}importErrorFor(e){if(!(e instanceof Cs))return this.messages.importError;switch(e.kind){case"cors":return this.messages.importErrorCors;case"mixed-content":return this.messages.importErrorMixedContent;case"unreachable":return this.messages.importErrorUnreachable;case"status":return this.messages.importErrorStatus.replace("{status}",String(e.status??""));case"malformed":return this.messages.importErrorMalformed;default:return this.messages.importError}}static NARRATIVE_KEY_STORAGE="rr0-sighting-editor.narrative-key";static NARRATIVE_SCOPE_STORAGE="rr0-sighting-editor.narrative-workspace";narrativeProvider=ws[0].create();narrativeAbort;async draftFromDescription(){const e=this.descriptionInput.value.trim();if(e===""||this.narrativeAbort)return;const t=this.narrativeAbort=new AbortController;this.setNarrativeBusy(!0);try{const n=await this.narrativeProvider.draft({ask:e,current:this.sightingData,language:this.showerLanguage()==="fr"?"French":"English",credential:this.narrativeKeyInput.value.trim()||void 0,credentialScope:this.narrativeWorkspaceInput.value.trim()||void 0},t.signal);this.applyNarrativeDraft(n)}catch(n){const i=n instanceof Cn&&n.kind==="cancelled";this.narrativeStatus.textContent=i?"":this.narrativeErrorFor(n),this.narrativeStatus.classList.toggle("error",!i)}finally{this.narrativeAbort=void 0,this.setNarrativeBusy(!1)}}applyNarrativeDraft(e){const{description:t,...n}=e.recording,{utcOffsetHours:i,...a}=n,r=n.timeZone?a:n,o=pi.stated(r);if(o.length>0){const l=this.ufoElement.sighting.provenance,c=Ih(this.ufoElement.sighting);this.sightingData=pi.apply(c,Sl.loadable(r),o),this.ufoElement.sighting.provenance=l,this.recordNarrativeProvenance(e,o),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset()}this.narrativeStatus.textContent=o.length>0?this.messages.narrativeApplied.replace("{count}",String(o.length)):this.messages.narrativeUnchanged,this.narrativeStatus.classList.remove("error"),this.showNarrativeReport(e),this.syncNarrativeEnabled()}recordNarrativeProvenance(e,t){const n=this.ufoElement.sighting,i=new Set(t);for(const a of e.claims)!i.has(a.path)&&!t.some(r=>a.path.startsWith(`${r}.`))||n.provenance.set(a.path,{basis:a.basis,rationale:a.rationale,of:ut.valueAt(Ih(this.ufoElement.sighting),a.path)})}static valueAt(e,t){let n=e;for(const i of t.split(".")){if(typeof n!="object"||n===null)return;n=n[i]}return n}showNarrativeReport(e){this.narrativeReport.replaceChildren();for(const t of["assumed","derived","stated"]){const n=e.claims.filter(i=>i.basis===t);if(n.length!==0){this.narrativeReport.append(this.narrativeHeading(this.messages[YT[t]]));for(const i of n){const a=document.createElement("div");a.className=`claim ${t}`;const r=document.createElement("code");r.textContent=i.path;const o=document.createElement(t==="stated"?"q":"span");o.textContent=i.rationale,a.append(r,o),this.narrativeReport.append(a)}}}if(e.gaps.length>0){this.narrativeReport.append(this.narrativeHeading(this.messages.narrativeGaps));const t=document.createElement("ul");t.className="gaps";for(const n of e.gaps){const i=document.createElement("li");i.textContent=n,t.append(i)}this.narrativeReport.append(t)}this.narrativeReport.hidden=this.narrativeReport.childElementCount===0}narrativeHeading(e){const t=document.createElement("h4");return t.textContent=e,t}setNarrativeBusy(e){this.descriptionInput.disabled=e,this.narrativeStopButton.hidden=!e,e&&(this.narrativeStatus.textContent=this.messages.narrativeWorking,this.narrativeStatus.classList.remove("error")),this.syncNarrativeEnabled()}syncNarrativeEnabled(){const e=ws[0].name,t=this.narrativeProvider.needsCredential&&this.narrativeKeyInput.value.trim()==="",n=this.descriptionInput.value.trim()==="";this.narrativeDraftButton.disabled=!!this.narrativeAbort||t||n,this.narrativeDraftButton.title=t?this.messages.narrativeNeedsKey.replace("{source}",e):n?this.messages.narrativeNeedsAsk:"",this.narrativeKeyInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeRememberInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeWorkspaceInput.parentElement.hidden=!this.narrativeProvider.acceptsCredentialScope;const i=this.narrativeKeyInput.value.trim(),a=i!==""&&!i.startsWith("sk-ant-");this.narrativeKeyInput.classList.toggle("invalid",a),this.narrativeKeyInput.title=a?this.messages.narrativeKeyUnlikely:""}narrativeErrorFor(e){if(!(e instanceof Cn))return this.messages.narrativeErrorMalformed;switch(e.kind){case"rejected":return this.messages.narrativeErrorRejected.replace("{detail}",e.detail??"");case"credential":return this.messages.narrativeErrorCredential;case"rate-limited":return this.messages.narrativeErrorRateLimited;case"refused":return this.messages.narrativeErrorRefused;case"unreachable":return this.messages.narrativeErrorUnreachable;default:return this.messages.narrativeErrorMalformed}}rememberNarrativeKey(){try{this.narrativeRememberInput.checked?(localStorage.setItem(ut.NARRATIVE_KEY_STORAGE,this.narrativeKeyInput.value),localStorage.setItem(ut.NARRATIVE_SCOPE_STORAGE,this.narrativeWorkspaceInput.value)):(localStorage.removeItem(ut.NARRATIVE_KEY_STORAGE),localStorage.removeItem(ut.NARRATIVE_SCOPE_STORAGE))}catch{}}restoreNarrativeKey(){let e=null;try{e=localStorage.getItem(ut.NARRATIVE_KEY_STORAGE)}catch{return}e!==null&&(this.narrativeKeyInput.value=e,this.narrativeWorkspaceInput.value=localStorage.getItem(ut.NARRATIVE_SCOPE_STORAGE)??"",this.narrativeRememberInput.checked=!0)}numberOrUndefined(e){return e===""?void 0:Number(e)}stringOrUndefined(e){return e===""?void 0:e}wrapDegrees(e,t){if(e===void 0)return;const n=(e%360+360)%360;return String(n)!==t.value&&(t.value=String(n)),n}refreshSourceRows(){this.placeSourceRow.replaceChildren(document.createTextNode(`${this.messages.according} `),this.sourcePicker("place",AT,e=>{this.placeProvider=e.create()})),this.weatherSourceRow.replaceChildren(this.sourcePicker("weather",IT,e=>{this.weatherInference=new mh(e.create()),this.scheduleWeatherLookup()})),this.terrainSourceRows.replaceChildren(this.labelledPicker("elevation",this.messages.sourceElevation,vh,()=>this.applyTerrainSources()),this.labelledPicker("imagery",this.messages.sourceImagery,$0,()=>this.applyTerrainSources()),this.labelledPicker("decor-model",this.messages.decorModel,bl,()=>this.applyDecorModelSource()))}sourcePicker(e,t,n){const i=document.createDocumentFragment(),a=document.createElement("select");a.id=`${e}Source`;for(const l of t){const c=document.createElement("option");c.value=l.id,c.textContent=l.name,c.title=l.credit,a.appendChild(c)}a.value=this.chosenSourceId.get(e)??t[0].id;const r=document.createElement("a");r.className="source-credit",r.target="_blank",r.rel="noopener noreferrer";const o=()=>{const l=Ea(t,a.value);a.title=l.credit,r.href=l.creditUrl,r.textContent=l.credit};return o(),a.addEventListener("change",()=>{this.chosenSourceId.set(e,a.value),o(),n(Ea(t,a.value))}),i.append(a,document.createTextNode(" "),r),i}labelledPicker(e,t,n,i){const a=document.createElement("label"),r=document.createElement("span");return r.textContent=t,a.append(r,this.sourcePicker(e,n,i)),a}applyTerrainSources(){this.sceneElement.setTerrainProviders({elevation:Ea(vh,this.chosenSourceId.get("elevation")).create(),imagery:Ea($0,this.chosenSourceId.get("imagery")).create()}),this.ufoElement.refresh()}applyDecorModelSource(){this.decorModelProvider=Ea(bl,this.chosenSourceId.get("decor-model")).create(),this.sceneElement.setDecorModelProvider(this.decorModelProvider),this.refreshDecorModelOptions(),this.ufoElement.refresh()}get placeSearchLanguage(){return navigator.languages?.[0]}set placeSearchProvider(e){this.placeProvider=e}async searchPlace(){const e=this.placeNameInput.value.trim();if(e==="")return;const t=++this.placeSearchToken;this.placeStatusText.textContent=this.messages.placeSearching;let n;try{n=await this.placeProvider.search(e,{language:this.placeSearchLanguage})}catch{if(t!==this.placeSearchToken)return;this.placeStatusText.textContent=this.messages.placeSearchFailed;return}t===this.placeSearchToken&&(this.placeMatches=n,this.refreshPlaceMatches(),n.length>0&&this.applyPlaceMatch(0))}refreshPlaceMatches(){this.placeMatchSelect.replaceChildren(...this.placeMatches.map(t=>{const n=document.createElement("option");return n.textContent=t.name,n.title=t.name,n})),this.placeMatchRow.hidden=this.placeMatches.length===0;const e=this.placeMatches.length===1?this.messages.placeMatchFound:this.messages.placeMatchesFound;this.placeStatusText.textContent=this.placeMatches.length===0?this.messages.placeNotFound:`${this.placeMatches.length} ${e} `,this.placeSourceRow.hidden=this.placeMatches.length===0}applyPlaceMatch(e){const t=this.placeMatches[e];t&&(this.placeMatchSelect.selectedIndex=e,this.placeNameInput.value=t.name,this.placeNameInput.title=t.name,this.latInput.value=String(t.lat),this.lngInput.value=String(t.lng),this.namedCoordinates={lat:t.lat,lng:t.lng},this.updateObserver())}updatePlaceName(){this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent="",this.placeSourceRow.hidden=!0,this.placeNameInput.title=this.placeNameInput.value,this.namedCoordinates=void 0,this.updateObserver()}schedulePlaceReverse(){if(!this.namedCoordinates)return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||Math.abs(e-this.namedCoordinates.lat)<Aa&&Math.abs(t-this.namedCoordinates.lng)<Aa||(clearTimeout(this.placeReverseTimer),this.placeReverseTimer=setTimeout(()=>void this.reversePlace(e,t),J0))}scheduleTimeZoneLookup(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);if(e===void 0||t===void 0)return;const n=this.ufoElement.sighting.event.timeZone;if(n&&n!==this.autoFilledTimeZone)return;const i=this.timeZoneLookedUpAt;i&&Math.abs(e-i.lat)<Aa&&Math.abs(t-i.lng)<Aa||(clearTimeout(this.timeZoneLookupTimer),this.timeZoneLookupTimer=setTimeout(()=>void this.lookUpTimeZone(e,t),J0))}async lookUpTimeZone(e,t){this.timeZoneLookedUpAt={lat:e,lng:t};const n=await this.timeZoneProvider.zoneAt(e,t),i=this.ufoElement.sighting.event.timeZone;!n||i&&i!==this.autoFilledTimeZone||this.timeZones.available().includes(n)&&(this.autoFilledTimeZone=n,this.timeZoneSelect.value=n,this.updateTimeZone(),this.dispatchEvent(new CustomEvent("sightingchange")))}async reversePlace(e,t){const n=++this.placeSearchToken;let i;try{i=await this.placeProvider.reverse(e,t,{language:this.placeSearchLanguage})}catch{return}n===this.placeSearchToken&&(this.namedCoordinates={lat:e,lng:t},this.placeNameInput.value=i?.name??"",this.placeNameInput.title=i?.name??"",this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=i?"":this.messages.placeNotFound,this.placeSourceRow.hidden=!i,this.updateObserver())}updateObserver(){if(this.ufoElement.playbackState==="playing")return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value),n=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),i=this.numberOrUndefined(this.pitchInput.value)??0,a=this.numberOrUndefined(this.rollInput.value)??0,r=this.numberOrUndefined(this.elevationInput.value)??this.groundElevationM??0,o=Math.max(0,r-(this.groundElevationM??0)),l=this.ufoElement.sighting.event,c=this.ufoElement.sighting.witnessTrack,h=this.ufoElement.currentTime,d=this.stringOrUndefined(this.placeNameInput.value.trim());l.place=e!==void 0&&t!==void 0?[{lat:e,lng:t,name:d}]:void 0;const u=this.ufoElement.sighting.instrument,f=this.numberOrUndefined(this.focalLengthInput.value),g=(u.frame&&f!==void 0?it.fieldOfViewDegAt(u,f):f)??this.currentFovDeg(),v=this.numberOrUndefined(this.fNumberInput.value),p=this.statedExposureSeconds(u);this.ufoElement.sighting.exposureSeconds=p===u.exposureSeconds?void 0:p;const m=this.numberOrUndefined(this.focusDistanceInput.value),S=Math.abs(g-it.fieldOfViewDeg(u))>.01||v!==u.fNumber||m!==void 0;e===void 0&&t===void 0&&n===void 0&&i===0&&a===0&&o===0&&!S?c.removeKeyframeAt(h):c.addKeyframe(h,{lat:e,lng:t,elevationM:o,headingDeg:n,pitchDeg:i,rollDeg:a===0?void 0:a,fovDeg:g,fNumber:v,focusDistanceM:m}),this.ufoElement.refresh(),this.scheduleWeatherLookup(),this.schedulePlaceReverse(),this.scheduleTimeZoneLookup(),this.scheduleGroundElevation(),this.updateUtcOffsetValidity()}applyEdtfTimeInput(e,t){const n=e.value.trim();if(n==="")t(void 0);else{const i=Zu(n);if(!i)return;t(i)}e.setCustomValidity(""),e.classList.remove("invalid"),this.dropDurationOutrankedByDates(),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset(),this.ufoElement.refresh(),this.syncDurationField(),this.scheduleWeatherLookup()}dropDurationOutrankedByDates(){const e=this.ufoElement.sighting.event;e.durationSeconds!==void 0&&Ka({...e,durationSeconds:void 0})!==void 0&&(this.ufoElement.durationSeconds=void 0)}validateEdtfTimeInput(e){const t=e.value.trim();t===""||Zu(t)||(e.setCustomValidity(this.messages.edtfInvalid),e.classList.add("invalid"))}refreshTimeZoneOptions(){const e=document.createElement("option");e.value="",e.textContent=this.messages.timeZoneManual,this.timeZoneSelect.replaceChildren(e,...this.timeZones.available().map(t=>{const n=document.createElement("option");return n.value=t,n.textContent=t,n})),this.timeZoneSelect.value=this.ufoElement.sighting.event.timeZone??""}updateTimeZone(){const e=this.stringOrUndefined(this.timeZoneSelect.value);this.ufoElement.sighting.event.timeZone=e,this.applyTimeZoneOffset()}applyTimeZoneOffset(){const e=this.ufoElement.sighting.event,t=e.timeZone&&e.time?this.timeZones.offsetHoursAt(e.timeZone,e.time):void 0;t!==void 0&&(e.utcOffsetHours=t),this.utcOffsetInput.readOnly=e.timeZone!==void 0,this.syncUtcOffsetField(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateUtcOffset(){this.ufoElement.sighting.event.utcOffsetHours=this.numberOrUndefined(this.utcOffsetInput.value),this.updateUtcOffsetValidity(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateObservationTime(){this.applyEdtfTimeInput(this.obsTimeInput,e=>{this.ufoElement.sighting.event.time=e})}updateObservationEndTime(){this.applyEdtfTimeInput(this.obsEndTimeInput,e=>{this.ufoElement.sighting.event.endTime=e})}updateWitnessMetadata(){const e=this.ufoElement.sighting,t=this.witnessFirstNamesInput.value.split(",").map(i=>i.trim()).filter(i=>i.length>0),n={id:this.stringOrUndefined(this.witnessIdInput.value),dirName:this.stringOrUndefined(this.witnessDirNameInput.value),title:this.stringOrUndefined(this.witnessTitleInput.value),lastName:this.stringOrUndefined(this.witnessLastNameInput.value),firstNames:t.length>0?t:void 0};e.witness=Object.values(n).some(i=>i!==void 0)?n:void 0,e.caseId=this.stringOrUndefined(this.caseIdInput.value),this.updateTestimony(),this.ufoElement.refresh()}updateTestimony(){const e=this.ufoElement.sighting,t=this.testimonyFollowedUpSelect.value,n={witnessAgeYears:this.numberOrUndefined(this.witnessAgeInput.value),witnessOccupation:this.witnessOccupationInput.value.trim()===""?void 0:this.said.write(e.testimony?.witnessOccupation,this.witnessOccupationInput.value,this.writingLanguage),source:this.stringOrUndefined(this.testimonySourceSelect.value),followedUp:t===""?void 0:t==="yes"};e.testimony=Object.values(n).some(i=>i!==void 0)?n:void 0}updateDescription(){this.ufoElement.sighting.event.description=this.said.write(this.ufoElement.sighting.event.description,this.descriptionInput.value,this.writingLanguage),this.ufoElement.refresh()}updateTags(){const e=this.tagsInput.value.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>this.tagNames.stored(t));this.ufoElement.sighting.event.tags=e.length>0?e:void 0,this.ufoElement.refresh()}applyWeatherAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio(),this.weatherFromRecords&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState());const e={cloudCover:Number(this.cloudCoverInput.value),highCloudCover:Number(this.highCloudCoverInput.value),lowerCloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),cloudBaseM:this.numberOrUndefined(this.cloudBaseInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),storm:this.stormInput.checked};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}applyIceAlignmentAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio();const e={...Fs(this.ufoElement.sighting,this.ufoElement.currentTime),iceCrystalAlignment:Number(this.iceCrystalAlignmentInput.value)};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}buildSoundKindOptions(){for(const e of S1){const t=document.createElement("option");t.value=e,t.textContent=this.soundKindLabel(e,this.messages),this.soundKindOptions.set(e,t),this.soundKindSelect.appendChild(t)}}soundKindLabel(e,t){switch(e){case"hum":return t.soundHum;case"whistle":return t.soundWhistle;case"rumble":return t.soundRumble;case"crackle":return t.soundCrackle;default:return t.soundNone}}applySoundAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;const e=this.readSound();this.ufoElement.sighting.soundTrack.addKeyframe(this.ufoElement.currentTime,e),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e),this.ufoElement.refresh(),this.previewSound(e)}previewSound(e){clearTimeout(this.soundPreviewTimer),this.ufoElement.previewSound(e),this.soundPreviewTimer=setTimeout(()=>this.ufoElement.stopSoundPreview(),OT)}readSound(){return{kind:this.soundKindSelect.value,volume:Number(this.soundVolumeInput.value),pitchHz:Number(this.soundPitchInput.value),src:this.soundSrcInput.value.trim()||void 0}}syncSoundFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Jd(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.soundKindSelect&&(this.soundKindSelect.value=e.kind),t!==this.soundVolumeInput&&(this.soundVolumeInput.value=String(e.volume)),t!==this.soundPitchInput&&(this.soundPitchInput.value=String(e.pitchHz)),t!==this.soundSrcInput&&(this.soundSrcInput.value=e.src??""),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e)}updateSoundPitchReadout(e){this.soundPitchValue.textContent=`${Math.round(e)} Hz`}updateSoundFieldsDisabledState(e){const t=e.kind==="none"&&!e.src;this.soundVolumeInput.disabled=t,this.soundSrcInput.disabled=t,this.soundPitchInput.disabled=t||e.src!==void 0}set weatherProvider(e){this.weatherInference=new mh(e),this.scheduleWeatherLookup()}onWeatherInferredToggled(){this.weatherFromRecords=this.weatherInferredInput.checked,this.weatherFromRecords?this.scheduleWeatherLookup():(this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}scheduleWeatherLookup(){this.weatherFromRecords&&(clearTimeout(this.weatherLookupTimer),this.weatherLookupTimer=setTimeout(()=>void this.inferWeather(),kT))}cancelWeatherLookup(){clearTimeout(this.weatherLookupTimer),this.weatherLookupToken++,this.weatherLookupPending=!1}async inferWeather(){if(!this.weatherFromRecords)return;const e=++this.weatherLookupToken;this.weatherLookupPending=!0,this.syncWeatherSourceState();const t=await this.weatherInference.infer(this.ufoElement.sighting);e!==this.weatherLookupToken||!this.weatherFromRecords||(this.weatherLookupPending=!1,this.weatherLookupResult=t,t.status==="inferred"?(this.weatherInference.applyTo(this.ufoElement.sighting,t),this.weatherTrackSpan=this.ufoElement.seekableDuration,this.ufoElement.refresh(),this.syncWeatherFromTimeline()):this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}ensureWeatherTrackSpan(){if(!this.weatherFromRecords||this.ufoElement.sighting.weatherSource===void 0)return;const e=this.ufoElement.seekableDuration;this.weatherTrackSpan===void 0||e===this.weatherTrackSpan||(this.weatherTrackSpan=e,this.scheduleWeatherLookup())}syncWeatherSourceState(){const e=this.ufoElement.sighting.weatherSource,t=this.weatherFromRecords;for(const o of this.weatherFields)o.disabled=t&&e!==void 0&&o!==this.iceCrystalAlignmentInput||this.ufoElement.playbackState==="playing",this.ufoElement.playbackState==="playing"?o.title=this.messages.weatherWhilePlaying:o.title===this.messages.weatherWhilePlaying&&(o.title="");const n=this.weatherInference.canInfer(this.ufoElement.sighting);this.weatherInferredInput.disabled=!n,this.weatherInferredInput.checked=n&&this.weatherFromRecords;const i=n?this.messages.weatherInferredTitle:this.messages.weatherNeedsDateAndPlace;this.weatherInferredInput.title=i,this.labelWeatherInferred.title=i;const a=t&&e!==void 0;if(this.weatherSourceLink.hidden=!a,a){this.weatherSourceRow.hidden=!1,this.weatherSourceText.textContent="",this.weatherSourceLink.href=e.url,this.weatherSourceLink.textContent=this.observationInstantLabel();return}const r=t?this.weatherStatusMessage():"";this.weatherSourceText.textContent=r===""?"":`${r} `,this.weatherSourceRow.hidden=r===""}weatherStatusMessage(){if(this.weatherLookupPending)return this.messages.weatherLookingUp;switch(this.weatherLookupResult?.status){case"unavailable":return this.messages.weatherNoRecord;case"failed":return this.messages.weatherLookupFailed;default:return""}}observationInstantLabel(){const e=this.ufoElement.sighting.event,t=e.time&&Va(e.time,e.place?.[0]?.lng??0,e.utcOffsetHours);return t?`, ${t.toISOString().slice(0,16).replace("T"," ")} UTC`:""}syncWeatherOwnership(){const e=this.ufoElement.sighting;this.cancelWeatherLookup(),this.weatherLookupResult=void 0,this.weatherFromRecords=e.weatherSource!==void 0||e.weatherTrack.allKeyframes.length===0,this.syncWeatherSourceState(),this.weatherFromRecords&&e.weatherSource===void 0&&this.scheduleWeatherLookup()}syncDurationField(){if(this.shadow.activeElement!==this.durationInput){const e=Ka(this.ufoElement.sighting.event);this.durationInput.value=e!==void 0?String(e/1e3):""}this.updateDurationValidity()}updateDurationValidity(){const e=this.durationInput.value==="";this.durationInput.classList.toggle("missing-required",e),this.markUnansweredQuestions(),this.durationInput.setAttribute("aria-invalid",String(e));const t=D1(this.ufoElement.sighting.event);this.durationInput.title=t==="imprecise"?this.messages.durationImprecise:""}syncPlaybackControls(){this.ensureWeatherTrackSpan();const e=this.ufoElement.playbackState==="playing",t=this.ufoElement.seekableDuration>0;this.playPauseButton.textContent=e?"⏸":"▶",this.playPauseButton.disabled=!t;const n=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.loopButton.setAttribute("aria-pressed",String(this.ufoElement.autoReplayEnabled)),this.seekInput.max=String(this.ufoElement.seekableDuration),this.shadow.activeElement!==this.seekInput&&(this.seekInput.value=String(this.ufoElement.currentTime)),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}switchTimeDisplay(){this.ufoElement.toggleTimeDisplay(),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}syncTimeDisplaySwitch(){const e=this.ufoElement.canSwitchTimeDisplay,t=this.ufoElement.showingClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime;for(const[n,i]of[[this.timeStartLabel,this.messages.currentPosition],[this.timeEndLabel,this.messages.duration]])n.title=e?`${i} — ${t}`:i,n.classList.toggle("switchable",e),e?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}static TIME_QUALIFIERS=[{value:"",key:"timeQualifierExact"},{value:"~",key:"timeQualifierApproximate"},{value:"?",key:"timeQualifierUncertain"},{value:"%",key:"timeQualifierBoth"}];refreshTimeQualifierOptions(){for(const e of[this.obsTimeQualifier,this.obsEndTimeQualifier]){const t=e.value;e.replaceChildren(...ut.TIME_QUALIFIERS.map(n=>{const i=document.createElement("option");return i.value=n.value,i.textContent=this.messages[n.key],i})),e.value=t}}qualifierOf(e){const t=e.trim().slice(-1);return"?~%".includes(t)?t:""}isPickable(e){return e?e.year!==void 0&&e.month!==void 0&&e.day!==void 0&&e.hour!==void 0&&e.minute!==void 0&&(e.second===void 0||e.second===0):!1}pickerValueOf(e){if(!this.isPickable(e))return"";const t=(n,i=2)=>String(n).padStart(i,"0");return`${t(e.year,4)}-${t(e.month)}-${t(e.day)}T${t(e.hour)}:${t(e.minute)}`}writeFromPicker(e,t,n,i){e.value===""&&e.validity.badInput||(n.value=e.value===""?"":`${e.value}${t.value}`,i())}chooseTimeInputMode(){const e=this.ufoElement.sighting.event,t=n=>n===void 0||this.isPickable(n);this.setEdtfMode(!(t(e.time)&&t(e.endTime)))}setEdtfMode(e){this.edtfMode=e,this.edtfModeButton.setAttribute("aria-pressed",String(e));for(const[t,n,i]of[[this.obsTimeInput,this.obsTimeNativeInput,this.obsTimeQualifier],[this.obsEndTimeInput,this.obsEndTimeNativeInput,this.obsEndTimeQualifier]])t.hidden=!e,n.hidden=e,i.hidden=e}syncObservationTimeFields(){const e=this.ufoElement.sighting.event.time;this.obsTimeInput.value=e?_l(e):"",this.obsTimeNativeInput.value=this.pickerValueOf(e),this.obsTimeQualifier.value=this.qualifierOf(this.obsTimeInput.value),this.obsTimeInput.setCustomValidity(""),this.obsTimeInput.classList.remove("invalid")}syncObservationEndTimeFields(){const e=this.ufoElement.sighting.event.endTime;this.obsEndTimeInput.value=e?_l(e):"",this.obsEndTimeNativeInput.value=this.pickerValueOf(e),this.obsEndTimeQualifier.value=this.qualifierOf(this.obsEndTimeInput.value),this.obsEndTimeInput.setCustomValidity(""),this.obsEndTimeInput.classList.remove("invalid")}syncUtcOffsetField(){const e=this.ufoElement.sighting.event.utcOffsetHours;this.utcOffsetInput.value=e===void 0?"":String(e),this.updateUtcOffsetValidity()}updateUtcOffsetValidity(){const e=this.ufoElement.sighting.event.utcOffsetHours,t=this.ufoElement.sighting.event.place?.[0]?.lng,n=t===void 0?void 0:Math.round(t/15),i=e!==void 0&&n!==void 0&&Math.abs(e-n)>BT;this.utcOffsetInput.classList.toggle("invalid",i),this.utcOffsetInput.title=i?this.messages.utcOffsetImplausible.replace("{solar}",n>=0?`+${n}`:String(n)):""}scheduleGroundElevation(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||this.groundElevationFor&&this.isSamePlace(this.groundElevationFor,e,t)||(clearTimeout(this.groundElevationTimer),this.groundElevationTimer=setTimeout(()=>void this.applyGroundElevation(e,t),UT))}isSamePlace(e,t,n){return Math.abs(e.lat-t)<Aa&&Math.abs(e.lng-n)<Aa}async applyGroundElevation(e,t){const n=++this.groundElevationToken,i=Ea(vh,this.chosenSourceId.get("elevation")),a=await new Du(i.create()).at(e,t);if(n!==this.groundElevationToken||a===void 0)return;this.groundElevationFor={lat:e,lng:t};const r=Math.max(0,(this.numberOrUndefined(this.elevationInput.value)??0)-(this.groundElevationM??0));this.groundElevationM=Math.round(a),this.syncElevationField(r),this.updateObserver()}syncElevationField(e){const t=this.groundElevationM;this.elevationInput.value=String(Math.round((t??0)+e)),this.elevationInput.min=t===void 0?"":String(t),this.elevationInput.title=t===void 0?"":this.messages.altitudeAboveSeaLevel,this.groundElevationOutput.textContent=t===void 0?"":this.messages.groundAt.replace("{m}",String(t))}syncGroundElevationField(){this.groundElevationToken++,clearTimeout(this.groundElevationTimer),this.groundElevationM=void 0,this.groundElevationFor=void 0,this.syncElevationField(xt(this.ufoElement.sighting,0)?.elevationM??0),this.scheduleGroundElevation()}syncPlaceNameField(){const e=this.ufoElement.sighting.event.place?.[0],t=e?.name??"";this.placeNameInput.value=t,this.placeNameInput.title=t,this.namedCoordinates=e&&t?{lat:e.lat,lng:e.lng}:void 0,this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=""}syncWitnessMetadataFields(){const e=this.ufoElement.sighting;this.witnessIdInput.value=e.witness?.id??"",this.witnessDirNameInput.value=e.witness?.dirName??"",this.witnessTitleInput.value=e.witness?.title??"",this.witnessLastNameInput.value=e.witness?.lastName??"",this.witnessFirstNamesInput.value=e.witness?.firstNames?.join(", ")??"",this.caseIdInput.value=e.caseId??"",this.witnessAgeInput.value=e.testimony?.witnessAgeYears?.toString()??"",this.witnessOccupationInput.value=this.said.read(e.testimony?.witnessOccupation)??"",this.testimonySourceSelect.value=e.testimony?.source??"",this.testimonyFollowedUpSelect.value=e.testimony?.followedUp===void 0?"":e.testimony.followedUp?"yes":"no",this.descriptionInput.value=this.said.read(e.event.description)??"",this.showTags(),this.instrumentSelect.value=e.instrument.id}syncWeatherFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Fs(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.cloudCoverInput&&(this.cloudCoverInput.value=String(e.cloudCover)),t!==this.highCloudCoverInput&&(this.highCloudCoverInput.value=String(e.highCloudCover??0)),t!==this.iceCrystalAlignmentInput&&(this.iceCrystalAlignmentInput.value=String(e.iceCrystalAlignment??_h)),t!==this.cloudDarknessInput&&(this.cloudDarknessInput.value=String(e.cloudDarkness)),t!==this.cloudBaseInput&&(this.cloudBaseInput.value=e.cloudBaseM===void 0?"":String(e.cloudBaseM)),t!==this.precipitationTypeSelect&&(this.precipitationTypeSelect.value=e.precipitationType),t!==this.precipitationIntensityInput&&(this.precipitationIntensityInput.value=String(e.precipitationIntensity)),t!==this.windDirectionInput&&(this.windDirectionInput.value=String(e.windDirectionDeg)),t!==this.windSpeedInput&&(this.windSpeedInput.value=String(e.windSpeed)),t!==this.stormInput&&(this.stormInput.checked=e.storm)}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=e.witnessTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),n=e.event.place?.[0],i=this.shadow.activeElement;i!==this.latInput&&(this.latInput.value=t?.lat!==void 0?String(t.lat):n?String(n.lat):""),i!==this.lngInput&&(this.lngInput.value=t?.lng!==void 0?String(t.lng):n?String(n.lng):""),i!==this.headingInput&&(this.headingInput.value=t?.headingDeg!==void 0?String(this.rounded(t.headingDeg)):""),i!==this.pitchInput&&(this.pitchInput.value=String(this.rounded(t?.pitchDeg??0)),this.rollInput.value=String(this.rounded(t?.rollDeg??0))),i!==this.elevationInput&&this.syncElevationField(t?.elevationM??0)}get appearance(){return{...this.currentAppearance}}set appearance(e){this.setAppearance(e)}setAppearance(e){const t="presetId"in e;this.currentAppearance={...this.currentAppearance,...e},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead(void 0,t)}applyAppearanceAtPlayhead(e,t=!0){const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=n.getInterpolatedShapeAt(i,this.currentSourceId),r=this.buildAppearanceShape(e??a?.bounds??this.defaultBounds(),a,t);this.commitShapes(i,[{sourceId:this.currentSourceId,shape:r}]),this.ufoElement.refresh()}buildAppearanceShape(e,t,n=!0){if(t&&!n)return{...t,color:this.currentAppearance.color,transparency:this.currentAppearance.transparency,haloScale:this.currentAppearance.haloScale,blur:this.currentAppearance.blur,brightness:this.currentAppearance.brightness};const i=Ku(e,this.currentAppearance);return t?{...i,angle:t.angle,title:t.title,selected:t.selected}:i}toggleSkyDetails(){const e=this.skyDetailsButton.getAttribute("aria-expanded")!=="true";this.skyDetailsButton.setAttribute("aria-expanded",String(e)),this.skyDetailsButton.textContent=e?"▴":"▾",this.skyDetailsButton.title=e?this.messages.skyDetailsHide:this.messages.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title);for(const t of this.clampedLines)t.classList.toggle("clamped",!e)}isGroupOpen(e){return e.getAttribute("aria-expanded")==="true"}toggleGroup(e,t){for(const[n,i]of this.groupTabs.entries()){const a=i===e&&t;i.setAttribute("aria-expanded",String(a)),this.groupPanels[n].hidden=!a}}static SUMMARY_GROUPS=["observation","witness","location","decor","temporal","weather","sound"];static PANEL_ORDER=["observation","witness","location","decor","temporal","weather","sound","shape"];refreshParamSummary(){const t=this.paramSummaryBuilder.entriesFor(this.ufoElement.sighting,this.ufoElement.currentTime,{decorId:this.currentDecorId,decorPicker:!0,groundElevationM:this.groundElevationM??0}).map(i=>({...i,panel:ut.SUMMARY_GROUPS.indexOf(i.group)})),n=t.map(i=>`${i.field}=${i.label}=${i.value}${i.unit}${i.fromSource?"*":""}`).join("|");n!==this.paramSummarySignature&&(this.paramSummarySignature=n,this.paramChips=t,this.renderParamSummary(),this.runAssessments())}paramChips=[];renderParamSummary(){const e=ut.NESTED_GROUPS,t=[];let n;for(const i of[...this.paramChips,...this.assessmentChips]){if(n&&n.group!==i.group&&(n=void 0),e.includes(i.group)&&!n){const r=document.createElement("span");r.className="param-nest",r.dataset.group=i.group;const o=document.createElement("span");o.className="param-nest-label",o.textContent=i.group==="assessment"?this.messages.assessmentGroup:ut.tabLabel(this.groupTabs[ut.SUMMARY_GROUPS.indexOf(i.group)]),r.append(o),n={group:i.group,element:r},t.push(r)}const a=this.paramChip(i);n?n.element.append(a):t.push(a)}this.paramSummary.replaceChildren(...t)}static NESTED_GROUPS=["witness","decor","assessment"];static QUESTION_FIELDS={when:{panel:"temporal",fields:["obs-time","obs-time-native"]},where:{panel:"location",fields:["lat","lng"]},facing:{panel:"location",fields:["heading"]},"apparent-size":{panel:"shape",fields:[]},"sky-position":{panel:"shape",fields:[]},"how-long":{panel:"temporal",fields:["durationSeconds","obs-end-time","obs-end-time-native"]},appearance:{panel:"shape",fields:["shapeTitle","color"]},movement:{panel:"shape",fields:[]},sound:{panel:"sound",fields:["soundKind"]},conditions:{panel:"weather",fields:["cloudCover"]}};assessmentChips=[];assessmentToken=0;async runAssessments(){const e=++this.assessmentToken,t=await new t1(this.messages).read(this.ufoElement.sighting);e===this.assessmentToken&&(this.assessmentChips=t.entries.map(n=>({...n,panel:ut.PANEL_ORDER.indexOf(n.about??"")})),this.markUnansweredQuestions(t.unanswered),this.renderParamSummary())}static tabLabel(e){return(e.querySelector("span:not(.tab-badge)")??e).textContent.trim()}static badgeOn(e){const t=e.querySelector(".tab-badge");if(t)return t;const n=document.createElement("span");return n.className="tab-badge",n.hidden=!0,e.append(n),n}unansweredQuestions=new Set;markUnansweredQuestions(e=this.unansweredQuestions){this.unansweredQuestions=e;const t=new Set;for(const a of e){const r=ut.QUESTION_FIELDS[a];if(r&&!r.fields.some(o=>this.shadow.getElementById(o)?.classList.contains("missing-required")))for(const o of r.fields){const l=this.shadow.getElementById(o);l&&!l.hidden&&l.value===""&&t.add(o)}}for(const[a,r]of Object.entries(ut.QUESTION_FIELDS))for(const o of ut.QUESTION_FIELDS[a].fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=t.has(o)&&!l.classList.contains("missing-required");l.classList.toggle("wanted",c),(c||l.title===this.messages.questionUnanswered)&&(l.title=c?this.messages.questionUnanswered:"")}const n=new Map;let i;for(const[a,r]of Object.entries(ut.QUESTION_FIELDS))for(const o of r.fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=l.classList.contains("missing-required");!c&&!l.classList.contains("wanted")||(c&&(i=r.panel),n.set(r.panel,(n.get(r.panel)??0)+1))}for(const[a,r]of this.groupTabs.entries()){const o=ut.PANEL_ORDER[a],l=n.get(o)??0,c=o===i,h=ut.badgeOn(r);h.hidden=l===0,h.textContent=String(l),h.classList.toggle("optional",!c),r.title=l===0?"":c?this.messages.durationRequired:this.messages.questionsUnanswered.replace("{count}",String(l))}}paramChip(e){const t=document.createElement("button");t.type="button",t.className=e.fromSource?"param-chip from-source":"param-chip",t.dataset.panel=String(e.panel),t.dataset.field=e.field;const n=document.createElement("span");if(n.className="param-chip-label",n.textContent=`${e.label} `,t.append(n),e.color!==void 0){const a=document.createElement("span");a.className="param-chip-swatch",a.style.background=e.color,t.append(a)}const i=document.createElement("span");return i.className="param-chip-value",i.textContent=e.unit===""?e.value:`${e.value} ${e.unit}`,t.append(i),t}onParamSummaryClick(e){const t=e.target.closest(".param-chip");if(t==null)return;const n=Number(t.dataset.panel);if(n<0)return;const i=this.groupPanels[n];this.toggleGroup(this.groupTabs[n],!0);const a=t.dataset.field;if(a.startsWith("decor:")){this.currentDecorId=a.slice(6),this.refreshDecorList(),this.decorSelect.focus();return}const r=this.shadow.getElementById(a);r===null||!i.contains(r)||(r.focus(),r instanceof HTMLInputElement&&r.type!=="checkbox"&&r.type!=="color"&&r.type!=="range"&&r.select(),r.scrollIntoView?.({block:"center"}))}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.syncWeatherFromTimeline(),this.syncWeatherSourceState(),this.syncSoundFromTimeline(),this.syncDecorLitFromTimeline(),this.syncDecorPlacementFromTimeline(),this.syncIndoorLookReset(),this.updateAppearanceFieldsDisabledState(),this.updateShapeTitleValidity(),this.refreshRealSize(),this.refreshBlurDistanceBound(),this.refreshSkyCandidates(),this.refreshInstrumentOptions(),this.syncOpticsFromInstrument(),this.ufoElement.selectedSourceIds=this.selectedSourceIds;const e=this.ufoElement.sighting.timeline.sourceIds,t=e.filter(n=>this.selectedSourceIds.has(n)).length;this.deleteShapeButton.disabled=this.isRecording||this.ufoElement.playbackState==="playing"||t===0||e.length-t<1,this.refreshParamSummary()}updateAppearanceFieldsDisabledState(){const e=this.selectedSourceIds.size>1,t=e?this.messages.multipleShapesSelected:"";for(const n of[this.shapeTitleInput,this.colorInput,this.transparencyInput,this.haloScaleInput,this.blurInput,this.brightnessInput,this.objectSizeInput,this.objectDistanceInput,this.distanceHypothesisInput,this.clearDistanceHypothesisButton,this.sourceSelect,...Object.values(this.presetButtons)])n.disabled=e,n.title=t}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.selectedSourceIds.size>1)return;const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);e&&(this.currentAppearance={presetId:WT(e),color:e.color,transparency:e.transparency,haloScale:e.haloScale,blur:e.blur??0,brightness:e.brightness??0},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale),this.blurInput.value=String(this.currentAppearance.blur),this.brightnessInput.value=String(this.currentAppearance.brightness),this.shadow.activeElement!==this.shapeTitleInput&&(this.shapeTitleInput.value=this.said.read(e.title)??""),this.refreshApparentSize())}updateShapeTitle(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime,n=e.getInterpolatedShapeAt(t,this.currentSourceId);n&&(this.commitShapes(t,[{sourceId:this.currentSourceId,shape:{...n,title:this.said.write(n.title,this.shapeTitleInput.value,this.writingLanguage)}}]),this.ufoElement.refresh(),this.refreshSourceList(),this.updateShapeTitleValidity())}applySizeHypothesis(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime,n=e.getInterpolatedShapeAt(t,this.currentSourceId);if(!n)return;const i=this.numberOrUndefined(this.objectSizeInput.value),a=this.numberOrUndefined(this.objectDistanceInput.value);if(i===void 0||a===void 0||i<=0||a<=0){this.refreshApparentSize();return}const r=this.currentProjection(),o=r.widthPx({sizeM:i,distanceM:a}),l=n.bounds.height*(n.bounds.width===0?1:o/n.bounds.width),c={x:n.bounds.x+(n.bounds.width-o)/2,y:n.bounds.y+(n.bounds.height-l)/2,width:o,height:l},h=r.ofBounds(c),d=n.kind==="oval"?{...n,bounds:c,angular:h}:{...n,bounds:c,angular:h,points:this.scalePoints(n,c)};this.commitShapes(t,[{sourceId:this.currentSourceId,shape:d}]),this.ufoElement.refresh(),this.refreshApparentSize()}scalePoints(e,t){const n=e.bounds.width===0?1:t.width/e.bounds.width,i=e.bounds.height===0?1:t.height/e.bounds.height;return e.points.map(a=>({x:a.x*n,y:a.y*i}))}refreshInstrumentOptions(){const e=this.ufoElement.sighting,t=e.event.time?.year,n=it.availableAt(t),i=e.instrument,a=n.includes(i)?n:[...n,i],r=this.instrumentSelect.value||i.id;this.instrumentSelect.replaceChildren();for(const o of a){const l=document.createElement("option");l.value=o.id;const c=o.name[this.showerLanguage()];l.textContent=n.includes(o)?c:this.messages.instrumentOutOfPeriod.replace("{name}",c),this.instrumentSelect.appendChild(l)}this.instrumentSelect.value=a.some(o=>o.id===r)?r:i.id}static exposureText(e){return e>=1?String(Math.round(e*100)/100):`1/${Math.round(1/e)}`}statedExposureSeconds(e){const t=ut.exposureSeconds(this.exposureInput.value),n=e.exposureRangeSeconds;if(!n)return e.exposureSeconds??t;if(t!==void 0)return Math.min(n.max,Math.max(n.min,t))}static exposureSeconds(e){const t=e.trim();if(!t)return;const n=/^(\d*\.?\d+)\s*\/\s*(\d*\.?\d+)$/.exec(t);if(n){const a=Number(n[1]),r=Number(n[2]);return r>0?a/r:void 0}const i=Number(t);return Number.isFinite(i)&&i>0?i:void 0}syncOpticsFromInstrument(){const e=this.ufoElement.sighting,t=e.instrument,n=xt(e,this.ufoElement.currentTime),i=t.frame,a=n?.fovDeg??it.fieldOfViewDeg(t),r=i?it.focalLengthMmFor(t,a):a;this.focalLengthInput!==this.shadow.activeElement&&(this.focalLengthInput.value=r===void 0?"":String(Math.round(r*10)/10)),this.unitFocalLength.textContent=i?this.messages.unitMillimetres:this.messages.unitDegrees,this.labelFocalLength.textContent=i?this.messages.focalLength:this.messages.fieldOfView,this.focalLengthInput.disabled=i!==void 0&&i.focalRangeMm===void 0,this.focalLengthInput.min=String(i?.focalRangeMm?.minMm??1),this.focalLengthInput.max=String(i?.focalRangeMm?.maxMm??2e3);const o=n?.fNumber??t.fNumber;this.fNumberInput!==this.shadow.activeElement&&(this.fNumberInput.value=o===void 0?"":String(o)),this.setRowVisible(this.fNumberInput,t.fNumber!==void 0),this.fNumberInput.disabled=t.fNumberRange===void 0,this.fNumberInput.min=String(t.fNumberRange?.min??.7),this.fNumberInput.max=String(t.fNumberRange?.max??64);const l=e.exposure;this.exposureInput!==this.shadow.activeElement&&(this.exposureInput.value=l===void 0?"":ut.exposureText(l)),this.setRowVisible(this.exposureInput,t.exposureSeconds!==void 0),this.exposureInput.disabled=t.exposureRangeSeconds===void 0,this.focusDistanceInput!==this.shadow.activeElement&&(this.focusDistanceInput.value=n?.focusDistanceM===void 0?"":String(n.focusDistanceM)),this.setRowVisible(this.focusDistanceInput,i!==void 0&&t.fNumber!==void 0)}retuneFieldOfView(e){const t=this.ufoElement.sighting,n=it.fieldOfViewDeg(e),i=it.fieldOfViewDeg(t.instrument);for(const a of[...t.witnessTrack.allKeyframes])Math.abs(a.pose.fovDeg-n)>zT||t.witnessTrack.addKeyframe(a.t,{...a.pose,fovDeg:i})}retuneExposure(e){const t=this.ufoElement.sighting,n=t.exposureSeconds,i=t.instrument.exposureRangeSeconds;if(n===void 0||n===e.exposureSeconds||!i){t.exposureSeconds=void 0;return}t.exposureSeconds=Math.min(i.max,Math.max(i.min,n))}currentFovDeg(){const e=this.ufoElement.sighting;return xt(e,this.ufoElement.currentTime)?.fovDeg??it.fieldOfViewDeg(e.instrument)}currentProjection(){return xi.of(this.ufoElement.sighting.instrument,this.ufoElement.canvasElement.height,this.currentFovDeg())}refreshApparentSize(){const e=this.selectedSourceIds.size===1?this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId):void 0;if(!e){this.apparentSizeOutput.textContent="";return}const t=this.currentProjection().pxToDeg(e.bounds.width),n=ht.inMoons(t);this.apparentSizeOutput.textContent=this.messages.apparentSize.replace("{deg}",t.toLocaleString(void 0,{maximumFractionDigits:t<1?2:1})).replace("{moons}",n.toLocaleString(void 0,{maximumFractionDigits:n<10?1:0})),this.refreshRealSize()}refreshBlurDistanceBound(){const e=this.currentAppearance.blur;if(e<=0||this.selectedSourceIds.size!==1){this.blurBoundOutput.textContent="";return}const t=this.ufoElement.sighting.instrument,n=t.frame;if(!n){this.blurBoundOutput.textContent=this.messages.blurBoundNoInstrument;return}const i=xt(this.ufoElement.sighting,this.ufoElement.currentTime),a=i?.focusDistanceM;if(a!==void 0){this.blurBoundOutput.textContent=this.messages.blurBoundNotAtInfinity.replace("{focus}",this.meters(a));return}const r=(i?it.focalLengthMmFor(t,i.fovDeg):void 0)??n.focalLengthMm,o=i?.fNumber??t.fNumber;if(o===void 0||r<=0){this.blurBoundOutput.textContent="";return}const l=this.ufoElement.canvasElement.height;if(l<=0)return;const c=2*xh*e/l*n.heightMm,h=r*r/(o*c)/1e3;this.blurBoundOutput.textContent=this.messages.blurBound.replace("{max}",this.meters(h))}refreshRealSize(){if(this.refreshDepth(),this.selectedSourceIds.size!==1){this.realSizeOutput.textContent="";return}const e=this.currentSourceId;if(this.sceneElement.sizeContradictory(e)){this.realSizeOutput.textContent=this.messages.realSizeContradiction;return}const{minM:t,maxM:n}=this.sceneElement.sizeRangeOf(e);if(t===void 0&&n===void 0){this.realSizeOutput.textContent=this.messages.realSizeUnknown;return}if(t!==void 0&&n!==void 0){const i=this.sceneElement.distanceRangeAt(e,this.ufoElement.currentTime),a=i.minM===void 0||i.maxM===void 0?"":this.messages.realDistanceHere.replace("{min}",this.meters(i.minM)).replace("{max}",this.meters(i.maxM));this.realSizeOutput.textContent=this.messages.realSizeBetween.replace("{min}",this.meters(t)).replace("{max}",this.meters(n))+a;return}this.realSizeOutput.textContent=t!==void 0?this.messages.realSizeAtLeast.replace("{min}",this.meters(t)):this.messages.realSizeAtMost.replace("{max}",this.meters(n))}decimal(e,t){return e.toLocaleString(void 0,{minimumFractionDigits:t,maximumFractionDigits:t})}static HYPOTHESIS_NEAREST_M=1;static HYPOTHESIS_FURTHEST_M=2e4;applyDistanceHypothesis(){this.selectedSourceIds.size===1&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,this.sliderToMeters(Number(this.distanceHypothesisInput.value))),this.refreshDepth())}clearDistanceHypothesis(){this.selectedSourceIds.size===1&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,void 0),this.refreshDepth())}sliderToMeters(e){const t=Math.log10(ut.HYPOTHESIS_NEAREST_M),n=Math.log10(ut.HYPOTHESIS_FURTHEST_M);return 10**(t+Math.min(1,Math.max(0,e))*(n-t))}metersToSlider(e){const t=Math.log10(ut.HYPOTHESIS_NEAREST_M),n=Math.log10(ut.HYPOTHESIS_FURTHEST_M);return Math.min(1,Math.max(0,(Math.log10(Math.max(e,.001))-t)/(n-t)))}refreshDepth(){const e=this.selectedSourceIds.size===1?this.sceneElement.depthOf(this.currentSourceId):void 0;if(!e){this.depthBasisOutput.textContent="",this.distanceHypothesisValue.textContent="";return}const t=this.meters(e.distanceM);this.distanceHypothesisValue.textContent=`${t} m`,this.distanceHypothesisInput.value=String(this.metersToSlider(e.distanceM)),this.clearDistanceHypothesisButton.hidden=e.basis!=="hypothesis";const n={stated:this.messages.depthStated,hypothesis:this.messages.depthHypothesis,derived:this.messages.depthDerived,bounded:this.messages.depthBounded,conventional:this.messages.depthConventional}[e.basis];this.depthBasisOutput.textContent=n.replace("{m}",t)}commitShapes(e,t){const n=this.ufoElement.sighting;n.timeline.addKeyframe(e,t.map(i=>{const a=on.aimOf(n,e,i.shape.bounds);return a?{...i,shape:{...i.shape,aim:a}}:i}))}meters(e){const t=e<1?2:e<10?1:0;return e.toLocaleString(void 0,{maximumFractionDigits:t})}updateShapeTitleValidity(){const e=this.selectedSourceIds.size===1&&this.shapeTitleInput.value==="";this.shapeTitleInput.classList.toggle("invalid",e),this.shapeTitleInput.setAttribute("aria-invalid",String(e))}shapeLabel(e){const t=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,e),n=this.said.read(t?.title);if(n)return n;const i=/^ufo-(\d+)$/.exec(e);return i?`${this.messages.shape} ${i[1]}`:e}addShape(){if(this.isRecording)return;const e=this.ufoElement.sighting.timeline,t=new Set([...e.sourceIds,this.currentSourceId]);let n=t.size+1;for(;t.has(`ufo-${n}`);)n++;this.currentSourceId=`ufo-${n}`,this.selectedSourceIds=new Set([this.currentSourceId]),this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(e.sourceIds.length)),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle()}deleteShape(){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline,t=e.sourceIds.filter(i=>this.selectedSourceIds.has(i));if(t.length===0||e.sourceIds.length-t.length<1)return;const n=t.length===1?this.messages.confirmDeleteShape.replace("{name}",this.shapeLabel(t[0])):this.messages.confirmDeleteShapes.replace("{count}",String(t.length));this.askConfirm(n,()=>this.removeShapes(t))}removeShapes(e){const t=this.ufoElement.sighting.timeline;for(const n of e)t.removeSource(n);this.currentSourceId=t.sourceIds[0],this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.ufoElement.refresh()}askConfirm(e,t){this.answerConfirm(!1),this.confirmMessage.textContent=e,this.confirmOverlay.hidden=!1,this.confirmAcceptButton.focus(),this.confirmAnswer=t}answerConfirm(e){const t=this.confirmAnswer;this.confirmAnswer=void 0,this.confirmOverlay.hidden=!0,e&&t?.()}offsetDefaultBounds(e){const t=this.defaultBounds(),n=24;return{...t,x:t.x+e*n,y:t.y+e*n}}refreshSourceList(){const e=this.ufoElement.sighting.timeline,t=[...new Set([...e.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const n of t){const i=document.createElement("option");i.value=n,i.textContent=this.shapeLabel(n),this.sourceSelect.appendChild(i)}this.sourceSelect.value=this.currentSourceId}decorLabel(e){const t=this.said.read(e.title);if(t)return t;const i=this.ufoElement.sighting.decor.filter(r=>r.kind===e.kind).indexOf(e)+1;return`${this.decorKindSelect.querySelector(`option[value="${e.kind}"]`)?.textContent??e.kind} ${i}`}addDecor(e=this.decorKindSelect.value){const t=this.ufoElement.sighting,i={id:`decor-${t.decor.length+1}`,kind:e,title:this.nextDecorLabel(e),eastM:8*t.decor.length,northM:15,headingDeg:0,lit:!1,...e==="aircraft"?this.defaultAircraft():{},...e==="building"?{floors:Oa}:{},windows:sm(e)};t.decor=[...t.decor,i],this.currentDecorId=i.id,this.refreshDecorList(),this.ufoElement.refresh()}defaultAircraft(){const e=2*yh,t=Math.round(e/GT*1e3);return{lights:sc.byId("airliner")?.create(),track:[{t:0,eastM:-yh,northM:1e3,altitudeM:1500,headingDeg:90},{t,eastM:yh,northM:1e3,altitudeM:1500,headingDeg:90}]}}nextDecorLabel(e){const t=this.ufoElement.sighting.decor.filter(i=>i.kind===e).length;return`${this.decorKindSelect.querySelector(`option[value="${e}"]`)?.textContent??e} ${t+1}`}deleteDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.filter(t=>t.id!==this.currentDecorId),this.currentDecorId=e.decor[0]?.id,this.refreshDecorList(),this.ufoElement.refresh()}selectDecor(e){this.currentDecorId=e,this.decorSelect.value=e,this.syncDecorFields()}updateDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.decorHeadingInput.value),this.decorHeadingInput)??0,n=this.decorWitnessSideSelect.value;e.decor=e.decor.map(i=>{if(i.id!==this.currentDecorId)return i;const a=Ra(i.kind)&&n!==""?n:void 0,r=Number(this.decorEastInput.value),o=Number(this.decorNorthInput.value),l=Number(this.decorAltitudeInput.value),c=i.track??(l!==0?[]:void 0);if(c){const h=this.ufoElement.currentTime,d={t:h,eastM:r,northM:o,altitudeM:l,headingDeg:t},u=c.filter(f=>f.t!==h);return{...i,title:this.said.write(i.title,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(i),track:[...u,d].sort((f,g)=>f.t-g.t),sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:a,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:i.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:i.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}return{...i,title:this.said.write(void 0,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(i),eastM:r,northM:o,headingDeg:t,sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:a,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:i.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:i.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}),this.decorSelect.options[this.decorSelect.selectedIndex].textContent=this.decorLabel(e.decor.find(i=>i.id===this.currentDecorId)),this.syncDecorVisibility(),this.updateDecorTitleValidity(),this.ufoElement.refresh()}syncDecorSizeFields(e){const t=e?mn.naturalSize(e.kind,e.floors):void 0,n=[[this.decorWidthInput,e?.sizeM?.widthM,t?.widthM],[this.decorLengthInput,e?.sizeM?.lengthM,t?.lengthM],[this.decorHeightInput,e?.sizeM?.heightM,t?.heightM]];for(const[i,a,r]of n)i.value=a===void 0?"":String(this.roundedMeters(a)),i.placeholder=r===void 0?"":String(this.roundedMeters(r))}syncDecorModelFields(e){this.refreshDecorModelOptions(e),this.decorModelSelect.value=e?.model?.id??"",this.decorModelUrlInput.value=e?.model?.url??"",this.decorModelTitleInput.value=e?.model?.credit?.title??"",this.decorModelAuthorInput.value=e?.model?.credit?.author??"",this.decorModelLicenseInput.value=e?.model?.credit?.license??"",this.decorModelSourceInput.value=e?.model?.credit?.sourceUrl??"",this.decorModelAdvanced.open=e?.model?.url!==void 0}async refreshDecorModelOptions(e){const t=e??this.ufoElement.sighting.decor.find(r=>r.id===this.currentDecorId),n=t?await this.decorModelProvider.entries(t.kind).catch(()=>[]):[],i=t?.model?.id??"",a=document.createElement("option");a.value="",a.textContent=this.messages.decorModelNone,this.decorModelSelect.replaceChildren(a,...n.map(r=>{const o=document.createElement("option");return o.value=r.id,o.textContent=r.name,o.title=`${r.credit.title}${r.credit.author?` — ${r.credit.author}`:""} (${r.credit.license})`,o})),this.decorModelSelect.value=i}updateDecorModelChoice(){const e=this.decorModelSelect.value;(async()=>{const t=e?await this.decorModelProvider.entry(e).catch(()=>{}):void 0,n=this.ufoElement.sighting.decor.find(i=>i.id===this.currentDecorId);if(t?.sizeM&&n&&!n.sizeM){const i=[[this.decorWidthInput,t.sizeM.widthM],[this.decorLengthInput,t.sizeM.lengthM],[this.decorHeightInput,t.sizeM.heightM]];for(const[a,r]of i)r!==void 0&&(a.value=String(this.roundedMeters(r)))}this.updateDecor()})()}roundedMeters(e){return Math.round(e*100)/100}positiveMeters(e){const t=Number(e);return e.trim()===""||!Number.isFinite(t)||t<=0?void 0:t}statedDecorColor(e){const t=this.decorColorInput.value;return t==="#808080"&&e.color===void 0?void 0:t}statedDecorSize(){const e=this.positiveMeters(this.decorWidthInput.value),t=this.positiveMeters(this.decorLengthInput.value),n=this.positiveMeters(this.decorHeightInput.value);return e===void 0&&t===void 0&&n===void 0?void 0:{widthM:e,lengthM:t,heightM:n}}statedDecorModel(){const e=this.stringOrUndefined(this.decorModelUrlInput.value);if(e){const n=this.stringOrUndefined(this.decorModelTitleInput.value),i=this.stringOrUndefined(this.decorModelLicenseInput.value);return{url:e,credit:n!==void 0&&i!==void 0?{title:n,license:i,author:this.stringOrUndefined(this.decorModelAuthorInput.value),sourceUrl:this.stringOrUndefined(this.decorModelSourceInput.value)}:void 0}}const t=this.stringOrUndefined(this.decorModelSelect.value);return t===void 0?void 0:{id:t}}addMilestone(){const e=Math.round(this.ufoElement.currentTime),t=this.ufoElement.sighting;t.milestones.find(i=>i.t===e)||(t.milestones=$a([...t.milestones,{t:e,label:this.nextMilestoneLabel()}])),this.currentMilestoneT=e,this.refreshMilestoneList(),this.ufoElement.refresh()}nextMilestoneLabel(){const e=new Set(this.ufoElement.sighting.milestones.map(t=>t.label));for(let t=0;t<26;t++){const n=String.fromCharCode(65+t);if(!e.has(n))return n}return String(this.ufoElement.sighting.milestones.length+1)}deleteMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting,n=t.milestones.find(i=>i.t===e);n&&this.askConfirm(this.messages.confirmDeleteMilestone.replace("{name}",this.said.read(n.label)??""),()=>{t.milestones=t.milestones.filter(i=>i.t!==e),this.currentMilestoneT=t.milestones[0]?.t,this.refreshMilestoneList(),this.ufoElement.refresh()})}selectMilestone(e){this.currentMilestoneT=e,this.syncMilestoneFields(),this.ufoElement.currentTime=e}updateMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting;t.milestones=t.milestones.map(n=>n.t===e?{...n,label:this.said.write(n.label,this.milestoneLabelInput.value,this.writingLanguage)??"",note:this.said.write(n.note,this.milestoneNoteInput.value,this.writingLanguage)}:n),this.refreshMilestoneList(),this.ufoElement.refresh()}refreshMilestoneList(){const e=$a(this.ufoElement.sighting.milestones);e.some(t=>t.t===this.currentMilestoneT)||(this.currentMilestoneT=e[0]?.t),this.milestoneSelect.replaceChildren(...e.map(t=>{const n=document.createElement("option");return n.value=String(t.t),n.textContent=`${this.said.read(t.label)??""} — ${this.formatSeconds(t.t)}`,n.title=this.said.read(t.note)??"",n})),this.currentMilestoneT!==void 0&&(this.milestoneSelect.value=String(this.currentMilestoneT)),this.syncMilestoneFields()}formatSeconds(e){return`${(e/1e3).toFixed(1)} s`}syncMilestoneFields(){const e=this.ufoElement.sighting.milestones.find(n=>n.t===this.currentMilestoneT),t=e!==void 0;for(const n of[this.milestoneSelect,this.milestoneLabelInput,this.milestoneNoteInput,this.deleteMilestoneButton])n.disabled=!t,this.setRowVisible(n,t);this.milestoneLabelInput.value=this.said.read(e?.label)??"",this.milestoneNoteInput.value=this.said.read(e?.note)??""}updateDecorTitleValidity(){const e=this.currentDecorId!==void 0&&this.decorTitleInput.value==="";this.decorTitleInput.classList.toggle("invalid",e),this.decorTitleInput.setAttribute("aria-invalid",String(e))}updateDecorWindows(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.map(t=>{if(t.id!==this.currentDecorId)return t;const n={};for(const i of Qs){const a=this.decorWindowInputs[i];if(a.value==="")continue;const r=Sh(t.kind,i)?0:Mh,o=Math.max(r,Math.min(100,Number(a.value)));n[i]=o,String(o)!==a.value&&(a.value=String(o))}return{...t,windows:n}}),this.ufoElement.refresh()}updateDecorLit(){if(this.currentDecorId===void 0||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=this.ufoElement.currentTime,n=this.decorLitInput.checked;e.decor=e.decor.map(i=>{if(i.id!==this.currentDecorId)return i;const a=[...(i.litKeyframes??[]).filter(r=>r.t!==t),{t,lit:n}].sort((r,o)=>r.t-o.t);return{...i,litKeyframes:a}}),this.ufoElement.refresh()}refreshDecorList(){const e=this.ufoElement.sighting.decor;this.decorSelect.innerHTML="";for(const t of e){const n=document.createElement("option");n.value=t.id,n.textContent=this.decorLabel(t),this.decorSelect.appendChild(n)}this.currentDecorId!==void 0&&(this.decorSelect.value=this.currentDecorId),this.syncDecorFields()}syncDecorFields(){const e=this.ufoElement.sighting.decor.find(n=>n.id===this.currentDecorId),t=e!==void 0;this.deleteDecorButton.disabled=!t;for(const n of[this.decorSelect,this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorHeadingInput,this.decorLitInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelSelect,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput,this.decorWitnessSideSelect,this.decorLightRigSelect,this.decorAltitudeInput,this.lookAtDecorButton])n.disabled=!t;this.decorTitleInput.value=this.said.read(e?.title)??"",this.decorColorInput.value=e?.color??"#808080",this.showDecorPlacement(e),this.decorLitInput.checked=e?Ml(e,this.ufoElement.currentTime):!1,this.refreshDecorLightRigOptions(e),this.decorSightingUrlInput.value=e?.sightingUrl??"",this.syncDecorSizeFields(e),this.syncDecorModelFields(e),this.decorFloorsInput.value=String(e?.floors??Oa),this.decorOccupiedFloorInput.value=String(e?.occupiedFloor??0),this.decorWitnessSideSelect.value=e?.witnessSide??"";for(const n of Qs){const i=e?.windows?.[n];this.decorWindowInputs[n].value=i===void 0?"":String(i)}this.syncDecorVisibility(),this.updateDecorTitleValidity()}setRowVisible(e,t){const n=e.closest("label")??e;n.hidden=!t}syncDecorVisibility(){const e=this.ufoElement.sighting.decor.find(c=>c.id===this.currentDecorId),t=e!==void 0,n=e?.kind;this.setRowVisible(this.decorSelect,t),this.setRowVisible(this.deleteDecorButton,t),this.setRowVisible(this.decorTitleInput,t),this.setRowVisible(this.decorEastInput,t),this.setRowVisible(this.decorNorthInput,t),this.setRowVisible(this.decorAltitudeInput,t),this.setRowVisible(this.decorHeadingInput,t),this.setRowVisible(this.decorWidthInput,t),this.setRowVisible(this.decorLengthInput,t),this.setRowVisible(this.decorHeightInput,t),this.setRowVisible(this.decorModelSelect,t),this.decorModelAdvanced.hidden=!t,this.setRowVisible(this.decorLitInput,t&&e?.kind!=="aircraft");const i=t&&n!==void 0&&Zd(n);this.setRowVisible(this.labelDecorWindows,i);const a=n!==void 0?$d(n):[];for(const c of Qs)this.decorWindowInputs[c].disabled=!t,this.decorWindowInputs[c].min=String(n!==void 0&&Sh(n,c)?0:Mh),this.setRowVisible(this.decorWindowInputs[c],i&&a.includes(c));const r=t&&n!==void 0&&Ra(n);this.setRowVisible(this.decorWitnessSideSelect,r);const o=n!==void 0?n1(n):[];for(const c of Qs)this.optionWitnessSide[c].hidden=!o.includes(c);const l=t&&n==="building";this.setRowVisible(this.decorFloorsInput,l),this.setRowVisible(this.decorOccupiedFloorInput,l),this.decorOccupiedFloorInput.max=String(e?.floors??Oa)}showDecorPlacement(e){const t=e?Ya(e,this.ufoElement.currentTime):void 0,n=[[this.decorEastInput,t?.eastM??0],[this.decorNorthInput,t?.northM??0],[this.decorAltitudeInput,t?.altitudeM??0],[this.decorHeadingInput,t?.headingDeg??0]];for(const[i,a]of n)this.shadow.activeElement!==i&&(i.value=String(this.rounded(a)))}syncDecorPlacementFromTimeline(){this.ufoElement.playbackState!=="playing"&&this.showDecorPlacement(this.ufoElement.sighting.decor.find(e=>e.id===this.currentDecorId))}showNextMeteor(){const e=this.sceneElement.meteorByRank(this.meteorRank++);e&&(this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=e.t,this.headingInput.value=String(Math.round(e.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(e.altitudeDeg*10)/10),this.updateObserver())}resetMeteorRankIfSkyChanged(){const e=this.sceneElement.meteorByRank(0),t=e?`${e.t}`:"";t!==this.meteorRankFor&&(this.meteorRankFor=t,this.meteorRank=0)}meteorRankFor;meteorRank=0;showerLanguage(){return Xr(Vs.preferencesFor(this),["en","fr"])}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;tagNames=new Ah({});get writingLanguage(){return this.showerLanguage()}refreshSkyCandidates(){this.resetMeteorRankIfSkyChanged();const e=this.ufoElement.sighting,t=e.event.place?.[0],n=e.event.time,i=t&&t.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?Va(n,t.lng,e.event.utcOffsetHours):void 0;if(!i||!t||t.lat===void 0||t.lng===void 0){this.showMeteorButton.hidden=!0,this.showCometButton.hidden=!0,this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",this.messages.skyUnknown);return}const a={lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0},r=[this.starsClause(i,a),this.showerClause(i,a),this.cometClause(i,a),this.satelliteClause(i,a),this.opticsClause(i,a),this.rainbowClause(i,a),this.glowClause(i,a)].filter(o=>o!==void 0);this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",r.join(" · "))}instrumentGain(){const e=this.ufoElement.sighting;return an.gainFor(e.instrument,{fNumber:xt(e,0)?.fNumber,fieldOfViewDeg:on.fovOf(e,0),exposureSeconds:e.exposure})}starsClause(e,t){const n=On("Sun",e,t).altitudeDeg,i=this.instrumentGain(),a=Or(n,i),r=c=>c.toLocaleString(void 0,{maximumFractionDigits:1});if(a<FT)return this.messages.skyStarsNone;const o=this.ufoElement.sighting.instrument,l=Math.abs(i)<.1?this.messages.skyStarsEye.replace("{limit}",r(a)):(i>0?this.messages.skyStarsDeeper:this.messages.skyStarsShallower).replace("{limit}",r(a)).replace("{device}",o.name[this.showerLanguage()]).replace("{gain}",r(Math.abs(i))).replace("{eye}",r(Or(n)));return a<=Br?l:l+this.messages.skyStarsCatalogue.replace("{catalogue}",r(Br))}showerClause(e,t){const n=Et.observedRatePerHour(Et.apexPosition(e,t).altitudeDeg).toLocaleString(void 0,{maximumFractionDigits:1}),i=Xa.activeAt(e);if(i.length===0)return this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyNothingActive.replace("{sporadic}",n);const a=i.map(r=>{const o=Xa.radiantPosition(r.shower,e,t);return{entry:r,position:o,rate:Xa.observedRatePerHour(r.zhr,o.altitudeDeg,r.shower.populationIndex)}}).sort((r,o)=>o.rate-r.rate)[0];return a.rate<=0?(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerBelowHorizon.replace("{name}",a.entry.shower.name[this.showerLanguage()])):(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerActive.replace("{name}",a.entry.shower.name[this.showerLanguage()]).replace("{altitude}",String(Math.round(a.position.altitudeDeg))).replace("{bearing}",Gs.towards(a.position.azimuthDeg,this.showerLanguage())).replace("{rate}",a.rate.toLocaleString(void 0,{maximumFractionDigits:a.rate<10?1:0})).replace("{sporadic}",n))}cometClause(e,t){const n=xl.brightestAt(e,t);if(!n||n.magnitude>Jr){this.showCometButton.hidden=!0;return}return this.showCometButton.hidden=n.position.altitudeDeg<=0,this.cometText(n)}satelliteClause(e,t){const n=fi.visibilityAt(e,t);if(!n.anythingInOrbit)return n.sunAltitudeDeg<0?this.messages.skySatellitesNotYet:void 0;const i=Or(n.sunAltitudeDeg,this.instrumentGain()),a=n.classes.filter(h=>h.peakMagnitude<=i),r=this.listed(a.map(h=>h.name[this.showerLanguage()]));if(n.sunAltitudeDeg>=0)return a.length===0?void 0:(a.length===1?this.messages.skySatellitesDaylightOne:this.messages.skySatellitesDaylight).replace("{eras}",r);const o=Math.round(n.shadowHeightKm).toLocaleString(),l=(n.trackedObjects??0).toLocaleString(),c=h=>h.replace("{height}",o).replace("{count}",l);return n.lowOrbitLit?a.length===0?c(this.messages.skySatellitesLit):c(this.messages.skySatellitesLitWith).replace("{eras}",r):c(this.messages.skySatellitesShadowed)}opticsClause(e,t){const n=Fs(this.ufoElement.sighting,0),i=On("Sun",e,t),a=On("Moon",e,t),r=je.deckLitUntilDeg(je.DECK_HEIGHT_M),o=i.altitudeDeg>-r,l=o?i:a;if(l.altitudeDeg<=-r)return;const c=n.highCloudCover;if(c===void 0||c<=0)return this.messages.skyOpticsNoIce;if(je.strength(c,n.lowerCloudCover??n.cloudCover,l.altitudeDeg,r)<=0)return this.messages.skyOpticsHidden;const h=o?this.messages.skyOpticsSun:this.messages.skyOpticsMoon,d=this.listed(je.formsAt(l.altitudeDeg,r).map(f=>this.opticsFormName(f))),u=n.iceCrystalAlignment??_h;return this.messages.skyOpticsPossible.replace("{forms}",d).replace("{source}",h)+this.messages.skyOpticsAlignment.replace("{alignment}",String(Math.round(u*100)))}rainbowClause(e,t){const n=Fs(this.ufoElement.sighting,0);if(n.precipitationType!=="rain"||n.precipitationIntensity<=0)return;const i=On("Sun",e,t),a=On("Moon",e,t),r=i.altitudeDeg>0,o=r?i:a;if(o.altitudeDeg<=0)return this.messages.skyBowNoSource;const l=n.lowerCloudCover??n.cloudCover;if(Qt.strength(n.precipitationIntensity,l,o.altitudeDeg)<=0)return this.messages.skyBowHidden;const c=Qt.formsAt(o.altitudeDeg);if(c.length===0)return this.messages.skyBowSourceTooHigh.replace("{altitude}",String(Math.round(o.altitudeDeg))).replace("{radius}",String(Math.round(Qt.primary().radiusDeg)));const h=this.listed(c.map(u=>this.bowFormName(u)));if(r)return this.messages.skyBowPossible.replace("{forms}",h);const d=Math.round(Hl(e).illuminatedFraction*100);return this.messages.skyBowMoon.replace("{forms}",h).replace("{lit}",String(d))}glowClause(e,t){if(On("Sun",e,t).altitudeDeg>XT)return;const i=this.glows.assess(e,t),a=this.showerLanguage(),r=[];if(i.milkyWay&&r.push(this.messages.skyGlowBand.replace("{contrast}",this.decimal(i.milkyWay.contrast,1)).replace("{altitude}",String(Math.round(i.milkyWay.altitudeDeg))).replace("{bearing}",Gs.towards(i.milkyWay.azimuthDeg,a))),i.zodiacal){const h=i.zodiacal.sunSeparationDeg<=tt.CONE_SEPARATION_DEG;r.push((h?this.messages.skyGlowCone:this.messages.skyGlowZodiacalBand).replace("{contrast}",this.decimal(i.zodiacal.contrast,1)).replace("{altitude}",String(Math.round(i.zodiacal.altitudeDeg))).replace("{bearing}",Gs.towards(i.zodiacal.azimuthDeg,a)).replace("{elongation}",String(Math.round(i.zodiacal.sunSeparationDeg))))}if(r.length>0)return this.listed(r);const o=this.decimal(i.darkestSkyMagPerArcsec2,1),l=On("Moon",e,t),c=i.darkestSkyMagPerArcsec2<qT;if(c&&l.altitudeDeg>0){const h=Math.round(Hl(e).illuminatedFraction*100);return this.messages.skyGlowMoon.replace("{lit}",String(h)).replace("{sky}",o)}return c?this.messages.skyGlowTwilight.replace("{sky}",o):this.messages.skyGlowNothingUp.replace("{sky}",o)}glows=new tt;bowFormName(e){return(e.id==="primary"?this.messages.skyBowPrimary:this.messages.skyBowSecondary).replace("{radius}",String(Math.round(e.radiusDeg))).replace("{top}",String(Math.round(e.topAltitudeDeg)))}opticsFormName(e){const t=n=>String(Math.round(n??0));switch(e.id){case"halo22":return this.messages.skyOpticsHalo22.replace("{angle}",t(e.angleDeg));case"halo46":return this.messages.skyOpticsHalo46.replace("{angle}",t(e.angleDeg));case"parhelia":return this.messages.skyOpticsParhelia.replace("{angle}",t(e.angleDeg));case"tangentArc":return this.messages.skyOpticsTangentArc;case"parhelicCircle":return this.messages.skyOpticsParhelicCircle;case"circumzenithal":return this.messages.skyOpticsCircumzenithal.replace("{angle}",t(e.angleDeg));case"circumhorizontal":return this.messages.skyOpticsCircumhorizontal;case"pillar":return this.messages.skyOpticsPillar}}listed(e){return new Intl.ListFormat(this.showerLanguage(),{style:"long",type:"conjunction"}).format(e)}cometText(e){const t=e.apparition.name[this.showerLanguage()],n=e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1});return e.position.altitudeDeg<=0?this.messages.skyCometBelowHorizon.replace("{name}",t).replace("{magnitude}",n):(e.elongationDeg<xl.TWILIGHT_ELONGATION_DEG?this.messages.skyCometInDaylight:e.tailLengthDeg===void 0?this.messages.skyCometNoTail:this.messages.skyComet).replace("{name}",t).replace("{magnitude}",n).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",Gs.towards(e.position.azimuthDeg,this.showerLanguage())).replace("{tail}",String(Math.round(e.tailLengthDeg??0))).replace("{elongation}",String(Math.round(e.elongationDeg)))}lookAtComet(){const e=this.ufoElement.sighting,t=e.event.place?.[0],n=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||n?.year===void 0)return;const i=Va(n,t.lng,e.event.utcOffsetHours);if(!i)return;const a=xl.brightestAt(i,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});a&&(this.headingInput.value=String(this.rounded(a.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(a.position.altitudeDeg)),this.updateObserver())}rounded(e){return Math.round(e*10)/10}lookAtDecor(){const e=this.ufoElement.sighting.decor.find(l=>l.id===this.currentDecorId);if(!e)return;const{eastM:t,northM:n,altitudeM:i}=Ya(e,this.ufoElement.currentTime),a=Math.hypot(t,n);if(a===0&&i===0)return;const r=Math.atan2(t,n)*180/Math.PI,o=Math.atan2(i-HT,a)*180/Math.PI;this.headingInput.value=String(Math.round(r*10)/10),this.pitchInput.value=String(Math.round(o*10)/10),this.updateObserver()}refreshDecorLightRigOptions(e){const t=e?sc.forKind(e.kind):[],n=document.createElement("option");n.value="",n.textContent=this.messages.decorLightsNone,this.decorLightRigSelect.replaceChildren(n,...t.map(a=>{const r=document.createElement("option");return r.value=a.id,r.textContent=a.name,r}));const i=e?.lights?.map(a=>a.id).join()??"";this.decorLightRigSelect.value=t.find(a=>a.create().map(r=>r.id).join()===i)?.id??""}updateDecorLightRig(){const e=this.ufoElement.sighting,t=e.decor.find(i=>i.id===this.currentDecorId);if(!t)return;const n=sc.byId(this.decorLightRigSelect.value);e.decor=e.decor.map(i=>i.id===t.id?{...i,lights:n?n.create():void 0}:i),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}syncDecorLitFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.shadow.activeElement===this.decorLitInput)return;const e=this.ufoElement.sighting.decor.find(t=>t.id===this.currentDecorId);e&&(this.decorLitInput.checked=Ml(e,this.ufoElement.currentTime))}updatePresetButtons(){for(const e of em)this.presetButtons[e]?.setAttribute("aria-pressed",String(e===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(e=this.defaultBounds()){return Ku(e,this.currentAppearance)}defaultBounds(){const e=this.ufoElement.canvasElement;return{x:e.width/2-Ta.width/2,y:e.height/2-Ta.height/2,width:Ta.width,height:Ta.height}}toggleRecording(){this.endDrag();const e=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),this.setCanvasCursor(void 0),e.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new nT(this.ufoElement.sighting.timeline,new iT(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),this.setCanvasCursor("record"),e.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0,this.deleteShapeButton.disabled=!0)}setRecordButtonLabel(e){this.recordButton.textContent=e?"⏹":"⏺";const t=e?this.messages.stop:this.messages.record;this.recordButton.title=t,this.recordButton.setAttribute("aria-label",t)}async loadLocaleMessages(){const e=Xr(Vs.preferencesFor(this),hm);e!=="en"&&(this.tagNames=new Ah(await q1(e)),this.showTags(),this.applyMessages(await X1(e)))}showTags(){this.tagsInput.value=this.ufoElement.sighting.event.tags?.map(e=>this.tagNames.name(e)).join(", ")??""}applyMessages(e){this.currentSourceId===cl&&this.shapeTitleInput.value===`${this.messages.shape} 1`?(this.messages=e,this.shapeTitleInput.value=`${this.messages.shape} 1`,this.updateShapeTitle()):this.messages=e,this.presetButtons.oval.textContent=e.oval,this.presetButtons.polygon.textContent=e.polygon,this.contextAddVertexButton.textContent=e.addVertex,this.contextDeleteVertexButton.textContent=e.deleteVertex,this.labelColor.textContent=e.color,this.labelTransparency.textContent=e.transparency,this.labelHalo.textContent=e.halo,this.labelBlur.textContent=e.blur,this.labelBrightness.textContent=e.brightness,this.labelShape.textContent=e.shape,this.labelShapeTitle.textContent=e.shapeTitle,this.labelUtcOffset.textContent=e.utcOffset,this.utcOffsetInput.placeholder=e.utcOffsetPlaceholder,this.labelObjectSize.textContent=e.objectSize,this.labelObjectDistance.textContent=e.objectDistance,this.objectSizeInput.placeholder=e.objectSizePlaceholder,this.objectDistanceInput.placeholder=e.objectDistancePlaceholder,this.labelDistanceHypothesis.textContent=e.distanceHypothesis,this.clearDistanceHypothesisButton.title=e.clearDistanceHypothesis,this.clearDistanceHypothesisButton.setAttribute("aria-label",e.clearDistanceHypothesis),this.refreshApparentSize(),this.labelSamplingRate.textContent=e.samplingRate,this.labelDuration.textContent=e.duration,this.durationInput.placeholder=e.durationPlaceholder,this.addShapeButton.title=e.addShape,this.addShapeButton.setAttribute("aria-label",e.addShape),this.deleteShapeButton.title=e.deleteShape,this.deleteShapeButton.setAttribute("aria-label",e.deleteShape),this.contextGroupButton.textContent=e.group,this.contextUngroupButton.textContent=e.ungroup,this.contextBringToFrontButton.textContent=e.bringToFront,this.contextSendToBackButton.textContent=e.sendToBack,this.contextDeleteButton.textContent=e.contextMenuDelete,this.exportButton.textContent=e.export,this.labelImportFile.textContent=e.importFile,this.labelImportUrl.textContent=e.importUrl,this.importUrlInput.placeholder=e.importUrlPlaceholder,this.importUrlButton.textContent=e.importButton,this.labelWitnessAge.textContent=e.witnessAge,this.labelWitnessOccupation.textContent=e.witnessOccupation,this.labelTestimonySource.textContent=e.testimonySource,this.labelTestimonyFollowedUp.textContent=e.testimonyFollowedUp;for(const[i,a]of[["option-source-unknown",e.testimonySourceUnknown],["option-source-on-site",e.testimonySourceOnSite],["option-source-interview",e.testimonySourceInterview],["option-source-telephone",e.testimonySourceTelephone],["option-source-questionnaire",e.testimonySourceQuestionnaire],["option-source-letter",e.testimonySourceLetter],["option-source-press",e.testimonySourcePress],["option-followed-unknown",e.testimonyUnknown],["option-followed-yes",e.testimonyYes],["option-followed-no",e.testimonyNo]]){const r=this.shadow.getElementById(i);r&&(r.textContent=a)}this.labelNarrativeKey.textContent=e.narrativeKey.replace("{source}",ws[0].name),this.labelNarrativeWorkspace.textContent=e.narrativeWorkspace,this.narrativeWorkspaceInput.placeholder=e.narrativeWorkspacePlaceholder,this.narrativeWorkspaceInput.title=e.narrativeWorkspaceHint,this.labelNarrativeRemember.textContent=e.narrativeRemember,this.narrativeStopButton.textContent=e.narrativeStop,this.narrativeDraftButton.textContent=e.narrativeDraft,this.descriptionInput.placeholder=e.narrativePlaceholder,this.syncNarrativeEnabled(),this.refreshSourceRows(),this.refreshTimeZoneOptions(),this.labelPlaceName.textContent=e.placeName,this.placeNameInput.placeholder=e.placeNamePlaceholder,this.searchPlaceButton.textContent=e.searchPlace,this.labelPlaceMatch.textContent=e.placeMatch,this.labelLatitude.textContent=e.latitude,this.labelLongitude.textContent=e.longitude,this.labelHeading.textContent=e.heading,this.headingInput.placeholder=e.headingPlaceholder,this.labelPitch.textContent=e.pitch,this.labelRoll.textContent=e.roll,this.labelElevation.textContent=e.elevation,this.labelObservationTime.textContent=e.observationTime,this.labelObservationEndTime.textContent=e.observationEndTime,this.obsTimeInput.placeholder=e.edtfPlaceholder,this.obsTimeInput.title=e.observationTimeHint,this.obsEndTimeInput.placeholder=e.edtfPlaceholder,this.obsEndTimeInput.title=e.observationEndTimeHint,this.presetsGroup.setAttribute("aria-label",e.presetsGroupLabel),this.labelDecor.textContent=e.decor,this.labelDecorGroup.textContent=e.decor,this.optionDecorBuilding.textContent=e.decorBuilding,this.optionDecorTree.textContent=e.decorTree,this.optionDecorCrop.textContent=e.decorCrop,this.optionDecorMound.textContent=e.decorMound,this.optionDecorStreetlight.textContent=e.decorStreetlight,this.optionDecorVehicle.textContent=e.decorVehicle,this.optionDecorAircraft.textContent=e.decorAircraft,this.optionDecorEntity.textContent=e.decorEntity,this.labelDecorLights.textContent=e.decorLights,this.labelDecorAltitude.textContent=e.decorAltitude,this.showMeteorButton.title=e.showMeteor,this.showMeteorButton.setAttribute("aria-label",e.showMeteor),this.showCometButton.title=e.showComet,this.showCometButton.setAttribute("aria-label",e.showComet),this.lookAtDecorButton.title=e.lookAtDecor,this.lookAtDecorButton.setAttribute("aria-label",e.lookAtDecor),this.optionDecorWitness.textContent=e.decorWitness,this.deleteDecorButton.title=e.deleteDecor,this.deleteDecorButton.setAttribute("aria-label",e.deleteDecor),this.labelDecorTitle.textContent=e.decorTitle,this.labelDecorEast.textContent=e.decorEast,this.labelDecorNorth.textContent=e.decorNorth,this.labelDecorHeading.textContent=e.decorHeading,this.labelDecorColor.textContent=e.decorColor,this.labelDecorLit.textContent=e.decorLit,this.labelDecorSightingUrl.textContent=e.decorSightingUrl,this.contextViewTestimonyButton.textContent=e.viewTestimony,this.labelContextMasks.textContent=`${e.masks} ▸`,this.addDecorWitnessButton.textContent=e.addWitness,this.addDecorBuildingButton.title=e.addDecor,this.addDecorBuildingButton.setAttribute("aria-label",e.addDecor),this.confirmAcceptButton.textContent=e.confirmAccept,this.confirmDeclineButton.textContent=e.confirmDecline,this.labelMilestones.textContent=e.milestones,this.labelMilestoneLabel.textContent=e.milestoneLabel,this.labelMilestoneNote.textContent=e.milestoneNote;for(const[i,a]of[[this.addMilestoneButton,e.addMilestone],[this.deleteMilestoneButton,e.deleteMilestone]])i.title=a,i.setAttribute("aria-label",a);this.labelDecorWidth.textContent=e.decorWidth,this.labelDecorLength.textContent=e.decorLength,this.labelDecorHeight.textContent=e.decorHeight,this.labelDecorModel.textContent=e.decorModel,this.labelDecorModelAdvanced.textContent=e.decorModelAdvanced,this.labelDecorModelUrl.textContent=e.decorModelUrl,this.labelDecorModelTitle.textContent=e.decorModelTitle,this.labelDecorModelAuthor.textContent=e.decorModelAuthor,this.labelDecorModelLicense.textContent=e.decorModelLicense,this.labelDecorModelSource.textContent=e.decorModelSource,this.labelDecorFloors.textContent=e.decorFloors,this.labelDecorOccupiedFloor.textContent=e.decorOccupiedFloor,this.labelDecorWitnessSide.textContent=e.decorWitnessSide,this.labelDecorWindows.textContent=e.decorWindows,this.optionWitnessSideNone.textContent=e.decorWitnessSideNone;const t={front:e.decorSideFront,behind:e.decorSideBehind,left:e.decorSideLeft,right:e.decorSideRight,"front-left":e.decorSideFrontLeft,"front-right":e.decorSideFrontRight,"behind-left":e.decorSideBehindLeft,"behind-right":e.decorSideBehindRight};for(const i of Qs)this.labelDecorSide[i].textContent=t[i],this.optionWitnessSide[i].textContent=t[i];this.refreshDecorList(),this.labelWitnessId.textContent=e.witnessId,this.labelWitnessDirName.textContent=e.witnessDirName,this.labelWitnessTitle.textContent=e.witnessTitle,this.labelWitnessLastName.textContent=e.witnessLastName,this.labelWitnessFirstNames.textContent=e.witnessFirstNames,this.witnessFirstNamesInput.placeholder=e.tagsPlaceholder,this.labelCaseId.textContent=e.caseId,this.labelDescription.textContent=e.description,this.labelTags.textContent=e.tags,this.tagsInput.placeholder=e.tagsPlaceholder,this.labelShapeGroup.textContent=e.shapeGroup,this.labelTemporalGroup.textContent=e.temporalGroup,this.labelLocationGroup.textContent=e.locationGroup,this.labelObservationGroup.textContent=e.observationGroup,this.labelWitnessGroup.textContent=e.witnessGroup,this.labelWeatherGroup.textContent=e.weather,this.refreshTimeQualifierOptions(),this.edtfModeButton.title=e.edtfModeTitle,this.edtfModeButton.setAttribute("aria-label",e.edtfModeTitle),this.paramSummaryBuilder=new tf(e,this.showerLanguage(),this.said,this.tagNames),this.refreshParamSummary();const n=this.skyDetailsButton.getAttribute("aria-expanded")==="true";this.skyDetailsButton.title=n?e.skyDetailsHide:e.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title),this.labelCloudCover.textContent=e.cloudCover,this.labelHighCloud.textContent=e.highCloudCover,this.labelIceAlignment.textContent=e.iceCrystalAlignment,this.labelFNumber.textContent=e.aperture,this.labelExposure.textContent=e.exposure,this.labelFocusDistance.textContent=e.focusDistance,this.syncOpticsFromInstrument(),this.labelCloudDarkness.textContent=e.cloudDarkness,this.labelCloudBase.textContent=e.cloudBase,this.labelPrecipitationType.textContent=e.precipitationType,this.optionPrecipitationNone.textContent=e.precipitationNone,this.optionPrecipitationRain.textContent=e.precipitationRain,this.optionPrecipitationSnow.textContent=e.precipitationSnow,this.optionPrecipitationHail.textContent=e.precipitationHail,this.labelPrecipitationIntensity.textContent=e.precipitationIntensity,this.labelWindDirection.textContent=e.windDirection,this.labelWindSpeed.textContent=e.windSpeed,this.labelStorm.textContent=e.storm,this.labelWeatherInferred.textContent=e.weatherInferred,this.syncWeatherSourceState(),this.labelSoundGroup.textContent=e.soundGroup,this.labelSoundKind.textContent=e.soundKind,this.labelSoundVolume.textContent=e.soundVolume,this.labelSoundPitch.textContent=e.soundPitch,this.labelSoundSrc.textContent=e.soundSrc,this.soundSrcInput.placeholder=e.soundSrcPlaceholder;for(const[i,a]of this.soundKindOptions)a.textContent=this.soundKindLabel(i,e);this.labelInstrument.textContent=e.instrument,this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.setRecordButtonLabel(this.isRecording),this.syncPlaybackControls()}onPointerDown(e){if(this.isRecording){this.onPointerMove(e);return}const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.ufoElement.playbackState==="playing";if(this.selectedSourceIds.size>1){const l=new ic(this.selectedMembers()),c=nt.hitTestHandle({bounds:l.bounds(),angle:0},t);if(c==="rotate"){if(a)return;this.dragState={kind:"group-rotate",group:l,startPointer:t},this.startDragListening();return}if(c){if(a)return;this.dragState={kind:"group-resize",group:l,handle:c},this.startDragListening();return}}else{const l=n.getInterpolatedShapeAt(i,this.currentSourceId),c=l?.kind==="polygon"?nt.hitTestVertex(l,t):void 0;if(l?.kind==="polygon"&&c!==void 0){if(a)return;this.dragState={kind:"vertex",sourceId:this.currentSourceId,original:l,vertexIndex:c},this.startDragListening();return}const h=l&&nt.hitTestHandle(l,t);if(l&&h){if(a)return;this.beginDrag(h==="rotate"?"rotate":"resize",this.currentSourceId,l,t,h);return}}const r=this.ufoElement.shapeAt(t.x,t.y,Z0);if(!r){const l=this.pickDecorAt(e);if(l!==void 0){this.selectDecor(l);return}a||this.beginCameraDrag(t);return}if(this.revealShapePanel(),e.shiftKey?this.toggleUnitSelection(r.sourceId):this.selectedSourceIds.has(r.sourceId)||this.selectUnit(r.sourceId),a)return;const o=[...this.selectedSourceIds].map(l=>({sourceId:l,original:l===r.sourceId?r.shape:n.getInterpolatedShapeAt(i,l)??r.shape}));this.dragState={kind:"move",sources:o,startPointer:t},this.startDragListening()}revealShapePanel(){const e=this.groupTabs.find(t=>t.getAttribute("aria-controls")==="group-shape");e&&this.toggleGroup(e,!0)}selectedMembers(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime;return[...this.selectedSourceIds].map(n=>({sourceId:n,shape:e.getInterpolatedShapeAt(t,n)})).filter(n=>!!n.shape)}selectUnit(e){const t=this.ufoElement.sighting.timeline.groupMembers(e)??[e];t.length===this.selectedSourceIds.size&&t.every(n=>this.selectedSourceIds.has(n))&&e===this.currentSourceId||(this.selectedSourceIds=new Set(t),this.currentSourceId=e,this.refreshSourceList(),this.onSelectionOrTimeChanged())}toggleUnitSelection(e){const t=this.ufoElement.sighting.timeline,n=t.groupMembers(e)??[e];if(n.every(a=>this.selectedSourceIds.has(a))){if(n.length>=this.selectedSourceIds.size)return;for(const a of n)this.selectedSourceIds.delete(a);if(!this.selectedSourceIds.has(this.currentSourceId)){const a=t.sourceIds;this.currentSourceId=[...this.selectedSourceIds].sort((r,o)=>a.indexOf(r)-a.indexOf(o)).pop()}}else{for(const a of n)this.selectedSourceIds.add(a);this.currentSourceId=e}this.refreshSourceList(),this.onSelectionOrTimeChanged()}onContextMenu(e){if(e.preventDefault(),this.isRecording||this.ufoElement.playbackState==="playing")return;this.hideContextMenu(),this.hideDecorContextMenu();const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.selectedSourceIds.size===1?n.getInterpolatedShapeAt(i,this.currentSourceId):void 0,o=a?.kind==="polygon"&&nt.hitTestVertex(a,t)!==void 0?{sourceId:this.currentSourceId}:this.ufoElement.shapeAt(t.x,t.y,Z0);if(o){this.selectedSourceIds.has(o.sourceId)||this.selectUnit(o.sourceId),this.currentSourceId=o.sourceId,this.contextMenuPoint=t,this.showContextMenu(e.clientX,e.clientY);return}const l=this.pickDecorAt(e),c=l?this.ufoElement.sighting.decor.find(h=>h.id===l):void 0;c&&this.showDecorContextMenu(e.clientX,e.clientY,c)}pickDecorAt(e){const n=this.ufoElement.canvasElement.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(e.clientX-n.left)/n.width*2-1,a=-((e.clientY-n.top)/n.height*2-1);return this.sceneElement.pickDecorAt(i,a)}showContextMenu(e,t){this.contextMenu.style.left=`${e}px`,this.contextMenu.style.top=`${t}px`,this.contextMenu.hidden=!1;const n=this.ufoElement.sighting.timeline.sourceIds,i=n.filter(f=>this.selectedSourceIds.has(f)),a=n.length<=i.length,r=i.length>0&&n.slice(n.length-i.length).every(f=>this.selectedSourceIds.has(f)),o=i.length>0&&n.slice(0,i.length).every(f=>this.selectedSourceIds.has(f));this.contextBringToFrontButton.disabled=a||r,this.contextSendToBackButton.disabled=a||o,this.contextBringToFrontButton.title=a?this.messages.onlyOneShape:r?this.messages.alreadyAtFront:"",this.contextSendToBackButton.title=a?this.messages.onlyOneShape:o?this.messages.alreadyAtBack:"",this.contextGroupButton.disabled=this.selectedSourceIds.size<2,this.contextGroupButton.title=this.contextGroupButton.disabled?this.messages.needTwoShapesToGroup:"";const l=this.ufoElement.sighting.timeline.groupMembers(this.currentSourceId)!==void 0;this.contextUngroupButton.disabled=!l,this.contextUngroupButton.title=l?"":this.messages.notGrouped,this.contextDeleteButton.disabled=this.deleteShapeButton.disabled,this.contextDeleteButton.title=this.contextDeleteButton.disabled?this.messages.onlyOneShape:"";const c=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId),h=this.selectedSourceIds.size===1&&c?.kind==="polygon";this.contextAddVertexButton.disabled=!h,this.contextAddVertexButton.title=h?"":this.messages.notAPolygon;const d=h&&this.contextMenuPoint?nt.hitTestVertex(c,this.contextMenuPoint):void 0,u=h&&c.points.length<=3;this.contextDeleteVertexButton.disabled=!h||d===void 0||u,this.contextDeleteVertexButton.title=h?u?this.messages.tooFewVertices:"":this.messages.notAPolygon,document.addEventListener("click",this.handleOutsideContextMenuClick)}hideContextMenu(){this.contextMenu.hidden=!0,this.contextMenuPoint=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}handleOutsideContextMenuClick=e=>{e.composedPath().includes(this.contextMenu)||e.composedPath().includes(this.decorContextMenu)||(this.hideContextMenu(),this.hideDecorContextMenu())};showDecorContextMenu(e,t,n){this.contextMenuDecorId=n.id,this.decorContextMenu.style.left=`${e}px`,this.decorContextMenu.style.top=`${t}px`,this.decorContextMenu.hidden=!1,this.contextViewTestimonyButton.disabled=!n.sightingUrl,this.contextViewTestimonyButton.title=n.sightingUrl?"":this.messages.noWitnessRecording,this.refreshContextMasksSubmenu(n),document.addEventListener("click",this.handleOutsideContextMenuClick)}hideDecorContextMenu(){this.decorContextMenu.hidden=!0,this.contextMenuDecorId=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}refreshContextMasksSubmenu(e){this.contextMasksSubmenu.innerHTML="";for(const t of this.ufoElement.sighting.timeline.sourceIds){const n=document.createElement("label"),i=document.createElement("input");i.type="checkbox",i.checked=e.occludesSourceIds?.includes(t)??!1,i.addEventListener("change",()=>this.updateDecorOccludesShape(e.id,t,i.checked)),n.appendChild(i),n.appendChild(document.createTextNode(this.shapeLabel(t))),this.contextMasksSubmenu.appendChild(n)}}updateDecorOccludesShape(e,t,n){const i=this.ufoElement.sighting;i.decor=i.decor.map(a=>{if(a.id!==e)return a;const r=n?[...new Set([...a.occludesSourceIds??[],t])]:(a.occludesSourceIds??[]).filter(o=>o!==t);return{...a,occludesSourceIds:r.length>0?r:void 0}}),this.ufoElement.refresh()}viewWitnessTestimony(){const e=this.ufoElement.sighting.decor.find(t=>t.id===this.contextMenuDecorId);this.hideDecorContextMenu(),e?.sightingUrl&&this.importFromUrl(e.sightingUrl)}addVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(n?.kind!=="polygon")return;const i=nt.insertVertexNear(n,e);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:i}]),this.ufoElement.refresh()}deleteVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(n?.kind!=="polygon")return;const i=nt.hitTestVertex(n,e);if(i===void 0)return;const a=nt.deleteVertex(n,i);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:a}]),this.ufoElement.refresh()}bringSelectedToFront(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(n=>this.selectedSourceIds.has(n)))e.bringToFront(t);this.hideContextMenu(),this.ufoElement.refresh()}sendSelectedToBack(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(n=>this.selectedSourceIds.has(n)).reverse())e.sendToBack(t);this.hideContextMenu(),this.ufoElement.refresh()}groupSelected(){this.selectedSourceIds.size<2||(this.ufoElement.sighting.timeline.group([...this.selectedSourceIds]),this.hideContextMenu(),this.ufoElement.refresh())}ungroupSelected(){this.ufoElement.sighting.timeline.ungroup(this.currentSourceId),this.selectedSourceIds=new Set([this.currentSourceId]),this.hideContextMenu(),this.ufoElement.refresh()}beginDrag(e,t,n,i,a){this.dragState={kind:e,sourceId:t,original:n,handle:a,startPointer:i},this.startDragListening()}beginCameraDrag(e){const t=this.isWitnessInsideDecor();this.cameraDragState={startPointer:e,startHeadingDeg:t?this.indoorLookYawDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:t?this.indoorLookPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0,insideDecor:t},t||this.sceneElement.setCompassForced(!0),this.setCanvasCursor("panning"),this.startDragListening()}isWitnessInsideDecor(){return this.ufoElement.sighting.decor.some(e=>e.witnessSide!==void 0&&Ra(e.kind))}syncIndoorLookReset(){const e=this.ufoElement.sighting.decor.find(n=>n.witnessSide!==void 0&&Ra(n.kind)),t=e?`${e.id}:${e.witnessSide}`:void 0;t!==this.lastInhabitedKey&&(this.lastInhabitedKey=t,this.indoorLookYawDeg=0,this.indoorLookPitchDeg=0,this.sceneElement.setIndoorLook(0,0))}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(e){if(this.cameraDragState){this.onCameraDragPointerMove(e);return}if(!this.dragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.currentTime;if(this.dragState.kind==="move"){const{sources:i,startPointer:a}=this.dragState,r=t.x-a.x,o=t.y-a.y,l=i.map(({sourceId:c,original:h})=>({sourceId:c,shape:{...h,bounds:{...h.bounds,x:h.bounds.x+r,y:h.bounds.y+o}}}));this.commitShapes(n,l)}else if(this.dragState.kind==="group-resize"){const{group:i,handle:a}=this.dragState;this.commitShapes(n,i.resize(a,t))}else if(this.dragState.kind==="group-rotate"){const{group:i,startPointer:a}=this.dragState;this.commitShapes(n,i.rotate(t,a))}else if(this.dragState.kind==="vertex"){const{sourceId:i,original:a,vertexIndex:r}=this.dragState,o=nt.moveVertex(a,r,t);this.commitShapes(n,[{sourceId:i,shape:o}])}else{const{kind:i,sourceId:a,original:r,handle:o}=this.dragState,l=i==="resize"?nt.resizeShape(r,o,t):nt.rotateShape(r,t);this.commitShapes(n,[{sourceId:a,shape:l}])}this.ufoElement.refresh()}onCameraDragPointerMove(e){if(!this.cameraDragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{startPointer:n,startHeadingDeg:i,startPitchDeg:a,insideDecor:r}=this.cameraDragState,o=i+(t.x-n.x)*j0,l=Math.max(-90,Math.min(90,a-(t.y-n.y)*j0));if(r){this.indoorLookYawDeg=o,this.indoorLookPitchDeg=l,this.sceneElement.setIndoorLook(o,l),this.ufoElement.refresh();return}this.headingInput.value=String(this.rounded(o)),this.pitchInput.value=String(this.rounded(l)),this.updateObserver()}endDrag(){!this.dragState&&!this.cameraDragState||(this.cameraDragState&&!this.cameraDragState.insideDecor&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,this.setCanvasCursor(this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}nudgeBounds(e,t){const n={...e};if(t.shiftKey){switch(t.key){case"ArrowLeft":n.width=Math.max(8,n.width-cs);break;case"ArrowRight":n.width+=cs;break;case"ArrowUp":n.height=Math.max(8,n.height-cs);break;case"ArrowDown":n.height+=cs;break}n.x-=(n.width-e.width)/2,n.y-=(n.height-e.height)/2}else switch(t.key){case"ArrowLeft":n.x-=cs;break;case"ArrowRight":n.x+=cs;break;case"ArrowUp":n.y-=cs;break;case"ArrowDown":n.y+=cs;break}return n}moveOrResizeSelectedShapes(e){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.currentTime,n=this.selectedMembers();if(n.length!==0){if(e.preventDefault(),n.length===1){const{sourceId:i,shape:a}=n[0];this.commitShapes(t,[{sourceId:i,shape:{...a,bounds:this.nudgeBounds(a.bounds,e)}}])}else{const i=new ic(n),a=this.nudgeBounds(i.bounds(),e);this.commitShapes(t,i.scaleTo(a))}this.ufoElement.refresh()}}updateHoverCursor(e){this.isRecording||this.dragState||this.cameraDragState||(this.hoverCursor=this.hoverCursorAt(e),this.setCanvasCursor(this.hoverCursor))}hoverCursorAt(e){const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.ufoElement.playbackState!=="playing";if(a)if(this.selectedSourceIds.size>1){const r=nt.hitTestHandle({bounds:new ic(this.selectedMembers()).bounds(),angle:0},t);if(r)return this.cursorForHandle(r,0)}else{const r=n.getInterpolatedShapeAt(i,this.currentSourceId);if(r?.kind==="polygon"&&nt.hitTestVertex(r,t)!==void 0)return"vertex";const o=r&&nt.hitTestHandle(r,t);if(r&&o)return this.cursorForHandle(o,r.angle)}return n.hitTest(i,t.x,t.y)?a?"move":"select":this.pickDecorAt(e)!==void 0?"select":a?"pan":void 0}cursorForHandle(e,t){return e==="rotate"?"rotate":`resize-${nt.resizeAxisFor(e,t)}`}setCanvasCursor(e){const t=this.ufoElement.canvasElement;e?t.dataset.cursor=e:delete t.dataset.cursor}onPointerMove(e){if(!this.isRecording){this.updateHoverCursor(e);return}const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top;this.recorder?.onPointerMove(i,a),this.ufoElement.renderer.clear(t.width,t.height),this.ufoElement.renderer.paintShape(rm(this.buildPrototype({x:0,y:0,width:Ta.width,height:Ta.height}),i,a))}canvasPointFromEvent(e){const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(!(n.width===0||n.height===0))return{x:(e.clientX-n.left)/n.width*t.width,y:(e.clientY-n.top)/n.height*t.height}}}const YT={stated:"narrativeStated",derived:"narrativeDerived",assumed:"narrativeAssumed"},tm="rr0-sighting-editor",nm="rr0-ufo-recorder";class KT extends ut{}function $T(){ql(),customElements.get(tm)||customElements.define(tm,ut),customElements.get(nm)||customElements.define(nm,KT)}$T();export{_n as $,Zn as A,vt as B,ve as C,hb as D,Vi as E,rA as F,ft as G,Dt as H,tA as I,eA as J,Ze as K,no as L,sA as M,fo as N,Tt as O,lb as P,bs as Q,Tl as R,zr as S,ZT as T,nA as U,Re as V,Hm as W,iA as X,ml as Y,ln as Z,Qn as _,jT as a,QT as a0,ar as a1,zm as a2,aA as a3,Cy as a4,Dl as a5,gd as a6,Nl as a7,en as a8,Ym as a9,gu as aa,vu as ab,Qe as ac,vs as ad,to as ae,Ti as af,Yi as ag,JT as b,On as c,cA as d,Rl as e,Nn as f,lA as g,qe as h,R as i,qf as j,oA as k,hA as l,Ty as m,Bs as n,cc as o,Ih as p,Cv as q,At as r,Va as s,Wt as t,Bh as u,vn as v,Gm as w,Ki as x,ky as y,Vy as z};
7133
+ `;let ol;function P3(){if(ol)return ol;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),ol=new Ai(e),ol}function L3(s){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.getContext("2d"),i=128/2-2,a=128/2,r=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(a,r,i,0,Math.PI*2),n.fill();const c=Vl(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,d=i*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(a,r,i,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(a,r,i,-Math.PI/2,Math.PI/2,!1),n.ellipse(a,r,d,i,0,Math.PI/2,-Math.PI/2,u)):(n.arc(a,r,i,Math.PI/2,-Math.PI/2,!1),n.ellipse(a,r,d,i,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new Ai(t)}function N3(s){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(s,64,68),new Ai(e)}function uh(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const fh=7.5,Br=9;class fi{static cache=new Map;static load(e){let t=fi.cache.get(e);return t||(t=fetch(e).then(n=>n.arrayBuffer()).then(n=>fi.parse(n)),fi.cache.set(e,t)),t}static upTo(e,t){const n=e.filter((r,o)=>o===0||e[o-1].magnitudeLimit<t);if(n.length<=1)return fi.load(e[0].url);const i=n.map(r=>r.url).join(`
7134
+ `);let a=fi.cache.get(i);return a||(a=Promise.all(n.map(r=>fi.load(r.url))).then(r=>r.reduce((o,l)=>fi.concat(o,l))),fi.cache.set(i,a)),a}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*n,t),dec:new Float32Array(e,1*n,t),mag:new Float32Array(e,2*n,t),ci:new Float32Array(e,3*n,t)}}static concat(e,t){const n=(i,a)=>{const r=new Float32Array(i.length+a.length);return r.set(i,0),r.set(a,i.length),r};return{count:e.count+t.count,ra:n(e.ra,t.ra),dec:n(e.dec,t.dec),mag:n(e.mag,t.mag),ci:n(e.ci,t.ci)}}}const O3=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,k3=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,U3=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,F3=20,B3=1;class z3{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,n){if(this.requested={type:e,intensity:t,windSpeed:n},!this.context)return;this.paused&&(e="none",t=0,n=0);const i=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=i==="hail"?Math.min(1,t*1.3+.2):i==="rain"?t:0,i!==this.ambientKey){this.ambientKey=i;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(O3,this.ambientVolume).then(o=>this.applyIfCurrent(o,r,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/F3,1);const a=n>B3;if(a!==this.windActive){this.windActive=a;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,a&&this.startLoop(k3,this.windVolume).then(o=>this.applyIfCurrent(o,r,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:i}=this.requested;this.setAmbient(t,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(U3,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(e,t,n,i){if(t!==n()){e?.source.stop();return}i(e)}async startLoop(e,t){const n=this.context;if(n)try{const i=await this.getBuffer(e),a=n.createBufferSource();a.buffer=i,a.loop=!0;const r=n.createGain();return r.gain.value=t,a.connect(r).connect(n.destination),a.start(),{source:a,gain:r}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(e,t){const n=this.context;if(n)try{const i=await this.getBuffer(e),a=n.createBufferSource();a.buffer=i;const r=n.createGain();r.gain.value=t,a.connect(r).connect(n.destination),a.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${e}`);return i.arrayBuffer()}).then(i=>t.decodeAudioData(i)),this.buffers.set(e,n)),n}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class ki{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[i,a]=this.perifocalAxes(),r=Math.sqrt(ki.SUN_GM_AU3_PER_DAY2*(1+t)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(a,r),this.inverseSemiMajorAxis=(1-t)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,n=this.universalAnomaly(t),i=this.inverseSemiMajorAxis*n*n,a=this.elements.perihelionAu,r=1-n*n/a*ki.stumpffC(i),o=t-n*n*n/Math.sqrt(ki.SUN_GM_AU3_PER_DAY2)*ki.stumpffS(i);return{x:r*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:r*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),n=Math.sqrt(ki.SUN_GM_AU3_PER_DAY2)*Math.abs(e),i=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*ki.stumpffS(l)+c*o};let a=Math.max(1,n/this.elements.perihelionAu);for(;i(a)<n;)a*=2;let r=0;for(let o=0;o<ki.MAX_ITERATIONS&&a-r>1e-13*Math.max(1,a);o++){const l=(r+a)/2;i(l)<n?r=l:a=l}return t*(r+a)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(e),a=Math.sin(e),r=Math.cos(t),o=Math.sin(t),l=Math.cos(n),c=Math.sin(n);return[{x:i*r-a*o*l,y:a*r+i*o*l,z:o*c},{x:-i*o-a*r*l,y:-a*o+i*r*l,z:r*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const n=Math.sqrt(e);return(n-Math.sin(n))/(n*n*n)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const Bg=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class xl{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return Bg.filter(n=>Math.abs(t-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(n=>this.appearanceOf(n,e,t)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(e,t,n){const i=Yt(t),a=this.earthPositionAt(i),r=this.apparentPositionOf(e,2451545+i.tt,a),o=this.subtract(r,a),l=this.length(r),c=this.length(o),h=this.tailEndAt(e,r,a,l,i,t,n),d=this.horizontalOf(o,i,t,n);return{apparition:e,position:d,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},a)),magnitude:this.magnitudeAt(e,l,c)}}static magnitudeAt(e,t,n){const i=e.absoluteMagnitude+5*Math.log10(n)+2.5*e.activityExponent*Math.log10(t);return Math.max(i,e.peakMagnitude)}static tailEndAt(e,t,n,i,a,r,o){if(e.tailLengthAu===void 0)return{};const l=1+e.tailLengthAu/i,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(c,a,r,o),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,n){const i=this.orbitOf(e);let a=i.positionAt(t);for(let r=0;r<2;r++){const o=this.length(this.subtract(a,n))/this.LIGHT_SPEED_AU_PER_DAY;a=i.positionAt(t-o)}return a}static horizontalOf(e,t,n,i){const a=yl(F_(),new xt(e.x,e.y,e.z,t)),r=yl(B_(t),a),o=m_(t,new Iu(i.lat,i.lng,i.elevationM)),l=new xt(r.x-o.x,r.y-o.y,r.z-o.z,t),c=_g(l);return tr(c.ra,c.dec,n,i)}static earthPositionAt(e){return yl(U_(),gs(Me.Earth,e))}static julianDayOf(e){return 2451545+Yt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new ki(e.orbit);return this.orbits.set(e.id,n),n}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const n=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const H3=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Jr=6.5;class Xa{static activeAt(e){return H3.flatMap(t=>{const n=this.nearness(t,e);return n<=0?[]:[{shower:t,zhr:t.peakZhr*n,nearness:n}]})}static nearness(e,t){const n=this.dayOfYear(t),i=this.dayOfYear(this.asDate(e.start)),a=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(n,a),l=this.wrappedDelta(a,i),c=this.wrappedDelta(r,a);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,n,i=Jr){if(t<=0)return 0;const a=Jr-i;return e*Math.sin(t*Math.PI/180)/Math.pow(n,a)}static radiantPosition(e,t,n){return tr(e.radiantRaHours,e.radiantDecDeg,t,n)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const n=e-t;return n>182?n-365:n<-182?n+365:n}}class Et{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Yt(e),i=new Tu(0,f_(e).elon-90,1),a=yl(z_(n),Sg(i,n)),r=_g(a);return tr(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=Jr){const n=Et.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),i=Jr-t;return(Et.QUIET_RATE_PER_HOUR+n)/Math.pow(Et.POPULATION_INDEX,i)}static schedule(e){const t=new Ag(e.seed^1542469173);return Xs.schedule(e).map(n=>{const i=Et.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),a=n.fromRadiantDeg*Math.PI/180,r=Et.turnAround(i,t.between(0,360)),o={x:i.x*Math.cos(a)+r.x*Math.sin(a),y:i.y*Math.cos(a)+r.y*Math.sin(a),z:i.z*Math.cos(a)+r.z*Math.sin(a)};return{...n,radiant:Et.toHorizontal(o),bearingDeg:Et.bearingFrom(o,i)}})}static turnAround(e,t){const[n,i]=Et.basisAround(e),a=t*Math.PI/180;return{x:n.x*Math.cos(a)+i.x*Math.sin(a),y:n.y*Math.cos(a)+i.y*Math.sin(a),z:n.z*Math.cos(a)+i.z*Math.sin(a)}}static bearingFrom(e,t){const[n,i]=Et.basisAround(e),a=e.x*t.x+e.y*t.y+e.z*t.z,r=Et.normalise({x:t.x-e.x*a,y:t.y-e.y*a,z:t.z-e.z*a});return(Math.atan2(r.x*i.x+r.y*i.y+r.z*i.z,r.x*n.x+r.y*n.y+r.z*n.z)*180/Math.PI%360+360)%360}static basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Et.normalise(Et.cross(e,t));return[n,Et.normalise(Et.cross(e,n))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=Et.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Et.turnAround(t,e.bearingDeg),i=e.fromRadiantDeg*Math.PI/180;return Et.toHorizontal({x:t.x*Math.cos(i)+n.x*Math.sin(i),y:t.y*Math.cos(i)+n.y*Math.sin(i),z:t.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,i=Math.cos(t);return{x:i*Math.sin(n),y:Math.sin(t),z:-i*Math.cos(n)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}class G3{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=et.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=et.sizeMAt(t.inFrontM,e);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:et.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:et.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class qa{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*qa.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const n=qa.degOver(e)/t;return n<1?1:Math.min(qa.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class rn{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return qa.DEG_PER_SECOND*3600}static graspOf(e,t={}){const n=t.exposureSeconds??e.exposureSeconds,i=t.fNumber??e.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return rn.EYE;const a=t.focalLengthMm??e.frame?.focalLengthMm??rn.UNKNOWN_CAMERA_FOCAL_MM,r=a/i,o=rn.resolutionArcsec(e,a,r);return{apertureMm:r,exposureSeconds:Math.min(n,rn.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,n){const a=(e.detailUm??rn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*rn.ARCSEC_PER_RADIAN,r=1.22*rn.WAVELENGTH_M/(n/1e3)*rn.ARCSEC_PER_RADIAN;return Math.max(a,r)}static trailLimitedSeconds(e){return e/rn.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const n=rn.graspOf(e,t),i=rn.EYE,a=(n.apertureMm/i.apertureMm)**2,r=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(a*r*o)}static gainFor(e,t){const n=t.fieldOfViewDeg===void 0?void 0:st.focalLengthMmFor(e,t.fieldOfViewDeg);return rn.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:n,exposureSeconds:t.exposureSeconds})}}class Ui{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(e,t,n,i,a){if(!(i>0))return 1;const r=a>0?Ui.travelDegOver(e,t,n,n+i*1e3)/a/Ui.PIXELS_PER_INSTANT:0,o=Ui.flashesOver(e,i)*Ui.INSTANTS_PER_FLASH,l=Math.ceil(Math.max(r,o));return l<2?1:Math.min(Ui.MAX_INSTANTS,l)}static travelDegOver(e,t,n,i){let a=0;for(const r of e){if(!r.track||r.track.length<2)continue;const o=Ui.directionAt(r,t,n),l=Ui.directionAt(r,t,i),c=Math.min(1,Math.max(-1,o.x*l.x+o.y*l.y+o.z*l.z));a=Math.max(a,Math.acos(c)*180/Math.PI)}return a}static flashesOver(e,t){let n=0;for(const i of e)for(const a of i.lights??[])a.pattern.kind==="flash"&&(n=Math.max(n,a.pattern.perMinute));return n/60*t}static directionAt(e,t,n){const i=Ya(e,n),a=i.eastM,r=i.altitudeM-t,o=i.northM,l=Math.hypot(a,r,o);return l===0?{x:0,y:1,z:0}:{x:a/l,y:r/l,z:o/l}}}const H0=111320,_r=Math.PI/180,V3=1.02,W3=1;class zr{static of(e,t){const n=zr.sightings(e,t);if(n.length<2)return;const i=zr.baseline(n);if(!i)return;const{near:a,far:r,closedM:o}=i,l=Math.tan(r.widthDeg/2*_r)===0?0:Math.tan(a.widthDeg/2*_r)/Math.tan(r.widthDeg/2*_r);if(l<V3)return;const c=o/(l-1),h=et.sizeMAt(c,a.widthDeg),d=n.map(u=>({t:u.t,m:et.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:r.t,toT:a.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===t)?.shape,a=i?.angular?.widthDeg,r=bt(e,n.t);return a===void 0||a<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:n.t,widthDeg:a,lat:r.lat,lng:r.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??r.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(e){let t;for(const n of e)for(const i of e){if(n.t>=i.t)continue;const a=zr.closedAlongSight(n,i),[r,o,l]=a>=0?[i,n,a]:[n,i,-a];l<W3||r.widthDeg<=o.widthDeg||(!t||l>t.closedM)&&(t={near:r,far:o,closedM:l})}return t}static closedAlongSight(e,t){const n=(t.lat-e.lat)*H0,i=(t.lng-e.lng)*H0*Math.cos(e.lat*_r),a=(e.sightAzimuthDeg??0)*_r;return n*Math.cos(a)+i*Math.sin(a)}}class fn{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:fn.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:fn.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:fn.atLeastNearest(e.derivedM),basis:"derived"};const t=fn.largest(e.range?.minM,e.crossing?.behindM),n=fn.smallest(e.range?.maxM,e.crossing?.inFrontM),i=t===void 0?void 0:t*fn.MARGIN,a=n===void 0?void 0:n/fn.MARGIN;return i!==void 0&&a!==void 0?{distanceM:fn.atLeastNearest(i<=a?Math.sqrt(i*a):i),basis:"bounded"}:i!==void 0?{distanceM:fn.atLeastNearest(i),basis:"bounded"}:a!==void 0&&a<fn.CONVENTIONAL_M?{distanceM:fn.atLeastNearest(a),basis:"bounded"}:{distanceM:fn.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(fn.NEAREST_M,e)}static largest(...e){const t=e.filter(n=>n!==void 0&&n>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(n=>n!==void 0&&n>0);return t.length===0?void 0:Math.min(...t)}}ql();const X3={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},q3=["en","fr"],Y3={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},K3={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},G0="comet:",$3={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},Z3=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,J3=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,j3=-18,Q3={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},ph={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class eT extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass",Ws,ka]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new z3;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(e.clientX-n.left)/n.width*t.width,a=(e.clientY-n.top)/n.height*t.height;if(this.ufoElement.hasVisibleShapeAt(i,a)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-n.left)/n.width*2-1,o=-((e.clientY-n.top)/n.height*2-1),l=Xr(Vs.preferencesFor(this),q3),c=this.sceneRenderer.pickBodyAt(r,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));return}const h=this.sceneRenderer.pickDecorAt(r,o),d=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(d){this.showHoverTooltip(e,this.said.read(d.title)||$3[d.kind][l]);return}const u=this.sceneRenderer.pickStarAt(r,o);if(u){const f=u.star.mag,g=u.altitudeDeg,v=(g<0?K3:Y3)[l];this.showHoverTooltip(e,v.replace("{name}",u.star.name[l]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(G0)?e.slice(G0.length):void 0;return(n?Bg.find(a=>a.id===n):void 0)?.name[t]??X3[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const e=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),e)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Fs(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs)};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${av}</style>${sv}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ui(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Dh),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",t=>this.lookToward(t.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&n!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&n!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),(e===Ws||e===ka)&&n!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[Ws,ka])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=bt(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=gn(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const a=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((a-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Kd.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=et.CANVAS_HEIGHT_PX,n=st.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=n,this.sceneRenderer.resize(t,n)}async loadStars(){const e=[{magnitudeLimit:fh,url:this.getAttribute("star-catalog-src")??Z3},{magnitudeLimit:Br,url:this.getAttribute("deep-star-catalog-src")??J3}],t=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=t>fh?Br:fh;const i=await fi.upTo(e,t);n===this.starCatalogRequest&&(this.starCatalog=i,this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Br||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=rn.gainFor(e.instrument,{fNumber:bt(e,0)?.fNumber,fieldOfViewDeg:en.fovOf(e,0),exposureSeconds:e.exposure});return Or(j3,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=this.exposureSeconds(),n=this.degreesPerPixelAt(e),i=qa.instants(t,n),a=Math.max(i,this.ufoElement.exposureTimes(e).length,Ui.instants(this.ufoElement.sighting.decor,bt(this.ufoElement.sighting,e)?.elevationM??0,e,t,n));if(a<=1){this.sceneRenderer.setExposure(1);return}const r=t*1e3;this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e+r*o/a,{sky:Math.floor(o*i/a)!==Math.floor((o-1)*i/a),stepMs:r/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:en.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const n=this.ufoElement.sighting;this.setWeather(Fs(n,e)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,e),this.sceneRenderer.setDecor(n.decor);const i=bt(n,e);if(this.sceneRenderer.setObserverPose(i??ph),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(rn.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:en.fovOf(n,e),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Gt.of(n)?.offsetAt(e)??Gt.STILL),this.sceneRenderer.updateDecorAnchoring(bt(n,0),i,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(e),t&&!t.sky)return;const a=i?.lat??ph.lat,r=i?.lng??ph.lng,o=Va(n.event.time??{},r,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(Q3);return}const l=new Date(o.getTime()+e),c={lat:a,lng:r,elevationM:i?.elevationM??0},h=`${l.getTime()}|${a}|${r}|${c.elevationM}|${this.starCatalog?this.starCatalogDepth:0}`;if(h===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=h;const d={...On("Sun",l,c),magnitude:Jc("Sun",l)},u={...On("Moon",l,c),phase:Hl(l),magnitude:Jc("Moon",l)},f=H_.map(g=>({body:g,position:On(g,l,c),magnitude:Jc(g,l)}));this.sceneRenderer.setAstronomy({sun:d,moon:u,planets:f,comet:this.cometAt(l,c),stars:this.starCatalog?{catalog:this.starCatalog,date:l,observer:c}:void 0,frame:{date:l,observer:c}}),this.ufoElement.setSunAltitude(d.altitudeDeg)}cometAt(e,t){const n=xl.brightestAt(e,t);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const n=t.timeline,i=this.ufoElement.canvasElement,a=this.ufoElement.frameShiftPx,r=this.projectionAt(e),o=new Map,l=new Map,c=new Set;for(const v of n.sourceIds){const p=n.getInterpolatedShapeAt(e,v);if(!p)continue;const m={...p,bounds:{...p.bounds,x:p.bounds.x+a.x,y:p.bounds.y+a.y}};o.set(v,m);const S=p.aim?this.sceneRenderer.screenPointOf($n.directionOf(p.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/i.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/i.height*2-1)},_=S!==void 0&&Math.abs(S.ndcX)<=1&&Math.abs(S.ndcY)<=1,x=_?this.sceneRenderer.decorDistancesAt(S.ndcX,S.ndcY,v):{};c.add(v),(_||p.aim)&&c.delete(v);const M=p.angular?.widthDeg??r.pxToDeg(p.bounds.width),E=this.sizeEstimateOf(v);E.add(M,x);const I=zr.of(t,v);l.set(v,fn.resolve({hypothesisM:this.distanceHypotheses.get(v),derivedM:I&&M>0?et.distanceMAt(I.widthM,M):void 0,range:E.distanceRangeAt(M),crossing:x}))}for(const[v,p]of o)for(const[m,S]of o){if(m===v||S.transparency>=1||S.bounds.width*S.bounds.height<=p.bounds.width*p.bounds.height||!(p.bounds.x>=S.bounds.x&&p.bounds.y>=S.bounds.y&&p.bounds.x+p.bounds.width<=S.bounds.x+S.bounds.width&&p.bounds.y+p.bounds.height<=S.bounds.y+S.bounds.height))continue;const x=l.get(m);x&&l.set(v,{distanceM:x.distanceM*.999,basis:x.basis});break}this.depths=l;const h=n.sourceIds,d=this.sceneRenderer.lowerCloudUp,u=[];for(const[v,p]of o)u.push({sourceId:v,shape:p,distanceM:l.get(v).distanceM,renderOrder:h.indexOf(v),aim:p.aim,hidden:p.behindCloud===!0&&d||c.has(v)});const g=(bt(t,e)?.rollDeg??0)+(Gt.of(t)?.offsetAt(e)??Gt.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:r,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:st.starPointsOf(t.instrument),rollRad:g*Math.PI/180})}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(t).pxToDeg(n.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(i)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],n=e.event.time;return JSON.stringify([t?.lat,t?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],n=e.event.time,i=t?.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?Va(n,t.lng,e.event.utcOffsetHours):void 0;if(!i||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const a={lat:t.lat,lng:t.lng,elevationM:0},r=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(t.lat*1e3),l=Et.schedule({ratePerHour:Et.observedRatePerHour(Et.apexPosition(i,a).altitudeDeg),durationMs:r,velocityKmS:Et.TYPICAL_VELOCITY_KM_S,seed:o}),c=Xa.activeAt(i).map(d=>{const u=Xa.radiantPosition(d.shower,i,a);return{entry:d,position:u,rate:Xa.observedRatePerHour(d.zhr,u.altitudeDeg,d.shower.populationIndex)}}).sort((d,u)=>u.rate-d.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=Xs.schedule({ratePerHour:c.rate,durationMs:r,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(a=>a.t+a.durationMs<=this.ufoElement.seekableDuration).sort((a,r)=>r.brightness-a.brightness);if(t.length===0)return;const n=t[e%t.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(e){const t=this.ufoElement.sighting,n=t.instrument,i=n.frame,a=bt(t,e),r=a?.fNumber??n.fNumber;if(!i||r===void 0)return;const o=st.focalLengthMmFor(n,en.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:r,focusDistance:a?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return Qn.of(t.instrument,et.CANVAS_HEIGHT_PX,en.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new G3,this.sizeEstimates.set(e,t)),t}}const Yd="rr0-scene";function tT(){ql(),customElements.get(Yd)||customElements.define(Yd,eT)}class nT{constructor(e,t){this.timeline=e,this.clock=t}currentPointer=null;shapePrototype=null;sourceId="";start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.clock.start(n=>this.recordSample(n))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop()}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=rm(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}])}}class iT{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const n=performance.now()-this.startTime;n-this.lastTick>=this.intervalMs&&(this.lastTick=n,e(n)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const sT=[{id:"echo",name:{en:"the Echo balloons",fr:"les ballons Echo"},from:"1960-08-12",to:"1969-06-07",peakMagnitude:-1,note:"Echo 1 and 2 were 30- and 40-metre reflective balloons, as bright as the brightest stars and moving slowly enough to be watched — deliberately visible, widely announced in newspapers, and the first objects most people ever saw crossing the night sky. They fall squarely inside the sighting waves this project reconstructs."},{id:"iridium-flares",name:{en:"the Iridium flares",fr:"les flashes d'Iridium"},from:"1997-05-05",to:"2019-12-27",peakMagnitude:-8,note:"The original Iridium satellites carried flat, mirror-finish antennas that threw a sunbeam a few kilometres wide across the ground: a still point of sky flaring to magnitude -8 over five seconds and vanishing again. Nothing else in the sky does that."},{id:"iss",name:{en:"the International Space Station",fr:"la Station spatiale internationale"},from:"1998-11-20",peakMagnitude:-5.9,note:"Since its first module, and much brighter as it grew: at its best it outshines everything in the sky but the Sun and the Moon, crossing in a straight silent line in about four minutes."},{id:"starlink-trains",name:{en:"the Starlink trains",fr:"les trains de Starlink"},from:"2019-05-24",peakMagnitude:1,note:"In the days after a launch, satellites still bunched in their deployment string cross as an evenly spaced line of lights — the most reported 'formation of UFOs' of the era. They spread out within weeks, so a train is a fact about the days after a launch rather than about the year."}],aT=23493,V0=[2,3,2,1,2,5,4,6,5,6,6,6,6,6,6,6,9,9,9,9,9,9,14,14,15,16,16,16,16,16,18,22,25,24,29,28,29,33,34,35,40,40,42,42,43,46,48,48,49,53,53,54,58,61,70,70,74,78,79,83,92,92,99,97,101,102,109,115,126,125,123,125,127,130,139,153,157,156,161,156,165,174,193,193,201,203,212,215,224,244,255,263,262,281,293,307,312,327,339,336,343,353,359,369,386,396,405,410,421,419,424,434,443,450,460,480,492,504,509,516,519,524,527,530,527,535,543,549,564,571,573,576,582,584,600,600,608,618,625,632,637,642,648,654,661,667,669,667,671,671,697,692,703,697,710,714,724,731,747,755,764,770,782,802,801,815,819,837,846,856,878,881,877,900,906,907,917,932,932,936,954,973,989,986,991,990,1002,1009,1021,1024,1040,1038,1058,1078,1098,1092,1094,1099,1122,1132,1140,1151,1154,1161,1176,1185,1202,1206,1227,1228,1243,1265,1281,1288,1296,1325,1328,1336,1354,1373,1375,1393,1398,1411,1432,1457,1462,1476,1487,1485,1506,1509,1521,1524,1537,1543,1563,1586,1598,1614,1621,1620,1640,1658,1660,1673,1670,1686,1708,1715,1726,1726,1745,1749,1767,1774,1790,1798,1803,1805,1815,1818,1819,1820,1833,1822,1821,1819,1838,1835,1845,1841,1851,1869,1865,1868,1871,1870,1879,1882,1886,1900,1899,1908,1921,1928,1954,1966,1976,1986,1999,2007,2015,2030,2036,2057,2067,2072,2077,2088,2101,2106,2112,2119,2127,2142,2171,2176,2203,2226,2242,2241,2244,2254,2263,2284,2300,2320,2327,2345,2364,2367,2402,2423,2425,2434,2443,2461,2476,2495,2505,2520,2531,2535,2556,2567,2599,2608,2625,2639,2660,2663,2668,2681,2695,2702,2709,2719,2720,2738,2746,2763,2778,2788,2796,2807,2822,2831,2831,2853,2863,2866,2883,2892,2895,2921,2919,2937,2941,2947,2964,2987,2992,2987,2995,3002,3021,3025,3026,3036,3052,3049,3059,3077,3075,3083,3086,3107,3123,3124,3146,3155,3168,3179,3204,3205,3211,3233,3252,3253,3276,3287,3294,3293,3297,3314,3326,3335,3338,3355,3362,3358,3365,3364,3376,3375,3382,3418,3429,3432,3455,3463,3483,3490,3502,3509,3521,3532,3542,3544,3553,3571,3580,3588,3596,3603,3633,3639,3649,3655,3660,3670,3699,3699,3707,3723,3747,3752,3754,3766,3772,3778,3781,3798,3815,3814,3824,3832,3853,3859,3879,3885,3899,3912,3910,3924,3937,3951,3951,3961,3963,3961,3976,3977,3988,4004,4018,4025,4047,4074,4086,4108,4133,4136,4159,4168,4182,4192,4200,4215,4230,4239,4257,4678,4698,4694,4713,4719,4739,4750,4756,4764,4771,4788,4792,4790,4809,4821,4829,4834,4836,4843,4853,4863,4872,4881,4890,4898,4901,4897,4895,4884,4886,4886,4894,4897,4905,4905,4909,4907,4925,4918,4920,4929,4925,4928,4936,4943,4944,4951,4955,4952,4974,4976,4975,4981,4994,4997,5022,5023,5032,5043,5048,5051,5066,5062,5068,5075,5082,5082,5098,5102,5110,5113,5119,5123,5138,5138,5145,5149,5157,5165,5166,5169,5178,5183,5190,5192,5203,5204,5207,5214,5228,5234,5245,5249,5256,5262,5275,5278,5305,5303,5315,5321,5348,5358,5369,5369,5372,5385,5402,5409,5427,5429,5429,5439,5456,5464,5481,5485,5494,5509,5520,5526,5543,5555,5568,5575,5585,5596,5602,5620,5627,5644,5647,5660,5678,5680,5684,5692,5700,5711,5727,5733,5736,5756,5776,5797,5805,5804,5807,5800,5808,5814,5822,5839,5856,5869,5889,5902,5919,5921,5936,5937,5936,5957,5961,5975,5981,6002,6015,6027,6035,6042,6059,6062,6080,6081,6092,6097,6106,6127,6129,6198,6227,6231,6243,6249,6262,6255,6279,6304,6315,6326,6330,6334,6361,6358,6359,6379,6381,6389,6388,6404,6404,6443,6465,6473,6497,6500,6513,6524,6532,6538,6578,6572,6576,6584,6582,6608,6639,6656,6761,6764,6768,6772,6836,6905,6916,6925,6951,6984,7009,7072,7092,7110,7122,7140,7148,7170,7168,7180,7194,7247,7374,7391,7393,7382,7425,7485,7530,7568,7587,7602,7602,7715,7771,7900,8004,8103,8153,8162,8296,8319,8437,8566,8746,8860,8913,9128,9275,9585,9739,10014,10123,10167,10203,10288,10323,10398,10544,10721,10883,11044,11157,11442,11515,11787,12070,12269,12468,12484,12619,12883,13008,13264,13317,13549,13859,14049,14175,14360,14498,14687,14843,14984,15093,15279,15431,15623,15741,15788,15966,16025,16132,16419,16568,16791,16892,17060,17269,17598,17959,18194,18482,18804,19136,19564,19990,20249,20509,20943,21248,21539,21845,22196,22412];class pi{static FIRST_ORBIT="1957-10-04";static EARTH_RADIUS_KM=6371;static LOW_ORBIT_KM=500;static shadowHeightKm(e){if(e>=0)return 0;const t=-e*Math.PI/180;return pi.EARTH_RADIUS_KM*(1/Math.cos(t)-1)}static isLitOverhead(e,t){return e>pi.shadowHeightKm(t)}static classesAt(e){const t=e.getTime();return sT.filter(n=>{const i=Date.parse(`${n.from}T00:00:00Z`),a=n.to===void 0?1/0:Date.parse(`${n.to}T23:59:59Z`);return t>=i&&t<=a})}static trackedInOrbitAt(e){const t=e.getUTCFullYear()*12+e.getUTCMonth()-aT;if(!(t<0))return V0[Math.min(t,V0.length-1)]}static visibilityAt(e,t){const n=On("Sun",e,t).altitudeDeg;return{sunAltitudeDeg:n,shadowHeightKm:pi.shadowHeightKm(n),lowOrbitLit:pi.isLitOverhead(pi.LOW_ORBIT_KM,n),classes:pi.classesAt(e),trackedObjects:pi.trackedInOrbitAt(e),anythingInOrbit:e.getTime()>=Date.parse(`${pi.FIRST_ORBIT}T00:00:00Z`)}}}const rT={en:["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"],fr:["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSO","SO","OSO","O","ONO","NO","NNO"]};class Gs{static POINT_DEG=360/16;static point(e,t){const n=(e%360+360)%360,i=Math.round(n/Gs.POINT_DEG)%16;return rT[t][i]}static towards(e,t){const n=Gs.point(e,t);return t==="en"?`to the ${n}`:oT.test(n)?`à l'${n}`:`au ${n}`}}const oT=/^[EO]/;class nt{static COARSE_STEP_DEG=10;static FINE_STEP_DEG=2;static FINE_SPAN_DEG=10;static LOWEST_DEG=5;static THRESHOLD_CONTRAST=.5;static CONE_SEPARATION_DEG=60;galaxy=new $e;dust=new _t;assess(e,t){const n=On("Sun",e,t),i=On("Moon",e,t),a={altitudeDeg:i.altitudeDeg,phaseAngleDeg:We.phaseAngleOf(Hl(e).illuminatedFraction)},r=Ln.galactic(e,t),o=nt.unit(r.centre),l=nt.unit(r.rotation),c=nt.unit(r.pole),h=nt.unit(Ln.eclipticPole(e,t)),d=nt.unit(n),u=nt.unit(i),f=nt.normalize(nt.reject(d,h));let g,v,p=0;const m=(S,_)=>{const x=nt.unit({altitudeDeg:S,azimuthDeg:_}),M=nt.between(x,d),E=We.magPerArcsec2({altitudeDeg:n.altitudeDeg,separationDeg:M},{...a,separationDeg:nt.between(x,u)},S);E>p&&(p=E);const I=qi.fromMagPerArcsec2(E),y=10**(-.4*We.EXTINCTION_PER_AIR_MASS*(We.airMass(S)-1)),T=this.galaxy.surfaceBrightnessS10(Math.atan2(nt.dot(x,l),nt.dot(x,o))*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,nt.dot(x,c))))*180/Math.PI)*y;g=nt.better(g,T,I,E,S,_,M);const C=Math.max(-1,Math.min(1,nt.dot(x,h))),D=nt.normalize(nt.reject(x,h)),P=this.dust.surfaceBrightnessS10(nt.between(D,f),Math.asin(C)*180/Math.PI)*y;v=nt.better(v,P,I,E,S,_,M)};for(let S=nt.LOWEST_DEG;S<=90;S+=nt.COARSE_STEP_DEG)for(let _=0;_<360;_+=nt.COARSE_STEP_DEG)m(S,_);for(const S of[g,v]){if(!S)continue;const _=nt.FINE_SPAN_DEG,x=nt.FINE_STEP_DEG;for(let M=S.altitudeDeg-_;M<=S.altitudeDeg+_;M+=x)if(!(M<nt.LOWEST_DEG||M>90))for(let E=S.azimuthDeg-_;E<=S.azimuthDeg+_;E+=x)m(M,(E+360)%360)}return{milkyWay:g&&g.contrast>=nt.THRESHOLD_CONTRAST?g:void 0,zodiacal:v&&v.contrast>=nt.THRESHOLD_CONTRAST?v:void 0,darkestSkyMagPerArcsec2:p}}static better(e,t,n,i,a,r,o){const l=t/n;return e&&e.contrast>=l?e:{contrast:l,altitudeDeg:a,azimuthDeg:r,magPerArcsec2:qi.toMagPerArcsec2(t),skyMagPerArcsec2:i,sunSeparationDeg:o}}static unit(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,i=Math.cos(t);return[i*Math.sin(n),Math.sin(t),-i*Math.cos(n)]}static dot(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}static between(e,t){return Math.acos(Math.max(-1,Math.min(1,nt.dot(e,t))))*180/Math.PI}static reject(e,t){const n=nt.dot(e,t);return[e[0]-n*t[0],e[1]-n*t[1],e[2]-n*t[2]]}static normalize(e){const t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]}}const ll=36e5,W0=25;class mh{constructor(e){this.provider=e}async infer(e){const t=this.questionOf(e);if(!t)return{status:"incomplete"};const{origin:n,start:i}=t,a=Ka(e.event)??0,r=this.sampleTimings(e,i,a);let o;try{o=await this.provider.getWeather({points:r.map(l=>this.pointAt(e,l,n))})}catch{return{status:"failed",at:i}}return o?{status:"inferred",at:i,source:o.source,keyframes:o.samples.map((l,c)=>({t:r[c].t,weather:l.weather}))}:{status:"unavailable",at:i}}applyTo(e,t){if(!(t.status!=="inferred"||!t.keyframes||!t.source)){e.weatherTrack.clear();for(const n of t.keyframes)e.weatherTrack.addKeyframe(n.t,n.weather);e.weatherSource=t.source}}sampleTimes(e,t){const n=[e],i=e.getTime()+t;let a=Math.floor(e.getTime()/ll)*ll+ll;for(;a<=i&&n.length<W0;)n.push(new Date(a)),a+=ll;return t>0&&n[n.length-1].getTime()!==i&&n.length<W0&&n.push(new Date(i)),n}sampleTimings(e,t,n){const i=e.timeline.duration>0?e.timeline.duration:n;return n<=0||i<=0?[{time:t,t:0}]:this.sampleTimes(t,n).map(a=>{const r=(a.getTime()-t.getTime())/n;return{time:a,t:Math.round(i*Math.max(0,Math.min(1,r)))}})}canInfer(e){return this.questionOf(e)!==void 0}questionOf(e){const t=this.originOf(e);if(!t)return;const n=e.event.time;if(n?.year===void 0||n.month===void 0||n.day===void 0)return;const i=Va(n,t.lng,e.event.utcOffsetHours);return i?{origin:t,start:i}:void 0}originOf(e){const t=bt(e,0),n=e.event.place?.[0],i=t?.lat??n?.lat,a=t?.lng??n?.lng;return i===void 0||a===void 0?void 0:{lat:i,lng:a}}pointAt(e,t,n){const i=bt(e,t.t);return{lat:i?.lat??n.lat,lng:i?.lng??n.lng,time:t.time}}}const lT=Date.UTC(1940,0,1),X0=36e5,q0=.25,cT=.7,hT=.45,dT=.1,uT=2,fT=.3,pT=.2,mT=8,gh=.125,gT=.05,vT=125,yT=100,bT=2500,Y0=3500,K0=8e3,xT=95,wT=99,MT=[96,99],ST=["cloud_cover","cloud_cover_low","cloud_cover_mid","cloud_cover_high","precipitation","snowfall","weather_code","wind_speed_10m","wind_direction_10m","temperature_2m","dew_point_2m"];class zg{fetchImpl;baseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://archive-api.open-meteo.com/v1/archive"}async getWeather(e){if(e.points.length===0)return;const t=e.points.map(f=>f.time.getTime()),n=Math.min(...t);if(n<lT)return;const i=new Map;for(const f of e.points){const g=this.cellKey(f);i.has(g)||i.set(g,{lat:f.lat,lng:f.lng,index:i.size})}const a=this.requestUrl([...i.values()],new Date(n),new Date(Math.max(...t))),r=this.cache.get(a);if(r)return r;const o=await this.fetchImpl(a);if(!o.ok)throw new Error(`Open-Meteo HTTP ${o.status}`);const l=await o.json(),c=Array.isArray(l)?l:[l];if(c.length<i.size||c.some(f=>f.error||!f.hourly))return;const h={id:"era5",name:"ERA5 (Open-Meteo)",url:a},d=e.points.map(f=>this.sampleAt(c[i.get(this.cellKey(f)).index].hourly,f.time));if(d.some(f=>f===void 0))return;const u={samples:d,source:h};return this.cache.set(a,u),u}cellKey(e){return`${Math.round(e.lat/q0)},${Math.round(e.lng/q0)}`}requestUrl(e,t,n){const i=new URLSearchParams({latitude:e.map(a=>a.lat).join(","),longitude:e.map(a=>a.lng).join(","),start_date:this.isoDate(t),end_date:this.isoDate(n),hourly:ST.join(","),wind_speed_unit:"ms",timezone:"UTC"});return`${this.baseUrl}?${i}`}isoDate(e){return e.toISOString().slice(0,10)}sampleAt(e,t){const n=this.recordAt(e,t);return n&&{time:t,weather:this.toWeather(n)}}recordAt(e,t){const n=e.time.map(o=>Date.parse(`${o}Z`)),i=t.getTime();if(n.length===0||i<n[0]-X0||i>n[n.length-1]+X0)return;if(i<=n[0])return this.recordFrom(e,0);if(i>=n[n.length-1])return this.recordFrom(e,n.length-1);let a=0;for(;a+1<n.length&&n[a+1]<=i;)a++;const r=n[a+1]-n[a];return this.blendRecords(this.recordFrom(e,a),this.recordFrom(e,a+1),r>0?(i-n[a])/r:0)}recordFrom(e,t){const n={cloudCover:e.cloud_cover[t]/100,cloudCoverLow:e.cloud_cover_low[t]/100,cloudCoverMid:e.cloud_cover_mid[t]/100,cloudCoverHigh:e.cloud_cover_high[t]/100,precipitationMm:e.precipitation[t],snowfallCm:e.snowfall[t],weatherCode:e.weather_code[t],windSpeedMs:e.wind_speed_10m[t],windFromDeg:e.wind_direction_10m[t],temperatureC:e.temperature_2m[t],dewPointC:e.dew_point_2m[t]};return Object.values(n).some(i=>i===void 0||Number.isNaN(i))?void 0:n}blendRecords(e,t,n){if(!e||!t)return e??t;const i=(r,o)=>r+(o-r)*n,a=((t.windFromDeg-e.windFromDeg)%360+540)%360-180;return{cloudCover:i(e.cloudCover,t.cloudCover),cloudCoverLow:i(e.cloudCoverLow,t.cloudCoverLow),cloudCoverMid:i(e.cloudCoverMid,t.cloudCoverMid),cloudCoverHigh:i(e.cloudCoverHigh,t.cloudCoverHigh),precipitationMm:i(e.precipitationMm,t.precipitationMm),snowfallCm:i(e.snowfallCm,t.snowfallCm),weatherCode:n<.5?e.weatherCode:t.weatherCode,windSpeedMs:i(e.windSpeedMs,t.windSpeedMs),windFromDeg:((e.windFromDeg+a*n)%360+360)%360,temperatureC:i(e.temperatureC,t.temperatureC),dewPointC:i(e.dewPointC,t.dewPointC)}}toWeather(e){const t=e.weatherCode>=xT&&e.weatherCode<=wT,n=this.precipitationTypeFrom(e);return{cloudCover:this.clamp(e.cloudCover,0,1),cloudDarkness:this.cloudDarknessFrom(e,t),cloudBaseM:this.cloudBaseFrom(e),highCloudCover:e.cloudCoverHigh,lowerCloudCover:Math.max(e.cloudCoverLow,e.cloudCoverMid),precipitationType:n,precipitationIntensity:n==="none"?0:this.clamp(Math.sqrt(e.precipitationMm/mT),0,1),windDirectionDeg:(e.windFromDeg+180)%360,windSpeed:e.windSpeedMs,storm:t}}precipitationTypeFrom(e){return e.snowfallCm>0?"snow":MT.includes(e.weatherCode)?"hail":e.precipitationMm>0?"rain":"none"}cloudDarknessFrom(e,t){const n=e.cloudCoverLow+e.cloudCoverMid+e.cloudCoverHigh;if(n<=0)return 0;const i=(cT*e.cloudCoverLow+hT*e.cloudCoverMid+dT*e.cloudCoverHigh)/n,a=Math.min(1,e.precipitationMm/uT);return this.clamp(i+fT*a+(t?pT:0),0,1)}cloudBaseFrom(e){if(e.cloudCover<gT)return;const t=this.clamp(vT*(e.temperatureC-e.dewPointC),yT,bT);if(e.cloudCoverLow>=gh)return Math.round(t);if(e.cloudCoverMid>=gh)return Y0;if(e.cloudCoverHigh>=gh)return K0;const n=Math.max(e.cloudCoverLow,e.cloudCoverMid,e.cloudCoverHigh);if(!(n<=0))return n===e.cloudCoverLow?Math.round(t):n===e.cloudCoverMid?Y0:K0}clamp(e,t,n){return Math.max(t,Math.min(n,e))}}function _T(){return new zg}const ET=5;class Hg{attribution={text:"© OpenStreetMap",url:"https://osm.org/copyright"};fetchImpl;baseUrl;reverseUrl;cache=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.baseUrl=e.baseUrl??"https://nominatim.openstreetmap.org/search",this.reverseUrl=e.reverseUrl??"https://nominatim.openstreetmap.org/reverse"}async reverse(e,t,n={}){const i=new URLSearchParams({lat:String(e),lon:String(t),format:"jsonv2"});n.language&&i.set("accept-language",n.language);const a=`${this.reverseUrl}?${i}`,r=this.cache.get(a);if(r)return r[0];const o=await this.fetchImpl(a,{signal:n.signal});if(!o.ok)throw new Error(`Nominatim HTTP ${o.status}`);const l=await o.json(),c=l.error?void 0:this.toMatch(l);return this.cache.set(a,c?[c]:[]),c}async search(e,t={}){const n=e.trim();if(n==="")return[];const i=this.requestUrl(n,t),a=this.cache.get(i);if(a)return a;const r=await this.fetchImpl(i,{signal:t.signal});if(!r.ok)throw new Error(`Nominatim HTTP ${r.status}`);const o=await r.json(),l=(Array.isArray(o)?o:[]).map(c=>this.toMatch(c)).filter(c=>c!==void 0);return this.cache.set(i,l),l}requestUrl(e,t){const n=new URLSearchParams({q:e,format:"jsonv2",limit:String(t.limit??ET)});return t.language&&n.set("accept-language",t.language),`${this.baseUrl}?${n}`}toMatch(e){const t=e.display_name??e.name,n=this.coordinate(e.lat),i=this.coordinate(e.lon);return t&&n!==void 0&&i!==void 0?{name:t,lat:n,lng:i}:void 0}coordinate(e){if(e===void 0||e.trim()==="")return;const t=Number(e);return Number.isFinite(t)?t:void 0}}function TT(){return new Hg}const AT=[{id:"nominatim",name:"Nominatim",credit:"© OpenStreetMap",creditUrl:"https://osm.org/copyright",create:()=>new Hg}],IT=[{id:"era5",name:"ERA5 (Open-Meteo)",credit:"© Copernicus/ECMWF",creditUrl:"https://open-meteo.com/en/docs/historical-weather-api",create:()=>new zg}];class DT{attribution;fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis);const t=e.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${t}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${t})`}async getImageryTexture(e,t){return ym(e,t,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}const vh=[{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new vm}],$0=[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:()=>new bm},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:()=>new DT}];class Du{constructor(e){this.provider=e}static SPAN_DEG=.002;async at(e,t){const n=Du.SPAN_DEG;try{const a=(await this.provider.getElevationGrid({south:e-n,north:e+n,west:t-n,east:t+n},{width:2,height:2})).heights[0];return Number.isFinite(a)?a:void 0}catch{return}}}class CT{available(){const e=Intl.supportedValuesOf;return e?[...e.call(Intl,"timeZone")].sort():[]}offsetHoursAt(e,t){if(t.year===void 0)return;const n=Date.UTC(t.year,(t.month??1)-1,t.day??1,t.hour??12,t.minute??0,t.second??0),i=this.zoneOffsetHours(e,new Date(n));if(i!==void 0)return this.zoneOffsetHours(e,new Date(n-i*36e5))??i}zoneOffsetHours(e,t){let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(a=>a.type==="timeZoneName")?.value??""}catch{return}const i=/^GMT(?:([+-])(\d{2}):(\d{2}))?$/.exec(n);if(i)return i[1]?(i[1]==="-"?-1:1)*(Number(i[2])+Number(i[3])/60):0}}function Ea(s,e){return s.find(t=>t.id===e)??s[0]}class RT{constructor(e="https://api.open-meteo.com/v1/forecast"){this.endpoint=e}async zoneAt(e,t){const n=new URL(this.endpoint);n.searchParams.set("latitude",String(e)),n.searchParams.set("longitude",String(t)),n.searchParams.set("timezone","auto"),n.searchParams.set("forecast_days","1");try{const i=await fetch(n.toString());if(!i.ok)return;const a=await i.json();return a.timezone&&a.timezone!=="GMT"?a.timezone:void 0}catch{return}}}const PT=[{id:"open-meteo",name:"Open-Meteo",credit:"© Open-Meteo",creditUrl:"https://open-meteo.com/en/docs",create:()=>new RT}],LT={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",assessmentGroup:"Assessment",assessmentNames:{coverage:"Witness info"},assessmentVerdicts:{"hynek.nl":"NL — nocturnal light","hynek.dd":"DD — daylight disc","hynek.rv":"RV — radar-visual","hynek.ce1":"CE1 — close encounter","hynek.ce2":"CE2 — with a physical trace","hynek.ce3":"CE3 — with entities"},witnessGroup:"Witness",witnessId:"ID",witnessTitle:"Title",witnessLastName:"Last name",witnessFirstNames:"First names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorEntity:"Being",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Environment",decorBuilding:"Building",decorTree:"Tree",decorCrop:"Crop row",decorMound:"Stone heap",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorColor:"Colour",decorLit:"Lit",decorTitle:"Name",milestones:"Moments",milestoneLabel:"Label",milestoneNote:"What happens",addMilestone:"Name this moment",deleteMilestone:"Delete moment",confirmAccept:"Delete",confirmDecline:"Cancel",decorWidth:"Width",decorLength:"Length",decorHeight:"Height",decorModel:"3D model",decorModelNone:"Built-in shape",decorModelAdvanced:"Model from an address",decorModelUrl:"glTF/GLB address",decorModelTitle:"Model name",decorModelAuthor:"Author",decorModelLicense:"Licence",decorModelSource:"Where it came from",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},Gg={...LT,oval:"Oval",polygon:"Polygon",addVertex:"Add vertex",deleteVertex:"Delete vertex",notAPolygon:"Select a single polygon shape",tooFewVertices:"A shape needs at least 3 points",shape:"Shape",apparentWidth:"Apparent width",realWidth:"Real width",distance:"Distance",sizeLock:"Hold",lockNone:"nothing",lockApparent:"the apparent width",lockReal:"the real width",lockDistance:"the distance",apparentSize:"{moons}× the Moon",utcOffsetPlaceholder:"from longitude",realSizeBetween:"The scene bounds that width: between {min} and {max} m, from what it crosses",realSizeAtLeast:"The scene bounds that width: at least {min} m, from what it passes behind",realSizeAtMost:"The scene bounds that width: at most {max} m, from what it passes in front of",realSizeUnknown:"Nothing in the scene bounds that width: it is only what the distance implies",realSizeOutside:" — the width above is outside that",blurBound:"Blurred through this lens: nearer than {max} m",blurBoundNoInstrument:"Blur through the naked eye bounds no distance — an eye has no aperture to be out of focus with",blurBoundNotAtInfinity:"Blur bounds a distance only for a lens focused at infinity: this one is focused at {focus} m, which blurs on both sides of it",realSizeContradiction:"Contradiction: the declared crossings cannot all be true",realDistanceHere:" — i.e. between {min} and {max} m here",clearDistanceHypothesis:"Withdraw the distance hypothesis",clearDistanceHypothesisTitle:"Back to what the recording establishes",depthStated:"Drawn at {m} m, as the recording states",depthHypothesis:"Drawn at {m} m: your hypothesis — what the decor hides of it is what a thing that far would lose",depthDerived:"Drawn at {m} m, from the witness's own walk",depthBounded:"Drawn at {m} m, from what it passes behind and in front of",depthConventional:"Drawn at {m} m by convention: nothing in the recording establishes a distance",addShape:"Add shape",deleteShape:"Delete shape",play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",group:"Group",ungroup:"Ungroup",bringToFront:"Bring to front",sendToBack:"Send to back",contextMenuDelete:"Delete",confirmDeleteShape:"Delete {name}? This can't be undone.",confirmDeleteShapes:"Delete {count} shapes? This can't be undone.",confirmDeleteMilestone:"Stop naming moment {name}? The recording itself is unchanged.",onlyOneShape:"There is only one shape",alreadyAtFront:"This shape is already at the front",alreadyAtBack:"This shape is already at the back",needTwoShapesToGroup:"Select at least two shapes to group them",notGrouped:"This shape isn't part of a group",multipleShapesSelected:"Multiple shapes selected — select just one to edit this",samplingRate:"Sampling rate",currentPosition:"Current position",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",durationPlaceholder:"observation length",durationImprecise:"These dates don't precisely enough determine a duration — enter it manually.",export:"Export",importFile:"Load JSON file",importUrl:"Or load from URL",importUrlPlaceholder:"https://…/sighting.json",importButton:"Load",importError:"Couldn't load that recording — check the file or URL and try again.",importErrorCors:'That address answers, but the browser is not allowed to read it from this page. The file itself is fine — its server needs to send the header "Access-Control-Allow-Origin: *" with it. If it is not your server, that is what to ask its administrator for.',importErrorMixedContent:"A secure page cannot load an address starting with http://. Use https:// if that server offers it.",importErrorUnreachable:"Nothing answered at that address. Check the spelling, and that you are online.",importErrorStatus:"That server answered with an error ({status}). The address is probably wrong, or the file has moved.",importErrorMalformed:"That address answered, but what came back is not a recording.",record:"Record",stop:"Stop",according:"according to",sourceElevation:"Relief",sourceImagery:"Imagery",placeNamePlaceholder:"Valensole, France",searchPlace:"Locate",placeMatch:"Matches",placeSearching:"Looking up the place…",placeMatchFound:"place found",placeMatchesFound:"places found",placeNotFound:"No place by that name",placeSearchFailed:"Place search temporarily unavailable",utcOffsetImplausible:"This time zone doesn't match the longitude entered, whose own solar time is UTC{solar} — yet the scene and the weather record both obey what is declared here. Clear the field to derive it from the longitude.",timeZoneManual:"offset entered",altitudeAboveSeaLevel:"The witness's altitude above sea level — the ground at the location entered sets its floor: a witness in the Alps is not at 0 m.",groundAt:"ground at {m} m",headingPlaceholder:"unknown",edtfInvalid:"Not a valid EDTF date/time (e.g. 1965-07-01T05:00, 2025-06?, 2025~).",edtfPlaceholder:"YYYY-MM-DDThh:mm[?~%] or hh:mm",observationTimeHint:"EDTF — e.g. 1965-07-01T05:00, 2025-06? (uncertain), 2025~ (approximate), or just 05:00 if the date isn't known",observationEndTimeHint:"EDTF — e.g. 1965-07-01T05:10, 2025-06? (uncertain), 2025~ (approximate), or just 05:10 if the date isn't known",presetsGroupLabel:"UFO shape",witnessDirName:"Dir name",description:"Description",tagsPlaceholder:"comma-separated",weather:"Weather",shapeGroup:"Phenomenon",soundGroup:"Sound",temporalGroup:"Moment",timeQualifierExact:"Exact",timeQualifierApproximate:"Approximate",timeQualifierUncertain:"Uncertain",timeQualifierBoth:"Uncertain and approximate",edtfModeTitle:"Type an imprecise date instead: a year alone, a month, a time with no date",locationGroup:"Location",observationGroup:"Observation",weatherWhilePlaying:"Pause the recording to state the weather — while it plays, the instant these would be written at is moving",weatherInferred:"From weather records",weatherInferredTitle:"Weather isn't testimony: it's a measurable fact, on record for the observation's own date, time and place. Uncheck to state the conditions the witness reported, which then override the record.",weatherLookingUp:"Looking up the record…",weatherNeedsDateAndPlace:"A full date and a place are needed to look up the record",weatherNoRecord:"No record for this date and place",weatherLookupFailed:"Weather records temporarily unreachable",instrumentOutOfPeriod:"{name} — not of this date",unitMillimetres:"mm",unitDegrees:"°",soundSrcPlaceholder:"URL of a real recording",skyLine:"Sky: {parts}",skyStarsEye:"stars down to magnitude {limit}, which is as faint as an eye went under this sky",skyStarsDeeper:"stars down to magnitude {limit} through a {device} — {gain} magnitudes past the {eye} the witness's own eyes reached",skyStarsShallower:"stars down to magnitude {limit} through a {device} — {gain} magnitudes short of the {eye} the witness's own eyes reached",skyStarsCatalogue:", drawn to {catalogue}, where this project's catalogue stops",skyStarsNone:"no star could be picked out of a sky this bright",skyDetails:"Show the records in full",skyDetailsHide:"Hide the records",skyShowerActive:"{name} — radiant {altitude}° above the horizon, {bearing} — about {rate}/h under this sky, over a sporadic background of {sporadic}/h",skyShowerBelowHorizon:"{name} is active, but its radiant is below the horizon — it can have produced nothing",skyNothingActive:"no meteor shower active on this date — a sporadic background of about {sporadic}/h",showMeteor:"Show me one",skyComet:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}, tail {tail}° long",skyCometNoTail:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing}",skyCometBelowHorizon:"{name} was there at magnitude {magnitude}, but below the horizon — nobody here saw it",skyCometInDaylight:"{name}, magnitude {magnitude}, {altitude}° above the horizon {bearing} — but only {elongation}° from the Sun",showComet:"Show me the comet",skyOpticsPossible:"ice cloud enough, around the {source}, for {forms}",skyOpticsAlignment:" — everything but the rings needs crystals falling level, stated here at {alignment}% since no record holds it",skyOpticsHalo22:"a {angle}° ring",skyOpticsHalo46:"a {angle}° ring",skyOpticsParhelia:"sundogs {angle}° to either side",skyOpticsTangentArc:"an arc tangent on top of it",skyOpticsParhelicCircle:"a white circle right round the sky at its own height",skyOpticsCircumzenithal:"a circumzenithal arc {angle}° up",skyOpticsCircumhorizontal:"a circumhorizontal arc far below it",skyOpticsPillar:"a pillar standing over it",skyOpticsNoIce:"no ice cloud: no halo and no sundogs",skyOpticsHidden:"ice cloud above, but a lower deck between it and the witness",skyOpticsSun:"Sun",skyOpticsMoon:"Moon",skyBowPossible:"rain and sunlight enough for {forms}",skyBowMoon:"rain under a Moon {lit}% lit, enough for {forms} — a moonbow, which the eye sees as a white arc",skyGlowBand:"the Milky Way {contrast}× the sky behind it, {altitude}° up {bearing}",skyGlowCone:"the zodiacal light {contrast}× the sky behind it, {altitude}° up {bearing}, {elongation}° from the Sun — a leaning cone with no edge, gone within the hour",skyGlowZodiacalBand:"the zodiacal band {contrast}× the sky behind it, {altitude}° up {bearing} — the whole ecliptic faintly alight, which is not the sight people report",skyGlowMoon:"no Milky Way and no zodiacal light: a Moon {lit}% lit held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowTwilight:"no Milky Way and no zodiacal light: twilight still held the sky at {sky} magnitudes a square arcsecond, where they need 22",skyGlowNothingUp:"sky dark enough ({sky} magnitudes a square arcsecond) but neither the galactic plane nor the ecliptic stood high enough in it",skyBowPrimary:"a bow {radius}° across, its top {top}° up",skyBowSecondary:"a second, fainter one at {radius}° with its colours reversed",skyBowSourceTooHigh:"rain, but with the source {altitude}° up no bow could clear the horizon: they stand {radius}° from the point opposite it",skyBowHidden:"rain, but an unbroken deck between it and the light: no bow",skyBowNoSource:"rain, and nothing lit to make a bow of it",skySatellitesLit:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month",skySatellitesLitWith:"the Earth's shadow stood {height} km above the witness, so low orbit was still in sunlight — {count} tracked objects were in orbit that month, among them {eras}",skySatellitesShadowed:"the Earth's shadow stood {height} km above the witness: of the {count} tracked objects in orbit that month, nothing in low orbit was lit",skySatellitesNotYet:"nothing had been put in orbit yet",skySatellitesDaylight:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skySatellitesDaylightOne:"everything in orbit was sunlit, as it always is by day, and {eras} could outshine even this sky",skyUnknown:"cannot be worked out without a date and a place",lookAtDecor:"Look at it",addDecor:"Add",deleteDecor:"Delete decor",decorSightingUrl:"Their own recording URL",viewTestimony:"View testimony",noWitnessRecording:"No recording URL set for this witness",masks:"Masks",addWitness:"Add witness",narrativePlaceholder:"What the witness reported, in their own words",narrativeKey:"{source} API key",narrativeNeedsKey:"Enter your own {source} API key to generate a reconstruction from the account",narrativeKeyUnlikely:"This does not look like a Claude API key: they begin with sk-ant-",narrativeWorkspace:"Workspace ID",narrativeWorkspacePlaceholder:"only if your key spans several",narrativeWorkspaceHint:"Only for a key whose scope is the whole organisation. Simpler: leave this empty and create a key scoped to one workspace instead.",narrativeNeedsAsk:"Nothing to send yet",narrativeRemember:"Remember on this device",narrativeDraft:"Generate reconstruction",narrativeStop:"Stop",narrativeWorking:"Reading the account…",narrativeApplied:"{count} fields written into the editor",narrativeUnchanged:"The account states nothing the recording can hold yet",narrativeStated:"What the witness said",narrativeDerived:"Worked out from the account",narrativeAssumed:"Guessed, so the reconstruction runs — check these",narrativeGaps:"What nothing could settle",narrativeErrorCredential:"No key, or one that was refused — check it at console.anthropic.com",narrativeErrorRateLimited:"Too many requests on your account: wait a moment and ask again",narrativeErrorRefused:"The account was not answered. Rephrasing may help; asking again will not",narrativeErrorMalformed:"The answer was not a usable draft — worth asking once more",narrativeErrorUnreachable:"Nothing answered: check the connection",narrativeErrorRejected:"Refused: {detail}",witnessAge:"Age then",witnessOccupation:"Occupation",testimonySource:"Account obtained",testimonySourceUnknown:"unknown",testimonySourceOnSite:"on-site investigation",testimonySourceInterview:"interview in person",testimonySourceTelephone:"by telephone",testimonySourceQuestionnaire:"questionnaire",testimonySourceLetter:"the witness wrote it",testimonySourcePress:"press or broadcast",testimonyFollowedUp:"Followed up",testimonyUnknown:"unknown",testimonyYes:"yes",testimonyNo:"no",questionUnanswered:"Nothing in this recording answers one of the questions a reconstruction needs settled",durationRequired:"The observation needs a length to be replayed at all — state one, or an end time, which may be approximate",questionsUnanswered:"{count} of the questions a full reconstruction answers are unanswered here"},NT=Object.freeze(Object.defineProperty({__proto__:null,sightingEditorMessages_en:Gg},Symbol.toStringTag,{value:"Module"})),Z0=new Set;ql();tT();const Ta={width:48,height:28},OT=2500,kT=600,J0=900,Aa=2e-4,UT=900,FT=-1.46,BT=3,j0=.2,zT=.01,HT=1.6,yh=2e3,GT=250,Q0=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),cs=4,cl="ufo-1",em=["oval","polygon"],VT={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5,blur:0,brightness:0};function WT(s){return s.kind==="oval"?"oval":"polygon"}const XT=-6,qT=21;class Mt extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;presetsGroup;colorInput;transparencyInput;haloScaleInput;blurInput;brightnessInput;blurBoundOutput;sourceSelect;shapeTitleInput;utcOffsetInput;timeZoneSelect;timeZoneProvider=PT[0].create();timeZoneLookupTimer;timeZoneLookedUpAt;autoFilledTimeZone;timeZones=new CT;apparentWidthInput;realWidthInput;objectDistanceInput;sizeLockSelect;apparentSizeOutput;realSizeOutput;clearDistanceHypothesisButton;depthBasisOutput;addShapeButton;deleteShapeButton;contextMenu;contextGroupButton;contextUngroupButton;contextBringToFrontButton;contextSendToBackButton;contextDeleteButton;contextAddVertexButton;contextDeleteVertexButton;decorContextMenu;contextViewTestimonyButton;contextMasksSubmenu;labelContextMasks;playPauseButton;seekInput;timeStartLabel;timeEndLabel;loopButton;durationInput;exportButton;importFileInput;importUrlInput;importUrlButton;narrativeKeyInput;narrativeWorkspaceInput;narrativeRememberInput;narrativeDraftButton;narrativeStopButton;narrativeCreditLink;narrativeStatus;narrativeReport;placeNameInput;searchPlaceButton;placeMatchRow;placeMatchSelect;placeStatusText;placeProvider=TT();placeMatches=[];placeSearchToken=0;placeReverseTimer;namedCoordinates;latInput;lngInput;headingInput;pitchInput;rollInput;elevationInput;groundElevationOutput;weatherFromRecords=!0;groundElevationM;groundElevationFor;groundElevationTimer;groundElevationToken=0;obsTimeInput;obsTimeNativeInput;obsEndTimeNativeInput;obsTimeQualifier;obsEndTimeQualifier;edtfModeButton;edtfMode=!1;obsEndTimeInput;witnessIdInput;witnessDirNameInput;witnessTitleInput;witnessLastNameInput;witnessFirstNamesInput;witnessAgeInput;witnessOccupationInput;testimonySourceSelect;testimonyFollowedUpSelect;caseIdInput;descriptionInput;tagsInput;cloudCoverInput;cloudDarknessInput;cloudBaseInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;stormInput;weatherInferredInput;weatherSourceText;skyCandidatesOutput;showMeteorButton;showCometButton;weatherSourceLink;weatherFields;weatherInference=new mh(_T());weatherLookupTimer;weatherLookupToken=0;weatherLookupPending=!1;weatherLookupResult;weatherTrackSpan;soundKindSelect;soundVolumeInput;soundPitchInput;soundPitchValue;soundSrcInput;soundFields;soundKindOptions=new Map;soundPreviewTimer;instrumentSelect;focalLengthInput;labelFocalLength;unitFocalLength;labelFNumber;labelExposure;labelFocusDistance;fNumberInput;exposureInput;focusDistanceInput;labelColor;labelTransparency;labelHalo;labelBlur;labelBrightness;labelShape;labelShapeTitle;labelUtcOffset;labelApparentWidth;labelRealWidth;labelObjectDistance;labelSizeLock;labelSamplingRate;labelDuration;placeSourceRow;weatherSourceRow;terrainSourceRows;chosenSourceId=new Map;labelPlaceName;labelPlaceMatch;labelLatitude;labelLongitude;labelHeading;labelPitch;labelRoll;labelElevation;labelObservationTime;labelObservationEndTime;labelWitnessId;labelWitnessDirName;labelWitnessTitle;labelWitnessLastName;labelWitnessFirstNames;labelWitnessAge;labelWitnessOccupation;labelTestimonySource;labelTestimonyFollowedUp;labelCaseId;labelDescription;labelTags;labelImportFile;labelImportUrl;labelNarrativeKey;labelNarrativeWorkspace;labelNarrativeRemember;groupTabs;groupPanels;paramSummary;paramSummaryBuilder;paramSummarySignature="";labelShapeGroup;labelTemporalGroup;labelLocationGroup;labelObservationGroup;labelWitnessGroup;skyDetailsButton;clampedLines;labelWeatherGroup;labelCloudCover;labelHighCloud;labelIceAlignment;highCloudCoverInput;iceCrystalAlignmentInput;labelCloudDarkness;labelCloudBase;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelStorm;labelWeatherInferred;labelSoundGroup;labelSoundKind;labelSoundVolume;labelSoundPitch;labelSoundSrc;labelInstrument;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;decorKindSelect;addDecorWitnessButton;addDecorBuildingButton;deleteDecorButton;decorSelect;decorTitleInput;decorEastInput;decorNorthInput;decorHeadingInput;decorColorInput;decorLitInput;decorLightRigSelect;lookAtDecorButton;decorAltitudeInput;labelDecorAltitude;decorSightingUrlInput;decorModelProvider=bl[0].create();confirmOverlay;confirmMessage;confirmAcceptButton;confirmDeclineButton;confirmAnswer;milestoneSelect;milestoneLabelInput;milestoneNoteInput;addMilestoneButton;deleteMilestoneButton;currentMilestoneT;decorWidthInput;decorLengthInput;decorHeightInput;decorModelSelect;decorModelAdvanced;decorModelUrlInput;decorModelTitleInput;decorModelAuthorInput;decorModelLicenseInput;decorModelSourceInput;decorFloorsInput;decorOccupiedFloorInput;decorWitnessSideSelect;decorWindowInputs;labelDecorSide;optionWitnessSide;labelDecor;labelDecorGroup;labelDecorTitle;labelDecorEast;labelDecorNorth;labelDecorHeading;labelDecorColor;labelDecorLit;labelDecorSightingUrl;labelMilestones;labelMilestoneLabel;labelMilestoneNote;labelDecorWidth;labelDecorLength;labelDecorHeight;labelDecorModel;labelDecorModelAdvanced;labelDecorModelUrl;labelDecorModelTitle;labelDecorModelAuthor;labelDecorModelLicense;labelDecorModelSource;labelDecorFloors;labelDecorOccupiedFloor;labelDecorWitnessSide;labelDecorWindows;optionWitnessSideNone;optionDecorBuilding;optionDecorTree;optionDecorCrop;optionDecorMound;optionDecorStreetlight;optionDecorVehicle;optionDecorAircraft;optionDecorEntity;labelDecorLights;optionDecorWitness;recorder;isRecording=!1;messages=Gg;currentAppearance={...VT};currentSourceId=cl;selectedSourceIds=new Set([cl]);currentDecorId;contextMenuDecorId;contextMenuPoint;dragState;cameraDragState;hoverCursor;indoorLookYawDeg=0;indoorLookPitchDeg=0;lastInhabitedKey;handleKeyDown=e=>{if(e.key==="Escape"&&(this.isRecording&&this.toggleRecording(),this.confirmOverlay.hidden||this.answerConfirm(!1),this.contextMenu.hidden||this.hideContextMenu(),this.decorContextMenu.hidden||this.hideDecorContextMenu()),Q0.has(e.key)||e.key==="Delete"||e.key==="Backspace"){const t=e.composedPath()[0];if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;Q0.has(e.key)?this.moveOrResizeSelectedShapes(e):this.deleteShape()}};handleDragPointerMove=e=>this.onDragPointerMove(e);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${o1}</style>${r1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Yd),this.sceneElement.setAttribute("show-compass",""),this.sceneElement.setAttribute(Ws,""),this.sceneElement.animateWhilePaused=!0,this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.ufoElement.showToolbar=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetsGroup=this.shadow.getElementById("presets-group"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),polygon:this.shadow.getElementById("preset-polygon")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.blurInput=this.shadow.getElementById("blur"),this.brightnessInput=this.shadow.getElementById("brightness"),this.blurBoundOutput=this.shadow.getElementById("blur-bound"),this.sourceSelect=this.shadow.getElementById("source"),this.shapeTitleInput=this.shadow.getElementById("shapeTitle"),this.utcOffsetInput=this.shadow.getElementById("utcOffsetHours"),this.timeZoneSelect=this.shadow.getElementById("timeZone"),this.apparentWidthInput=this.shadow.getElementById("apparentWidth"),this.realWidthInput=this.shadow.getElementById("realWidth"),this.objectDistanceInput=this.shadow.getElementById("objectDistance"),this.sizeLockSelect=this.shadow.getElementById("sizeLock"),this.apparentSizeOutput=this.shadow.getElementById("apparent-size"),this.realSizeOutput=this.shadow.getElementById("real-size"),this.clearDistanceHypothesisButton=this.shadow.getElementById("clear-distance-hypothesis"),this.depthBasisOutput=this.shadow.getElementById("depth-basis"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.deleteShapeButton=this.shadow.getElementById("delete-shape"),this.contextMenu=this.shadow.getElementById("context-menu"),this.contextGroupButton=this.shadow.getElementById("context-group"),this.contextUngroupButton=this.shadow.getElementById("context-ungroup"),this.contextBringToFrontButton=this.shadow.getElementById("context-bring-to-front"),this.contextSendToBackButton=this.shadow.getElementById("context-send-to-back"),this.contextDeleteButton=this.shadow.getElementById("context-delete"),this.contextAddVertexButton=this.shadow.getElementById("context-add-vertex"),this.contextDeleteVertexButton=this.shadow.getElementById("context-delete-vertex"),this.decorContextMenu=this.shadow.getElementById("decor-context-menu"),this.contextViewTestimonyButton=this.shadow.getElementById("context-view-testimony"),this.contextMasksSubmenu=this.shadow.getElementById("context-masks-submenu"),this.labelContextMasks=this.shadow.getElementById("label-context-masks"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.switchTimeDisplay()),t.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.switchTimeDisplay())});this.loopButton=this.shadow.getElementById("loop"),this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.importFileInput=this.shadow.getElementById("import-file"),this.importUrlInput=this.shadow.getElementById("import-url"),this.importUrlButton=this.shadow.getElementById("import-url-button"),this.narrativeKeyInput=this.shadow.getElementById("narrativeKey"),this.narrativeWorkspaceInput=this.shadow.getElementById("narrativeWorkspace"),this.narrativeRememberInput=this.shadow.getElementById("narrativeRemember"),this.narrativeDraftButton=this.shadow.getElementById("narrative-draft"),this.narrativeStopButton=this.shadow.getElementById("narrative-stop"),this.narrativeCreditLink=this.shadow.getElementById("narrative-credit"),this.narrativeStatus=this.shadow.getElementById("narrative-status"),this.narrativeReport=this.shadow.getElementById("narrative-report"),this.placeNameInput=this.shadow.getElementById("placeName"),this.searchPlaceButton=this.shadow.getElementById("search-place"),this.placeMatchRow=this.shadow.getElementById("place-match-row"),this.placeMatchSelect=this.shadow.getElementById("placeMatch"),this.placeStatusText=this.shadow.getElementById("place-status-text"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.pitchInput=this.shadow.getElementById("pitch"),this.rollInput=this.shadow.getElementById("roll"),this.elevationInput=this.shadow.getElementById("elevation"),this.groundElevationOutput=this.shadow.getElementById("ground-elevation"),this.obsTimeInput=this.shadow.getElementById("obs-time"),this.obsEndTimeInput=this.shadow.getElementById("obs-end-time"),this.obsTimeNativeInput=this.shadow.getElementById("obs-time-native"),this.obsEndTimeNativeInput=this.shadow.getElementById("obs-end-time-native"),this.obsTimeQualifier=this.shadow.getElementById("obs-time-qualifier"),this.obsEndTimeQualifier=this.shadow.getElementById("obs-end-time-qualifier"),this.edtfModeButton=this.shadow.getElementById("edtf-mode"),this.witnessIdInput=this.shadow.getElementById("witnessId"),this.witnessDirNameInput=this.shadow.getElementById("witnessDirName"),this.witnessTitleInput=this.shadow.getElementById("witnessTitle"),this.witnessLastNameInput=this.shadow.getElementById("witnessLastName"),this.witnessFirstNamesInput=this.shadow.getElementById("witnessFirstNames"),this.witnessAgeInput=this.shadow.getElementById("witnessAge"),this.witnessOccupationInput=this.shadow.getElementById("witnessOccupation"),this.testimonySourceSelect=this.shadow.getElementById("testimonySource"),this.testimonyFollowedUpSelect=this.shadow.getElementById("testimonyFollowedUp"),this.caseIdInput=this.shadow.getElementById("caseId"),this.descriptionInput=this.shadow.getElementById("description"),this.tagsInput=this.shadow.getElementById("tags"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.highCloudCoverInput=this.shadow.getElementById("highCloudCover"),this.iceCrystalAlignmentInput=this.shadow.getElementById("iceCrystalAlignment"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.cloudBaseInput=this.shadow.getElementById("cloudBase"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.stormInput=this.shadow.getElementById("storm"),this.weatherInferredInput=this.shadow.getElementById("weatherInferred"),this.weatherSourceText=this.shadow.getElementById("weather-source-text"),this.skyCandidatesOutput=this.shadow.getElementById("sky-candidates"),this.showMeteorButton=this.shadow.getElementById("show-meteor"),this.showCometButton=this.shadow.getElementById("show-comet"),this.weatherSourceLink=this.shadow.getElementById("weather-source-link"),this.weatherFields=[this.cloudCoverInput,this.highCloudCoverInput,this.iceCrystalAlignmentInput,this.cloudDarknessInput,this.cloudBaseInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.stormInput],this.soundKindSelect=this.shadow.getElementById("soundKind"),this.soundVolumeInput=this.shadow.getElementById("soundVolume"),this.soundPitchInput=this.shadow.getElementById("soundPitch"),this.soundPitchValue=this.shadow.getElementById("sound-pitch-value"),this.soundSrcInput=this.shadow.getElementById("soundSrc"),this.soundFields=[this.soundKindSelect,this.soundVolumeInput,this.soundPitchInput,this.soundSrcInput],this.buildSoundKindOptions(),this.instrumentSelect=this.shadow.getElementById("instrument"),this.focalLengthInput=this.shadow.getElementById("focalLength"),this.labelFocalLength=this.shadow.getElementById("label-focal-length"),this.unitFocalLength=this.shadow.getElementById("unit-focal-length"),this.labelFNumber=this.shadow.getElementById("label-f-number"),this.labelExposure=this.shadow.getElementById("label-exposure"),this.fNumberInput=this.shadow.getElementById("fNumber"),this.exposureInput=this.shadow.getElementById("exposureSeconds"),this.focusDistanceInput=this.shadow.getElementById("focusDistance"),this.labelFocusDistance=this.shadow.getElementById("label-focus-distance"),this.refreshInstrumentOptions(),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelBlur=this.shadow.getElementById("label-blur"),this.labelBrightness=this.shadow.getElementById("label-brightness"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelShapeTitle=this.shadow.getElementById("label-shape-title"),this.labelUtcOffset=this.shadow.getElementById("label-utc-offset"),this.labelApparentWidth=this.shadow.getElementById("label-apparent-width"),this.labelRealWidth=this.shadow.getElementById("label-real-width"),this.labelObjectDistance=this.shadow.getElementById("label-object-distance"),this.labelSizeLock=this.shadow.getElementById("label-size-lock"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelSoundGroup=this.shadow.getElementById("label-sound-group"),this.labelSoundKind=this.shadow.getElementById("label-sound-kind"),this.labelSoundVolume=this.shadow.getElementById("label-sound-volume"),this.labelSoundPitch=this.shadow.getElementById("label-sound-pitch"),this.labelSoundSrc=this.shadow.getElementById("label-sound-src"),this.labelDuration=this.shadow.getElementById("label-duration"),this.placeSourceRow=this.shadow.getElementById("place-source-row"),this.weatherSourceRow=this.shadow.getElementById("weather-source-row"),this.terrainSourceRows=this.shadow.getElementById("terrain-source-rows"),this.labelPlaceName=this.shadow.getElementById("label-place-name"),this.labelPlaceMatch=this.shadow.getElementById("label-place-match"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelRoll=this.shadow.getElementById("label-roll"),this.labelElevation=this.shadow.getElementById("label-elevation"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelObservationEndTime=this.shadow.getElementById("label-observation-end-time"),this.labelWitnessId=this.shadow.getElementById("label-witness-id"),this.labelWitnessDirName=this.shadow.getElementById("label-witness-dir-name"),this.labelWitnessTitle=this.shadow.getElementById("label-witness-title"),this.labelWitnessLastName=this.shadow.getElementById("label-witness-last-name"),this.labelWitnessFirstNames=this.shadow.getElementById("label-witness-first-names"),this.labelWitnessAge=this.shadow.getElementById("label-witness-age"),this.labelWitnessOccupation=this.shadow.getElementById("label-witness-occupation"),this.labelTestimonySource=this.shadow.getElementById("label-testimony-source"),this.labelTestimonyFollowedUp=this.shadow.getElementById("label-testimony-followed-up"),this.labelCaseId=this.shadow.getElementById("label-case-id"),this.labelDescription=this.shadow.getElementById("label-description"),this.labelTags=this.shadow.getElementById("label-tags"),this.labelImportFile=this.shadow.getElementById("label-import-file"),this.labelImportUrl=this.shadow.getElementById("label-import-url"),this.labelNarrativeKey=this.shadow.getElementById("label-narrative-key"),this.labelNarrativeWorkspace=this.shadow.getElementById("label-narrative-workspace"),this.labelNarrativeRemember=this.shadow.getElementById("label-narrative-remember"),this.labelShapeGroup=this.shadow.getElementById("label-shape-group"),this.labelTemporalGroup=this.shadow.getElementById("label-temporal-group"),this.labelLocationGroup=this.shadow.getElementById("label-location-group"),this.labelObservationGroup=this.shadow.getElementById("label-observation-group"),this.labelWitnessGroup=this.shadow.getElementById("label-witness-group"),this.labelWeatherGroup=this.shadow.getElementById("label-weather-group"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelHighCloud=this.shadow.getElementById("label-high-cloud"),this.labelIceAlignment=this.shadow.getElementById("label-ice-alignment"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelCloudBase=this.shadow.getElementById("label-cloud-base"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelStorm=this.shadow.getElementById("label-storm"),this.labelWeatherInferred=this.shadow.getElementById("label-weather-inferred"),this.labelInstrument=this.shadow.getElementById("label-instrument"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.decorKindSelect=this.shadow.getElementById("decorKind"),this.addDecorWitnessButton=this.shadow.getElementById("add-decor-witness"),this.addDecorBuildingButton=this.shadow.getElementById("add-decor-building"),this.deleteDecorButton=this.shadow.getElementById("delete-decor"),this.decorSelect=this.shadow.getElementById("decor"),this.decorTitleInput=this.shadow.getElementById("decorTitle"),this.decorEastInput=this.shadow.getElementById("decorEast"),this.decorNorthInput=this.shadow.getElementById("decorNorth"),this.decorHeadingInput=this.shadow.getElementById("decorHeading"),this.decorColorInput=this.shadow.getElementById("decorColor"),this.decorLitInput=this.shadow.getElementById("decorLit"),this.decorLightRigSelect=this.shadow.getElementById("decorLightRig"),this.lookAtDecorButton=this.shadow.getElementById("look-at-decor"),this.decorAltitudeInput=this.shadow.getElementById("decorAltitude"),this.labelDecorAltitude=this.shadow.getElementById("label-decor-altitude"),this.decorSightingUrlInput=this.shadow.getElementById("decorSightingUrl"),this.confirmOverlay=this.shadow.getElementById("confirm-overlay"),this.confirmMessage=this.shadow.getElementById("confirm-message"),this.confirmAcceptButton=this.shadow.getElementById("confirm-ok"),this.confirmDeclineButton=this.shadow.getElementById("confirm-cancel"),this.milestoneSelect=this.shadow.getElementById("milestone"),this.milestoneLabelInput=this.shadow.getElementById("milestoneLabel"),this.milestoneNoteInput=this.shadow.getElementById("milestoneNote"),this.addMilestoneButton=this.shadow.getElementById("add-milestone"),this.deleteMilestoneButton=this.shadow.getElementById("delete-milestone"),this.decorWidthInput=this.shadow.getElementById("decorWidth"),this.decorLengthInput=this.shadow.getElementById("decorLength"),this.decorHeightInput=this.shadow.getElementById("decorHeight"),this.decorModelSelect=this.shadow.getElementById("decorModel"),this.decorModelAdvanced=this.shadow.getElementById("decor-model-advanced"),this.decorModelUrlInput=this.shadow.getElementById("decorModelUrl"),this.decorModelTitleInput=this.shadow.getElementById("decorModelTitle"),this.decorModelAuthorInput=this.shadow.getElementById("decorModelAuthor"),this.decorModelLicenseInput=this.shadow.getElementById("decorModelLicense"),this.decorModelSourceInput=this.shadow.getElementById("decorModelSource"),this.decorFloorsInput=this.shadow.getElementById("decorFloors"),this.decorOccupiedFloorInput=this.shadow.getElementById("decorOccupiedFloor"),this.decorWitnessSideSelect=this.shadow.getElementById("decorWitnessSide"),this.decorWindowInputs={front:this.shadow.getElementById("decorWindowFront"),behind:this.shadow.getElementById("decorWindowBehind"),left:this.shadow.getElementById("decorWindowLeft"),right:this.shadow.getElementById("decorWindowRight"),"front-left":this.shadow.getElementById("decorWindowFrontLeft"),"front-right":this.shadow.getElementById("decorWindowFrontRight"),"behind-left":this.shadow.getElementById("decorWindowBehindLeft"),"behind-right":this.shadow.getElementById("decorWindowBehindRight")},this.labelDecorSide={front:this.shadow.getElementById("label-decor-window-front"),behind:this.shadow.getElementById("label-decor-window-behind"),left:this.shadow.getElementById("label-decor-window-left"),right:this.shadow.getElementById("label-decor-window-right"),"front-left":this.shadow.getElementById("label-decor-window-front-left"),"front-right":this.shadow.getElementById("label-decor-window-front-right"),"behind-left":this.shadow.getElementById("label-decor-window-behind-left"),"behind-right":this.shadow.getElementById("label-decor-window-behind-right")},this.optionWitnessSide={front:this.shadow.getElementById("option-witness-side-front"),behind:this.shadow.getElementById("option-witness-side-behind"),left:this.shadow.getElementById("option-witness-side-left"),right:this.shadow.getElementById("option-witness-side-right"),"front-left":this.shadow.getElementById("option-witness-side-front-left"),"front-right":this.shadow.getElementById("option-witness-side-front-right"),"behind-left":this.shadow.getElementById("option-witness-side-behind-left"),"behind-right":this.shadow.getElementById("option-witness-side-behind-right")},this.optionWitnessSideNone=this.shadow.getElementById("option-witness-side-none"),this.labelDecor=this.shadow.getElementById("label-decor"),this.labelDecorGroup=this.shadow.getElementById("label-decor-group"),this.labelDecorTitle=this.shadow.getElementById("label-decor-title"),this.labelDecorEast=this.shadow.getElementById("label-decor-east"),this.labelDecorNorth=this.shadow.getElementById("label-decor-north"),this.labelDecorHeading=this.shadow.getElementById("label-decor-heading"),this.labelDecorColor=this.shadow.getElementById("label-decor-color"),this.labelDecorLit=this.shadow.getElementById("label-decor-lit"),this.labelDecorSightingUrl=this.shadow.getElementById("label-decor-sighting-url"),this.labelMilestones=this.shadow.getElementById("label-milestones"),this.labelMilestoneLabel=this.shadow.getElementById("label-milestone-label"),this.labelMilestoneNote=this.shadow.getElementById("label-milestone-note"),this.labelDecorWidth=this.shadow.getElementById("label-decor-width"),this.labelDecorLength=this.shadow.getElementById("label-decor-length"),this.labelDecorHeight=this.shadow.getElementById("label-decor-height"),this.labelDecorModel=this.shadow.getElementById("label-decor-model"),this.labelDecorModelAdvanced=this.shadow.getElementById("label-decor-model-advanced"),this.labelDecorModelUrl=this.shadow.getElementById("label-decor-model-url"),this.labelDecorModelTitle=this.shadow.getElementById("label-decor-model-title"),this.labelDecorModelAuthor=this.shadow.getElementById("label-decor-model-author"),this.labelDecorModelLicense=this.shadow.getElementById("label-decor-model-license"),this.labelDecorModelSource=this.shadow.getElementById("label-decor-model-source"),this.labelDecorFloors=this.shadow.getElementById("label-decor-floors"),this.labelDecorOccupiedFloor=this.shadow.getElementById("label-decor-occupied-floor"),this.labelDecorWitnessSide=this.shadow.getElementById("label-decor-witness-side"),this.labelDecorWindows=this.shadow.getElementById("label-decor-windows"),this.optionDecorBuilding=this.shadow.getElementById("option-decor-building"),this.optionDecorTree=this.shadow.getElementById("option-decor-tree"),this.optionDecorCrop=this.shadow.getElementById("option-decor-crop"),this.optionDecorMound=this.shadow.getElementById("option-decor-mound"),this.optionDecorStreetlight=this.shadow.getElementById("option-decor-streetlight"),this.optionDecorVehicle=this.shadow.getElementById("option-decor-vehicle"),this.optionDecorAircraft=this.shadow.getElementById("option-decor-aircraft"),this.optionDecorEntity=this.shadow.getElementById("option-decor-entity"),this.labelDecorLights=this.shadow.getElementById("label-decor-lights"),this.optionDecorWitness=this.shadow.getElementById("option-decor-witness"),this.ufoElement.canvasElement.addEventListener("pointerdown",t=>{this.focus({preventScroll:!0}),this.onPointerDown(t)}),this.ufoElement.canvasElement.addEventListener("pointermove",t=>this.onPointerMove(t)),this.ufoElement.canvasElement.addEventListener("contextmenu",t=>this.onContextMenu(t)),this.contextGroupButton.addEventListener("click",()=>this.groupSelected()),this.contextUngroupButton.addEventListener("click",()=>this.ungroupSelected()),this.contextBringToFrontButton.addEventListener("click",()=>this.bringSelectedToFront()),this.contextSendToBackButton.addEventListener("click",()=>this.sendSelectedToBack()),this.contextDeleteButton.addEventListener("click",()=>{this.hideContextMenu(),this.deleteShape()}),this.contextAddVertexButton.addEventListener("click",()=>this.addVertexAtContextMenu()),this.contextDeleteVertexButton.addEventListener("click",()=>this.deleteVertexAtContextMenu()),this.contextViewTestimonyButton.addEventListener("click",()=>this.viewWitnessTestimony()),this.playPauseButton.addEventListener("click",()=>{this.ufoElement.togglePlayPause(),this.syncPlaybackControls()}),this.loopButton.addEventListener("click",()=>{this.ufoElement.toggleLoop(),this.syncPlaybackControls()}),this.seekInput.addEventListener("input",()=>this.ufoElement.currentTime=Number(this.seekInput.value)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.deleteShapeButton.addEventListener("click",()=>this.deleteShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.importFileInput.addEventListener("change",()=>this.importFromFile()),this.importUrlButton.addEventListener("click",()=>this.importFromUrl()),this.testimonySourceSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.testimonyFollowedUpSelect.addEventListener("change",()=>this.updateWitnessMetadata()),this.narrativeDraftButton.addEventListener("click",()=>this.draftFromDescription()),this.narrativeStopButton.addEventListener("click",()=>this.narrativeAbort?.abort()),this.narrativeRememberInput.addEventListener("change",()=>this.rememberNarrativeKey()),this.narrativeWorkspaceInput.addEventListener("input",()=>this.rememberNarrativeKey()),this.narrativeKeyInput.addEventListener("input",()=>{this.rememberNarrativeKey(),this.syncNarrativeEnabled()}),this.narrativeCreditLink.textContent=`${ws[0].name} — ${ws[0].credit}`,this.narrativeCreditLink.href=ws[0].creditUrl,this.labelNarrativeKey.textContent=this.messages.narrativeKey.replace("{source}",ws[0].name),this.narrativeWorkspaceInput.title=this.messages.narrativeWorkspaceHint,this.restoreNarrativeKey(),this.syncNarrativeEnabled(),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh(),this.updateDurationValidity(),this.scheduleWeatherLookup()}),this.sourceSelect.addEventListener("change",()=>this.selectUnit(this.sourceSelect.value)),this.shapeTitleInput.addEventListener("input",()=>this.updateShapeTitle()),this.apparentWidthInput.addEventListener("input",()=>this.typing(this.apparentWidthInput,()=>this.onApparentWidthInput())),this.realWidthInput.addEventListener("input",()=>this.typing(this.realWidthInput,()=>this.onRealWidthInput())),this.objectDistanceInput.addEventListener("input",()=>this.typing(this.objectDistanceInput,()=>this.onDistanceInput())),this.sizeLockSelect.addEventListener("change",()=>this.applySizeLock()),this.clearDistanceHypothesisButton.addEventListener("click",()=>this.clearDistanceHypothesis()),this.addDecorWitnessButton.addEventListener("click",()=>this.addDecor("witness")),this.addDecorBuildingButton.addEventListener("click",()=>this.addDecor()),this.deleteDecorButton.addEventListener("click",()=>this.deleteDecor()),this.decorSelect.addEventListener("change",()=>this.selectDecor(this.decorSelect.value));for(const t of[this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorAltitudeInput,this.decorHeadingInput,this.decorColorInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput])t.addEventListener("input",()=>this.updateDecor());this.decorWitnessSideSelect.addEventListener("change",()=>this.updateDecor()),this.decorModelSelect.addEventListener("change",()=>this.updateDecorModelChoice()),this.addMilestoneButton.addEventListener("click",()=>this.addMilestone()),this.deleteMilestoneButton.addEventListener("click",()=>this.deleteMilestone()),this.milestoneSelect.addEventListener("change",()=>this.selectMilestone(Number(this.milestoneSelect.value)));for(const t of[this.milestoneLabelInput,this.milestoneNoteInput])t.addEventListener("input",()=>this.updateMilestone());this.confirmAcceptButton.addEventListener("click",()=>this.answerConfirm(!0)),this.confirmDeclineButton.addEventListener("click",()=>this.answerConfirm(!1)),this.confirmOverlay.addEventListener("click",t=>{t.target===this.confirmOverlay&&this.answerConfirm(!1)});for(const t of Qs)this.decorWindowInputs[t].addEventListener("input",()=>this.updateDecorWindows());this.decorLitInput.addEventListener("input",()=>this.updateDecorLit()),this.decorLightRigSelect.addEventListener("change",()=>this.updateDecorLightRig()),this.lookAtDecorButton.addEventListener("click",()=>this.lookAtDecor()),this.showMeteorButton.addEventListener("click",()=>this.showNextMeteor()),this.showCometButton.addEventListener("click",()=>this.lookAtComet()),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.syncPlaybackControls(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.addEventListener("keydown",this.handleKeyDown);for(const t of em)this.presetButtons[t].addEventListener("click",()=>this.setAppearance({presetId:t}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.brightnessInput.addEventListener("input",()=>this.setAppearance({brightness:Number(this.brightnessInput.value)})),this.blurInput.addEventListener("input",()=>{this.setAppearance({blur:Number(this.blurInput.value)}),this.refreshBlurDistanceBound()}),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const t of[this.latInput,this.lngInput,this.headingInput,this.pitchInput,this.rollInput,this.elevationInput])t.addEventListener("input",()=>this.updateObserver());for(const t of[this.focalLengthInput,this.fNumberInput,this.exposureInput,this.focusDistanceInput])t.addEventListener("input",()=>this.updateObserver());this.searchPlaceButton.addEventListener("click",()=>void this.searchPlace()),this.placeNameInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.searchPlace())}),this.placeMatchSelect.addEventListener("change",()=>this.applyPlaceMatch(this.placeMatchSelect.selectedIndex)),this.placeNameInput.addEventListener("input",()=>this.updatePlaceName()),this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1)),this.instrumentSelect.addEventListener("change",()=>{const t=this.ufoElement.sighting.instrument;this.ufoElement.sighting.instrumentId=this.instrumentSelect.value;const n=new Map(this.ufoElement.sighting.timeline.allKeyframes.map(i=>[i.t,en.fovOf(this.ufoElement.sighting,i.t)]));this.retuneFieldOfView(t),this.retuneExposure(t),en.reproject(this.ufoElement.sighting,t,n),this.sceneElement.applyFrameFormat(),this.syncOpticsFromInstrument(),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}),this.utcOffsetInput.addEventListener("input",()=>this.updateUtcOffset()),this.timeZoneSelect.addEventListener("change",()=>{this.autoFilledTimeZone=void 0,this.updateTimeZone()}),this.obsTimeInput.addEventListener("input",()=>this.updateObservationTime()),this.obsEndTimeInput.addEventListener("input",()=>this.updateObservationEndTime()),this.obsTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeNativeInput.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.obsTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsTimeNativeInput,this.obsTimeQualifier,this.obsTimeInput,()=>this.updateObservationTime())),this.obsEndTimeQualifier.addEventListener("change",()=>this.writeFromPicker(this.obsEndTimeNativeInput,this.obsEndTimeQualifier,this.obsEndTimeInput,()=>this.updateObservationEndTime())),this.edtfModeButton.addEventListener("click",()=>this.setEdtfMode(!this.edtfMode)),this.obsTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsTimeInput)),this.obsEndTimeInput.addEventListener("blur",()=>this.validateEdtfTimeInput(this.obsEndTimeInput));for(const t of[this.witnessIdInput,this.witnessDirNameInput,this.witnessTitleInput,this.witnessLastNameInput,this.witnessFirstNamesInput,this.witnessAgeInput,this.witnessOccupationInput,this.caseIdInput])t.addEventListener("input",()=>this.updateWitnessMetadata());this.descriptionInput.addEventListener("input",()=>{this.updateDescription(),this.syncNarrativeEnabled()}),this.tagsInput.addEventListener("input",()=>this.updateTags());for(const t of this.weatherFields){if(t===this.iceCrystalAlignmentInput){t.addEventListener("input",()=>this.applyIceAlignmentAtPlayhead());continue}t.addEventListener("input",()=>this.applyWeatherAtPlayhead())}for(const t of this.soundFields)t.addEventListener("input",()=>this.applySoundAtPlayhead());this.weatherInferredInput.addEventListener("change",()=>this.onWeatherInferredToggled()),this.skyDetailsButton=this.shadow.getElementById("sky-details"),this.clampedLines=[this.shadow.getElementById("weather-source"),this.shadow.getElementById("sky-candidates")],this.skyDetailsButton.addEventListener("click",()=>this.toggleSkyDetails()),this.groupTabs=[...this.shadow.querySelectorAll(".group-tab")],this.groupPanels=this.groupTabs.map(t=>this.shadow.getElementById(t.getAttribute("aria-controls")));for(const t of this.groupTabs)t.addEventListener("click",()=>this.toggleGroup(t,!this.isGroupOpen(t)));this.paramSummary=this.shadow.getElementById("param-summary"),this.paramSummaryBuilder=new tf(this.messages,this.showerLanguage(),this.said,this.tagNames),this.paramSummary.addEventListener("click",t=>this.onParamSummaryClick(t)),this.toggleGroup(this.groupTabs[this.groupTabs.length-1],!0),this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncPlaybackControls(),this.refreshSourceRows(),this.refreshTimeQualifierOptions(),this.refreshTimeZoneOptions(),this.syncWeatherSourceState(),this.loadLocaleMessages()}static get observedAttributes(){return["src"]}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=-1);const e=this.getAttribute("src");e&&this.importFromUrl(e)}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.importFromUrl(n)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideContextMenuClick),this.endDrag()}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.endDrag(),this.ufoElement.sightingData=e,this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??cl,this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.currentDecorId=this.ufoElement.sighting.decor[0]?.id,this.refreshDecorList(),this.currentMilestoneT=this.ufoElement.sighting.milestones[0]?.t,this.refreshMilestoneList(),this.onSelectionOrTimeChanged(),this.syncDurationField(),this.syncObservationTimeFields(),this.syncObservationEndTimeFields(),this.chooseTimeInputMode(),this.syncWitnessMetadataFields(),this.refreshTimeZoneOptions(),this.utcOffsetInput.readOnly=this.ufoElement.sighting.event.timeZone!==void 0,this.syncUtcOffsetField(),this.syncPlaceNameField(),this.syncGroundElevationField(),this.syncWeatherOwnership()}exportJson(){const e=this.sightingData,t=`${e.witness?.id??"sighting"}-sighting.json`,n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),i=URL.createObjectURL(n),a=document.createElement("a");a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}async importFromFile(){const e=this.importFileInput.files?.[0];if(e)try{const t=await new Promise((n,i)=>{const a=new FileReader;a.onload=()=>n(a.result),a.onerror=()=>i(a.error),a.readAsText(e)});this.sightingData=JSON.parse(t)}catch{window.alert(this.messages.importError)}finally{this.importFileInput.value=""}}async importFromUrl(e=this.importUrlInput.value.trim()){if(e)try{this.sightingData=await Kd.json(e)}catch(t){window.alert(this.importErrorFor(t))}}importErrorFor(e){if(!(e instanceof Cs))return this.messages.importError;switch(e.kind){case"cors":return this.messages.importErrorCors;case"mixed-content":return this.messages.importErrorMixedContent;case"unreachable":return this.messages.importErrorUnreachable;case"status":return this.messages.importErrorStatus.replace("{status}",String(e.status??""));case"malformed":return this.messages.importErrorMalformed;default:return this.messages.importError}}static NARRATIVE_KEY_STORAGE="rr0-sighting-editor.narrative-key";static NARRATIVE_SCOPE_STORAGE="rr0-sighting-editor.narrative-workspace";narrativeProvider=ws[0].create();narrativeAbort;async draftFromDescription(){const e=this.descriptionInput.value.trim();if(e===""||this.narrativeAbort)return;const t=this.narrativeAbort=new AbortController;this.setNarrativeBusy(!0);try{const n=await this.narrativeProvider.draft({ask:e,current:this.sightingData,language:this.showerLanguage()==="fr"?"French":"English",credential:this.narrativeKeyInput.value.trim()||void 0,credentialScope:this.narrativeWorkspaceInput.value.trim()||void 0},t.signal);this.applyNarrativeDraft(n)}catch(n){const i=n instanceof Cn&&n.kind==="cancelled";this.narrativeStatus.textContent=i?"":this.narrativeErrorFor(n),this.narrativeStatus.classList.toggle("error",!i)}finally{this.narrativeAbort=void 0,this.setNarrativeBusy(!1)}}applyNarrativeDraft(e){const{description:t,...n}=e.recording,{utcOffsetHours:i,...a}=n,r=n.timeZone?a:n,o=mi.stated(r);if(o.length>0){const l=this.ufoElement.sighting.provenance,c=Ih(this.ufoElement.sighting);this.sightingData=mi.apply(c,Sl.loadable(r),o),this.ufoElement.sighting.provenance=l,this.recordNarrativeProvenance(e,o),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset()}this.narrativeStatus.textContent=o.length>0?this.messages.narrativeApplied.replace("{count}",String(o.length)):this.messages.narrativeUnchanged,this.narrativeStatus.classList.remove("error"),this.showNarrativeReport(e),this.syncNarrativeEnabled()}recordNarrativeProvenance(e,t){const n=this.ufoElement.sighting,i=new Set(t);for(const a of e.claims)!i.has(a.path)&&!t.some(r=>a.path.startsWith(`${r}.`))||n.provenance.set(a.path,{basis:a.basis,rationale:a.rationale,of:Mt.valueAt(Ih(this.ufoElement.sighting),a.path)})}static valueAt(e,t){let n=e;for(const i of t.split(".")){if(typeof n!="object"||n===null)return;n=n[i]}return n}showNarrativeReport(e){this.narrativeReport.replaceChildren();for(const t of["assumed","derived","stated"]){const n=e.claims.filter(i=>i.basis===t);if(n.length!==0){this.narrativeReport.append(this.narrativeHeading(this.messages[YT[t]]));for(const i of n){const a=document.createElement("div");a.className=`claim ${t}`;const r=document.createElement("code");r.textContent=i.path;const o=document.createElement(t==="stated"?"q":"span");o.textContent=i.rationale,a.append(r,o),this.narrativeReport.append(a)}}}if(e.gaps.length>0){this.narrativeReport.append(this.narrativeHeading(this.messages.narrativeGaps));const t=document.createElement("ul");t.className="gaps";for(const n of e.gaps){const i=document.createElement("li");i.textContent=n,t.append(i)}this.narrativeReport.append(t)}this.narrativeReport.hidden=this.narrativeReport.childElementCount===0}narrativeHeading(e){const t=document.createElement("h4");return t.textContent=e,t}setNarrativeBusy(e){this.descriptionInput.disabled=e,this.narrativeStopButton.hidden=!e,e&&(this.narrativeStatus.textContent=this.messages.narrativeWorking,this.narrativeStatus.classList.remove("error")),this.syncNarrativeEnabled()}syncNarrativeEnabled(){const e=ws[0].name,t=this.narrativeProvider.needsCredential&&this.narrativeKeyInput.value.trim()==="",n=this.descriptionInput.value.trim()==="";this.narrativeDraftButton.disabled=!!this.narrativeAbort||t||n,this.narrativeDraftButton.title=t?this.messages.narrativeNeedsKey.replace("{source}",e):n?this.messages.narrativeNeedsAsk:"",this.narrativeKeyInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeRememberInput.parentElement.hidden=!this.narrativeProvider.needsCredential,this.narrativeWorkspaceInput.parentElement.hidden=!this.narrativeProvider.acceptsCredentialScope;const i=this.narrativeKeyInput.value.trim(),a=i!==""&&!i.startsWith("sk-ant-");this.narrativeKeyInput.classList.toggle("invalid",a),this.narrativeKeyInput.title=a?this.messages.narrativeKeyUnlikely:""}narrativeErrorFor(e){if(!(e instanceof Cn))return this.messages.narrativeErrorMalformed;switch(e.kind){case"rejected":return this.messages.narrativeErrorRejected.replace("{detail}",e.detail??"");case"credential":return this.messages.narrativeErrorCredential;case"rate-limited":return this.messages.narrativeErrorRateLimited;case"refused":return this.messages.narrativeErrorRefused;case"unreachable":return this.messages.narrativeErrorUnreachable;default:return this.messages.narrativeErrorMalformed}}rememberNarrativeKey(){try{this.narrativeRememberInput.checked?(localStorage.setItem(Mt.NARRATIVE_KEY_STORAGE,this.narrativeKeyInput.value),localStorage.setItem(Mt.NARRATIVE_SCOPE_STORAGE,this.narrativeWorkspaceInput.value)):(localStorage.removeItem(Mt.NARRATIVE_KEY_STORAGE),localStorage.removeItem(Mt.NARRATIVE_SCOPE_STORAGE))}catch{}}restoreNarrativeKey(){let e=null;try{e=localStorage.getItem(Mt.NARRATIVE_KEY_STORAGE)}catch{return}e!==null&&(this.narrativeKeyInput.value=e,this.narrativeWorkspaceInput.value=localStorage.getItem(Mt.NARRATIVE_SCOPE_STORAGE)??"",this.narrativeRememberInput.checked=!0)}numberOrUndefined(e){return e===""?void 0:Number(e)}stringOrUndefined(e){return e===""?void 0:e}wrapDegrees(e,t){if(e===void 0)return;const n=(e%360+360)%360;return String(n)!==t.value&&(t.value=String(n)),n}refreshSourceRows(){this.placeSourceRow.replaceChildren(document.createTextNode(`${this.messages.according} `),this.sourcePicker("place",AT,e=>{this.placeProvider=e.create()})),this.weatherSourceRow.replaceChildren(this.sourcePicker("weather",IT,e=>{this.weatherInference=new mh(e.create()),this.scheduleWeatherLookup()})),this.terrainSourceRows.replaceChildren(this.labelledPicker("elevation",this.messages.sourceElevation,vh,()=>this.applyTerrainSources()),this.labelledPicker("imagery",this.messages.sourceImagery,$0,()=>this.applyTerrainSources()),this.labelledPicker("decor-model",this.messages.decorModel,bl,()=>this.applyDecorModelSource()))}sourcePicker(e,t,n){const i=document.createDocumentFragment(),a=document.createElement("select");a.id=`${e}Source`;for(const l of t){const c=document.createElement("option");c.value=l.id,c.textContent=l.name,c.title=l.credit,a.appendChild(c)}a.value=this.chosenSourceId.get(e)??t[0].id;const r=document.createElement("a");r.className="source-credit",r.target="_blank",r.rel="noopener noreferrer";const o=()=>{const l=Ea(t,a.value);a.title=l.credit,r.href=l.creditUrl,r.textContent=l.credit};return o(),a.addEventListener("change",()=>{this.chosenSourceId.set(e,a.value),o(),n(Ea(t,a.value))}),i.append(a,document.createTextNode(" "),r),i}labelledPicker(e,t,n,i){const a=document.createElement("label"),r=document.createElement("span");return r.textContent=t,a.append(r,this.sourcePicker(e,n,i)),a}applyTerrainSources(){this.sceneElement.setTerrainProviders({elevation:Ea(vh,this.chosenSourceId.get("elevation")).create(),imagery:Ea($0,this.chosenSourceId.get("imagery")).create()}),this.ufoElement.refresh()}applyDecorModelSource(){this.decorModelProvider=Ea(bl,this.chosenSourceId.get("decor-model")).create(),this.sceneElement.setDecorModelProvider(this.decorModelProvider),this.refreshDecorModelOptions(),this.ufoElement.refresh()}get placeSearchLanguage(){return navigator.languages?.[0]}set placeSearchProvider(e){this.placeProvider=e}async searchPlace(){const e=this.placeNameInput.value.trim();if(e==="")return;const t=++this.placeSearchToken;this.placeStatusText.textContent=this.messages.placeSearching;let n;try{n=await this.placeProvider.search(e,{language:this.placeSearchLanguage})}catch{if(t!==this.placeSearchToken)return;this.placeStatusText.textContent=this.messages.placeSearchFailed;return}t===this.placeSearchToken&&(this.placeMatches=n,this.refreshPlaceMatches(),n.length>0&&this.applyPlaceMatch(0))}refreshPlaceMatches(){this.placeMatchSelect.replaceChildren(...this.placeMatches.map(t=>{const n=document.createElement("option");return n.textContent=t.name,n.title=t.name,n})),this.placeMatchRow.hidden=this.placeMatches.length===0;const e=this.placeMatches.length===1?this.messages.placeMatchFound:this.messages.placeMatchesFound;this.placeStatusText.textContent=this.placeMatches.length===0?this.messages.placeNotFound:`${this.placeMatches.length} ${e} `,this.placeSourceRow.hidden=this.placeMatches.length===0}applyPlaceMatch(e){const t=this.placeMatches[e];t&&(this.placeMatchSelect.selectedIndex=e,this.placeNameInput.value=t.name,this.placeNameInput.title=t.name,this.latInput.value=String(t.lat),this.lngInput.value=String(t.lng),this.namedCoordinates={lat:t.lat,lng:t.lng},this.updateObserver())}updatePlaceName(){this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent="",this.placeSourceRow.hidden=!0,this.placeNameInput.title=this.placeNameInput.value,this.namedCoordinates=void 0,this.updateObserver()}schedulePlaceReverse(){if(!this.namedCoordinates)return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||Math.abs(e-this.namedCoordinates.lat)<Aa&&Math.abs(t-this.namedCoordinates.lng)<Aa||(clearTimeout(this.placeReverseTimer),this.placeReverseTimer=setTimeout(()=>void this.reversePlace(e,t),J0))}scheduleTimeZoneLookup(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);if(e===void 0||t===void 0)return;const n=this.ufoElement.sighting.event.timeZone;if(n&&n!==this.autoFilledTimeZone)return;const i=this.timeZoneLookedUpAt;i&&Math.abs(e-i.lat)<Aa&&Math.abs(t-i.lng)<Aa||(clearTimeout(this.timeZoneLookupTimer),this.timeZoneLookupTimer=setTimeout(()=>void this.lookUpTimeZone(e,t),J0))}async lookUpTimeZone(e,t){this.timeZoneLookedUpAt={lat:e,lng:t};const n=await this.timeZoneProvider.zoneAt(e,t),i=this.ufoElement.sighting.event.timeZone;!n||i&&i!==this.autoFilledTimeZone||this.timeZones.available().includes(n)&&(this.autoFilledTimeZone=n,this.timeZoneSelect.value=n,this.updateTimeZone(),this.dispatchEvent(new CustomEvent("sightingchange")))}async reversePlace(e,t){const n=++this.placeSearchToken;let i;try{i=await this.placeProvider.reverse(e,t,{language:this.placeSearchLanguage})}catch{return}n===this.placeSearchToken&&(this.namedCoordinates={lat:e,lng:t},this.placeNameInput.value=i?.name??"",this.placeNameInput.title=i?.name??"",this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=i?"":this.messages.placeNotFound,this.placeSourceRow.hidden=!i,this.updateObserver())}updateObserver(){if(this.ufoElement.playbackState==="playing")return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value),n=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),i=this.numberOrUndefined(this.pitchInput.value)??0,a=this.numberOrUndefined(this.rollInput.value)??0,r=this.numberOrUndefined(this.elevationInput.value)??this.groundElevationM??0,o=Math.max(0,r-(this.groundElevationM??0)),l=this.ufoElement.sighting.event,c=this.ufoElement.sighting.witnessTrack,h=this.ufoElement.currentTime,d=this.stringOrUndefined(this.placeNameInput.value.trim());l.place=e!==void 0&&t!==void 0?[{lat:e,lng:t,name:d}]:void 0;const u=this.ufoElement.sighting.instrument,f=this.numberOrUndefined(this.focalLengthInput.value),g=(u.frame&&f!==void 0?st.fieldOfViewDegAt(u,f):f)??this.currentFovDeg(),v=this.numberOrUndefined(this.fNumberInput.value),p=this.statedExposureSeconds(u);this.ufoElement.sighting.exposureSeconds=p===u.exposureSeconds?void 0:p;const m=this.numberOrUndefined(this.focusDistanceInput.value),S=Math.abs(g-st.fieldOfViewDeg(u))>.01||v!==u.fNumber||m!==void 0;e===void 0&&t===void 0&&n===void 0&&i===0&&a===0&&o===0&&!S?c.removeKeyframeAt(h):c.addKeyframe(h,{lat:e,lng:t,elevationM:o,headingDeg:n,pitchDeg:i,rollDeg:a===0?void 0:a,fovDeg:g,fNumber:v,focusDistanceM:m}),this.ufoElement.refresh(),this.scheduleWeatherLookup(),this.schedulePlaceReverse(),this.scheduleTimeZoneLookup(),this.scheduleGroundElevation(),this.updateUtcOffsetValidity()}applyEdtfTimeInput(e,t){const n=e.value.trim();if(n==="")t(void 0);else{const i=Zu(n);if(!i)return;t(i)}e.setCustomValidity(""),e.classList.remove("invalid"),this.dropDurationOutrankedByDates(),this.ufoElement.sighting.event.timeZone&&this.applyTimeZoneOffset(),this.ufoElement.refresh(),this.syncDurationField(),this.scheduleWeatherLookup()}dropDurationOutrankedByDates(){const e=this.ufoElement.sighting.event;e.durationSeconds!==void 0&&Ka({...e,durationSeconds:void 0})!==void 0&&(this.ufoElement.durationSeconds=void 0)}validateEdtfTimeInput(e){const t=e.value.trim();t===""||Zu(t)||(e.setCustomValidity(this.messages.edtfInvalid),e.classList.add("invalid"))}refreshTimeZoneOptions(){const e=document.createElement("option");e.value="",e.textContent=this.messages.timeZoneManual,this.timeZoneSelect.replaceChildren(e,...this.timeZones.available().map(t=>{const n=document.createElement("option");return n.value=t,n.textContent=t,n})),this.timeZoneSelect.value=this.ufoElement.sighting.event.timeZone??""}updateTimeZone(){const e=this.stringOrUndefined(this.timeZoneSelect.value);this.ufoElement.sighting.event.timeZone=e,this.applyTimeZoneOffset()}applyTimeZoneOffset(){const e=this.ufoElement.sighting.event,t=e.timeZone&&e.time?this.timeZones.offsetHoursAt(e.timeZone,e.time):void 0;t!==void 0&&(e.utcOffsetHours=t),this.utcOffsetInput.readOnly=e.timeZone!==void 0,this.syncUtcOffsetField(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateUtcOffset(){this.ufoElement.sighting.event.utcOffsetHours=this.numberOrUndefined(this.utcOffsetInput.value),this.updateUtcOffsetValidity(),this.ufoElement.refresh(),this.scheduleWeatherLookup()}updateObservationTime(){this.applyEdtfTimeInput(this.obsTimeInput,e=>{this.ufoElement.sighting.event.time=e})}updateObservationEndTime(){this.applyEdtfTimeInput(this.obsEndTimeInput,e=>{this.ufoElement.sighting.event.endTime=e})}updateWitnessMetadata(){const e=this.ufoElement.sighting,t=this.witnessFirstNamesInput.value.split(",").map(i=>i.trim()).filter(i=>i.length>0),n={id:this.stringOrUndefined(this.witnessIdInput.value),dirName:this.stringOrUndefined(this.witnessDirNameInput.value),title:this.stringOrUndefined(this.witnessTitleInput.value),lastName:this.stringOrUndefined(this.witnessLastNameInput.value),firstNames:t.length>0?t:void 0};e.witness=Object.values(n).some(i=>i!==void 0)?n:void 0,e.caseId=this.stringOrUndefined(this.caseIdInput.value),this.updateTestimony(),this.ufoElement.refresh()}updateTestimony(){const e=this.ufoElement.sighting,t=this.testimonyFollowedUpSelect.value,n={witnessAgeYears:this.numberOrUndefined(this.witnessAgeInput.value),witnessOccupation:this.witnessOccupationInput.value.trim()===""?void 0:this.said.write(e.testimony?.witnessOccupation,this.witnessOccupationInput.value,this.writingLanguage),source:this.stringOrUndefined(this.testimonySourceSelect.value),followedUp:t===""?void 0:t==="yes"};e.testimony=Object.values(n).some(i=>i!==void 0)?n:void 0}updateDescription(){this.ufoElement.sighting.event.description=this.said.write(this.ufoElement.sighting.event.description,this.descriptionInput.value,this.writingLanguage),this.ufoElement.refresh()}updateTags(){const e=this.tagsInput.value.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>this.tagNames.stored(t));this.ufoElement.sighting.event.tags=e.length>0?e:void 0,this.ufoElement.refresh()}applyWeatherAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio(),this.weatherFromRecords&&(this.weatherFromRecords=!1,this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState());const e={cloudCover:Number(this.cloudCoverInput.value),highCloudCover:Number(this.highCloudCoverInput.value),lowerCloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),cloudBaseM:this.numberOrUndefined(this.cloudBaseInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),storm:this.stormInput.checked};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}applyIceAlignmentAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;this.sceneElement.resumeWeatherAudio();const e={...Fs(this.ufoElement.sighting,this.ufoElement.currentTime),iceCrystalAlignment:Number(this.iceCrystalAlignmentInput.value)};this.ufoElement.sighting.weatherTrack.addKeyframe(this.ufoElement.currentTime,e),this.ufoElement.refresh()}buildSoundKindOptions(){for(const e of S1){const t=document.createElement("option");t.value=e,t.textContent=this.soundKindLabel(e,this.messages),this.soundKindOptions.set(e,t),this.soundKindSelect.appendChild(t)}}soundKindLabel(e,t){switch(e){case"hum":return t.soundHum;case"whistle":return t.soundWhistle;case"rumble":return t.soundRumble;case"crackle":return t.soundCrackle;default:return t.soundNone}}applySoundAtPlayhead(){if(this.ufoElement.playbackState==="playing")return;const e=this.readSound();this.ufoElement.sighting.soundTrack.addKeyframe(this.ufoElement.currentTime,e),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e),this.ufoElement.refresh(),this.previewSound(e)}previewSound(e){clearTimeout(this.soundPreviewTimer),this.ufoElement.previewSound(e),this.soundPreviewTimer=setTimeout(()=>this.ufoElement.stopSoundPreview(),OT)}readSound(){return{kind:this.soundKindSelect.value,volume:Number(this.soundVolumeInput.value),pitchHz:Number(this.soundPitchInput.value),src:this.soundSrcInput.value.trim()||void 0}}syncSoundFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Jd(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.soundKindSelect&&(this.soundKindSelect.value=e.kind),t!==this.soundVolumeInput&&(this.soundVolumeInput.value=String(e.volume)),t!==this.soundPitchInput&&(this.soundPitchInput.value=String(e.pitchHz)),t!==this.soundSrcInput&&(this.soundSrcInput.value=e.src??""),this.updateSoundPitchReadout(e.pitchHz),this.updateSoundFieldsDisabledState(e)}updateSoundPitchReadout(e){this.soundPitchValue.textContent=`${Math.round(e)} Hz`}updateSoundFieldsDisabledState(e){const t=e.kind==="none"&&!e.src;this.soundVolumeInput.disabled=t,this.soundSrcInput.disabled=t,this.soundPitchInput.disabled=t||e.src!==void 0}set weatherProvider(e){this.weatherInference=new mh(e),this.scheduleWeatherLookup()}onWeatherInferredToggled(){this.weatherFromRecords=this.weatherInferredInput.checked,this.weatherFromRecords?this.scheduleWeatherLookup():(this.cancelWeatherLookup(),this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}scheduleWeatherLookup(){this.weatherFromRecords&&(clearTimeout(this.weatherLookupTimer),this.weatherLookupTimer=setTimeout(()=>void this.inferWeather(),kT))}cancelWeatherLookup(){clearTimeout(this.weatherLookupTimer),this.weatherLookupToken++,this.weatherLookupPending=!1}async inferWeather(){if(!this.weatherFromRecords)return;const e=++this.weatherLookupToken;this.weatherLookupPending=!0,this.syncWeatherSourceState();const t=await this.weatherInference.infer(this.ufoElement.sighting);e!==this.weatherLookupToken||!this.weatherFromRecords||(this.weatherLookupPending=!1,this.weatherLookupResult=t,t.status==="inferred"?(this.weatherInference.applyTo(this.ufoElement.sighting,t),this.weatherTrackSpan=this.ufoElement.seekableDuration,this.ufoElement.refresh(),this.syncWeatherFromTimeline()):this.ufoElement.sighting.weatherSource=void 0,this.syncWeatherSourceState())}ensureWeatherTrackSpan(){if(!this.weatherFromRecords||this.ufoElement.sighting.weatherSource===void 0)return;const e=this.ufoElement.seekableDuration;this.weatherTrackSpan===void 0||e===this.weatherTrackSpan||(this.weatherTrackSpan=e,this.scheduleWeatherLookup())}syncWeatherSourceState(){const e=this.ufoElement.sighting.weatherSource,t=this.weatherFromRecords;for(const o of this.weatherFields)o.disabled=t&&e!==void 0&&o!==this.iceCrystalAlignmentInput||this.ufoElement.playbackState==="playing",this.ufoElement.playbackState==="playing"?o.title=this.messages.weatherWhilePlaying:o.title===this.messages.weatherWhilePlaying&&(o.title="");const n=this.weatherInference.canInfer(this.ufoElement.sighting);this.weatherInferredInput.disabled=!n,this.weatherInferredInput.checked=n&&this.weatherFromRecords;const i=n?this.messages.weatherInferredTitle:this.messages.weatherNeedsDateAndPlace;this.weatherInferredInput.title=i,this.labelWeatherInferred.title=i;const a=t&&e!==void 0;if(this.weatherSourceLink.hidden=!a,a){this.weatherSourceRow.hidden=!1,this.weatherSourceText.textContent="",this.weatherSourceLink.href=e.url,this.weatherSourceLink.textContent=this.observationInstantLabel();return}const r=t?this.weatherStatusMessage():"";this.weatherSourceText.textContent=r===""?"":`${r} `,this.weatherSourceRow.hidden=r===""}weatherStatusMessage(){if(this.weatherLookupPending)return this.messages.weatherLookingUp;switch(this.weatherLookupResult?.status){case"unavailable":return this.messages.weatherNoRecord;case"failed":return this.messages.weatherLookupFailed;default:return""}}observationInstantLabel(){const e=this.ufoElement.sighting.event,t=e.time&&Va(e.time,e.place?.[0]?.lng??0,e.utcOffsetHours);return t?`, ${t.toISOString().slice(0,16).replace("T"," ")} UTC`:""}syncWeatherOwnership(){const e=this.ufoElement.sighting;this.cancelWeatherLookup(),this.weatherLookupResult=void 0,this.weatherFromRecords=e.weatherSource!==void 0||e.weatherTrack.allKeyframes.length===0,this.syncWeatherSourceState(),this.weatherFromRecords&&e.weatherSource===void 0&&this.scheduleWeatherLookup()}syncDurationField(){if(this.shadow.activeElement!==this.durationInput){const e=Ka(this.ufoElement.sighting.event);this.durationInput.value=e!==void 0?String(e/1e3):""}this.updateDurationValidity()}updateDurationValidity(){const e=this.durationInput.value==="";this.durationInput.classList.toggle("missing-required",e),this.markUnansweredQuestions(),this.durationInput.setAttribute("aria-invalid",String(e));const t=D1(this.ufoElement.sighting.event);this.durationInput.title=t==="imprecise"?this.messages.durationImprecise:""}syncPlaybackControls(){this.ensureWeatherTrackSpan();const e=this.ufoElement.playbackState==="playing",t=this.ufoElement.seekableDuration>0;this.playPauseButton.textContent=e?"⏸":"▶",this.playPauseButton.disabled=!t;const n=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.loopButton.setAttribute("aria-pressed",String(this.ufoElement.autoReplayEnabled)),this.seekInput.max=String(this.ufoElement.seekableDuration),this.shadow.activeElement!==this.seekInput&&(this.seekInput.value=String(this.ufoElement.currentTime)),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}switchTimeDisplay(){this.ufoElement.toggleTimeDisplay(),this.timeStartLabel.textContent=this.ufoElement.positionLabel,this.timeEndLabel.textContent=this.ufoElement.durationLabel,this.syncTimeDisplaySwitch()}syncTimeDisplaySwitch(){const e=this.ufoElement.canSwitchTimeDisplay,t=this.ufoElement.showingClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime;for(const[n,i]of[[this.timeStartLabel,this.messages.currentPosition],[this.timeEndLabel,this.messages.duration]])n.title=e?`${i} — ${t}`:i,n.classList.toggle("switchable",e),e?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}static TIME_QUALIFIERS=[{value:"",key:"timeQualifierExact"},{value:"~",key:"timeQualifierApproximate"},{value:"?",key:"timeQualifierUncertain"},{value:"%",key:"timeQualifierBoth"}];refreshTimeQualifierOptions(){for(const e of[this.obsTimeQualifier,this.obsEndTimeQualifier]){const t=e.value;e.replaceChildren(...Mt.TIME_QUALIFIERS.map(n=>{const i=document.createElement("option");return i.value=n.value,i.textContent=this.messages[n.key],i})),e.value=t}}qualifierOf(e){const t=e.trim().slice(-1);return"?~%".includes(t)?t:""}isPickable(e){return e?e.year!==void 0&&e.month!==void 0&&e.day!==void 0&&e.hour!==void 0&&e.minute!==void 0&&(e.second===void 0||e.second===0):!1}pickerValueOf(e){if(!this.isPickable(e))return"";const t=(n,i=2)=>String(n).padStart(i,"0");return`${t(e.year,4)}-${t(e.month)}-${t(e.day)}T${t(e.hour)}:${t(e.minute)}`}writeFromPicker(e,t,n,i){e.value===""&&e.validity.badInput||(n.value=e.value===""?"":`${e.value}${t.value}`,i())}chooseTimeInputMode(){const e=this.ufoElement.sighting.event,t=n=>n===void 0||this.isPickable(n);this.setEdtfMode(!(t(e.time)&&t(e.endTime)))}setEdtfMode(e){this.edtfMode=e,this.edtfModeButton.setAttribute("aria-pressed",String(e));for(const[t,n,i]of[[this.obsTimeInput,this.obsTimeNativeInput,this.obsTimeQualifier],[this.obsEndTimeInput,this.obsEndTimeNativeInput,this.obsEndTimeQualifier]])t.hidden=!e,n.hidden=e,i.hidden=e}syncObservationTimeFields(){const e=this.ufoElement.sighting.event.time;this.obsTimeInput.value=e?_l(e):"",this.obsTimeNativeInput.value=this.pickerValueOf(e),this.obsTimeQualifier.value=this.qualifierOf(this.obsTimeInput.value),this.obsTimeInput.setCustomValidity(""),this.obsTimeInput.classList.remove("invalid")}syncObservationEndTimeFields(){const e=this.ufoElement.sighting.event.endTime;this.obsEndTimeInput.value=e?_l(e):"",this.obsEndTimeNativeInput.value=this.pickerValueOf(e),this.obsEndTimeQualifier.value=this.qualifierOf(this.obsEndTimeInput.value),this.obsEndTimeInput.setCustomValidity(""),this.obsEndTimeInput.classList.remove("invalid")}syncUtcOffsetField(){const e=this.ufoElement.sighting.event.utcOffsetHours;this.utcOffsetInput.value=e===void 0?"":String(e),this.updateUtcOffsetValidity()}updateUtcOffsetValidity(){const e=this.ufoElement.sighting.event.utcOffsetHours,t=this.ufoElement.sighting.event.place?.[0]?.lng,n=t===void 0?void 0:Math.round(t/15),i=e!==void 0&&n!==void 0&&Math.abs(e-n)>BT;this.utcOffsetInput.classList.toggle("invalid",i),this.utcOffsetInput.title=i?this.messages.utcOffsetImplausible.replace("{solar}",n>=0?`+${n}`:String(n)):""}scheduleGroundElevation(){const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value);e===void 0||t===void 0||this.groundElevationFor&&this.isSamePlace(this.groundElevationFor,e,t)||(clearTimeout(this.groundElevationTimer),this.groundElevationTimer=setTimeout(()=>void this.applyGroundElevation(e,t),UT))}isSamePlace(e,t,n){return Math.abs(e.lat-t)<Aa&&Math.abs(e.lng-n)<Aa}async applyGroundElevation(e,t){const n=++this.groundElevationToken,i=Ea(vh,this.chosenSourceId.get("elevation")),a=await new Du(i.create()).at(e,t);if(n!==this.groundElevationToken||a===void 0)return;this.groundElevationFor={lat:e,lng:t};const r=Math.max(0,(this.numberOrUndefined(this.elevationInput.value)??0)-(this.groundElevationM??0));this.groundElevationM=Math.round(a),this.syncElevationField(r),this.updateObserver()}syncElevationField(e){const t=this.groundElevationM;this.elevationInput.value=String(Math.round((t??0)+e)),this.elevationInput.min=t===void 0?"":String(t),this.elevationInput.title=t===void 0?"":this.messages.altitudeAboveSeaLevel,this.groundElevationOutput.textContent=t===void 0?"":this.messages.groundAt.replace("{m}",String(t))}syncGroundElevationField(){this.groundElevationToken++,clearTimeout(this.groundElevationTimer),this.groundElevationM=void 0,this.groundElevationFor=void 0,this.syncElevationField(bt(this.ufoElement.sighting,0)?.elevationM??0),this.scheduleGroundElevation()}syncPlaceNameField(){const e=this.ufoElement.sighting.event.place?.[0],t=e?.name??"";this.placeNameInput.value=t,this.placeNameInput.title=t,this.namedCoordinates=e&&t?{lat:e.lat,lng:e.lng}:void 0,this.placeMatches=[],this.placeMatchRow.hidden=!0,this.placeStatusText.textContent=""}syncWitnessMetadataFields(){const e=this.ufoElement.sighting;this.witnessIdInput.value=e.witness?.id??"",this.witnessDirNameInput.value=e.witness?.dirName??"",this.witnessTitleInput.value=e.witness?.title??"",this.witnessLastNameInput.value=e.witness?.lastName??"",this.witnessFirstNamesInput.value=e.witness?.firstNames?.join(", ")??"",this.caseIdInput.value=e.caseId??"",this.witnessAgeInput.value=e.testimony?.witnessAgeYears?.toString()??"",this.witnessOccupationInput.value=this.said.read(e.testimony?.witnessOccupation)??"",this.testimonySourceSelect.value=e.testimony?.source??"",this.testimonyFollowedUpSelect.value=e.testimony?.followedUp===void 0?"":e.testimony.followedUp?"yes":"no",this.descriptionInput.value=this.said.read(e.event.description)??"",this.showTags(),this.instrumentSelect.value=e.instrument.id}syncWeatherFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=Fs(this.ufoElement.sighting,this.ufoElement.currentTime),t=this.shadow.activeElement;t!==this.cloudCoverInput&&(this.cloudCoverInput.value=String(e.cloudCover)),t!==this.highCloudCoverInput&&(this.highCloudCoverInput.value=String(e.highCloudCover??0)),t!==this.iceCrystalAlignmentInput&&(this.iceCrystalAlignmentInput.value=String(e.iceCrystalAlignment??_h)),t!==this.cloudDarknessInput&&(this.cloudDarknessInput.value=String(e.cloudDarkness)),t!==this.cloudBaseInput&&(this.cloudBaseInput.value=e.cloudBaseM===void 0?"":String(e.cloudBaseM)),t!==this.precipitationTypeSelect&&(this.precipitationTypeSelect.value=e.precipitationType),t!==this.precipitationIntensityInput&&(this.precipitationIntensityInput.value=String(e.precipitationIntensity)),t!==this.windDirectionInput&&(this.windDirectionInput.value=String(e.windDirectionDeg)),t!==this.windSpeedInput&&(this.windSpeedInput.value=String(e.windSpeed)),t!==this.stormInput&&(this.stormInput.checked=e.storm)}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=e.witnessTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),n=e.event.place?.[0],i=this.shadow.activeElement;i!==this.latInput&&(this.latInput.value=t?.lat!==void 0?String(t.lat):n?String(n.lat):""),i!==this.lngInput&&(this.lngInput.value=t?.lng!==void 0?String(t.lng):n?String(n.lng):""),i!==this.headingInput&&(this.headingInput.value=t?.headingDeg!==void 0?String(this.rounded(t.headingDeg)):""),i!==this.pitchInput&&(this.pitchInput.value=String(this.rounded(t?.pitchDeg??0)),this.rollInput.value=String(this.rounded(t?.rollDeg??0))),i!==this.elevationInput&&this.syncElevationField(t?.elevationM??0)}get appearance(){return{...this.currentAppearance}}set appearance(e){this.setAppearance(e)}setAppearance(e){const t="presetId"in e;this.currentAppearance={...this.currentAppearance,...e},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead(void 0,t)}applyAppearanceAtPlayhead(e,t=!0){const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=n.getInterpolatedShapeAt(i,this.currentSourceId),r=this.buildAppearanceShape(e??a?.bounds??this.defaultBounds(),a,t);this.commitShapes(i,[{sourceId:this.currentSourceId,shape:r}]),this.ufoElement.refresh()}buildAppearanceShape(e,t,n=!0){if(t&&!n)return{...t,color:this.currentAppearance.color,transparency:this.currentAppearance.transparency,haloScale:this.currentAppearance.haloScale,blur:this.currentAppearance.blur,brightness:this.currentAppearance.brightness};const i=Ku(e,this.currentAppearance);return t?{...i,angle:t.angle,title:t.title,selected:t.selected}:i}toggleSkyDetails(){const e=this.skyDetailsButton.getAttribute("aria-expanded")!=="true";this.skyDetailsButton.setAttribute("aria-expanded",String(e)),this.skyDetailsButton.textContent=e?"▴":"▾",this.skyDetailsButton.title=e?this.messages.skyDetailsHide:this.messages.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title);for(const t of this.clampedLines)t.classList.toggle("clamped",!e)}isGroupOpen(e){return e.getAttribute("aria-expanded")==="true"}toggleGroup(e,t){for(const[n,i]of this.groupTabs.entries()){const a=i===e&&t;i.setAttribute("aria-expanded",String(a)),this.groupPanels[n].hidden=!a}}static SUMMARY_GROUPS=["observation","witness","location","decor","temporal","weather","sound"];static PANEL_ORDER=["observation","witness","location","decor","temporal","weather","sound","shape"];refreshParamSummary(){const t=this.paramSummaryBuilder.entriesFor(this.ufoElement.sighting,this.ufoElement.currentTime,{decorId:this.currentDecorId,decorPicker:!0,groundElevationM:this.groundElevationM??0}).map(i=>({...i,panel:Mt.SUMMARY_GROUPS.indexOf(i.group)})),n=t.map(i=>`${i.field}=${i.label}=${i.value}${i.unit}${i.fromSource?"*":""}`).join("|");n!==this.paramSummarySignature&&(this.paramSummarySignature=n,this.paramChips=t,this.renderParamSummary(),this.runAssessments())}paramChips=[];renderParamSummary(){const e=Mt.NESTED_GROUPS,t=[];let n;for(const i of[...this.paramChips,...this.assessmentChips]){if(n&&n.group!==i.group&&(n=void 0),e.includes(i.group)&&!n){const r=document.createElement("span");r.className="param-nest",r.dataset.group=i.group;const o=document.createElement("span");o.className="param-nest-label",o.textContent=i.group==="assessment"?this.messages.assessmentGroup:Mt.tabLabel(this.groupTabs[Mt.SUMMARY_GROUPS.indexOf(i.group)]),r.append(o),n={group:i.group,element:r},t.push(r)}const a=this.paramChip(i);n?n.element.append(a):t.push(a)}this.paramSummary.replaceChildren(...t)}static NESTED_GROUPS=["witness","decor","assessment"];static QUESTION_FIELDS={when:{panel:"temporal",fields:["obs-time","obs-time-native"]},where:{panel:"location",fields:["lat","lng"]},facing:{panel:"location",fields:["heading"]},"apparent-size":{panel:"shape",fields:[]},"sky-position":{panel:"shape",fields:[]},"how-long":{panel:"temporal",fields:["durationSeconds","obs-end-time","obs-end-time-native"]},appearance:{panel:"shape",fields:["shapeTitle","color"]},movement:{panel:"shape",fields:[]},sound:{panel:"sound",fields:["soundKind"]},conditions:{panel:"weather",fields:["cloudCover"]}};assessmentChips=[];assessmentToken=0;async runAssessments(){const e=++this.assessmentToken,t=await new t1(this.messages).read(this.ufoElement.sighting);e===this.assessmentToken&&(this.assessmentChips=t.entries.map(n=>({...n,panel:Mt.PANEL_ORDER.indexOf(n.about??"")})),this.markUnansweredQuestions(t.unanswered),this.renderParamSummary())}static tabLabel(e){return(e.querySelector("span:not(.tab-badge)")??e).textContent.trim()}static badgeOn(e){const t=e.querySelector(".tab-badge");if(t)return t;const n=document.createElement("span");return n.className="tab-badge",n.hidden=!0,e.append(n),n}unansweredQuestions=new Set;markUnansweredQuestions(e=this.unansweredQuestions){this.unansweredQuestions=e;const t=new Set;for(const a of e){const r=Mt.QUESTION_FIELDS[a];if(r&&!r.fields.some(o=>this.shadow.getElementById(o)?.classList.contains("missing-required")))for(const o of r.fields){const l=this.shadow.getElementById(o);l&&!l.hidden&&l.value===""&&t.add(o)}}for(const[a,r]of Object.entries(Mt.QUESTION_FIELDS))for(const o of Mt.QUESTION_FIELDS[a].fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=t.has(o)&&!l.classList.contains("missing-required");l.classList.toggle("wanted",c),(c||l.title===this.messages.questionUnanswered)&&(l.title=c?this.messages.questionUnanswered:"")}const n=new Map;let i;for(const[a,r]of Object.entries(Mt.QUESTION_FIELDS))for(const o of r.fields){const l=this.shadow.getElementById(o);if(!l)continue;const c=l.classList.contains("missing-required");!c&&!l.classList.contains("wanted")||(c&&(i=r.panel),n.set(r.panel,(n.get(r.panel)??0)+1))}for(const[a,r]of this.groupTabs.entries()){const o=Mt.PANEL_ORDER[a],l=n.get(o)??0,c=o===i,h=Mt.badgeOn(r);h.hidden=l===0,h.textContent=String(l),h.classList.toggle("optional",!c),r.title=l===0?"":c?this.messages.durationRequired:this.messages.questionsUnanswered.replace("{count}",String(l))}}paramChip(e){const t=document.createElement("button");t.type="button",t.className=e.fromSource?"param-chip from-source":"param-chip",t.dataset.panel=String(e.panel),t.dataset.field=e.field;const n=document.createElement("span");if(n.className="param-chip-label",n.textContent=`${e.label} `,t.append(n),e.color!==void 0){const a=document.createElement("span");a.className="param-chip-swatch",a.style.background=e.color,t.append(a)}const i=document.createElement("span");return i.className="param-chip-value",i.textContent=e.unit===""?e.value:`${e.value} ${e.unit}`,t.append(i),t}onParamSummaryClick(e){const t=e.target.closest(".param-chip");if(t==null)return;const n=Number(t.dataset.panel);if(n<0)return;const i=this.groupPanels[n];this.toggleGroup(this.groupTabs[n],!0);const a=t.dataset.field;if(a.startsWith("decor:")){this.currentDecorId=a.slice(6),this.refreshDecorList(),this.decorSelect.focus();return}const r=this.shadow.getElementById(a);r===null||!i.contains(r)||(r.focus(),r instanceof HTMLInputElement&&r.type!=="checkbox"&&r.type!=="color"&&r.type!=="range"&&r.select(),r.scrollIntoView?.({block:"center"}))}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.syncWeatherFromTimeline(),this.syncWeatherSourceState(),this.syncSoundFromTimeline(),this.syncDecorLitFromTimeline(),this.syncDecorPlacementFromTimeline(),this.syncIndoorLookReset(),this.updateAppearanceFieldsDisabledState(),this.updateShapeTitleValidity(),this.refreshRealSize(),this.refreshBlurDistanceBound(),this.refreshSkyCandidates(),this.refreshInstrumentOptions(),this.syncOpticsFromInstrument(),this.ufoElement.selectedSourceIds=this.selectedSourceIds;const e=this.ufoElement.sighting.timeline.sourceIds,t=e.filter(n=>this.selectedSourceIds.has(n)).length;this.deleteShapeButton.disabled=this.isRecording||this.ufoElement.playbackState==="playing"||t===0||e.length-t<1,this.refreshParamSummary()}updateAppearanceFieldsDisabledState(){const e=this.selectedSourceIds.size>1,t=e?this.messages.multipleShapesSelected:"";for(const n of[this.shapeTitleInput,this.colorInput,this.transparencyInput,this.haloScaleInput,this.blurInput,this.brightnessInput,this.apparentWidthInput,this.realWidthInput,this.objectDistanceInput,this.sizeLockSelect,this.clearDistanceHypothesisButton,this.sourceSelect,...Object.values(this.presetButtons)])n.disabled=e,n.title=t}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.selectedSourceIds.size>1)return;const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);e&&(this.currentAppearance={presetId:WT(e),color:e.color,transparency:e.transparency,haloScale:e.haloScale,blur:e.blur??0,brightness:e.brightness??0},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale),this.blurInput.value=String(this.currentAppearance.blur),this.brightnessInput.value=String(this.currentAppearance.brightness),this.shadow.activeElement!==this.shapeTitleInput&&(this.shapeTitleInput.value=this.said.read(e.title)??""),this.refreshApparentSize())}updateShapeTitle(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime,n=e.getInterpolatedShapeAt(t,this.currentSourceId);n&&(this.commitShapes(t,[{sourceId:this.currentSourceId,shape:{...n,title:this.said.write(n.title,this.shapeTitleInput.value,this.writingLanguage)}}]),this.ufoElement.refresh(),this.refreshSourceList(),this.updateShapeTitleValidity())}sizeLock="none";onApparentWidthInput(){const e=this.numberOrUndefined(this.apparentWidthInput.value);if(!(e===void 0||e<=0||this.selectedSourceIds.size!==1)){if(this.sizeLock==="real"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.sceneElement.setDistanceHypothesis(this.currentSourceId,et.distanceMAt(t,e))}this.applyApparentWidth(e)}}onRealWidthInput(){const e=this.numberOrUndefined(this.realWidthInput.value);if(e===void 0||e<=0||this.selectedSourceIds.size!==1)return;if(this.sizeLock==="apparent"){const n=this.currentApparentWidthDeg();n!==void 0&&n>0&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,et.distanceMAt(e,n)),this.refreshDepth());return}const t=this.currentDistanceM();t!==void 0&&t>0&&this.applyApparentWidth(et.angularWidthDeg({sizeM:e,distanceM:t}))}onDistanceInput(){const e=this.numberOrUndefined(this.objectDistanceInput.value);e===void 0||e<=0||this.applyDistance(e)}applyDistance(e){if(this.selectedSourceIds.size===1){if(this.sizeLock!=="apparent"){const t=this.numberOrUndefined(this.realWidthInput.value);t!==void 0&&t>0&&this.applyApparentWidth(et.angularWidthDeg({sizeM:t,distanceM:e}))}this.sceneElement.setDistanceHypothesis(this.currentSourceId,e),this.refreshDepth()}}applySizeLock(){this.sizeLock=this.sizeLockSelect.value,this.apparentWidthInput.readOnly=this.sizeLock==="apparent",this.realWidthInput.readOnly=this.sizeLock==="real",this.objectDistanceInput.readOnly=this.sizeLock==="distance"}currentApparentWidthDeg(){const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);if(e)return e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width)}currentDistanceM(){return this.sceneElement.depthOf(this.currentSourceId)?.distanceM}applyApparentWidth(e){const t=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,i=t.getInterpolatedShapeAt(n,this.currentSourceId);if(!i)return;const a=this.currentProjection(),r=a.degToPx(e),o=i.bounds.height*(i.bounds.width===0?1:r/i.bounds.width),l={x:i.bounds.x+(i.bounds.width-r)/2,y:i.bounds.y+(i.bounds.height-o)/2,width:r,height:o},c=a.ofBounds(l),h=i.kind==="oval"?{...i,bounds:l,angular:c}:{...i,bounds:l,angular:c,points:this.scalePoints(i,l)};this.commitShapes(n,[{sourceId:this.currentSourceId,shape:h}]),this.ufoElement.refresh(),this.refreshApparentSize()}scalePoints(e,t){const n=e.bounds.width===0?1:t.width/e.bounds.width,i=e.bounds.height===0?1:t.height/e.bounds.height;return e.points.map(a=>({x:a.x*n,y:a.y*i}))}refreshInstrumentOptions(){const e=this.ufoElement.sighting,t=e.event.time?.year,n=st.availableAt(t),i=e.instrument,a=n.includes(i)?n:[...n,i],r=this.instrumentSelect.value||i.id;this.instrumentSelect.replaceChildren();for(const o of a){const l=document.createElement("option");l.value=o.id;const c=o.name[this.showerLanguage()];l.textContent=n.includes(o)?c:this.messages.instrumentOutOfPeriod.replace("{name}",c),this.instrumentSelect.appendChild(l)}this.instrumentSelect.value=a.some(o=>o.id===r)?r:i.id}static exposureText(e){return e>=1?String(Math.round(e*100)/100):`1/${Math.round(1/e)}`}statedExposureSeconds(e){const t=Mt.exposureSeconds(this.exposureInput.value),n=e.exposureRangeSeconds;if(!n)return e.exposureSeconds??t;if(t!==void 0)return Math.min(n.max,Math.max(n.min,t))}static exposureSeconds(e){const t=e.trim();if(!t)return;const n=/^(\d*\.?\d+)\s*\/\s*(\d*\.?\d+)$/.exec(t);if(n){const a=Number(n[1]),r=Number(n[2]);return r>0?a/r:void 0}const i=Number(t);return Number.isFinite(i)&&i>0?i:void 0}syncOpticsFromInstrument(){const e=this.ufoElement.sighting,t=e.instrument,n=bt(e,this.ufoElement.currentTime),i=t.frame,a=n?.fovDeg??st.fieldOfViewDeg(t),r=i?st.focalLengthMmFor(t,a):a;this.focalLengthInput!==this.shadow.activeElement&&(this.focalLengthInput.value=r===void 0?"":String(Math.round(r*10)/10)),this.unitFocalLength.textContent=i?this.messages.unitMillimetres:this.messages.unitDegrees,this.labelFocalLength.textContent=i?this.messages.focalLength:this.messages.fieldOfView,this.focalLengthInput.disabled=i!==void 0&&i.focalRangeMm===void 0,this.focalLengthInput.min=String(i?.focalRangeMm?.minMm??1),this.focalLengthInput.max=String(i?.focalRangeMm?.maxMm??2e3);const o=n?.fNumber??t.fNumber;this.fNumberInput!==this.shadow.activeElement&&(this.fNumberInput.value=o===void 0?"":String(o)),this.setRowVisible(this.fNumberInput,t.fNumber!==void 0),this.fNumberInput.disabled=t.fNumberRange===void 0,this.fNumberInput.min=String(t.fNumberRange?.min??.7),this.fNumberInput.max=String(t.fNumberRange?.max??64);const l=e.exposure;this.exposureInput!==this.shadow.activeElement&&(this.exposureInput.value=l===void 0?"":Mt.exposureText(l)),this.setRowVisible(this.exposureInput,t.exposureSeconds!==void 0),this.exposureInput.disabled=t.exposureRangeSeconds===void 0,this.focusDistanceInput!==this.shadow.activeElement&&(this.focusDistanceInput.value=n?.focusDistanceM===void 0?"":String(n.focusDistanceM)),this.setRowVisible(this.focusDistanceInput,i!==void 0&&t.fNumber!==void 0)}retuneFieldOfView(e){const t=this.ufoElement.sighting,n=st.fieldOfViewDeg(e),i=st.fieldOfViewDeg(t.instrument);for(const a of[...t.witnessTrack.allKeyframes])Math.abs(a.pose.fovDeg-n)>zT||t.witnessTrack.addKeyframe(a.t,{...a.pose,fovDeg:i})}retuneExposure(e){const t=this.ufoElement.sighting,n=t.exposureSeconds,i=t.instrument.exposureRangeSeconds;if(n===void 0||n===e.exposureSeconds||!i){t.exposureSeconds=void 0;return}t.exposureSeconds=Math.min(i.max,Math.max(i.min,n))}currentFovDeg(){const e=this.ufoElement.sighting;return bt(e,this.ufoElement.currentTime)?.fovDeg??st.fieldOfViewDeg(e.instrument)}currentProjection(){return Qn.of(this.ufoElement.sighting.instrument,this.ufoElement.canvasElement.height,this.currentFovDeg())}refreshApparentSize(){const e=this.selectedSourceIds.size===1?this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId):void 0;if(!e){this.apparentSizeOutput.textContent="",this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=""),this.refreshRealSize();return}const t=e.angular?.widthDeg??this.currentProjection().pxToDeg(e.bounds.width),n=et.inMoons(t);this.hasFocus(this.apparentWidthInput)||(this.apparentWidthInput.value=this.plain(t,t<1?2:1)),this.apparentSizeOutput.textContent=this.messages.apparentSize.replace("{moons}",n.toLocaleString(void 0,{maximumFractionDigits:n<10?1:0})),this.refreshRealSize()}hasFocus(e){return this.typingIn===e}typingIn;typing(e,t){this.typingIn=e;try{t()}finally{this.typingIn=void 0}}plain(e,t){return String(Number(e.toFixed(t)))}refreshBlurDistanceBound(){const e=this.currentAppearance.blur;if(e<=0||this.selectedSourceIds.size!==1){this.blurBoundOutput.textContent="";return}const t=this.ufoElement.sighting.instrument,n=t.frame;if(!n){this.blurBoundOutput.textContent=this.messages.blurBoundNoInstrument;return}const i=bt(this.ufoElement.sighting,this.ufoElement.currentTime),a=i?.focusDistanceM;if(a!==void 0){this.blurBoundOutput.textContent=this.messages.blurBoundNotAtInfinity.replace("{focus}",this.meters(a));return}const r=(i?st.focalLengthMmFor(t,i.fovDeg):void 0)??n.focalLengthMm,o=i?.fNumber??t.fNumber;if(o===void 0||r<=0){this.blurBoundOutput.textContent="";return}const l=this.ufoElement.canvasElement.height;if(l<=0)return;const c=2*xh*e/l*n.heightMm,h=r*r/(o*c)/1e3;this.blurBoundOutput.textContent=this.messages.blurBound.replace("{max}",this.meters(h))}refreshRealSize(){if(this.refreshDepth(),this.selectedSourceIds.size!==1){this.realSizeOutput.textContent="";return}const e=this.currentSourceId;if(this.sceneElement.sizeContradictory(e)){this.realSizeOutput.textContent=this.messages.realSizeContradiction;return}const{minM:t,maxM:n}=this.sceneElement.sizeRangeOf(e);if(t===void 0&&n===void 0){this.realSizeOutput.textContent=this.messages.realSizeUnknown;return}const i=this.numberOrUndefined(this.realWidthInput.value),a=i!==void 0&&(t!==void 0&&i<t||n!==void 0&&i>n)?this.messages.realSizeOutside:"";if(t!==void 0&&n!==void 0){const r=this.sceneElement.distanceRangeAt(e,this.ufoElement.currentTime),o=r.minM===void 0||r.maxM===void 0?"":this.messages.realDistanceHere.replace("{min}",this.meters(r.minM)).replace("{max}",this.meters(r.maxM));this.realSizeOutput.textContent=this.messages.realSizeBetween.replace("{min}",this.meters(t)).replace("{max}",this.meters(n))+o+a;return}this.realSizeOutput.textContent=(t!==void 0?this.messages.realSizeAtLeast.replace("{min}",this.meters(t)):this.messages.realSizeAtMost.replace("{max}",this.meters(n)))+a}decimal(e,t){return e.toLocaleString(void 0,{minimumFractionDigits:t,maximumFractionDigits:t})}clearDistanceHypothesis(){this.selectedSourceIds.size===1&&(this.sceneElement.setDistanceHypothesis(this.currentSourceId,void 0),this.refreshDepth())}refreshDepth(){const e=this.selectedSourceIds.size===1?this.sceneElement.depthOf(this.currentSourceId):void 0;if(!e){this.depthBasisOutput.textContent="",this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=""),this.hasFocus(this.realWidthInput)||(this.realWidthInput.value="");return}const t=this.meters(e.distanceM);this.hasFocus(this.objectDistanceInput)||(this.objectDistanceInput.value=this.plain(e.distanceM,e.distanceM<10?1:0));const n=this.currentApparentWidthDeg();if(!this.hasFocus(this.realWidthInput)){const a=n===void 0||n<=0?void 0:et.sizeMAt(e.distanceM,n);this.realWidthInput.value=a===void 0?"":this.plain(a,a<1?2:a<10?1:0)}this.clearDistanceHypothesisButton.hidden=e.basis!=="hypothesis";const i={stated:this.messages.depthStated,hypothesis:this.messages.depthHypothesis,derived:this.messages.depthDerived,bounded:this.messages.depthBounded,conventional:this.messages.depthConventional}[e.basis];this.depthBasisOutput.textContent=i.replace("{m}",t)}commitShapes(e,t){const n=this.ufoElement.sighting,i=Qn.of(n.instrument,et.CANVAS_HEIGHT_PX,en.fovOf(n,e));n.timeline.addKeyframe(e,t.map(a=>{const r=en.aimOf(n,e,a.shape.bounds),o=i.ofBounds(a.shape.bounds);return{...a,shape:r?{...a.shape,aim:r,angular:o}:{...a.shape,angular:o}}}))}meters(e){const t=e<1?2:e<10?1:0;return e.toLocaleString(void 0,{maximumFractionDigits:t})}updateShapeTitleValidity(){const e=this.selectedSourceIds.size===1&&this.shapeTitleInput.value==="";this.shapeTitleInput.classList.toggle("invalid",e),this.shapeTitleInput.setAttribute("aria-invalid",String(e))}shapeLabel(e){const t=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,e),n=this.said.read(t?.title);if(n)return n;const i=/^ufo-(\d+)$/.exec(e);return i?`${this.messages.shape} ${i[1]}`:e}addShape(){if(this.isRecording)return;const e=this.ufoElement.sighting.timeline,t=new Set([...e.sourceIds,this.currentSourceId]);let n=t.size+1;for(;t.has(`ufo-${n}`);)n++;this.currentSourceId=`ufo-${n}`,this.selectedSourceIds=new Set([this.currentSourceId]),this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(e.sourceIds.length)),this.shapeTitleInput.value=this.shapeLabel(this.currentSourceId),this.updateShapeTitle()}deleteShape(){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline,t=e.sourceIds.filter(i=>this.selectedSourceIds.has(i));if(t.length===0||e.sourceIds.length-t.length<1)return;const n=t.length===1?this.messages.confirmDeleteShape.replace("{name}",this.shapeLabel(t[0])):this.messages.confirmDeleteShapes.replace("{count}",String(t.length));this.askConfirm(n,()=>this.removeShapes(t))}removeShapes(e){const t=this.ufoElement.sighting.timeline;for(const n of e)t.removeSource(n);this.currentSourceId=t.sourceIds[0],this.selectedSourceIds=new Set([this.currentSourceId]),this.refreshSourceList(),this.ufoElement.refresh()}askConfirm(e,t){this.answerConfirm(!1),this.confirmMessage.textContent=e,this.confirmOverlay.hidden=!1,this.confirmAcceptButton.focus(),this.confirmAnswer=t}answerConfirm(e){const t=this.confirmAnswer;this.confirmAnswer=void 0,this.confirmOverlay.hidden=!0,e&&t?.()}offsetDefaultBounds(e){const t=this.defaultBounds(),n=24;return{...t,x:t.x+e*n,y:t.y+e*n}}refreshSourceList(){const e=this.ufoElement.sighting.timeline,t=[...new Set([...e.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const n of t){const i=document.createElement("option");i.value=n,i.textContent=this.shapeLabel(n),this.sourceSelect.appendChild(i)}this.sourceSelect.value=this.currentSourceId}decorLabel(e){const t=this.said.read(e.title);if(t)return t;const i=this.ufoElement.sighting.decor.filter(r=>r.kind===e.kind).indexOf(e)+1;return`${this.decorKindSelect.querySelector(`option[value="${e.kind}"]`)?.textContent??e.kind} ${i}`}addDecor(e=this.decorKindSelect.value){const t=this.ufoElement.sighting,i={id:`decor-${t.decor.length+1}`,kind:e,title:this.nextDecorLabel(e),eastM:8*t.decor.length,northM:15,headingDeg:0,lit:!1,...e==="aircraft"?this.defaultAircraft():{},...e==="building"?{floors:Oa}:{},windows:sm(e)};t.decor=[...t.decor,i],this.currentDecorId=i.id,this.refreshDecorList(),this.ufoElement.refresh()}defaultAircraft(){const e=2*yh,t=Math.round(e/GT*1e3);return{lights:sc.byId("airliner")?.create(),track:[{t:0,eastM:-yh,northM:1e3,altitudeM:1500,headingDeg:90},{t,eastM:yh,northM:1e3,altitudeM:1500,headingDeg:90}]}}nextDecorLabel(e){const t=this.ufoElement.sighting.decor.filter(i=>i.kind===e).length;return`${this.decorKindSelect.querySelector(`option[value="${e}"]`)?.textContent??e} ${t+1}`}deleteDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.filter(t=>t.id!==this.currentDecorId),this.currentDecorId=e.decor[0]?.id,this.refreshDecorList(),this.ufoElement.refresh()}selectDecor(e){this.currentDecorId=e,this.decorSelect.value=e,this.syncDecorFields()}updateDecor(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting,t=this.wrapDegrees(Number(this.decorHeadingInput.value),this.decorHeadingInput)??0,n=this.decorWitnessSideSelect.value;e.decor=e.decor.map(i=>{if(i.id!==this.currentDecorId)return i;const a=Ra(i.kind)&&n!==""?n:void 0,r=Number(this.decorEastInput.value),o=Number(this.decorNorthInput.value),l=Number(this.decorAltitudeInput.value),c=i.track??(l!==0?[]:void 0);if(c){const h=this.ufoElement.currentTime,d={t:h,eastM:r,northM:o,altitudeM:l,headingDeg:t},u=c.filter(f=>f.t!==h);return{...i,title:this.said.write(i.title,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(i),track:[...u,d].sort((f,g)=>f.t-g.t),sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:a,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:i.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:i.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}return{...i,title:this.said.write(void 0,this.decorTitleInput.value,this.writingLanguage),color:this.statedDecorColor(i),eastM:r,northM:o,headingDeg:t,sightingUrl:this.stringOrUndefined(this.decorSightingUrlInput.value),witnessSide:a,sizeM:this.statedDecorSize(),model:this.statedDecorModel(),floors:i.kind==="building"?Number(this.decorFloorsInput.value):void 0,occupiedFloor:i.kind==="building"?Number(this.decorOccupiedFloorInput.value):void 0}}),this.decorSelect.options[this.decorSelect.selectedIndex].textContent=this.decorLabel(e.decor.find(i=>i.id===this.currentDecorId)),this.syncDecorVisibility(),this.updateDecorTitleValidity(),this.ufoElement.refresh()}syncDecorSizeFields(e){const t=e?on.naturalSize(e.kind,e.floors):void 0,n=[[this.decorWidthInput,e?.sizeM?.widthM,t?.widthM],[this.decorLengthInput,e?.sizeM?.lengthM,t?.lengthM],[this.decorHeightInput,e?.sizeM?.heightM,t?.heightM]];for(const[i,a,r]of n)i.value=a===void 0?"":String(this.roundedMeters(a)),i.placeholder=r===void 0?"":String(this.roundedMeters(r))}syncDecorModelFields(e){this.refreshDecorModelOptions(e),this.decorModelSelect.value=e?.model?.id??"",this.decorModelUrlInput.value=e?.model?.url??"",this.decorModelTitleInput.value=e?.model?.credit?.title??"",this.decorModelAuthorInput.value=e?.model?.credit?.author??"",this.decorModelLicenseInput.value=e?.model?.credit?.license??"",this.decorModelSourceInput.value=e?.model?.credit?.sourceUrl??"",this.decorModelAdvanced.open=e?.model?.url!==void 0}async refreshDecorModelOptions(e){const t=e??this.ufoElement.sighting.decor.find(r=>r.id===this.currentDecorId),n=t?await this.decorModelProvider.entries(t.kind).catch(()=>[]):[],i=t?.model?.id??"",a=document.createElement("option");a.value="",a.textContent=this.messages.decorModelNone,this.decorModelSelect.replaceChildren(a,...n.map(r=>{const o=document.createElement("option");return o.value=r.id,o.textContent=r.name,o.title=`${r.credit.title}${r.credit.author?` — ${r.credit.author}`:""} (${r.credit.license})`,o})),this.decorModelSelect.value=i}updateDecorModelChoice(){const e=this.decorModelSelect.value;(async()=>{const t=e?await this.decorModelProvider.entry(e).catch(()=>{}):void 0,n=this.ufoElement.sighting.decor.find(i=>i.id===this.currentDecorId);if(t?.sizeM&&n&&!n.sizeM){const i=[[this.decorWidthInput,t.sizeM.widthM],[this.decorLengthInput,t.sizeM.lengthM],[this.decorHeightInput,t.sizeM.heightM]];for(const[a,r]of i)r!==void 0&&(a.value=String(this.roundedMeters(r)))}this.updateDecor()})()}roundedMeters(e){return Math.round(e*100)/100}positiveMeters(e){const t=Number(e);return e.trim()===""||!Number.isFinite(t)||t<=0?void 0:t}statedDecorColor(e){const t=this.decorColorInput.value;return t==="#808080"&&e.color===void 0?void 0:t}statedDecorSize(){const e=this.positiveMeters(this.decorWidthInput.value),t=this.positiveMeters(this.decorLengthInput.value),n=this.positiveMeters(this.decorHeightInput.value);return e===void 0&&t===void 0&&n===void 0?void 0:{widthM:e,lengthM:t,heightM:n}}statedDecorModel(){const e=this.stringOrUndefined(this.decorModelUrlInput.value);if(e){const n=this.stringOrUndefined(this.decorModelTitleInput.value),i=this.stringOrUndefined(this.decorModelLicenseInput.value);return{url:e,credit:n!==void 0&&i!==void 0?{title:n,license:i,author:this.stringOrUndefined(this.decorModelAuthorInput.value),sourceUrl:this.stringOrUndefined(this.decorModelSourceInput.value)}:void 0}}const t=this.stringOrUndefined(this.decorModelSelect.value);return t===void 0?void 0:{id:t}}addMilestone(){const e=Math.round(this.ufoElement.currentTime),t=this.ufoElement.sighting;t.milestones.find(i=>i.t===e)||(t.milestones=$a([...t.milestones,{t:e,label:this.nextMilestoneLabel()}])),this.currentMilestoneT=e,this.refreshMilestoneList(),this.ufoElement.refresh()}nextMilestoneLabel(){const e=new Set(this.ufoElement.sighting.milestones.map(t=>t.label));for(let t=0;t<26;t++){const n=String.fromCharCode(65+t);if(!e.has(n))return n}return String(this.ufoElement.sighting.milestones.length+1)}deleteMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting,n=t.milestones.find(i=>i.t===e);n&&this.askConfirm(this.messages.confirmDeleteMilestone.replace("{name}",this.said.read(n.label)??""),()=>{t.milestones=t.milestones.filter(i=>i.t!==e),this.currentMilestoneT=t.milestones[0]?.t,this.refreshMilestoneList(),this.ufoElement.refresh()})}selectMilestone(e){this.currentMilestoneT=e,this.syncMilestoneFields(),this.ufoElement.currentTime=e}updateMilestone(){const e=this.currentMilestoneT;if(e===void 0)return;const t=this.ufoElement.sighting;t.milestones=t.milestones.map(n=>n.t===e?{...n,label:this.said.write(n.label,this.milestoneLabelInput.value,this.writingLanguage)??"",note:this.said.write(n.note,this.milestoneNoteInput.value,this.writingLanguage)}:n),this.refreshMilestoneList(),this.ufoElement.refresh()}refreshMilestoneList(){const e=$a(this.ufoElement.sighting.milestones);e.some(t=>t.t===this.currentMilestoneT)||(this.currentMilestoneT=e[0]?.t),this.milestoneSelect.replaceChildren(...e.map(t=>{const n=document.createElement("option");return n.value=String(t.t),n.textContent=`${this.said.read(t.label)??""} — ${this.formatSeconds(t.t)}`,n.title=this.said.read(t.note)??"",n})),this.currentMilestoneT!==void 0&&(this.milestoneSelect.value=String(this.currentMilestoneT)),this.syncMilestoneFields()}formatSeconds(e){return`${(e/1e3).toFixed(1)} s`}syncMilestoneFields(){const e=this.ufoElement.sighting.milestones.find(n=>n.t===this.currentMilestoneT),t=e!==void 0;for(const n of[this.milestoneSelect,this.milestoneLabelInput,this.milestoneNoteInput,this.deleteMilestoneButton])n.disabled=!t,this.setRowVisible(n,t);this.milestoneLabelInput.value=this.said.read(e?.label)??"",this.milestoneNoteInput.value=this.said.read(e?.note)??""}updateDecorTitleValidity(){const e=this.currentDecorId!==void 0&&this.decorTitleInput.value==="";this.decorTitleInput.classList.toggle("invalid",e),this.decorTitleInput.setAttribute("aria-invalid",String(e))}updateDecorWindows(){if(this.currentDecorId===void 0)return;const e=this.ufoElement.sighting;e.decor=e.decor.map(t=>{if(t.id!==this.currentDecorId)return t;const n={};for(const i of Qs){const a=this.decorWindowInputs[i];if(a.value==="")continue;const r=Sh(t.kind,i)?0:Mh,o=Math.max(r,Math.min(100,Number(a.value)));n[i]=o,String(o)!==a.value&&(a.value=String(o))}return{...t,windows:n}}),this.ufoElement.refresh()}updateDecorLit(){if(this.currentDecorId===void 0||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=this.ufoElement.currentTime,n=this.decorLitInput.checked;e.decor=e.decor.map(i=>{if(i.id!==this.currentDecorId)return i;const a=[...(i.litKeyframes??[]).filter(r=>r.t!==t),{t,lit:n}].sort((r,o)=>r.t-o.t);return{...i,litKeyframes:a}}),this.ufoElement.refresh()}refreshDecorList(){const e=this.ufoElement.sighting.decor;this.decorSelect.innerHTML="";for(const t of e){const n=document.createElement("option");n.value=t.id,n.textContent=this.decorLabel(t),this.decorSelect.appendChild(n)}this.currentDecorId!==void 0&&(this.decorSelect.value=this.currentDecorId),this.syncDecorFields()}syncDecorFields(){const e=this.ufoElement.sighting.decor.find(n=>n.id===this.currentDecorId),t=e!==void 0;this.deleteDecorButton.disabled=!t;for(const n of[this.decorSelect,this.decorTitleInput,this.decorEastInput,this.decorNorthInput,this.decorHeadingInput,this.decorLitInput,this.decorSightingUrlInput,this.decorWidthInput,this.decorLengthInput,this.decorHeightInput,this.decorModelSelect,this.decorModelUrlInput,this.decorModelTitleInput,this.decorModelAuthorInput,this.decorModelLicenseInput,this.decorModelSourceInput,this.decorFloorsInput,this.decorOccupiedFloorInput,this.decorWitnessSideSelect,this.decorLightRigSelect,this.decorAltitudeInput,this.lookAtDecorButton])n.disabled=!t;this.decorTitleInput.value=this.said.read(e?.title)??"",this.decorColorInput.value=e?.color??"#808080",this.showDecorPlacement(e),this.decorLitInput.checked=e?Ml(e,this.ufoElement.currentTime):!1,this.refreshDecorLightRigOptions(e),this.decorSightingUrlInput.value=e?.sightingUrl??"",this.syncDecorSizeFields(e),this.syncDecorModelFields(e),this.decorFloorsInput.value=String(e?.floors??Oa),this.decorOccupiedFloorInput.value=String(e?.occupiedFloor??0),this.decorWitnessSideSelect.value=e?.witnessSide??"";for(const n of Qs){const i=e?.windows?.[n];this.decorWindowInputs[n].value=i===void 0?"":String(i)}this.syncDecorVisibility(),this.updateDecorTitleValidity()}setRowVisible(e,t){const n=e.closest("label")??e;n.hidden=!t}syncDecorVisibility(){const e=this.ufoElement.sighting.decor.find(c=>c.id===this.currentDecorId),t=e!==void 0,n=e?.kind;this.setRowVisible(this.decorSelect,t),this.setRowVisible(this.deleteDecorButton,t),this.setRowVisible(this.decorTitleInput,t),this.setRowVisible(this.decorEastInput,t),this.setRowVisible(this.decorNorthInput,t),this.setRowVisible(this.decorAltitudeInput,t),this.setRowVisible(this.decorHeadingInput,t),this.setRowVisible(this.decorWidthInput,t),this.setRowVisible(this.decorLengthInput,t),this.setRowVisible(this.decorHeightInput,t),this.setRowVisible(this.decorModelSelect,t),this.decorModelAdvanced.hidden=!t,this.setRowVisible(this.decorLitInput,t&&e?.kind!=="aircraft");const i=t&&n!==void 0&&Zd(n);this.setRowVisible(this.labelDecorWindows,i);const a=n!==void 0?$d(n):[];for(const c of Qs)this.decorWindowInputs[c].disabled=!t,this.decorWindowInputs[c].min=String(n!==void 0&&Sh(n,c)?0:Mh),this.setRowVisible(this.decorWindowInputs[c],i&&a.includes(c));const r=t&&n!==void 0&&Ra(n);this.setRowVisible(this.decorWitnessSideSelect,r);const o=n!==void 0?n1(n):[];for(const c of Qs)this.optionWitnessSide[c].hidden=!o.includes(c);const l=t&&n==="building";this.setRowVisible(this.decorFloorsInput,l),this.setRowVisible(this.decorOccupiedFloorInput,l),this.decorOccupiedFloorInput.max=String(e?.floors??Oa)}showDecorPlacement(e){const t=e?Ya(e,this.ufoElement.currentTime):void 0,n=[[this.decorEastInput,t?.eastM??0],[this.decorNorthInput,t?.northM??0],[this.decorAltitudeInput,t?.altitudeM??0],[this.decorHeadingInput,t?.headingDeg??0]];for(const[i,a]of n)this.shadow.activeElement!==i&&(i.value=String(this.rounded(a)))}syncDecorPlacementFromTimeline(){this.ufoElement.playbackState!=="playing"&&this.showDecorPlacement(this.ufoElement.sighting.decor.find(e=>e.id===this.currentDecorId))}showNextMeteor(){const e=this.sceneElement.meteorByRank(this.meteorRank++);e&&(this.ufoElement.playbackState==="playing"&&this.ufoElement.togglePlayPause(),this.ufoElement.currentTime=e.t,this.headingInput.value=String(Math.round(e.azimuthDeg*10)/10),this.pitchInput.value=String(Math.round(e.altitudeDeg*10)/10),this.updateObserver())}resetMeteorRankIfSkyChanged(){const e=this.sceneElement.meteorByRank(0),t=e?`${e.t}`:"";t!==this.meteorRankFor&&(this.meteorRankFor=t,this.meteorRank=0)}meteorRankFor;meteorRank=0;showerLanguage(){return Xr(Vs.preferencesFor(this),["en","fr"])}get said(){return this.saidTexts??=new Fi(Vs.preferencesFor(this))}saidTexts;tagNames=new Ah({});get writingLanguage(){return this.showerLanguage()}refreshSkyCandidates(){this.resetMeteorRankIfSkyChanged();const e=this.ufoElement.sighting,t=e.event.place?.[0],n=e.event.time,i=t&&t.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?Va(n,t.lng,e.event.utcOffsetHours):void 0;if(!i||!t||t.lat===void 0||t.lng===void 0){this.showMeteorButton.hidden=!0,this.showCometButton.hidden=!0,this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",this.messages.skyUnknown);return}const a={lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0},r=[this.starsClause(i,a),this.showerClause(i,a),this.cometClause(i,a),this.satelliteClause(i,a),this.opticsClause(i,a),this.rainbowClause(i,a),this.glowClause(i,a)].filter(o=>o!==void 0);this.skyCandidatesOutput.textContent=this.messages.skyLine.replace("{parts}",r.join(" · "))}instrumentGain(){const e=this.ufoElement.sighting;return rn.gainFor(e.instrument,{fNumber:bt(e,0)?.fNumber,fieldOfViewDeg:en.fovOf(e,0),exposureSeconds:e.exposure})}starsClause(e,t){const n=On("Sun",e,t).altitudeDeg,i=this.instrumentGain(),a=Or(n,i),r=c=>c.toLocaleString(void 0,{maximumFractionDigits:1});if(a<FT)return this.messages.skyStarsNone;const o=this.ufoElement.sighting.instrument,l=Math.abs(i)<.1?this.messages.skyStarsEye.replace("{limit}",r(a)):(i>0?this.messages.skyStarsDeeper:this.messages.skyStarsShallower).replace("{limit}",r(a)).replace("{device}",o.name[this.showerLanguage()]).replace("{gain}",r(Math.abs(i))).replace("{eye}",r(Or(n)));return a<=Br?l:l+this.messages.skyStarsCatalogue.replace("{catalogue}",r(Br))}showerClause(e,t){const n=Et.observedRatePerHour(Et.apexPosition(e,t).altitudeDeg).toLocaleString(void 0,{maximumFractionDigits:1}),i=Xa.activeAt(e);if(i.length===0)return this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyNothingActive.replace("{sporadic}",n);const a=i.map(r=>{const o=Xa.radiantPosition(r.shower,e,t);return{entry:r,position:o,rate:Xa.observedRatePerHour(r.zhr,o.altitudeDeg,r.shower.populationIndex)}}).sort((r,o)=>o.rate-r.rate)[0];return a.rate<=0?(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerBelowHorizon.replace("{name}",a.entry.shower.name[this.showerLanguage()])):(this.showMeteorButton.hidden=!this.sceneElement.meteorByRank(0),this.messages.skyShowerActive.replace("{name}",a.entry.shower.name[this.showerLanguage()]).replace("{altitude}",String(Math.round(a.position.altitudeDeg))).replace("{bearing}",Gs.towards(a.position.azimuthDeg,this.showerLanguage())).replace("{rate}",a.rate.toLocaleString(void 0,{maximumFractionDigits:a.rate<10?1:0})).replace("{sporadic}",n))}cometClause(e,t){const n=xl.brightestAt(e,t);if(!n||n.magnitude>Jr){this.showCometButton.hidden=!0;return}return this.showCometButton.hidden=n.position.altitudeDeg<=0,this.cometText(n)}satelliteClause(e,t){const n=pi.visibilityAt(e,t);if(!n.anythingInOrbit)return n.sunAltitudeDeg<0?this.messages.skySatellitesNotYet:void 0;const i=Or(n.sunAltitudeDeg,this.instrumentGain()),a=n.classes.filter(h=>h.peakMagnitude<=i),r=this.listed(a.map(h=>h.name[this.showerLanguage()]));if(n.sunAltitudeDeg>=0)return a.length===0?void 0:(a.length===1?this.messages.skySatellitesDaylightOne:this.messages.skySatellitesDaylight).replace("{eras}",r);const o=Math.round(n.shadowHeightKm).toLocaleString(),l=(n.trackedObjects??0).toLocaleString(),c=h=>h.replace("{height}",o).replace("{count}",l);return n.lowOrbitLit?a.length===0?c(this.messages.skySatellitesLit):c(this.messages.skySatellitesLitWith).replace("{eras}",r):c(this.messages.skySatellitesShadowed)}opticsClause(e,t){const n=Fs(this.ufoElement.sighting,0),i=On("Sun",e,t),a=On("Moon",e,t),r=je.deckLitUntilDeg(je.DECK_HEIGHT_M),o=i.altitudeDeg>-r,l=o?i:a;if(l.altitudeDeg<=-r)return;const c=n.highCloudCover;if(c===void 0||c<=0)return this.messages.skyOpticsNoIce;if(je.strength(c,n.lowerCloudCover??n.cloudCover,l.altitudeDeg,r)<=0)return this.messages.skyOpticsHidden;const h=o?this.messages.skyOpticsSun:this.messages.skyOpticsMoon,d=this.listed(je.formsAt(l.altitudeDeg,r).map(f=>this.opticsFormName(f))),u=n.iceCrystalAlignment??_h;return this.messages.skyOpticsPossible.replace("{forms}",d).replace("{source}",h)+this.messages.skyOpticsAlignment.replace("{alignment}",String(Math.round(u*100)))}rainbowClause(e,t){const n=Fs(this.ufoElement.sighting,0);if(n.precipitationType!=="rain"||n.precipitationIntensity<=0)return;const i=On("Sun",e,t),a=On("Moon",e,t),r=i.altitudeDeg>0,o=r?i:a;if(o.altitudeDeg<=0)return this.messages.skyBowNoSource;const l=n.lowerCloudCover??n.cloudCover;if(Qt.strength(n.precipitationIntensity,l,o.altitudeDeg)<=0)return this.messages.skyBowHidden;const c=Qt.formsAt(o.altitudeDeg);if(c.length===0)return this.messages.skyBowSourceTooHigh.replace("{altitude}",String(Math.round(o.altitudeDeg))).replace("{radius}",String(Math.round(Qt.primary().radiusDeg)));const h=this.listed(c.map(u=>this.bowFormName(u)));if(r)return this.messages.skyBowPossible.replace("{forms}",h);const d=Math.round(Hl(e).illuminatedFraction*100);return this.messages.skyBowMoon.replace("{forms}",h).replace("{lit}",String(d))}glowClause(e,t){if(On("Sun",e,t).altitudeDeg>XT)return;const i=this.glows.assess(e,t),a=this.showerLanguage(),r=[];if(i.milkyWay&&r.push(this.messages.skyGlowBand.replace("{contrast}",this.decimal(i.milkyWay.contrast,1)).replace("{altitude}",String(Math.round(i.milkyWay.altitudeDeg))).replace("{bearing}",Gs.towards(i.milkyWay.azimuthDeg,a))),i.zodiacal){const h=i.zodiacal.sunSeparationDeg<=nt.CONE_SEPARATION_DEG;r.push((h?this.messages.skyGlowCone:this.messages.skyGlowZodiacalBand).replace("{contrast}",this.decimal(i.zodiacal.contrast,1)).replace("{altitude}",String(Math.round(i.zodiacal.altitudeDeg))).replace("{bearing}",Gs.towards(i.zodiacal.azimuthDeg,a)).replace("{elongation}",String(Math.round(i.zodiacal.sunSeparationDeg))))}if(r.length>0)return this.listed(r);const o=this.decimal(i.darkestSkyMagPerArcsec2,1),l=On("Moon",e,t),c=i.darkestSkyMagPerArcsec2<qT;if(c&&l.altitudeDeg>0){const h=Math.round(Hl(e).illuminatedFraction*100);return this.messages.skyGlowMoon.replace("{lit}",String(h)).replace("{sky}",o)}return c?this.messages.skyGlowTwilight.replace("{sky}",o):this.messages.skyGlowNothingUp.replace("{sky}",o)}glows=new nt;bowFormName(e){return(e.id==="primary"?this.messages.skyBowPrimary:this.messages.skyBowSecondary).replace("{radius}",String(Math.round(e.radiusDeg))).replace("{top}",String(Math.round(e.topAltitudeDeg)))}opticsFormName(e){const t=n=>String(Math.round(n??0));switch(e.id){case"halo22":return this.messages.skyOpticsHalo22.replace("{angle}",t(e.angleDeg));case"halo46":return this.messages.skyOpticsHalo46.replace("{angle}",t(e.angleDeg));case"parhelia":return this.messages.skyOpticsParhelia.replace("{angle}",t(e.angleDeg));case"tangentArc":return this.messages.skyOpticsTangentArc;case"parhelicCircle":return this.messages.skyOpticsParhelicCircle;case"circumzenithal":return this.messages.skyOpticsCircumzenithal.replace("{angle}",t(e.angleDeg));case"circumhorizontal":return this.messages.skyOpticsCircumhorizontal;case"pillar":return this.messages.skyOpticsPillar}}listed(e){return new Intl.ListFormat(this.showerLanguage(),{style:"long",type:"conjunction"}).format(e)}cometText(e){const t=e.apparition.name[this.showerLanguage()],n=e.magnitude.toLocaleString(void 0,{maximumFractionDigits:1});return e.position.altitudeDeg<=0?this.messages.skyCometBelowHorizon.replace("{name}",t).replace("{magnitude}",n):(e.elongationDeg<xl.TWILIGHT_ELONGATION_DEG?this.messages.skyCometInDaylight:e.tailLengthDeg===void 0?this.messages.skyCometNoTail:this.messages.skyComet).replace("{name}",t).replace("{magnitude}",n).replace("{altitude}",String(Math.round(e.position.altitudeDeg))).replace("{bearing}",Gs.towards(e.position.azimuthDeg,this.showerLanguage())).replace("{tail}",String(Math.round(e.tailLengthDeg??0))).replace("{elongation}",String(Math.round(e.elongationDeg)))}lookAtComet(){const e=this.ufoElement.sighting,t=e.event.place?.[0],n=e.event.time;if(!t||t.lat===void 0||t.lng===void 0||n?.year===void 0)return;const i=Va(n,t.lng,e.event.utcOffsetHours);if(!i)return;const a=xl.brightestAt(i,{lat:t.lat,lng:t.lng,elevationM:this.groundElevationM??0});a&&(this.headingInput.value=String(this.rounded(a.position.azimuthDeg)),this.pitchInput.value=String(this.rounded(a.position.altitudeDeg)),this.updateObserver())}rounded(e){return Math.round(e*10)/10}lookAtDecor(){const e=this.ufoElement.sighting.decor.find(l=>l.id===this.currentDecorId);if(!e)return;const{eastM:t,northM:n,altitudeM:i}=Ya(e,this.ufoElement.currentTime),a=Math.hypot(t,n);if(a===0&&i===0)return;const r=Math.atan2(t,n)*180/Math.PI,o=Math.atan2(i-HT,a)*180/Math.PI;this.headingInput.value=String(Math.round(r*10)/10),this.pitchInput.value=String(Math.round(o*10)/10),this.updateObserver()}refreshDecorLightRigOptions(e){const t=e?sc.forKind(e.kind):[],n=document.createElement("option");n.value="",n.textContent=this.messages.decorLightsNone,this.decorLightRigSelect.replaceChildren(n,...t.map(a=>{const r=document.createElement("option");return r.value=a.id,r.textContent=a.name,r}));const i=e?.lights?.map(a=>a.id).join()??"";this.decorLightRigSelect.value=t.find(a=>a.create().map(r=>r.id).join()===i)?.id??""}updateDecorLightRig(){const e=this.ufoElement.sighting,t=e.decor.find(i=>i.id===this.currentDecorId);if(!t)return;const n=sc.byId(this.decorLightRigSelect.value);e.decor=e.decor.map(i=>i.id===t.id?{...i,lights:n?n.create():void 0}:i),this.ufoElement.refresh(),this.dispatchEvent(new CustomEvent("sightingchange"))}syncDecorLitFromTimeline(){if(this.ufoElement.playbackState==="playing"||this.shadow.activeElement===this.decorLitInput)return;const e=this.ufoElement.sighting.decor.find(t=>t.id===this.currentDecorId);e&&(this.decorLitInput.checked=Ml(e,this.ufoElement.currentTime))}updatePresetButtons(){for(const e of em)this.presetButtons[e]?.setAttribute("aria-pressed",String(e===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(e=this.defaultBounds()){return Ku(e,this.currentAppearance)}defaultBounds(){const e=this.ufoElement.canvasElement;return{x:e.width/2-Ta.width/2,y:e.height/2-Ta.height/2,width:Ta.width,height:Ta.height}}toggleRecording(){this.endDrag();const e=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),this.setCanvasCursor(void 0),e.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new nT(this.ufoElement.sighting.timeline,new iT(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),this.setCanvasCursor("record"),e.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0,this.deleteShapeButton.disabled=!0)}setRecordButtonLabel(e){this.recordButton.textContent=e?"⏹":"⏺";const t=e?this.messages.stop:this.messages.record;this.recordButton.title=t,this.recordButton.setAttribute("aria-label",t)}async loadLocaleMessages(){const e=Xr(Vs.preferencesFor(this),hm);e!=="en"&&(this.tagNames=new Ah(await q1(e)),this.showTags(),this.applyMessages(await X1(e)))}showTags(){this.tagsInput.value=this.ufoElement.sighting.event.tags?.map(e=>this.tagNames.name(e)).join(", ")??""}applyMessages(e){this.currentSourceId===cl&&this.shapeTitleInput.value===`${this.messages.shape} 1`?(this.messages=e,this.shapeTitleInput.value=`${this.messages.shape} 1`,this.updateShapeTitle()):this.messages=e,this.presetButtons.oval.textContent=e.oval,this.presetButtons.polygon.textContent=e.polygon,this.contextAddVertexButton.textContent=e.addVertex,this.contextDeleteVertexButton.textContent=e.deleteVertex,this.labelColor.textContent=e.color,this.labelTransparency.textContent=e.transparency,this.labelHalo.textContent=e.halo,this.labelBlur.textContent=e.blur,this.labelBrightness.textContent=e.brightness,this.labelShape.textContent=e.shape,this.labelShapeTitle.textContent=e.shapeTitle,this.labelUtcOffset.textContent=e.utcOffset,this.utcOffsetInput.placeholder=e.utcOffsetPlaceholder,this.labelApparentWidth.textContent=e.apparentWidth,this.labelRealWidth.textContent=e.realWidth,this.labelObjectDistance.textContent=e.distance,this.labelSizeLock.textContent=e.sizeLock;for(const[i,a]of[["option-lock-none",e.lockNone],["option-lock-apparent",e.lockApparent],["option-lock-real",e.lockReal],["option-lock-distance",e.lockDistance]])this.shadow.getElementById(i).textContent=a;this.clearDistanceHypothesisButton.textContent=e.clearDistanceHypothesis,this.clearDistanceHypothesisButton.title=e.clearDistanceHypothesisTitle,this.refreshApparentSize(),this.labelSamplingRate.textContent=e.samplingRate,this.labelDuration.textContent=e.duration,this.durationInput.placeholder=e.durationPlaceholder,this.addShapeButton.title=e.addShape,this.addShapeButton.setAttribute("aria-label",e.addShape),this.deleteShapeButton.title=e.deleteShape,this.deleteShapeButton.setAttribute("aria-label",e.deleteShape),this.contextGroupButton.textContent=e.group,this.contextUngroupButton.textContent=e.ungroup,this.contextBringToFrontButton.textContent=e.bringToFront,this.contextSendToBackButton.textContent=e.sendToBack,this.contextDeleteButton.textContent=e.contextMenuDelete,this.exportButton.textContent=e.export,this.labelImportFile.textContent=e.importFile,this.labelImportUrl.textContent=e.importUrl,this.importUrlInput.placeholder=e.importUrlPlaceholder,this.importUrlButton.textContent=e.importButton,this.labelWitnessAge.textContent=e.witnessAge,this.labelWitnessOccupation.textContent=e.witnessOccupation,this.labelTestimonySource.textContent=e.testimonySource,this.labelTestimonyFollowedUp.textContent=e.testimonyFollowedUp;for(const[i,a]of[["option-source-unknown",e.testimonySourceUnknown],["option-source-on-site",e.testimonySourceOnSite],["option-source-interview",e.testimonySourceInterview],["option-source-telephone",e.testimonySourceTelephone],["option-source-questionnaire",e.testimonySourceQuestionnaire],["option-source-letter",e.testimonySourceLetter],["option-source-press",e.testimonySourcePress],["option-followed-unknown",e.testimonyUnknown],["option-followed-yes",e.testimonyYes],["option-followed-no",e.testimonyNo]]){const r=this.shadow.getElementById(i);r&&(r.textContent=a)}this.labelNarrativeKey.textContent=e.narrativeKey.replace("{source}",ws[0].name),this.labelNarrativeWorkspace.textContent=e.narrativeWorkspace,this.narrativeWorkspaceInput.placeholder=e.narrativeWorkspacePlaceholder,this.narrativeWorkspaceInput.title=e.narrativeWorkspaceHint,this.labelNarrativeRemember.textContent=e.narrativeRemember,this.narrativeStopButton.textContent=e.narrativeStop,this.narrativeDraftButton.textContent=e.narrativeDraft,this.descriptionInput.placeholder=e.narrativePlaceholder,this.syncNarrativeEnabled(),this.refreshSourceRows(),this.refreshTimeZoneOptions(),this.labelPlaceName.textContent=e.placeName,this.placeNameInput.placeholder=e.placeNamePlaceholder,this.searchPlaceButton.textContent=e.searchPlace,this.labelPlaceMatch.textContent=e.placeMatch,this.labelLatitude.textContent=e.latitude,this.labelLongitude.textContent=e.longitude,this.labelHeading.textContent=e.heading,this.headingInput.placeholder=e.headingPlaceholder,this.labelPitch.textContent=e.pitch,this.labelRoll.textContent=e.roll,this.labelElevation.textContent=e.elevation,this.labelObservationTime.textContent=e.observationTime,this.labelObservationEndTime.textContent=e.observationEndTime,this.obsTimeInput.placeholder=e.edtfPlaceholder,this.obsTimeInput.title=e.observationTimeHint,this.obsEndTimeInput.placeholder=e.edtfPlaceholder,this.obsEndTimeInput.title=e.observationEndTimeHint,this.presetsGroup.setAttribute("aria-label",e.presetsGroupLabel),this.labelDecor.textContent=e.decor,this.labelDecorGroup.textContent=e.decor,this.optionDecorBuilding.textContent=e.decorBuilding,this.optionDecorTree.textContent=e.decorTree,this.optionDecorCrop.textContent=e.decorCrop,this.optionDecorMound.textContent=e.decorMound,this.optionDecorStreetlight.textContent=e.decorStreetlight,this.optionDecorVehicle.textContent=e.decorVehicle,this.optionDecorAircraft.textContent=e.decorAircraft,this.optionDecorEntity.textContent=e.decorEntity,this.labelDecorLights.textContent=e.decorLights,this.labelDecorAltitude.textContent=e.decorAltitude,this.showMeteorButton.title=e.showMeteor,this.showMeteorButton.setAttribute("aria-label",e.showMeteor),this.showCometButton.title=e.showComet,this.showCometButton.setAttribute("aria-label",e.showComet),this.lookAtDecorButton.title=e.lookAtDecor,this.lookAtDecorButton.setAttribute("aria-label",e.lookAtDecor),this.optionDecorWitness.textContent=e.decorWitness,this.deleteDecorButton.title=e.deleteDecor,this.deleteDecorButton.setAttribute("aria-label",e.deleteDecor),this.labelDecorTitle.textContent=e.decorTitle,this.labelDecorEast.textContent=e.decorEast,this.labelDecorNorth.textContent=e.decorNorth,this.labelDecorHeading.textContent=e.decorHeading,this.labelDecorColor.textContent=e.decorColor,this.labelDecorLit.textContent=e.decorLit,this.labelDecorSightingUrl.textContent=e.decorSightingUrl,this.contextViewTestimonyButton.textContent=e.viewTestimony,this.labelContextMasks.textContent=`${e.masks} ▸`,this.addDecorWitnessButton.textContent=e.addWitness,this.addDecorBuildingButton.title=e.addDecor,this.addDecorBuildingButton.setAttribute("aria-label",e.addDecor),this.confirmAcceptButton.textContent=e.confirmAccept,this.confirmDeclineButton.textContent=e.confirmDecline,this.labelMilestones.textContent=e.milestones,this.labelMilestoneLabel.textContent=e.milestoneLabel,this.labelMilestoneNote.textContent=e.milestoneNote;for(const[i,a]of[[this.addMilestoneButton,e.addMilestone],[this.deleteMilestoneButton,e.deleteMilestone]])i.title=a,i.setAttribute("aria-label",a);this.labelDecorWidth.textContent=e.decorWidth,this.labelDecorLength.textContent=e.decorLength,this.labelDecorHeight.textContent=e.decorHeight,this.labelDecorModel.textContent=e.decorModel,this.labelDecorModelAdvanced.textContent=e.decorModelAdvanced,this.labelDecorModelUrl.textContent=e.decorModelUrl,this.labelDecorModelTitle.textContent=e.decorModelTitle,this.labelDecorModelAuthor.textContent=e.decorModelAuthor,this.labelDecorModelLicense.textContent=e.decorModelLicense,this.labelDecorModelSource.textContent=e.decorModelSource,this.labelDecorFloors.textContent=e.decorFloors,this.labelDecorOccupiedFloor.textContent=e.decorOccupiedFloor,this.labelDecorWitnessSide.textContent=e.decorWitnessSide,this.labelDecorWindows.textContent=e.decorWindows,this.optionWitnessSideNone.textContent=e.decorWitnessSideNone;const t={front:e.decorSideFront,behind:e.decorSideBehind,left:e.decorSideLeft,right:e.decorSideRight,"front-left":e.decorSideFrontLeft,"front-right":e.decorSideFrontRight,"behind-left":e.decorSideBehindLeft,"behind-right":e.decorSideBehindRight};for(const i of Qs)this.labelDecorSide[i].textContent=t[i],this.optionWitnessSide[i].textContent=t[i];this.refreshDecorList(),this.labelWitnessId.textContent=e.witnessId,this.labelWitnessDirName.textContent=e.witnessDirName,this.labelWitnessTitle.textContent=e.witnessTitle,this.labelWitnessLastName.textContent=e.witnessLastName,this.labelWitnessFirstNames.textContent=e.witnessFirstNames,this.witnessFirstNamesInput.placeholder=e.tagsPlaceholder,this.labelCaseId.textContent=e.caseId,this.labelDescription.textContent=e.description,this.labelTags.textContent=e.tags,this.tagsInput.placeholder=e.tagsPlaceholder,this.labelShapeGroup.textContent=e.shapeGroup,this.labelTemporalGroup.textContent=e.temporalGroup,this.labelLocationGroup.textContent=e.locationGroup,this.labelObservationGroup.textContent=e.observationGroup,this.labelWitnessGroup.textContent=e.witnessGroup,this.labelWeatherGroup.textContent=e.weather,this.refreshTimeQualifierOptions(),this.edtfModeButton.title=e.edtfModeTitle,this.edtfModeButton.setAttribute("aria-label",e.edtfModeTitle),this.paramSummaryBuilder=new tf(e,this.showerLanguage(),this.said,this.tagNames),this.refreshParamSummary();const n=this.skyDetailsButton.getAttribute("aria-expanded")==="true";this.skyDetailsButton.title=n?e.skyDetailsHide:e.skyDetails,this.skyDetailsButton.setAttribute("aria-label",this.skyDetailsButton.title),this.labelCloudCover.textContent=e.cloudCover,this.labelHighCloud.textContent=e.highCloudCover,this.labelIceAlignment.textContent=e.iceCrystalAlignment,this.labelFNumber.textContent=e.aperture,this.labelExposure.textContent=e.exposure,this.labelFocusDistance.textContent=e.focusDistance,this.syncOpticsFromInstrument(),this.labelCloudDarkness.textContent=e.cloudDarkness,this.labelCloudBase.textContent=e.cloudBase,this.labelPrecipitationType.textContent=e.precipitationType,this.optionPrecipitationNone.textContent=e.precipitationNone,this.optionPrecipitationRain.textContent=e.precipitationRain,this.optionPrecipitationSnow.textContent=e.precipitationSnow,this.optionPrecipitationHail.textContent=e.precipitationHail,this.labelPrecipitationIntensity.textContent=e.precipitationIntensity,this.labelWindDirection.textContent=e.windDirection,this.labelWindSpeed.textContent=e.windSpeed,this.labelStorm.textContent=e.storm,this.labelWeatherInferred.textContent=e.weatherInferred,this.syncWeatherSourceState(),this.labelSoundGroup.textContent=e.soundGroup,this.labelSoundKind.textContent=e.soundKind,this.labelSoundVolume.textContent=e.soundVolume,this.labelSoundPitch.textContent=e.soundPitch,this.labelSoundSrc.textContent=e.soundSrc,this.soundSrcInput.placeholder=e.soundSrcPlaceholder;for(const[i,a]of this.soundKindOptions)a.textContent=this.soundKindLabel(i,e);this.labelInstrument.textContent=e.instrument,this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.setRecordButtonLabel(this.isRecording),this.syncPlaybackControls()}onPointerDown(e){if(this.isRecording){this.onPointerMove(e);return}const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.ufoElement.playbackState==="playing";if(this.selectedSourceIds.size>1){const l=new ic(this.selectedMembers()),c=it.hitTestHandle({bounds:l.bounds(),angle:0},t);if(c==="rotate"){if(a)return;this.dragState={kind:"group-rotate",group:l,startPointer:t},this.startDragListening();return}if(c){if(a)return;this.dragState={kind:"group-resize",group:l,handle:c},this.startDragListening();return}}else{const l=n.getInterpolatedShapeAt(i,this.currentSourceId),c=l?.kind==="polygon"?it.hitTestVertex(l,t):void 0;if(l?.kind==="polygon"&&c!==void 0){if(a)return;this.dragState={kind:"vertex",sourceId:this.currentSourceId,original:l,vertexIndex:c},this.startDragListening();return}const h=l&&it.hitTestHandle(l,t);if(l&&h){if(a)return;this.beginDrag(h==="rotate"?"rotate":"resize",this.currentSourceId,l,t,h);return}}const r=this.ufoElement.shapeAt(t.x,t.y,Z0);if(!r){const l=this.pickDecorAt(e);if(l!==void 0){this.selectDecor(l);return}a||this.beginCameraDrag(t);return}if(this.revealShapePanel(),e.shiftKey?this.toggleUnitSelection(r.sourceId):this.selectedSourceIds.has(r.sourceId)||this.selectUnit(r.sourceId),a)return;const o=[...this.selectedSourceIds].map(l=>({sourceId:l,original:l===r.sourceId?r.shape:n.getInterpolatedShapeAt(i,l)??r.shape}));this.dragState={kind:"move",sources:o,startPointer:t},this.startDragListening()}revealShapePanel(){const e=this.groupTabs.find(t=>t.getAttribute("aria-controls")==="group-shape");e&&this.toggleGroup(e,!0)}selectedMembers(){const e=this.ufoElement.sighting.timeline,t=this.ufoElement.currentTime;return[...this.selectedSourceIds].map(n=>({sourceId:n,shape:e.getInterpolatedShapeAt(t,n)})).filter(n=>!!n.shape)}selectUnit(e){const t=this.ufoElement.sighting.timeline.groupMembers(e)??[e];t.length===this.selectedSourceIds.size&&t.every(n=>this.selectedSourceIds.has(n))&&e===this.currentSourceId||(this.selectedSourceIds=new Set(t),this.currentSourceId=e,this.refreshSourceList(),this.onSelectionOrTimeChanged())}toggleUnitSelection(e){const t=this.ufoElement.sighting.timeline,n=t.groupMembers(e)??[e];if(n.every(a=>this.selectedSourceIds.has(a))){if(n.length>=this.selectedSourceIds.size)return;for(const a of n)this.selectedSourceIds.delete(a);if(!this.selectedSourceIds.has(this.currentSourceId)){const a=t.sourceIds;this.currentSourceId=[...this.selectedSourceIds].sort((r,o)=>a.indexOf(r)-a.indexOf(o)).pop()}}else{for(const a of n)this.selectedSourceIds.add(a);this.currentSourceId=e}this.refreshSourceList(),this.onSelectionOrTimeChanged()}onContextMenu(e){if(e.preventDefault(),this.isRecording||this.ufoElement.playbackState==="playing")return;this.hideContextMenu(),this.hideDecorContextMenu();const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.selectedSourceIds.size===1?n.getInterpolatedShapeAt(i,this.currentSourceId):void 0,o=a?.kind==="polygon"&&it.hitTestVertex(a,t)!==void 0?{sourceId:this.currentSourceId}:this.ufoElement.shapeAt(t.x,t.y,Z0);if(o){this.selectedSourceIds.has(o.sourceId)||this.selectUnit(o.sourceId),this.currentSourceId=o.sourceId,this.contextMenuPoint=t,this.showContextMenu(e.clientX,e.clientY);return}const l=this.pickDecorAt(e),c=l?this.ufoElement.sighting.decor.find(h=>h.id===l):void 0;c&&this.showDecorContextMenu(e.clientX,e.clientY,c)}pickDecorAt(e){const n=this.ufoElement.canvasElement.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(e.clientX-n.left)/n.width*2-1,a=-((e.clientY-n.top)/n.height*2-1);return this.sceneElement.pickDecorAt(i,a)}showContextMenu(e,t){this.contextMenu.style.left=`${e}px`,this.contextMenu.style.top=`${t}px`,this.contextMenu.hidden=!1;const n=this.ufoElement.sighting.timeline.sourceIds,i=n.filter(f=>this.selectedSourceIds.has(f)),a=n.length<=i.length,r=i.length>0&&n.slice(n.length-i.length).every(f=>this.selectedSourceIds.has(f)),o=i.length>0&&n.slice(0,i.length).every(f=>this.selectedSourceIds.has(f));this.contextBringToFrontButton.disabled=a||r,this.contextSendToBackButton.disabled=a||o,this.contextBringToFrontButton.title=a?this.messages.onlyOneShape:r?this.messages.alreadyAtFront:"",this.contextSendToBackButton.title=a?this.messages.onlyOneShape:o?this.messages.alreadyAtBack:"",this.contextGroupButton.disabled=this.selectedSourceIds.size<2,this.contextGroupButton.title=this.contextGroupButton.disabled?this.messages.needTwoShapesToGroup:"";const l=this.ufoElement.sighting.timeline.groupMembers(this.currentSourceId)!==void 0;this.contextUngroupButton.disabled=!l,this.contextUngroupButton.title=l?"":this.messages.notGrouped,this.contextDeleteButton.disabled=this.deleteShapeButton.disabled,this.contextDeleteButton.title=this.contextDeleteButton.disabled?this.messages.onlyOneShape:"";const c=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId),h=this.selectedSourceIds.size===1&&c?.kind==="polygon";this.contextAddVertexButton.disabled=!h,this.contextAddVertexButton.title=h?"":this.messages.notAPolygon;const d=h&&this.contextMenuPoint?it.hitTestVertex(c,this.contextMenuPoint):void 0,u=h&&c.points.length<=3;this.contextDeleteVertexButton.disabled=!h||d===void 0||u,this.contextDeleteVertexButton.title=h?u?this.messages.tooFewVertices:"":this.messages.notAPolygon,document.addEventListener("click",this.handleOutsideContextMenuClick)}hideContextMenu(){this.contextMenu.hidden=!0,this.contextMenuPoint=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}handleOutsideContextMenuClick=e=>{e.composedPath().includes(this.contextMenu)||e.composedPath().includes(this.decorContextMenu)||(this.hideContextMenu(),this.hideDecorContextMenu())};showDecorContextMenu(e,t,n){this.contextMenuDecorId=n.id,this.decorContextMenu.style.left=`${e}px`,this.decorContextMenu.style.top=`${t}px`,this.decorContextMenu.hidden=!1,this.contextViewTestimonyButton.disabled=!n.sightingUrl,this.contextViewTestimonyButton.title=n.sightingUrl?"":this.messages.noWitnessRecording,this.refreshContextMasksSubmenu(n),document.addEventListener("click",this.handleOutsideContextMenuClick)}hideDecorContextMenu(){this.decorContextMenu.hidden=!0,this.contextMenuDecorId=void 0,document.removeEventListener("click",this.handleOutsideContextMenuClick)}refreshContextMasksSubmenu(e){this.contextMasksSubmenu.innerHTML="";for(const t of this.ufoElement.sighting.timeline.sourceIds){const n=document.createElement("label"),i=document.createElement("input");i.type="checkbox",i.checked=e.occludesSourceIds?.includes(t)??!1,i.addEventListener("change",()=>this.updateDecorOccludesShape(e.id,t,i.checked)),n.appendChild(i),n.appendChild(document.createTextNode(this.shapeLabel(t))),this.contextMasksSubmenu.appendChild(n)}}updateDecorOccludesShape(e,t,n){const i=this.ufoElement.sighting;i.decor=i.decor.map(a=>{if(a.id!==e)return a;const r=n?[...new Set([...a.occludesSourceIds??[],t])]:(a.occludesSourceIds??[]).filter(o=>o!==t);return{...a,occludesSourceIds:r.length>0?r:void 0}}),this.ufoElement.refresh()}viewWitnessTestimony(){const e=this.ufoElement.sighting.decor.find(t=>t.id===this.contextMenuDecorId);this.hideDecorContextMenu(),e?.sightingUrl&&this.importFromUrl(e.sightingUrl)}addVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(n?.kind!=="polygon")return;const i=it.insertVertexNear(n,e);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:i}]),this.ufoElement.refresh()}deleteVertexAtContextMenu(){const e=this.contextMenuPoint;if(this.hideContextMenu(),!e)return;const t=this.ufoElement.currentTime,n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,this.currentSourceId);if(n?.kind!=="polygon")return;const i=it.hitTestVertex(n,e);if(i===void 0)return;const a=it.deleteVertex(n,i);this.commitShapes(t,[{sourceId:this.currentSourceId,shape:a}]),this.ufoElement.refresh()}bringSelectedToFront(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(n=>this.selectedSourceIds.has(n)))e.bringToFront(t);this.hideContextMenu(),this.ufoElement.refresh()}sendSelectedToBack(){const e=this.ufoElement.sighting.timeline;for(const t of e.sourceIds.filter(n=>this.selectedSourceIds.has(n)).reverse())e.sendToBack(t);this.hideContextMenu(),this.ufoElement.refresh()}groupSelected(){this.selectedSourceIds.size<2||(this.ufoElement.sighting.timeline.group([...this.selectedSourceIds]),this.hideContextMenu(),this.ufoElement.refresh())}ungroupSelected(){this.ufoElement.sighting.timeline.ungroup(this.currentSourceId),this.selectedSourceIds=new Set([this.currentSourceId]),this.hideContextMenu(),this.ufoElement.refresh()}beginDrag(e,t,n,i,a){this.dragState={kind:e,sourceId:t,original:n,handle:a,startPointer:i},this.startDragListening()}beginCameraDrag(e){const t=this.isWitnessInsideDecor();this.cameraDragState={startPointer:e,startHeadingDeg:t?this.indoorLookYawDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:t?this.indoorLookPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0,insideDecor:t},t||this.sceneElement.setCompassForced(!0),this.setCanvasCursor("panning"),this.startDragListening()}isWitnessInsideDecor(){return this.ufoElement.sighting.decor.some(e=>e.witnessSide!==void 0&&Ra(e.kind))}syncIndoorLookReset(){const e=this.ufoElement.sighting.decor.find(n=>n.witnessSide!==void 0&&Ra(n.kind)),t=e?`${e.id}:${e.witnessSide}`:void 0;t!==this.lastInhabitedKey&&(this.lastInhabitedKey=t,this.indoorLookYawDeg=0,this.indoorLookPitchDeg=0,this.sceneElement.setIndoorLook(0,0))}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(e){if(this.cameraDragState){this.onCameraDragPointerMove(e);return}if(!this.dragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.currentTime;if(this.dragState.kind==="move"){const{sources:i,startPointer:a}=this.dragState,r=t.x-a.x,o=t.y-a.y,l=i.map(({sourceId:c,original:h})=>({sourceId:c,shape:{...h,bounds:{...h.bounds,x:h.bounds.x+r,y:h.bounds.y+o}}}));this.commitShapes(n,l)}else if(this.dragState.kind==="group-resize"){const{group:i,handle:a}=this.dragState;this.commitShapes(n,i.resize(a,t))}else if(this.dragState.kind==="group-rotate"){const{group:i,startPointer:a}=this.dragState;this.commitShapes(n,i.rotate(t,a))}else if(this.dragState.kind==="vertex"){const{sourceId:i,original:a,vertexIndex:r}=this.dragState,o=it.moveVertex(a,r,t);this.commitShapes(n,[{sourceId:i,shape:o}])}else{const{kind:i,sourceId:a,original:r,handle:o}=this.dragState,l=i==="resize"?it.resizeShape(r,o,t):it.rotateShape(r,t);this.commitShapes(n,[{sourceId:a,shape:l}])}this.ufoElement.refresh()}onCameraDragPointerMove(e){if(!this.cameraDragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{startPointer:n,startHeadingDeg:i,startPitchDeg:a,insideDecor:r}=this.cameraDragState,o=i+(t.x-n.x)*j0,l=Math.max(-90,Math.min(90,a-(t.y-n.y)*j0));if(r){this.indoorLookYawDeg=o,this.indoorLookPitchDeg=l,this.sceneElement.setIndoorLook(o,l),this.ufoElement.refresh();return}this.headingInput.value=String(this.rounded(o)),this.pitchInput.value=String(this.rounded(l)),this.updateObserver()}endDrag(){!this.dragState&&!this.cameraDragState||(this.cameraDragState&&!this.cameraDragState.insideDecor&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,this.setCanvasCursor(this.hoverCursor),document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}nudgeBounds(e,t){const n={...e};if(t.shiftKey){switch(t.key){case"ArrowLeft":n.width=Math.max(8,n.width-cs);break;case"ArrowRight":n.width+=cs;break;case"ArrowUp":n.height=Math.max(8,n.height-cs);break;case"ArrowDown":n.height+=cs;break}n.x-=(n.width-e.width)/2,n.y-=(n.height-e.height)/2}else switch(t.key){case"ArrowLeft":n.x-=cs;break;case"ArrowRight":n.x+=cs;break;case"ArrowUp":n.y-=cs;break;case"ArrowDown":n.y+=cs;break}return n}moveOrResizeSelectedShapes(e){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.currentTime,n=this.selectedMembers();if(n.length!==0){if(e.preventDefault(),n.length===1){const{sourceId:i,shape:a}=n[0];this.commitShapes(t,[{sourceId:i,shape:{...a,bounds:this.nudgeBounds(a.bounds,e)}}])}else{const i=new ic(n),a=this.nudgeBounds(i.bounds(),e);this.commitShapes(t,i.scaleTo(a))}this.ufoElement.refresh()}}updateHoverCursor(e){this.isRecording||this.dragState||this.cameraDragState||(this.hoverCursor=this.hoverCursorAt(e),this.setCanvasCursor(this.hoverCursor))}hoverCursorAt(e){const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,i=this.ufoElement.currentTime,a=this.ufoElement.playbackState!=="playing";if(a)if(this.selectedSourceIds.size>1){const r=it.hitTestHandle({bounds:new ic(this.selectedMembers()).bounds(),angle:0},t);if(r)return this.cursorForHandle(r,0)}else{const r=n.getInterpolatedShapeAt(i,this.currentSourceId);if(r?.kind==="polygon"&&it.hitTestVertex(r,t)!==void 0)return"vertex";const o=r&&it.hitTestHandle(r,t);if(r&&o)return this.cursorForHandle(o,r.angle)}return n.hitTest(i,t.x,t.y)?a?"move":"select":this.pickDecorAt(e)!==void 0?"select":a?"pan":void 0}cursorForHandle(e,t){return e==="rotate"?"rotate":`resize-${it.resizeAxisFor(e,t)}`}setCanvasCursor(e){const t=this.ufoElement.canvasElement;e?t.dataset.cursor=e:delete t.dataset.cursor}onPointerMove(e){if(!this.isRecording){this.updateHoverCursor(e);return}const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top;this.recorder?.onPointerMove(i,a),this.ufoElement.renderer.clear(t.width,t.height),this.ufoElement.renderer.paintShape(rm(this.buildPrototype({x:0,y:0,width:Ta.width,height:Ta.height}),i,a))}canvasPointFromEvent(e){const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(!(n.width===0||n.height===0))return{x:(e.clientX-n.left)/n.width*t.width,y:(e.clientY-n.top)/n.height*t.height}}}const YT={stated:"narrativeStated",derived:"narrativeDerived",assumed:"narrativeAssumed"},tm="rr0-sighting-editor",nm="rr0-ufo-recorder";class KT extends Mt{}function $T(){ql(),customElements.get(tm)||customElements.define(tm,Mt),customElements.get(nm)||customElements.define(nm,KT)}$T();export{En as $,Zn as A,gt as B,ve as C,hb as D,Vi as E,rA as F,ut as G,Dt as H,tA as I,eA as J,Ze as K,no as L,sA as M,fo as N,Tt as O,lb as P,bs as Q,Tl as R,zr as S,ZT as T,nA as U,Re as V,Hm as W,iA as X,ml as Y,cn as Z,ei as _,jT as a,QT as a0,ar as a1,zm as a2,aA as a3,Cy as a4,Dl as a5,gd as a6,Nl as a7,tn as a8,Ym as a9,gu as aa,vu as ab,Qe as ac,vs as ad,to as ae,Ti as af,Yi as ag,JT as b,On as c,cA as d,Rl as e,Nn as f,lA as g,qe as h,R as i,qf as j,oA as k,hA as l,Ty as m,Bs as n,cc as o,Ih as p,Cv as q,At as r,Va as s,Wt as t,Bh as u,vn as v,Gm as w,Ki as x,ky as y,Vy as z};