@rr0/ufoathome 0.189.0 → 0.189.1
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.
- package/dist-embed-scene/rr0-scene.mjs +5 -5
- package/dist-embed-sighting/{CaseReportExport-Dq8QfB_9.js → CaseReportExport-GwM0Pm21.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +9 -9
- package/dist-embed-sighting-editor/{CaseReportExport-DQEJL9zL.js → CaseReportExport-DNBdWKUJ.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_en-Bt9dhchY.js → SightingEditorMessages_en-BgJRl09G.js} +2 -2
- package/dist-embed-sighting-editor/{SightingEditorMessages_es-BnoHmcFj.js → SightingEditorMessages_es-CK8yosal.js} +2 -2
- package/dist-embed-sighting-editor/{SightingEditorMessages_fr-CE7C8gk2.js → SightingEditorMessages_fr-CcBrcUd-.js} +2 -2
- package/dist-embed-sighting-editor/{SightingEditorMessages_it-lqZ7QCHn.js → SightingEditorMessages_it-Dvnh7lnI.js} +2 -2
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +16 -11
- package/package.json +1 -1
|
@@ -1932,9 +1932,9 @@ button:has(> .icon:only-child) { display: inline-flex; align-items: center; just
|
|
|
1932
1932
|
`}class Yr{static KINDS=["beams","launches","reentries"];static statedKinds(t){return Object.keys(t??{}).filter(e=>Array.isArray(t[e])&&t[e].length>0)}static isEmpty(t){return Yr.statedKinds(t).length===0}static written(t){const e=Yr.statedKinds(t);if(e.length===0)return;const i={};for(const n of e)i[n]=t[n];return i}static read(t,e){const i=e,n={};for(const r of Yr.statedKinds(t))n[r]=t[r];for(const r of Yr.KINDS){const a=[...t?.[r]??[],...i?.[r]??[]];a.length>0&&(n[r]=a)}let s=e;if(i&&Yr.KINDS.some(r=>r in i)){const{beams:r,launches:a,reentries:c,...l}=i;s=Yr.isReading(l)?l:void 0}return{skyEvents:Yr.written(n),interpretation:s}}static isReading(t){return(t.bodies?.length??0)>0||t.title!==void 0||(t.smoke?.length??0)>0}}function Lu(o){return[...o].sort((t,e)=>t.t-e.t)}function rf(o,t){let e;for(const i of Lu(o)){if(i.t>t)break;e=i}return e}const pm=Math.PI/180,af=180/Math.PI;class ca{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*pm/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new ca(t.projection,e,i)}degToPx(t){const e=t*pm;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*af:2*Math.atan(t/(2*this.focalPx))*af}angleDegToRadiusPx(t){const e=t*pm;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*af:Math.atan(t/this.focalPx)*af}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(di.angularWidthDeg(t))}}class mn{static fovOf(t,e){return ke(t,e)?.fovDeg??qi.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>{const n=i.ofBounds(e.bounds);return e.angular?.widthDeg===n.widthDeg&&e.angular.heightDeg===n.heightDeg?e:{...e,angular:n}})}static toBounds(t){this.eachKeyframe(t,(e,i)=>this.sizedFromAngle(e,i))}static sizedFromAngle(t,e){if(!t.angular)return t;const{width:i,height:n}=e.toBoundsSize(t.angular),s={x:t.bounds.x+(t.bounds.width-i)/2,y:t.bounds.y+(t.bounds.height-n)/2,width:i,height:n};if(t.kind!=="polygon")return{...t,bounds:s};const r=t.bounds.width===0?1:i/t.bounds.width,a=t.bounds.height===0?1:n/t.bounds.height;return{...t,bounds:s,points:t.points.map(c=>({x:c.x*r,y:c.y*a}))}}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<mn.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<mn.UNMOVED_PX)return e;const r=this.aimFrom(t,i,n,e.bounds);return r?{...e,aim:r}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=ca.of(t.instrument,di.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,ke(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),r=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),a=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+a}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>this.placedByAim(t,e,i,n))}static placedByAim(t,e,i,n){const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e}static derivable(t){const e=new Set,i=new Map,n=new Map;return t.timeline.allKeyframes.forEach((s,r)=>{const a=ke(t,s.t),c=ca.of(t.instrument,di.CANVAS_HEIGHT_PX,this.fovOf(t,s.t));for(const{sourceId:l,shape:h}of s.shapes){const u=n.get(l),d=i.get(l);if(n.set(l,h),!u||!d){i.set(l,h);continue}const f=Object.fromEntries(Object.entries(h).filter(([m,M])=>m!=="bounds"&&m!=="points"&&JSON.stringify(M)!==JSON.stringify(u[m]))),p={...d,...f},g=this.placedByAim(t,this.sizedFromAngle(p,c),c,a);mn.near(g,h)?(e.add(`${r}:${l}`),i.set(l,p)):i.set(l,h)}}),(s,r)=>e.has(`${s}:${r}`)}static SAME_PX=1e-6;static near(t,e){const i=(r,a)=>Math.abs(r-a)<=mn.SAME_PX*Math.max(1,Math.abs(a)),n=t.bounds,s=e.bounds;return!i(n.x,s.x)||!i(n.y,s.y)||!i(n.width,s.width)||!i(n.height,s.height)?!1:e.kind!=="polygon"||t.kind!=="polygon"?!0:t.points.length===e.points.length&&t.points.every((r,a)=>i(r.x,e.points[a].x)&&i(r.y,e.points[a].y))}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(t),a=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,a)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:qi.frameWidthPx(t.instrument,di.CANVAS_HEIGHT_PX)/2,y:di.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=mn.OFF_CANVAS_DEG?Math.sign(e)*mn.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=qi.frameWidthPx(e,di.CANVAS_HEIGHT_PX)/2,s=qi.frameWidthPx(t.instrument,di.CANVAS_HEIGHT_PX)/2,r=di.CANVAS_HEIGHT_PX/2;for(const a of[...t.timeline.allKeyframes]){const c=this.fovOf(t,a.t),l=i?.get(a.t)??c,h=ca.of(e,di.CANVAS_HEIGHT_PX,l),u=ca.of(t.instrument,di.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(a.t,a.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,g=f.y+f.height/2-r,m=Math.hypot(p,g),M=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,v={...f,x:s+p*M-f.width/2,y:r+g*M-f.height/2};return{...d,shape:{...d.shape,bounds:v}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=ke(t,n.t),r=this.fovOf(t,n.t),a=ca.of(t.instrument,di.CANVAS_HEIGHT_PX,r);let c=!1;const l=n.shapes.map(h=>{const u=e(h.shape,a,s);return u===h.shape?h:(c=!0,{...h,shape:u})});c&&i.addKeyframe(n.t,l)}}}class gs{static isRelative(t){return t!==void 0&&typeof t.eastM=="number"&&typeof t.northM=="number"}static isAbsolute(t){return t!==void 0&&typeof t.lat=="number"&&typeof t.lng=="number"}static referenceOf(t,e){return e.references.find(i=>(i.id??void 0)===(t.relativeTo??void 0))}static resolve(t,e){if(gs.isRelative(t)){const i=gs.referenceOf(t,e);return i?{eastM:i.eastM+t.eastM,northM:i.northM+t.northM}:void 0}return gs.isAbsolute(t)&&e.origin?gs.toLocal(t,e.origin):void 0}static restated(t,e,i){if(gs.isRelative(t)){const s=gs.referenceOf(t,i);return s?gs.relative(e.eastM-s.eastM,e.northM-s.northM,t.relativeTo):void 0}if(!i.origin)return t;const n=gs.toGeo(e,i.origin);return{lat:gs.degrees(n.lat),lng:gs.degrees(n.lng)}}static relative(t,e,i){const n={eastM:gs.metres(t),northM:gs.metres(e)};return i!==void 0&&(n.relativeTo=i),n}static toLocal(t,e){const i=ae(t.lat,t.lng,e.lat,e.lng);return{eastM:i.x,northM:-i.z}}static toGeo(t,e){return ks(t.eastM,-t.northM,e.lat,e.lng)}static metres(t){return Math.round(t*100)/100}static degrees(t){return Math.round(t*1e7)/1e7}}class Qn{static restatedDecor(t){const e=Qn.originOf(t);return t.decor.map(i=>{let n=i;if(i.saidPosition){const s=Qn.restated(i.saidPosition,i,Qn.frameAt(t,0,e,i.id));JSON.stringify(s)!==JSON.stringify(i.saidPosition)&&(n={...i,saidPosition:s},s||delete n.saidPosition)}if(i.track?.some(s=>s.saidPosition)){const s=i.track.map(r=>{if(!r.saidPosition)return r;const a=Qn.restated(r.saidPosition,r,Qn.frameAt(t,r.t,e,i.id));if(JSON.stringify(a)===JSON.stringify(r.saidPosition))return r;const c={...r,saidPosition:a};return a||delete c.saidPosition,c});n={...n,track:s}}return n})}static restatedObserverTrack(t){const e=t.observerTrack.toJSON(),i=Qn.originOf(t);return!i||!e.keyframes.some(n=>n.pose.saidPosition)?e:{...e,keyframes:e.keyframes.map(n=>{const{pose:s}=n;if(!s.saidPosition||s.lat===void 0||s.lng===void 0)return n;const r=gs.toLocal({lat:s.lat,lng:s.lng},i),a=Qn.restated(s.saidPosition,r,Qn.frameAt(t,n.t,i));if(JSON.stringify(a)===JSON.stringify(s.saidPosition))return n;const c={...s,saidPosition:a};return a||delete c.saidPosition,{...n,pose:c}})}}static restatedInterpretation(t){const e=t.interpretation;if(!e?.bodies.some(n=>n.track.some(s=>s.saidPosition)))return e;const i=Qn.originOf(t);return{...e,bodies:e.bodies.map(n=>n.track.some(s=>s.saidPosition)?{...n,track:n.track.map(s=>{if(!s.saidPosition)return s;const r=s.eastM!==void 0&&s.northM!==void 0?Qn.restated(s.saidPosition,{eastM:s.eastM,northM:s.northM},Qn.frameAt(t,s.t,i)):void 0;if(JSON.stringify(r)===JSON.stringify(s.saidPosition))return s;const a={...s,saidPosition:r};return r||delete a.saidPosition,a})}:n)}}static originOf(t){const e=t.observerTrack.getInterpolatedPoseAt(0),i=t.event.place?.[0],n=e?.lat??i?.lat,s=e?.lng??i?.lng;return typeof n=="number"&&typeof s=="number"?{lat:n,lng:s}:void 0}static frameAt(t,e,i,n){const s=[{label:"",eastM:0,northM:0},...t.decor.filter(r=>r.id!==n).map(r=>{const{eastM:a,northM:c}=da(r,e);return{id:r.id,label:r.id,eastM:a,northM:c}})];return{origin:i,references:s}}static restated(t,e,i){return gs.restated(t,{eastM:e.eastM,northM:e.northM},i)}}class ci{constructor(t,e,i){this.params=t,this.from=e,this.origin=t.path[0],this.cos0=Math.cos(t.path[0].lat*Math.PI/180),this.points=t.path.map(r=>this.local(r)),this.cumulative=[0];for(let r=1;r<this.points.length;r++){const a=this.points[r-1],c=this.points[r];this.cumulative.push(this.cumulative[r-1]+Math.hypot(c.e-a.e,c.n-a.n))}this.distances=[];let n=0;for(let r=e;r<=i+ci.BEYOND_MS;r+=ci.STEP_MS)this.distances.push(n),n+=this.speedAt(r)*ci.STEP_MS/1e3;this.shift=this.project(this.local(t.through))-this.distanceAt(t.through.t);const s=[];for(let r=e;r<=i;r+=ci.SAMPLE_MS)s.push({t:r,place:this.placeAt(r)});this.sampleOrigin=s[0].place,this.sampleCos=Math.cos(this.sampleOrigin.lat*Math.PI/180),this.samples=s.map(({t:r,place:a})=>({t:r,e:(a.lng-this.sampleOrigin.lng)*Math.PI/180*ci.R*this.sampleCos,n:(a.lat-this.sampleOrigin.lat)*Math.PI/180*ci.R}))}static R=63710088e-1;static STEP_MS=100;static SAMPLE_MS=2e3;static BEYOND_MS=8e4;origin;cos0;points;cumulative;distances;shift;samples;sampleOrigin;sampleCos;get start(){return this.sampleOrigin}stateAt(t){const e=this.samples,i=e.length-2;let n=0;for(;n<i&&e[n+1].t<t;)n++;const s=e[n],r=e[n+1],a=(t-s.t)/(r.t-s.t),c=p=>[n>0?p[n-1]:2*p[n]-p[n+1],p[n],p[n+1],n+2<p.length?p[n+2]:2*p[n+1]-p[n]],l=e.map(p=>p.e),h=e.map(p=>p.n),u=ci.catmull(c(l),a),d=ci.catmull(c(h),a),f=(Math.atan2(ci.slope(c(l),a),ci.slope(c(h),a))*180/Math.PI%360+360)%360;return{eastM:u,northM:d,roadDeg:f,lat:this.sampleOrigin.lat+d/ci.R*180/Math.PI,lng:this.sampleOrigin.lng+u/(ci.R*this.sampleCos)*180/Math.PI}}bearingAt(t,e){const i=this.local(this.placeAt(t)),n=this.local(e);return(Math.atan2(n.e-i.e,n.n-i.n)*180/Math.PI%360+360)%360}get sampleTimes(){return this.samples.map(t=>t.t)}placeAt(t){const e=this.along(this.distanceAt(t)+this.shift);return{lat:this.origin.lat+e.n/ci.R*180/Math.PI,lng:this.origin.lng+e.e/(ci.R*this.cos0)*180/Math.PI}}distanceAt(t){const e=Math.max(0,Math.min(this.distances.length-1,Math.round((t-this.from)/ci.STEP_MS)));return this.distances[e]}speedAt(t){const e=this.params.speedDivisors?ci.linear(this.params.speedDivisors.map(({t:i,divisor:n,step:s})=>({t:i,value:n,step:s})),t):1;return ci.linear(this.params.speeds.map(({t:i,kmh:n,step:s})=>({t:i,value:n,step:s})),t)/3.6/e}local(t){return{e:(t.lng-this.origin.lng)*Math.PI/180*ci.R*this.cos0,n:(t.lat-this.origin.lat)*Math.PI/180*ci.R}}along(t){const e=this.points;let i=0;for(;i<e.length-2&&this.cumulative[i+1]<t;)i++;const n=e[i],s=e[i+1],r=(t-this.cumulative[i])/(this.cumulative[i+1]-this.cumulative[i]);return{e:n.e+(s.e-n.e)*r,n:n.n+(s.n-n.n)*r}}project(t){let e=1/0,i=0;for(let n=0;n<this.points.length-1;n++){const s=this.points[n],r=this.points[n+1],a=r.e-s.e,c=r.n-s.n,l=Math.max(0,Math.min(1,((t.e-s.e)*a+(t.n-s.n)*c)/(a*a+c*c))),h=Math.hypot(s.e+a*l-t.e,s.n+c*l-t.n);h<e&&(e=h,i=this.cumulative[n]+l*Math.hypot(a,c))}return i}static linear(t,e){if(e<=t[0].t)return t[0].value;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(s.step&&e<s.t)return n.value;if(e<=s.t)return n.value+(s.value-n.value)*(e-n.t)/(s.t-n.t)}return t[t.length-1].value}static catmull([t,e,i,n],s){return .5*(2*e+(i-t)*s+(2*t-5*e+4*i-n)*s*s+(3*e-t-3*i+n)*s**3)}static slope([t,e,i,n],s){return .5*(i-t+2*(2*t-5*e+4*i-n)*s+3*(3*e-t-3*i+n)*s*s)}}class ti{constructor(t,e,i,n,s,r){this.drive=t,this.eye=e,this.lookAhead=i,this.lean=n,this.watch=s,this.times=t.sampleTimes;const a=i.pitchShare??1;this.aimed=[];for(const c of this.times){const l=t.bearingAt(c,i.target),h=this.aimed[this.aimed.length-1];this.aimed.push(h===void 0?l:h+ti.signed(l-h))}this.pitched=this.times.map(c=>r(c)*a)}static STEP_MS=250;static DENSE_MS=50;static SETTLED_MS=700;static TURN_S=.4;static TURN_S_PER_DEG=.5/150;static ROAD_PITCH_DEG=-1;static SHOULDER={x:-.08,y:0,z:-.07};static TWIST_FROM_DEG=60;aimed;pitched;times;poses(t,e){const i=[];for(let u=t;u<e;u+=ti.STEP_MS)i.push(u);i.push(e);const n=new Map(i.map(u=>{const d=this.sample(u);return[u,ti.signed(d.headingDeg-d.roadDeg)]})),s=u=>n.get(i.reduce((d,f)=>Math.abs(f-u)<Math.abs(d-u)?f:d)),r=this.schedule(s,e),a=this.watch?.t,c=r.map(([u,d],f)=>{if(f===0)return 0;if(u===a&&this.lean)return this.lean.params.turnS;const p=this.sample(u);return ti.turnS(this.target(r[f-1][1],p),this.target(d,p))}),l=new Set(i),h=r.map(([u],d)=>[u,c[d]]);this.lean&&h.push([this.lean.t,this.lean.params.turnS],[this.lean.t+this.lean.params.holdS*1e3,this.lean.params.turnS]);for(const[u,d]of h){const f=Math.round(u+d*1e3+ti.SETTLED_MS)+ti.DENSE_MS;for(let p=Math.round(u);p<f;p+=ti.DENSE_MS)p>=t&&p<=e&&l.add(p)}return[...l].sort((u,d)=>u-d).map(u=>{const d=this.sample(u),[f,p]=this.gaze(r,c,d),g=this.drive.stateAt(u);return{t:u,headingDeg:f,pitchDeg:p,eye:this.eyeAt(u,ti.signed(f-d.roadDeg)),roadDeg:g.roadDeg,lat:g.lat,lng:g.lng}})}schedule(t,e){const i=[],n=this.lookAhead,s=this.watch?.t??e;let r=0;for(;r<s;){if(Math.abs(t(r))<=n.glanceBeyondDeg){(i.length===0||i[i.length-1][1]!=="watch")&&i.push([r,"watch"]),r+=ti.STEP_MS;continue}if(i.push([r,"glance"]),r+=n.glanceS*1e3,r>=s)break;i.push([r,"road"]),r+=n.roadS*1e3}if(!this.watch)return i;const a=this.watch.params;r=s,i.push([r,"mirror"]),r+=a.firstS*1e3;let c=0;for(;r<e;){const l=r<a.glancesUntil&&c%2===0?"glance":"road";i.push([r,l]),r+=(l==="glance"?a.glanceS:a.roadS)*1e3,i.push([r,"mirror"]),r+=a.mirrorS*1e3,c++}return i}sample(t){const e=this.times,i=e.length-2;let n=0;for(;n<i&&e[n+1]<t;)n++;const s=(t-e[n])/(e[n+1]-e[n]),r=a=>[n>0?a[n-1]:2*a[n]-a[n+1],a[n],a[n+1],n+2<a.length?a[n+2]:2*a[n+1]-a[n]];return{t,roadDeg:this.drive.stateAt(t).roadDeg,headingDeg:(ci.catmull(r(this.aimed),s)%360+360)%360,pitchDeg:ci.catmull(r(this.pitched),s),eye:this.eyeAt(t,0)}}target(t,e){const{roadDeg:i,headingDeg:n,pitchDeg:s,eye:r}=e;if(t==="glance")return[n,s];if(t==="watch"){const u=ti.signed(n-i),d=this.lookAhead.keepDeg,f=u-d*Math.tanh(u/d),p=u?f/u:0;return[ti.normalized(i+f),ti.ROAD_PITCH_DEG+(s-ti.ROAD_PITCH_DEG)*p]}if(t==="road"||!this.watch)return[i,ti.ROAD_PITCH_DEG];const a=this.watch.params.mirror,c={x:a.x-r.x,y:a.y-r.y,z:a.z-r.z},l=Math.atan2(-c.x,-c.z)*180/Math.PI,h=Math.atan2(c.y,Math.hypot(c.x,c.z))*180/Math.PI;return[ti.normalized(i-l),h]}gaze(t,e,i,n){const s=i.t;let r=n??0;if(n===void 0&&s>=t[0][0])for(let m=0;m<t.length;m++)t[m][0]<=s&&(r=m);const[a,c]=this.target(t[r][1],i);if(r===0)return[a,c];const l=e[r]*1e3,h=s-t[r][0];if(h>l+ti.SETTLED_MS)return[a,c];const[u,d]=this.gaze(t,e,i,r-1);if(h<l){const m=h/l,M=-2*m**3+3*m*m+(m**3-m*m)*yn.ARRIVAL;return[ti.normalized(u+ti.signed(a-u)*M),d+(c-d)*M]}const f=ti.signed(a-u),p=h-l,g=yn.ARRIVAL/l*p*Math.exp(-p/Math.min(yn.SETTLE_MS,.4*l));return[ti.normalized(a+f*g),c+(c-d)*g]}leanAt(t){if(!this.lean)return 0;const{holdS:e,turnS:i}=this.lean.params,n=(t-this.lean.t)/1e3;return n<0||n>e+i?0:ti.smooth(Math.min(1,n/i,(e+i-n)/i))}eyeAt(t,e){const i=this.leanAt(t),n=this.lean?.params.offsetM??{x:0,y:0,z:0},s=ti.smooth((Math.abs(e)-ti.TWIST_FROM_DEG)/(180-ti.TWIST_FROM_DEG)),r=ti.SHOULDER;return{x:this.eye.x+n.x*i+r.x*s,y:this.eye.y+n.y*i+r.y*s,z:this.eye.z+n.z*i+r.z*s}}static turnS(t,e){return ti.TURN_S+ti.TURN_S_PER_DEG*Math.hypot(ti.signed(e[0]-t[0]),e[1]-t[1])}static smooth(t){const e=Math.min(1,Math.max(0,t));return e*e*e*(10-15*e+6*e*e)}static signed(t){return((t+540)%360+360)%360-180}static normalized(t){return(t%360+360)%360}}const mm=Math.PI/180;class Lt{constructor(t,e,i){this.body=t,this.ground=e,this.eyeAt=i;const n=Lt.placedInWorld.get(t);if(n){this.keys=n.keys,this.motionKeys=n.motionKeys,this.turnKeys=n.turnKeys,this.lightKeys=n.lightKeys;return}const s=[...t.track].sort((r,a)=>r.t-a.t);this.keys=this.place(s,i),this.motionKeys=new Map,this.turnKeys=new Map,this.lightKeys=new Map;for(const r of s)Lt.collect(this.motionKeys,r.t,r.motions),Lt.collect(this.turnKeys,r.t,r.turns),Lt.collect(this.lightKeys,r.t,r.lights);!t.withObserver&&s.every(r=>r.azimuthDeg===void 0&&r.altitudeDeg===void 0)&&Lt.placedInWorld.set(t,{keys:this.keys,motionKeys:this.motionKeys,turnKeys:this.turnKeys,lightKeys:this.lightKeys})}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,finish:"matt",luminanceCdM2:0,transparency:0,haloScale:1};keys;static placedInWorld=new WeakMap;motionKeys;turnKeys;lightKeys;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const r=t.get(n)??[];r.push({t:e,value:s}),t.set(n,r)}}motionsAt(t){return Lt.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?Lt.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,r]of t){let a=r.length-1;for(;a>=0&&r[a].t>e;)a--;if(a<0){i!==void 0&&(n[s]=i);continue}const c=r[a],l=r[Math.min(a+1,r.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=Lt.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=ke(t,0),s=ke(t,e),a=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ae(s.lat,s.lng,n.lat,n.lng):void 0,c=a?a.x:0,l=a?-a.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+Lt.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=Lt.directionOf(e,i),r=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let a=0,c=0;for(;c<Lt.MAX_RANGE_M;){if(c=a+Math.max(.5,a*.01),r(c)<=0){for(let l=0;l<30;l++){const h=(a+c)/2;r(h)<=0?c=h:a=h}return c}a=c}}static directionOf(t,e){const i=t*mm,n=e*mm;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(t){const e=this.keys;if(e.length===0||t<e[0].t)return;let i=0,n=e.length-1;for(;i<n;){const g=i+n+1>>1;e[g].t>t?n=g-1:i=g}const s=i,r=e[s];if(!r.present)return;const a=e[Math.min(s+1,e.length-1)],c=a===r||a.t===r.t?0:Math.min(1,(t-r.t)/(a.t-r.t)),l=this.body.withObserver&&r.carried&&a.carried?this.eyeAt(t):void 0,h=l?l.eastM+Lt.lerp(r.carried.eastM,a.carried.eastM,c):Lt.lerp(r.eastM,a.eastM,c),u=l?l.northM+Lt.lerp(r.carried.northM,a.carried.northM,c):Lt.lerp(r.northM,a.northM,c),d={widthM:Lt.lerp(r.sizeM.widthM,a.sizeM.widthM,c),lengthM:Lt.lerp(r.sizeM.lengthM,a.sizeM.lengthM,c),heightM:Lt.lerp(r.sizeM.heightM,a.sizeM.heightM,c)},f={headingDeg:Lt.lerpAngle(r.attitude.headingDeg,a.attitude.headingDeg,c),pitchDeg:Lt.lerp(r.attitude.pitchDeg,a.attitude.pitchDeg,c),rollDeg:Lt.lerp(r.attitude.rollDeg,a.attitude.rollDeg,c)};let p;if(l)p=l.upM+Lt.lerp(r.carried.upM,a.carried.upM,c);else if("aboveGroundM"in r.vertical&&"aboveGroundM"in a.vertical){const g=Lt.lerp(r.vertical.aboveGroundM,a.vertical.aboveGroundM,c);p=this.groundUnderFootprint(h,u,d,f.headingDeg)+g+d.heightM/2}else p=Lt.lerp(this.centreUpOf(r),this.centreUpOf(a),c);return{id:this.body.id,model:this.body.model,modelParameters:this.body.modelParameters,flicker:this.body.flicker,explains:this.body.explains??[],...this.body.ensemble?{ensemble:this.body.ensemble}:{},...this.body.shadow===!1?{shadow:!1}:{},...this.body.lightFromBelow?{lightFromBelow:this.body.lightFromBelow}:{},outlineNode:this.body.outlineNode,eastM:h,northM:u,upM:p,sizeM:d,attitude:f,appearance:{color:Lt.lerpColor(r.appearance.color,a.appearance.color,c),albedo:Lt.lerp(r.appearance.albedo,a.appearance.albedo,c),finish:c<1?r.appearance.finish:a.appearance.finish,luminanceCdM2:Lt.lerp(r.appearance.luminanceCdM2,a.appearance.luminanceCdM2,c),transparency:Lt.lerp(r.appearance.transparency,a.appearance.transparency,c),haloScale:Lt.lerp(r.appearance.haloScale,a.appearance.haloScale,c)},flame:Lt.flameBetween(r.flame,a.flame,c),motions:this.motionsAt(t),...this.turnKeys.size>0?{turns:Lt.channelsAt(this.turnKeys,t,0)}:{},lights:this.lightsAt(t),throwsFlame:this.body.track.some(g=>g.flame!==void 0&&g.flame.luminanceCdM2>0)}}static flameBetween(t,e,i){if(!t||t.luminanceCdM2<=0)return i>=1&&e&&e.luminanceCdM2>0?e:void 0;const n=t,s=e??t,r={...i<1?n:s,lengthM:Lt.lerp(n.lengthM,s.lengthM,i),widthM:Lt.lerp(n.widthM,s.widthM,i),luminanceCdM2:Lt.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return r.luminanceCdM2>0?r:void 0}centreUpOf(t){if(!("upM"in t.vertical))return this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2;const e=t.vertical.fromGround;if(!e)return t.vertical.upM-(this.ground.dropAt?.(t.eastM,t.northM)??0);const i=t.vertical.upM+this.ground.heightAt(e.eastM,e.northM);return Math.max(i,this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.sizeM.heightM/2)}groundUnderFootprint(t,e,i,n){const s=n*mm,r={eastM:Math.cos(s),northM:-Math.sin(s)},a={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(t,e);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(t+r.eastM*u+a.eastM*d,e+r.northM*u+a.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const r=s.sizeM??n?.sizeM??Lt.DEFAULT_SIZE,a={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??Lt.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??Lt.DEFAULT_APPEARANCE.albedo,finish:s.appearance?.finish??n?.appearance.finish??Lt.DEFAULT_APPEARANCE.finish,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??Lt.DEFAULT_APPEARANCE.luminanceCdM2,transparency:s.appearance?.transparency??n?.appearance.transparency??Lt.DEFAULT_APPEARANCE.transparency,haloScale:s.appearance?.haloScale??n?.appearance.haloScale??Lt.DEFAULT_APPEARANCE.haloScale},l=this.positionOf(s,r,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s,r)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;if(n={t:s.t,...l,sizeM:r,attitude:a,appearance:c,flame:h,present:u},this.body.withObserver&&s.azimuthDeg!==void 0&&s.distanceM!==void 0){const d=Lt.directionOf(s.azimuthDeg,s.altitudeDeg??0);n.carried={eastM:d.eastM*s.distanceM,northM:d.northM*s.distanceM,upM:d.upM*s.distanceM}}i.push(n)}return i}verticalOf(t,e){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM};if(t.altitudeM!==void 0)return{upM:t.altitudeM+e.heightM/2,fromGround:this.body.altitudeFrom}}positionOf(t,e,i){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t,e)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const n=i(t.t);if(!n)return;const s=t.distanceM??(t.onGround?Lt.lineOfSightMeetsGround(n,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(s===void 0)return;const r=Lt.directionOf(t.azimuthDeg,t.altitudeDeg),a=n.eastM+r.eastM*s,c=n.northM+r.northM*s;return{eastM:a,northM:c,vertical:this.verticalOf(t,e)??{upM:n.upM+r.upM*s}}}static lerp(t,e,i){return t+(e-t)*i}static lerpColor(t,e,i){const n=Lt.rgbOf(t),s=Lt.rgbOf(e);return!n||!s?i<1?t:e:"#"+n.map((r,a)=>Math.round(Lt.lerp(r,s[a],i)).toString(16).padStart(2,"0")).join("")}static rgbOf(t){const e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(!e)return;const i=e[1].length===3?e[1].replace(/./g,"$&$&"):e[1];return[0,2,4].map(n=>parseInt(i.slice(n,n+2),16))}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}class Ps{static ANONYMOUS_OBSERVER="observer";static observerId(t){return t.observer?.id??Ps.ANONYMOUS_OBSERVER}static shapeIds(t){const e=new Set(t.timeline.sourceIds);for(const i of t.events??[])if(i.eventType==="appearance")for(const n of i.params?.parts??[])e.add(n.sourceId);return[...e]}static ids(t){const e=new Map,i=(n,s)=>{n!==void 0&&e.set(n,[...e.get(n)??[],s])};i(Ps.observerId(t),"observer");for(const n of Ps.shapeIds(t))i(n,"shape");for(const n of t.timeline.allGroups)i(n.id,"group");for(const n of t.interpretation?.bodies??[])i(n.id,"body");for(const n of t.decor)i(n.id,"decor");return e}static kindOf(t,e){if(e===void 0)return;const i=Ps.ids(t).get(e);return i?.length===1?i[0]:void 0}static partOf(t){const e=t?.indexOf("/")??-1;if(!(t===void 0||e<=0||e===t.length-1))return{element:t.slice(0,e),part:t.slice(e+1)}}static hasPart(t,e,i){if(e==="body")return!0;if(e!=="decor")return!1;const n=t.decor.find(s=>s.id===i.element);return!!(n?.lights?.some(s=>s.id===i.part)||n?.groups?.some(s=>s.id===i.part))}static isObserver(t,e){return e.who===Ps.observerId(t)}static isPhenomenon(t,e){return e.who===void 0?!1:t.timeline.groupOf(e.who)!==void 0||Ps.shapeIds(t).includes(e.who)}static within(t,e){const i=new Set([e]),n=s=>{for(const r of t.timeline.groupOf(s)?.members??[])i.has(r)||(i.add(r),n(r))};return n(e),i}static renamed(t,e,i){if(e!==i)for(const n of t.events??[])n.who===e&&(n.who=i)}static issues(t){const e=[],i=Ps.ids(t);for(const[n,s]of i)s.length>1&&e.push({kind:"duplicate-id",id:n,path:s.join(", ")});return(t.events??[]).forEach((n,s)=>{const r=Ps.partOf(n.who);r&&i.get(r.element)?.length===1&&Ps.hasPart(t,i.get(r.element)[0],r)||(n.who===void 0||!i.has(n.who))&&e.push({kind:"unknown-who",id:n.who??"",path:`events.${s}.who`})}),e}}class Se{constructor(t,e,i){this.travel=t;const n=t.params,s=t.until??i;let r=Se.unit(n.from),a=Se.towards(r,Se.unit(n.towards));const c=e.map(h=>{const u=h.params,d=u.side==="left"?1:-1;return{from:h.t,to:h.until??h.t,radians:u.byDeg*Math.PI/180*(u.seenFrom==="craft"?-d:d)}}),l=Se.STEP_MS;for(let h=t.t;h<=s;h+=l){this.directions.push(Se.direction(r));for(const f of c){const p=f.to-f.from;if(p<=0)continue;const g=f.radians*(Se.smooth((h+l-f.from)/p)-Se.smooth((h-f.from)/p));g&&(a=Se.add(Se.scale(a,Math.cos(g)),Se.scale(Se.cross(a,r),Math.sin(g))))}const u=Se.speedAt(n.speeds,h)*l/1e3*Math.PI/180,d=Se.add(Se.scale(r,Math.cos(u)),Se.scale(a,Math.sin(u)));a=Se.add(Se.scale(a,Math.cos(u)),Se.scale(r,-Math.sin(u))),r=d}}static STEP_MS=5;directions=[];at(t){const e=Math.round((t-this.travel.t)/Se.STEP_MS);return this.directions[Math.max(0,Math.min(this.directions.length-1,e))]}sizeAt(t){const e=this.travel.params;return e.sizeBy!=="altitude"?e.sizeDeg:e.sizeDeg*Math.max(.1,Math.sin(Math.max(this.at(t).altitudeDeg,1)*Math.PI/180))}static speedAt(t,e){if(t.length===0)return 0;if(e<=t[0].t)return t[0].degPerS;for(let i=1;i<t.length;i++){const n=t[i-1],s=t[i];if(s.step&&e<s.t)return n.degPerS;if(e<s.t)return n.degPerS+(s.degPerS-n.degPerS)*Se.smooth((e-n.t)/(s.t-n.t))}return t[t.length-1].degPerS}static smooth(t){const e=Math.max(0,Math.min(1,t));return e*e*(3-2*e)}static unit(t){const e=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return[Math.cos(i)*Math.sin(e),Math.cos(i)*Math.cos(e),Math.sin(i)]}static direction(t){return{azimuthDeg:(Math.atan2(t[0],t[1])*180/Math.PI%360+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,t[2])))*180/Math.PI}}static towards(t,e){const i=Se.add(e,Se.scale(t,-Se.dot(t,e))),n=Math.hypot(...i)||1;return Se.scale(i,1/n)}static toScreen(t,e,i){const[n,s,r]=Se.basis(e,i),a=Se.unit(t),c=Se.dot(a,n);return[Se.dot(a,s)/c,Se.dot(a,r)/c]}static fromScreen(t,e,i,n){const[s,r,a]=Se.basis(i,n),c=[s[0]+t*r[0]+e*a[0],s[1]+t*r[1]+e*a[1],s[2]+t*r[2]+e*a[2]],l=Math.hypot(...c);return Se.direction([c[0]/l,c[1]/l,c[2]/l])}static basis(t,e){const i=t*Math.PI/180,n=e*Math.PI/180;return[[Math.cos(n)*Math.sin(i),Math.cos(n)*Math.cos(i),Math.sin(n)],[Math.cos(i),-Math.sin(i),0],[-Math.sin(n)*Math.sin(i),-Math.sin(n)*Math.cos(i),Math.cos(n)]]}static dot(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}static cross(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}static add(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}static scale(t,e){return[t[0]*e,t[1]*e,t[2]*e]}}class Eo{constructor(t,e){this.sighting=t,this.events=e}static FOV_DEG=60;keyframes(){const t=this.events.filter(c=>c.eventType==="look").sort((c,l)=>c.t-l.t),e=this.events.filter(c=>c.eventType==="walk").sort((c,l)=>c.t-l.t),i=this.events.filter(c=>c.eventType==="follow").sort((c,l)=>c.t-l.t);if(t.length===0&&e.length===0)return[];const n=new Set([0]);for(const c of[...t,...e,...i])n.add(c.t),c.until!==void 0&&n.add(c.until);const s=c=>{let l;for(const h of e){const u=h.params;if(c<=h.t)return l??u.from;if(h.until===void 0||c>=h.until)l=u.to;else return}return l??this.sighting.event.place?.[0]},r=c=>([...t].reverse().find(h=>h.t<=c)??t[0])?.params??{headingDeg:0,pitchDeg:0},a=[...n].sort((c,l)=>c-l).flatMap(c=>{const l=s(c);if(!l)return[];const h=r(c);return[{t:c,pose:Eo.pose(l,h.headingDeg,h.pitchDeg,h.fovDeg)}]});for(const c of a)this.sighting.observerTrack.addKeyframe(c.t,c.pose);for(const c of i)this.follow(c,r(c.t));return[...this.sighting.observerTrack.allKeyframes]}follow(t,e){const i=t.params;if(this.followSky(t,e))return;const n=this.sighting.interpretation?.bodies.find(h=>h.id===i.target);if(!n)return;const s={heightAt:()=>0},r=h=>Lt.eyeOf(this.sighting,h,s),a=new Lt(n,s,r),c=t.until??1/0;let l=e;for(const h of n.track){if(h.t<=t.t||h.t>=c)continue;const u=a.at(h.t),d=r(h.t),f=this.sighting.observerTrack.getInterpolatedPoseAt(h.t);if(!u||!d||!f)continue;const p=u.eastM-d.eastM,g=u.northM-d.northM,m=u.upM-d.upM;l={headingDeg:(Math.atan2(p,g)*180/Math.PI%360+360)%360,pitchDeg:Math.atan2(m,Math.hypot(p,g))*180/Math.PI},this.sighting.observerTrack.addKeyframe(h.t,{...f,headingDeg:l.headingDeg,pitchDeg:l.pitchDeg})}if(Number.isFinite(c)){const h=this.sighting.observerTrack.getInterpolatedPoseAt(c);h&&this.sighting.observerTrack.addKeyframe(c,{...h,headingDeg:l.headingDeg,pitchDeg:l.pitchDeg})}}static FOLLOW_SKY_MS=25;static CATCH_UP_MS=900;static OVERHEAD_DEG=78;static HIGHEST_PITCH_DEG=88;followSky(t,e){const i=t.params,n=Ps.within(this.sighting,i.target),s=this.sighting.events??[],r=s.find(M=>M.eventType==="travel"&&M.who!==void 0&&n.has(M.who));if(!r)return!1;const a=this.sighting.event.durationSeconds!==void 0?this.sighting.event.durationSeconds*1e3:r.until??t.t,c=new Se(r,s.filter(M=>M.eventType==="turn"&&M.who!==void 0&&n.has(M.who)),a),l=t.until??a,h=(i.lagS??0)*1e3,u=(i.reactionS??0)*1e3,d=[],f=this.sighting.sampleMs??Eo.FOLLOW_SKY_MS;for(let M=t.t;M<=l;M+=f)d.push(M);const p=d.map(M=>c.at(Math.max(r.t,M-h))),g=p.map(M=>M.azimuthDeg),m=p.flatMap((M,v)=>M.altitudeDeg>Eo.OVERHEAD_DEG?[v]:[]);if(m.length>0){const M=Math.max(0,m[0]-1),v=Math.min(d.length-1,m[m.length-1]+1),x=g[M],y=(g[v]-x+540)%360-180;for(let w=M;w<=v;w++)g[w]=((x+y*Se.smooth((w-M)/(v-M)))%360+360)%360}return d.forEach((M,v)=>{const x=Se.smooth((M-t.t-u)/Eo.CATCH_UP_MS),y=(g[v]-e.headingDeg+540)%360-180,w=Math.min(p[v].altitudeDeg,Eo.HIGHEST_PITCH_DEG),b=this.sighting.observerTrack.getInterpolatedPoseAt(M)??this.sighting.observerTrack.getLatestPoseAt(M);if(!b)return;const E=S=>Math.round(S*100)/100;this.sighting.observerTrack.addKeyframe(M,{...b,headingDeg:E(((e.headingDeg+y*x)%360+360)%360),pitchDeg:E(e.pitchDeg+(w-e.pitchDeg)*x)})}),!0}static pose(t,e,i,n=Eo.FOV_DEG){return{lat:t.lat,lng:t.lng,elevationM:0,headingDeg:e,pitchDeg:i,fovDeg:n}}}class Ho{constructor(t,e,i,n){this.body=t,this.events=e,this.endMs=i,this.sampleMs=n}static SAMPLE_MS=250;track(){const t=new Map,e=l=>{const h=t.get(l.t);t.set(l.t,h?{...h,...l,motions:{...h.motions,...l.motions},...h.turns||l.turns?{turns:{...h.turns,...l.turns}}:{},...h.lights||l.lights?{lights:{...h.lights,...l.lights}}:{}}:l)};for(const l of this.body.track)e({...l});const i=[...this.events].sort((l,h)=>l.t-h.t),n=new Map,s=new Map,r=new Map;let a=0;for(const l of this.body.track){for(const[h,u]of Object.entries(l.motions??{}))n.set(h,u);for(const[h,u]of Object.entries(l.turns??{}))s.set(h,u);for(const[h,u]of Object.entries(l.lights??{}))r.set(h,u);l.attitude?.headingDeg!==void 0&&(a=l.attitude.headingDeg)}let c=this.startPlace();for(const l of i){const h=Ho.partOf(l.who,this.body.id);if(h!==void 0&&(l.eventType==="light"||l.eventType==="blink")){for(const u of this.leavesOf(h))this.switchLight(u,l,r,e,d=>t.get(d)?.lights?.[u]);continue}if(h!==void 0){if(l.eventType!=="spin"&&l.eventType!=="turn")continue;const u=s.get(h)??0,d=l.until??l.t,f=l.eventType==="spin"?u+360*l.params.turnsPerS*(d-l.t)/1e3:l.params.headingDeg;e({t:l.t,turns:{[h]:u}}),e({t:d,turns:{[h]:f}}),s.set(h,f);continue}if((l.eventType==="motion"||l.eventType==="spin")&&l.params?.motion){const u=l.params,d=u.motion,f=n.get(d)??0,p=l.until??l.t,g=l.eventType==="motion"?u.to:f+u.turnsPerS*(p-l.t)/1e3;e({t:l.t,motions:{[d]:f}}),e({t:p,motions:{[d]:g}}),n.set(d,g)}else if(l.eventType==="rise"&&c){const u=l.params,d=l.until??l.t,f=u.angleDeg*Math.PI/180,p=(u.headingDeg??0)*Math.PI/180,g=c,m=M=>{const v=u.stops===!1?M*M:M*M*M*(10-15*M+6*M*M),x=u.distanceM*v;return{eastM:g.eastM+x*Math.sin(f)*Math.sin(p),northM:g.northM+x*Math.sin(f)*Math.cos(p),aboveGroundM:g.aboveGroundM+x*Math.cos(f)}};for(let M=l.t;M<d;M+=this.sampleMs??Ho.SAMPLE_MS)e(Ho.key(M,m((M-l.t)/(d-l.t))));c=m(1),e(Ho.key(d,c))}else if(l.eventType==="turn"){const u=l.params;e({t:l.t,attitude:{headingDeg:a}}),e({t:l.until??l.t,attitude:{headingDeg:u.headingDeg}}),a=u.headingDeg}else l.eventType==="vanish"&&e({t:l.t,present:!1})}return[...t.values()].sort((l,h)=>l.t-h.t)}static ride(t,e,i){const n=e.params,s=e.until??1/0,r=new Map(t.track.map(a=>[a.t,{...a}]));for(const a of i.track){if(a.t<e.t||a.t>s||(a.present===!1&&r.set(a.t,{...r.get(a.t),t:a.t,present:!1}),a.eastM===void 0||a.northM===void 0))continue;const c=(a.onGround?0:a.altitudeAboveGroundM??0)+n.aboveM;r.set(a.t,{...r.get(a.t),t:a.t,eastM:a.eastM,northM:a.northM,altitudeAboveGroundM:c})}return[...r.values()].sort((a,c)=>a.t-c.t)}switchLight(t,e,i,n,s){const r=i.get(t)??0,a=e.eventType==="light"?e.until:e.until??this.endMs,c=(l,h)=>n({t:l,lights:{[t]:h}});if(e.t>0&&s(e.t-1)===void 0&&c(e.t-1,r),e.eventType==="light"){const l=e.params.cdM2;if(c(e.t,l),a===void 0){i.set(t,l);return}c(a-1,l)}else{const l=e.params;if(a===void 0)return;const h=l.cdM2??r;let u=e.t,d=!0;for(;u<a;){const f=Math.min(Math.round(u+1e3*(d?l.onS:l.offS)),a);if(f<=u)break;c(u,d?h:0),c(f-1,d?h:0),u=f,d=!d}}c(a,r),i.set(t,r)}leavesOf(t,e=new Set){const i=this.body.groups?.find(n=>n.id===t);return!i||e.has(t)?[t]:(e.add(t),i.members.flatMap(n=>this.leavesOf(n,e)))}static partOf(t,e){return t!==void 0&&t.startsWith(`${e}/`)&&t.length>e.length+1?t.slice(e.length+1):void 0}startPlace(){const t=this.body.track.find(e=>e.eastM!==void 0&&e.northM!==void 0);return t&&{eastM:t.eastM,northM:t.northM,aboveGroundM:t.onGround?0:t.altitudeAboveGroundM??0}}static key(t,e){return e.aboveGroundM<=0?{t,eastM:e.eastM,northM:e.northM,onGround:!0}:{t,eastM:e.eastM,northM:e.northM,altitudeAboveGroundM:e.aboveGroundM}}}class Rd{constructor(t,e,i){this.object=t,this.events=e,this.endMs=i}lights(){const t=new Map,e=[...this.events].sort((i,n)=>i.t-n.t);for(const i of e){const n=Rd.partOf(i.who,this.object.id);if(!(n===void 0||i.eventType!=="light"&&i.eventType!=="blink"))for(const s of this.leavesOf(n)){const r=this.object.lights?.find(a=>a.id===s);r&&t.set(s,this.switched(r,t.get(s)??[],i))}}return(this.object.lights??[]).map(i=>t.has(i.id)?{...i,keyframes:t.get(i.id)}:i)}switched(t,e,i){const n=Rd.stateAt(t,e,i.t),s=i.eventType==="light"?i.until:i.until??this.endMs,r=[];if(i.eventType==="light")r.push({t:i.t,intensity:i.params.intensity,pattern:n.pattern});else{const c=i.params,l=c.onS+c.offS;if(s===void 0||l<=0)return e;const h=l*1e3,u=(-i.t/h%1+1)%1,d={kind:"flash",perMinute:60/l,dutyCycle:c.onS/l,...u?{phase:u}:{}},f=c.intensity??(n.intensity>0?n.intensity:t.intensity??1);r.push({t:i.t,intensity:f,pattern:d})}s!==void 0&&r.push({t:s,intensity:n.intensity,pattern:n.pattern});const a=new Set(r.map(c=>c.t));return[...e.filter(c=>!a.has(c.t)),...r].sort((c,l)=>c.t-l.t)}static stateAt(t,e,i){const n=e.filter(s=>s.t<=i).at(-1);return{intensity:n?.intensity??t.intensity??1,pattern:n?.pattern??t.pattern}}leavesOf(t,e=new Set){const i=this.object.groups?.find(n=>n.id===t);return!i||e.has(t)?[t]:(e.add(t),i.members.flatMap(n=>this.leavesOf(n,e)))}static partOf(t,e){return t!==void 0&&t.startsWith(`${e}/`)&&t.length>e.length+1?t.slice(e.length+1):void 0}}class Mh{static observer(t){const e=t.allKeyframes,i=e.map(s=>Mh.said(s.pose)),n=e.filter((s,r)=>r>0&&r<e.length-1&&i[r]===i[r-1]&&i[r]===i[r+1]);for(const s of n)t.removeKeyframeAt(s.t)}static said(t){return JSON.stringify(t,(e,i)=>typeof i=="number"?Math.round(i*1e10)/1e10:i)}static timeline(t){const e=new Map;for(const i of t.allKeyframes)for(const n of i.shapes){const s=e.get(n.sourceId)??[];s.push({t:i.t,said:Mh.said(n.shape)}),e.set(n.sourceId,s)}for(const[i,n]of e){const s=n.filter((r,a)=>a>0&&a<n.length-1&&r.said===n[a-1].said&&r.said===n[a+1].said);for(const r of s)t.removeShapeAt(r.t,i)}}}class Y0{constructor(t,e){this.end=e;const i=[...t].sort((n,s)=>n.t-s.t);this.rolls=i.filter(n=>n.eventType==="roll"),this.vibrations=i.filter(n=>n.eventType==="vibrate"),this.spirals=i.filter(n=>n.eventType==="spiral")}static SPIRAL_OPENS=4;static THINNEST=.08;rolls;vibrations;spirals;rollAt(t){let e=0,i=0;for(const n of this.rolls){if(t<n.t)break;const s=n.params,r=this.progress(n,t);i=e+(s.toDeg-e)*(s.andBack?Math.sin(Math.PI*Se.smooth(r)):Se.smooth(r)),s.andBack||(e=s.toDeg)}for(const n of this.spirals){if(t<n.t)break;const s=n.params;i=e+(s.clockwise?1:-1)*s.rollDeg*this.progress(n,t)}return i}acrossShareAt(t){return Math.max(Y0.THINNEST,Math.abs(Math.cos(this.rollAt(t)*Math.PI/180)))}sidewaysAt(t,e){let i=0;for(const n of this.vibrations){const s=n.until??this.end;if(t<n.t||t>=s)continue;const r=n.params,a=Se.smooth((t-n.t)/(r.riseS*1e3))*Math.max(0,1-(t-n.t)/(s-n.t));i+=r.amplitudeShare*e*a*Math.sin(2*Math.PI*r.hz*(t-n.t)/1e3)}return i}spiralAt(t){const e=[...this.spirals].reverse().find(a=>a.t<=t);if(!e)return;const i=e.params,n=this.progress(e,t),s=Math.tan(i.radiusDeg*Math.PI/180)*Se.smooth(n*Y0.SPIRAL_OPENS)*(1-i.shrink*Se.smooth(n)),r=-(i.clockwise?1:-1)*2*Math.PI*i.turns*n;return[s*(Math.cos(r)-1),s*Math.sin(r)]}progress(t,e){const i=t.until??this.end;return i<=t.t?1:Math.max(0,Math.min(1,(e-t.t)/(i-t.t)))}}class Is{constructor(t,e,i,n){this.sighting=t,this.stand=e;const s=i.filter(a=>a.eventType==="appearance").sort((a,c)=>a.t-c.t);this.vanishAt=i.find(a=>a.eventType==="vanish")?.t;const r=this.vanishAt??n;this.path=e.eventType==="travel"?new Se(e,i.filter(a=>a.eventType==="turn"),n):void 0,this.motion=this.path?new Y0(i,e.until??n):void 0,this.looks=s.map((a,c)=>({t:a.t,until:a.until??s[c+1]?.t??r,parts:a.params.parts})),this.blinks=i.filter(a=>a.eventType==="blink").map(a=>({t:a.t,until:a.until??r,parts:a.who===void 0?[]:t.timeline.leavesOf(a.who),params:a.params}))}static SAMPLE_MS=2e3;static TRAVEL_SAMPLE_MS=25;static MOTION_MS=40;static SPIRAL_AHEAD_MS=20;static R=63710088e-1;looks;blinks;vanishAt;path;motion;timeline(){const t=new Map,e=(r,a)=>{const c=this.state(a,r);c&&(t.has(r)||t.set(r,new Map),t.get(r).set(a,c))},i=[...new Set(this.looks.flatMap(r=>r.parts.map(a=>a.sourceId)))];this.looks.forEach((r,a)=>{const c=this.looks[a+1];for(const l of i){if(!r.parts.some(d=>d.sourceId===l)){e(r.t,l),c?.parts.some(d=>d.sourceId===l)&&e(c.t-1,l);continue}const u=this.sighting.sampleMs??(this.path?Is.TRAVEL_SAMPLE_MS:Is.SAMPLE_MS);for(let d=r.t;d<r.until;d+=u)e(d,l);e(r.until-1,l)}});for(const r of this.blinks)for(const[a,c]of this.phases(r))for(const l of r.parts)e(a,l),e(c-1,l);if(this.vanishAt!==void 0)for(const r of i)e(this.vanishAt,r);const n=[...t.keys()].sort((r,a)=>r-a).map(r=>({t:r,shapes:[...t.get(r).values()]})),s=new Map;for(const r of n)for(const a of r.shapes){const c=a.shape.angle,l=s.get(a.sourceId);if(c===void 0)continue;const h=l===void 0?c:c+2*Math.PI*Math.round((l-c)/(2*Math.PI));a.shape.angle=Math.round(h*1e4)/1e4,s.set(a.sourceId,h)}return{keyframes:n,order:i,groups:[]}}phases(t){const e=[];let i=!0;for(let n=t.t;n<t.until;){const s=Math.min(n+(i?t.params.onS:t.params.offS)*1e3,t.until);e.push([n,s]),n=s,i=!i}return e}off(t,e){for(const i of this.blinks){if(e<i.t||e>=i.until||!i.parts.includes(t))continue;if(this.phases(i).findIndex(([s,r])=>e>=s&&e<r)%2===1)return i.params.off}}state(t,e){const i=[...this.looks].reverse().find(l=>l.t<=e)??this.looks[0],n=i?.parts.find(l=>l.sourceId===t),r=(n?i:this.looks.find(l=>l.t>e&&l.parts.some(h=>h.sourceId===t))??[...this.looks].reverse().find(l=>l.parts.some(h=>h.sourceId===t)))?.parts.find(l=>l.sourceId===t);if(!r)return;const a=!n||this.vanishAt!==void 0&&e>=this.vanishAt,c=a?void 0:this.off(t,e);return this.path?{sourceId:t,shape:this.onPath(r,e,c,a)}:{sourceId:t,shape:Is.shape(r,this.geometry(e),c,a)}}onPath(t,e,i,n){const s=this.path,r=this.sighting.observerTrack.getInterpolatedPoseAt(e)??this.sighting.observerTrack.getLatestPoseAt(e),a=r?.headingDeg??0,c=r?.pitchDeg??0,l=this.motion,h=S=>Se.toScreen(s.at(S),a,c),u=(S,A)=>{const R=Math.hypot(A[0]-S[0],A[1]-S[1])||1;return[(A[0]-S[0])/R,(A[1]-S[1])/R]};let d=h(e),[f,p]=u(h(e-Is.MOTION_MS),h(e+Is.MOTION_MS));const g=s.sizeAt(e),m=Math.tan(l.sidewaysAt(e,g)*Math.PI/180);d=[d[0]-m*p,d[1]+m*f];const M=l.spiralAt(e);if(M){const S=l.spiralAt(e+Is.SPIRAL_AHEAD_MS),A=h(e),R=h(e+Is.SPIRAL_AHEAD_MS);d=[d[0]+M[0],d[1]+M[1]],[f,p]=u([A[0]+M[0],A[1]+M[1]],[R[0]+S[0],R[1]+S[1]])}const v=l.acrossShareAt(e),x={...t,heightShare:(t.heightShare??t.widthShare)*v,...t.upShare===void 0?{}:{upShare:t.upShare*v}},y=Math.tan(g*(x.alongShare??0)*Math.PI/180),w=Math.tan(g*(x.upShare??0)*Math.PI/180),b=Se.fromScreen(d[0]+y*f-w*p,d[1]+y*p+w*f,a,c),E=Is.shape(x,{...b,sizeDeg:g},i,n,!0);return E.angle=Math.atan2(-p,f),E}geometry(t){const e=this.stand.params,i=this.sighting.observerTrack.getInterpolatedPoseAt(t)??this.sighting.observerTrack.getLatestPoseAt(t),n=i?.lat!==void 0&&i.lng!==void 0?{lat:i.lat,lng:i.lng}:this.sighting.event.place?.[0]??e.place;return Is.seenFrom(e,n,t)}static seenFrom(t,e,i){const n=(t.place.lng-e.lng)*Math.PI/180*Is.R*Math.cos(e.lat*Math.PI/180),s=(t.place.lat-e.lat)*Math.PI/180*Is.R,r=Math.hypot(n,s),a=ci.linear(t.metres.map(({t:l,widthM:h,step:u})=>({t:l,value:h,step:u})),i),c=ci.linear(t.metres.map(({t:l,heightM:h,step:u})=>({t:l,value:h,step:u})),i);return{azimuthDeg:(Math.atan2(n,s)*180/Math.PI%360+360)%360,altitudeDeg:Math.atan2(c,r)*180/Math.PI,sizeDeg:2*Math.atan(a/(2*r))*180/Math.PI}}static shape(t,e,i,n,s=!1){const r=e.sizeDeg,a=Math.max(t.minWidthDeg??0,r*t.widthShare),c=t.kind==="oval"&&t.heightShare===void 0?a:Math.max(t.minHeightDeg??0,r*(t.heightShare??t.widthShare)),l=s?e.altitudeDeg:e.altitudeDeg+r*(t.upShare??0),h=s?e.azimuthDeg:e.azimuthDeg+r*(t.alongShare??0)/Math.cos(l*Math.PI/180),u=(p,g)=>Math.round(p*10**g)/10**g,d=t.kind==="polygon"?{kind:"polygon",bounds:{x:300,y:170,width:100,height:100*c/a},points:(t.points??[]).map(p=>({x:u(p.x*100,2),y:u(p.y*100*c/a,2)}))}:{kind:"oval",bounds:{x:320,y:180,width:2,height:2}};Object.assign(d,{color:i?.color??t.color,angle:0,transparency:n?1:i?.transparency??t.transparency??0,haloScale:t.halo??0,selected:!1,...t.blur===void 0?{}:{blur:t.blur},...t.title===void 0?{}:{title:t.title},angular:{widthDeg:u(a,4),heightDeg:u(c,4)},aim:{azimuthDeg:u((h%360+360)%360,3),altitudeDeg:u(l,3)}});const f=i&&"brightness"in i?i.brightness:t.brightness;return f!=null&&(d.brightness=n?0:f),d}}class Oe{static STANDING_EYE_M=1.6;static METERS_PER_DEGREE=111320;static expand(t){Oe.expandBodies(t),Oe.expandObserver(t),Oe.expandFlights(t),Oe.expandDecorLights(t),Oe.expandPhenomenon(t)}static expandDecorLights(t){for(const e of t.decor){if(!e.lights?.length||e.lights.some(s=>s.keyframes?.length))continue;const i=(t.events??[]).filter(s=>Rd.partOf(s.who,e.id)!==void 0);if(i.length===0)continue;const n=JSON.stringify(e.lights);e.lights=new Rd(e,i,Oe.endOf(t)).lights(),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.decorLights={...t.eventsExpansion.decorLights,[e.id]:{stated:n,expanded:JSON.stringify(e.lights)}}}}static writtenLights(t,e,i){const n=t.eventsExpansion?.decorLights?.[e];return n&&JSON.stringify(i)===n.expanded?JSON.parse(n.stated):i}static expandPhenomenon(t){if(t.timeline.allKeyframes.length>0)return;const e=Oe.stands(t);for(const i of e){const n=Ps.within(t,i.who),s=(t.events??[]).filter(a=>a.who!==void 0&&n.has(a.who)),r=new Is(t,i,s,i.until??Oe.endOf(t)).timeline();for(const a of Wd.fromJSON(r).allKeyframes)t.timeline.addKeyframe(a.t,a.shapes)}e.length!==0&&(Mh.timeline(t.timeline),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.timelinePending=!0)}static stands(t){return(t.events??[]).filter(e=>(e.eventType==="stand"||e.eventType==="travel")&&Ps.isPhenomenon(t,e))}static shapesOf(t){const{groups:e,...i}=t.timeline.toJSON();return JSON.stringify(i)}static timelineWithoutShapes(t){const e=t.timeline.toJSON().groups??[];return e.length>0?{keyframes:[],groups:e}:{keyframes:[]}}static settle(t){t.eventsExpansion?.timelinePending&&(mn.toAngular(t),mn.toAim(t),t.eventsExpansion.timeline=Oe.shapesOf(t),t.eventsExpansion.timelinePending=!1)}static timelineIsExpanded(t){return t.eventsExpansion?.timeline!==void 0&&t.eventsExpansion.timeline===Oe.shapesOf(t)}static expandFlights(t){const e=t.observerTrack.allKeyframes[0]?.pose??t.event.place?.[0];if(e?.lat===void 0||e.lng===void 0)return;const i=Math.cos(e.lat*Math.PI/180);for(const n of t.events??[]){if(n.eventType!=="fly"||n.who===void 0)continue;const s=t.decor.find(g=>g.id===n.who);if(!s||s.track?.length)continue;const r=n.params,a=n.until??Oe.endOf(t),c=r.headingDeg*Math.PI/180,l=(r.from.lng-e.lng)*Math.PI/180*Oe.R*i,h=(r.from.lat-e.lat)*Math.PI/180*Oe.R,u=r.speeds.map(({t:g,kmh:m,step:M})=>({t:g,value:m/3.6,step:M})),d=r.heights.map(({t:g,altitudeM:m,step:M})=>({t:g,value:m,step:M})),f=g=>{const m=Math.sign(g-r.at.t)*Oe.FLY_STEP_MS;let M=0;for(let v=r.at.t;m!==0&&(m>0?v<g:v>g);v+=m){const x=m>0?Math.min(g,v+m):Math.max(g,v+m);M+=(ci.linear(u,v)+ci.linear(u,x))/2*(x-v)/1e3}return M},p=[];for(let g=n.t;g<=a;g+=ci.SAMPLE_MS){const m=r.at.metresBefore-f(g);p.push({t:g,eastM:l-Math.sin(c)*m,northM:h-Math.cos(c)*m,altitudeM:ci.linear(d,g),headingDeg:r.headingDeg})}s.track=p,s.eastM=p[0].eastM,s.northM=p[0].northM,s.headingDeg=r.headingDeg,t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.decorTracks[s.id]=JSON.stringify(p)}}static R=63710088e-1;static FLY_STEP_MS=100;static expandObserver(t){const e=(t.events??[]).filter(g=>Ps.isObserver(t,g)),i=e.find(g=>g.eventType==="drive"),n=e.find(g=>g.eventType==="lookAhead");if(t.observerTrack.allKeyframes.length>0)return;if(!i){new Eo(t,e).keyframes().length>0&&(Mh.observer(t.observerTrack),t.eventsExpansion={...t.eventsExpansion,observerTrack:JSON.stringify(t.observerTrack.toJSON()),decorTracks:t.eventsExpansion?.decorTracks??{}});return}if(!n)return;const s=i.until??Oe.endOf(t),r=i.params,a=new ci(r,i.t,s),c=e.find(g=>g.eventType==="lean"),l=e.find(g=>g.eventType==="watch"),u=new ti(a,r.eye,n.params,c&&{t:c.t,params:c.params},l&&{t:l.t,params:l.params},g=>{const m=Oe.stands(t).find(v=>v.eventType==="stand");if(!m)return Oe.phenomenonPitchAt(t,g);const M=a.stateAt(g);return Is.seenFrom(m.params,{lat:M.lat,lng:M.lng},g).altitudeDeg}).poses(i.t,s),d=u.map(g=>({t:g.t,pose:{lat:g.lat,lng:g.lng,elevationM:g.eye.y-Oe.STANDING_EYE_M,headingDeg:g.headingDeg,pitchDeg:g.pitchDeg,fovDeg:r.fovDeg??60}}));for(const g of d)t.observerTrack.addKeyframe(g.t,g.pose);Mh.observer(t.observerTrack);const f={observerTrack:JSON.stringify(t.observerTrack.toJSON()),decorTracks:{}},p=r.vehicle===void 0?void 0:t.decor.find(g=>g.id===r.vehicle);if(p&&!p.track?.length){const g=u[0],m=v=>Math.cos(v*Math.PI/180),M=u.map(v=>{const x=v.roadDeg*Math.PI/180,y=-v.eye.z,w=v.eye.x,b=(v.lng-g.lng)*Oe.METERS_PER_DEGREE*m(v.lat),E=(v.lat-g.lat)*Oe.METERS_PER_DEGREE;return{t:v.t,eastM:b-y*Math.sin(x)-w*Math.cos(x),northM:E-y*Math.cos(x)+w*Math.sin(x),altitudeM:0,headingDeg:v.roadDeg}});p.track=M,p.eastM=M[0].eastM,p.northM=M[0].northM,p.headingDeg=M[0].headingDeg,f.decorTracks[p.id]=JSON.stringify(M)}t.eventsExpansion={...t.eventsExpansion,...f}}static expandBodies(t){const e=t.interpretation?.bodies??[],i=n=>(t.events??[]).some(s=>s.who===n.id&&s.eventType==="ride");for(const n of[...e.filter(s=>!i(s)),...e.filter(i)]){const s=(t.events??[]).filter(h=>h.who===n.id||Ho.partOf(h.who,n.id)!==void 0);if(s.length===0)continue;const r=Math.min(...s.map(h=>h.t));if(n.track.some(h=>h.t>r))continue;const a=JSON.stringify(n.track),c=s.find(h=>h.eventType==="ride"),l=c&&e.find(h=>h.id===c.params.in);n.track=c?l?Ho.ride(n,c,l):n.track:new Ho(n,s,Oe.endOf(t),t.sampleMs).track(),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.bodies={...t.eventsExpansion.bodies,[n.id]:{stated:a,expanded:JSON.stringify(n.track)}}}}static writtenInterpretation(t,e){const i=t.eventsExpansion?.bodies;return!e||!i?e:{...e,bodies:e.bodies.map(n=>{const s=i[n.id];return s&&JSON.stringify(n.track)===s.expanded?{...n,track:JSON.parse(s.stated)}:n})}}static refresh(t){const e=t.observerTrack.allKeyframes.length===0||Oe.observerTrackIsExpanded(t),i=t.timeline.allKeyframes.length===0||Oe.timelineIsExpanded(t);Oe.again(t,e,i)}static reset(t){Oe.again(t,!0,Oe.stands(t).length>0)}static again(t,e,i){for(const s of t.interpretation?.bodies??[]){const r=t.eventsExpansion?.bodies?.[s.id];r&&JSON.stringify(s.track)===r.expanded&&(s.track=JSON.parse(r.stated))}for(const s of t.decor)s.lights&&(s.lights=Oe.writtenLights(t,s.id,s.lights));if(e){for(const s of Object.keys(t.eventsExpansion?.decorTracks??{})){const r=t.decor.find(a=>a.id===s);r&&delete r.track}t.observerTrack.clear()}const n=t.timeline.toJSON().groups??[];if(i){for(const s of[...t.timeline.sourceIds])t.timeline.removeSource(s);t.timeline.setGroups(n,!1)}t.eventsExpansion=void 0,Oe.expand(t),i&&t.timeline.pruneGroups(),i&&(mn.toBounds(t),mn.toPosition(t)),Oe.settle(t)}static bodiesAreExpanded(t){const e=t.eventsExpansion?.bodies??{};return(t.interpretation?.bodies??[]).every(i=>!e[i.id]||JSON.stringify(i.track)===e[i.id].expanded)}static observerTrackIsExpanded(t){return t.eventsExpansion?.observerTrack!==void 0&&t.eventsExpansion.observerTrack===JSON.stringify(t.observerTrack.toJSON())}static decorTrackIsExpanded(t,e,i){const n=t.eventsExpansion?.decorTracks[e];return n!==void 0&&n===JSON.stringify(i)}static phenomenonPitchAt(t,e){let i;for(const n of t.timeline.sourceIds){const s=t.timeline.getInterpolatedShapeAt(e,n),r=s?.aim?.altitudeDeg;if(!s||s.transparency>=1||r===void 0)continue;const a=(s.angular?.widthDeg??0)*(s.angular?.heightDeg??0);(!i||a>i.area)&&(i={area:a,altitude:r})}return i?.altitude??0}static endOf(t){return t.event.durationSeconds!==void 0?t.event.durationSeconds*1e3:Math.max(...(t.events??[]).map(e=>e.until??e.t))}}function vb(o){return lr.restore(yb(o),o.provenance)}function yb(o,t=!1){return mn.toAngular(o),mn.toAim(o),{version:4,id:o.id,time:K0.write(o.event.time),endTime:K0.write(o.event.endTime),durationSeconds:o.event.durationSeconds,durationText:o.event.durationText,utcOffsetHours:o.event.utcOffsetHours,timeZone:o.event.timeZone,place:wb.write(o.event.place),observer:o.observer,account:o.account,sources:o.sources?.length?o.sources:void 0,sway:o.sway,vehicle:o.vehicle,description:o.event.description,image:o.event.image,summary:o.event.summary,summaryTime:o.event.summaryTime,tags:o.event.tags,timeline:!t&&Oe.timelineIsExpanded(o)?Oe.timelineWithoutShapes(o):o.timeline.toJSON(),observerTrack:!t&&Oe.observerTrackIsExpanded(o)?void 0:Qn.restatedObserverTrack(o),events:o.events?.length?o.events:void 0,weatherTrack:o.weatherTrack.toJSON(),soundTrack:o.soundTrack.toJSON(),weather:o.weather,decor:Qn.restatedDecor(o).map(e=>{if(!t&&e.lights&&(e={...e,lights:Oe.writtenLights(o,e.id,e.lights)}),t||!Oe.decorTrackIsExpanded(o,e.id,e.track))return e;const{track:i,...n}=e;return n}),milestones:o.milestones.length>0?o.milestones:void 0,references:o.references.length>0?o.references:void 0,roads:o.roads.length>0?o.roads:void 0,traces:o.traces.length>0?o.traces:void 0,weatherSource:o.weatherSource,instrument:o.instrumentId,exposureSeconds:o.exposureSeconds,iso:o.iso,film:o.film,metering:o.metering,sampleMs:o.sampleMs,lens:o.lens,lighting:o.lighting,lightPollution:o.lightPollution,observerMap:o.observerMap,interpretation:t?Qn.restatedInterpretation(o):Oe.writtenInterpretation(o,Qn.restatedInterpretation(o)),variants:o.variants.length>0?o.variants:void 0,skyEvents:Yr.written(o.skyEvents),skySources:o.skySources===!1?!1:void 0,snapshots:o.snapshots,modules:o.modules?.length?o.modules:void 0}}function O_(o){return o.observer?.id??"observer"}function xb(o){const t=ra.check(o,"sighting"),{recording:e,provenance:i}=lr.strip(t),n=N_(e);return n.provenance=i,n}function N_(o){const t=[],e=new Lp({eventType:"sighting",time:K0.read(o.time),endTime:K0.read(o.endTime),durationSeconds:o.durationSeconds,durationText:o.durationText,utcOffsetHours:o.utcOffsetHours,timeZone:o.timeZone,place:wb.read(o.place),description:o.description,image:o.image,summary:o.summary,summaryTime:o.summaryTime,tags:o.tags},Wd.fromJSON(o.timeline,t,!1),o.observerTrack?rd.fromJSON(o.observerTrack):new rd,o.weatherTrack?ad.fromJSON(o.weatherTrack):new ad,o.soundTrack?od.fromJSON(o.soundTrack):new od,o.observer&&{id:o.observer.id,title:o.observer.title,lastName:o.observer.lastName,firstNames:o.observer.firstNames},o.id,o.weather,(o.decor??[]).map(n=>{if(!n.facade?.plain)return n;const{plain:s,...r}=n.facade;return{...n,facade:{...r,openings:"plain"}}}),o.weatherSource,o.instrument,o.exposureSeconds??o.observerTrack?.keyframes.map(n=>n.pose.exposureSeconds).find(n=>n!==void 0),Lu(o.milestones??[]),o.references??[],o.roads??[],o.traces??[]);e.account=o.account,e.sources=o.sources,e.sway=o.sway,e.iso=o.iso,e.film=o.film,e.metering=o.metering,e.sampleMs=o.sampleMs,e.lens=o.lens,e.lighting=o.lighting,e.lightPollution=o.lightPollution,e.observerMap=o.observerMap,e.vehicle=o.vehicle,e.events=o.events?.map(n=>n.who===void 0?{...n,who:O_(o)}:n);const i=Yr.read(o.skyEvents,o.interpretation);return e.interpretation=i.interpretation,e.variants=Array.isArray(o.variants)?o.variants:[],e.skyEvents=i.skyEvents,e.skySources=o.skySources===!1?!1:void 0,e.snapshots=o.snapshots,e.modules=Array.isArray(o.modules)?o.modules.filter(n=>typeof n=="string"):void 0,e.loadIssues=t,Oe.expand(e),e.timeline.pruneGroups(),mn.toBounds(e),mn.toPosition(e),Oe.settle(e),e}class K0{static read(t){return t===void 0||t.trim()===""?void 0:v_(t)}static write(t){if(t===void 0)return;const e=y_(t);return e===""?void 0:e}}class wb{static read(t){if(t?.locations?.length)return t.locations.map(({lat:e,lng:i})=>({lat:e,lng:i,...t.name===void 0?{}:{name:t.name}}))}static write(t){if(!t?.length)return;const e=t.find(i=>i.name)?.name;return{...e===void 0?{}:{name:e},locations:t.map(({lat:i,lng:n})=>({lat:i,lng:n}))}}}const L_=Object.freeze(Object.defineProperty({__proto__:null,fromSightingJson:xb,plainSightingJson:yb,toSightingJson:vb},Symbol.toStringTag,{value:"Module"}));class Id{static EN={"unknown-key":"{path}: unknown key, ignored","wrong-type":"{path}: expected {expected}, found {found}","not-in-list":"{path}: {found} is not one of {expected}","out-of-range":"{path}: {found} is outside {expected}",defaulted:"{path}: missing, {expected} used",unplaced:"{path}: no aim (and no bounds), drawn at the middle of the view",unsized:"{path}: no angular size (and no bounds), drawn one pixel wide","pixels-over-angles":"{path}: bounds restated without aim or angular, so the shape follows the pixels"};static text(t,e=Id.EN){return e[t.kind].replace("{path}",t.path).replace("{expected}",t.expected??"").replace("{found}",t.found??"")}static warn(t,e){if(t.length===0)return;const i=t.map(n=>` ${Id.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
|
|
1933
1933
|
${i.join(`
|
|
1934
1934
|
`)}`)}}class rr{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!rr.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:rr.typeOf(t)});return}for(const[s,r]of Object.entries(t)){const a=i?`${i}.${s}`:s,c=e[s];c?this.field(r,c,a,n):n.push({kind:"unknown-key",path:a})}}field(t,e,i,n){if(rr.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):rr.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:rr.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,r)=>{const a=rr.isStated(s)?s.value:s;this.object(a,e.fields,`${i}.${r}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:rr.typeOf(t)});return;default:typeof t!==e.type?n.push({kind:"wrong-type",path:i,expected:e.type,found:rr.typeOf(t)}):typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&n.push({kind:"out-of-range",path:i,expected:`${e.minimum??"−∞"}–${e.maximum??"∞"}`,found:String(t)})}}static STATED_KEYS=new Set(["value","basis","rationale","how","range","source"]);static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return rr.isObject(t)&&"value"in t&&Object.keys(t).every(e=>rr.STATED_KEYS.has(e))}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class ts{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const r=s>0?ts.travelDegOver(t,e,i,i+n*1e3)/s/ts.PIXELS_PER_INSTANT:0,a=ts.flashesOver(t,n)*ts.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,a));return c<2?1:Math.min(ts.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const r of t){if(!r.track||r.track.length<2)continue;const a=ts.directionAt(r,e,i),c=ts.directionAt(r,e,n),l=Math.min(1,Math.max(-1,a.x*c.x+a.y*c.y+a.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=da(t,i),s=n.eastM,r=n.altitudeM-e,a=n.northM,c=Math.hypot(s,r,a);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:a/c}}static bodyInstants(t,e,i,n,s){if(!(n>i)||!(s>0))return 1;let r=0;for(const c of t){const l=ts.bodyAt(c,i),h=ts.bodyAt(c,n);if(!l||!h)continue;const u={x:l.eastM,y:l.upM-e,z:l.northM},d={x:h.eastM,y:h.upM-e,z:h.northM},f=Math.hypot(u.x,u.y,u.z),p=Math.hypot(d.x,d.y,d.z);if(f===0||p===0)continue;const g=Math.min(1,Math.max(-1,(u.x*d.x+u.y*d.y+u.z*d.z)/f/p));let m=Math.acos(g)*180/Math.PI,M=0;for(const v of Object.keys(h.motions))M=Math.max(M,Math.abs(h.motions[v]-(l.motions[v]??h.motions[v])));M>0&&(m+=M*2*(h.halfWidthM/Math.max(p,.001))*180/Math.PI),r=Math.max(r,m)}const a=Math.ceil(r/s/ts.PIXELS_PER_INSTANT);return a<2?1:Math.min(ts.MAX_INSTANTS,a)}static bodyAt(t,e){const i=t.track;if(i.length===0||e<i[0].t||e>i[i.length-1].t)return;let n=0,s=i.length-1;for(;s-n>1;){const d=n+s>>1;i[d].t<=e?n=d:s=d}const r=i[n],a=i[s];if(r.eastM===void 0||r.northM===void 0||a.eastM===void 0||a.northM===void 0)return;const c=a.t>r.t?(e-r.t)/(a.t-r.t):0,l=(d,f)=>d+(f-d)*c,h={};for(const d of Object.keys(a.motions??{})){const f=r.motions?.[d],p=a.motions[d];h[d]=f===void 0?p:l(f,p)}const u=i.find(d=>d.sizeM)?.sizeM?.widthM??1;return{eastM:l(r.eastM,a.eastM),northM:l(r.northM,a.northM),upM:l(r.altitudeM??0,a.altitudeM??0),halfWidthM:u/2,motions:h}}}function A0(o,t){for(const e of o){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class Do{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}Nt.register(Nn,()=>new Ac);Nt.register(Ph,()=>new mh);Nt.register(Ir,()=>new jM);Nt.register(Oh,()=>new gh);Nt.register(cd,()=>new QM);Nt.register(Nh,()=>new fd);Nt.register(Ch,()=>new dd);Nt.register(Lh,()=>new pd);Nt.register(qo,()=>new kh);Nt.register(Dh,()=>new ud);Nt.register(Ls,()=>new Fi);Nt.register(Fo,()=>new Md);Nt.register(pn,()=>new _c);Nt.register(Uo,()=>new vd);Nt.register(ld,()=>new tv);Nt.register(zo,()=>new yd);Nt.register(ko,()=>new gd);Nt.register(Bo,()=>new xd);Nt.register(Gc,()=>new wd);Nt.register(Lo,()=>new md);Nt.register(ys,()=>new je);Nt.register(Xa,()=>new Ed);Nt.register(fn,()=>new ie);Nt.register(Ya,()=>new Ad);Nt.register(hd,()=>new Np);Nt.register(Ka,()=>new Td);Nt.register(Wa,()=>new bd);Nt.register($a,()=>new _d);Nt.register(X0,()=>new f_);Nt.register(Va,()=>new Sd);class Tr{constructor(t){this.preferences=t}read(t){var e,i;if(t===void 0)return;if(typeof t=="string")return t===""?void 0:t;for(const s of this.preferences){const r=(e=t[s])!==null&&e!==void 0?e:t[Tr.base(s)];if(r)return r}const n=new Set(this.preferences.map(s=>Tr.base(s)));for(const[s,r]of Object.entries(t))if(r&&n.has(Tr.base(s)))return r;return(i=Object.values(t).find(s=>s))!==null&&i!==void 0?i:void 0}write(t,e,i){var n,s;const r=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return r;const a={...t},c=(s=(n=Object.keys(a).find(l=>l===i))!==null&&n!==void 0?n:Object.keys(a).find(l=>Tr.base(l)===Tr.base(i)))!==null&&s!==void 0?s:i;return r===void 0?delete a[c]:a[c]=r,Object.keys(a).length===0?void 0:a}static base(t){return t.toLowerCase().split("-")[0]}}Tr.any=new Tr([]);var A2;(function(o){o.abductee="abductee",o.actor="actor",o.artist="artist",o.anthropologist="anthropologist",o.archeologist="archeologist",o.astronaut="astronaut",o.astronomer="astronomer",o.astrologist="astrologist",o.astrophysicist="astrophysicist",o.banker="banker",o.barman="barman",o.biologist="biologist",o.biochemist="biochemist",o.biophysicist="biophysicist",o.bishop="bishop",o.businessman="businessman",o.botanist="botanist",o.cameraman="cameraman",o.chemist="chemist",o.contactee="contactee",o.cryptozoologist="cryptozoologist",o.dentist="dentist",o.director="director",o.diplomat="diplomat",o.diver="diver",o.electronics="electronics",o.engineer="engineer",o.ethnologist="ethnologist",o.exobiologist="exobiologist",o.farmer="farmer",o.firefighter="firefighter",o.flightAttendant="flightAttendant",o.geologist="geologist",o.geophysicist="geophysicist",o.geographer="geographer",o.historian="historian",o.houseWife="houseWife",o.hypnotherapist="hypnotherapist",o.illusionist="illusionist",o.journalist="journalist",o.judge="judge",o.lawyer="lawyer",o.leader="leader",o.librarian="librarian",o.logger="logger",o.mathematician="mathematician",o.mechanic="mechanic",o.meteorologist="meteorologist",o.military="military",o.musician="musician",o.neurologist="neurologist",o.neuroscientist="neuroscientist",o.neuropsychiatrist="neuropsychiatrist",o.nurse="nurse",o.oceanographer="oceanographer",o.painter="painter",o.parapsychologist="parapsychologist",o.philosopher="philosopher",o.photographer="photographer",o.physician="physician",o.physicist="physicist",o.pilot="pilot",o.politician="politician",o.policeman="policeman",o.priest="priest",o.producer="producer",o.prospector="prospector",o.psychologist="psychologist",o.psychiatrist="psychiatrist",o.radioastronomer="radioastronomer",o.radioamateur="radioamateur",o.salesman="salesman",o.sailor="sailor",o.sociologist="sociologist",o.softwareEngineer="softwareEngineer",o.stuntman="stuntman",o.taxiDriver="taxiDriver",o.teacher="teacher",o.telegrapher="telegrapher",o.truckDriver="truckDriver",o.ufologist="ufologist",o.ufoWitness="ufoWitness",o.ufoWitness2="ufoWitness2",o.worker="worker",o.writer="writer"})(A2||(A2={}));var _2;(function(o){o.neutral="neutral",o.male="male",o.female="female"})(_2||(_2={}));class k_ extends Error{constructor(t,e){super(t),this.cause=e}}class iv extends k_{constructor(t=iv.defaultMessage,e){super(t,e)}}iv.defaultMessage="Assertion failed";var T2;(function(o){o.country="country",o.region="region",o.department="department",o.city="city",o.company="company"})(T2||(T2={}));var R2;(function(o){o.at="at",o.au="au",o.ar="ar",o.be="be",o.br="br",o.ca="ca",o.ch="ch",o.cn="cn",o.cl="cl",o.co="co",o.cy="cy",o.de="de",o.dk="dk",o.do="do",o.dz="dz",o.gr="gr",o.ec="ec",o.eg="eg",o.es="es",o.fi="fi",o.fr="fr",o.ga="ga",o.ge="ge",o.hu="hu",o.in="in",o.ie="ie",o.ir="ir",o.il="il",o.it="it",o.jp="jp",o.kr="kr",o.ma="ma",o.mx="mx",o.my="my",o.mz="mz",o.nl="nl",o.no="no",o.nz="nz",o.pa="pa",o.pe="pe",o.ph="ph",o.pl="pl",o.pt="pt",o.ro="ro",o.ru="ru",o.sc="sc",o.tr="tr",o.ua="ua",o.uk="uk",o.us="us",o.sa="sa",o.se="se",o.su="su",o.tn="tn",o.tw="tw",o.ve="ve",o.za="za"})(R2||(R2={}));const F_=["en","fr","es","it"];class Qs{static catalog(t){const e=new Map;return{load(i){const n=Qs.languageOf(i);let s=e.get(n);return s||(s=t[n](),e.set(n,s),s.catch(()=>e.delete(n))),s}}}static none(){return new Proxy({},{get:()=>""})}static blank(){const t=new Proxy(()=>t,{get:(e,i)=>i===Symbol.toPrimitive?()=>"":i===Symbol.iterator?function*(){}:i==="toString"||i==="valueOf"?()=>"":i==="then"?void 0:t,apply:()=>t,has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return t}static languageOf(t){const e=t.toLowerCase().split("-")[0];return F_.includes(e)?e:"en"}}const _0=["en","fr","es","it"],U_={en:()=>xt(()=>import("./UfoMessages_en-BzK4iS9N.js"),[],import.meta.url).then(o=>o.ufoMessages_en),fr:()=>xt(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(o=>o.ufoMessages_fr),es:()=>xt(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(o=>o.ufoMessages_es),it:()=>xt(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(o=>o.ufoMessages_it)},z_=Qs.catalog(U_),B_=Qs.catalog({en:()=>xt(()=>import("./SceneNames_en-BLm2h3zy.js"),[],import.meta.url).then(o=>o.sceneNames_en),fr:()=>xt(()=>import("./SceneNames_fr-CddH0oWD.js"),[],import.meta.url).then(o=>o.sceneNames_fr),es:()=>xt(()=>import("./SceneNames_es-DrJ24RvP.js"),[],import.meta.url).then(o=>o.sceneNames_es),it:()=>xt(()=>import("./SceneNames_it-DL3AbXlk.js"),[],import.meta.url).then(o=>o.sceneNames_it)});function H_(o){return B_.load(o)}const Sb=Math.PI/180,G_=180/Math.PI,V_=256,bb=19,W_=1.25;function Eb(o,t){return 156543.03392*Math.cos(o*Sb)/2**t}function Ab(o,t){return Eb(o,t)*V_}function X_(o,t){let e=0;for(;e<bb&&Ab(o,e+1)>=t;)e++;return e}function nv(o,t){return Ab(o,t)}function _b(o,t){const e=t*W_;let i=0;for(;i<bb&&Eb(o,i)>e;)i++;return i}function T0(o){const t=o*Sb;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function Tb(o,t,e){const i=2**e;return{x:(o+180)/360*i,y:T0(t)*i}}function Rb(o,t,e){const i=T0(o.north),n=T0(o.south);return{x:(t-o.west)/(o.east-o.west),y:(T0(e)-i)/(n-i)}}function Y_(o,t,e){const{x:i,y:n}=Tb(o,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function K_(o){const t=2**o.z,e=o.x/t*360-180,i=(o.x+1)/t*360-180,n=I2(o.y,t);return{south:I2(o.y+1,t),north:n,west:e,east:i}}function I2(o,t){const e=o/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*G_}function Ib(o,t,e,i){const n=Y_(o,t,e),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:e});const a=r.map(K_),c={south:Math.min(...a.map(l=>l.south)),north:Math.max(...a.map(l=>l.north)),west:Math.min(...a.map(l=>l.west)),east:Math.max(...a.map(l=>l.east))};return{tiles:r,bounds:c}}const $_="#2ec4ff";class vc{constructor(t){this.ctx=t}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(t,e){let i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-t,s.y-e);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),this.paintTraces(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=Rb(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintTraces(t){const{ctx:e}=this;for(const i of t.traces??[]){const n=i.points.map(r=>this.toCanvas(t.bounds,r.lat,r.lng));if(n.length===0)continue;const s=i.color??$_;if(i.kind==="point")e.beginPath(),e.moveTo(n[0].x,n[0].y-6),e.lineTo(n[0].x+6,n[0].y),e.lineTo(n[0].x,n[0].y+6),e.lineTo(n[0].x-6,n[0].y),e.closePath(),e.fillStyle=s,e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.8)",e.stroke();else{e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const r of n.slice(1))e.lineTo(r.x,r.y);i.kind==="polygon"&&e.closePath(),e.lineJoin="round",e.setLineDash([]),e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=4.5,e.stroke(),e.setLineDash([9,5]),e.strokeStyle=s,e.lineWidth=2.5,e.stroke(),e.setLineDash([])}if(i.label){e.font="11px sans-serif",e.textAlign="left",e.textBaseline="middle";let r=n[0];if(i.kind==="line"&&t.position){const a=this.toCanvas(t.bounds,t.position.lat,t.position.lng);r=n.reduce((c,l)=>Math.hypot(l.x-a.x,l.y-a.y)>Math.hypot(c.x-a.x,c.y-a.y)?l:c)}this.paintOutlinedText(i.label,r.x+9,r.y-9)}}}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),a=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,a,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,a);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)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:vc.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,vc.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(r=>{if(!r.current)return!1;const a=ae(r.lat,r.lng,e.lat,e.lng);return Math.hypot(a.x,a.z)<=vc.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?vc.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(t.south+t.north)/2,c=Math.abs(ae(r,t.east,r,t.west).x)/this.width,l=vc.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>e?(i.push(n),n=s):n=r}return n&&i.push(n),i}}class gi{static MIN_ZOOM=.25;static MAX_ZOOM=64;static MIN_SPAN_M=400;static MARGIN=.6;static IMAGERY_PX=768;static fitted(t,e){return gi.including(t.boundsAround(gi.MIN_SPAN_M,gi.MARGIN),e)}zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(gi.MAX_ZOOM,Math.max(gi.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,r=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=r-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=gi.mercatorY01(e.north),s=gi.mercatorY01(e.south),r=gi.mercatorY01(i.north),a=gi.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((r+a)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=gi.mercatorY01(n.north),r=gi.mercatorY01(n.south),a=(e.lng-n.west)/(n.east-n.west),c=(gi.mercatorY01(e.lat)-s)/(r-s);return a>=i&&a<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-a,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=gi.mercatorY01(t.north),n=gi.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:gi.latitudeAt(i+(this.centerY-e)*(n-i)),south:gi.latitudeAt(i+(this.centerY+e)*(n-i))}}static including(t,e,i=3){const n=(t.north+t.south)/2,s=(t.east+t.west)/2,r=ae(n,t.east,n,s).x;let a=r;for(const c of e){const{x:l,z:h}=ae(c.lat,c.lng,n,s),u=Math.max(Math.abs(l),Math.abs(h));u<=r*i&&(a=Math.max(a,u*1.15))}return a<=r?t:{north:ks(0,-a,n,s).lat,south:ks(0,a,n,s).lat,east:ks(a,0,n,s).lng,west:ks(-a,0,n,s).lng}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=gi.mercatorY01(t.north),s=gi.mercatorY01(t.south);return{lat:gi.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const er=256,q_=3,Z_=129,J_=7,j_=32768;class Db{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(ae(i,t.east,i,t.west).x),r=Math.abs(ae(t.north,n,t.south,n).z),a=Math.max(s,r);let c=X_(i,a),l=q_;if(e.width>=Z_){const g=M=>2*Math.ceil((a/nv(i,M)+1)/2)+1;let m=_b(i,a/(e.width-1)/2);for(;m>c&&g(m)>J_;)m--;m>c&&(c=m,l=g(m))}const{tiles:h}=Ib(n,i,c,l),u=l*er,d=new Float32Array(u*u),f=h[0];await Promise.all(h.map(g=>this.decodeTileInto(g,f,d,u)));const p=new Float32Array(e.width*e.height);for(let g=0;g<e.height;g++){const m=t.north+(t.south-t.north)*(g/(e.height-1));for(let M=0;M<e.width;M++){const v=t.west+(t.east-t.west)*(M/(e.width-1));p[g*e.width+M]=this.sampleAt(m,v,c,f,d,u)}}return{heights:p,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const a=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=er,c.height=er;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(a,0,0);const{data:h}=l.getImageData(0,0,er,er),u=(t.x-e.x)*er,d=(t.y-e.y)*er;for(let f=0;f<er;f++)for(let p=0;p<er;p++){const g=(f*er+p)*4,m=h[g]*256+h[g+1]+h[g+2]/256-j_,M=u+p,v=d+f;i[v*n+M]=m}}sampleAt(t,e,i,n,s,r){const{x:a,y:c}=Tb(e,t,i),l=(a-n.x)*er,h=(c-n.y)*er,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),g=l-u,m=h-d,M=s[d*r+u],v=s[d*r+f],x=s[p*r+u],y=s[p*r+f],w=M+(v-M)*g,b=x+(y-x)*g;return w+(b-w)*m}}class kp{constructor(t,e,i,n){this.width=t,this.height=e,this.samples=i,this.values=n}at(t,e,i=0){return this.values[(e*this.width+t)*this.samples+i]}static parse(t){const e=new DataView(t);if(t.byteLength<8||e.getUint16(0)!==18761||e.getUint16(2,!0)!==42)throw new Error("Not a little-endian TIFF");const i=e.getUint32(4,!0),n=e.getUint16(i,!0),s=new Map;for(let M=0;M<n;M++){const v=i+2+M*12;s.set(e.getUint16(v,!0),{type:e.getUint16(v+2,!0),count:e.getUint32(v+4,!0),value:e.getUint32(v+8,!0)})}const r=(M,v)=>{const x=s.get(M);if(x===void 0){if(v===void 0)throw new Error(`TIFF without tag ${M}`);return v}return x.type===3?x.value&65535:x.value},a=M=>{const v=s.get(M);if(v===void 0)throw new Error(`TIFF without tag ${M}`);const x=v.type===3?2:4,y=[];if(v.count*x<=4){const w=new DataView(new ArrayBuffer(4));w.setUint32(0,v.value,!0);for(let b=0;b<v.count;b++)y.push(x===2?w.getUint16(b*2,!0):w.getUint32(0,!0))}else for(let w=0;w<v.count;w++)y.push(x===2?e.getUint16(v.value+w*2,!0):e.getUint32(v.value+w*4,!0));return y};if(r(259,1)!==1)throw new Error("Compressed TIFF");if(s.has(322))throw new Error("Tiled TIFF");const c=r(256),l=r(257),h=r(277,1),u=a(258)[0],d=r(339,1)===3;if(!(d&&u===32||!d&&u===8))throw new Error(`Unsupported TIFF samples: ${u} bits`);const f=a(273),p=a(279),g=new Uint8Array(c*l*h*(u/8));let m=0;for(let M=0;M<f.length&&m<g.length;M++){const v=Math.min(p[M],g.length-m);g.set(new Uint8Array(t,f[M],v),m),m+=v}if(m<g.length)throw new Error("Truncated TIFF");return new kp(c,l,h,d?new Float32Array(g.buffer):g)}}class co extends Error{constructor(t,e){super(e),this.reason=t,this.name="SurroundingsUnavailableError"}}class Q_{constructor(t,e,i,n,s){this.heights=t,this.plants=e,this.buildings=i,this.size=n,this.metresPerPixel=s}structureAt(t,e){const i=Math.floor(t/this.metresPerPixel+this.size/2),n=Math.floor(this.size/2-e/this.metresPerPixel);if(i<0||n<0||i>=this.size||n>=this.size)return;const s=n*this.size+i;if(!(this.plants[s]||this.buildings[s]))return this.heights[s]}tallestStructureNear(t,e,i){let n;const s=Math.ceil(i/this.metresPerPixel);for(let r=-s;r<=s;r++)for(let a=-s;a<=s;a++){if(Math.hypot(a,r)*this.metresPerPixel>i)continue;const c=this.structureAt(t+a*this.metresPerPixel,e+r*this.metresPerPixel);c!==void 0&&(n===void 0||c>n)&&(n=c)}return n}}class Fe{static covers(t,e){return t>=41.2&&t<=51.3&&e>=-5.4&&e<=9.8}static WMS="https://data.geopf.fr/wms-r/wms";static WFS="https://data.geopf.fr/wfs/ows";static HEIGHT_LAYER="IGNF_LIDAR-HD_MNH_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static PHOTO_LAYER="ORTHOIMAGERY.ORTHOPHOTOS";static MAX_PHOTO_PIXELS=1e3;static METRES_PER_PIXEL=.5;static MAX_RADIUS_M=3e3;static MAX_LIDAR_RADIUS_M=150;static NO_DATA=-9999;static METRES_PER_DEGREE=111320;fetchImpl;wms;wfs;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??Fe.WMS,this.wfs=t.wfsEndpoint??Fe.WFS}static radius(t){return Math.min(t,Fe.MAX_RADIUS_M)}static lidarRadius(t){return Math.min(t,Fe.MAX_LIDAR_RADIUS_M)}async lidar(t,e){const i=Fe.lidarRadius(e),n=Math.ceil(2*i/Fe.METRES_PER_PIXEL),[s,r]=await Promise.all([this.raster(t,i,n,Fe.HEIGHT_LAYER),this.raster(t,i,n,Fe.CLASS_LAYER)]);if(s.samples!==1||r.samples<3)throw new co("unreachable","The survey answered in a layout this does not read");const a=s.values;if(a.every(u=>u===Fe.NO_DATA))throw new co("no-coverage","No LiDAR HD survey here yet");const c=new Uint8Array(n*n),l=new Uint8Array(n*n);for(let u=0;u<n*n;u++){const d=r.values[u*r.samples],f=r.values[u*r.samples+1],p=r.values[u*r.samples+2];c[u]=f>d&&f>p?1:0,l[u]=d>120&&f<90&&p<90?1:0}const h=2*i/n;return{size:n,metresPerPixel:h,heights:a,vegetation:c,building:l,structures:new Q_(a,c,l,n,h)}}async laserDate(t){return Fe.latest(await this.dated("IGNF_LIDAR-HD_METADONNEE:metadata","geom","date_fin_acquisition",t))}async photoDate(t){return Fe.latest(await this.dated("ORTHOIMAGERY.ORTHOPHOTOS.GRAPHE-MOSAIQUAGE:graphe_bdortho","geom","date_vol",t))}static latest(t){return t.map(i=>/^\d{4}-\d{2}-\d{2}/.exec(String(i??""))?.[0]).filter(i=>i!==void 0).sort().at(-1)}async dated(t,e,i,n){const r=[n.lng-1e-4,n.lat-1e-4,n.lng+1e-4,n.lat+1e-4].map(a=>a.toFixed(6)).join(",");try{return(await this.features(t,`BBOX(${e},${r},'EPSG:4326')`,i,20)).map(a=>a.properties[i])}catch{return[]}}async photo(t,e){const i=Fe.radius(e),n=Math.min(Fe.MAX_PHOTO_PIXELS,Math.ceil(2*i/Fe.METRES_PER_PIXEL)),s=await this.raster(t,i,n,Fe.PHOTO_LAYER);if(s.samples<3)throw new co("unreachable","The photograph came in a layout this does not read");return{size:n,metresPerPixel:2*i/n,samples:s.samples,values:s.values}}async vectors(t,e,i){const n=Fe.radius(e),s=n/Fe.METRES_PER_DEGREE,r=n/(Fe.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),c=`BBOX(geometrie,${[t.lng-r,t.lat-s,t.lng+r,t.lat+s].map(M=>M.toFixed(6)).join(",")},'EPSG:4326')`,[l,h,u,d,f,p]=await Promise.all([this.features("construction_lineaire",`${c} AND nature='Pont'`,"nature,geometrie"),this.features("troncon_de_route",`${c} AND position_par_rapport_au_sol>'0'`,"nature,largeur_de_chaussee,position_par_rapport_au_sol,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie"),this.features("troncon_de_voie_ferree",`${c} AND position_par_rapport_au_sol>'0'`,"position_par_rapport_au_sol,geometrie").catch(()=>[]),this.features("ligne_electrique",c,"voltage,geometrie"),i?this.features("batiment",c,Fe.BUILDING_PROPERTIES,5e3):Promise.resolve([]),i?this.features("zone_d_activite_ou_d_interet",c,"toponyme,categorie,geometrie",100).catch(()=>[]):Promise.resolve([])]),g=i?await this.wholeWorship(p,f,[t.lng-r,t.lat-s,t.lng+r,t.lat+s]):[],m=[...f,...g];return{bridges:l,elevatedRoads:h,elevatedRailways:u,lines:d,buildings:m,zones:p,mapDate:Fe.latest(m.map(M=>M.properties.date_modification))}}static BUILDING_PROPERTIES="cleabs,nature,usage_1,hauteur,nombre_d_etages,materiaux_des_murs,materiaux_de_la_toiture,date_d_apparition,date_modification,geometrie";static MAX_WHOLE_M=300;async wholeWorship(t,e,i){const[n,s,r,a]=i,c=Fe.MAX_WHOLE_M/Fe.METRES_PER_DEGREE;let l;for(const u of t){if(u.properties.categorie!=="Religieux")continue;const[d,f,p,g]=Fe.extent(u);if(d>=n&&f>=s&&p<=r&&g<=a)continue;const m=[Math.max(d,n-c),Math.max(f,s-c),Math.min(p,r+c),Math.min(g,a+c)];l=l?[Math.min(l[0],m[0]),Math.min(l[1],m[1]),Math.max(l[2],m[2]),Math.max(l[3],m[3])]:m}if(!l)return[];const h=new Set(e.map(u=>u.properties.cleabs));try{return(await this.features("batiment",`BBOX(geometrie,${l.map(d=>d.toFixed(6)).join(",")},'EPSG:4326')`,Fe.BUILDING_PROPERTIES,1e3)).filter(d=>!h.has(d.properties.cleabs))}catch{return[]}}static extent(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;const r=a=>{Array.isArray(a)&&typeof a[0]=="number"?(e=Math.min(e,a[0]),n=Math.max(n,a[0]),i=Math.min(i,a[1]),s=Math.max(s,a[1])):Array.isArray(a)&&a.forEach(r)};return r(t.geometry.coordinates),[e,i,n,s]}async elevatedRoadLines(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(s=>s.toFixed(6)).join(",")},'EPSG:4326')`,i=await this.features("troncon_de_route",`${e} AND position_par_rapport_au_sol>'0'`,"geometrie",300),n=[];for(const s of i){const{type:r,coordinates:a}=s.geometry,c=r==="LineString"?[a]:r==="MultiLineString"?a:[];for(const l of c)n.push(l.map(h=>({lat:h[1],lng:h[0]})))}return n}async waterSurfaces(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("surface_hydrographique",`${e} AND position_par_rapport_au_sol='0' AND persistance='Permanent'`,"cleabs,nature,geometrie",500)}async roads(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_route",`${e} AND nature<>'Sentier' AND nature<>'Escalier' AND position_par_rapport_au_sol>='0'`,"cleabs,nature,largeur_de_chaussee,nombre_de_voies,sens_de_circulation,vitesse_moyenne_vl,urbain,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie",3e3)}async railways(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_voie_ferree",`${e} AND etat_de_l_objet='En service'`,"cleabs,nature,electrifie,largeur,nombre_de_voies,position_par_rapport_au_sol,cpx_toponyme,geometrie",3e3)}async raster(t,e,i,n){const s=e/Fe.METRES_PER_DEGREE,r=e/(Fe.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),a=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:n,STYLES:"",CRS:"EPSG:4326",BBOX:[t.lat-s,t.lng-r,t.lat+s,t.lng+r].map(l=>l.toFixed(6)).join(","),WIDTH:String(i),HEIGHT:String(i),FORMAT:"image/geotiff"});let c;try{c=await this.fetchImpl(`${this.wms}?${a}`)}catch(l){throw new co("unreachable",l instanceof Error?l.message:String(l))}if(!c.ok)throw new co("unreachable",`The survey answered ${c.status}`);try{return kp.parse(await c.arrayBuffer())}catch(l){throw new co("unreachable",l instanceof Error?l.message:String(l))}}async features(t,e,i,n=200){const s=new URLSearchParams({SERVICE:"WFS",VERSION:"2.0.0",REQUEST:"GetFeature",TYPENAMES:t.includes(":")?t:`BDTOPO_V3:${t}`,SRSNAME:"EPSG:4326",OUTPUTFORMAT:"application/json",COUNT:String(n),CQL_FILTER:e,PROPERTYNAME:i});let r;try{r=await this.fetchImpl(`${this.wfs}?${s}`)}catch(c){throw new co("unreachable",c instanceof Error?c.message:String(c))}if(!r.ok)throw new co("unreachable",`The map answered ${r.status}`);return(await r.json()).features??[]}}class Ao{static NEAR_M=15;static ALIGNED_DEG=30;static LONG_ENOUGH_M=15;static SAMPLE_M=5;static follows(t,e){if(t.length<2||e.length<2)return!1;const i=e[0],n=e.map(a=>ae(a.lat,a.lng,i.lat,i.lng)),s=t.map(a=>ae(a.lat,a.lng,i.lat,i.lng));let r=0;for(let a=0;a<s.length-1;a++){const c=s[a],l=s[a+1],h=Math.hypot(l.x-c.x,l.z-c.z);if(h<1e-6)continue;const u=Math.max(1,Math.ceil(h/Ao.SAMPLE_M)),d=Math.atan2(l.x-c.x,-(l.z-c.z));for(let f=0;f<=u;f++){const p=f/u,g=Ao.nearest(n,c.x+(l.x-c.x)*p,c.z+(l.z-c.z)*p);g.distanceM>Ao.NEAR_M||Ao.angleBetween(d,g.heading)<=Ao.ALIGNED_DEG&&(r+=h/u)}}return r>=Ao.LONG_ENOUGH_M}static nearest(t,e,i){let n={distanceM:1/0,heading:0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.z-r.z,h=c*c+l*l,u=h<1e-9?0:Math.max(0,Math.min(1,((e-r.x)*c+(i-r.z)*l)/h)),d=Math.hypot(e-(r.x+c*u),i-(r.z+l*u));d<n.distanceM&&(n={distanceM:d,heading:Math.atan2(c,-l)})}return n}static angleBetween(t,e){const i=Math.abs((t-e)*180/Math.PI%180);return Math.min(i,180-i)}}class Pe{static WMS="https://data.geopf.fr/wms-r/wms";static LAYERS=["IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93","ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES"];static METRES_PER_PIXEL=4;static METRES_PER_DEGREE=111320;static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static SURFACE_LAYER="IGNF_LIDAR-HD_MNS_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static DECK=[240,240,0];static NO_CLASS=[0,0,0];static DECK_END_PIXELS=3;static DECK_HALF_WIDTH_M=8;static DECK_APPROACH_M=10;static DECK_STRAIGHT_MAX_M=200;static MIN_PIXELS=8;static MAX_PIXELS=700;static NO_DATA_BELOW=-100;static COARSE_METRES_PER_PIXEL=20;static MESH_FROM_VERTICES=33;static FINE_SPACING_M=7;static MAX_SEGMENTS=256;static MAX_HOLE_SHARE=.05;static DEFAULT_TIMEOUT_MS=12e3;static MAX_WINDOW_M=50;fetchImpl;wms;timeoutMs;maxWindowM;geoplatform;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??Pe.WMS,this.timeoutMs=t.timeoutMs??Pe.DEFAULT_TIMEOUT_MS,this.maxWindowM=t.maxWindowM??Pe.MAX_WINDOW_M,this.geoplatform=new Fe({fetchImpl:this.fetchImpl,wmsEndpoint:this.wms,wfsEndpoint:t.wfsEndpoint})}async getElevationGrid(t,e,i){const n={lat:(t.south+t.north)/2,lng:(t.west+t.east)/2};if(!Fe.covers(n.lat,n.lng))throw new Error("The IGN's relief covers France only");const s=Math.abs(ae(n.lat,t.east,n.lat,t.west).x),r=Math.abs(ae(t.north,n.lng,t.south,n.lng).z);e=this.finer(e,s,r);const a={x:s/Math.max(1,e.width-1),y:r/Math.max(1,e.height-1)},c={x:Math.min(a.x,this.maxWindowM),y:Math.min(a.y,this.maxWindowM)},l={south:t.south-c.y/Pe.METRES_PER_DEGREE,north:t.north+c.y/Pe.METRES_PER_DEGREE,west:t.west-c.x/(Pe.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180)),east:t.east+c.x/(Pe.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180))},h=g=>Math.min(Pe.MAX_PIXELS,Math.max(Pe.MIN_PIXELS,Math.ceil(g/Pe.METRES_PER_PIXEL))),u={width:h(s+2*c.x),height:h(r+2*c.y)},d={x:(s+2*c.x)/u.width,y:(r+2*c.y)/u.height};let f=new Error("No layer of the IGN's relief answered");const p=Math.max(d.x,d.y)>Pe.COARSE_METRES_PER_PIXEL;for(const g of p?[...Pe.LAYERS].reverse():Pe.LAYERS)try{const m=await this.heights(l,u,g);g===Pe.LAYERS[0]&&await this.layBridgeDecks(m,l,u,i?.route);const M=this.sample(m,e,t,l,d,a);if(M)return{heights:M,width:e.width,height:e.height,bounds:t};f=new Error(`${g} does not cover this place`)}catch(m){f=m}throw f}finer(t,e,i){if(t.width<Pe.MESH_FROM_VERTICES||t.height<Pe.MESH_FROM_VERTICES)return t;const n=(s,r)=>{const a=Math.ceil(s/Pe.FINE_SPACING_M),c=Math.max(r-1,Math.min(Pe.MAX_SEGMENTS,a));return c%2===0?c:c+1};return{width:n(e,t.width)+1,height:n(i,t.height)+1}}async raster(t,e,i){const n=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:i,STYLES:"",CRS:"EPSG:4326",BBOX:[t.south,t.west,t.north,t.east].map(r=>r.toFixed(6)).join(","),WIDTH:String(e.width),HEIGHT:String(e.height),FORMAT:"image/geotiff"}),s=await this.fetchImpl(`${this.wms}?${n}`,{signal:AbortSignal.timeout(this.timeoutMs)});if(!s.ok)throw new Error(`The IGN's relief answered ${s.status}`);return kp.parse(await s.arrayBuffer())}async heights(t,e,i){const n=await this.raster(t,e,i);if(n.samples!==1||!(n.values instanceof Float32Array))throw new Error("The IGN's relief came in a layout this does not read");return n}async layBridgeDecks(t,e,i,n){if(!(!n||n.length<2)&&!(!(t.values instanceof Float32Array)||!t.values.some(s=>s>Pe.NO_DATA_BELOW)))try{const s=(await this.geoplatform.elevatedRoadLines({west:e.west,south:e.south,east:e.east,north:e.north})).filter(a=>Ao.follows(n,a));if(s.length===0)return;const r=Float32Array.from(t.values);await this.layClassifiedDecks(t,e,i,s),this.layRouteDecks(t,r,e,s)}catch{}}async layClassifiedDecks(t,e,i,n){try{const s=await this.raster(e,i,Pe.CLASS_LAYER);if(s.samples<3||s.width!==t.width||s.height!==t.height)return;const r=(m,[M,v,x])=>s.values[m*s.samples]===M&&s.values[m*s.samples+1]===v&&s.values[m*s.samples+2]===x,a=t.width,c=t.height,l=new Uint8Array(a*c);let h=!1;for(let m=0;m<l.length;m++)r(m,Pe.DECK)&&(l[m]=1,h=!0);if(!h)return;const u=Pe.DECK_END_PIXELS,d=[];for(let m=0;m<l.length;m++){if(l[m]!==1)continue;const M=m%a,v=(m-M)/a;for(let x=-u;x<=u;x++)for(let y=-u;y<=u;y++){const w=M+y,b=v+x;if(w<0||b<0||w>=a||b>=c)continue;const E=b*a+w;l[E]===0&&r(E,Pe.NO_CLASS)&&d.push(E)}}for(const m of d)l[m]=1;const f=this.paint(n,e,a,c),p=this.touching(l,f,a,c);if(p.every(m=>m===0))return;const g=await this.heights(e,i,Pe.SURFACE_LAYER);if(g.width!==a||g.height!==c)return;for(let m=0;m<p.length;m++){if(p[m]===0)continue;const M=g.values[m];Number.isFinite(M)&&M>Pe.NO_DATA_BELOW&&M>t.values[m]&&(t.values[m]=M)}}catch{}}layRouteDecks(t,e,i,n){const{width:s,height:r}=t,a=(i.north+i.south)/2,c=(i.east-i.west)*Pe.METRES_PER_DEGREE*Math.cos(a*Math.PI/180),l=(i.north-i.south)*Pe.METRES_PER_DEGREE,h=c/s,u=l/r,d=M=>({x:(M.lng-i.west)/(i.east-i.west)*c,y:(i.north-M.lat)/(i.north-i.south)*l}),f=(M,v)=>{const x=Math.floor(M/h),y=Math.floor(v/u);if(x<0||y<0||x>=s||y>=r)return;const w=e[y*s+x];return Number.isFinite(w)&&w>Pe.NO_DATA_BELOW?w:void 0},p=Pe.DECK_HALF_WIDTH_M,g=Pe.DECK_APPROACH_M,m=(M,v)=>{const x=Math.hypot(M.x-v.x,M.y-v.y)||1,y={x:(M.x-v.x)/x,y:(M.y-v.y)/x},w=[0,g/2,g].map(b=>f(M.x+y.x*b,M.y+y.y*b)).filter(b=>b!==void 0);return w.length>0?Math.max(...w):void 0};for(const M of Pe.chains(n.map(v=>v.map(d)))){const v=[0];for(let I=1;I<M.length;I++)v.push(v[I-1]+Math.hypot(M[I].x-M[I-1].x,M[I].y-M[I-1].y));const x=v[v.length-1];if(x<1||x>Pe.DECK_STRAIGHT_MAX_M)continue;const y=m(M[0],M[1]),w=m(M[M.length-1],M[M.length-2]);if(y===void 0||w===void 0)continue;const b=p+g,E=Math.max(0,Math.floor((Math.min(...M.map(I=>I.x))-b)/h)),S=Math.min(s-1,Math.ceil((Math.max(...M.map(I=>I.x))+b)/h)),A=Math.max(0,Math.floor((Math.min(...M.map(I=>I.y))-b)/u)),R=Math.min(r-1,Math.ceil((Math.max(...M.map(I=>I.y))+b)/u));for(let I=A;I<=R;I++)for(let D=E;D<=S;D++){const P=Pe.nearestAlong(M,v,{x:(D+.5)*h,y:(I+.5)*u});if(P.distance>p||P.s<-g||P.s>x+g)continue;const L=y+(w-y)*Math.min(1,Math.max(0,P.s/x)),O=I*s+D;e[O]>=L||(t.values[O]=L)}}}static chains(t){const e=t.filter(s=>s.length>=2).map(s=>[...s]),i=[],n=(s,r)=>Math.hypot(s.x-r.x,s.y-r.y)<=1;for(;e.length>0;){let s=e.shift(),r=!0;for(;r;){r=!1;for(let a=0;a<e.length;a++){const c=e[a],l=s[0],h=s[s.length-1];if(n(h,c[0]))s=[...s,...c.slice(1)];else if(n(h,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else if(n(l,c[c.length-1]))s=[...c.slice(0,-1),...s];else if(n(l,c[0]))s=[...[...c].reverse().slice(0,-1),...s];else continue;e.splice(a,1),r=!0;break}}i.push(s)}return i}static nearestAlong(t,e,i){let n={s:0,distance:1/0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.y-r.y,h=c*c+l*l;if(h<1e-9)continue;let u=((i.x-r.x)*c+(i.y-r.y)*l)/h;s>0&&(u=Math.max(0,u)),s<t.length-2&&(u=Math.min(1,u));const d=Math.hypot(i.x-(r.x+c*u),i.y-(r.y+l*u));d<n.distance&&(n={s:e[s]+u*Math.sqrt(h),distance:d})}return n}paint(t,e,i,n){const s=new Uint8Array(i*n),r=c=>(c-e.west)/(e.east-e.west)*i,a=c=>(e.north-c)/(e.north-e.south)*n;for(const c of t)for(let l=0;l<c.length-1;l++){const h=r(c[l].lng),u=a(c[l].lat),d=r(c[l+1].lng),f=a(c[l+1].lat),p=Math.max(1,Math.ceil(Math.hypot(d-h,f-u)*2));for(let g=0;g<=p;g++){const m=Math.floor(h+(d-h)*g/p),M=Math.floor(u+(f-u)*g/p);for(let v=-1;v<=1;v++)for(let x=-1;x<=1;x++){const y=m+x,w=M+v;y>=0&&w>=0&&y<i&&w<n&&(s[w*i+y]=1)}}}return s}touching(t,e,i,n){const s=new Uint8Array(t.length),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++){if(t[a]===0||r[a]===1)continue;const c=[],l=[a];r[a]=1;let h=!1;for(;l.length>0;){const u=l.pop();c.push(u),e[u]===1&&(h=!0);const d=u%i,f=(u-d)/i;for(let p=-1;p<=1;p++)for(let g=-1;g<=1;g++){const m=d+g,M=f+p;if(m<0||M<0||m>=i||M>=n)continue;const v=M*i+m;t[v]===1&&r[v]===0&&(r[v]=1,l.push(v))}}if(h)for(const u of c)s[u]=1}return s}sample(t,e,i,n,s,r){const{width:a,height:c}=e,l=new Float32Array(a*c),h=new Uint8Array(a*c),u=Math.min(r.x,this.maxWindowM)/s.x,d=Math.min(r.y,this.maxWindowM)/s.y;let f=0;for(let p=0;p<c;p++){const g=i.north+(i.south-i.north)*(c===1?.5:p/(c-1)),m=(n.north-g)/(n.north-n.south)*t.height-.5;for(let M=0;M<a;M++){const x=(i.west+(i.east-i.west)*(a===1?.5:M/(a-1))-n.west)/(n.east-n.west)*t.width-.5,y=u>1||d>1?this.tent(t,x,m,Math.max(1,u),Math.max(1,d)):this.bilinear(t,x,m),w=p*a+M;y===void 0?f++:(l[w]=y,h[w]=1)}}if(!(f===a*c||f/(a*c)>Pe.MAX_HOLE_SHARE))return this.fill(l,h,a,c),l}tent(t,e,i,n,s){let r=0,a=0,c=0;const l=Math.max(0,Math.ceil(i-s)),h=Math.min(t.height-1,Math.floor(i+s)),u=Math.max(0,Math.ceil(e-n)),d=Math.min(t.width-1,Math.floor(e+n));for(let f=l;f<=h;f++){const p=1-Math.abs(f-i)/s;if(!(p<=0))for(let g=u;g<=d;g++){const m=p*(1-Math.abs(g-e)/n);if(m<=0)continue;c+=m;const M=t.at(g,f);!Number.isFinite(M)||M<Pe.NO_DATA_BELOW||(r+=m*M,a+=m)}}return c>0&&a>=c*.5?r/a:void 0}bilinear(t,e,i){const n=Math.max(0,Math.min(t.width-1,Math.floor(e))),s=Math.max(0,Math.min(t.height-1,Math.floor(i))),r=Math.min(t.width-1,n+1),a=Math.min(t.height-1,s+1),c=Math.max(0,Math.min(1,e-n)),l=Math.max(0,Math.min(1,i-s)),h=t.at(n,s),u=t.at(r,s),d=t.at(n,a),f=t.at(r,a);for(const m of[h,u,d,f])if(!Number.isFinite(m)||m<Pe.NO_DATA_BELOW)return;const p=h+(u-h)*c,g=d+(f-d)*c;return p+(g-p)*l}fill(t,e,i,n){let s=e.reduce((r,a)=>r+(a?0:1),0);for(;s>0;){const r=[];for(let a=0;a<n;a++)for(let c=0;c<i;c++){const l=a*i+c;if(e[l])continue;let h=0,u=0;for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const p=a+d,g=c+f;p<0||g<0||p>=n||g>=i||!e[p*i+g]||(h+=t[p*i+g],u++)}u>0&&r.push([l,h/u])}if(r.length===0)return;for(const[a,c]of r)t[a]=c,e[a]=1;s-=r.length}}}class t5{providers;constructor(...t){this.providers=t}async getElevationGrid(t,e,i){let n=new Error("No source of relief to ask");for(const s of this.providers)try{return await s.getElevationGrid(t,e,i)}catch(r){n=r}throw n}}const R0=256,e5=5;async function Cb(o,t,e,i){const n=(o.south+o.north)/2,s=(o.west+o.east)/2,r=Math.abs(ae(n,o.east,n,o.west).x),a=Math.abs(ae(o.north,s,o.south,s).z),c=Math.max(r,a),{zoom:l,gridSize:h}=i5(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=Ib(s,n,l,h),f=h*R0,p=document.createElement("canvas");p.width=f,p.height=f;const g=p.getContext("2d");if(!g)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async y=>{const w=e(y),b=await i(w);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${w}`);const E=await createImageBitmap(await b.blob());g.drawImage(E,(y.x-m.x)*R0,(y.y-m.y)*R0)}));const M=Math.min(Math.max(t.width,t.height),f);if(M===f)return{source:p,width:f,height:f,bounds:d};const v=document.createElement("canvas");v.width=M,v.height=M;const x=v.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(p,0,0,f,f,0,0,M,M),{source:v,width:M,height:M,bounds:d}}function i5(o,t,e){let i=_b(o,t/Math.max(1,e)),n=D2(o,i,t);for(;n>e5&&i>0;)i--,n=D2(o,i,t);return{zoom:i,gridSize:n,mPerPixel:nv(o,i)/R0}}function D2(o,t,e){const i=Math.ceil(e/2/nv(o,t));return Math.max(3,2*i+1)}class Pb{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return Cb(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Os{static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];static FRANCE_ENDPOINT="https://overpass.openstreetmap.fr/api/interpreter";static FRANCE={south:41.3,west:-5.2,north:51.1,east:9.6};static endpointsFor(t,e=Os.ENDPOINTS){const i=/\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/.exec(t);if(!i)return[...e];const[n,s,r,a]=i.slice(1).map(Number),c=(n+r)/2,l=(s+a)/2,h=Os.FRANCE;return c>=h.south&&c<=h.north&&l>=h.west&&l<=h.east?[Os.FRANCE_ENDPOINT,...e.filter(d=>d!==Os.FRANCE_ENDPOINT)]:[...e]}fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints}static queue=Promise.resolve();static HANG_MS=4e4;static RETRY_MS=4e3;query(t){return this.queued(()=>this.ask(t))}queued(t){const e=Os.queue.then(t,t);return Os.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints??Os.endpointsFor(t))for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(Os.HANG_MS)});if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Os.RETRY_MS))}throw e??new Error("No Overpass instance answered")}}class _o{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;client;constructor(t={}){this.client=new Os(t)}async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${_o.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.client.query(i))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:_o.surfaceOf(s),widthM:_o.widthOf(s),..._o.paintOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return e}static paintOf(t){const e=t.highway??"",i=t.junction==="roundabout"||t.junction==="circular",n=t.oneway,s=n==="yes"||n==="1"||n==="true"||n===void 0&&(e==="motorway"||i),r=n==="-1"||n==="reverse",a=Number.parseInt(t.lanes??"",10),c=Number.parseInt(t.maxspeed??"",10),l=i?"roundabout":e==="motorway"?"motorway":e.endsWith("_link")?"slip":(e==="trunk"||e==="primary")&&(s||r)?"dual":e?"road":void 0;return{...l?{kind:l}:{},...Number.isFinite(a)&&a>0?{lanes:a}:{},...n!==void 0||e==="motorway"||i?{direction:r?"backward":s?"forward":"both"}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{}}}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:_o.WIDTH_M[t.highway]??_o.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const gm="https://ufoathome.org/roads/index.json";class $l{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??$l.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1935
|
-
`);let e=$l.shared.get(t);return e||(e=this.fetchFirstAvailable(),$l.shared.set(t,e),e.then(i=>{i.length===0&&$l.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.
|
|
1936
|
-
`);let e=ql.shared.get(t);return e||(e=this.fetchFirstAvailable(),ql.shared.set(t,e),e.then(i=>{i.length===0&&ql.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.0")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==Mm?[e,Mm]:[Mm]).map(i=>i+t)}}class As{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=As.key(t);let i=As.asked.get(e);return i===void 0&&(i=this.recalled(e,t),As.asked.set(e,i),i.catch(()=>As.asked.delete(e))),structuredClone(await i)}static forget(){As.asked.clear()}static key(t){return`v${As.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await As.openCache(),n=As.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<As.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&As.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-As.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(As.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class Po{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>Po.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=Po.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=Po.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=Po.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const g=f.map(m=>({lat:m[1],lng:m[0],...m.length>2&&Number.isFinite(m[2])&&m[2]>Po.NO_ALTITUDE?{altitudeM:m[2]}:{}}));return g.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:g}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class Gn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new Os(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${Gn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Gn.ROUTES})$"];out body;`;return Gn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=Gn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(M=>ae(M.lat,M.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(M=>M.service===!!r.service);for(const M of Gn.samples(a)){u++;const v=Gn.waysAt(d,M);if(v.length===0)continue;const[x]=v;x.name&&c.set(x.name,(c.get(x.name)??0)+1),x.voltageV&&l.set(x.voltageV,(l.get(x.voltageV)??0)+1);for(const y of new Set(v.flatMap(w=>w.services)))h.set(y,(h.get(y)??0)+1)}const f=M=>[...M.entries()].sort((v,x)=>x[1]-v[1])[0]?.[0],p=r.name??f(c),g=r.voltageV??(r.electrification==="none"?void 0:f(l)),m=[...h.entries()].filter(([,M])=>M*4>=u).sort((M,v)=>v[1]-M[1]||M[0].localeCompare(v[0])).map(([M])=>M);return{...r,...p?{name:p}:{},...g?{voltageV:g}:{},...m.length>0?{services:m}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=Gn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=Gn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=Gn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>ae(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=Gn.SAMPLE_M/2;a<n;a+=Gn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(Gn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=Gn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class Zl{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new Os(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Zl.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Gn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Gn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=Gn.voltageOf(r),l=Zl.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Zl.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:Zl.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class r5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!Po.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class hn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=hn.key(t);let i=hn.asked.get(e)??hn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},hn.asked.set(e,i),n.catch(()=>hn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){hn.asked.clear(),hn.failedAt=-1/0}static key(t){return`v${hn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of hn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await hn.openCache(),n=hn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<hn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-hn.failedAt<hn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(hn.failedAt=this.now(),s)return s;throw a}return i&&hn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-hn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(hn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const vm="https://ufoathome.org/railways/index.json";class Jl{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Jl.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1937
|
-
`);let e=Jl.shared.get(t);return e||(e=this.fetchFirstAvailable(),Jl.shared.set(t,e),e.then(i=>{i.length===0&&Jl.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.0")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==vm?[e,vm]:[vm]).map(i=>i+t)}}function Ob(){return{elevation:Nb(),imagery:Lb(),roads:a5(),water:o5(),railways:c5()}}function Nb(){return new t5(new Pe,new Db)}function Lb(){return new Pb}function a5(){return new $l({fallback:new n5(new Co,new _o)})}function o5(){return new ql({fallback:new As(new s5(new Dd,new yc))})}function c5(){return new Jl({fallback:new hn(new r5(new Po,new Zl))})}const l5=new Set,vh="show-observer-map",yh="hide-milestones",Tc="minified";class He extends HTMLElement{static get observedAttributes(){return["src",vh,yh,Tc]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new gi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Lp.create();issues=[];issueCheck=0;sightingAudio=new E2;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new E2(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>He.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");He.setIcon(this.moreButton,t?Qt.UNFOLDED:Qt.FOLDED);const e=t?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Qt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await xt(async()=>{const{VideoButton:s}=await import("./VideoButton-Cy_r767Z.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?rf(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<He.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=gi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=gi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},He.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=gi.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${a3}</style>${r3}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Fh(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",a=>{a.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new vc(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.citedMarks=this.shadow.getElementById("cited-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.playerTitleBox=this.shadow.getElementById("player-title"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.tracesButton.addEventListener("click",()=>this.toggleTraces()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>{this.player.seek(this.snapSeekToMark(Number(this.seekInput.value))),this.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.seekPreview.hidden=!0,this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.chromeResizeObserver?.observe(this.chromeCanvas),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===vh&&this.applyObserverMapDefault(),t===yh&&this.setMilestonesShown(!this.hasAttribute(yh)),t===Tc){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(Tc)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(Fb)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await sd.recording(t)}get sightingData(){return vb(this.currentSighting)}set sightingData(t){const e=ra.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=xb(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await xt(async()=>{const{default:r}=await import("./sightingSchema-DjI7FV42.js");return{default:r}},[],import.meta.url);n=new rr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Id.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(u5,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=(this.messages?.recordingIssues??"").replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Id.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}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(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,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}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=De.INTERVIEW,i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<He.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(h5,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}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(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get playbackRate(){return this.player.playbackRate}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),He.setIcon(this.referencesButton,i?Qt.PICTURES_ON:Qt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),He.setIcon(this.tracesButton,this.tracesShownState?Qt.TRACES_ON:Qt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Lu(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=He.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){if(t.buttons!==0){this.seekPreview.hidden=!0;return}const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=He.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?rf(a,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new Fh(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=He.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?rf(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=ts.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<He.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(He.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/He.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/He.EXPOSURE_STEP_PX),s=Math.min(He.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=qi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:l5;this.canvasRenderer.setStarPoints(qi.starPointsOf(this.sighting.instrument,ke(this.sighting,t)?.fNumber));const n=(ke(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?Xs.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(A_(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new __(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*He.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Qt.PLAY:Qt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){He.icons.get(t)!==e&&(He.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(t){this.quietControlsValue=t,this.stageElement.classList.toggle("quiet",t)}tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},He.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),He.setIcon(this.playPauseButton,t?Qt.PAUSE:Qt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages?.pause??"":this.messages?.play??"":this.messages?.noDuration??"";this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.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(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(vh),e=t===null?this.sighting.observerMap??this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;He.setIcon(this.observerMapButton,t?Qt.MAP_ON:Qt.MAP_OFF);const e=t?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=ph.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=gi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?gi.expand(t,He.OBSERVER_MAP_IMAGERY_AHEAD):t,n=gi.IMAGERY_PX*(e?1+2*He.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:Lb();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??s).attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?gi.expand(t,He.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages?.mapImageryUnavailable??"":this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=He.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=ke(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},He.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?rf(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Lu(this.currentSighting.milestones):[]){const a=ke(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?ca.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(qi.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,Lu(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages?.moments??"",He.setIcon(this.milestonesButton,this.milestonesShown?Qt.MILESTONES_ON:Qt.MILESTONES_OFF);const t=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=ke(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=da(i,t),{lat:s,lng:r}=ks(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=ke(this.currentSighting,this.currentTime),s=ca.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return oi.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=He.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),He.setIcon(this.miniMuteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){He.setIcon(this.muteButton,Qt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}He.setIcon(this.muteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;He.setIcon(this.fullscreenButton,t?Qt.EXIT_FULLSCREEN:Qt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Tr(Do.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=A0(Do.preferencesFor(this),_0);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await z_.load(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+e,this.timeEndLabel.title=(this.messages?.duration??"")+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=S_(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?n1(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return lo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?P2(C2(this.realStartMs+i)):lo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?lo(t):lo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return lo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return lo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?lo(this.currentSighting.timeline.duration):this.canShowClockTime?P2(C2(this.realStartMs+this.realDurationMs)):lo(this.realDurationMs)}}function C2(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function P2(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function lo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const r1="rr0-ufo";function kb(){customElements.get(r1)||customElements.define(r1,He)}const h5="timechange",u5="recordingissues",Fb="minifiedreset";/**
|
|
1935
|
+
`);let e=$l.shared.get(t);return e||(e=this.fetchFirstAvailable(),$l.shared.set(t,e),e.then(i=>{i.length===0&&$l.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.1")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==gm?[e,gm]:[gm]).map(i=>i+t)}}class Co{attribution="Roads © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Type autoroutier":{surface:"paved",widthM:11},"Route à 2 chaussées":{surface:"paved",widthM:7},"Route à 1 chaussée":{surface:"paved",widthM:5.5},"Rond-point":{surface:"paved",widthM:6},Bretelle:{surface:"paved",widthM:5},"Route empierrée":{surface:"gravel",widthM:3.5},Chemin:{surface:"dirt",widthM:3},"Piste cyclable":{surface:"paved",widthM:2.5}};static DEFAULT={surface:"paved",widthM:5};static KINDS={"Type autoroutier":"motorway","Route à 2 chaussées":"dual","Route à 1 chaussée":"road","Rond-point":"roundabout",Bretelle:"slip"};static DIRECTIONS={"Double sens":"both","Sens direct":"forward","Sens inverse":"backward"};platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRoads(t){return(await this.platform.roads(t)).flatMap((i,n)=>Co.wayOf(i,n))}static wayOf(t,e){if(t.geometry.type!=="LineString")return[];const i=t.geometry.coordinates.map(([d,f])=>({lat:f,lng:d}));if(i.length<2)return[];const n=String(t.properties.nature??""),s=Co.BY_NATURE[n]??Co.DEFAULT,r=Number(t.properties.largeur_de_chaussee),a=Number(t.properties.nombre_de_voies),c=Number(t.properties.vitesse_moyenne_vl),l=Co.DIRECTIONS[String(t.properties.sens_de_circulation??"")],h=Co.KINDS[n],u=[t.properties.cpx_toponyme_route_nommee,t.properties.nom_voie_ban_gauche,t.properties.nom_voie_ban_droite].find(d=>typeof d=="string"&&d.length>0);return[{id:String(t.properties.cleabs??`ign-${e}`),...u?{name:u}:{},surface:s.surface,widthM:Number.isFinite(r)&&r>0?r:s.widthM,...t.properties.urbain===!0?{urban:!0}:{},...h?{kind:h}:{},...Number.isInteger(a)&&a>0?{lanes:a}:{},...l?{direction:l}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{},points:i}]}}class n5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Roads © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRoads(t){if(Co.covers(t))try{const e=await this.regional.getRoads(t);if(e.length>0)return e}catch{}return this.worldwide.getRoads(t)}}class Dd{attribution="Water © IGN, BD TOPO (Licence Ouverte 2.0)";platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getWater(t){return(await this.platform.waterSurfaces(t)).flatMap((i,n)=>Dd.surfacesOf(i,n))}static surfacesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="Polygon"?[n]:i==="MultiPolygon"?n:[],r=String(t.properties.cleabs??`ign-water-${e}`);return s.flatMap((a,c)=>{const l=a.map(h=>Dd.open(h.map(u=>({lat:u[1],lng:u[0]})))).filter(h=>h.length>=3);return l.length>0?[{id:s.length>1?`${r}-${c}`:r,rings:l}]:[]})}static open(t){const e=t[0],i=t[t.length-1];return t.length>1&&e.lat===i.lat&&e.lng===i.lng?t.slice(0,-1):t}}class yc{attribution="Water © OpenStreetMap contributors";client;constructor(t={}){this.client=new Os(t)}async getWater(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];(way["natural"="water"](${e});way["waterway"="riverbank"](${e});)->.w;(relation["natural"="water"](${e});relation["waterway"="riverbank"](${e});)->.r;.w out geom;.r out body;way(r.r)(${e});out geom;`;return yc.surfacesFrom(await this.client.query(i))}static surfacesFrom(t){const e=t.elements??[],i=new Map;for(const r of e)r.type==="way"&&r.id!==void 0&&r.geometry&&i.set(r.id,r.geometry.map(a=>({lat:a.lat,lng:a.lon})));const n=[],s=new Set;for(const r of e){if(r.type!=="relation")continue;const a=l=>(r.members??[]).filter(h=>h.type==="way"&&h.role===l&&h.ref!==void 0&&i.has(h.ref)).map(h=>(s.add(h.ref),i.get(h.ref))),c=yc.rings(a("inner"));for(const[l,h]of yc.rings(a("outer")).entries()){const u=c.filter(d=>yc.contains(h,d[0]));n.push({id:`osm-r${r.id}-${l}`,rings:[h,...u]})}}for(const r of e)if(!(r.type!=="way"||!r.tags||r.id===void 0||s.has(r.id))&&!(r.tags.natural!=="water"&&r.tags.waterway!=="riverbank"))for(const a of yc.rings([i.get(r.id)??[]]))n.push({id:`osm-w${r.id}`,rings:[a]});return n}static rings(t){const e=(s,r)=>s.lat===r.lat&&s.lng===r.lng,i=t.filter(s=>s.length>=2).map(s=>[...s]),n=[];for(;i.length>0;){let s=i.pop(),r=!0;for(;!e(s[0],s[s.length-1])&&r;){r=!1;for(let a=0;a<i.length;a++){const c=i[a],l=s[s.length-1];if(e(l,c[0]))s=[...s,...c.slice(1)];else if(e(l,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else continue;i.splice(a,1),r=!0;break}}s.length>=4&&e(s[0],s[s.length-1])&&n.push(s.slice(0,-1))}return n}static contains(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const r=t[n],a=t[s];r.lat>e.lat!=a.lat>e.lat&&e.lng<(a.lng-r.lng)*(e.lat-r.lat)/(a.lat-r.lat)+r.lng&&(i=!i)}return i}}class s5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Water © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere";async getWater(t){if(Dd.covers(t))try{const e=await this.regional.getWater(t);if(e.length>0)return e}catch{}return this.worldwide.getWater(t)}}const Mm="https://ufoathome.org/water/index.json";class ql{attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??ql.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Water © OpenStreetMap contributors"}async getWater(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getWater(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.surfaces)?(this.attributionRead=s.attribution,s.surfaces):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1936
|
+
`);let e=ql.shared.get(t);return e||(e=this.fetchFirstAvailable(),ql.shared.set(t,e),e.then(i=>{i.length===0&&ql.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.1")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==Mm?[e,Mm]:[Mm]).map(i=>i+t)}}class As{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=As.key(t);let i=As.asked.get(e);return i===void 0&&(i=this.recalled(e,t),As.asked.set(e,i),i.catch(()=>As.asked.delete(e))),structuredClone(await i)}static forget(){As.asked.clear()}static key(t){return`v${As.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await As.openCache(),n=As.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<As.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&As.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-As.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(As.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class Po{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>Po.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=Po.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=Po.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=Po.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const g=f.map(m=>({lat:m[1],lng:m[0],...m.length>2&&Number.isFinite(m[2])&&m[2]>Po.NO_ALTITUDE?{altitudeM:m[2]}:{}}));return g.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:g}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class Gn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new Os(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${Gn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Gn.ROUTES})$"];out body;`;return Gn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=Gn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(M=>ae(M.lat,M.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(M=>M.service===!!r.service);for(const M of Gn.samples(a)){u++;const v=Gn.waysAt(d,M);if(v.length===0)continue;const[x]=v;x.name&&c.set(x.name,(c.get(x.name)??0)+1),x.voltageV&&l.set(x.voltageV,(l.get(x.voltageV)??0)+1);for(const y of new Set(v.flatMap(w=>w.services)))h.set(y,(h.get(y)??0)+1)}const f=M=>[...M.entries()].sort((v,x)=>x[1]-v[1])[0]?.[0],p=r.name??f(c),g=r.voltageV??(r.electrification==="none"?void 0:f(l)),m=[...h.entries()].filter(([,M])=>M*4>=u).sort((M,v)=>v[1]-M[1]||M[0].localeCompare(v[0])).map(([M])=>M);return{...r,...p?{name:p}:{},...g?{voltageV:g}:{},...m.length>0?{services:m}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=Gn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=Gn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=Gn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>ae(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=Gn.SAMPLE_M/2;a<n;a+=Gn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(Gn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=Gn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class Zl{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new Os(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Zl.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Gn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Gn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=Gn.voltageOf(r),l=Zl.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Zl.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:Zl.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class r5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!Po.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class hn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=hn.key(t);let i=hn.asked.get(e)??hn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},hn.asked.set(e,i),n.catch(()=>hn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){hn.asked.clear(),hn.failedAt=-1/0}static key(t){return`v${hn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of hn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await hn.openCache(),n=hn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<hn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-hn.failedAt<hn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(hn.failedAt=this.now(),s)return s;throw a}return i&&hn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-hn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(hn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const vm="https://ufoathome.org/railways/index.json";class Jl{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Jl.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1937
|
+
`);let e=Jl.shared.get(t);return e||(e=this.fetchFirstAvailable(),Jl.shared.set(t,e),e.then(i=>{i.length===0&&Jl.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.189.1")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==vm?[e,vm]:[vm]).map(i=>i+t)}}function Ob(){return{elevation:Nb(),imagery:Lb(),roads:a5(),water:o5(),railways:c5()}}function Nb(){return new t5(new Pe,new Db)}function Lb(){return new Pb}function a5(){return new $l({fallback:new n5(new Co,new _o)})}function o5(){return new ql({fallback:new As(new s5(new Dd,new yc))})}function c5(){return new Jl({fallback:new hn(new r5(new Po,new Zl))})}const l5=new Set,vh="show-observer-map",yh="hide-milestones",Tc="minified";class He extends HTMLElement{static get observedAttributes(){return["src",vh,yh,Tc]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new gi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Lp.create();issues=[];issueCheck=0;sightingAudio=new E2;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new E2(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>He.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");He.setIcon(this.moreButton,t?Qt.UNFOLDED:Qt.FOLDED);const e=t?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Qt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await xt(async()=>{const{VideoButton:s}=await import("./VideoButton-Cy_r767Z.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?rf(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<He.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=gi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=gi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},He.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=gi.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${a3}</style>${r3}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Fh(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",a=>{a.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new vc(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.citedMarks=this.shadow.getElementById("cited-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.playerTitleBox=this.shadow.getElementById("player-title"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.tracesButton.addEventListener("click",()=>this.toggleTraces()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>{this.player.seek(this.snapSeekToMark(Number(this.seekInput.value))),this.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.seekPreview.hidden=!0,this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.chromeResizeObserver?.observe(this.chromeCanvas),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===vh&&this.applyObserverMapDefault(),t===yh&&this.setMilestonesShown(!this.hasAttribute(yh)),t===Tc){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(Tc)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(Fb)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await sd.recording(t)}get sightingData(){return vb(this.currentSighting)}set sightingData(t){const e=ra.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=xb(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await xt(async()=>{const{default:r}=await import("./sightingSchema-DjI7FV42.js");return{default:r}},[],import.meta.url);n=new rr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Id.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(u5,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=(this.messages?.recordingIssues??"").replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Id.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}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(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,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}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=De.INTERVIEW,i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<He.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(h5,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}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(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get playbackRate(){return this.player.playbackRate}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),He.setIcon(this.referencesButton,i?Qt.PICTURES_ON:Qt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),He.setIcon(this.tracesButton,this.tracesShownState?Qt.TRACES_ON:Qt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Lu(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=He.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){if(t.buttons!==0){this.seekPreview.hidden=!0;return}const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=He.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?rf(a,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new Fh(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=He.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?rf(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=ts.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<He.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(He.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/He.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/He.EXPOSURE_STEP_PX),s=Math.min(He.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=qi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:l5;this.canvasRenderer.setStarPoints(qi.starPointsOf(this.sighting.instrument,ke(this.sighting,t)?.fNumber));const n=(ke(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?Xs.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(A_(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new __(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*He.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Qt.PLAY:Qt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){He.icons.get(t)!==e&&(He.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(t){this.quietControlsValue=t,this.stageElement.classList.toggle("quiet",t)}tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},He.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),He.setIcon(this.playPauseButton,t?Qt.PAUSE:Qt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages?.pause??"":this.messages?.play??"":this.messages?.noDuration??"";this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.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(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(vh),e=t===null?this.sighting.observerMap??this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;He.setIcon(this.observerMapButton,t?Qt.MAP_ON:Qt.MAP_OFF);const e=t?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=ph.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=gi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?gi.expand(t,He.OBSERVER_MAP_IMAGERY_AHEAD):t,n=gi.IMAGERY_PX*(e?1+2*He.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:Lb();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??s).attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?gi.expand(t,He.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages?.mapImageryUnavailable??"":this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=He.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=ke(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},He.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?rf(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Lu(this.currentSighting.milestones):[]){const a=ke(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?ca.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(qi.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,Lu(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages?.moments??"",He.setIcon(this.milestonesButton,this.milestonesShown?Qt.MILESTONES_ON:Qt.MILESTONES_OFF);const t=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=ke(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=da(i,t),{lat:s,lng:r}=ks(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=ke(this.currentSighting,this.currentTime),s=ca.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return oi.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=He.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),He.setIcon(this.miniMuteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){He.setIcon(this.muteButton,Qt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}He.setIcon(this.muteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;He.setIcon(this.fullscreenButton,t?Qt.EXIT_FULLSCREEN:Qt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Tr(Do.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=A0(Do.preferencesFor(this),_0);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await z_.load(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+e,this.timeEndLabel.title=(this.messages?.duration??"")+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=S_(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?n1(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return lo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?P2(C2(this.realStartMs+i)):lo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?lo(t):lo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return lo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return lo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?lo(this.currentSighting.timeline.duration):this.canShowClockTime?P2(C2(this.realStartMs+this.realDurationMs)):lo(this.realDurationMs)}}function C2(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function P2(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function lo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const r1="rr0-ufo";function kb(){customElements.get(r1)||customElements.define(r1,He)}const h5="timechange",u5="recordingissues",Fb="minifiedreset";/**
|
|
1938
1938
|
* @license
|
|
1939
1939
|
* Copyright 2010-2026 Three.js Authors
|
|
1940
1940
|
* SPDX-License-Identifier: MIT
|
|
@@ -8293,7 +8293,7 @@ ${l.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissive
|
|
|
8293
8293
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
8294
8294
|
}
|
|
8295
8295
|
`,transparent:!0,depthWrite:!1,side:Sn,fog:!1,blending:Vc,blendSrc:Wc,blendDst:Cd})}static wallReflectance(t,e,i){const n=i(t,1,e);return 2*n/(1+n)}static DISCS={uDiscDirection:{value:[new _(0,1,0),new _(0,1,0)]},uDiscCosRadius:{value:[2,2]},uDiscRadiance:{value:[new _,new _]}};static DISC_INDEX={sun:0,moon:1};static setDisc(t,e){const i=rs.DISC_INDEX[t],n=rs.DISCS;if(!e){n.uDiscCosRadius.value[i]=2,n.uDiscRadiance.value[i].set(0,0,0);return}n.uDiscDirection.value[i].set(...e.direction).normalize(),n.uDiscCosRadius.value[i]=Math.cos(e.radiusRad),n.uDiscRadiance.value[i].set(...e.radiance)}setSurroundings(t){this.uniforms.uSurroundings.value=t}static reflectedResponse(t,e){return Ht.respond(e*Ht.relativeOfResponse(Math.max(t,1e-5)))}}class Ts{static SIZE=64;static MOVE_M=.01;holder=new Ni;cameras=[];faces=[];target=new qe(Ts.SIZE,Ts.SIZE);white=new ws({color:new at(1,1,1),side:Sn});scene=new Js;cabin;meshes=0;eye=new _;scratch=new _;constructor(){const t=[[new _(1,0,0),new _(0,1,0)],[new _(-1,0,0),new _(0,1,0)],[new _(0,1,0),new _(0,0,1)],[new _(0,-1,0),new _(0,0,-1)],[new _(0,0,1),new _(0,1,0)],[new _(0,0,-1),new _(0,1,0)]];for(const[e,i]of t){const n=new Wn(90,1,.02,20);n.up.copy(i),n.lookAt(e),this.holder.add(n),this.cameras.push(n),this.faces.push(new Uint8Array(Ts.SIZE*Ts.SIZE*4))}this.scene.background=new at(0,0,0)}get any(){return this.cabin!==void 0}update(t,e,i){if(!e){this.forget();return}e.updateWorldMatrix(!0,!0);const n=this.scratch.copy(i);e.worldToLocal(n);let s=0;e.traverse(r=>{r.isMesh&&s++}),!(e===this.cabin&&s===this.meshes&&n.distanceTo(this.eye)<Ts.MOVE_M)&&(this.cabin=e,this.meshes=s,this.eye.copy(n),this.draw(t,e))}hides(t){if(!this.cabin)return!1;this.holder.updateWorldMatrix(!0,!0);for(let e=0;e<6;e++){const i=this.cameras[e],n=this.scratch.copy(t).transformDirection(i.matrixWorldInverse);if(n.z>=0)continue;const s=n.x/-n.z,r=n.y/-n.z;if(Math.abs(s)>1||Math.abs(r)>1)continue;const a=Math.min(Ts.SIZE-1,Math.floor((s+1)/2*Ts.SIZE)),c=Math.min(Ts.SIZE-1,Math.floor((r+1)/2*Ts.SIZE));return this.faces[e][(c*Ts.SIZE+a)*4]>127}return!1}forget(){this.holder.removeFromParent(),this.cabin=void 0,this.meshes=0}dispose(){this.forget(),this.target.dispose(),this.white.dispose()}draw(t,e){e.add(this.holder),this.holder.position.copy(this.eye),this.holder.updateWorldMatrix(!0,!0);const i=[];e.traverse(r=>{const a=r;if(!a.isMesh||!a.visible||(Array.isArray(a.material)?a.material:[a.material]).every(h=>h instanceof rs))return;const l=new ft(a.geometry,this.white);l.matrixAutoUpdate=!1,l.matrix.copy(a.matrixWorld),l.matrixWorld.copy(a.matrixWorld),i.push(l)});for(const r of i)this.scene.add(r);const n=t.getRenderTarget(),s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;for(let r=0;r<6;r++){const a=this.cameras[r];a.updateMatrixWorld(!0),t.setRenderTarget(this.target),t.clear(),t.render(this.scene,a),yp.now(t,this.target,0,0,Ts.SIZE,Ts.SIZE,this.faces[r])}t.setRenderTarget(n),t.shadowMap.autoUpdate=s;for(const r of i)r.removeFromParent()}}const xg="https://ufoathome.org/models/index.json";class Zu{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??J8()}async entries(t){const e=await this.load();return t?e.filter(i=>[i.kind].flat().includes(t)):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){if(this.loading)return this.loading;if(!this.sharing)return this.loading=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
8296
|
-
`);let e=Zu.shared.get(t);return e||(e=this.fetchFirstAvailable(),Zu.shared.set(t,e),e.then(i=>{i.length===0&&Zu.shared.delete(t)})),this.loading=e}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function J8(){const o=`?v=${encodeURIComponent("0.189.
|
|
8296
|
+
`);let e=Zu.shared.get(t);return e||(e=this.fetchFirstAvailable(),Zu.shared.set(t,e),e.then(i=>{i.length===0&&Zu.shared.delete(t)})),this.loading=e}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function J8(){const o=`?v=${encodeURIComponent("0.189.1")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==xg?[t,xg]:[xg]).map(e=>e+o)}const j8=Te.point("decorModels").provide(Te.BUILT_IN,[{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 Zu}]);class bA{constructor(t,e=j8){this.preferredId=t,this.sources=e}attribution="3D models, each under its own author's licence";built=new Map;catalogues(){const t=this.sources.find(i=>i.id===this.preferredId)??this.sources[0];return(t?[t,...this.sources.filter(i=>i!==t)]:[]).map(i=>{let n=this.built.get(i);return n||(n=i.create(),this.built.set(i,n)),n})}entries(t){const e=this.catalogues()[0];return e?e.entries(t):Promise.resolve([])}async entry(t){for(const e of this.catalogues()){const i=await e.entry(t).catch(()=>{});if(i)return i}}async moduleOf(t){const e=Te.point("decorModels");for(const i of this.sources){const n=e.ownerOf(i.id);if(!(n===void 0||n===Te.BUILT_IN)&&await this.catalogueOf(i).entry(t).catch(()=>{}))return n}}catalogueOf(t){return this.catalogues(),this.built.get(t)}}async function wg(o){const{GLTFLoader:t}=await xt(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BmUyASZK.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(o,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${o}: ${s instanceof Error?s.message:String(s)}`)))})}const EA=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"],Il=Math.PI/180,Mu=180/Math.PI;class mi{constructor(t,e){this.timeline=t,this.tolerance=e}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;static lawsOf(t,e){return{direction(i,n,s){const r=t.law({kind:"heading",value:i.azimuthDeg},e),a=Math.abs(((n.azimuthDeg-i.azimuthDeg)%360+540)%360-180),c=t.law({kind:"elevation",value:i.altitudeDeg},e),l=Math.max(mi.DIRECTION_TOLERANCE_DEG,s);return a>(r.high??i.azimuthDeg)-i.azimuthDeg+l||n.altitudeDeg>(c.high??i.altitudeDeg)+l||n.altitudeDeg<(c.low??i.altitudeDeg)-l},size(i,n){const s=t.law({kind:"angularSize",value:i},e);return n<(s.low??i)/mi.SIZE_TOLERANCE||n>(s.high??i)*mi.SIZE_TOLERANCE}}}at(t,e,i,n){const s=[],r=new Map,a=[];for(const c of e){if(c.ensemble&&c.explains.length>0){const l=r.get(c.ensemble);l?l.push(c):r.set(c.ensemble,[c]);continue}a.push({id:c.id,explains:c.explains,predicted:mi.projectionOf(c,i,n?.(c))})}for(const[c,l]of r){const h=l.flatMap(u=>n?.(u)??mi.outlineOf(u));a.push({id:c,explains:l[0].explains,predicted:mi.projectionOf(l[0],i,h)})}for(const c of a){const l=c.predicted;if(l)for(const h of c.explains){const u=this.timeline.getInterpolatedShapeAt(t,h);!u||u.transparency>=1||s.push({...mi.compare(h,c.id,{aim:u.aim,angular:u.angular},l,this.tolerance),title:u.title})}}return s}static compare(t,e,i,n,s){const r=[],a=i.aim?mi.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const u=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;(s?s.direction(i.aim,n.aim,u):a>Math.max(mi.DIRECTION_TOLERANCE_DEG,u))&&r.push("direction")}const c=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,l=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0,h=(u,d)=>s?s.size(d,d*u):!mi.withinSize(u);return c!==void 0&&h(c,i.angular.widthDeg)&&r.push("width"),l!==void 0&&h(l,i.angular.heightDeg)&&r.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:c,heightRatio:l,disagreements:r}}static projectionOf(t,e,i){const n=i&&i.length>0?i:mi.outlineOf(t),s=i&&i.length>0?mi.centreOf(i):t,r=mi.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!r)return;const a=mi.normalized({eastM:r.northM,northM:-r.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=mi.cross(a,r);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-e.eastM,northM:f.northM-e.northM,upM:f.upM-e.upM},g=mi.dot(p,r);if(g<=0)return;const m=Math.atan2(mi.dot(p,a),g),M=Math.atan2(mi.dot(p,c),g);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,M),d=Math.max(d,M)}return{aim:{azimuthDeg:(Math.atan2(r.eastM,r.northM)*Mu+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,r.upM)))*Mu},angular:{widthDeg:(h-l)*Mu,heightDeg:(d-u)*Mu}}}static centreOf(t){const e=i=>(Math.min(...t.map(n=>n[i]))+Math.max(...t.map(n=>n[i])))/2;return{eastM:e("eastM"),northM:e("northM"),upM:e("upM")}}static separationDeg(t,e){const i=t.altitudeDeg*Il,n=e.altitudeDeg*Il,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*Il);return Math.acos(Math.max(-1,Math.min(1,s)))*Mu}static withinSize(t){return t<=mi.SIZE_TOLERANCE&&t>=1/mi.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],r=t.model.url===void 0?t.model.id:void 0;if(r!==void 0&&r!=="box"&&EA.includes(r))for(let u=0;u<=mi.RINGS;u++){const d=u/mi.RINGS*Math.PI;for(let f=0;f<mi.SEGMENTS;f++){const p=f/mi.SEGMENTS*2*Math.PI;s.push([e*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-e,e])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=t.attitude.headingDeg*Il,l=t.attitude.pitchDeg*Il,h=t.attitude.rollDeg*Il;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),g=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-g*Math.sin(l),M=d*Math.sin(l)+g*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+m*Math.sin(c),northM:t.northM-p*Math.sin(c)+m*Math.cos(c),upM:t.upM+M}})}static dot(t,e){return t.eastM*e.eastM+t.northM*e.northM+t.upM*e.upM}static cross(t,e){return{eastM:t.northM*e.upM-t.upM*e.northM,northM:t.upM*e.eastM-t.eastM*e.upM,upM:t.eastM*e.northM-t.northM*e.eastM}}static normalized(t){const e=Math.hypot(t.eastM,t.northM,t.upM);return e>1e-9?{eastM:t.eastM/e,northM:t.northM/e,upM:t.upM/e}:void 0}}class Ks{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new ft(new us(2,2),new Ie({uniforms:{uColor:{value:new at(0,0,0)},uRadius:{value:1}},vertexShader:Ks.VERTEX,fragmentShader:Ks.FRAGMENT,transparent:!0,depthWrite:!1,blending:_n,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*Ks.MIN_ANGLE_RAD),r=Ks.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(Ks.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(Ks.MAX_SHARE*Ks.FILL*Math.PI))}static VERTEX=`
|
|
8297
8297
|
uniform float uRadius;
|
|
8298
8298
|
varying vec2 vOffset;
|
|
8299
8299
|
void main() {
|
|
@@ -8938,4 +8938,4 @@ void main() {
|
|
|
8938
8938
|
`);let s=Xr.cache.get(n);return s||(s=Promise.all(i.map(r=>Xr.load(r.url))).then(r=>r.reduce((a,c)=>Xr.concat(a,c))),Xr.cache.set(n,s)),s}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*i,e),dec:new Float32Array(t,1*i,e),mag:new Float32Array(t,2*i,e),ci:new Float32Array(t,3*i,e)}}static concat(t,e){const i=(n,s)=>{const r=new Float32Array(n.length+s.length);return r.set(n,0),r.set(s,n.length),r};return{count:t.count+e.count,ra:i(t.ra,e.ra),dec:i(t.dec,e.dec),mag:i(t.mag,e.mag),ci:i(t.ci,e.ci)}}}class ai{constructor(t){if(this.heights=t,t.length!==ai.WIDTH*ai.HEIGHT)throw new Error(`a lunar relief has ${ai.WIDTH*ai.HEIGHT} samples, not ${t.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*ai.SAMPLES_PER_DEGREE;static HEIGHT=180*ai.SAMPLES_PER_DEGREE;static UNIT_KM=.1;static REFERENCE_RADIUS_KM=1737.4;static BAND_FROM_DEG=74;static BAND_TO_DEG=106;heightKm(t,e){const i=ai.SAMPLES_PER_DEGREE,n=(e%360+360)%360*i-.5,s=(90-t)*i-.5,r=Math.floor(n),a=Math.floor(s),c=n-r,l=s-a,h=(f,p)=>{const g=(f%ai.WIDTH+ai.WIDTH)%ai.WIDTH,m=Math.min(ai.HEIGHT-1,Math.max(0,p));return this.heights[m*ai.WIDTH+g]},u=h(r,a)*(1-c)+h(r+1,a)*c,d=h(r,a+1)*(1-c)+h(r+1,a+1)*c;return(u*(1-l)+d*l)*ai.UNIT_KM}static inBand(t,e){const i=Math.PI/180,n=Math.acos(Math.cos(t*i)*Math.cos(e*i))*180/Math.PI;return n>=ai.BAND_FROM_DEG&&n<=ai.BAND_TO_DEG}static withBump(t,e,i,n=.4){const s=new Int8Array(ai.WIDTH*ai.HEIGHT),r=ai.SAMPLES_PER_DEGREE,a=Math.ceil(n*r),c=Math.floor(e*r),l=Math.floor((90-t)*r);for(let h=-a;h<=a;h++)for(let u=-a;u<=a;u++)Math.hypot(u,h)<=a&&(s[(l+h)*ai.WIDTH+(c+u+ai.WIDTH)%ai.WIDTH]=Math.round(i/ai.UNIT_KM));return new ai(s)}static smooth(){return new ai(new Int8Array(ai.WIDTH*ai.HEIGHT))}}class cr{static SAMPLES=5760;static SEARCH_FROM_DEG=87;static SEARCH_TO_DEG=90.2;static SEARCH_STEP_DEG=.0625;static profile(t,e,i,n=cr.SAMPLES){const{s,u:r,w:a,distanceKm:c}=cr.frame(t,e),l=Math.PI/180,h=new Float32Array(n),u=ai.REFERENCE_RADIUS_KM;for(let d=0;d<n;d++){const f=d/n*2*Math.PI,p=Math.cos(f),g=Math.sin(f),m=p*r[0]+g*a[0],M=p*r[1]+g*a[1],v=p*r[2]+g*a[2];let x=0;for(let y=cr.SEARCH_FROM_DEG;y<=cr.SEARCH_TO_DEG;y+=cr.SEARCH_STEP_DEG){const w=Math.cos(y*l),b=Math.sin(y*l),E=w*s[0]+b*m,S=w*s[1]+b*M,A=w*s[2]+b*v,R=Math.asin(Math.max(-1,Math.min(1,A)))/l,I=Math.atan2(S,E)/l,D=u+i.heightKm(R,I),P=Math.atan2(D*b,c-D*w);P>x&&(x=P)}h[d]=x/l}return{radiusDeg:h,meanRadiusDeg:Math.asin(u/c)/l}}static frame(t,e){const i=new jo(e.lat,e.lng,e.elevationM),n=eo(t),s=mM(t,i,!1),r=new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t),a=Math.hypot(r.x,r.y,r.z)*cr.AU_KM,c=cr.bodyFixed(t),l=c(r),h=Math.hypot(l[0],l[1],l[2]),u=[l[0]/h,l[1]/h,l[2]/h],d=SO(t,i),f=Uv(d),p=ja(d,new Be(-r.x,-r.y,-r.z,n.t)),g=Math.asin(p.z/Math.hypot(p.x,p.y,p.z)),m=Math.atan2(-p.y,p.x),M=new Be(-Math.sin(g)*Math.cos(m),Math.sin(g)*Math.sin(m),Math.cos(g),n.t),v=new Be(-Math.sin(m),-Math.cos(m),0,n.t);return{s:u,u:c(ja(f,M)),w:c(ja(f,v)),distanceKm:a}}static surfacePoint(t,e,i,n){const{s,u:r,w:a}=cr.frame(t,e),c=Math.PI/180,l=[0,1,2].map(u=>Math.cos(i*c)*r[u]+Math.sin(i*c)*a[u]),h=[0,1,2].map(u=>Math.cos(n*c)*s[u]+Math.sin(n*c)*l[u]);return{latDeg:Math.asin(h[2])/c,lonDeg:Math.atan2(h[1],h[0])/c}}static radiusAt(t,e){const i=t.radiusDeg.length,n=(e/360*i%i+i)%i,s=Math.floor(n),r=n-s;return t.radiusDeg[s]*(1-r)+t.radiusDeg[(s+1)%i]*r}static uncoveredFraction(t,e,i){const n=t.radiusDeg.length,s=i.upDeg*i.upDeg+i.rightDeg*i.rightDeg;let r=0;for(let a=0;a<n;a++){const c=a/n*2*Math.PI,l=Math.cos(c),h=Math.sin(c),u=l*i.upDeg+h*i.rightDeg,d=u*u-s+e*e;if(d<=0)continue;const f=Math.sqrt(d),p=u+f;if(p<=0)continue;const g=Math.max(0,u-f),m=Math.max(g,t.radiusDeg[a]);p>m&&(r+=.5*(p*p-m*m))}return Math.min(1,Math.max(0,r*(2*Math.PI/n)/(Math.PI*e*e)))}static AU_KM=1495978707e-1;static bodyFixed(t){const e=UO(mt.Moon,t),i=Math.PI/180,n=e.ra*15*i,s=e.dec*i,r=e.spin*i,a=(l,[h,u,d])=>[Math.cos(l)*h+Math.sin(l)*u,-Math.sin(l)*h+Math.cos(l)*u,d],c=(l,[h,u,d])=>[h,Math.cos(l)*u+Math.sin(l)*d,-Math.sin(l)*u+Math.cos(l)*d];return l=>a(r,c(Math.PI/2-s,a(Math.PI/2+n,[l.x,l.y,l.z])))}static subObserverPoint(t,e){const i=new jo(e.lat,e.lng,e.elevationM),n=eo(t),s=mM(t,i,!1),r=cr.bodyFixed(t)(new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t)),a=Math.hypot(r[0],r[1],r[2]);return{latDeg:Math.asin(r[2]/a)*180/Math.PI,lonDeg:Math.atan2(r[1],r[0])*180/Math.PI}}}class Qu{static cache=new Map;static load(t){let e=Qu.cache.get(t);return e||(e=Qu.fetchRelief(t).catch(()=>{}),Qu.cache.set(t,e)),e}static async fetchRelief(t){const e=await fetch(t);if(!e.ok)return;let i=new Uint8Array(await e.arrayBuffer());if(i[0]===31&&i[1]===139){if(typeof DecompressionStream>"u")return;const n=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip"));i=new Uint8Array(await new Response(n).arrayBuffer())}return new ai(new Int8Array(i.buffer,i.byteOffset,i.length))}}const Jv=Qs.catalog({en:()=>xt(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(o=>o.perceptionMessages_en),fr:()=>xt(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(o=>o.perceptionMessages_fr),es:()=>xt(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(o=>o.perceptionMessages_es),it:()=>xt(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(o=>o.perceptionMessages_it)});class Tp{static ID="color-vision";static MATRICES={protan:[.152286,1.052583,-.204868,.114503,.786281,.099216,-.003882,-.048116,1.051998],deutan:[.367322,.860646,-.227968,.280085,.672501,.047413,-.01182,.04294,.968881],tritan:[1.255528,-.076749,-.178779,-.078411,.930809,.147602,.004733,.691367,.3039]};id=Tp.ID;messages=Jv;sources=["Machado, Oliveira, Fernandes, A Physiologically-based Model for Simulation of Color Vision Deficiency, IEEE TVCG 15(6), 2009"];settings=[{id:"type",kind:"choice",default:"normal",choices:[{id:"normal"},{id:"protan"},{id:"deutan"},{id:"tritan"}]},{id:"severity",kind:"number",default:100,min:0,max:100,step:5,unit:"%"}];perceive(t){const e=Tp.MATRICES[String(t.type)];if(!e)return Fs.NONE;const i=Number(t.severity??100),n=Math.max(0,Math.min(100,Number.isFinite(i)?i:100))/100;return{colorMatrix:e.map((r,a)=>Fs.IDENTITY[a]+(r-Fs.IDENTITY[a])*n),contrastGain:1}}}class jv{static ID="fatigue";id=jv.ID;messages=Jv;sources=["Studies of contrast sensitivity during prolonged sleep deprivation (60 hours, naval officers): no significant change"];settings=[{id:"hoursAwake",kind:"number",default:0,min:0,max:72,step:1,unit:"h"}];perceive(t){return Fs.NONE}}class wc{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=wc.ID;messages=Jv;sources=["Frontiers in Neuroscience, 2022, doi:10.3389/fnins.2022.873671 (contrast sensitivity at about 0.08 % blood alcohol)"];settings=[{id:"bloodAlcohol",kind:"number",default:0,min:0,max:wc.MAX_LEVEL,step:.01,unit:"%",also:{unit:"g/L",factor:10,digits:1}}];perceive(t){const e=Number(t.bloodAlcohol??0),i=Math.max(0,Math.min(wc.MAX_EFFECT_LEVEL,Number.isFinite(e)?e:0));if(i===0)return Fs.NONE;const n=i/wc.MEASURED_LEVEL*wc.MEASURED_LOSS_DB;return{colorMatrix:Fs.IDENTITY,contrastGain:10**(-n/20)}}}const sL=o=>o.sources[0]??o.id,rL=Te.point("perception").provide(Te.BUILT_IN,[new Tp,new wc,new jv].map(o=>({id:o.id,name:o.id,credit:sL(o),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>o})));class Sc{static built=new WeakMap;static get ALL(){return rL.map(t=>{let e=Sc.built.get(t);return e||(e=t.create(),Sc.built.set(t,e)),e})}static byId(t){return Sc.ALL.find(e=>e.id===t)}static perceptionOf(t){return Sc.ALL.reduce((e,i)=>Fs.combine(e,i.perceive(t?.[i.id]??{})),Fs.NONE)}static compact(t){const e={},i=Sc.ALL;for(const[n,s]of Object.entries(t))!i.some(r=>r.id===n)&&Object.keys(s??{}).length>0&&(e[n]=s);for(const n of i){const s=t[n.id]??{},r=Object.fromEntries(n.settings.filter(a=>s[a.id]!==void 0&&s[a.id]!==a.default).map(a=>[a.id,s[a.id]]));Object.keys(r).length>0&&(e[n.id]=r)}return Object.keys(e).length>0?e:void 0}}class bc{static NONE={id:"none",name:"No filter",opticalDensity:0};static SOLAR_VISUAL={id:"solar-visual",name:"Solar filter for the eye (OD 5)",opticalDensity:5,usableWith:["eye","binoculars","telescope"]};static SOLAR_PHOTO={id:"solar-photo",name:"Solar film for a camera (OD 3.8)",opticalDensity:3.8,usableWith:["camera","dslr","phone","telescope"]};static ALL=[bc.NONE,bc.SOLAR_VISUAL,bc.SOLAR_PHOTO];static usableWith(t,e){return!t.usableWith||t.usableWith.includes(e.category)}static byId(t){return bc.ALL.find(e=>e.id===t)??bc.NONE}static transmittance(t){return 10**-t.opticalDensity}static magnitudes(t){return 2.5*t.opticalDensity}}class VS{names;constructor(t){this.names=t??Qs.blank(),this.loaded=t!==void 0}loaded;body(t){return this.names.bodies[t]??t}star(t){return this.names.stars[t.name]??t.name}comet(t){return this.names.comets[t.id]??t.name}nova(t){return this.names.novae[t.id]??t.name}satelliteClass(t){return this.names.satelliteClasses[t.id]??t.name}shower(t){return this.names.showers[t.id]??t.name}lightRig(t){return this.names.lightRigs[t.id]??t.name}instrument(t){return this.names.instruments[t.id]??t.name}decorKind(t){return this.names.decorKinds[t]}point(t){return zc.point(t,this.loaded?this.names.compassPoints:void 0)}towards(t){return zc.towards(t,this.loaded?this.names:void 0)}}class $r{static STANDARD_GAUGE_MM=1435;static METRE_GAUGE_MM=1e3;static kind(t,e){return t.highSpeed?e.highSpeed:t.service?e.service:e.kinds[t.kind]}static name(t,e){const i=t.name??$r.kind(t,e);return t.services?.length?`${i} — ${t.services.join(", ")}`:i}static voltage(t,e){return t>=1e3?`${(t/1e3).toLocaleString(e,{maximumFractionDigits:1})} kV`:`${t.toLocaleString(e)} V`}static detail(t,e,i,n){const{line:s}=t,r=[];s.name&&r.push($r.kind(s,e).toLocaleLowerCase(n)),r.push(s.tracks>1?e.tracks.replace("{count}",String(s.tracks)):e.singleTrack);const a=s.voltageV?$r.voltage(s.voltageV,n):void 0;if(t.contactM!==void 0){const c=t.contactM.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2});r.push((a?e.overheadVoltage.replace("{voltage}",a):e.overhead).replace("{height}",c))}else s.electrification==="third_rail"?r.push(a?e.thirdRailVoltage.replace("{voltage}",a):e.thirdRail):s.electrification==="none"&&r.push(e.notElectrified);return s.gaugeMm===$r.METRE_GAUGE_MM?r.push(e.metreGauge):s.gaugeMm!==$r.STANDARD_GAUGE_MM&&r.push(e.gauge.replace("{mm}",s.gaugeMm.toLocaleString(n))),r.push(e.distance.replace("{distance}",i(t.distanceM))),s.services?.length?`${$r.name(s,e)}; ${r.join(", ")}`:`${$r.name(s,e)} — ${r.join(", ")}`}}class td{constructor(t,e){this.element=t,this.onChange=e,t.addEventListener("error",()=>{this.url=void 0,this.release()})}shown=!1;url;get up(){return this.shown}show(t,e,i=!0){const n=td.resolve(t,e);if(this.url=n,!n||!i){this.release();return}this.element.src=n,this.element.hidden=!1;const s=this.shown;this.shown=!0,s||this.onChange()}release(){this.shown&&(this.shown=!1,this.element.hidden=!0,this.element.removeAttribute("src"),this.onChange())}restore(){this.url&&this.show(this.url)}static resolve(t,e){if(!(typeof t!="string"||t.trim()===""))try{const i=new URL(t.trim(),e??location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?void 0:i.origin===td.PUBLISHED_ORIGIN&&td.isDevelopmentHost(location.hostname)?location.origin+i.pathname:i.href}catch{return}}static PUBLISHED_ORIGIN="https://ufoathome.org";static isDevelopmentHost(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}}const aL="Global Meteor Network",oL="https://globalmeteornetwork.org/data/",cL="“Thunder” by Jerimee",lL="https://creativecommons.org/licenses/by/3.0/",hL="CC BY 3.0";class Zn{static fill(t,e){t.innerHTML="";const i=d=>t.appendChild(d),n=e.currentTerrainAttribution;n&&i(Zn.text(n));const s=e.currentRoadAttribution;s&&i(Zn.text(s));const r=e.currentWaterAttribution;r&&i(Zn.text(r));const a=e.currentRailwayAttribution;a&&i(Zn.text(a));const c=e.ufoElement.observerMapCredit;c&&!n?.includes(c)&&i(Zn.text(c));for(const d of e.decorModelCredits){const f=d.author?` — ${d.author}`:"",p=document.createElement("li");d.sourceUrl?p.append(Zn.link(d.sourceUrl,d.title),document.createTextNode(`${f} (${d.license})`)):p.textContent=`${d.title}${f} (${d.license})`,i(p)}for(const d of e.ufoElement.sighting.references){if(!d.credit)continue;const f=document.createElement("li");d.creditUrl?f.appendChild(Zn.link(d.creditUrl,d.credit)):f.textContent=d.credit,i(f)}if(e.ufoElement.sighting.traces.length>0){const d=new Tr(Do.preferencesFor(e)),f=new Set(e.ufoElement.sighting.traces.map(p=>d.read(p.source)).filter(p=>!!p));for(const p of f)i(Zn.text(p))}const l=e.satelliteState;if(l.status==="ready"&&l.credit){const d=document.createElement("li");d.appendChild(Zn.link(l.creditUrl??"",l.credit)),i(d)}if(e.fireballState.status==="ready"&&e.fireballState.records.length>0){const d=document.createElement("li");d.append(Zn.link(oL,aL),document.createTextNode(" (CC BY 4.0)")),i(d)}const h=e.aircraftState;if(h.status==="ready"&&h.shown>0){const d=document.createElement("li");if(d.appendChild(Zn.link(h.creditUrl,h.credit)),i(d),h.trailCredit){const f=document.createElement("li");f.appendChild(Zn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(f)}}const u=Zn.text(`${cL} (`);u.append(Zn.link(lL,hL),document.createTextNode(")")),i(u)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const uL=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,dL=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,WS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,fL=20,pL=1;class kc{context;constructor(t){this.context=t}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};level=1;share=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.gain,this.master.connect(t.destination)),this.master}get gain(){return this.level*this.share}setLevel(t){this.level=t,this.master&&(this.master.gain.value=this.gain)}setOutsideHeard(t){this.share=Math.min(1,Math.max(0,t)),this.master&&(this.master.gain.value=this.gain)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}Zs.isLive(this.context)&&Zs.unlock(this.context)}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(uL,this.ambientVolume).then(a=>this.applyIfCurrent(a,r,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/fL,1);const s=i>pL;if(s!==this.windActive){this.windActive=s;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(dL,this.windVolume).then(a=>this.applyIfCurrent(a,r,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:i,windSpeed:n}=this.requested;this.setAmbient(e,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(WS,.9)}playDetonation(t){const e=this.context;if(!e||this.paused)return;const i=Math.min(1,Math.max(0,t)),n=e.createBufferSource();n.buffer=this.crackBuffer(e);const s=e.createBiquadFilter();s.type="lowpass",s.frequency.value=kc.CRACK_CUTOFF_HZ;const r=e.createGain();r.gain.value=i,n.connect(s).connect(r).connect(this.output(e)),n.start(),this.playOneShot(WS,i,kc.DETONATION_RATE)}static DETONATION_RATE=.8;static CRACK_CUTOFF_HZ=2500;static CRACK_DECAY_S=.25;crackBuffer(t){if(this.crack?.sampleRate===t.sampleRate)return this.crack;const e=Math.round(t.sampleRate*kc.CRACK_DECAY_S*6),i=t.createBuffer(1,e,t.sampleRate),n=i.getChannelData(0);for(let s=0;s<e;s++){const r=s/t.sampleRate;n[s]=(Math.random()*2-1)*Math.min(1,r/.005)*Math.exp(-r/kc.CRACK_DECAY_S)}return this.crack=i,i}crack;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,Zs.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(t,e,i,n){if(e!==i()){t?.source.stop();return}n(t)}async startLoop(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n,s.loop=!0;const r=i.createGain();return r.gain.value=e,s.connect(r).connect(this.output(i)),s.start(),{source:s,gain:r}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e,i=1){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.playbackRate.value=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(this.output(n)),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ua{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),r=Math.sqrt(Ua.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,r),this.inverseSemiMajorAxis=(1-e)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,i=this.universalAnomaly(e),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,r=1-i*i/s*Ua.stumpffC(n),a=e-i*i*i/Math.sqrt(Ua.SUN_GM_AU3_PER_DAY2)*Ua.stumpffS(n);return{x:r*this.perihelionPosition.x+a*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+a*this.perihelionVelocity.y,z:r*this.perihelionPosition.z+a*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),i=Math.sqrt(Ua.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=a=>{const c=this.inverseSemiMajorAxis*a*a,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*a*a*a*Ua.stumpffS(c)+l*a};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let r=0;for(let a=0;a<Ua.MAX_ITERATIONS&&s-r>1e-13*Math.max(1,s);a++){const c=(r+s)/2;n(c)<i?r=c:s=c}return e*(r+s)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(t),s=Math.sin(t),r=Math.cos(e),a=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*r-s*a*c,y:s*r+n*a*c,z:a*l},{x:-n*a-s*r*c,y:-s*a+n*r*c,z:r*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const i=Math.sqrt(t);return(i-Math.sin(i))/(i*i*i)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const NA=[{id:"halley-1910",designation:"1P/Halley",name:"Halley's Comet",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:"Comet 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:"Comet 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:"Comet 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:"the Southern Comet",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:"the Eclipse Comet",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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Halley's Comet",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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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:"Comet 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 mL{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return NA.filter(i=>Math.abs(e-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(i=>this.appearanceOf(i,t,e)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(t,e,i){const n=fi(e),s=this.earthPositionAt(n),r=this.apparentPositionOf(t,2451545+n.tt,s),a=this.subtract(r,s),c=this.length(r),l=this.length(a),h=this.tailEndAt(t,r,s,c,n,e,i),u=this.horizontalOf(a,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(a,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,i){const n=t.absoluteMagnitude+5*Math.log10(i)+2.5*t.activityExponent*Math.log10(e);return Math.max(n,t.peakMagnitude)}static tailEndAt(t,e,i,n,s,r,a){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/n,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},i),h=this.subtract(e,i);return{tailEnd:this.horizontalOf(l,s,r,a),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let r=0;r<2;r++){const a=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-a)}return s}static horizontalOf(t,e,i,n){const s=ja(vO(),new Be(t.x,t.y,t.z,e)),r=ja(hA(e),s),a=mM(e,new jo(n.lat,n.lng,n.elevationM),!0),c=new Be(r.x-a.x,r.y-a.y,r.z-a.z,e),l=qp(c);return Hv(l.ra,l.dec,i,n)}static earthPositionAt(t){return ja(MO(),Ko(mt.Earth,t))}static julianDayOf(t){return 2451545+fi(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ua(t.orbit);return this.orbits.set(t.id,i),i}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const i=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const jg=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:"Supernova of 1006",raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:"Supernova of 1054",raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:"Supernova of 1181",raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:"Tycho's Supernova",raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:"Kepler's Supernova",raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1866",raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:"Nova Aurigae 1891",raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:"Nova Persei 1901",raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:"Nova Geminorum 1912",raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:"Nova Aquilae 1918",raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:"Nova Cygni 1920",raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:"Nova Pictoris 1925",raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:"Nova Herculis 1934",raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:"Nova Lacertae 1936",raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:"Nova Puppis 1942",raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1946",raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:"Nova Herculis 1960",raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:"Nova Herculis 1963",raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:"Nova Delphini 1967",raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:"Nova Vulpeculae 1968",raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:"Nova Serpentis 1970",raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:"Nova Cygni 1975",raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:"Nova Centauri 1986",raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:"Supernova 1987A",raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:"Nova Cygni 1992",raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:"Nova Velorum 1999",raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:"Nova Aquilae 1999",raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:"Nova Sagittarii 2002",raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2006",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:"Nova Scorpii 2007",raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:"Nova Delphini 2013",raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:"Nova Centauri 2013",raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2021",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class XS{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return jg.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of jg){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:_r.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:r})}return n.sort((s,r)=>s.magnitude-r.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return jg.find(e=>e.id===t)}static magnitudeAt(t,e){const i=t.lightCurve,n=e-t.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[r,a]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===r)return a;const h=Math.min(1,Math.max(0,(n-r)/(c-r)));return a+h*(l-a)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const gL=[{id:"quadrantids",code:"QUA",name:"Quadrantids",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:"April Lyrids",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:"eta Aquariids",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:"alpha Capricornids",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:"Southern delta Aquariids",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:"Perseids",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:"Southern Taurids",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:"October Draconids",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:"Orionids",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:"Northern Taurids",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:"Leonids",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:"Geminids",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:"Ursids",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}],Rp=6.5;class Qg{static activeAt(t){return gL.flatMap(e=>{const i=this.nearness(e,t);return i<=0?[]:[{shower:e,zhr:e.peakZhr*i,nearness:i}]})}static nearness(t,e){const i=this.dayOfYear(e),n=this.dayOfYear(this.asDate(t.start)),s=this.dayOfYear(this.asDate(t.peak)),r=this.dayOfYear(this.asDate(t.end)),a=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(r,s);return a<0?a<-c?0:1+a/c:a>0?a>l?0:1-a/l:1}static observedRatePerHour(t,e,i,n=Rp){if(e<=0)return 0;const s=Rp-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return _r.ofJ2000(t.radiantRaHours,t.radiantDecDeg,e,i)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const i=t-e;return i>182?i-365:i<-182?i+365:i}}class Ki{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=fi(t),n=new Xp(0,qP(t).elon-90,1),s=ja(bO(i),Bv(n,i)),r=qp(s);return Hv(r.ra,r.dec,t,e)}static observedRatePerHour(t,e=Rp){const i=Ki.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Rp-e;return(Ki.QUIET_RATE_PER_HOUR+i)/Math.pow(Ki.POPULATION_INDEX,n)}static schedule(t){const e=new Zp(t.seed^1542469173);return hr.schedule(t).map(i=>{const n=Ki.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=Ki.turnAround(n,e.between(0,360)),a={x:n.x*Math.cos(s)+r.x*Math.sin(s),y:n.y*Math.cos(s)+r.y*Math.sin(s),z:n.z*Math.cos(s)+r.z*Math.sin(s)};return{...i,radiant:Ki.toHorizontal(a),bearingDeg:Ki.bearingFrom(a,n)}})}static turnAround(t,e){const[i,n]=Ki.basisAround(t),s=e*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(t,e){const[i,n]=Ki.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,r=Ki.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(r.x*n.x+r.y*n.y+r.z*n.z,r.x*i.x+r.y*i.y+r.z*i.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=Ki.normalise(Ki.cross(t,e));return[i,Ki.normalise(Ki.cross(t,i))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=Ki.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=Ki.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return Ki.toHorizontal({x:e.x*Math.cos(n)+i.x*Math.sin(n),y:e.y*Math.cos(n)+i.y*Math.sin(n),z:e.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180,n=Math.cos(e);return{x:n*Math.sin(i),y:Math.sin(e),z:-n*Math.cos(i)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}const YS="https://ufoathome.org/tle/index.json";class Jn{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Jn.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/tle/index.json",location.href).href),t.includes(YS)||t.push(YS),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${Jn.FIRST_SNAPSHOT}T00:00:00Z`)-Jn.MAX_ELEMENT_AGE_DAYS*Jn.DAY_MS;if(t.getTime()<e)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>t.getTime()>=Date.parse(n.from)-Jn.MAX_ELEMENT_AGE_DAYS*Jn.DAY_MS&&t.getTime()<=Date.parse(n.to)+Jn.MAX_ELEMENT_AGE_DAYS*Jn.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],r=[];for(const a of Object.keys(i.kinds)){const c=await this.kindAt(a,t,i,n);s.push(...c),r.push(this.coverageOf(a,t,i,c.length>0))}return{objects:s,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),r=i.binDays*Jn.DAY_MS,a=Math.floor(s/r),c=s-a*r<r/2?a-1:a+1,l=new Set(i.kinds[t].bins),h=[a,c].map(g=>new Date(g*r).toISOString().slice(0,10)).filter(g=>l.has(g));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(g=>this.binary(new URL(`${t}/${g}.bin`,n).href))]),f=new Map;for(const g of d)for(const m of Jn.decode(g,i.recordBytes)){const M=f.get(m.norad);(!M||Math.abs(m.epochMs-s)<Math.abs(M.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const g of f.values()){const m=Math.abs(g.epochMs-s)/Jn.DAY_MS;if(m>Jn.MAX_ELEMENT_AGE_DAYS)continue;const M=u[g.norad]??{name:String(g.norad)};M.launch&&Date.parse(`${M.launch}T00:00:00Z`)>s||p.push({norad:g.norad,name:M.name,kind:t,launch:M.launch,stdMag:M.stdMag,elements:g,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:r}=i.kinds[t],a=e.getTime(),c=Jn.MAX_ELEMENT_AGE_DAYS*Jn.DAY_MS,l=n?"covered":a<Date.parse(s)-c?"before":a>Date.parse(r)+c?"after":"gap";return{kind:t,status:l,from:s,to:r}}static decode(t,e){const i=new DataView(t),n=[];for(let s=0;s+e<=t.byteLength;s+=e)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;return{index:await e.json(),base:t}}catch{}})(),this.index}json(t){return this.cached(t,async e=>e.json())}binary(t){return this.cached(t,async e=>e.arrayBuffer())}cached(t,e){let i=this.files.get(t);return i||(i=this.fetchImpl(t).then(n=>{if(!n.ok)throw new Error(`${t}: ${n.status}`);return e(n)}),i.catch(()=>this.files.delete(t)),this.files.set(t,i)),i}}class ML{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=di.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=di.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}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(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:di.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:di.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Bc{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Bc.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=Bc.degOver(t)/e;return i<1?1:Math.min(Bc.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Hn{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 Bc.DEG_PER_SECOND*3600}static graspOf(t,e={}){if(t.visualAid)return Hn.visualAidGrasp(t,e.focalLengthMm);const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Hn.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??Hn.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,a=Hn.resolutionArcsec(t,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Hn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(t,e){const i=t.visualAid,n=Hn.EYE,s=e??t.frame?.focalLengthMm,r=i.magnification??(s!==void 0&&i.eyepieceFocalMm?s/i.eyepieceFocalMm:1),a=Math.min(i.apertureMm,n.apertureMm*r);return{apertureMm:Math.max(a,n.apertureMm),exposureSeconds:n.exposureSeconds,resolutionArcsec:n.resolutionArcsec/Math.max(1,Math.min(r,i.apertureMm/n.apertureMm))}}static resolutionArcsec(t,e,i){const s=(t.detailUm??Hn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*Hn.ARCSEC_PER_RADIAN,r=1.22*Hn.WAVELENGTH_M/(i/1e3)*Hn.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(t){return t/Hn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=Hn.graspOf(t,e),n=Hn.EYE,s=(i.apertureMm/n.apertureMm)**2,r=i.exposureSeconds/n.exposureSeconds,a=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*r*a)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:qi.focalLengthMmFor(t,e.fieldOfViewDeg);return Hn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const KS=111320,Ru=Math.PI/180,vL=1.02,yL=1;class ed{static of(t,e){const i=ed.sightings(t,e);if(i.length<2)return;const n=ed.baseline(i);if(!n)return;const{near:s,far:r,closedM:a}=n,c=Math.tan(r.widthDeg/2*Ru)===0?0:Math.tan(s.widthDeg/2*Ru)/Math.tan(r.widthDeg/2*Ru);if(c<vL)return;const l=a/(c-1),h=di.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:di.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:r.t,toT:s.t,closedM:a}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(a=>a.sourceId===e)?.shape,s=n?.angular?.widthDeg,r=ke(t,i.t);return s===void 0||s<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:r.lat,lng:r.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??r.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(t){let e;for(const i of t)for(const n of t){if(i.t>=n.t)continue;const s=ed.closedAlongSight(i,n),[r,a,c]=s>=0?[n,i,s]:[i,n,-s];c<yL||r.widthDeg<=a.widthDeg||(!e||c>e.closedM)&&(e={near:r,far:a,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*KS,n=(e.lng-t.lng)*KS*Math.cos(t.lat*Ru),s=(t.sightAzimuthDeg??0)*Ru;return i*Math.cos(s)+n*Math.sin(s)}}class ms{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:ms.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:ms.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:ms.atLeastNearest(t.derivedM),basis:"derived"};const e=ms.largest(t.range?.minM,t.crossing?.behindM),i=ms.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*ms.MARGIN,s=i===void 0?void 0:i/ms.MARGIN;return n!==void 0&&s!==void 0?{distanceM:ms.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:ms.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<ms.CONVENTIONAL_M?{distanceM:ms.atLeastNearest(s),basis:"bounded"}:{distanceM:ms.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(ms.NEAREST_M,t)}static largest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.min(...e)}}class Pt{static A=6378137;static E2=.00669437999014;static DEG=Math.PI/180;static STANDARD_DISTANCE_KM=100;static DEFAULT_COLOR="#ffb347";static DEFAULT_TRAIN_S=4;static DEFAULT_CRUMBLING={perS:1.2,lifeS:4,magnitudeDrop:3,dropBack:.3,spreadKmS:1,sinkKmS:.6,trainS:2.5};static DEFAULT_BURST={perS:12,lifeS:3.5,magnitudeDrop:3.5,dropBack:.5,spreadKmS:1.5,sinkKmS:.9,trainS:2};static FLARE_MAGNITUDES=.5;static shedsOf(t){return t.sheds?t.sheds:[Pt.DEFAULT_CRUMBLING,...Pt.flareBursts(t)]}static flareBursts(t){const e=t.lightCurve??[],i=[];for(let n=1;n<e.length-1;n++){const s=e[n];e[n-1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||e[n+1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||i.push({...Pt.DEFAULT_BURST,fromT:s.t-1e3,untilT:s.t+1500})}return i}static FADE_MS=1e3;static FADED_MAGNITUDE=8;static TRAIN_POINTS=8;static leadAt(t,e){const i=t.track;if(i.length<2||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-2&&i[n+1].t<e;)n++;const s=i[n],r=i[n+1],a=r.t-s.t,c=a>0?(e-s.t)/a:0,[l,h]=Pt.alongGreatCircle(s,r,c);return{lat:l,lng:h,heightM:(s.altitudeKm+(r.altitudeKm-s.altitudeKm)*c)*1e3}}static mayDazzle(t){const e=Math.max(1,Math.min(...t.track.map(n=>n.altitudeKm))),i=5*Math.log10(e/Pt.STANDARD_DISTANCE_KM);return t.fragments.some(n=>Math.min(n.absoluteMagnitude,...(n.lightCurve??[]).map(r=>r.absoluteMagnitude))+i<=Pt.DAZZLING_MAGNITUDE)}static detonationsOf(t,e){const i=[];for(const n of t)n.fragments.forEach((s,r)=>{const a=Pt.piecesOf(n).find(l=>l.id===(s.id??String(r)));if(!a)return;const c=(s.lightCurve??[]).filter((l,h,u)=>(h===0||u[h-1].absoluteMagnitude>=l.absoluteMagnitude)&&(h===u.length-1||u[h+1].absoluteMagnitude>l.absoluteMagnitude)).map(l=>({t:l.t,magnitude:l.absoluteMagnitude}));c.push({t:a.untilT,magnitude:a.magnitudeAt(a.untilT)});for(const l of c){if(l.magnitude>Pt.DETONATING_MAGNITUDE||l.t<a.fromT||l.t>a.untilT)continue;const h=Pt.pieceAt(n,a,l.t);if(!h||h.heightM>Pt.AUDIBLE_BELOW_KM*1e3||i.some(d=>d.flashT===l.t&&d.reentryId===n.id))continue;const u=Pt.seenFrom(e,h).distanceKm;i.push({reentryId:n.id,flashT:l.t,t:l.t+u/Pt.SOUND_KM_S*1e3,distanceKm:u,loudness:Math.min(1,(.3+(Pt.DETONATING_MAGNITUDE-l.magnitude)/15)*Math.min(1,30/u))})}});return i.sort((n,s)=>n.t-s.t)}static DETONATING_MAGNITUDE=-12;static AUDIBLE_BELOW_KM=50;static SOUND_KM_S=.31;static DAZZLING_MAGNITUDE=-11;static absoluteMagnitudeAt(t,e){const i=t.lightCurve;if(!i||i.length===0)return t.absoluteMagnitude;if(e<=i[0].t)return i[0].absoluteMagnitude;for(let n=1;n<i.length;n++){const s=i[n-1],r=i[n];if(e<=r.t)return s.absoluteMagnitude+(r.absoluteMagnitude-s.absoluteMagnitude)*(e-s.t)/Math.max(r.t-s.t,1)}return i[i.length-1].absoluteMagnitude}static viewsAt(t,e,i){const n=[];for(const s of t)for(const r of Pt.piecesOf(s)){if(e<r.fromT||e>r.untilT)continue;const a=Pt.pieceAt(s,r,e);if(!a)continue;const c=Pt.seenFrom(i,a);if(c.altitudeDeg<0)continue;const l=Math.min(Pt.FADE_MS,(r.untilT-r.fromT)/4),h=l>0?Math.min(1,(e-r.fromT)/l,(r.untilT-e)/l):1,u=r.magnitudeAt(e)+5*Math.log10(c.distanceKm/Pt.STANDARD_DISTANCE_KM),d=u+(1-h)*Math.max(0,Pt.FADED_MAGNITUDE-u),f=[c];for(let p=1;p<=Pt.TRAIN_POINTS;p++){const g=Math.min(r.trainMs*p/Pt.TRAIN_POINTS,e-r.fromT),m=Pt.pieceAt(s,r,e-g);if(!m||(f.push(Pt.seenFrom(i,m)),g>=e-r.fromT))break}n.push({reentryId:s.id,fragmentId:r.id,head:c,magnitude:d,fade:h,color:r.color,train:f})}return n}static piecesOf(t){const e=Pt.pieces.get(t);if(e)return e;const i=t.track[0]?.t??0,n=t.track[t.track.length-1]?.t??0,s=[];return t.fragments.forEach((r,a)=>{const c=(r.lagS??0)*1e3,l={id:r.id??String(a),fromT:r.fromT??i,untilT:r.untilT??n,lagMsAt:()=>c,acrossKmAt:()=>0,belowKmAt:()=>0,magnitudeAt:h=>Pt.absoluteMagnitudeAt(r,h),color:r.color??Pt.DEFAULT_COLOR,trainMs:(r.trainS??Pt.DEFAULT_TRAIN_S)*1e3};s.push(l),Pt.shedsOf(r).forEach((h,u)=>s.push(...Pt.shedPieces(l,h,u)))}),Pt.pieces.set(t,s),s}static pieces=new WeakMap;static shedPieces(t,e,i=0){const n=e.fromT??t.fromT,s=Math.min(e.untilT??t.untilT,t.untilT);if(!(e.perS>0)||s<=n)return[];const r=Math.floor((s-n)/1e3*e.perS),a=e.spreadKmS??.3,c=e.sinkKmS??.3,l=e.trainS!==void 0?e.trainS*1e3:t.trainMs*(2/3),h=[];for(let u=0;u<r;u++){const d=E=>Pt.hash(`${t.id}/${i}/${u}/${E}`),f=n+(u+d(1))/e.perS*1e3,p=e.lifeS*(.4+1.2*d(2))*1e3,g=e.magnitudeDrop*(.5-.5*Math.log(1-.999*d(3))),m=e.dropBack*(.5+d(4)),M=a*(2*d(5)-1),v=c*(.5+d(6)),x=t.lagMsAt(f),y=t.acrossKmAt(f),w=t.belowKmAt(f),b=E=>Math.max(0,E-f)/1e3;h.push({id:`${t.id}.${i}.${u}`,fromT:f,untilT:Math.min(f+p,Pt.endOf(t)),lagMsAt:E=>x+1e3*Pt.lagOfBraking(2*m,b(E)),acrossKmAt:E=>y+M*b(E),belowKmAt:E=>w+v*b(E),magnitudeAt:E=>t.magnitudeAt(Math.min(E,t.untilT))+g,color:t.color,trainMs:l})}return h}static lagOfBraking(t,e){return t<=0||e<=0?0:e-(1-Math.exp(-t*e))/t}static endOf(t){return t.untilT}static hash(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return(e>>>0)/4294967296}static pieceAt(t,e,i){const n=i-e.lagMsAt(i),s=Pt.leadAt(t,n);if(!s)return;const r=e.acrossKmAt(i),a=s.heightM-e.belowKmAt(i)*1e3;if(r===0)return{...s,heightM:a};const c=Pt.leadAt(t,n-1e3)??s;return{...Pt.across(c,s,r),heightM:a}}static across(t,e,i){const n=Pt.DEG,s=t.lat*n,r=e.lat*n,a=(e.lng-t.lng)*n,c=Math.atan2(Math.sin(a)*Math.cos(r),Math.cos(s)*Math.sin(r)-Math.sin(s)*Math.cos(r)*Math.cos(a))+Math.PI/2,l=i/6371,h=Math.asin(Math.sin(r)*Math.cos(l)+Math.cos(r)*Math.sin(l)*Math.cos(c)),u=e.lng*n+Math.atan2(Math.sin(c)*Math.sin(l)*Math.cos(r),Math.cos(l)-Math.sin(r)*Math.sin(h));return{lat:h/n,lng:u/n}}static seenFrom(t,e){const i=Pt.ecef(t),n=Pt.ecef(e),s=n[0]-i[0],r=n[1]-i[1],a=n[2]-i[2],c=t.lat*Pt.DEG,l=t.lng*Pt.DEG,h=-Math.sin(l)*s+Math.cos(l)*r,u=-Math.sin(c)*Math.cos(l)*s-Math.sin(c)*Math.sin(l)*r+Math.cos(c)*a,d=Math.cos(c)*Math.cos(l)*s+Math.cos(c)*Math.sin(l)*r+Math.sin(c)*a,f=Math.hypot(h,u,d);return{altitudeDeg:Math.asin(d/f)/Pt.DEG,azimuthDeg:(Math.atan2(h,u)/Pt.DEG+360)%360,distanceKm:f/1e3}}static ecef(t){const e=t.lat*Pt.DEG,i=t.lng*Pt.DEG,n=Math.sin(e),s=Pt.A/Math.sqrt(1-Pt.E2*n*n);return[(s+t.heightM)*Math.cos(e)*Math.cos(i),(s+t.heightM)*Math.cos(e)*Math.sin(i),(s*(1-Pt.E2)+t.heightM)*n]}static alongGreatCircle(t,e,i){const n=h=>{const u=h.lat*Pt.DEG,d=h.lng*Pt.DEG;return[Math.cos(u)*Math.cos(d),Math.cos(u)*Math.sin(d),Math.sin(u)]},s=n(t),r=n(e),a=Math.max(-1,Math.min(1,s[0]*r[0]+s[1]*r[1]+s[2]*r[2])),c=Math.acos(a);let l;if(c<1e-12)l=s;else{const h=Math.sin((1-i)*c)/Math.sin(c),u=Math.sin(i*c)/Math.sin(c);l=[s[0]*h+r[0]*u,s[1]*h+r[1]*u,s[2]*h+r[2]*u]}return[Math.atan2(l[2],Math.hypot(l[0],l[1]))/Pt.DEG,Math.atan2(l[1],l[0])/Pt.DEG]}}class uh{static typed=new Map;static of(t){return uh.typed.get(t)}static set(t,e){const i=e.trim();i===""?uh.typed.delete(t):uh.typed.set(t,i)}static forget(){uh.typed.clear()}}class Qv{static FIRST_DAY="2022-01-01";static mayCover(t){return new Date(t).toISOString().slice(0,10)>=Qv.FIRST_DAY}}class $S{constructor(t,e,i){this.citation=t,this.covers=e,this.load=i}loading;mayCover(t){return this.covers(t)}async between(t,e,i,n){try{return await(await this.provider()).between(t,e,i,n)}catch{return{status:"failed"}}}async describe(t,e){try{return await(await this.provider()).describe?.(t,e)}catch{return}}provider(){if(!this.loading){const t=this.load();this.loading=t,t.catch(()=>{this.loading===t&&(this.loading=void 0)})}return this.loading}}const xL="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",wL="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",qS="flightradar24",SL=Te.point("aircraft").provide(Te.BUILT_IN,[{id:"adsb-lol",name:"adsb.lol",credit:"adsb.lol feeders and contributors, ODbL 1.0",creditUrl:"https://www.adsb.lol/docs/open-data/historical/",create:()=>new $S(xL,o=>Qv.mayCover(o),async()=>new(await xt(async()=>{const{AdsbLolArchiveProvider:o}=await import("./AdsbLolArchiveProvider-DdUpO-EA.js");return{AdsbLolArchiveProvider:o}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:qS,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new $S(wL,o=>o>=Date.UTC(2016,4,11)&&o<=Date.now(),async()=>new(await xt(async()=>{const{Flightradar24Provider:o}=await import("./Flightradar24Provider-DnJbUJ3f.js");return{Flightradar24Provider:o}},[],import.meta.url)).Flightradar24Provider({token:()=>uh.of(qS)}))}]);class On{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(t,e,i){const n=On.positionAt(t,i);if(!n)return;const s=Pt.seenFrom(e,n.geo);if(!(s.altitudeDeg<0))return{track:t,sky:s,altitudeFt:n.altitudeFt,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg,angularRateDegPerS:On.angularRate(t,e,i)}}static viewsAt(t,e,i){return t.flatMap(n=>On.seenFrom(n,e,i)??[])}static groundDistanceKm(t,e){const i=Math.PI/180,n=Math.sin((e.lat-t.lat)*i/2)**2+Math.cos(t.lat*i)*Math.cos(e.lat*i)*Math.sin((e.lng-t.lng)*i/2)**2;return 2*On.EARTH_RADIUS_KM*Math.asin(Math.min(1,Math.sqrt(n)))}static wrapLongitude(t){return((t+180)%360+360)%360-180}static positionAt(t,e){const i=t.points;if(i.length===0||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-1&&i[n+1].t<=e;)n++;const s=i[n],r=i[n+1]??s,a=r.t-s.t;if(a>On.MAX_GAP_S*1e3)return;const c=a>0?(e-s.t)/a:0,l=s.altitudeFt+(r.altitudeFt-s.altitudeFt)*c,h=(r.lng-s.lng+540)%360-180;return{geo:{lat:s.lat+(r.lat-s.lat)*c,lng:On.wrapLongitude(s.lng+h*c),heightM:l*On.FT_TO_M},altitudeFt:l,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg}}static angularRate(t,e,i){const n=On.positionAt(t,i-500),s=On.positionAt(t,i+500);if(!n||!s)return;const r=On.unit(Pt.seenFrom(e,n.geo)),a=On.unit(Pt.seenFrom(e,s.geo)),c=Math.min(1,Math.max(-1,r[0]*a[0]+r[1]*a[1]+r[2]*a[2]));return Math.acos(c)*180/Math.PI}static unit(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180;return[Math.cos(e)*Math.sin(i),Math.cos(e)*Math.cos(i),Math.sin(e)]}}class Cn{constructor(t){this.boxes=t;for(const i of t){const n=Math.hypot(i.halfWidthM,i.halfLengthM),[s,r]=[Cn.cell(i.eastM-n),Cn.cell(i.eastM+n)],[a,c]=[Cn.cell(i.northM-n),Cn.cell(i.northM+n)];for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=Cn.key(l,h),d=this.cells.get(u);d?d.push(i):this.cells.set(u,[i])}}let e=2166136261;for(const i of t)for(const n of[i.eastM,i.northM,i.cos,i.halfWidthM,i.halfLengthM,i.topM])e=Math.imul(e^Math.round(n*10),16777619);this.signature=t.length===0?"":`${t.length}:${(e>>>0).toString(36)}`}static NONE=new Cn([]);static SOLID=new Set(["building","tree","wall","mound","terrace","shrub"]);static CELL_M=16;static last;signature;cells=new Map;static of(t,e){const i=[];for(const s of t){if(!Cn.SOLID.has(s.kind)||(s.track?.length??0)>0)continue;const r=e(s);if(!(r.heightM>0)||!(r.widthM>0)||!(r.lengthM>0))continue;const a=(s.headingDeg??0)*Math.PI/180;i.push({eastM:s.eastM,northM:s.northM,cos:Math.cos(a),sin:Math.sin(a),halfWidthM:r.widthM/2,halfLengthM:r.lengthM/2,topM:r.heightM})}const n=new Cn(i);return Cn.last?.signature===n.signature?Cn.last.obstacles:(Cn.last={signature:n.signature,obstacles:n},n)}get empty(){return this.boxes.length===0}inside(t,e,i,n=0){const s=this.cells.get(Cn.key(Cn.cell(t),Cn.cell(e)));if(s)for(const r of s){if(i>r.topM+n)continue;const a=t-r.eastM,c=e-r.northM,l=a*r.sin+c*r.cos,h=a*r.cos-c*r.sin,u=r.halfLengthM+n-Math.abs(l),d=r.halfWidthM+n-Math.abs(h);if(u<=0||d<=0)continue;const f=r.topM+n-i;if(u<d){const g=Math.sign(l)||1;return{box:r,nx:r.sin*g,ny:r.cos*g,depthM:u,belowTopM:f}}const p=Math.sign(h)||1;return{box:r,nx:r.cos*p,ny:-r.sin*p,depthM:d,belowTopM:f}}}static cell(t){return Math.floor(t/Cn.CELL_M)}static key(t,e){return(t+32768)*65536+(e+32768)}}const ZS="https://ufoathome.org/fireballs/index.json";class sa{static FIRST_MONTH="2018-12";static STRIKING_MAGNITUDE=-1;static COLOR="#eef2ff";static TRAIN_S=.3;fetchImpl;indexUrls;index;months=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??sa.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/fireballs/index.json",location.href).href),t.includes(ZS)||t.push(ZS),t}static mayCover(t){return new Date(t).toISOString().slice(0,7)>=sa.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(t,e){if(!sa.mayCover(e))return;const i=await this.loadIndex();if(!i)return;const n=new Set([new Date(t).toISOString().slice(0,7),new Date(e).toISOString().slice(0,7)]);return[...n].some(r=>r>=i.index.from&&r<=i.index.to)?(await Promise.all([...n].filter(r=>i.index.months.includes(r)).map(r=>this.monthOf(r,i.base)))).flat().filter(r=>r.t>=t&&r.t<=e):void 0}static seenFrom(t,e){const i=sa.peakFraction(t),n={lat:t.from[0]+(t.to[0]-t.from[0])*i,lng:t.from[1]+(t.to[1]-t.from[1])*i,heightM:t.peakHeightKm*1e3},s=Pt.seenFrom(e,n);if(!(s.altitudeDeg<0))return{record:t,peak:s,magnitude:t.peakMagnitude+5*Math.log10(s.distanceKm/Pt.STANDARD_DISTANCE_KM)}}static asReentry(t,e){const i=t.t-e,n=i+Math.max(t.durationS,.1)*1e3;return{id:`gmn-${t.id}`,track:[{t:i,lat:t.from[0],lng:t.from[1],altitudeKm:t.from[2]},{t:n,lat:t.to[0],lng:t.to[1],altitudeKm:t.to[2]}],fragments:[{absoluteMagnitude:t.peakMagnitude,color:sa.COLOR,trainS:sa.TRAIN_S}]}}static peakFraction(t){const e=t.from[2]-t.to[2];return Math.abs(e)<1e-6?.5:Math.min(1,Math.max(0,(t.from[2]-t.peakHeightKm)/e))}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(e.ok)return{index:await e.json(),base:t}}catch{}})(),this.index}monthOf(t,e){let i=this.months.get(t);return i||(i=this.fetchImpl(new URL(`${t}.json`,e).href).then(n=>n.ok?n.json():[]).catch(()=>[]),this.months.set(t,i)),i}}class Bi{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(i=>Bi.itemsOf(t,i.key).length===0||Bi.computers.has(i))}static load(t,e){return Promise.all(e.filter(i=>Bi.itemsOf(t,i.key).length>0&&!Bi.computers.has(i)).map(i=>{let n=Bi.loading.get(i);return n||(n=i.compute().then(s=>{Bi.computers.set(i,s)}),n.catch(()=>Bi.loading.delete(i)),Bi.loading.set(i,n)),n.catch(()=>{})})).then(()=>{})}static of(t){let e=Bi.built.get(t);return e||(e=t.create(),Bi.built.set(t,e)),e}static itemsOf(t,e){const i=t?.[e];return Array.isArray(i)?i:[]}static computes(t,e){return e.some(i=>Bi.itemsOf(t,i.key).length>0)}static expand(t,e,i){return Bi.expandWithKinds(t,e,i).interpretation}static expandWithKinds(t,e,i){const n=new Map;if(!t||!Bi.computes(t,e))return{interpretation:t,kindOf:n};const s=e.flatMap(r=>Bi.itemsOf(t,r.key).flatMap(a=>{const c=Bi.computers.get(r);if(!c)return[];const l=c(a,i);for(const h of l)n.set(h.id,r);return l}));return{interpretation:{...t,bodies:[...t.bodies,...s]},kindOf:n}}static computedPart(t,e){const i={};for(const n of e){const s=Bi.itemsOf(t,n.key);s.length>0&&(i[n.key]=[...s])}return i}static saysNothing(t,e){return t.bodies.length===0&&t.title===void 0&&t.smoke===void 0&&e.every(i=>t[i.key]===void 0)}}const bL=Qs.catalog({en:()=>xt(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(o=>o.flareKindMessages_en),fr:()=>xt(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(o=>o.flareKindMessages_fr),es:()=>xt(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(o=>o.flareKindMessages_es),it:()=>xt(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(o=>o.flareKindMessages_it)}),JS={key:"flares",messages:bL,compute:()=>xt(async()=>{const{DecoyFlare:o}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:o}},[],import.meta.url).then(({DecoyFlare:o})=>t=>o.bodiesOf(t))},EL=Qs.catalog({en:()=>xt(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(o=>o.lanternKindMessages_en),fr:()=>xt(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(o=>o.lanternKindMessages_fr),es:()=>xt(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(o=>o.lanternKindMessages_es),it:()=>xt(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(o=>o.lanternKindMessages_it)}),jS={key:"lanterns",messages:EL,compute:()=>xt(async()=>{const{SkyLantern:o}=await import("./SkyLantern-dInLqzN4.js");return{SkyLantern:o}},[],import.meta.url).then(({SkyLantern:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>xt(async()=>{const{LanternEditor:o}=await import("./LanternEditor-CpNWWMyY.js");return{LanternEditor:o}},__vite__mapDeps([11,3,12]),import.meta.url).then(({LanternEditor:o})=>(t,e,i)=>new o(t,e,i))},AL=Qs.catalog({en:()=>xt(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(o=>o.birdKindMessages_en),fr:()=>xt(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(o=>o.birdKindMessages_fr),es:()=>xt(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(o=>o.birdKindMessages_es),it:()=>xt(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(o=>o.birdKindMessages_it)}),QS={key:"birds",messages:AL,compute:()=>xt(async()=>{const{BirdFlock:o}=await import("./BirdFlock-DGC3adr7.js").then(t=>t.b);return{BirdFlock:o}},[],import.meta.url).then(({BirdFlock:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>xt(async()=>{const{BirdEditor:o}=await import("./BirdEditor-BxlHc4L5.js");return{BirdEditor:o}},__vite__mapDeps([13,3,14,4]),import.meta.url).then(({BirdEditor:o})=>(t,e,i)=>new o(t,e,i))},_L=Te.point("interpretations").provide(Te.BUILT_IN,[{id:JS.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>JS},{id:jS.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>jS},{id:QS.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>QS}]);class tb{static kinds(){return _L.map(t=>Bi.of(t))}}kb();const TL="satellites-change",RL="fireballs-change",IL="references-change",DL="aircraft-change",CL="rr0-confrontation",eb="comet:",ib="nova:",PL=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,OL=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,NL=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,LL=-18,kL={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},b0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class ve extends HTMLElement{creditsButton;set ownCredits(t){this.creditsButton.hidden=!t}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",vh,yh,Tc]}shadow;stageElement;frameElement;sceneCanvas;busyElement;busyNote;loaderNote;loaderNotVideo;ufoElement;sceneRenderer;hoverTooltip;ghostPath;flightMark;markedFlight;holding=!1;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;approaches={key:"",of:new Map};distanceHypotheses=new Map;depths=new Map;directionScratch=new _;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationTolerance;confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Jn;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new sa;fireballs;static aircraftProviders=new Map;static SOUND_LOOKBACK_MS=3e5;static TRAIL_LOOKBACK_MS=36e5;static TRAIL_MAX_AIRCRAFT=60;static NO_CONTRAILS=[];static upperAirProviders=new Map;static NO_PRESENCE=new Map;aircraftSource=SL[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return ve.trafficRuntimeLoading??=xt(()=>import("./trafficRuntime-CJIPy2oO.js"),__vite__mapDeps([15,10]),import.meta.url).then(t=>ve.trafficRuntime=t),ve.trafficRuntimeLoading.catch(()=>{ve.trafficRuntimeLoading=void 0}),ve.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new kc;vehicleAudio=new dy;aircraftAudio;vehicleHearing=new V0;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;thunderTimeoutId;handleFullscreenChange=()=>{this.resizeToStage(),this.hoverTooltip.hidden=!0;for(const t of[this.hoverTooltip,this.shadow.getElementById("credits-panel")])t&&typeof t.hidePopover=="function"&&t.matches(":popover-open")&&t.hidePopover();this.tooltipOver=document.fullscreenElement};handlePointerMove=t=>{if(this.lastHover={clientX:t.clientX,clientY:t.clientY,altKey:t.altKey},this.ghostMissedSinceMs=void 0,this.hoverFrame!==void 0&&t.altKey===this.hoverAlt){this.hoverPending=!0;return}this.hoverAlt=t.altKey,this.hoverAt(this.lastHover),this.hoverFrame===void 0&&(this.hoverFrame=requestAnimationFrame(()=>{this.hoverFrame=void 0,this.hoverPending&&this.lastHover&&this.hoverAt(this.lastHover),this.hoverPending=!1}))};ghostMissedSinceMs;static GHOST_KEPT_MS=600;ghostStillUnder(t,e){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return!0;const n=(t.clientX-i.left)/i.width*2-1,s=1-(t.clientY-i.top)/i.height*2;return this.sceneRenderer.ghostsReadableAt(n,s)?this.sceneRenderer.pickGhostAt(n,s)?(this.ghostMissedSinceMs=void 0,!0):(this.ghostMissedSinceMs??=e,e-this.ghostMissedSinceMs>ve.GHOST_KEPT_MS):!1}hoverFrame;hoverPending=!1;hoverAlt=!1;lastPlayingHoverMs=0;static PLAYING_HOVER_MS=150;lastHover;tooltipOver=null;hoverAt(t){if(this.showCompassFor({hovered:!0}),this.holding){this.hoverTooltip.hidden=!0;return}const e=this.ufoElement.canvasElement,i=e.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(t.clientX-i.left)/i.width*e.width,s=(t.clientY-i.top)/i.height*e.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const r=(t.clientX-i.left)/i.width*2-1,a=-((t.clientY-i.top)/i.height*2-1);if(!this.ghostPath.hasAttribute("hidden")&&!this.sceneRenderer.ghostsReadableAt(r,a))return;const c=this.pickAt(r,a,!0,t.altKey);c?this.showHoverTooltip(t,t.altKey&&c.detail?c.detail():c.name):this.hoverTooltip.hidden=!0,this.showGhostPath(c?.path,i)}showGhostPath(t,e){if(!t){this.ghostPath.toggleAttribute("hidden",!0);return}const i=this.stageElement.getBoundingClientRect(),n=d=>({x:e.left-i.left+(d.x+1)/2*e.width,y:e.top-i.top+(1-d.y)/2*e.height}),s=n(t.from),r=n(t.to),a=n({x:0,y:0});this.ghostPath.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);const[c,l,h,u]=Array.from(this.ghostPath.children);for(const d of[c,l])d.setAttribute("x1",String(s.x)),d.setAttribute("y1",String(s.y)),d.setAttribute("x2",String(r.x)),d.setAttribute("y2",String(r.y));h.setAttribute("cx",String(a.x)),h.setAttribute("cy",String(a.y)),u.setAttribute("cx",String(r.x)),u.setAttribute("cy",String(r.y)),this.ghostPath.toggleAttribute("hidden",!1)}pickAt(t,e,i=!0,n=!1){const s=this.naming,r=s.names;if(n&&this.sceneRenderer.pickDropAt(t,e)){const b=r.ghostTooltip,E=b.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:E,detail:()=>b.dropDetail.replace("{name}",E)}}const a=this.sceneRenderer.pickBodyAt(t,e);if(a)return{kind:"sky",id:a,name:this.bodyName(a)};const c=this.interpretationShown?this.sceneRenderer.pickInterpretationBodyAt(t,e):void 0,l=c?this.interpretationShown?.bodies.find(b=>b.id===c):void 0,h=l?this.said.read(l.title)||this.explainedName(l.explains)||this.kindName(l):void 0;if(c!==void 0&&h)return{kind:"body",id:c,name:h};const u=this.skyEventPickAt(t,e,(b,E)=>!E.inSky);if(u)return u;const d=i?this.ghostPick(t,e):void 0;if(d)return d;if(this.sceneRenderer.pickAfterimageAt(t,e)){const b=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:b.name,detail:()=>b.detail.replace("{name}",b.name)}}const f=this.pickDecorAt(t,e)??this.sceneRenderer.pickPeakAt(t,e),p=f?this.ufoElement.sighting.decor.find(b=>b.id===f):void 0;if(p){const b=this.said.read(p.title)||s.decorKind(p.kind);return{kind:"decor",id:p.id,name:b,detail:()=>this.decorTooltip(p,b)}}const g=this.sceneRenderer.pickRailwayAt(t,e);if(g){const b=r.railwayTooltip;return{kind:"railway",id:g.line.id,name:$r.name(g.line,b),detail:()=>$r.detail(g,b,E=>this.distanceText(E))}}const m=this.trafficTooltipAt(t,e);if(m)return{kind:"traffic",name:m};const M=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&!b.pickedAfterSatellites);if(M)return M;const v=this.sceneRenderer.pickSatelliteAt(t,e);if(v)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",v.name).replace("{mag}",v.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(v.heightKm).toLocaleString())};const x=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&b.pickedAfterSatellites===!0);if(x)return x;const y=this.sceneRenderer.pickOpticsAt(t,e);if(y){const b=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:b.split(" — ")[0],detail:()=>b}}const w=this.sceneRenderer.pickStarAt(t,e);if(w){const b=w.star.mag,E=w.altitudeDeg,S=E<0?r.starTooltipBelow:r.starTooltip,A=s.star(w.star);return{kind:"star",name:A,detail:()=>S.replace("{name}",A).replace("{mag}",b.toLocaleString(void 0,{maximumFractionDigits:Math.abs(b)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(E))))}}}ghostLights=new Map;static GHOST_LIGHT_KEPT_MS=1e3;lightOfGhost(t,e){const i=this.ufoElement.canvasElement,n={x:8/Math.max(1,i.clientWidth),y:8/Math.max(1,i.clientHeight)},s=`${Math.round(t/n.x)}:${Math.round(e/n.y)}`,r=performance.now(),a=this.ghostLights.get(s);if(a&&r-a.atMs<ve.GHOST_LIGHT_KEPT_MS)return a.light;let c=this.shiningDecorNear(t,e,2*Math.max(n.x,n.y)),l;if(!c)for(const[h,u]of[[0,0],[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){const d=this.pickAt(t+h*n.x,e+u*n.y,!1);if(d?.kind==="star")l??=d;else if(d){c=d;break}}return c??=this.shiningDecorNear(t,e,6*Math.max(n.x,n.y)),c??=l,this.ghostLights.size>256&&this.ghostLights.clear(),this.ghostLights.set(s,{light:c??null,atMs:r}),c??null}ghostPick(t,e){const i=this.sceneRenderer.pickGhostAt(t,e);if(!i)return;const n=this.naming.names.ghostTooltip,s=i.beyond?{kind:"sky",id:"sun",name:this.bodyName("sun")}:this.lightOfGhost(i.source.x,i.source.y)??void 0,r=(s?.kind==="star"?s.name.split(" — ")[0]:s?.name)??n.unnamed,a=i.ghost,l=(Ze.scatters(a)?n.halo:a.cause==="glass"?n.double:n.ghost).replace("{name}",r),h=a.scale<0?n.opposite:a.scale===1?n.around:n.sameSide;return{kind:"ghost",id:s?.id,name:l,detail:()=>n.detail.replace("{name}",l).replace("{cause}",n.causes[a.cause??"lens"]).replace("{where}",h),path:{from:{x:2*(a.offset?.[0]??0)+a.scale*i.source.x,y:2*(a.offset?.[1]??0)+a.scale*i.source.y},to:i.source}}}shiningDecorNear(t,e,i){let n;for(const s of this.ufoElement.sighting.decor){if(!(s.kind==="streetlight"||s.kind==="trafficlight"||(s.lights?.length??0)>0||s.kind==="vehicle"&&s.lit))continue;const a=this.sceneRenderer.decorScreenBox(s.id);if(!a)continue;const c=Math.hypot(Math.max(a.minX-t,0,t-a.maxX),Math.max(a.minY-e,0,e-a.maxY));if(c>i||n&&c>=n.distance)continue;const l=this.said.read(s.title)||this.naming.decorKind(s.kind);n={distance:c,pick:{kind:"decor",id:s.id,name:l}}}return n?.pick}glassWettingOf(t){const e=JSON.stringify([t.lens,t.instrumentId,t.weatherTrack.allKeyframes.map(i=>[i.t,i.weather.precipitationType,i.weather.precipitationIntensity,i.weather.windDirectionDeg,i.weather.windSpeed])]);if(this.glassWetting?.sighting!==t||this.glassWetting.key!==e){const i=new Pc(n=>{if(!Ze.records(t.instrument)||!Ze.falling(t.lens))return 0;const s=Jh(t,n*1e3),r=ke(t,n*1e3);return(s.precipitationAmount??1)*Ze.impactRate(s,t.lens?.glass,r&&{headingDeg:r.headingDeg??0,pitchDeg:r.pitchDeg,windFromDeg:s.windDirectionDeg,windSpeedMS:s.windSpeed})});this.glassWetting={sighting:t,key:e,wetting:i}}return this.glassWetting.wetting}glassWetting;get skyEventsShown(){return this.skyEventsOf(this.ufoElement.sighting)}skyEventsStartDate;skyEventsMerged;skyEventsOf(t){const e=t.skyEvents,i=this.fireballs?.reentries,n=this.skyEventsMerged;if(n&&n.stated===e&&n.fireballs===i)return n.shown;const s=i?.length?{...e,reentries:[...e?.reentries??[],...i]}:e;return this.skyEventsMerged={stated:e,fireballs:i,shown:s},s}skyEventTexts=new Map;skyEventTextsLanguage;loadSkyEventTexts(t){const e=A0(Do.preferencesFor(this),_0);e!==this.skyEventTextsLanguage&&(this.skyEventTexts.clear(),this.skyEventTextsLanguage=e);for(const i of t)this.skyEventTexts.has(i)||i.messages.load(e).then(n=>{this.skyEventTextsLanguage===e&&this.skyEventTexts.set(i,n)},()=>{})}skyEventPickAt(t,e,i){const n=this.skyEventsShown;if(!n)return;const s=this.sceneRenderer.pickSkyEventAt(t,e,i),r=s?_M.map(d=>Za.of(d)).find(d=>d.key===s.kind):void 0,a=s&&r?Za.eventsOf(n,r).find(d=>d.id===s.id):void 0;if(!s||!r||!a)return;const c=this.skyEventTexts.get(r);if(!c){this.loadSkyEventTexts([r]);return}const l=this.said.read(a.title)||c.name,h=r.describe?.(a,s,{said:this.said,texts:c,name:l,distance:d=>this.distanceText(d)}),u=h?.detail??(s.distanceM!==void 0?`${l}, ${this.distanceText(s.distanceM)}`:void 0);return{kind:r.pickKind??"skyEvent",id:a.id,name:h?.name??l,...u!==void 0?{detail:()=>u}:{}}}distanceText(t){return t>=1e3?`${(t/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} km`:`${t.toLocaleString(void 0,{maximumFractionDigits:t<10?1:0})} m`}decorTooltip(t,e){const i=h=>h.toLocaleString(void 0,{maximumFractionDigits:h<10?1:0}),n=ut.sizeOf(t),s=this.sceneRenderer.decorDistanceM(t.id),r=s===void 0?"":this.distanceText(s),c=this.naming.names.decorTooltip.replace("{name}",e).replace("{size}",`${i(n.widthM)} × ${i(n.lengthM)} × ${i(n.heightM)} m`),l=this.said.read(t.note);return l?`${c.replace("{distance}",r)}. ${l}`:c.replace("{distance}",r)}computedKinds=new Map;computedKindTexts=new Map;bodyModelKinds=new Map;showInterpretation(t){const e=tb.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:n,kindOf:s}=Bi.expandWithKinds(t,e,{obstacles:i});if(this.interpretationAsked=t,this.interpretationShown=n,this.computedKinds=s,this.loadComputedKindTexts(),Bi.loaded(t,e))return;const r=Bi.load(t,e);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==t||!Bi.loaded(t,e)||(this.showInterpretation(t),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=Cn.NONE;obstaclesMadeOf;obstaclesOf(t){return this.obstaclesMadeOf?.decor!==t&&(this.obstaclesMadeOf={decor:t,obstacles:Cn.of(t,e=>ut.sizeOf(e))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const t=this.interpretationAsked;!t||!Bi.computes(t,tb.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(t),this.ufoElement.refreshSoundControls())}loadComputedKindTexts(){const t=this.namesLanguage;if(t)for(const e of new Set(this.computedKinds.values()))this.computedKindTexts.has(e)||e.messages.load(t).then(i=>{t===this.namesLanguage&&this.computedKindTexts.set(e,i)}).catch(()=>{})}kindName(t){const e=this.computedKinds.get(t.id),i=e?this.computedKindTexts.get(e):void 0;if(i?.name)return i.name;const n=t.model.id;if(n==="figure")return this.naming.decorKind("entity");if(!n||t.model.url!==void 0)return;if(!this.bodyModelKinds.has(n)){this.bodyModelKinds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(r=>this.bodyModelKinds.set(n,[r?.kind].flat()[0])).catch(()=>{});return}const s=this.bodyModelKinds.get(n);return s&&this.naming.decorKind(s)||void 0}explainedName(t){if(!t?.length)return;const e=this.ufoElement.sighting.timeline.allKeyframes,i=t.map(n=>{for(const s of e){const r=this.said.read(s.shapes.find(a=>a.sourceId===n)?.shape.title);if(r)return r}}).filter(n=>!!n);return i.length?i.join(", "):void 0}bodyName(t){const e=t.startsWith(eb)?t.slice(eb.length):void 0,i=e?NA.find(s=>s.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(ib)?XS.byId(t.slice(ib.length)):void 0;return n?this.naming.nova(n):this.naming.body(t)}get naming(){return this.sceneNaming}sceneNaming=new VS;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const t=A0(Do.preferencesFor(this),_0);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await H_(t);t===this.namesLanguage&&(this.applySceneNaming(new VS(e)),this.computedKindTexts.clear(),this.loadComputedKindTexts())}setBusy(t,e=""){this.busyElement.hidden=!t,this.busyNote.textContent=t?e:"",this.busyElement.setAttribute("aria-label",e),this.busyElement.setAttribute("aria-busy",String(t))}renderLoaderText(t,e){let i=0;const n=(s,r)=>{s.setAttribute("aria-label",r),s.replaceChildren(),r.split(" ").forEach((a,c)=>{c>0&&s.append(" ");const l=document.createElement("span");l.className="scene-loader-word",l.setAttribute("aria-hidden","true");for(const h of a){const u=document.createElement("span");u.className="scene-loader-letter",u.style.setProperty("--i",String(i++)),u.textContent=h,l.append(u)}s.append(l),i++})};n(this.loaderNotVideo,t),i+=6,n(this.loaderNote,e)}applySceneNaming(t){this.sceneNaming=t,t.loaded&&(this.creditsButton.title=t.names.credits,this.creditsButton.setAttribute("aria-label",t.names.credits),this.renderLoaderText(t.names.notAVideo,t.names.isASimulation),this.sceneRenderer.setCompassPoints(t.names.compassPoints))}showHoverTooltip(t,e){const i=this.hoverTooltip;if(i.textContent=e,i.hidden=!1,typeof i.showPopover=="function"){const u=document.fullscreenElement;i.matches(":popover-open")&&u!==this.tooltipOver&&i.hidePopover(),i.matches(":popover-open")||i.showPopover(),this.tooltipOver=u}const{innerWidth:n,innerHeight:s}=window,r=12,a=4,c=Math.min(t.clientX+r,n-i.offsetWidth-a),l=t.clientY+r,h=l+i.offsetHeight+a>s?t.clientY-r-i.offsetHeight:l;i.style.left=`${Math.max(a,c)}px`,i.style.top=`${Math.max(a,h)}px`}handlePointerLeave=()=>{this.lastHover=void 0,this.hoverTooltip.hidden=!0,this.ghostPath.toggleAttribute("hidden",!0),this.showCompassFor({hovered:!1})};hearDetonations(t,e,i,n){const s=`${i.lat.toFixed(4)},${i.lng.toFixed(4)}`,r=this.detonationsFor;(!r||s!==r.key||t.length!==r.reentries.length||t.some((l,h)=>l!==r.reentries[h]))&&(this.detonationsFor={reentries:[...t],key:s,detonations:t.length?Pt.detonationsOf(t,i):[]});const a=this.detonationsFor.detonations;if(n)return;const c=this.lastDetonationT;if(this.lastDetonationT=e,!(c===void 0||e<c||e-c>ve.DETONATION_JUMP_MS||this.ufoElement.playbackState!=="playing"))for(const l of a)l.t>c&&l.t<=e&&this.weatherAudio.playDetonation(l.loudness)}detonates(t){const e=[...t.skyEvents?.reentries??[],...this.fireballs?.reentries??[]],i=ke(t,0),n=t.event.place?.[0],s=i?.lat??n?.lat,r=i?.lng??n?.lng;return e.length>0&&s!==void 0&&r!==void 0&&Pt.detonationsOf(e,{lat:s,lng:r,heightM:this.altitudeOf(i)}).length>0}detonationsFor;lastDetonationT;static DETONATION_JUMP_MS=2e3;handleLightningFlash(t){if(clearTimeout(this.thunderTimeoutId),this.filmSound){this.filmThunderAtMs=this.lastTimeMs+dn.thunderDelayMs(t)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),dn.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(Jh(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;applyLevel(){if(this.filmSound)return;const t=this.ufoElement.level;this.weatherAudio.setLevel(t),this.vehicleAudio.setLevel(t),this.aircraftAudio?.setLevel(t)}handlePageGesture=()=>{this.ufoElement.playbackState==="playing"&&this.handleFirstInteraction()};unlockIfAlreadyActivated(){this.interacted||navigator.userActivation?.hasBeenActive&&this.handleFirstInteraction()}static GESTURES=["pointerdown","pointerup","touchend","click","keydown"];handleTimeUpdate=t=>{if(this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"){this.sceneRenderer.frame(performance.now());const e=performance.now();this.lastHover&&!this.ghostPath.hasAttribute("hidden")&&e-this.lastPlayingHoverMs>=ve.PLAYING_HOVER_MS&&(this.lastPlayingHoverMs=e,this.ghostStillUnder(this.lastHover,e)&&this.hoverAt(this.lastHover))}this.placeFlightMark(),this.ufoElement.repaintChrome()};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.filming;this.sceneRenderer.setAnimationsRunning(e,e);const i=t||this.filmSound!==void 0;this.weatherAudio.setPaused(!i),this.vehicleAudio.setPaused(!i),this.aircraftAudio?.setPaused(!i),t&&this.unlockIfAlreadyActivated(),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${s3}</style>${n3}`,this.shadow.appendChild(t.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 lt(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(IL));const e=this.shadow.getElementById("scene-loader");this.loaderNote=this.shadow.getElementById("scene-loader-note"),this.loaderNotVideo=this.shadow.getElementById("scene-loader-not-video"),this.busyElement=this.shadow.getElementById("scene-busy"),this.busyNote=this.shadow.getElementById("scene-busy-note"),this.loader=e,this.poster=new td(this.shadow.getElementById("scene-poster"),()=>{this.loader.style.animationDelay=!this.poster.up&&this.holding?"0s":"",this.applyHold()}),this.sceneRenderer.onFirstFrameHold=s=>{this.holding=s,this.applyHold()},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ghostPath=this.shadow.getElementById("ghost-path"),this.flightMark=this.shadow.getElementById("flight-mark"),this.ufoElement=document.createElement(r1),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.ufoElement.observerMapSnapshotSource=s=>this.snapshotMapOf(s),this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",s=>this.lookToward(s.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.creditShownExternally=!0,this.creditsButton=this.shadow.getElementById("credits-button");const i=this.shadow.getElementById("credits-panel"),n=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",s=>{s.newState==="open"&&Zn.fill(n,this)}),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("revealrequest",()=>this.poster.release()),this.ufoElement.addEventListener(Fb,()=>this.poster.restore()),this.ufoElement.seekPreviewPainter=(s,r)=>this.seekPreviewOf(r).paint(s,r),typeof VideoEncoder<"u"&&typeof OffscreenCanvas<"u"&&(this.ufoElement.filmer={film:(s,r,a)=>this.film(s,r,a),generativeKit:(s,r,a)=>this.generativeKit(s,r,a),fileName:()=>this.filmFileName(),kitFileName:()=>this.filmFileName().replace(/\.mp4$/," - kit.zip"),pictureSize:()=>this.filmPictureSize(),hasMap:()=>this.ufoElement.hasObserverMap,durationS:()=>this.ufoElement.seekableDuration/this.filmRate()/1e3,positionS:()=>this.ufoElement.currentTime/this.filmRate()/1e3}),this.ufoElement.addEventListener("mutedchange",()=>this.applyLevel()),this.ufoElement.ambientSound=s=>s.vehicle!==void 0||s.decor.some(r=>r.engine!==void 0)||s.decor.some(r=>id.kindOf(r,this.decorModelSounds.get(r.model?.id??""))!==void 0)||this.interpretationShown?.bodies.some(r=>r.sound)===!0||s.weatherTrack.allKeyframes.some(r=>r.weather.precipitationType!=="none"||r.weather.windSpeed>1)||this.detonates(s),this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.addEventListener("traceview",s=>this.sceneRenderer.setTracesShown(s.detail.shown)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const s of ve.GESTURES)this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Tr(Do.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(t,e){const i=t.vehicle;return!i||!Vn.isRoad(i.kind)?void 0:{setting:Hc.at(i.headlights??"auto",i.headlightKeyframes,e)??"auto",headingDeg:this.travelHeadingAt(t,e)}}travelHeadingAt(t,e){const i=ke(t,e);if(!i)return 0;for(const n of[400,-400]){const s=ke(t,e+n);if(!s||i.lat===void 0||i.lng===void 0||s.lat===void 0||s.lng===void 0)break;const r=ae(s.lat,s.lng,i.lat,i.lng);if(Math.hypot(r.x,r.z)<.8)continue;return(Math.atan2(r.x,-r.z)*180/Math.PI+(n<0?180:0)+360)%360}return i.headingDeg??0}routeCache;routeOf(t){const e=t.allKeyframes;if(this.routeCache?.track===t&&this.routeCache.count===e.length)return this.routeCache.route;const i=e.flatMap(s=>s.pose.lat!==void 0&&s.pose.lng!==void 0?[{lat:s.pose.lat,lng:s.pose.lng}]:[]),n=i.length>=2?i:void 0;return this.routeCache={track:t,count:e.length,route:n},n}traceLabels(t){const e=Do.preferencesFor(this).join();if(this.traceLabelsFor?.traces!==t||this.traceLabelsFor.language!==e){const i=new Map;for(const n of t){const s=this.said.read(n.title);s&&i.set(n.id,s)}this.traceLabelsFor={traces:t,language:e,labels:i}}return this.traceLabelsFor.labels}connectedCallback(){Te.changes.addEventListener("change",this.onModulesChanged),this.saidTexts=void 0,this.ready=this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),this.watchVisibility(),document.addEventListener("fullscreenchange",this.handleFullscreenChange);for(const e of ve.GESTURES)document.addEventListener(e,this.handlePageGesture,!0);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}watchVisibility(){this.visibilityObserver?.disconnect(),!(typeof IntersectionObserver>"u"||this.hasAttribute("always-live"))&&(this.visibilityObserver=new IntersectionObserver(t=>{if(t[t.length-1].isIntersecting){this.sceneRenderer.resume();return}this.ufoElement.pause(),this.sceneRenderer.suspend()},{rootMargin:"100px"}),this.visibilityObserver.observe(this))}visibilityObserver;disconnectedCallback(){Te.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const t of ve.GESTURES)document.removeEventListener(t,this.handlePageGesture,!0);this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.dispose(),this.seekPreview?.dispose(),this.seekPreview=void 0,queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&i!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&i!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&i!==e){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(t===vh||t===yh||t===Tc)&&i!==e&&this.forwardPlayerAttributes(),t===Tc&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const t of[vh,yh,Tc]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.showCompassFor({forced:t})}compassHovered=!1;compassForced=!1;showCompassFor(t){this.compassHovered=t.hovered??this.compassHovered,this.compassForced=t.forced??this.compassForced,this.sceneRenderer.setCompassForced(this.compassForced||this.compassHovered)}lookToward(t){const e=ke(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="observer"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ae(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setOutsideHeard(Vn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}decorScreenBox(t){return this.sceneRenderer.decorScreenBox(t)}decorDrawnOffset(t){return this.sceneRenderer.decorDrawnOffset(t)}decorGroundPointAt(t,e,i,n=0){return this.sceneRenderer.decorGroundPointAt(t,e,i,n)}decorMetresPerNdcY(t){return this.sceneRenderer.decorMetresPerNdcY(t)}decorGrabHeightAt(t,e,i){return this.sceneRenderer.decorGrabHeightAt(t,e,i)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume()}async loadFromSrc(t){const e=sd.recording(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.showPoster(i.image,this.documentUrl,!this.ufoElement.playRequested),this.sightingData=i}loader;poster;showPoster(t,e,i=!0){this.poster.show(t,e,i)}applyHold(){const t=this.holding,e=this.poster.up;this.loader.hidden=!t||e,t&&(this.hoverTooltip.hidden=!0),this.ufoElement.captionHeld=t||e,this.ufoElement.controlsHeld=t||e,this.ufoElement.holdClock(t)}holdForNewScene(t){this.sceneRenderer.holdForNewScene(t)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(t){this.sceneRenderer.documentUrl=t}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){const e=ra.recording(t);this.ufoElement.playerTitle=void 0,this.ufoElement.sightingData=e,this.requireModules(e.modules),this.upperAirHeardLive=void 0,this.seekPreview?.recordingChanged(e),this.showInterpretation(this.inTheRound?this.ufoElement.sighting.interpretation:void 0),this.syncAccountHidden(),this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}onModulesChanged=t=>{t.detail==="skyEvents"&&this.sceneRenderer.setSkyEvents(this.skyEventsShown,!0,this.skyEventsStartDate)};requireModules(t){if(!t?.length)return;const e=this.documentUrl,i=xt(async()=>{const{ModuleSession:n}=await import("./ModuleSession-Dd9RVc7I.js");return{ModuleSession:n}},[],import.meta.url).then(({ModuleSession:n})=>n.shared.require(t,e)).then(()=>this.sceneRenderer.setDecorModelProvider(new bA));this.sceneRenderer.holdUntil(i)}seekPreview;seekPreviewOf(t){const e=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(t.width/e);return t.height!==i&&(t.height=i),this.seekPreview??=new Ep(this,()=>document.createElement(XM))}showAt(t){this.ufoElement.currentTime=t,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(t){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const e=t.getContext("2d");return e?(e.imageSmoothingQuality="high",e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}filmName;filmFileName(){return`${(this.filmName??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim()||"observation"}.mp4`}filming=!1;async film(t,e,i){const[{VideoExport:n},{FilmChrome:s}]=await Promise.all([xt(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),xt(()=>import("./FilmChrome-DYiyzoB_.js"),[],import.meta.url)]),r=await s.loadLogo();return this.filmScene(t,a=>n.film({...a,frameAt:(c,l,h)=>a.frameAt(c,l,h)?(s.paint(h,this.ufoElement.filmChrome(t),r),!0):!1},e,i))}async generativeKit(t,e,i){const[{GenerativeKit:n},{generativeKitMessages:s},{toSightingJson:r}]=await Promise.all([xt(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([16,17,18]),import.meta.url),xt(()=>import("./GenerativeKitMessages-7-3kT9Ef.js"),[],import.meta.url),xt(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url)]),a=A0(Do.preferencesFor(this),_0),[c]=await Promise.all([s.load(a),this.sceneRenderer.loadControlPasses()]),l=this.sceneRenderer.areReferencesShown;this.sceneRenderer.setReferencesShown(!1);try{return await this.filmScene({...t,caption:!1,time:!1,map:!1},h=>n.make({film:h,drawControlPasses:()=>this.sceneRenderer.drawControlPasses(),recording:r(this.ufoElement.sighting),title:this.filmName??"",source:h.about?.source,language:a},c,e,i))}finally{this.sceneRenderer.setReferencesShown(l)}}async filmScene(t,e){if(this.filming)throw new Error("Already filming");const i=this.ufoElement,n=i.currentTime;i.pause();const s={width:this.sceneCanvas.clientWidth,height:this.sceneCanvas.clientHeight},r=t.height&&s.height>0?t.height/s.height:this.sceneRenderer.maxPixelRatio;this.filming=!0,this.sceneRenderer.holdPixelRatio(r),i.filmMap(t.map),this.syncAnimationsToPlayback();try{const a=t.height??this.sceneCanvas.height,c=t.height&&s.height>0?Math.round(t.height*s.width/s.height):this.sceneCanvas.width,l=this.filmRate(),h=Math.min(i.seekableDuration,t.toS!==void 0?t.toS*1e3*l:i.seekableDuration),u=Math.min(h,Math.max(0,(t.fromS??0)*1e3*l));return await e({fromMs:u,toMs:h,rate:l,width:c,height:a,frameAt:(d,f,p)=>this.filmFrameAt(d,f,p),hearInto:d=>this.hearInto(d),about:{title:this.filmName,description:i.filmDescription,source:this.documentUrl?new URL(this.documentUrl,location.href).href:void 0}})}finally{this.filming=!1,this.sceneRenderer.holdPixelRatio(void 0),i.filmMap(void 0),i.currentTime=n,this.syncAnimationsToPlayback()}}filmRate(){const t=this.ufoElement.playbackRate;return t>0?t:1}filmPictureSize(){const t=this.sceneRenderer.maxPixelRatio;return{width:Math.round(this.sceneCanvas.clientWidth*t),height:Math.round(this.sceneCanvas.clientHeight*t)}}filmSound;liveSound;filmThunderAtMs;hearInto(t){if(t){this.liveSound??={weather:this.weatherAudio,vehicle:this.vehicleAudio,aircraft:this.aircraftAudio},this.filmSound=t,this.weatherAudio=new kc(t),this.vehicleAudio=new dy(t);const e=ve.trafficRuntime;this.aircraftAudio=this.liveSound.aircraft&&e?this.newAircraftAudio(e):void 0}else this.liveSound&&(this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.dispose(),this.weatherAudio=this.liveSound.weather,this.vehicleAudio=this.liveSound.vehicle,this.aircraftAudio=this.liveSound.aircraft,this.liveSound=void 0,this.filmSound=void 0,this.filmThunderAtMs=void 0);this.ufoElement.hearInto(t),this.syncAnimationsToPlayback()}filmFrameAt(t,e,i){this.ufoElement.currentTime!==t&&(this.ufoElement.currentTime=t),this.filmThunderAtMs!==void 0&&t>=this.filmThunderAtMs&&(this.filmThunderAtMs=void 0,this.weatherAudio.playThunder()),this.sceneRenderer.render();const n=this.sceneRenderer.framesDrawn;return this.sceneRenderer.frame(e),this.sceneRenderer.framesDrawn===n?!1:(i.drawImage(this.sceneCanvas,0,0,i.canvas.width,i.canvas.height),!0)}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}horizonPointAt(t){const e=t*Math.PI/180,i=this.sceneRenderer.screenPointOf(new _(Math.sin(e),0,-Math.cos(e)));return i&&{x:(i.ndcX+1)/2,y:(1-i.ndcY)/2}}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailure(t){return this.sceneRenderer.referenceFailure(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references){const i=t.views?.[e.id];this.sceneRenderer.setReferenceView(e.id,{opacity:i?i.shown?i.opacity:0:t.opacity})}}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}get currentWaterAttribution(){return this.sceneRenderer.currentWaterAttribution}get currentRailwayAttribution(){return this.sceneRenderer.currentRailwayAttribution}setTerrainProviders(t){this.liveTerrainProviders=t,this.snapshotKey=void 0,this.applySnapshots(this.ufoElement.sighting.snapshots)}liveTerrainProviders;snapshotKey="none";applySnapshots(t){const e=fh.isEmpty(t)?"none":`${JSON.stringify(t)}
|
|
8939
8939
|
${this.documentUrl??""}
|
|
8940
8940
|
${Mi.generation}`;if(e===this.snapshotKey)return;const i=this.snapshotKey!==void 0&&this.traffic?.set!==void 0;this.snapshotKey=e,this.sceneRenderer.setTerrainProviders(_p.providers(t,this.documentUrl,this.liveTerrainProviders??Ob())),this.ufoElement.observerMapSnapshot=this.snapshotMapOf(t),i&&(this.traffic=void 0,this.decorMemo=void 0)}snapshotMapOf(t){const e=fh.held(t,"map");if(!e)return;const i=`${Mi.address(e.src,this.documentUrl)}
|
|
8941
|
-
${Mi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,imagery:_p.map(e,this.documentUrl)}),this.snapshotMap.imagery}snapshotMap;setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return[...new Map(this.sceneRenderer.currentDecorModelCredits.map(e=>[`${e.title}|${e.author??""}|${e.license}|${e.sourceUrl??""}`,e])).values()]}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=di.CANVAS_HEIGHT_PX,i=qi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:Zg,url:this.getAttribute("star-catalog-src")??OL},{magnitudeLimit:Jg,url:this.getAttribute("deep-star-catalog-src")??NL}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>Zg?Jg:Zg;const n=await Xr.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Jg||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=Hn.gainFor(t.instrument,{fNumber:ke(t,0)?.fNumber,fieldOfViewDeg:mn.fovOf(t,0),exposureSeconds:t.exposure});return k0(LL,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=ts.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=Bc.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(t).length,ts.instants(this.decorWithTraffic(this.ufoElement.sighting),ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n),ts.bodyInstants(this.interpretationShown?.bodies??[],ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,t,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=this.ufoElement.sighting.observerTrack.turnIsViewOnly(e.fromMs,t)?t:void 0;this.sceneRenderer.setExposure(r,c=>this.applySceneAt(e.fromMs+e.ms*c/(r-1),{viewAt:a,sky:Math.floor(c*s/r)!==Math.floor((c-1)*s/r),stepMs:e.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:mn.fovOf(this.ufoElement.sighting,t)/e}roadGradeAt(t,e){return t.observerTrack.allKeyframes.length<2?0:Wl.at(t,e,this.sceneRenderer.bodyGround)}get roadGradeDeg(){return this.roadGradeAt(this.ufoElement.sighting,this.ufoElement.currentTime)}applySceneAt(t,e){const i=this.ufoElement.sighting;e||this.sceneRenderer.setRecordingTime(t),this.setWeather(Jh(i,t)),this.sceneRenderer.setInstrument(i.instrument,ke(i,t)?.fNumber),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),e||this.pushAircraftSound(i,t),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(this.seatedDecor(this.decorWithTraffic(i),t)),this.recomputeAmongNewDecor(),this.sceneRenderer.setDecorPresence(this.traffic?.set?.presence??ve.NO_PRESENCE),this.sceneRenderer.setDecorSunlight(this.trafficSunlight(t)),this.sceneRenderer.setContrails(this.traffic?.contrails??ve.NO_CONTRAILS),this.sceneRenderer.setContrailSunlight(this.contrailSunlight(t));const n=ke(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0),e||this.sceneRenderer.setReferencesTime({t,playing:this.ufoElement.playbackState==="playing",timeScale:this.ufoElement.playbackRate});const s=ke(i,0),r=Zh(i,0),a=_l(i.event.time??{},n?.lng??b0.lng,i.event.utcOffsetHours),c=i.weatherSource!==void 0&&a?e3(a):void 0,l=Object.fromEntries(W0(Zh(i,t)).map(P=>[P.id,xy(t,i.weatherTrack,r,s,n,P.id,P.instances?.length?void 0:c)]));this.sceneRenderer.setCloudOffset(xy(t,i.weatherTrack,r,s,n,void 0,c),l);const h=e?.viewAt!==void 0?ke(i,e.viewAt):void 0,u=n&&h?{...n,headingDeg:h.headingDeg,pitchDeg:h.pitchDeg,rollDeg:h.rollDeg,fovDeg:h.fovDeg}:n;this.sceneRenderer.setObserverPose(u?{...u,pitchDeg:u.pitchDeg+this.roadGradeAt(i,e?.viewAt??t)}:b0),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(Hn.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:mn.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0,bc.byId(n?.filter).opticalDensity),this.sceneRenderer.setMedium(Vd.mediumOf(i.instrument.medium,Vd.byId(i.film)),i.exposure,n?.fNumber??i.instrument.fNumber,i.iso,i.metering),this.sceneRenderer.setLensGhosts(Ze.optics(i.instrument,n?.fNumber??i.instrument.fNumber,i.lens,this.glassWettingOf(i).stateAt(t/1e3),t)),this.sceneRenderer.setPerception(Sc.perceptionOf(i.account?.observerPerception)),this.sceneRenderer.setGait(oi.bodyAt(i,t,this.ufoElement.steadyBody)),this.sceneRenderer.updateDecorAnchoring(ke(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.applySnapshots(i.snapshots),this.sceneRenderer.setObserverRoute(this.routeOf(i.observerTrack)),this.sceneRenderer.setObserverHeadlights(this.observerHeadlightsAt(i,t)),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.sceneRenderer.setTraces(i.traces,this.traceLabels(i.traces)),this.pushPhenomenaAt(t);const d=n?.lat??b0.lat,f=n?.lng??b0.lng,p=_l(i.event.time??{},f,i.event.utcOffsetHours),g={lat:d,lng:f,elevationM:this.altitudeOf(n)};this.pushSatellitesAt(p,t,g),this.ensureFireballs(p);const m=this.skyEventsOf(i),M=m?.reentries??[];this.hearDetonations(M,t,{lat:d,lng:f,heightM:g.elevationM},e!==void 0);const v=M.filter(P=>Pt.mayDazzle(P));if(this.sceneRenderer.setRetinaHistory(v.length===0?void 0:P=>{const L=ke(i,P),O={lat:L?.lat??d,lng:L?.lng??f,heightM:L?this.altitudeOf(L):g.elevationM};return{views:Pt.viewsAt(v,P,O),pose:L}},i),this.skyEventsStartDate=p,this.sceneRenderer.setSkyEvents(m,!1,p),m&&this.loadSkyEventTexts(_M.map(P=>Za.of(P)).filter(P=>Za.eventsOf(m,P).length>0&&!this.skyEventTexts.has(P))),e&&!e.sky)return;if(this.sceneRenderer.setSkyUnknown(!p),!p){this.sceneRenderer.setAstronomy(kL);return}const x=new Date(p.getTime()+t),y=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Bc.DEG_PER_SECOND*1e3)),w=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),b=`${Math.floor(x.getTime()/y)}|${Math.round(d/w)}|${Math.round(f/w)}|${Math.round(g.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(b===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=b;const E=Kf("Sun",x,g),S=Kf("Moon",x,g);let A=nn.separationOf(E,S)<1?nn.viewAt(x,g):void 0;if(A){const P=nn.offsetOf(E,S,A.separationDeg);if(A.obscuration>ve.LIMB_FROM_OBSCURATION){const L=this.limbFor(x,g);L&&(A={...A,obscuration:1-cr.uncoveredFraction(L,A.sunRadiusDeg,P),limb:L})}A={...A,horizonShare:nn.horizonShare(A,P,E.altitudeDeg,E.azimuthDeg,na.distanceKm(x,g))}}const R={...E,magnitude:ug("Sun",x)-2.5*Math.log10(nn.beamFraction(A))};this.lastSun={altitudeDeg:R.altitudeDeg,azimuthDeg:R.azimuthDeg};const I={...S,phase:BO(x),magnitude:ug("Moon",x),radiusDeg:na.apparentRadiusDeg(x,g)},D=zO.map(P=>({body:P,position:Kf(P,x,g),magnitude:ug(P,x)}));this.sceneRenderer.setAstronomy({sun:R,moon:I,planets:D,comet:this.cometAt(x,g),novae:XS.appearancesAt(x,g).map(({outburst:P,position:L,magnitude:O})=>({id:P.id,position:L,magnitude:O})),stars:this.starCatalog?{catalog:this.starCatalog,date:x,observer:g}:void 0,frame:{date:x,observer:g},localHour:((x.getUTCHours()+x.getUTCMinutes()/60+(i.event.utcOffsetHours??Math.round(f/15)))%24+24)%24,eclipse:A}),this.ufoElement.setSunAltitude(R.altitudeDeg)}static LIMB_FROM_OBSCURATION=.98;limbRelief;limbRequested=!1;limbCache;limbFor(t,e){if(!this.limbRelief){this.limbRequested||(this.limbRequested=!0,Qu.load(PL).then(s=>{this.limbRelief=s,this.lastSkyKey="",s&&this.isConnected&&this.updateAstronomy(this.lastTimeMs)}));return}const i=this.limbCache;if(i&&Math.abs(t.getTime()-i.atMs)<5e3&&i.lat===e.lat&&i.lng===e.lng&&i.elevationM===e.elevationM)return i.profile;const n=cr.profile(t,e,this.limbRelief);return this.limbCache={profile:n,atMs:t.getTime(),lat:e.lat,lng:e.lng,elevationM:e.elevationM},n}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const r of this.satellites.passes.positionsAt(n,i,-1))r.magnitude!==void 0&&s.push({norad:r.object.norad,name:r.object.name,position:{altitudeDeg:r.altitudeDeg,azimuthDeg:r.azimuthDeg},magnitude:r.magnitude,heightKm:r.heightKm});this.sceneRenderer.setSatellites(s)}ensureFireballs(t){const e=this.ufoElement.sighting,i=Math.max((e.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),n=t?.getTime(),s=e.skySources!==!1,r=n===void 0||!s?"":`${n}+${i}`;if(this.fireballs?.key===r)return;if(!s){this.fireballs={key:r,status:"outside",reentries:[]};return}if(n===void 0||!sa.mayCover(n+i)){this.fireballs={key:r,status:"outside",reentries:[]};return}const a={key:r,status:"loading",reentries:[]};this.fireballs=a,ve.fireballArchive.between(n,n+i).then(c=>{a.status=c?"ready":"unavailable",a.records=c??[],a.reentries=a.records.map(l=>sa.asReentry(l,n)),!(this.fireballs!==a||!this.isConnected)&&(this.dispatchEvent(new CustomEvent(RL)),a.reentries.length>0&&this.updateAstronomy(this.lastTimeMs))})}decorWithTraffic(t){const e=this.ensureTraffic(t);if(!e||e.objects.length===0)return t.decor;const i=this.decorMemo;if(i&&i.base===t.decor&&i.traffic===e.objects)return i.merged;const n=[...t.decor,...e.objects];return this.decorMemo={base:t.decor,traffic:e.objects,merged:n},n}seatedDecor(t,e){if(!t.some(r=>r.observerKeyframes?.length))return t;const i=t.map(r=>{if(!r.observerKeyframes?.length)return"";const a=my(r,e);return`${a.side??"-"}/${a.facing??"-"}`}).join("|"),n=this.seatedMemo;if(n&&n.base===t&&n.seats===i)return n.seated;const s=t.map(r=>{if(!r.observerKeyframes?.length)return r;const a=my(r,e);return{...r,observerSide:a.side,observerFacing:a.facing}});return this.seatedMemo={base:t,seats:i,seated:s},s}ensureTraffic(t){const e=ke(t,0),i=e?.lng===void 0?void 0:_l(t.event.time??{},e.lng,t.event.utcOffsetHours),n=Math.max((t.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),s=i?.getTime(),r=s===void 0||e?.lat===void 0||e.lng===void 0?"":`${this.aircraftSource.id}|${s}+${n}|${e.lat.toFixed(3)},${e.lng.toFixed(3)}|${Math.round(e.elevationM??0)}|${Math.round(this.sceneRenderer.groundAltitudeM)}`;if(this.traffic?.key===r)return this.traffic.set;if(this.upperAirHeardLive=void 0,r===""||s===void 0||e?.lat===void 0||e.lng===void 0){this.traffic={key:r,status:"outside"};return}let a=ve.aircraftProviders.get(this.aircraftSource.id);if(a||ve.aircraftProviders.set(this.aircraftSource.id,a=this.aircraftSource.create()),a.mayCover&&!a.mayCover(s+n)){this.traffic={key:r,status:"outside"};return}const c={key:r,status:"loading",startMs:s,observer:{lat:e.lat,lng:e.lng}};this.traffic=c;const l={lat:e.lat,lng:e.lng,heightM:this.sceneRenderer.groundAltitudeM},h=On.MAX_GAP_S*1e3,u=ve.SOUND_LOOKBACK_MS,d={lat:e.lat,lng:e.lng,elevationM:this.altitudeOf(e)},f=(p,g)=>p.TrafficDecor.from(c.tracks??[],l,s,p.TrafficDecor.MAX_OBJECTS,{models:g,sunElevationAt:m=>this.sunElevationAt(m,d)});a.between(l,s-u,s+n+h).then(async p=>{if(this.traffic!==c)return;if(p.status!=="found"){c.status=p.status==="outside"?"outside":"unavailable",p.status==="failed"&&(c.problem=p.problem,c.creditsSpent=p.creditsSpent),this.announceTraffic();return}let g;try{g=await ve.loadTrafficRuntime()}catch{this.traffic===c&&(c.status="unavailable",this.announceTraffic());return}this.traffic===c&&(c.status="ready",c.tracks=p.tracks,c.partial=p.partial,c.creditsSpent=p.creditsSpent,c.set=f(g),this.startAircraftSound(c,g),this.announceTraffic(),this.describeTraffic(a,c,g,f),c.set.shown>0&&(this.readUpperAir(c,g,s-u,s+n+h),this.readTrailTraffic(a,c,g,l,s-ve.TRAIL_LOOKBACK_MS,s+n+h)))})}trafficSunlight(t){const e=new Map,i=this.traffic,n=i?.set,s=this.lastSun;if(!n||!s||i.startMs===void 0||!i.observer)return e;for(const[r,a]of n.presence){if(t<a.fromMs||t>a.untilMs)continue;const c=n.flights.get(r),l=c?On.positionAt(c,i.startMs+t):void 0;l&&e.set(r,{heightM:l.geo.heightM,sunElevationDeg:vs.sunElevationDeg(s,i.observer,l.geo)})}return e}trafficTooltipAt(t,e){const i=this.sceneRenderer.pickTrafficAt(t,e),n=i?this.trafficInfoAt(i):void 0;if(!n)return;const s=this.naming;return ve.trafficRuntime?.TrafficTooltip.text(n,s.names.trafficTooltip,a=>s.towards(a))}trafficInfoAt(t){const e=this.traffic,i=e?.set?.flights.get(t);if(!e||!i||e.startMs===void 0||!e.observer)return;const n=ve.trafficRuntime;if(!n)return;const s=e.descriptions?.get(Je.keyOf(i)),r=ke(this.ufoElement.sighting,this.lastTimeMs),a={lat:e.observer.lat,lng:e.observer.lng,heightM:this.altitudeOf(r)},c=n.AmbientNoise.dbA(Jh(this.ufoElement.sighting,this.lastTimeMs)),l=n.TrafficInfos.at(i,s,a,e.startMs+this.lastTimeMs,{ambientDbA:c}),h=l&&this.contrailAt(t,this.lastTimeMs);return l&&h?{...l,contrail:h}:l}contrailAt(t,e){const i=this.traffic?.contrails?.find(s=>s.id===t);if(!i)return;let n;for(const s of i.points){if(s.tMs>e)break;n=s}return n?.forms?{persistent:n.persistent,iceRelativeHumidity:n.iceRelativeHumidity}:void 0}startAircraftSound(t,e){this.aircraftAudio??=this.newAircraftAudio(e),this.sortOutAudible(t,e)}sortOutAudible(t,e){!t.set||!t.observer||(t.audible=e.TrafficSound.candidates(t.set.flights,t.descriptions??new Map,Je.keyOf,{...t.observer,heightM:this.sceneRenderer.groundAltitudeM},{ambientDbA:e.AmbientNoise.BASE_DB_A}))}pushAircraftSound(t,e){this.startDecorAircraftSound(t),this.startBodySound(),this.startRideSound(t);const i=this.aircraftAudio;if(!i)return;const n=ve.trafficRuntime;if(!n){i.setVoices([]);return}const s=ke(t,e),r=Jh(t,e),a={ambientDbA:n.AmbientNoise.dbA(r),referenceAmplitude:n.AmbientNoise.referenceAmplitude(r)},c=t.vehicle,l=c?n.CabinHearing.voice(c,a):void 0,h={...a,ambientDbA:Math.max(a.ambientDbA,l?.levelDbA??0),...c?{throughDb:Vn.insulationDb(c)}:{}},u=this.trafficVoices(e,s,h,n),d=t.event.place?.[0],f={lat:s?.lat??d?.lat,lng:s?.lng??d?.lng};f.lat!==void 0&&f.lng!==void 0&&(this.decorAircraftHearing??=new n.DecorAircraftHearing,u.push(...this.decorAircraftHearing.voices(t,e,{lat:f.lat,lng:f.lng,heightM:s?.elevationM??0},h,p=>this.decorModelSounds.get(p.model?.id??""))),u.push(...this.bodyVoices(t,e,h,n)),l&&u.push(l),u.sort((p,g)=>g.levelDbA-p.levelDbA),u.length=Math.min(u.length,4)),i.setVoices(u,s?.headingDeg??0)}startRideSound(t){this.aircraftAudio||Vn.aircraftOf(t.vehicle)===void 0||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}startBodySound(){this.aircraftAudio||!this.interpretationShown?.bodies.some(t=>t.sound)||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}bodyVoices(t,e,i,n){const s=this.interpretationShown,r=t.event.place?.[0];if(!s||!r||!s.bodies.some(f=>f.sound))return[];const a=this.sceneRenderer.bodyGround,c=f=>Lt.eyeOf(t,f,a),l=c(e);if(!l)return[];const h=new Map,u=(f,p)=>{let g=h.get(f.id);return g||h.set(f.id,g=new Lt(f,a,c)),g.at(p)};this.bodyHearing??=new n.BodyHearing;const d=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3);return this.bodyHearing.voices(s.bodies,u,l,r,e,d,i)}trafficVoices(t,e,i,n){const s=this.traffic,r=s?.set;if(!s||!r||!s.audible||s.startMs===void 0||!s.observer)return[];const a={lat:s.observer.lat,lng:s.observer.lng,heightM:this.altitudeOf(e)};return n.TrafficSound.voices(s.audible,r.flights,s.descriptions??new Map,Je.keyOf,a,s.startMs+t,i)}startDecorAircraftSound(t){const e=t.decor.filter(i=>i.kind==="aircraft"&&i.track?.some(n=>(n.altitudeM??0)>0));if(e.length!==0){for(const i of e){const n=i.model?.id;!n||i.model?.url!==void 0||this.decorModelSounds.has(n)||(this.decorModelSounds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(s=>{this.decorModelSounds.set(n,s?.parameters?.sound),this.ufoElement.refreshSoundControls()}))}if(this.aircraftAudio||ve.trafficRuntime){!this.aircraftAudio&&ve.trafficRuntime&&(this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime));return}ve.loadTrafficRuntime().catch(()=>{})}}newAircraftAudio(t){const e=new t.AircraftAudio(this.filmSound);return this.filmSound||e.setLevel(this.ufoElement.level),(this.interacted||this.filmSound)&&e.resume(),e.setPaused(this.ufoElement.playbackState!=="playing"&&!this.filmSound),e}get aircraftFlights(){return[...this.declaredFlights,...this.recordedFlights]}get declaredFlights(){return this.ufoElement.sighting.decor.filter(t=>t.kind==="aircraft"&&id.flies(t)).map(t=>{const e=this.sceneRenderer.decorSkyPoint(t.id);return{key:Je.declaredKeyOf(t.id),type:this.said.read(t.title)||this.naming.decorKind(t.kind),sky:e?.sky,altitudeFt:e?e.altitudeM/.3048:void 0,firstMs:0,drawn:e!==void 0,declared:!0}})}get recordedFlights(){const t=this.traffic;if(!t?.tracks||t.startMs===void 0||!t.observer)return[];const e=t.startMs,i=this.observerAt(this.lastTimeMs,t.observer),n=new Set([...t.set?.flights.values()??[]].map(a=>Je.keyOf(a))),s=t.nearestPassKm??=new Map(t.tracks.map(a=>[Je.keyOf(a),Math.min(...a.points.map(c=>On.groundDistanceKm(t.observer,c)))])),r=this.ufoElement.seekableDuration;return[...t.tracks].sort((a,c)=>s.get(Je.keyOf(a))-s.get(Je.keyOf(c))).map(a=>{const c=Je.keyOf(a),l=t.descriptions?.get(c),h=t.models?.get(c),u=On.seenFrom(a,i,e+this.lastTimeMs),d=a.points.find(f=>f.t>=e)?.t;return{key:c,type:h?.basis==="type"?h.name:l?.type,registration:l?.registration,sky:u?.sky,altitudeFt:u?.altitudeFt,firstMs:d!==void 0&&d-e<=r?d-e:void 0,drawn:n.has(c)}})}lookAtFlight(t,e=this.lastTimeMs){const i=this.traffic,n=ke(this.ufoElement.sighting,e),s=Je.declaredIdOf(t);if(s!==void 0){const c=this.sceneRenderer.decorSkyPoint(s);return!c||n?.headingDeg===void 0?!1:(this.setLookOffset(((c.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,c.sky.altitudeDeg-(n.pitchDeg??0)),!0)}const r=i?.tracks?.find(c=>Je.keyOf(c)===t);if(!i?.observer||i.startMs===void 0||!r||n?.headingDeg===void 0)return!1;const a=On.seenFrom(r,this.observerAt(e,i.observer),i.startMs+e);return a?(this.setLookOffset(((a.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,a.sky.altitudeDeg-(n.pitchDeg??0)),!0):!1}markFlight(t){this.markedFlight=t,this.placeFlightMark()}placeFlightMark(){const t=this.markedFlight,e=t===void 0?void 0:this.sceneRenderer.flightScreenPoint(t);if(this.flightMark.toggleAttribute("hidden",!e),!e)return;const i=this.sceneCanvas.getBoundingClientRect(),n=this.stageElement.getBoundingClientRect(),s=i.left-n.left+(e.ndcX+1)/2*i.width,r=i.top-n.top+(1-e.ndcY)/2*i.height;for(const a of Array.from(this.flightMark.children))a.setAttribute("cx",String(s)),a.setAttribute("cy",String(r))}altitudeOf(t){return this.sceneRenderer.groundAltitudeM+(t?.elevationM??0)}observerAt(t,e){const i=ke(this.ufoElement.sighting,t);return{lat:i?.lat??e.lat,lng:i?.lng??e.lng,heightM:this.altitudeOf(i)}}announceTraffic(){this.isConnected&&(this.dispatchEvent(new CustomEvent(DL)),this.updateAstronomy(this.lastTimeMs))}async describeTraffic(t,e,i,n){if(!t.describe||!e.set||!e.tracks)return;const s=new Set([...e.set.flights.values()].map(l=>Je.keyOf(l))),r=e.tracks.filter(l=>s.has(Je.keyOf(l))&&l.points.length>0),a=new Map,c=new Map;await Promise.all(r.map(async l=>{const h=new Date(l.points[0].t).toISOString().slice(0,10),u=await t.describe(l,h).catch(()=>{});u&&(c.set(Je.keyOf(l),u),a.set(Je.keyOf(l),i.AircraftModels.of(u)))})),!(this.traffic!==e||a.size===0)&&(e.descriptions=c,e.models=a,e.set=n(i,a),this.planContrails(e,i),this.sortOutAudible(e,i),this.announceTraffic())}async readTrailTraffic(t,e,i,n,s,r){if(e.startMs===void 0)return;const a=await t.between(n,s,r).catch(()=>{});if(this.traffic!==e||a?.status!=="found")return;const c=a.tracks.filter(u=>u.points.some(d=>d.altitudeFt>=i.AircraftContrails.MIN_ALTITUDE_FT)),l=new Map(e.models??[]);if(t.describe&&await Promise.all(c.filter(u=>u.points.length>0&&!l.has(Je.keyOf(u))).map(async u=>{const d=await t.describe(u,new Date(u.points[0].t).toISOString().slice(0,10)).catch(()=>{});d&&l.set(Je.keyOf(u),i.AircraftModels.of(d))})),this.traffic!==e||e.startMs===void 0)return;const h=i.TrafficDecor.from(c,n,e.startMs,ve.TRAIL_MAX_AIRCRAFT,{models:l});e.trailSet=ve.alignTrailIds(h,e.set),e.models=new Map([...l,...e.models??[]]),this.planContrails(e,i),this.announceTraffic()}static alignTrailIds(t,e){if(!e)return t;const i=new Map;for(const[a,c]of e.flights){const l=e.presence.get(a);if(l)for(const[h,u]of t.flights){const d=t.presence.get(h);!d||Je.keyOf(u)!==Je.keyOf(c)||d.fromMs<=l.untilMs&&l.fromMs<=d.untilMs&&i.set(h,a)}}const n=a=>i.get(a)??`${a}-trail`,s=new Set(i.values()),r=e.objects.filter(a=>!s.has(a.id));return{...t,objects:[...t.objects.map(a=>({...a,id:n(a.id)})),...r],presence:new Map([...[...t.presence].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.presence.get(a.id)])]),flights:new Map([...[...t.flights].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.flights.get(a.id)])])}}async readUpperAir(t,e,i,n){if(!t.observer)return;const s=fh.held(this.ufoElement.sighting.snapshots,"upperAir");let r;if(s){const l=Mi.address(s.src,this.documentUrl);r=ve.upperAirProviders.get(l),r||ve.upperAirProviders.set(l,r=new hh(Mi.json(l)))}else{const l=this.upperAirSource??e.UPPER_AIR_SOURCES[0];r=ve.upperAirProviders.get(l.id),r||ve.upperAirProviders.set(l.id,r=l.create())}const a={lat:t.observer.lat,lng:t.observer.lng},c=await r.between(a,i,n);this.traffic!==t||c.status!=="found"||(s||(this.upperAirHeardLive={...a,startMs:i,endMs:n,answer:c}),t.air=c.samples,t.airSource=c.source,this.planContrails(t,e),this.announceTraffic())}planContrails(t,e){const i=t.trailSet??t.set;!i||!t.air||t.startMs===void 0||(t.contrails=e.AircraftContrails.plan(i,t.models,t.air,t.startMs))}contrailSunlight(t){const e=new Map,i=this.traffic,n=i?.trailSet??i?.set,s=this.lastSun;if(!i||!n||!s||!i.contrails?.length||i.startMs===void 0||!i.observer)return e;for(const r of i.contrails){const a=n.presence.get(r.id),c=n.flights.get(r.id);if(!a||!c)continue;const l=On.positionAt(c,i.startMs+Math.min(a.untilMs,Math.max(a.fromMs,t)));l&&e.set(r.id,{heightM:l.geo.heightM,sunElevationDeg:vs.sunElevationDeg(s,i.observer,l.geo)})}return e}sunElevationAt(t,e){const i=Kf("Sun",new Date(t.t),e);return vs.sunElevationDeg(i,e,t)}upperAirSource;upperAirHeardLive;get upperAirHeard(){return this.upperAirHeardLive}setUpperAirSource(t){t.id!==this.upperAirSource?.id&&(this.upperAirSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}setAircraftSource(t,e=!1){!e&&t.id===this.aircraftSource.id||(this.aircraftSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}get aircraftState(){const t=this.traffic?.contrails?.length?this.upperAirSource??ve.trafficRuntime?.UPPER_AIR_SOURCES[0]:void 0;return{trailCredit:t&&{credit:t.credit,creditUrl:t.creditUrl},status:this.traffic?.status??"none",problem:this.traffic?.problem,partial:this.traffic?.partial,creditsSpent:this.traffic?.creditsSpent,total:this.traffic?.set?.total??0,shown:this.traffic?.set?.shown??0,credit:this.aircraftSource.credit,creditUrl:this.aircraftSource.creditUrl}}get fireballState(){return{status:this.fireballs?.status??"none",records:this.fireballs?.records??[]}}ensureSatellites(t){this.ufoElement.sighting.skySources===!1&&(t=void 0);const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.isConnected&&this.dispatchEvent(new CustomEvent(TL)))},s=ve.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[r,a]=await Promise.all([s.at(t),xt(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return n("unavailable");this.satellites={snapshot:r,passes:new a.SatellitePasses(r.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}burningCandidates(){return{reentries:this.ufoElement.sighting.skyEvents?.reentries??[],fireballs:this.fireballs?.reentries??[]}}trafficCandidates(){const t=this.traffic;if(!(t?.status!=="ready"||!t.tracks||t.startMs===void 0))return{tracks:t.tracks,startMs:t.startMs,describe:e=>t.descriptions?.get(Je.keyOf(e))}}satellitePositionsAt(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!(!e||r===void 0||a===void 0))return e.passes.positionsAt(t,{lat:r,lng:a,elevationM:this.altitudeOf(n)})}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!e||r===void 0||a===void 0)return[];const c=_l(i.event.time??{},a,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:r,lng:a,elevationM:this.altitudeOf(n)},u=JSON.stringify([this.satellitesFor,c.getTime(),r,a,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=mL.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}approachOf(t,e){return this.approaches.of.has(e)||this.approaches.of.set(e,ed.of(t,e)),this.approaches.of.get(e)}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=JSON.stringify([e.timeline.allKeyframes.map(g=>[g.t,g.shapes.map(m=>[m.sourceId,m.shape.angular?.widthDeg,m.shape.aim?.azimuthDeg])]),e.observerTrack.allKeyframes,e.event.place?.[0]]);i!==this.approaches.key&&(this.approaches={key:i,of:new Map});const n=e.timeline,s=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),c=new Map,l=new Map,h=new Set;for(const g of n.sourceIds){const m=n.getInterpolatedShapeAt(t,g);if(!m)continue;const M={...m,bounds:{...m.bounds,x:m.bounds.x+r.x,y:m.bounds.y+r.y}};c.set(g,M);const v=m.aim?this.sceneRenderer.screenPointOf(Cs.directionOf(m.aim,this.directionScratch)):{ndcX:(M.bounds.x+M.bounds.width/2)/s.width*2-1,ndcY:-((M.bounds.y+M.bounds.height/2)/s.height*2-1)},x=v!==void 0&&Math.abs(v.ndcX)<=1&&Math.abs(v.ndcY)<=1,y=x?this.sceneRenderer.decorDistancesAt(v.ndcX,v.ndcY,g):{};h.add(g),(x||m.aim)&&h.delete(g);const w=m.angular?.widthDeg??a.pxToDeg(m.bounds.width),b=this.sizeEstimateOf(g);b.add(w,y);const E=this.approachOf(e,g);l.set(g,ms.resolve({hypothesisM:this.distanceHypotheses.get(g),derivedM:E&&w>0?di.distanceMAt(E.widthM,w):void 0,range:b.distanceRangeAt(w),crossing:y}))}for(const[g,m]of c)for(const[M,v]of c){if(M===g||v.transparency>=1||v.bounds.width*v.bounds.height<=m.bounds.width*m.bounds.height||!(m.bounds.x>=v.bounds.x&&m.bounds.y>=v.bounds.y&&m.bounds.x+m.bounds.width<=v.bounds.x+v.bounds.width&&m.bounds.y+m.bounds.height<=v.bounds.y+v.bounds.height))continue;const y=l.get(M);y&&l.set(g,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=l;const u=n.sourceIds,d=[];for(const[g,m]of c)d.push({sourceId:g,shape:m,distanceM:l.get(g).distanceM,renderOrder:u.indexOf(g),aim:m.aim,hidden:h.has(g)||this.interpretationShown!==void 0&&(!this.comparing||m.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=ke(e,t),p=(f?.rollDeg??0)+oi.bodyAt(e,t,this.ufoElement.steadyBody).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:s.width,canvasHeightPx:s.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,s.height)),starPoints:qi.starPointsOf(e.instrument,f?.fNumber),rollRad:p*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.showInterpretation(t),this.ufoElement.playerTitle=t?.title,this.ufoElement.refreshSoundControls(),this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome()}redrawSky(){this.updateAstronomy(this.lastTimeMs)}syncAccountHidden(){this.ufoElement.accountHidden=this.interpretationShown!==void 0&&!this.comparing}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){t!==this.comparing&&(this.comparing=t,this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=Lt.eyeOf(this.ufoElement.sighting,i,n);return s?Lt.lineOfSightMeetsGround(s,t,e,n):void 0}bodyMaskedBy(t,e){return this.sceneRenderer.bodyMaskedByDecor(t,e)}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>Lt.eyeOf(n,d,i),r=new Lt(t,i,s).at(e),a=s(e);if(!r||!a)return;const c=r.eastM-a.eastM,l=r.northM-a.northM,h=r.upM-a.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:r.eastM,northM:r.northM,aboveGroundM:r.upM-r.sizeM.heightM/2-i.heightAt(r.eastM,r.northM),sizeM:r.sizeM,attitude:r.attitude,appearance:r.appearance}}bodyProjectionAt(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=c=>Lt.eyeOf(n,c,i),r=new Lt(t,i,s).at(e),a=s(e);return r&&a?mi.projectionOf(r,a):void 0}directionToDecor(t){return this.sceneRenderer.directionToDecor(t)}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>Lt.eyeOf(n,p,i),r=new Lt(t,i,s),a=r.at(e)?e:t.track[0]?.t,c=a===void 0?void 0:r.at(a),l=a===void 0?void 0:s(a);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],r=[];const a=this.sceneRenderer.bodyGround,c=p=>Lt.eyeOf(n,p,a);i&&(s=i.bodies.map(p=>new Lt(p,a,c).at(t)).filter(p=>p!==void 0));const l=Zh(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(r=new mi(n.timeline,this.confrontationTolerance).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=r,!e)return;const f=JSON.stringify(r);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(CL,{detail:r})))}async pictureAt(t,e=640){const i=document.createElement("canvas");i.width=e,i.height=Math.round(e*(this.sceneCanvas.height||9)/(this.sceneCanvas.width||16));let n=!1;for(const s of[1200,0]){this.showAt(t),n=!1;for(let r=0;r<900&&!n;r++)await new Promise(a=>requestAnimationFrame(()=>a())),n=this.snapshotTo(i);if(!n)return;s&&await new Promise(r=>setTimeout(r,s))}return i.toDataURL("image/jpeg",.85)}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(r=>r.t>n&&r.t<=e).pop();s&&Zh(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Zh(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],r=n?.year!==void 0?_l(n,s?.lng??0,t.event.utcOffsetHours):void 0,a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((r?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=dn.schedule({durationMs:a,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration,t.skySources])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?_l(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0||t.skySources===!1){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},r=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,a=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=Ki.schedule({ratePerHour:Ki.observedRatePerHour(Ki.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:Ki.TYPICAL_VELOCITY_KM_S,seed:a}),l=Qg.activeAt(n).map(u=>{const d=Qg.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:Qg.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=hr.schedule({ratePerHour:l.rate,durationMs:r,velocityKmS:l.entry.shower.velocityKmS,seed:a+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}groundHides(t,e){return this.sceneRenderer.groundHidesDirection(t,e)}get groundKey(){return this.sceneRenderer.groundKey}meteorByRank(t,e=Number.POSITIVE_INFINITY){this.ensureMeteorSchedule(this.ufoElement.sighting);const i=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).filter(r=>hr.magnitudeOf(r)<=e).filter(r=>{const a=this.sceneRenderer.meteorMidpoint(r);return a!==void 0&&!this.sceneRenderer.groundHidesDirection(a.altitudeDeg,a.azimuthDeg)}).sort((r,a)=>a.brightness-r.brightness);if(i.length===0)return;const n=i[t%i.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=ke(e,t),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const a=qi.focalLengthMmFor(i,mn.fovOf(e,t));if(a!==void 0)return{focalLengthMm:a,fNumber:r,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return ca.of(e.instrument,di.CANVAS_HEIGHT_PX,mn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new ML,this.sizeEstimates.set(t,e)),e}}const XM="rr0-scene";function FL(){kb(),customElements.get(XM)||customElements.define(XM,ve)}FL();export{ws as $,Zs as A,we as B,at as C,id as D,to as E,pe as F,We as G,Ve as H,jL as I,HL as J,$_ as K,Dw as L,Te as M,Y1 as N,Vn as O,Qt as P,Ys as Q,Pt as R,Gu as S,Je as T,xR as U,_ as V,qe as W,zu as X,ic as Y,Hl as Z,xt as _,On as a,$d as a$,Sn as a0,ZL as a1,Hc as a2,_n as a3,Si as a4,ii as a5,Ji as a6,Xn as a7,yp as a8,ls as a9,sE as aA,qs as aB,of as aC,wm as aD,O5 as aE,Zo as aF,f1 as aG,Zi as aH,ba as aI,zT as aJ,ui as aK,GL as aL,WL as aM,oE as aN,XL as aO,js as aP,aE as aQ,Rx as aR,OT as aS,AA as aT,J0 as aU,W1 as aV,SE as aW,Ev as aX,Av as aY,ze as aZ,ya as a_,YL as aa,Ln as ab,zn as ac,Oi as ad,on as ae,us as af,Ni as ag,Id as ah,xr as ai,Xl as aj,xL as ak,Qv as al,wL as am,UL as an,BL as ao,zL as ap,qd as aq,JL as ar,$L as as,tp as at,EE as au,op as av,VL as aw,cx as ax,qL as ay,QL as az,Db as b,Ct as b0,wn as b1,De as b2,Yr as b3,Tr as b4,Do as b5,A0 as b6,lr as b7,_0 as b8,gs as b9,Ss as bA,hs as bB,Xh as bC,ji as bD,ma as ba,wi as bb,jo as bc,Hd as bd,mt as be,XP as bf,Eh as bg,Wt as bh,th as bi,Dv as bj,Ht as bk,br as bl,sa as bm,Qg as bn,Kf as bo,H_ as bp,_l as bq,ke as br,Cn as bs,S_ as bt,Zh as bu,Bi as bv,tb as bw,bv as bx,Yo as by,xa as bz,Qs as c,bR as d,Vt as e,Cb as f,Wn as g,Ar as h,Re as i,tt as j,ae as k,ks as l,ft as m,Me as n,Ga as o,ye as p,mr as q,da as r,t7 as s,sp as t,KL as u,Ge as v,pr as w,Ie as x,Zr as y,St as z};
|
|
8941
|
+
${Mi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,imagery:_p.map(e,this.documentUrl)}),this.snapshotMap.imagery}snapshotMap;setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return[...new Map(this.sceneRenderer.currentDecorModelCredits.map(e=>[`${e.title}|${e.author??""}|${e.license}|${e.sourceUrl??""}`,e])).values()]}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=di.CANVAS_HEIGHT_PX,i=qi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:Zg,url:this.getAttribute("star-catalog-src")??OL},{magnitudeLimit:Jg,url:this.getAttribute("deep-star-catalog-src")??NL}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>Zg?Jg:Zg;const n=await Xr.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Jg||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=Hn.gainFor(t.instrument,{fNumber:ke(t,0)?.fNumber,fieldOfViewDeg:mn.fovOf(t,0),exposureSeconds:t.exposure});return k0(LL,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=ts.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=Bc.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(t).length,ts.instants(this.decorWithTraffic(this.ufoElement.sighting),ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n),ts.bodyInstants(this.interpretationShown?.bodies??[],ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,t,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=this.ufoElement.sighting.observerTrack.turnIsViewOnly(e.fromMs,t)?t:void 0;this.sceneRenderer.setExposure(r,c=>this.applySceneAt(e.fromMs+e.ms*c/(r-1),{viewAt:a,sky:Math.floor(c*s/r)!==Math.floor((c-1)*s/r),stepMs:e.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:mn.fovOf(this.ufoElement.sighting,t)/e}roadGradeAt(t,e){return t.observerTrack.allKeyframes.length<2?0:Wl.at(t,e,this.sceneRenderer.bodyGround)}get roadGradeDeg(){return this.roadGradeAt(this.ufoElement.sighting,this.ufoElement.currentTime)}applySceneAt(t,e){const i=this.ufoElement.sighting;e||this.sceneRenderer.setRecordingTime(t),this.setWeather(Jh(i,t)),this.sceneRenderer.setInstrument(i.instrument,ke(i,t)?.fNumber),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),e||this.pushAircraftSound(i,t),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(this.seatedDecor(this.decorWithTraffic(i),t)),this.recomputeAmongNewDecor(),this.sceneRenderer.setDecorPresence(this.traffic?.set?.presence??ve.NO_PRESENCE),this.sceneRenderer.setDecorSunlight(this.trafficSunlight(t)),this.sceneRenderer.setContrails(this.traffic?.contrails??ve.NO_CONTRAILS),this.sceneRenderer.setContrailSunlight(this.contrailSunlight(t));const n=ke(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0),e||this.sceneRenderer.setReferencesTime({t,playing:this.ufoElement.playbackState==="playing",timeScale:this.ufoElement.playbackRate});const s=ke(i,0),r=Zh(i,0),a=_l(i.event.time??{},n?.lng??b0.lng,i.event.utcOffsetHours),c=i.weatherSource!==void 0&&a?e3(a):void 0,l=Object.fromEntries(W0(Zh(i,t)).map(P=>[P.id,xy(t,i.weatherTrack,r,s,n,P.id,P.instances?.length?void 0:c)]));this.sceneRenderer.setCloudOffset(xy(t,i.weatherTrack,r,s,n,void 0,c),l);const h=e?.viewAt!==void 0?ke(i,e.viewAt):void 0,u=n&&h?{...n,headingDeg:h.headingDeg,pitchDeg:h.pitchDeg,rollDeg:h.rollDeg,fovDeg:h.fovDeg}:n;this.sceneRenderer.setObserverPose(u?{...u,pitchDeg:u.pitchDeg+this.roadGradeAt(i,e?.viewAt??t)}:b0),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(Hn.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:mn.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0,bc.byId(n?.filter).opticalDensity),this.sceneRenderer.setMedium(Vd.mediumOf(i.instrument.medium,Vd.byId(i.film)),i.exposure,n?.fNumber??i.instrument.fNumber,i.iso,i.metering),this.sceneRenderer.setLensGhosts(Ze.optics(i.instrument,n?.fNumber??i.instrument.fNumber,i.lens,this.glassWettingOf(i).stateAt(t/1e3),t)),this.sceneRenderer.setPerception(Sc.perceptionOf(i.account?.observerPerception)),this.sceneRenderer.setGait(oi.bodyAt(i,t,this.ufoElement.steadyBody)),this.sceneRenderer.updateDecorAnchoring(ke(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.applySnapshots(i.snapshots),this.sceneRenderer.setObserverRoute(this.routeOf(i.observerTrack)),this.sceneRenderer.setObserverHeadlights(this.observerHeadlightsAt(i,t)),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.sceneRenderer.setTraces(i.traces,this.traceLabels(i.traces)),this.pushPhenomenaAt(t);const d=n?.lat??b0.lat,f=n?.lng??b0.lng,p=_l(i.event.time??{},f,i.event.utcOffsetHours),g={lat:d,lng:f,elevationM:this.altitudeOf(n)};this.pushSatellitesAt(p,t,g),this.ensureFireballs(p);const m=this.skyEventsOf(i),M=m?.reentries??[];this.hearDetonations(M,t,{lat:d,lng:f,heightM:g.elevationM},e!==void 0);const v=M.filter(P=>Pt.mayDazzle(P));if(this.sceneRenderer.setRetinaHistory(v.length===0?void 0:P=>{const L=ke(i,P),O={lat:L?.lat??d,lng:L?.lng??f,heightM:L?this.altitudeOf(L):g.elevationM};return{views:Pt.viewsAt(v,P,O),pose:L}},i),this.skyEventsStartDate=p,this.sceneRenderer.setSkyEvents(m,!1,p),m&&this.loadSkyEventTexts(_M.map(P=>Za.of(P)).filter(P=>Za.eventsOf(m,P).length>0&&!this.skyEventTexts.has(P))),e&&!e.sky)return;if(this.sceneRenderer.setSkyUnknown(!p),!p){this.sceneRenderer.setAstronomy(kL);return}const x=new Date(p.getTime()+t),y=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Bc.DEG_PER_SECOND*1e3)),w=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),b=`${Math.floor(x.getTime()/y)}|${Math.round(d/w)}|${Math.round(f/w)}|${Math.round(g.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(b===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=b;const E=Kf("Sun",x,g),S=Kf("Moon",x,g);let A=nn.separationOf(E,S)<1?nn.viewAt(x,g):void 0;if(A){const P=nn.offsetOf(E,S,A.separationDeg);if(A.obscuration>ve.LIMB_FROM_OBSCURATION){const L=this.limbFor(x,g);L&&(A={...A,obscuration:1-cr.uncoveredFraction(L,A.sunRadiusDeg,P),limb:L})}A={...A,horizonShare:nn.horizonShare(A,P,E.altitudeDeg,E.azimuthDeg,na.distanceKm(x,g))}}const R={...E,magnitude:ug("Sun",x)-2.5*Math.log10(nn.beamFraction(A))};this.lastSun={altitudeDeg:R.altitudeDeg,azimuthDeg:R.azimuthDeg};const I={...S,phase:BO(x),magnitude:ug("Moon",x),radiusDeg:na.apparentRadiusDeg(x,g)},D=zO.map(P=>({body:P,position:Kf(P,x,g),magnitude:ug(P,x)}));this.sceneRenderer.setAstronomy({sun:R,moon:I,planets:D,comet:this.cometAt(x,g),novae:XS.appearancesAt(x,g).map(({outburst:P,position:L,magnitude:O})=>({id:P.id,position:L,magnitude:O})),stars:this.starCatalog?{catalog:this.starCatalog,date:x,observer:g}:void 0,frame:{date:x,observer:g},localHour:((x.getUTCHours()+x.getUTCMinutes()/60+(i.event.utcOffsetHours??Math.round(f/15)))%24+24)%24,eclipse:A}),this.ufoElement.setSunAltitude(R.altitudeDeg)}static LIMB_FROM_OBSCURATION=.98;limbRelief;limbRequested=!1;limbCache;limbFor(t,e){if(!this.limbRelief){this.limbRequested||(this.limbRequested=!0,Qu.load(PL).then(s=>{this.limbRelief=s,this.lastSkyKey="",s&&this.isConnected&&this.updateAstronomy(this.lastTimeMs)}));return}const i=this.limbCache;if(i&&Math.abs(t.getTime()-i.atMs)<5e3&&i.lat===e.lat&&i.lng===e.lng&&i.elevationM===e.elevationM)return i.profile;const n=cr.profile(t,e,this.limbRelief);return this.limbCache={profile:n,atMs:t.getTime(),lat:e.lat,lng:e.lng,elevationM:e.elevationM},n}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const r of this.satellites.passes.positionsAt(n,i,-1))r.magnitude!==void 0&&s.push({norad:r.object.norad,name:r.object.name,position:{altitudeDeg:r.altitudeDeg,azimuthDeg:r.azimuthDeg},magnitude:r.magnitude,heightKm:r.heightKm});this.sceneRenderer.setSatellites(s)}ensureFireballs(t){const e=this.ufoElement.sighting,i=Math.max((e.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),n=t?.getTime(),s=e.skySources!==!1,r=n===void 0||!s?"":`${n}+${i}`;if(this.fireballs?.key===r)return;if(!s){this.fireballs={key:r,status:"outside",reentries:[]};return}if(n===void 0||!sa.mayCover(n+i)){this.fireballs={key:r,status:"outside",reentries:[]};return}const a={key:r,status:"loading",reentries:[]};this.fireballs=a,ve.fireballArchive.between(n,n+i).then(c=>{a.status=c?"ready":"unavailable",a.records=c??[],a.reentries=a.records.map(l=>sa.asReentry(l,n)),!(this.fireballs!==a||!this.isConnected)&&(this.dispatchEvent(new CustomEvent(RL)),a.reentries.length>0&&this.updateAstronomy(this.lastTimeMs))})}decorWithTraffic(t){const e=this.ensureTraffic(t);if(!e||e.objects.length===0)return t.decor;const i=this.decorMemo;if(i&&i.base===t.decor&&i.traffic===e.objects)return i.merged;const n=[...t.decor,...e.objects];return this.decorMemo={base:t.decor,traffic:e.objects,merged:n},n}seatedDecor(t,e){if(!t.some(r=>r.observerKeyframes?.length))return t;const i=t.map(r=>{if(!r.observerKeyframes?.length)return"";const a=my(r,e);return`${a.side??"-"}/${a.facing??"-"}`}).join("|"),n=this.seatedMemo;if(n&&n.base===t&&n.seats===i)return n.seated;const s=t.map(r=>{if(!r.observerKeyframes?.length)return r;const a=my(r,e);return{...r,observerSide:a.side,observerFacing:a.facing}});return this.seatedMemo={base:t,seats:i,seated:s},s}ensureTraffic(t){const e=ke(t,0),i=e?.lng===void 0?void 0:_l(t.event.time??{},e.lng,t.event.utcOffsetHours),n=Math.max((t.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),s=i?.getTime(),r=s===void 0||e?.lat===void 0||e.lng===void 0?"":`${this.aircraftSource.id}|${s}+${n}|${e.lat.toFixed(3)},${e.lng.toFixed(3)}|${Math.round(e.elevationM??0)}|${Math.round(this.sceneRenderer.groundAltitudeM)}`;if(t.skySources===!1){this.traffic?.status!=="byHand"&&(this.traffic={key:"byHand",status:"byHand"},this.upperAirHeardLive=void 0);return}if(this.traffic?.key===r)return this.traffic.set;if(this.upperAirHeardLive=void 0,r===""||s===void 0||e?.lat===void 0||e.lng===void 0){this.traffic={key:r,status:"outside"};return}let a=ve.aircraftProviders.get(this.aircraftSource.id);if(a||ve.aircraftProviders.set(this.aircraftSource.id,a=this.aircraftSource.create()),a.mayCover&&!a.mayCover(s+n)){this.traffic={key:r,status:"outside"};return}const c={key:r,status:"loading",startMs:s,observer:{lat:e.lat,lng:e.lng}};this.traffic=c;const l={lat:e.lat,lng:e.lng,heightM:this.sceneRenderer.groundAltitudeM},h=On.MAX_GAP_S*1e3,u=ve.SOUND_LOOKBACK_MS,d={lat:e.lat,lng:e.lng,elevationM:this.altitudeOf(e)},f=(p,g)=>p.TrafficDecor.from(c.tracks??[],l,s,p.TrafficDecor.MAX_OBJECTS,{models:g,sunElevationAt:m=>this.sunElevationAt(m,d)});a.between(l,s-u,s+n+h).then(async p=>{if(this.traffic!==c)return;if(p.status!=="found"){c.status=p.status==="outside"?"outside":"unavailable",p.status==="failed"&&(c.problem=p.problem,c.creditsSpent=p.creditsSpent),this.announceTraffic();return}let g;try{g=await ve.loadTrafficRuntime()}catch{this.traffic===c&&(c.status="unavailable",this.announceTraffic());return}this.traffic===c&&(c.status="ready",c.tracks=p.tracks,c.partial=p.partial,c.creditsSpent=p.creditsSpent,c.set=f(g),this.startAircraftSound(c,g),this.announceTraffic(),this.describeTraffic(a,c,g,f),c.set.shown>0&&(this.readUpperAir(c,g,s-u,s+n+h),this.readTrailTraffic(a,c,g,l,s-ve.TRAIL_LOOKBACK_MS,s+n+h)))})}trafficSunlight(t){const e=new Map,i=this.traffic,n=i?.set,s=this.lastSun;if(!n||!s||i.startMs===void 0||!i.observer)return e;for(const[r,a]of n.presence){if(t<a.fromMs||t>a.untilMs)continue;const c=n.flights.get(r),l=c?On.positionAt(c,i.startMs+t):void 0;l&&e.set(r,{heightM:l.geo.heightM,sunElevationDeg:vs.sunElevationDeg(s,i.observer,l.geo)})}return e}trafficTooltipAt(t,e){const i=this.sceneRenderer.pickTrafficAt(t,e),n=i?this.trafficInfoAt(i):void 0;if(!n)return;const s=this.naming;return ve.trafficRuntime?.TrafficTooltip.text(n,s.names.trafficTooltip,a=>s.towards(a))}trafficInfoAt(t){const e=this.traffic,i=e?.set?.flights.get(t);if(!e||!i||e.startMs===void 0||!e.observer)return;const n=ve.trafficRuntime;if(!n)return;const s=e.descriptions?.get(Je.keyOf(i)),r=ke(this.ufoElement.sighting,this.lastTimeMs),a={lat:e.observer.lat,lng:e.observer.lng,heightM:this.altitudeOf(r)},c=n.AmbientNoise.dbA(Jh(this.ufoElement.sighting,this.lastTimeMs)),l=n.TrafficInfos.at(i,s,a,e.startMs+this.lastTimeMs,{ambientDbA:c}),h=l&&this.contrailAt(t,this.lastTimeMs);return l&&h?{...l,contrail:h}:l}contrailAt(t,e){const i=this.traffic?.contrails?.find(s=>s.id===t);if(!i)return;let n;for(const s of i.points){if(s.tMs>e)break;n=s}return n?.forms?{persistent:n.persistent,iceRelativeHumidity:n.iceRelativeHumidity}:void 0}startAircraftSound(t,e){this.aircraftAudio??=this.newAircraftAudio(e),this.sortOutAudible(t,e)}sortOutAudible(t,e){!t.set||!t.observer||(t.audible=e.TrafficSound.candidates(t.set.flights,t.descriptions??new Map,Je.keyOf,{...t.observer,heightM:this.sceneRenderer.groundAltitudeM},{ambientDbA:e.AmbientNoise.BASE_DB_A}))}pushAircraftSound(t,e){this.startDecorAircraftSound(t),this.startBodySound(),this.startRideSound(t);const i=this.aircraftAudio;if(!i)return;const n=ve.trafficRuntime;if(!n){i.setVoices([]);return}const s=ke(t,e),r=Jh(t,e),a={ambientDbA:n.AmbientNoise.dbA(r),referenceAmplitude:n.AmbientNoise.referenceAmplitude(r)},c=t.vehicle,l=c?n.CabinHearing.voice(c,a):void 0,h={...a,ambientDbA:Math.max(a.ambientDbA,l?.levelDbA??0),...c?{throughDb:Vn.insulationDb(c)}:{}},u=this.trafficVoices(e,s,h,n),d=t.event.place?.[0],f={lat:s?.lat??d?.lat,lng:s?.lng??d?.lng};f.lat!==void 0&&f.lng!==void 0&&(this.decorAircraftHearing??=new n.DecorAircraftHearing,u.push(...this.decorAircraftHearing.voices(t,e,{lat:f.lat,lng:f.lng,heightM:s?.elevationM??0},h,p=>this.decorModelSounds.get(p.model?.id??""))),u.push(...this.bodyVoices(t,e,h,n)),l&&u.push(l),u.sort((p,g)=>g.levelDbA-p.levelDbA),u.length=Math.min(u.length,4)),i.setVoices(u,s?.headingDeg??0)}startRideSound(t){this.aircraftAudio||Vn.aircraftOf(t.vehicle)===void 0||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}startBodySound(){this.aircraftAudio||!this.interpretationShown?.bodies.some(t=>t.sound)||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}bodyVoices(t,e,i,n){const s=this.interpretationShown,r=t.event.place?.[0];if(!s||!r||!s.bodies.some(f=>f.sound))return[];const a=this.sceneRenderer.bodyGround,c=f=>Lt.eyeOf(t,f,a),l=c(e);if(!l)return[];const h=new Map,u=(f,p)=>{let g=h.get(f.id);return g||h.set(f.id,g=new Lt(f,a,c)),g.at(p)};this.bodyHearing??=new n.BodyHearing;const d=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3);return this.bodyHearing.voices(s.bodies,u,l,r,e,d,i)}trafficVoices(t,e,i,n){const s=this.traffic,r=s?.set;if(!s||!r||!s.audible||s.startMs===void 0||!s.observer)return[];const a={lat:s.observer.lat,lng:s.observer.lng,heightM:this.altitudeOf(e)};return n.TrafficSound.voices(s.audible,r.flights,s.descriptions??new Map,Je.keyOf,a,s.startMs+t,i)}startDecorAircraftSound(t){const e=t.decor.filter(i=>i.kind==="aircraft"&&i.track?.some(n=>(n.altitudeM??0)>0));if(e.length!==0){for(const i of e){const n=i.model?.id;!n||i.model?.url!==void 0||this.decorModelSounds.has(n)||(this.decorModelSounds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(s=>{this.decorModelSounds.set(n,s?.parameters?.sound),this.ufoElement.refreshSoundControls()}))}if(this.aircraftAudio||ve.trafficRuntime){!this.aircraftAudio&&ve.trafficRuntime&&(this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime));return}ve.loadTrafficRuntime().catch(()=>{})}}newAircraftAudio(t){const e=new t.AircraftAudio(this.filmSound);return this.filmSound||e.setLevel(this.ufoElement.level),(this.interacted||this.filmSound)&&e.resume(),e.setPaused(this.ufoElement.playbackState!=="playing"&&!this.filmSound),e}get aircraftFlights(){return[...this.declaredFlights,...this.recordedFlights]}get declaredFlights(){return this.ufoElement.sighting.decor.filter(t=>t.kind==="aircraft"&&id.flies(t)).map(t=>{const e=this.sceneRenderer.decorSkyPoint(t.id);return{key:Je.declaredKeyOf(t.id),type:this.said.read(t.title)||this.naming.decorKind(t.kind),sky:e?.sky,altitudeFt:e?e.altitudeM/.3048:void 0,firstMs:0,drawn:e!==void 0,declared:!0}})}get recordedFlights(){const t=this.traffic;if(!t?.tracks||t.startMs===void 0||!t.observer)return[];const e=t.startMs,i=this.observerAt(this.lastTimeMs,t.observer),n=new Set([...t.set?.flights.values()??[]].map(a=>Je.keyOf(a))),s=t.nearestPassKm??=new Map(t.tracks.map(a=>[Je.keyOf(a),Math.min(...a.points.map(c=>On.groundDistanceKm(t.observer,c)))])),r=this.ufoElement.seekableDuration;return[...t.tracks].sort((a,c)=>s.get(Je.keyOf(a))-s.get(Je.keyOf(c))).map(a=>{const c=Je.keyOf(a),l=t.descriptions?.get(c),h=t.models?.get(c),u=On.seenFrom(a,i,e+this.lastTimeMs),d=a.points.find(f=>f.t>=e)?.t;return{key:c,type:h?.basis==="type"?h.name:l?.type,registration:l?.registration,sky:u?.sky,altitudeFt:u?.altitudeFt,firstMs:d!==void 0&&d-e<=r?d-e:void 0,drawn:n.has(c)}})}lookAtFlight(t,e=this.lastTimeMs){const i=this.traffic,n=ke(this.ufoElement.sighting,e),s=Je.declaredIdOf(t);if(s!==void 0){const c=this.sceneRenderer.decorSkyPoint(s);return!c||n?.headingDeg===void 0?!1:(this.setLookOffset(((c.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,c.sky.altitudeDeg-(n.pitchDeg??0)),!0)}const r=i?.tracks?.find(c=>Je.keyOf(c)===t);if(!i?.observer||i.startMs===void 0||!r||n?.headingDeg===void 0)return!1;const a=On.seenFrom(r,this.observerAt(e,i.observer),i.startMs+e);return a?(this.setLookOffset(((a.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,a.sky.altitudeDeg-(n.pitchDeg??0)),!0):!1}markFlight(t){this.markedFlight=t,this.placeFlightMark()}placeFlightMark(){const t=this.markedFlight,e=t===void 0?void 0:this.sceneRenderer.flightScreenPoint(t);if(this.flightMark.toggleAttribute("hidden",!e),!e)return;const i=this.sceneCanvas.getBoundingClientRect(),n=this.stageElement.getBoundingClientRect(),s=i.left-n.left+(e.ndcX+1)/2*i.width,r=i.top-n.top+(1-e.ndcY)/2*i.height;for(const a of Array.from(this.flightMark.children))a.setAttribute("cx",String(s)),a.setAttribute("cy",String(r))}altitudeOf(t){return this.sceneRenderer.groundAltitudeM+(t?.elevationM??0)}observerAt(t,e){const i=ke(this.ufoElement.sighting,t);return{lat:i?.lat??e.lat,lng:i?.lng??e.lng,heightM:this.altitudeOf(i)}}announceTraffic(){this.isConnected&&(this.dispatchEvent(new CustomEvent(DL)),this.updateAstronomy(this.lastTimeMs))}async describeTraffic(t,e,i,n){if(!t.describe||!e.set||!e.tracks)return;const s=new Set([...e.set.flights.values()].map(l=>Je.keyOf(l))),r=e.tracks.filter(l=>s.has(Je.keyOf(l))&&l.points.length>0),a=new Map,c=new Map;await Promise.all(r.map(async l=>{const h=new Date(l.points[0].t).toISOString().slice(0,10),u=await t.describe(l,h).catch(()=>{});u&&(c.set(Je.keyOf(l),u),a.set(Je.keyOf(l),i.AircraftModels.of(u)))})),!(this.traffic!==e||a.size===0)&&(e.descriptions=c,e.models=a,e.set=n(i,a),this.planContrails(e,i),this.sortOutAudible(e,i),this.announceTraffic())}async readTrailTraffic(t,e,i,n,s,r){if(e.startMs===void 0)return;const a=await t.between(n,s,r).catch(()=>{});if(this.traffic!==e||a?.status!=="found")return;const c=a.tracks.filter(u=>u.points.some(d=>d.altitudeFt>=i.AircraftContrails.MIN_ALTITUDE_FT)),l=new Map(e.models??[]);if(t.describe&&await Promise.all(c.filter(u=>u.points.length>0&&!l.has(Je.keyOf(u))).map(async u=>{const d=await t.describe(u,new Date(u.points[0].t).toISOString().slice(0,10)).catch(()=>{});d&&l.set(Je.keyOf(u),i.AircraftModels.of(d))})),this.traffic!==e||e.startMs===void 0)return;const h=i.TrafficDecor.from(c,n,e.startMs,ve.TRAIL_MAX_AIRCRAFT,{models:l});e.trailSet=ve.alignTrailIds(h,e.set),e.models=new Map([...l,...e.models??[]]),this.planContrails(e,i),this.announceTraffic()}static alignTrailIds(t,e){if(!e)return t;const i=new Map;for(const[a,c]of e.flights){const l=e.presence.get(a);if(l)for(const[h,u]of t.flights){const d=t.presence.get(h);!d||Je.keyOf(u)!==Je.keyOf(c)||d.fromMs<=l.untilMs&&l.fromMs<=d.untilMs&&i.set(h,a)}}const n=a=>i.get(a)??`${a}-trail`,s=new Set(i.values()),r=e.objects.filter(a=>!s.has(a.id));return{...t,objects:[...t.objects.map(a=>({...a,id:n(a.id)})),...r],presence:new Map([...[...t.presence].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.presence.get(a.id)])]),flights:new Map([...[...t.flights].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.flights.get(a.id)])])}}async readUpperAir(t,e,i,n){if(!t.observer)return;const s=fh.held(this.ufoElement.sighting.snapshots,"upperAir");let r;if(s){const l=Mi.address(s.src,this.documentUrl);r=ve.upperAirProviders.get(l),r||ve.upperAirProviders.set(l,r=new hh(Mi.json(l)))}else{const l=this.upperAirSource??e.UPPER_AIR_SOURCES[0];r=ve.upperAirProviders.get(l.id),r||ve.upperAirProviders.set(l.id,r=l.create())}const a={lat:t.observer.lat,lng:t.observer.lng},c=await r.between(a,i,n);this.traffic!==t||c.status!=="found"||(s||(this.upperAirHeardLive={...a,startMs:i,endMs:n,answer:c}),t.air=c.samples,t.airSource=c.source,this.planContrails(t,e),this.announceTraffic())}planContrails(t,e){const i=t.trailSet??t.set;!i||!t.air||t.startMs===void 0||(t.contrails=e.AircraftContrails.plan(i,t.models,t.air,t.startMs))}contrailSunlight(t){const e=new Map,i=this.traffic,n=i?.trailSet??i?.set,s=this.lastSun;if(!i||!n||!s||!i.contrails?.length||i.startMs===void 0||!i.observer)return e;for(const r of i.contrails){const a=n.presence.get(r.id),c=n.flights.get(r.id);if(!a||!c)continue;const l=On.positionAt(c,i.startMs+Math.min(a.untilMs,Math.max(a.fromMs,t)));l&&e.set(r.id,{heightM:l.geo.heightM,sunElevationDeg:vs.sunElevationDeg(s,i.observer,l.geo)})}return e}sunElevationAt(t,e){const i=Kf("Sun",new Date(t.t),e);return vs.sunElevationDeg(i,e,t)}upperAirSource;upperAirHeardLive;get upperAirHeard(){return this.upperAirHeardLive}setUpperAirSource(t){t.id!==this.upperAirSource?.id&&(this.upperAirSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}setAircraftSource(t,e=!1){!e&&t.id===this.aircraftSource.id||(this.aircraftSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}get aircraftState(){const t=this.traffic?.contrails?.length?this.upperAirSource??ve.trafficRuntime?.UPPER_AIR_SOURCES[0]:void 0;return{trailCredit:t&&{credit:t.credit,creditUrl:t.creditUrl},status:this.traffic?.status??"none",problem:this.traffic?.problem,partial:this.traffic?.partial,creditsSpent:this.traffic?.creditsSpent,total:this.traffic?.set?.total??0,shown:this.traffic?.set?.shown??0,credit:this.aircraftSource.credit,creditUrl:this.aircraftSource.creditUrl}}get fireballState(){return{status:this.fireballs?.status??"none",records:this.fireballs?.records??[]}}ensureSatellites(t){this.ufoElement.sighting.skySources===!1&&(t=void 0);const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.isConnected&&this.dispatchEvent(new CustomEvent(TL)))},s=ve.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[r,a]=await Promise.all([s.at(t),xt(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return n("unavailable");this.satellites={snapshot:r,passes:new a.SatellitePasses(r.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}burningCandidates(){return{reentries:this.ufoElement.sighting.skyEvents?.reentries??[],fireballs:this.fireballs?.reentries??[]}}trafficCandidates(){const t=this.traffic;if(!(t?.status!=="ready"||!t.tracks||t.startMs===void 0))return{tracks:t.tracks,startMs:t.startMs,describe:e=>t.descriptions?.get(Je.keyOf(e))}}satellitePositionsAt(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!(!e||r===void 0||a===void 0))return e.passes.positionsAt(t,{lat:r,lng:a,elevationM:this.altitudeOf(n)})}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!e||r===void 0||a===void 0)return[];const c=_l(i.event.time??{},a,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:r,lng:a,elevationM:this.altitudeOf(n)},u=JSON.stringify([this.satellitesFor,c.getTime(),r,a,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=mL.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}approachOf(t,e){return this.approaches.of.has(e)||this.approaches.of.set(e,ed.of(t,e)),this.approaches.of.get(e)}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=JSON.stringify([e.timeline.allKeyframes.map(g=>[g.t,g.shapes.map(m=>[m.sourceId,m.shape.angular?.widthDeg,m.shape.aim?.azimuthDeg])]),e.observerTrack.allKeyframes,e.event.place?.[0]]);i!==this.approaches.key&&(this.approaches={key:i,of:new Map});const n=e.timeline,s=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),c=new Map,l=new Map,h=new Set;for(const g of n.sourceIds){const m=n.getInterpolatedShapeAt(t,g);if(!m)continue;const M={...m,bounds:{...m.bounds,x:m.bounds.x+r.x,y:m.bounds.y+r.y}};c.set(g,M);const v=m.aim?this.sceneRenderer.screenPointOf(Cs.directionOf(m.aim,this.directionScratch)):{ndcX:(M.bounds.x+M.bounds.width/2)/s.width*2-1,ndcY:-((M.bounds.y+M.bounds.height/2)/s.height*2-1)},x=v!==void 0&&Math.abs(v.ndcX)<=1&&Math.abs(v.ndcY)<=1,y=x?this.sceneRenderer.decorDistancesAt(v.ndcX,v.ndcY,g):{};h.add(g),(x||m.aim)&&h.delete(g);const w=m.angular?.widthDeg??a.pxToDeg(m.bounds.width),b=this.sizeEstimateOf(g);b.add(w,y);const E=this.approachOf(e,g);l.set(g,ms.resolve({hypothesisM:this.distanceHypotheses.get(g),derivedM:E&&w>0?di.distanceMAt(E.widthM,w):void 0,range:b.distanceRangeAt(w),crossing:y}))}for(const[g,m]of c)for(const[M,v]of c){if(M===g||v.transparency>=1||v.bounds.width*v.bounds.height<=m.bounds.width*m.bounds.height||!(m.bounds.x>=v.bounds.x&&m.bounds.y>=v.bounds.y&&m.bounds.x+m.bounds.width<=v.bounds.x+v.bounds.width&&m.bounds.y+m.bounds.height<=v.bounds.y+v.bounds.height))continue;const y=l.get(M);y&&l.set(g,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=l;const u=n.sourceIds,d=[];for(const[g,m]of c)d.push({sourceId:g,shape:m,distanceM:l.get(g).distanceM,renderOrder:u.indexOf(g),aim:m.aim,hidden:h.has(g)||this.interpretationShown!==void 0&&(!this.comparing||m.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=ke(e,t),p=(f?.rollDeg??0)+oi.bodyAt(e,t,this.ufoElement.steadyBody).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:s.width,canvasHeightPx:s.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,s.height)),starPoints:qi.starPointsOf(e.instrument,f?.fNumber),rollRad:p*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.showInterpretation(t),this.ufoElement.playerTitle=t?.title,this.ufoElement.refreshSoundControls(),this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome()}redrawSky(){this.updateAstronomy(this.lastTimeMs)}syncAccountHidden(){this.ufoElement.accountHidden=this.interpretationShown!==void 0&&!this.comparing}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){t!==this.comparing&&(this.comparing=t,this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=Lt.eyeOf(this.ufoElement.sighting,i,n);return s?Lt.lineOfSightMeetsGround(s,t,e,n):void 0}bodyMaskedBy(t,e){return this.sceneRenderer.bodyMaskedByDecor(t,e)}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>Lt.eyeOf(n,d,i),r=new Lt(t,i,s).at(e),a=s(e);if(!r||!a)return;const c=r.eastM-a.eastM,l=r.northM-a.northM,h=r.upM-a.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:r.eastM,northM:r.northM,aboveGroundM:r.upM-r.sizeM.heightM/2-i.heightAt(r.eastM,r.northM),sizeM:r.sizeM,attitude:r.attitude,appearance:r.appearance}}bodyProjectionAt(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=c=>Lt.eyeOf(n,c,i),r=new Lt(t,i,s).at(e),a=s(e);return r&&a?mi.projectionOf(r,a):void 0}directionToDecor(t){return this.sceneRenderer.directionToDecor(t)}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>Lt.eyeOf(n,p,i),r=new Lt(t,i,s),a=r.at(e)?e:t.track[0]?.t,c=a===void 0?void 0:r.at(a),l=a===void 0?void 0:s(a);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],r=[];const a=this.sceneRenderer.bodyGround,c=p=>Lt.eyeOf(n,p,a);i&&(s=i.bodies.map(p=>new Lt(p,a,c).at(t)).filter(p=>p!==void 0));const l=Zh(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(r=new mi(n.timeline,this.confrontationTolerance).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=r,!e)return;const f=JSON.stringify(r);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(CL,{detail:r})))}async pictureAt(t,e=640){const i=document.createElement("canvas");i.width=e,i.height=Math.round(e*(this.sceneCanvas.height||9)/(this.sceneCanvas.width||16));let n=!1;for(const s of[1200,0]){this.showAt(t),n=!1;for(let r=0;r<900&&!n;r++)await new Promise(a=>requestAnimationFrame(()=>a())),n=this.snapshotTo(i);if(!n)return;s&&await new Promise(r=>setTimeout(r,s))}return i.toDataURL("image/jpeg",.85)}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(r=>r.t>n&&r.t<=e).pop();s&&Zh(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Zh(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],r=n?.year!==void 0?_l(n,s?.lng??0,t.event.utcOffsetHours):void 0,a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((r?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=dn.schedule({durationMs:a,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration,t.skySources])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?_l(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0||t.skySources===!1){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},r=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,a=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=Ki.schedule({ratePerHour:Ki.observedRatePerHour(Ki.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:Ki.TYPICAL_VELOCITY_KM_S,seed:a}),l=Qg.activeAt(n).map(u=>{const d=Qg.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:Qg.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=hr.schedule({ratePerHour:l.rate,durationMs:r,velocityKmS:l.entry.shower.velocityKmS,seed:a+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}groundHides(t,e){return this.sceneRenderer.groundHidesDirection(t,e)}get groundKey(){return this.sceneRenderer.groundKey}meteorByRank(t,e=Number.POSITIVE_INFINITY){this.ensureMeteorSchedule(this.ufoElement.sighting);const i=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).filter(r=>hr.magnitudeOf(r)<=e).filter(r=>{const a=this.sceneRenderer.meteorMidpoint(r);return a!==void 0&&!this.sceneRenderer.groundHidesDirection(a.altitudeDeg,a.azimuthDeg)}).sort((r,a)=>a.brightness-r.brightness);if(i.length===0)return;const n=i[t%i.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=ke(e,t),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const a=qi.focalLengthMmFor(i,mn.fovOf(e,t));if(a!==void 0)return{focalLengthMm:a,fNumber:r,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return ca.of(e.instrument,di.CANVAS_HEIGHT_PX,mn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new ML,this.sizeEstimates.set(t,e)),e}}const XM="rr0-scene";function FL(){kb(),customElements.get(XM)||customElements.define(XM,ve)}FL();export{ws as $,Zs as A,we as B,at as C,id as D,to as E,pe as F,We as G,Ve as H,jL as I,HL as J,$_ as K,Dw as L,Te as M,Y1 as N,Vn as O,Qt as P,Ys as Q,Pt as R,Gu as S,Je as T,xR as U,_ as V,qe as W,zu as X,ic as Y,Hl as Z,xt as _,On as a,$d as a$,Sn as a0,ZL as a1,Hc as a2,_n as a3,Si as a4,ii as a5,Ji as a6,Xn as a7,yp as a8,ls as a9,sE as aA,qs as aB,of as aC,wm as aD,O5 as aE,Zo as aF,f1 as aG,Zi as aH,ba as aI,zT as aJ,ui as aK,GL as aL,WL as aM,oE as aN,XL as aO,js as aP,aE as aQ,Rx as aR,OT as aS,AA as aT,J0 as aU,W1 as aV,SE as aW,Ev as aX,Av as aY,ze as aZ,ya as a_,YL as aa,Ln as ab,zn as ac,Oi as ad,on as ae,us as af,Ni as ag,Id as ah,xr as ai,Xl as aj,xL as ak,Qv as al,wL as am,UL as an,BL as ao,zL as ap,qd as aq,JL as ar,$L as as,tp as at,EE as au,op as av,VL as aw,cx as ax,qL as ay,QL as az,Db as b,Ct as b0,wn as b1,De as b2,Yr as b3,Tr as b4,Do as b5,A0 as b6,lr as b7,_0 as b8,gs as b9,Ss as bA,hs as bB,Xh as bC,ji as bD,ma as ba,wi as bb,jo as bc,Hd as bd,mt as be,XP as bf,Eh as bg,Wt as bh,th as bi,Dv as bj,Ht as bk,br as bl,sa as bm,Qg as bn,Kf as bo,H_ as bp,_l as bq,ke as br,Cn as bs,S_ as bt,Zh as bu,Bi as bv,tb as bw,bv as bx,Yo as by,xa as bz,Qs as c,bR as d,Vt as e,Cb as f,Wn as g,Ar as h,Re as i,tt as j,ae as k,ks as l,ft as m,Me as n,Ga as o,ye as p,mr as q,da as r,t7 as s,sp as t,KL as u,Ge as v,pr as w,Ie as x,Zr as y,St as z};
|