@rr0/ufoathome 0.191.1 → 0.192.0
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 +6 -6
- package/dist-embed-scene/trafficRuntime-CL5yz3t-.js +2 -0
- package/dist-embed-sighting/CaseMessages_en-Bv5lKWl_.js +1 -0
- package/dist-embed-sighting/CaseMessages_es-BhZv_CtC.js +1 -0
- package/dist-embed-sighting/CaseMessages_fr-C5V5YNc_.js +1 -0
- package/dist-embed-sighting/CaseMessages_it-NPdAZwa_.js +1 -0
- package/dist-embed-sighting/{CaseReportExport-Jt3sfR-8.js → CaseReportExport-dMWWJNIh.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +168 -130
- package/dist-embed-sighting/trafficRuntime-BUvbWOcl.js +2 -0
- package/dist-embed-sighting-editor/{CaseReportExport-CKuvpQqy.js → CaseReportExport-ByPXoIiq.js} +1 -1
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +37 -11
- package/dist-embed-sighting-editor/trafficRuntime-DwnTE9-7.js +2 -0
- package/package.json +1 -1
- package/dist-embed-scene/trafficRuntime-DRDMbo2X.js +0 -2
- package/dist-embed-sighting/CaseMessages_en-CBS5QChl.js +0 -1
- package/dist-embed-sighting/CaseMessages_es-DAMl4aTC.js +0 -1
- package/dist-embed-sighting/CaseMessages_fr-C3wQxAk_.js +0 -1
- package/dist-embed-sighting/CaseMessages_it-CyrREg6v.js +0 -1
- package/dist-embed-sighting/trafficRuntime-CuYrKvX9.js +0 -2
- package/dist-embed-sighting-editor/trafficRuntime-Cqj3IpvH.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LanternEditor-DDcI5Kv1.js","./SkyEventEditorStyle-CvY_AhbI.js","./SkyLantern-De_MXfQz.js","./BirdEditor-ESUliJEN.js","./BirdFlock-DtshFXGT.js","./DroneEditor-DDaJO8FS.js","./DroneFlight-tXCk1Tg1.js","./ShareCodeEditor-CF7IVeXv.js","./index-DSNA74v6.js","./BeamSystem-BGdR-Xez.js","./LaserBeam-CadJcSMd.js","./BeamEditor-5-OlhNfL.js","./LaunchSimulation-45Z9GUBF.js","./LaunchPlume-C7My5ccR.js","./LaunchEditor-Pkk0K648.js","./ReentryEditor-NE8z5aZT.js","./HynekAssessor-PxE7JR1h.js","./NearestApproach-EbQIYGTt.js","./BallesterGuaspAssessor-CXvIvYxV.js","./CoverageAssessor-CJQzNdyr.js","./ContrailSystem-BTVyJpmn.js","./ContrailGrowth-DwHS8If9.js","./ReferenceSystem-DUIJceGg.js","./PictureFetch-C3wgf1ZV.js","./trafficRuntime-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LanternEditor-DDcI5Kv1.js","./SkyEventEditorStyle-CvY_AhbI.js","./SkyLantern-De_MXfQz.js","./BirdEditor-ESUliJEN.js","./BirdFlock-DtshFXGT.js","./DroneEditor-DDaJO8FS.js","./DroneFlight-tXCk1Tg1.js","./ShareCodeEditor-CF7IVeXv.js","./index-DSNA74v6.js","./BeamSystem-BGdR-Xez.js","./LaserBeam-CadJcSMd.js","./BeamEditor-5-OlhNfL.js","./LaunchSimulation-45Z9GUBF.js","./LaunchPlume-C7My5ccR.js","./LaunchEditor-Pkk0K648.js","./ReentryEditor-NE8z5aZT.js","./HynekAssessor-PxE7JR1h.js","./NearestApproach-EbQIYGTt.js","./BallesterGuaspAssessor-CXvIvYxV.js","./CoverageAssessor-CJQzNdyr.js","./ContrailSystem-BTVyJpmn.js","./ContrailGrowth-DwHS8If9.js","./ReferenceSystem-DUIJceGg.js","./PictureFetch-C3wgf1ZV.js","./trafficRuntime-DwnTE9-7.js","./GenerativeKit-BmhvjjzB.js","./browser-CltifEM0.js","./VideoExport-B8ZhHNnd.js","./ModelThumbnails-CNO_j-KM.js","./ModelSource-CzGHu4XS.js","./ModelViewer-yfIxofpG.js","./SightingFileEditor-0VZmtiOX.js","./sightingSchema-CgwoRMl-.js","./ModulesPanelElement-DgbOYqaS.js","./ModuleSession-Cxe0BJue.js","./KmlExport-dpml2tIJ.js","./GeographicFigures-DC6Tw3ja.js","./GeoJsonExport-_yjIEd4F.js","./GhostSearchView-Dlhj3xWa.js","./InterviewEditorElement-D-UDHU0L.js","./InterviewMedia-CvAxC62V.js","./interviewJson-iURHP4Zk.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
const w_="modulepreload",M_=function(l,e){return new URL(l,e).href},jM={},V=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let r=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");s=r(t.map(h=>{if(h=M_(h,i),h in jM)return;jM[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!i)for(let m=a.length-1;m>=0;m--){const g=a[m];if(g.href===h&&(!d||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":w_,d||(f.as="script"),f.crossOrigin="",f.href=h,c&&f.setAttribute("nonce",c),document.head.appendChild(f),d)return new Promise((m,g)=>{f.addEventListener("load",m),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})};class Wt{constructor(e){this.entries=e}static free(e){return e?.basis==="assumed"||e?.basis==="fitted"}static empty(){return new Wt(new Map)}get size(){return this.entries.size}at(e){return this.entries.get(e)}paths(){return[...this.entries.keys()]}sourced(){return[...this.entries].filter(([,e])=>e.source!==void 0).map(([e,t])=>({path:e,basis:t.basis,source:t.source}))}interviewsCited(){const e=[];for(const{source:t}of this.sourced()){const i=t.said?.interview;i!==void 0&&!e.includes(i)&&e.push(i)}return e}pathsFromInterview(e){return this.sourced().filter(({source:t})=>t.said!==void 0&&t.said.interview===e).map(({path:t})=>t)}set(e,t){t.basis==="stated"&&t.rationale===void 0&&t.how===void 0&&t.range===void 0&&t.source===void 0?this.entries.delete(e):this.entries.set(e,t)}clear(e){for(const t of this.entries.keys())(t===e||t.startsWith(`${e}.`))&&this.entries.delete(t)}static strip(e){const t=new Wt(new Map);return{recording:Wt.stripValue(e,[],t),provenance:t}}static restore(e,t){if(t.size===0)return e;const i={...e},s=new Set([i]);for(const n of t.paths()){const r=t.at(n),a=n.split("."),o=Wt.writableHolderOf(i,a,s);if(!o)continue;const c=a[a.length-1],h=o[c];h!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(h)||(o[c]={value:h,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale},...r.how===void 0?{}:{how:r.how},...r.range===void 0?{}:{range:r.range},...r.source===void 0?{}:{source:r.source}}))}return i}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,i){return Wt.isWrapper(e)?(i.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},...e.how===void 0?{}:{how:e.how},...e.range===void 0?{}:{range:e.range},...e.source===void 0?{}:{source:e.source},of:e.value}),Wt.stripValue(e.value,t,i)):Array.isArray(e)?e.map((s,n)=>Wt.stripValue(s,[...t,String(n)],i)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([s,n])=>[s,Wt.stripValue(n,[...t,s],i)])):e}static writableHolderOf(e,t,i){let s=e;for(const n of t.slice(0,-1)){const r=s[n];if(typeof r!="object"||r===null)return;if(i.has(r)){s=r;continue}const a=Array.isArray(r)?[...r]:{...r};i.add(a),s[n]=a,s=a}return s}}class $p extends Error{constructor(e,t,i){super(typeof t=="number"&&Number.isInteger(t)&&t>=1?`This ${e} file is in version ${t} of its format; this UFO@home reads version ${i}. Read it with the UFO@home that reads its version.`:`This ${e} file states ${JSON.stringify(t)} as its format version, which is not a version.`),this.format=e,this.found=t,this.supported=i,this.name="FormatVersionError"}said(e){return e.replace("{found}",typeof this.found=="number"?String(this.found):JSON.stringify(this.found)).replace("{supported}",String(this.supported))}}class En{static CURRENT={sighting:4,case:1,interview:1};static SCHEMA_BASE="https://ufoathome.org/schema";static schemaUrl(e,t=En.CURRENT[e]){return`${En.SCHEMA_BASE}/${t}/${e}.schema.json`}static of(e){if(typeof e!="object"||e===null)return 1;const t=e.version;return t===void 0?1:typeof t=="object"&&t!==null&&"value"in t?t.value:t}static recording(e){return En.check(e,"sighting")}static check(e,t){const i=En.of(e),s=En.CURRENT[t];if(typeof i!="number"||!Number.isInteger(i)||i!==s)throw new $p(t,i,s);return e}}class hi{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(e,t){return t.every(i=>hi.itemsOf(e,i.key).length===0||hi.computers.has(i))}static load(e,t){return Promise.all(t.filter(i=>hi.itemsOf(e,i.key).length>0&&!hi.computers.has(i)).map(i=>{let s=hi.loading.get(i);return s||(s=i.compute().then(n=>{hi.computers.set(i,n)}),s.catch(()=>hi.loading.delete(i)),hi.loading.set(i,s)),s.catch(()=>{})})).then(()=>{})}static of(e){let t=hi.built.get(e);return t||(t=e.create(),hi.built.set(e,t)),t}static itemsOf(e,t){const i=e?.[t];return Array.isArray(i)?i:[]}static computes(e,t){return t.some(i=>hi.itemsOf(e,i.key).length>0)}static expand(e,t,i){return hi.expandWithKinds(e,t,i).interpretation}static expandWithKinds(e,t,i){const s=new Map,n=new Map;if(!e||!hi.computes(e,t))return{interpretation:e,kindOf:s,phenomenonOf:n};const r=t.flatMap(a=>hi.itemsOf(e,a.key).flatMap(o=>{const c=hi.computers.get(a);if(!c)return[];const h=c(o,i),d=a.phenomenon?.(o);for(const u of h)s.set(u.id,a),d&&n.set(u.id,d);return h}));return{interpretation:{...e,bodies:[...e.bodies,...r]},kindOf:s,phenomenonOf:n}}static computedPart(e,t){const i={};for(const s of t){const n=hi.itemsOf(e,s.key);n.length>0&&(i[s.key]=[...n])}return i}static saysNothing(e,t){return e.bodies.length===0&&e.title===void 0&&e.smoke===void 0&&t.every(i=>e[i.key]===void 0)}}class uT extends Error{constructor(e,t,i,s){super(`Module "${e}" gives "${i}" at ${t}, which module "${s}" already gives`),this.moduleId=e,this.point=t,this.sourceId=i,this.ownerId=s,this.name="ModuleConflictError"}}class x_{constructor(e){this.id=e}sources=[];owners=new Map;ownerOf(e){return this.owners.get(e)}conflict(e,t){for(const i of t){const s=this.owners.get(i.id);if(s!==void 0&&s!==e)return{sourceId:i.id,ownerId:s}}}provide(e,t){const i=this.conflict(e,t);if(i)throw new uT(e,this.id,i.sourceId,i.ownerId);this.withdraw(e);const s=e===Xe.BUILT_IN?this.sources.findIndex(n=>this.owners.get(n.id)!==Xe.BUILT_IN):-1;s<0?this.sources.push(...t):this.sources.splice(s,0,...t);for(const n of t)this.owners.set(n.id,e);return this.sources}withdraw(e){for(let t=this.sources.length-1;t>=0;t--){const i=this.sources[t].id;this.owners.get(i)===e&&(this.sources.splice(t,1),this.owners.delete(i))}}}class Xe{static BUILT_IN="ufoathome";static changes=new EventTarget;static points=new Map;static modules=new Map;static point(e){let t=Xe.points.get(e);return t||(t=new x_(e),Xe.points.set(e,t)),t}static install(e){if(e.id===Xe.BUILT_IN)throw new Error(`"${Xe.BUILT_IN}" is the id of the built-in module`);const t=Xe.contributionsOf(e);for(const[n,r]of t){const a=Xe.point(n).conflict(e.id,r);if(a)throw new uT(e.id,n,a.sourceId,a.ownerId)}const i=new Set(t.map(([n])=>n)),s=Xe.modules.get(e.id);if(s)for(const[n]of Xe.contributionsOf(s))i.add(n);for(const n of i)Xe.point(n).withdraw(e.id);for(const[n,r]of t)Xe.point(n).provide(e.id,r);Xe.modules.set(e.id,e);for(const n of i)Xe.announce(n)}static uninstall(e){const t=Xe.modules.get(e);if(t){Xe.modules.delete(e);for(const[i]of Xe.contributionsOf(t))Xe.point(i).withdraw(e),Xe.announce(i)}}static installed(){return[...Xe.modules.values()]}static contributionsOf(e){return Object.entries(e.contributes).filter(t=>Array.isArray(t[1])&&t[1].length>0)}static announce(e){Xe.changes.dispatchEvent(new CustomEvent("change",{detail:e}))}}const E_=["en","fr","es","it"];class yi{static catalog(e){const t=new Map;return{load(i){const s=yi.languageOf(i);let n=t.get(s);return n||(n=e[s](),t.set(s,n),n.catch(()=>t.delete(s))),n}}}static none(){return new Proxy({},{get:()=>""})}static blank(){const e=new Proxy(()=>e,{get:(t,i)=>i===Symbol.toPrimitive?()=>"":i===Symbol.iterator?function*(){}:i==="toString"||i==="valueOf"?()=>"":i==="then"?void 0:e,apply:()=>e,has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return e}static languageOf(e){const t=e.toLowerCase().split("-")[0];return E_.includes(t)?t:"en"}}const S_=yi.catalog({en:()=>V(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(l=>l.flareKindMessages_en),fr:()=>V(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(l=>l.flareKindMessages_fr),es:()=>V(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(l=>l.flareKindMessages_es),it:()=>V(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(l=>l.flareKindMessages_it)}),ZM={key:"flares",messages:S_,phenomenon:()=>"DecoyFlare",compute:()=>V(async()=>{const{DecoyFlare:l}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:l}},[],import.meta.url).then(({DecoyFlare:l})=>e=>l.bodiesOf(e))},A_=yi.catalog({en:()=>V(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(l=>l.lanternKindMessages_en),fr:()=>V(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(l=>l.lanternKindMessages_fr),es:()=>V(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(l=>l.lanternKindMessages_es),it:()=>V(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(l=>l.lanternKindMessages_it)}),JM={key:"lanterns",messages:A_,phenomenon:()=>"SkyLantern",compute:()=>V(async()=>{const{SkyLantern:l}=await import("./SkyLantern-De_MXfQz.js");return{SkyLantern:l}},[],import.meta.url).then(({SkyLantern:l})=>(e,t)=>l.bodiesOf(e,t?.obstacles)),editor:()=>V(async()=>{const{LanternEditor:l}=await import("./LanternEditor-DDcI5Kv1.js");return{LanternEditor:l}},__vite__mapDeps([0,1,2]),import.meta.url).then(({LanternEditor:l})=>(e,t,i)=>new l(e,t,i))},T_=yi.catalog({en:()=>V(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(l=>l.birdKindMessages_en),fr:()=>V(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(l=>l.birdKindMessages_fr),es:()=>V(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(l=>l.birdKindMessages_es),it:()=>V(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(l=>l.birdKindMessages_it)}),QM={key:"birds",messages:T_,phenomenon:()=>"Birds",compute:()=>V(async()=>{const{BirdFlock:l}=await import("./BirdFlock-DtshFXGT.js").then(e=>e.b);return{BirdFlock:l}},[],import.meta.url).then(({BirdFlock:l})=>(e,t)=>l.bodiesOf(e,t?.obstacles)),editor:()=>V(async()=>{const{BirdEditor:l}=await import("./BirdEditor-ESUliJEN.js");return{BirdEditor:l}},__vite__mapDeps([3,1,4]),import.meta.url).then(({BirdEditor:l})=>(e,t,i)=>new l(e,t,i))},I_=yi.catalog({en:()=>V(()=>import("./DroneKindMessages_en-CLygXcsv.js"),[],import.meta.url).then(l=>l.droneKindMessages_en),fr:()=>V(()=>import("./DroneKindMessages_fr-CAX15_pk.js"),[],import.meta.url).then(l=>l.droneKindMessages_fr),es:()=>V(()=>import("./DroneKindMessages_es-B9XFRYnQ.js"),[],import.meta.url).then(l=>l.droneKindMessages_es),it:()=>V(()=>import("./DroneKindMessages_it-CSGsCaJQ.js"),[],import.meta.url).then(l=>l.droneKindMessages_it)}),ex={quadcopter:"ConsumerDrone",saucer:"ConsumerDrone","fixed-wing":"MilitaryDrone"},tx={key:"drones",messages:I_,phenomenon:l=>ex[l.airframe]??ex.quadcopter,compute:()=>V(async()=>{const{DroneFlight:l}=await import("./DroneFlight-tXCk1Tg1.js").then(e=>e.c);return{DroneFlight:l}},[],import.meta.url).then(({DroneFlight:l})=>e=>l.bodiesOf(e)),editor:()=>V(async()=>{const{DroneEditor:l}=await import("./DroneEditor-DDaJO8FS.js");return{DroneEditor:l}},__vite__mapDeps([5,1,6]),import.meta.url).then(({DroneEditor:l})=>(e,t,i)=>new l(e,t,i))},__=Xe.point("interpretations").provide(Xe.BUILT_IN,[{id:ZM.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>ZM},{id:JM.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>JM},{id:QM.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>QM},{id:tx.key,name:"Drones",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>tx}]);class dc{static kinds(){return __.map(e=>hi.of(e))}}class ji{static SIGHTING_EVENT="sighting";static INTERPRETATION_EVENT="interpretation";static INTERVIEW_EVENT="interview";static check(e){return En.check(e,"case")}static isCase(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.events)&&!("timeline"in e)}static sightingUrls(e,t){return(e.events??[]).filter(i=>i.eventType===ji.SIGHTING_EVENT&&!i.interpretationOf&&typeof i.url=="string"&&i.url!=="").map(i=>new URL(i.url,t).href)}static accountIds(e,t,i,s){const n=(e.events??[]).filter(r=>r.eventType===ji.SIGHTING_EVENT&&r.id!==void 0&&typeof r.url=="string"&&i!==void 0&&new URL(r.url,t).href===i).map(r=>r.id);return s!==void 0&&n.push(s),n}static interpretationEvents(e,t){const i=[t].flat().filter(s=>!!s);return i.length===0?[]:(e.events??[]).filter(s=>s.eventType===ji.INTERPRETATION_EVENT?s.sighting!==void 0&&i.includes(s.sighting):s.eventType!==ji.SIGHTING_EVENT||s.interpretationOf===void 0?!1:[s.interpretationOf].flat().some(n=>i.includes(n))).map(s=>s)}static problems(e,t){const i=e.events??[],s=new Set,n=new Set;for(const a of i)a.id!==void 0&&(s.has(a.id)&&n.add(a.id),s.add(a.id));const r=[];for(const a of i){const o=a.eventType===ji.SIGHTING_EVENT?a.interpretationOf:a.eventType===ji.INTERVIEW_EVENT?a.interviewOf:void 0;if(o!==void 0)for(const c of[o].flat())!s.has(c)&&!t.includes(c)&&r.push({reading:a.url??a.id??"",reference:c})}return{duplicateIds:[...n],unresolved:r}}static async interpretationOf(e,t,i){if(e.bodies)return ji.withModelsFrom(Wt.strip({title:e.title,bodies:e.bodies??[],smoke:e.smoke,findings:e.findings,...hi.computedPart(e,dc.kinds())}).recording,t);if(!e.url)return{title:e.title,bodies:[]};const s=new URL(e.url,t).href,n=await i(s),r="timeline"in n&&n.interpretation?n.interpretation:n;return ji.withModelsFrom(Wt.strip({title:e.title??r.title,bodies:r.bodies??[],smoke:r.smoke,findings:r.findings,...hi.computedPart(r,dc.kinds())}).recording,s)}static withModelsFrom(e,t){return{...e,bodies:e.bodies.map(i=>i.model?.url?{...i,model:{...i.model,url:new URL(i.model.url,t).href}}:i)}}}class de{static draw(e,t="none"){return`<svg class="icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="${t}" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`}static TRASH=de.draw('<path d="M2.5 4.5h11"/><path d="M6 4.5V3h4v1.5"/><path d="M4 4.5l.7 9h6.6l.7-9"/><path d="M6.8 7v4.5M9.2 7v4.5"/>');static TARGET=de.draw('<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="1.6"/><path d="M8 1v2.2M8 12.8V15M1 8h2.2M12.8 8H15"/>');static PLAY=de.draw('<path d="M5 3.2v9.6L12.6 8z"/>',"currentColor");static PAUSE=de.draw('<path d="M5.5 3.5v9M10.5 3.5v9"/>');static RECORD=de.draw('<circle cx="8" cy="8" r="4.2" fill="var(--error, #d93025)" stroke="none"/>');static STOP=de.draw('<rect x="4" y="4" width="8" height="8" rx="1.2"/>',"currentColor");static PREVIOUS_MARK=de.draw('<path d="M6.5 4 2.5 8l4 4"/><path d="M11 5.2 13.8 8 11 10.8 8.2 8z"/>');static NEXT_MARK=de.draw('<path d="M9.5 4l4 4-4 4"/><path d="M5 5.2 7.8 8 5 10.8 2.2 8z"/>');static CLOSE=de.draw('<path d="M4 4l8 8M12 4l-8 8"/>');static PLUS=de.draw('<path d="M8 3v10M3 8h10"/>');static COPY=de.draw('<rect x="5.5" y="5.5" width="8" height="8" rx="1.3"/><path d="M10.5 3.2h-7a1.3 1.3 0 0 0-1.3 1.3v7"/>');static CLOCK=de.draw('<circle cx="8" cy="8" r="6"/><path d="M8 4.6V8l2.4 1.6"/>');static INTERVIEW=de.draw('<path d="M13.3 9.2a1.6 1.6 0 0 1-1.6 1.6H6.2L3 13.4V4.4a1.6 1.6 0 0 1 1.6-1.6h7.1a1.6 1.6 0 0 1 1.6 1.6z"/><path d="M5.8 6.1h5.1M5.8 8.4h3.2"/>');static LOCK=de.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8"/>');static LOCK_OPEN=de.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.6-.7"/>');static METEOR=de.draw('<path d="M2.5 2.5l7 7"/><path d="M5.5 2.5l5 5"/><circle cx="11.5" cy="11.5" r="2"/>');static COMET=de.draw('<circle cx="11" cy="11" r="2.4"/><path d="M9.3 9.3 2.5 2.5M9 11.2 3 7M11.2 9 7 3"/>');static STAR=de.draw('<path d="M8 2.2l1.7 3.6 3.9.5-2.9 2.7.8 3.9L8 11l-3.5 1.9.8-3.9-2.9-2.7 3.9-.5z"/>');static SATELLITE=de.draw('<rect x="6.3" y="6.3" width="3.4" height="3.4" transform="rotate(45 8 8)"/><path d="M5.4 5.4 3 3M10.6 10.6 13 13"/><path d="M1.8 4.2 4.2 1.8M11.8 14.2l2.4-2.4"/><path d="M10.5 3.5a3 3 0 0 1 2 2"/>');static FIREBALL=de.draw('<circle cx="10.5" cy="10.5" r="2.6"/><path d="M8.6 8.6 3 3M8 10.6 4.5 8.5M10.6 8 8.5 4.5"/>');static SUMMARY=de.draw('<rect x="3" y="2" width="10" height="12" rx="1.5"/><path d="M5.5 5.5h5M5.5 8h5M5.5 10.5h3"/>');static WITNESS=de.draw('<circle cx="8" cy="5" r="2.6"/><path d="M2.8 14c.6-3 2.6-4.6 5.2-4.6s4.6 1.6 5.2 4.6"/>');static LOCATION=de.draw('<path d="M8 14.3s4.5-4.3 4.5-7.8a4.5 4.5 0 0 0-9 0c0 3.5 4.5 7.8 4.5 7.8z"/><circle cx="8" cy="6.5" r="1.6"/>');static DATE=de.draw('<rect x="2.3" y="3.3" width="11.4" height="10.4" rx="1.5"/><path d="M2.3 6.6h11.4M5.3 1.8v2.8M10.7 1.8v2.8"/>');static ENVIRONMENT=de.draw('<path d="M1.5 14h13"/><path d="M2.8 14V8.3L6.3 5.5l3.5 2.8V14"/><path d="M12.2 14V9.4"/><circle cx="12.2" cy="7.4" r="2.1"/>');static SKY=de.draw('<path d="M4.6 12.5h7a2.6 2.6 0 0 0 .3-5.2 3.8 3.8 0 0 0-7.3-.6 2.9 2.9 0 0 0 0 5.8z"/>');static PHENOMENON=de.draw('<ellipse cx="8" cy="9" rx="6.3" ry="2.1"/><path d="M4.6 7.8a3.4 3.4 0 0 1 6.8 0"/><path d="M5 13.4l.6-1.4M11 13.4l-.6-1.4M8 14v-1.4"/>');static SOUND=de.draw('<path d="M2.5 6.2h2.3L8 3.5v9L4.8 9.8H2.5z"/><path d="M10.5 6a2.8 2.8 0 0 1 0 4M12.3 4.2a5.4 5.4 0 0 1 0 7.6"/>');static PICTURES=de.draw('<rect x="2" y="3" width="12" height="10" rx="1.5"/><circle cx="5.8" cy="6.4" r="1.2"/><path d="M2.5 12l3.8-3.6 2.4 2.2 2.2-1.8 2.6 2.5"/>');static FILES=de.draw('<path d="M4 1.8h5.2L12.5 5v9.2H4z"/><path d="M9 1.8V5.2h3.5"/>');static BY_GLYPH={"🗑":de.TRASH,"🎯":de.TARGET,"+":de.PLUS,"✕":de.CLOSE,"▶":de.PLAY,"⏸":de.PAUSE,"⏺":de.RECORD,"⏹":de.STOP};static show(e,t){if(e.dataset.icon===t&&e.firstChild)return;const i=de.BY_GLYPH[t];i?e.innerHTML=i:e.textContent=t,e.dataset.icon=t}static CSS=`
|
|
3
3
|
.icon { display: block; flex: none; }
|
|
4
4
|
button:has(> .icon:only-child) { display: inline-flex; align-items: center; justify-content: center; }
|
|
@@ -111,7 +111,7 @@ ${e} :is(select:not([multiple]):not([size]), .rr0-select) {
|
|
|
111
111
|
:where(${e}) :where(.icon-btn) { min-width: 36px; padding: 0; border-radius: 8px; }
|
|
112
112
|
:where(${e}) input[type="range"] { accent-color: var(--glow-solid); }
|
|
113
113
|
:where(${e}) input[type="checkbox"], :where(${e}) input[type="radio"] { accent-color: var(--glow-solid); }
|
|
114
|
-
`}}class ul{constructor(e,t,i=t){this.list=e,this.choose=t,this.follow=i}static CSS=`
|
|
114
|
+
`}}class ul{constructor(e,t,i=t,s,n){this.list=e,this.choose=t,this.follow=i,this.toggle=s,this.fold=n}static CSS=`
|
|
115
115
|
:host {
|
|
116
116
|
--tl-ink: currentColor;
|
|
117
117
|
--tl-ink-dim: color-mix(in srgb, currentColor 80%, transparent);
|
|
@@ -145,6 +145,32 @@ ${e} :is(select:not([multiple]):not([size]), .rr0-select) {
|
|
|
145
145
|
width: 22px; height: 22px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--tl-disc); color: var(--kind);
|
|
146
146
|
pointer-events: none; }
|
|
147
147
|
.event-mark svg { width: 14px; height: 14px; }
|
|
148
|
+
/* Where the host lets several events be open, the mark is what shows one beside the others or puts it away: the card itself opens it
|
|
149
|
+
alone. Above the title's hit area, which runs over the rail. */
|
|
150
|
+
button.event-mark { z-index: 2; padding: 0; border: 1px solid var(--tl-line); font: inherit; cursor: pointer; pointer-events: auto; }
|
|
151
|
+
button.event-mark:hover { border-color: var(--kind); }
|
|
152
|
+
button.event-mark:focus-visible { outline: 2px solid var(--tl-sky); outline-offset: 1px; }
|
|
153
|
+
/* Open, it is ringed in the kind's colour on its disc, never filled: a reading's colour is a translucent grey, which the rail showed through. */
|
|
154
|
+
.event-card[data-open] > button.event-mark { border-color: var(--kind); box-shadow: 0 0 0 1px var(--kind); color: var(--tl-ink); }
|
|
155
|
+
/* A reading grouped under its observation: set in from the rail, on a branch that comes out of the observation's card, its mark on that
|
|
156
|
+
branch. The rail goes on past it, to the next event in time. The branch runs from the card above (the observation, or the reading before)
|
|
157
|
+
down to this mark, and on to the next reading's when there is one. */
|
|
158
|
+
.event-card[data-nested] { --nest: 28px; --branch: calc(-1px - var(--nest) / 2 - 3px); margin-left: var(--nest); }
|
|
159
|
+
.event-card[data-nested]::after { left: calc(var(--rail) - 24px - 1px - var(--nest)); }
|
|
160
|
+
.event-card[data-nested] > .event-mark { left: var(--branch); }
|
|
161
|
+
.event-card[data-nested]::before { content: ""; position: absolute; left: var(--branch); top: calc(-1px - var(--gap));
|
|
162
|
+
bottom: calc(100% - var(--dot-y) - 1px); width: 1px; transform: translateX(-50%); background: var(--tl-ink-faint); pointer-events: none; }
|
|
163
|
+
.event-card[data-nested]:has(+ .event-card[data-nested])::before { bottom: -1px; }
|
|
164
|
+
.event-card[data-nested] .event-open::after { left: calc(-24px - 1px - var(--nest)); }
|
|
165
|
+
/* What folds an observation's readings away or unfolds them: above the title's hit area, at the card's end. */
|
|
166
|
+
.event-fold { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 4px; justify-self: end; grid-column: -2 / -1;
|
|
167
|
+
grid-row: 1; padding: 2px 8px; border: 1px solid var(--tl-line); border-radius: 999px; background: none; color: var(--tl-ink-dim);
|
|
168
|
+
font: 600 12px/1.5 var(--tl-sans); cursor: pointer; }
|
|
169
|
+
.event-fold:hover { color: var(--tl-ink); border-color: var(--tl-ink-faint); }
|
|
170
|
+
.event-fold:focus-visible { outline: 2px solid var(--tl-sky); outline-offset: 2px; }
|
|
171
|
+
.event-fold svg { width: 12px; height: 12px; transition: transform .15s; }
|
|
172
|
+
.event-fold[aria-expanded="false"] svg { transform: rotate(-90deg); }
|
|
173
|
+
.event-main:has(+ .event-fold) { padding-right: 64px; }
|
|
148
174
|
/* What the card is linked to goes UNDER what it says, across the card: beside the title it had a third of the width and wrapped on every
|
|
149
175
|
reference, below it has the whole of it. */
|
|
150
176
|
.event-body { display: grid; grid-template-columns: minmax(96px, auto) minmax(0, 1fr); grid-template-areas: "pill main" "links links";
|
|
@@ -188,7 +214,7 @@ ${e} :is(select:not([multiple]):not([size]), .rr0-select) {
|
|
|
188
214
|
--tl-sky: var(--sky);
|
|
189
215
|
--tl-glow: var(--glow-solid);
|
|
190
216
|
--tl-sans: var(--sans);
|
|
191
|
-
`;static MARKS={observation:de.WITNESS,reading:de.SUMMARY,interview:de.INTERVIEW};static inTime(e,t){const i=n=>{const r=t.when(n);return r!==""||t.kind(n)!=="reading"?r:t.read(n).map(a=>t.when(a)).find(a=>a!=="")??""},s=n=>t.kind(n)==="reading"?1:0;return e.map((n,r)=>({item:n,index:r,when:i(n)})).sort((n,r)=>n.when.localeCompare(r.when)||s(n.item)-s(r.item)||n.index-r.index).map(({item:n,index:r})=>({item:n,index:r}))}static kindLabel(e,t){return{observation:t.kindObservation,reading:t.kindReading,interview:t.kindInterview}[e]}render(e,t,i){this.list.replaceChildren(...e.map(s=>{const n=this.card(s,t);return i?.(s,n),n.card}))}card(e,t){const i=document.createElement("li");i.className="event-card",i.dataset.kind=e.kind,i.dataset.at=String(e.at),e.open&&(i.dataset.open="");const s=document.createElement("span");s.className="kind-pill",s.dataset.kind=e.kind,s.textContent=ul.kindLabel(e.kind,t);const n=document.createElement("div");n.className="event-main";const r=document.createElement("button");r.type="button",r.className="event-open",r.textContent=e.title,r.title=t.openEvent,r.addEventListener("click",()=>this.choose(e.at));const a=document.createElement("span");a.className="event-meta",a.textContent=e.meta,n.append(r,a);const o=document.createElement("span");o.className="event-links",o.append(...this.said(e,t));const c=document.createElement("div");c.className="event-body",c.append(s,n,o);const h=document.createElement("span");return h.className="event-mark",h.innerHTML=ul.MARKS[e.kind],h.setAttribute("aria-hidden","true"),i.append(c,h),{card:i,body:c,links:o}}said(e,t){const i=[],s=e.links?.to??[];if(e.links&&s.length>0){const n=s.map(r=>this.renvoi(r.at,r.title,t));i.push(`${e.links.heading} `,...n.flatMap((r,a)=>a===0?[r]:[document.createTextNode(a===n.length-1?` ${t.linkAnd} `:", "),r]))}return e.by&&i.push(`${i.length>0?" ":""}${t.byAuthor} ${e.by}`),i}renvoi(e,t,i){const s=document.createElement("a");s.href="#",s.className="event-ref",s.textContent=t,s.title=i.openEvent,s.addEventListener("click",r=>{r.preventDefault(),this.follow(e)});const n=r=>this.list.querySelector(`.event-card[data-at="${e}"]`)?.classList.toggle("event-aimed",r);for(const[r,a]of[["mouseenter",!0],["mouseleave",!1],["focus",!0],["blur",!1]])s.addEventListener(r,()=>n(a));return s}}class Jt{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(e,t){return`${e}.${t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}.json`}static taken(e,t){const i={};if(e==="decor")return Array.isArray(t.decor)&&(i.decor=t.decor.filter(Jt.surveyed)),i;for(const s of Jt.KEYS[e])t[s]!==void 0&&(i[s]=t[s]);return i}static strip(e,t){if(e==="decor"){const i=Array.isArray(t.decor)?t.decor.filter(s=>!Jt.surveyed(s)):[];i.length>0?t.decor=i:delete t.decor;return}for(const i of Jt.KEYS[e])delete t[i]}static put(e,t,i){if(e==="decor"){if(!Array.isArray(i.decor))return;const s=Array.isArray(t.decor)?t.decor.filter(n=>!Jt.surveyed(n)):[];t.decor=[...s,...i.decor];return}for(const s of Jt.KEYS[e])i[s]!==void 0&&(t[s]=i[s])}static surveyed(e){return typeof e=="object"&&e!==null&&typeof e.origin=="string"}static fromFile(e,t){return e?.[t]!==void 0&&e[t].live!==!0}}class us{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(e,t){if(!e||e.live)return;const i=e[t];return i&&!i.live&&!i.refresh&&i.src!==void 0?i:void 0}static isLive(e,t){return e?.live===!0||e?.[t]?.live===!0}static annexName(e,t){const i=t==="relief"||t==="imagery"||t==="map"?"zip":"json",s=t.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return`${e}.${s}.${i}`}static isEmpty(e){return!e||!e.live&&us.NAMES.every(t=>!e[t])&&Jt.NAMES.every(t=>!e[t])}}class Vl extends Error{constructor(e,t,i){super(`${e}: ${t}${i===void 0?"":` (HTTP ${i})`}`),this.kind=e,this.url=t,this.status=i,this.name="SightingFetchError"}}class Fa{static async recording(e){const t=await Fa.json(e);for(const i of Jt.NAMES){const s=t?.snapshots?.[i];if(!(!s?.src||s.live))try{const n=En.recording(await Fa.json(new URL(s.src,new URL(e,location.href)).href));Jt.put(i,t,n)}catch{}}return t}static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new Vl("mixed-content",e);let i;try{i=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!i.ok)throw new Vl("status",e,i.status);try{return await i.json()}catch{throw new Vl("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new Vl("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new Vl("cors",e)}catch{return new Vl("unreachable",e)}}}class lo{static PACKAGE="@rr0/ufoathome";static CDN="https://cdn.jsdelivr.net/npm";static DIRECTORIES={"rr0-sighting":"dist-embed-sighting","rr0-sighting-editor":"dist-embed-sighting-editor"};static current(e,t,i){const s=new URL(`${e}.mjs`,t);return s.href.startsWith(`${lo.CDN}/`)?`${i}/lib/${e}.mjs`:(s.pathname=s.pathname.replace(/\/lib\/\d+\.\d+\.\d+[^/]*\//,"/lib/"),s.href)}static VERSION_PARAMETER="v";static pinnable(e){return e in lo.DIRECTORIES}static pinnedLink(e,t){const i=new URL(e);return i.searchParams.set(lo.VERSION_PARAMETER,t),i.href}static pinned(e,t){return`${lo.CDN}/${lo.PACKAGE}@${t}/${lo.DIRECTORIES[e]}/${e}.mjs`}}class lu{static PRODUCTION="https://ufoathome.org";static home(){try{const e=new URL(import.meta.url),t=new URL(location.href);return(t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="[::1]"||t.hostname.endsWith(".localhost"))&&e.origin===t.origin?t.origin:lu.PRODUCTION}catch{return lu.PRODUCTION}}}const Ba=["en","fr","es","it"],D_={en:()=>V(()=>import("./UfoMessages_en-FAvzKxmR.js"),[],import.meta.url).then(l=>l.ufoMessages_en),fr:()=>V(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(l=>l.ufoMessages_fr),es:()=>V(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(l=>l.ufoMessages_es),it:()=>V(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(l=>l.ufoMessages_it)},k_=yi.catalog(D_),R_={en:()=>V(()=>import("./SightingEditorMessages_en-DSPvgYFi.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_en),fr:()=>V(()=>import("./SightingEditorMessages_fr-BTmWQX0n.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_fr),es:()=>V(()=>import("./SightingEditorMessages_es-Bl3DipHr.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_es),it:()=>V(()=>import("./SightingEditorMessages_it-lzbDsHjx.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_it)},xw=yi.catalog(R_);function YB(l){return xw.load(l)}const C_={en:()=>V(()=>import("./ShareMessages_en-B43x8LgJ.js"),[],import.meta.url).then(l=>l.shareMessages_en),fr:()=>V(()=>import("./ShareMessages_fr-CzZyVbbX.js"),[],import.meta.url).then(l=>l.shareMessages_fr),es:()=>V(()=>import("./ShareMessages_es-DZCJojSc.js"),[],import.meta.url).then(l=>l.shareMessages_es),it:()=>V(()=>import("./ShareMessages_it-C_Z6eDQK.js"),[],import.meta.url).then(l=>l.shareMessages_it)},O_=yi.catalog(C_);function L_(l){switch(l){case"fr":return V(()=>import("./TagNames_fr-Dnqq6HQ5.js"),[],import.meta.url).then(e=>e.tagNames_fr);case"es":return V(()=>import("./TagNames_es-BfnMpc3D.js"),[],import.meta.url).then(e=>e.tagNames_es);case"it":return V(()=>import("./TagNames_it-n6E4EGYO.js"),[],import.meta.url).then(e=>e.tagNames_it);default:return Promise.resolve({})}}const P_={en:()=>V(()=>import("./BodyEditorMessages_en-CckxSS1L.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_en),fr:()=>V(()=>import("./BodyEditorMessages_fr-638ypdqf.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_fr),es:()=>V(()=>import("./BodyEditorMessages_es-B8GlFFBo.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_es),it:()=>V(()=>import("./BodyEditorMessages_it-SKpMkHFI.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_it)},N_={en:()=>V(()=>import("./CaseEditorMessages_en-DrJY0M8h.js"),[],import.meta.url).then(l=>l.caseEditorMessages_en),fr:()=>V(()=>import("./CaseEditorMessages_fr-BkwEF9mu.js"),[],import.meta.url).then(l=>l.caseEditorMessages_fr),es:()=>V(()=>import("./CaseEditorMessages_es-j8EeOBq6.js"),[],import.meta.url).then(l=>l.caseEditorMessages_es),it:()=>V(()=>import("./CaseEditorMessages_it-d3Z0PBEw.js"),[],import.meta.url).then(l=>l.caseEditorMessages_it)},F_={en:()=>V(()=>import("./ReadingSensitivityMessages_en-ChQHFyxb.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_en),fr:()=>V(()=>import("./ReadingSensitivityMessages_fr-Dl4a8udu.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_fr),es:()=>V(()=>import("./ReadingSensitivityMessages_es-BbFqHsvR.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_es),it:()=>V(()=>import("./ReadingSensitivityMessages_it-CwiJfUo_.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_it)},pT=yi.catalog(F_),U_={en:()=>V(()=>import("./CaseExportMessages_en-jHlu58Y7.js"),[],import.meta.url).then(l=>l.caseExportMessages_en),fr:()=>V(()=>import("./CaseExportMessages_fr-sDfEgjWg.js"),[],import.meta.url).then(l=>l.caseExportMessages_fr),es:()=>V(()=>import("./CaseExportMessages_es-dCQQFgjq.js"),[],import.meta.url).then(l=>l.caseExportMessages_es),it:()=>V(()=>import("./CaseExportMessages_it-BJaglZtP.js"),[],import.meta.url).then(l=>l.caseExportMessages_it)},B_=yi.catalog(U_),z_={en:()=>V(()=>import("./InterviewMessages_en-ru7GkZlQ.js"),[],import.meta.url).then(l=>l.interviewMessages_en),fr:()=>V(()=>import("./InterviewMessages_fr-DAYgf8Ms.js"),[],import.meta.url).then(l=>l.interviewMessages_fr),es:()=>V(()=>import("./InterviewMessages_es-DkJurNrG.js"),[],import.meta.url).then(l=>l.interviewMessages_es),it:()=>V(()=>import("./InterviewMessages_it-6lenkmSg.js"),[],import.meta.url).then(l=>l.interviewMessages_it)},qB=yi.catalog(z_),H_=yi.catalog(N_),jB=yi.catalog(P_),G_=yi.catalog({en:()=>V(()=>import("./SceneNames_en-9zK_E4jO.js"),[],import.meta.url).then(l=>l.sceneNames_en),fr:()=>V(()=>import("./SceneNames_fr-lUEwaxUk.js"),[],import.meta.url).then(l=>l.sceneNames_fr),es:()=>V(()=>import("./SceneNames_es-B6FtSh6r.js"),[],import.meta.url).then(l=>l.sceneNames_es),it:()=>V(()=>import("./SceneNames_it-ChU8RE2E.js"),[],import.meta.url).then(l=>l.sceneNames_it)});function fT(l){return G_.load(l)}const V_=yi.catalog({en:()=>V(()=>import("./CloudEditorMessages_en-SmcRKW1O.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_en),fr:()=>V(()=>import("./CloudEditorMessages_fr-SvL-CR04.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_fr),es:()=>V(()=>import("./CloudEditorMessages_es-DFCuS9Qg.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_es),it:()=>V(()=>import("./CloudEditorMessages_it-BvfiHWV9.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_it)}),W_=`
|
|
217
|
+
`;static MARKS={observation:de.WITNESS,reading:de.SUMMARY,interview:de.INTERVIEW};static inTime(e,t){const i=n=>{const r=t.when(n);return r!==""||t.kind(n)!=="reading"?r:t.read(n).map(a=>t.when(a)).find(a=>a!=="")??""},s=n=>t.kind(n)==="reading"?1:0;return e.map((n,r)=>({item:n,index:r,when:i(n)})).sort((n,r)=>n.when.localeCompare(r.when)||s(n.item)-s(r.item)||n.index-r.index).map(({item:n,index:r})=>({item:n,index:r}))}static grouped(e,t){const i=new Set(e.filter(({item:r})=>t.kind(r)==="observation").map(({item:r})=>r)),s=new Map;for(const{item:r}of e){if(t.kind(r)!=="reading")continue;const a=t.read(r).filter(o=>i.has(o));a.length>0&&s.set(r,a)}const n=[];for(const r of e)if(!s.has(r.item)&&(n.push(r),!!i.has(r.item)))for(const a of e)s.get(a.item)?.includes(r.item)&&n.push({...a,under:r.item});return n}static kindLabel(e,t){return{observation:t.kindObservation,reading:t.kindReading,interview:t.kindInterview}[e]}render(e,t,i){this.list.replaceChildren(...e.map(s=>{const n=this.card(s,t);return i?.(s,n),n.card}))}card(e,t){const i=document.createElement("li");i.className="event-card",i.dataset.kind=e.kind,i.dataset.at=String(e.at),e.open&&(i.dataset.open=""),e.nested&&(i.dataset.nested="");const s=document.createElement("span");s.className="kind-pill",s.dataset.kind=e.kind,s.textContent=ul.kindLabel(e.kind,t);const n=document.createElement("div");n.className="event-main";const r=document.createElement("button");r.type="button",r.className="event-open",r.textContent=e.title,r.title=t.openEvent,r.addEventListener("click",()=>this.choose(e.at));const a=document.createElement("span");a.className="event-meta",a.textContent=e.meta,n.append(r,a);const o=document.createElement("span");o.className="event-links",o.append(...this.said(e,t));const c=document.createElement("div");if(c.className="event-body",c.append(s,n),e.readings&&e.readings.count>0&&this.fold){const d=document.createElement("button");d.type="button",d.className="event-fold",d.setAttribute("aria-expanded",String(!e.readings.folded)),d.title=(e.readings.folded?t.unfoldReadings:t.foldReadings)??"",d.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg>',d.append(String(e.readings.count)),d.addEventListener("click",()=>this.fold(e.at)),c.append(d)}c.append(o);const h=document.createElement(this.toggle?"button":"span");return h.className="event-mark",h.innerHTML=ul.MARKS[e.kind],h instanceof HTMLButtonElement?(h.type="button",h.title=t.toggleEvent??t.openEvent,h.setAttribute("aria-label",`${h.title} — ${e.title}`),h.setAttribute("aria-pressed",String(e.open===!0)),h.addEventListener("click",()=>this.toggle(e.at))):h.setAttribute("aria-hidden","true"),i.append(c,h),{card:i,body:c,links:o}}said(e,t){const i=[],s=e.links?.to??[];if(e.links&&s.length>0){const n=s.map(r=>this.renvoi(r.at,r.title,t));i.push(`${e.links.heading} `,...n.flatMap((r,a)=>a===0?[r]:[document.createTextNode(a===n.length-1?` ${t.linkAnd} `:", "),r]))}return e.by&&i.push(`${i.length>0?" ":""}${t.byAuthor} ${e.by}`),i}renvoi(e,t,i){const s=document.createElement("a");s.href="#",s.className="event-ref",s.textContent=t,s.title=i.openEvent,s.addEventListener("click",r=>{r.preventDefault(),this.follow(e)});const n=r=>this.list.querySelectorAll(`.event-card[data-at="${e}"]`).forEach(a=>a.classList.toggle("event-aimed",r));for(const[r,a]of[["mouseenter",!0],["mouseleave",!1],["focus",!0],["blur",!1]])s.addEventListener(r,()=>n(a));return s}}class Jt{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(e,t){return`${e}.${t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}.json`}static taken(e,t){const i={};if(e==="decor")return Array.isArray(t.decor)&&(i.decor=t.decor.filter(Jt.surveyed)),i;for(const s of Jt.KEYS[e])t[s]!==void 0&&(i[s]=t[s]);return i}static strip(e,t){if(e==="decor"){const i=Array.isArray(t.decor)?t.decor.filter(s=>!Jt.surveyed(s)):[];i.length>0?t.decor=i:delete t.decor;return}for(const i of Jt.KEYS[e])delete t[i]}static put(e,t,i){if(e==="decor"){if(!Array.isArray(i.decor))return;const s=Array.isArray(t.decor)?t.decor.filter(n=>!Jt.surveyed(n)):[];t.decor=[...s,...i.decor];return}for(const s of Jt.KEYS[e])i[s]!==void 0&&(t[s]=i[s])}static surveyed(e){return typeof e=="object"&&e!==null&&typeof e.origin=="string"}static fromFile(e,t){return e?.[t]!==void 0&&e[t].live!==!0}}class us{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(e,t){if(!e||e.live)return;const i=e[t];return i&&!i.live&&!i.refresh&&i.src!==void 0?i:void 0}static isLive(e,t){return e?.live===!0||e?.[t]?.live===!0}static annexName(e,t){const i=t==="relief"||t==="imagery"||t==="map"?"zip":"json",s=t.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return`${e}.${s}.${i}`}static isEmpty(e){return!e||!e.live&&us.NAMES.every(t=>!e[t])&&Jt.NAMES.every(t=>!e[t])}}class Vl extends Error{constructor(e,t,i){super(`${e}: ${t}${i===void 0?"":` (HTTP ${i})`}`),this.kind=e,this.url=t,this.status=i,this.name="SightingFetchError"}}class Fa{static async recording(e){const t=await Fa.json(e);for(const i of Jt.NAMES){const s=t?.snapshots?.[i];if(!(!s?.src||s.live))try{const n=En.recording(await Fa.json(new URL(s.src,new URL(e,location.href)).href));Jt.put(i,t,n)}catch{}}return t}static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new Vl("mixed-content",e);let i;try{i=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!i.ok)throw new Vl("status",e,i.status);try{return await i.json()}catch{throw new Vl("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new Vl("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new Vl("cors",e)}catch{return new Vl("unreachable",e)}}}class lo{static PACKAGE="@rr0/ufoathome";static CDN="https://cdn.jsdelivr.net/npm";static DIRECTORIES={"rr0-sighting":"dist-embed-sighting","rr0-sighting-editor":"dist-embed-sighting-editor"};static current(e,t,i){const s=new URL(`${e}.mjs`,t);return s.href.startsWith(`${lo.CDN}/`)?`${i}/lib/${e}.mjs`:(s.pathname=s.pathname.replace(/\/lib\/\d+\.\d+\.\d+[^/]*\//,"/lib/"),s.href)}static VERSION_PARAMETER="v";static pinnable(e){return e in lo.DIRECTORIES}static pinnedLink(e,t){const i=new URL(e);return i.searchParams.set(lo.VERSION_PARAMETER,t),i.href}static pinned(e,t){return`${lo.CDN}/${lo.PACKAGE}@${t}/${lo.DIRECTORIES[e]}/${e}.mjs`}}class lu{static PRODUCTION="https://ufoathome.org";static home(){try{const e=new URL(import.meta.url),t=new URL(location.href);return(t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="[::1]"||t.hostname.endsWith(".localhost"))&&e.origin===t.origin?t.origin:lu.PRODUCTION}catch{return lu.PRODUCTION}}}const Ba=["en","fr","es","it"],D_={en:()=>V(()=>import("./UfoMessages_en-FAvzKxmR.js"),[],import.meta.url).then(l=>l.ufoMessages_en),fr:()=>V(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(l=>l.ufoMessages_fr),es:()=>V(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(l=>l.ufoMessages_es),it:()=>V(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(l=>l.ufoMessages_it)},k_=yi.catalog(D_),R_={en:()=>V(()=>import("./SightingEditorMessages_en-DSPvgYFi.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_en),fr:()=>V(()=>import("./SightingEditorMessages_fr-BTmWQX0n.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_fr),es:()=>V(()=>import("./SightingEditorMessages_es-Bl3DipHr.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_es),it:()=>V(()=>import("./SightingEditorMessages_it-lzbDsHjx.js"),[],import.meta.url).then(l=>l.sightingEditorMessages_it)},xw=yi.catalog(R_);function YB(l){return xw.load(l)}const C_={en:()=>V(()=>import("./ShareMessages_en-B43x8LgJ.js"),[],import.meta.url).then(l=>l.shareMessages_en),fr:()=>V(()=>import("./ShareMessages_fr-CzZyVbbX.js"),[],import.meta.url).then(l=>l.shareMessages_fr),es:()=>V(()=>import("./ShareMessages_es-DZCJojSc.js"),[],import.meta.url).then(l=>l.shareMessages_es),it:()=>V(()=>import("./ShareMessages_it-C_Z6eDQK.js"),[],import.meta.url).then(l=>l.shareMessages_it)},O_=yi.catalog(C_);function L_(l){switch(l){case"fr":return V(()=>import("./TagNames_fr-Dnqq6HQ5.js"),[],import.meta.url).then(e=>e.tagNames_fr);case"es":return V(()=>import("./TagNames_es-BfnMpc3D.js"),[],import.meta.url).then(e=>e.tagNames_es);case"it":return V(()=>import("./TagNames_it-n6E4EGYO.js"),[],import.meta.url).then(e=>e.tagNames_it);default:return Promise.resolve({})}}const P_={en:()=>V(()=>import("./BodyEditorMessages_en-CckxSS1L.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_en),fr:()=>V(()=>import("./BodyEditorMessages_fr-638ypdqf.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_fr),es:()=>V(()=>import("./BodyEditorMessages_es-B8GlFFBo.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_es),it:()=>V(()=>import("./BodyEditorMessages_it-SKpMkHFI.js"),[],import.meta.url).then(l=>l.bodyEditorMessages_it)},N_={en:()=>V(()=>import("./CaseEditorMessages_en-DrJY0M8h.js"),[],import.meta.url).then(l=>l.caseEditorMessages_en),fr:()=>V(()=>import("./CaseEditorMessages_fr-BkwEF9mu.js"),[],import.meta.url).then(l=>l.caseEditorMessages_fr),es:()=>V(()=>import("./CaseEditorMessages_es-j8EeOBq6.js"),[],import.meta.url).then(l=>l.caseEditorMessages_es),it:()=>V(()=>import("./CaseEditorMessages_it-d3Z0PBEw.js"),[],import.meta.url).then(l=>l.caseEditorMessages_it)},F_={en:()=>V(()=>import("./ReadingSensitivityMessages_en-ChQHFyxb.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_en),fr:()=>V(()=>import("./ReadingSensitivityMessages_fr-Dl4a8udu.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_fr),es:()=>V(()=>import("./ReadingSensitivityMessages_es-BbFqHsvR.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_es),it:()=>V(()=>import("./ReadingSensitivityMessages_it-CwiJfUo_.js"),[],import.meta.url).then(l=>l.readingSensitivityMessages_it)},pT=yi.catalog(F_),U_={en:()=>V(()=>import("./CaseExportMessages_en-jHlu58Y7.js"),[],import.meta.url).then(l=>l.caseExportMessages_en),fr:()=>V(()=>import("./CaseExportMessages_fr-sDfEgjWg.js"),[],import.meta.url).then(l=>l.caseExportMessages_fr),es:()=>V(()=>import("./CaseExportMessages_es-dCQQFgjq.js"),[],import.meta.url).then(l=>l.caseExportMessages_es),it:()=>V(()=>import("./CaseExportMessages_it-BJaglZtP.js"),[],import.meta.url).then(l=>l.caseExportMessages_it)},B_=yi.catalog(U_),z_={en:()=>V(()=>import("./InterviewMessages_en-ru7GkZlQ.js"),[],import.meta.url).then(l=>l.interviewMessages_en),fr:()=>V(()=>import("./InterviewMessages_fr-DAYgf8Ms.js"),[],import.meta.url).then(l=>l.interviewMessages_fr),es:()=>V(()=>import("./InterviewMessages_es-DkJurNrG.js"),[],import.meta.url).then(l=>l.interviewMessages_es),it:()=>V(()=>import("./InterviewMessages_it-6lenkmSg.js"),[],import.meta.url).then(l=>l.interviewMessages_it)},qB=yi.catalog(z_),H_=yi.catalog(N_),jB=yi.catalog(P_),G_=yi.catalog({en:()=>V(()=>import("./SceneNames_en-9zK_E4jO.js"),[],import.meta.url).then(l=>l.sceneNames_en),fr:()=>V(()=>import("./SceneNames_fr-lUEwaxUk.js"),[],import.meta.url).then(l=>l.sceneNames_fr),es:()=>V(()=>import("./SceneNames_es-B6FtSh6r.js"),[],import.meta.url).then(l=>l.sceneNames_es),it:()=>V(()=>import("./SceneNames_it-ChU8RE2E.js"),[],import.meta.url).then(l=>l.sceneNames_it)});function fT(l){return G_.load(l)}const V_=yi.catalog({en:()=>V(()=>import("./CloudEditorMessages_en-SmcRKW1O.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_en),fr:()=>V(()=>import("./CloudEditorMessages_fr-SvL-CR04.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_fr),es:()=>V(()=>import("./CloudEditorMessages_es-DFCuS9Qg.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_es),it:()=>V(()=>import("./CloudEditorMessages_it-BvfiHWV9.js"),[],import.meta.url).then(l=>l.cloudEditorMessages_it)}),W_=`
|
|
192
218
|
<style>
|
|
193
219
|
/* What the dialog is drawn with: light by default, and the dark set when the system asks for it, as the player and the editors
|
|
194
220
|
are. The form controls follow through color-scheme. Defined here and not by the host, so that any element can hold this dialog;
|
|
@@ -414,8 +440,8 @@ ${e} :is(select:not([multiple]):not([size]), .rr0-select) {
|
|
|
414
440
|
<button id="copy" class="share-copy" type="button"></button>
|
|
415
441
|
</div>
|
|
416
442
|
</dialog>
|
|
417
|
-
`;class $d extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get($d.TAG)||customElements.define($d.TAG,$d)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=W_;const e=t=>this.shadow.getElementById(t);this.dialog=e("dialog"),this.linkField=e("link"),this.copyButton=e("copy"),this.linkBox=e("link-box"),this.embedBox=e("embed-box"),this.linkOption=e("link-option"),this.embedOption=e("embed-option"),this.pin=e("pin"),this.embedMarkup=e("embed-markup"),this.noteElement=e("note"),e("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",t=>{t.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(e){const t=++this.languageToken,i=await O_.load(e);if(t===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(e){this.noteElement.textContent=e??"",this.noteElement.hidden=e===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const e=this.subject;if(!e)return;const t=this.pin.checked;this.linkField.value=t?lo.pinnedLink(e.link(),"0.
|
|
418
|
-
${e.element()}`;this.embedMarkup.value=s,this.codeEditor&&(this.codeEditor.text=s)}applyMessages(){const e=this.messages;if(!e)return;const t=(i,s)=>{this.shadow.getElementById(i).textContent=s};t("title",e.share),t("link-label",e.link),t("embed-label",e.embed),t("copy",e.copy),t("pin-label",e.pin.replace("{version}","0.191.1")),this.pin.parentElement.title=e.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",e.close),this.linkField.setAttribute("aria-label",e.link)}show(e){this.linkBox.hidden=e!=="link",this.embedBox.hidden=e!=="embed",this.linkOption.setAttribute("aria-pressed",String(e==="link")),this.embedOption.setAttribute("aria-pressed",String(e==="embed")),e==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=V(async()=>{const{ShareCodeEditor:e}=await import("./ShareCodeEditor-CF7IVeXv.js");return{ShareCodeEditor:e}},__vite__mapDeps([7,8]),import.meta.url).then(({ShareCodeEditor:e})=>{this.codeEditor=new e(this.shadow.getElementById("embed-code"),this.embedMarkup.value,t=>{this.embedMarkup.value=t},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(e,t){try{await navigator.clipboard.writeText(e),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{t.select()}}}class Ur extends Error{}class Xg{constructor(e){this.name=e}validate(e){return!0}}class mT extends Xg{min;max;constructor(e,t,i){super(e),this.min=t,this.max=i}validate(e){if(typeof e!="number")throw new Ur(`${this.name} value must be a number, but was ${e}`);if(e<this.min||e>this.max)throw new Ur(`${this.name} value must be >= ${this.min} and <= ${this.max}, but was ${e}`);return super.validate(e)}}class Pi{name;min;max;duration;subUnit;validator;constructor(e,t,i,s,n=new mT(e,t,i)){this.name=e,this.min=t,this.max=i,this.subUnit=s,this.duration=s?(s.max-s.min+1)*s.duration:1,this.validator=n}validate(e){return this.validator.validate(e)}[Symbol.iterator](){let e=this.min;return{next:()=>{const t={done:e>this.max,value:e};return e++,t}}}}class Ew{millisecond;second;minute;hour;day;month;year}class $_ extends Ew{}class gT extends $_{millisecond=new Pi("millisecond",0,999,void 0);second=new Pi("second",0,59,this.millisecond);minute=new Pi("minute",0,59,this.second);hour=new Pi("hour",0,23,this.minute);day=new Pi("day",1,31,this.hour);month=new Pi("month",1,12,this.day);year=new Pi("year",0,9999,this.month)}const gt=new gT;class vT extends mT{constructor(e=1,t=12){super("month",e,t)}}class Sd extends Pi{static Month28=new Sd(28);static Month29=new Sd(29);static ThirtyDays=new Sd(30);static ThirtyOneDays=new Sd(31);constructor(e,t=new vT(1,e)){super("month",1,e,gt.day,t)}static create(e,t){switch(e){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return this.ThirtyOneDays;case 2:return t%4===0?this.Month29:this.Month28;case 4:case 6:case 9:case 11:return this.ThirtyDays;default:throw new Ur("Unsupported month",e,t)}}}class yo{static instance=new yo;render(e){return e.value.toString()}}class jn{unit;#e;constructor(e,t){this.unit=t,this.value=typeof e=="number"?e:e.value}get value(){return this.#e}set value(e){this.unit.validate(e),this.#e=e}get duration(){return this.value*this.unit.duration}#t(e){if(this.constructor.name!==e.constructor.name)throw new Xg(`${this.unit.name} "${this.toString()}" cannot be compared with ${e.unit?.name} "${e.toString()}"`)}compare(e){return this.#t(e),this.value-e.value}isEqual(e){return this.compare(e)===0}isBefore(e){return this.compare(e)<0}isAfter(e){return this.compare(e)>0}previous(e=this.unit){const t=this.value-1;return new this.constructor(t,e)}next(e=this.unit){const t=this.value+1;return new this.constructor(t,e)}toString(e=yo.instance){return e.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class Be{static#e=new Map;static register(e,t){Be.#e.set(e,t)}static get(e){const t=Be.#e.get(e);if(!t)throw new Ur(`No default parser registered for ${e.name}: import "@rr0/time/defaults" or pass a parser to fromString()`);return t()}}class hu extends jn{constructor(e=new Date().getFullYear(),t=gt.year){super(e,t)}static fromString(e,t=Be.get(hu)){return new hu(t.parse(e))}}class Co extends yo{static default=new Co("0",2);constructor(e,t){super(),this.char=e,this.size=t}render(e){return super.render(e).padStart(this.size,this.char)}}class du extends jn{constructor(e=new Date().getMonth()+1,t=gt.month){super(e,t)}static fromString(e,t=Be.get(du)){return new du(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class uu extends jn{constructor(e=new Date().getDate(),t=gt.day){super(e,t)}static fromString(e,t=Be.get(uu)){const i=t.parse(e);return new uu(i)}toString(e=Co.default){return super.toString(e)}}class pu extends jn{constructor(e=new Date().getHours(),t=gt.hour){super(e,t)}static fromString(e,t=Be.get(pu)){return new pu(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class fu extends jn{constructor(e=new Date().getMinutes(),t=gt.minute){super(e,t)}static fromString(e,t=Be.get(fu)){return new fu(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class mu extends jn{constructor(e=new Date().getSeconds(),t=gt.second){super(e,t)}static fromString(e,t=Be.get(mu)){return new mu(t.parse(e),gt.second)}toString(e=Co.default){return super.toString(e)}}class Tl extends jn{static renderer=new Co("0",3);constructor(e,t=gt.millisecond){super(e,t)}static parseFraction(e){return parseInt(e.padEnd(3,"0").substring(0,3),10)}toString(e=Tl.renderer){return super.toString(e)}}class K_{render(e){return e.toString()}}class X_ extends K_{render(e){const t=e.value,i=Math.abs(t),s=Math.floor(i/60),n=i%60;if(s===0&&n===0)return"Z";{const r=t<0?"-":"+",a=s.toString().padStart(2,"0"),o=n>0?":"+n.toString().padEnd(2,"0"):"";return r+a+o}}}class bl{value;name="timeshift";renderer;constructor(e=0){this.value=e}static fromString(e,t=Be.get(bl),i=void 0){const s=t.parse(e,i);return new bl(s)}toString(e=new X_){return e.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class Vn{static timeshift(e,t){return e+(Vn.isDaylight(t)?60:0)}static isDaylight(e){const{year:t,month:i,day:s}=e,n=e.hour??12;if(![t,i,s].every(Number.isInteger))throw new RangeError("Daylight saving time depends on the year, month and day");const r=Vn.rule(t);if(!r)return!1;const a=Vn.rank(i,s,n);return a>=Vn.rank(r.start.month,r.start.day,2)&&a<Vn.rank(r.end.month,r.end.day,2)}static rule(e){if(e<1967)return;const t={month:10,day:Vn.sunday(e,10,-1)};return e>=2007?{start:{month:3,day:Vn.sunday(e,3,2)},end:{month:11,day:Vn.sunday(e,11,1)}}:e>=1987?{start:{month:4,day:Vn.sunday(e,4,1)},end:t}:e===1975?{start:{month:2,day:23},end:t}:e===1974?{start:{month:1,day:6},end:t}:{start:{month:4,day:Vn.sunday(e,4,-1)},end:t}}static sunday(e,t,i){const s=new Date(Date.UTC(2e3,t-1,1));s.setUTCFullYear(e);const n=1+(7-s.getUTCDay())%7;if(i>0)return n+7*(i-1);const r=[31,Vn.isLeap(e)?29:28,31,30,31,30,31,31,30,31,30,31][t-1];let a=n;for(;a+7<=r;)a+=7;return a}static isLeap(e){return e%4===0&&(e%100!==0||e%400===0)}static rank(e,t,i){return(e*100+t)*100+i}}const Y_={name:"PST",timeshift:"-08",title:"Pacific Standard Time (US)"},q_={name:"PDT",timeshift:"-07",title:"Pacific Daylight Time (US)"},j_={name:"MDT",timeshift:"-06",title:"Mountain Standard Time (US)"},Z_={name:"MST",timeshift:"-07",title:"Mountain Daylight Time (US)"},J_={name:"PT",timeshift:l=>Vn.timeshift(-480,l),title:"Pacific Time (US)"},Q_={name:"MT",timeshift:l=>Vn.timeshift(-420,l),title:"Mountain Time (US)"},e5={name:"CT",timeshift:l=>Vn.timeshift(-360,l),title:"Central Time (US)"},t5={name:"ET",timeshift:l=>Vn.timeshift(-300,l),title:"Eastern Time (US)"},i5={name:"CWT",timeshift:"-05",title:"Central War Time (US)"},s5={name:"CDT",timeshift:"-05",title:"Central Daylight Time"},n5={name:"EST",timeshift:"-05",title:"Eastern Standard Time (US)"},r5={name:"EDT",timeshift:"-04",title:"Eastern Time (US)"},a5={name:"AST",timeshift:"-04",title:"Atlantic Standard Time (US)"},o5={name:"ADT",timeshift:"-03",title:"Atlantic Daylight Time (US)"},c5={name:"UTC",timeshift:"Z",title:"Coordinated Universal Time"},l5={name:"Z",timeshift:"Z",title:"UTC"},h5={name:"GMT",timeshift:"Z",title:"Greenwich Mean Time"},d5={name:"BST",timeshift:"+01",title:"British Summer Time"},u5={name:"CEST",timeshift:"+02",title:"Central European Summer Time"},p5={name:"CET",timeshift:"+01",title:"Central European Time"},f5={name:"MSK",timeshift:"+03",title:"Moscow Time (RU)"},m5={name:"IST",timeshift:"+05:30",title:"Indian Standard Time"},g5={name:"BJT",timeshift:"+08",title:"Beijing Time"},v5={name:"CST",timeshift:"-06",title:"Central Standard Time"},b5={name:"JST",timeshift:"+09",title:"Japan Standard Time"},y5={name:"AEST",timeshift:"+10",title:"Australian Eastern Standard Time"},w5={name:"NZST",timeshift:"+12",title:"New Zealand Standard Time"},M5={name:"LST",timeshift:"?",title:"Local Sideral Time"},ix=[o5,y5,a5,g5,d5,v5,s5,p5,u5,e5,i5,r5,n5,t5,h5,m5,b5,M5,j_,f5,Z_,Q_,w5,q_,Y_,J_,c5,l5];class Yg{static instance=new Yg;renderComponent(e,t){return e[t].toString()}renderSecond(e){return this.renderComponent(e,"second")+(e.millisecond?"."+e.millisecond.toString():"")}render(e){const t=[];e.year&&t.push(this.renderComponent(e,"year")),e.month&&t.push(this.renderComponent(e,"month")),e.day&&t.push(this.renderComponent(e,"day"));const i=[];e.hour&&i.push(this.renderComponent(e,"hour")),e.minute&&i.push(this.renderComponent(e,"minute")),e.second&&i.push(this.renderSecond(e));const s=t.join("-"),n=e.timeshift?e.timeshift.toString():"",r=i.join(":")+n;return s+(r.length>0?"T"+r:"")}}class Wl extends Ur{constructor(e="method is abstract"){super(e)}}class Sw{units;constructor(e){this.units=e}newYear(e){throw new Wl}newMonth(e){throw new Wl}newDay(e){throw new Wl}newHour(e){throw new Wl}newMinute(e){throw new Wl}newSecond(e){throw new Wl}}class x5 extends Ew{millisecond=new Pi("milliseconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,void 0);second=new Pi("seconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new Pi("minutes",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.second);hour=new Pi("hours",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.minutes);day=new Pi("days",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.hour);month=new Pi("months",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.day);year=new Pi("years",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const Hf=new x5;class qg{static instance=new qg;render(e){const t=Ua.toSpec(e);let i="P";const s=t.years;s&&(i+=s.toString()+"Y");const n=t.months;n&&(i+=n.toString(yo.instance)+"MM");const r=t.days;r&&(i+=r.toString(yo.instance)+"D");const a=t.hours;a&&(i+=a.toString(yo.instance)+"H");const o=t.minutes;o&&(i+=o.toString(yo.instance)+"M");const c=t.seconds;return c&&(i+=c.toString(yo.instance)+"S"),i}}class Ua extends jn{constructor(e={years:new Date().getFullYear(),months:new Date().getMonth(),days:new Date().getDate(),hours:new Date().getHours(),minutes:new Date().getMinutes(),seconds:new Date().getSeconds(),milliseconds:new Date().getMilliseconds()}){super({value:typeof e=="number"?e:+(e.years?e.years*gt.year.duration:0)+(e.months?e.months*gt.month.duration:0)+(e.days?e.days*gt.day.duration:0)+(e.hours?e.hours*gt.hour.duration:0)+(e.minutes?e.minutes*gt.minute.duration:0)+(e.seconds?e.seconds*gt.second.duration:0)},new Pi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0))}static toSpec(e,t=S5){let i=typeof e=="number"?e:e.value;const s=i>0?1:-1;i=Math.abs(i);const n={},r=i/gt.year.duration,a=Math.floor(r);a>0&&(n.years=t.newYear(s*a),i-=a*gt.year.duration);const o=i/gt.month.duration,c=Math.floor(o);c>0&&(n.months=t.newMonth(s*c),i-=c*gt.month.duration);const h=i/gt.day.duration,d=Math.floor(h);d>0&&(n.days=t.newDay(s*d),i-=d*gt.day.duration);const u=i/gt.hour.duration,p=Math.floor(u);p>0&&(n.hours=t.newHour(s*p),i-=p*gt.hour.duration);const f=i/gt.minute.duration,m=Math.floor(f);m>0&&(n.minutes=t.newMinute(s*m),i-=m*gt.minute.duration);const g=i/gt.second.duration,v=Math.floor(s*g);return v>0&&(n.seconds=t.newSecond(v)),n}static fromString(e,t=Be.get(Ua)){return new Ua(t.parse(e))}static between(e,t){const i=t.getTime(),s=e.getTime();return new Ua(i-s)}toSpec(){return Ua.toSpec(this)}toString(e=qg.instance){return e.render(this)}}class bT extends Sw{constructor(e){super(e)}newYear(e){return new hu(e,this.units.year)}newMonth(e){return new du(e,this.units.month)}newDay(e){return new uu(e,this.units.day)}newHour(e){return new pu(e,this.units.hour)}newMinute(e){return new fu(e,this.units.minute)}newSecond(e){return new mu(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new bl(typeof e=="number"?e:e.value)}}const E5=new bT(gt),S5=new bT(Hf);class Mn{#e;#t;#i;#s;#n;#r;#a;#o;constructor(e={year:new Date().getFullYear(),month:new Date().getMonth()+1,day:new Date().getDate(),hour:new Date().getHours(),minute:new Date().getMinutes(),second:new Date().getSeconds(),timeshift:Mn.timeshiftOf(new Date)}){this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.millisecond=e.millisecond,this.timeshift=e.timeshift}get year(){return this.#e}set year(e){const t=typeof e=="number";this.#e&&t?this.#e.value=e:this.#e=t?this.factory.newYear(e):!e||e.start||e instanceof jn?e:this.factory.newYear(e)}get month(){return this.#t}set month(e){const t=typeof e=="number";this.#t&&t?this.#t.value=e:this.#t=t?this.factory.newMonth(e):!e||e.start||e instanceof jn?e:this.factory.newMonth(e)}get day(){return this.#i}set day(e){const t=typeof e=="number";this.#i&&t?this.#i.value=e:this.#i=t?this.factory.newDay(e):!e||e.start||e instanceof jn?e:this.factory.newDay(e)}get hour(){return this.#s}set hour(e){const t=typeof e=="number";this.#s&&t?this.#s.value=e:this.#s=t?this.factory.newHour(e):!e||e.start||e instanceof jn?e:this.factory.newHour(e)}get minute(){return this.#n}set minute(e){const t=typeof e=="number";this.#n&&t?this.#n.value=e:this.#n=t?this.factory.newMinute(e):!e||e.start||e instanceof jn?e:this.factory.newMinute(e)}get second(){return this.#r}set second(e){const t=typeof e=="number";this.#r&&t?this.#r.value=e:this.#r=t?this.factory.newSecond(e):!e||e.start||e instanceof jn?e:this.factory.newSecond(e)}get millisecond(){return this.#a}set millisecond(e){const t=typeof e=="number";this.#a&&t?this.#a.value=e:this.#a=t||e&&!(e instanceof jn)?this.factory.newMillisecond(e):e}get timeshift(){return this.#o}set timeshift(e){const t=typeof e=="number";this.#o&&t?this.#o.value=e:this.#o=t||e&&!(e instanceof bl)?this.factory.newTimeshift(e):e}get factory(){return E5}static fromString(e,t=Be.get(Mn)){const{year:i,month:s,day:n,hour:r,minute:a,second:o,millisecond:c,timeshift:h}=t.parse(e);return new Mn({year:i,month:s,day:n,hour:r,minute:a,second:o,millisecond:c,timeshift:h})}static timeshiftOf(e){return-e.getTimezoneOffset()||0}static fromDate(e){return new Mn({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return Mn.fromString(i)}#c(e){if(this.constructor.name!==e.constructor.name)throw new Xg(`Date "${this.toString()}" cannot be compared with "${e.toString()}"`)}compare(e){return this.#c(e),this.getTime()-e.getTime()}delta(e){const t=this.compare(e);return new Ua(t)}getTime(){return(this.year?.duration||0)+(this.month?.duration||0)+(this.day?.duration||0)+(this.hour?.duration||0)+(this.minute?.duration||0)+(this.second?.duration||0)+(this.millisecond?.duration||0)}isEqual(e){return this.compare(e)===0}isBefore(e){return this.compare(e)<0}isAfter(e){return this.compare(e)>0}clone(){return new Mn(this.toSpec())}previous(){let e=this.clone();try{e.second=this.second.previous()}catch{try{e.minute=this.minute.previous()}catch{try{e.hour=this.hour.previous()}catch{try{e.day=this.day.previous()}catch{try{e.month=this.month.previous()}catch{e.year=this.year.previous()}}}}}return e}next(){let e=this.clone();try{e.second=this.second.next()}catch{try{e.minute=this.minute.next()}catch{try{e.hour=this.hour.next()}catch{try{e.day=this.day.next()}catch{try{e.month=this.month.next()}catch{e.year=this.year.next()}}}}}return e}toString(e=Yg.instance){return e.render(this)}toSpec(){const e={},t=this.year?.toSpec();t&&(e.year=t);const i=this.month?.toSpec();i&&(e.month=i);const s=this.day?.toSpec();s&&(e.day=s);const n=this.hour?.toSpec();n&&(e.hour=n);const r=this.minute?.toSpec();r&&(e.minute=r);const a=this.second?.toSpec();a&&(e.second=a);const o=this.millisecond?.toSpec();o&&(e.millisecond=o);const c=this.timeshift?.toSpec();return c&&(e.timeshift=c),e}toJSON(){return this.toSpec()}}class Aw{static instance=new Aw;render(e){return(e.start?e.start.toString():"")+"/"+(e.end?e.end.toString():"")}}class Kp{constructor(e,t){this.start=e,this.end=t}_start;get start(){return this._start}set start(e){if(typeof e=="string"&&(e=Mn.fromString(e)),e&&!(e instanceof Mn)&&!(e instanceof Ua))throw new Ur("Interval start is not a level 0 date or duration: "+e);this._start=e}_end;get end(){return this._end}set end(e){if(typeof e=="string"&&(e=Mn.fromString(e)),e&&!(e instanceof Mn)&&!(e instanceof Ua))throw new Ur("Interval end is not a level 0 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Kp)){const{start:i,end:s}=t.parse(e);return new Kp(i,s)}toString(e=Aw.instance){return e.render(this)}[Symbol.iterator](){let e=this.start;return{next:()=>{const t={done:e>this.end,value:e};return e++,t}}}}class Gf extends yo{static instance=new Gf(Co.default);constructor(e){super(),this.valueRenderer=e}render(e){return(this.valueRenderer?this.valueRenderer.render(e):super.render(e))+this.qualifier(e)}qualifier(e){return e.uncertain?e.approximate?"%":"?":e.approximate?"~":""}}class Do extends jn{#e;#t;constructor(e,t){super(e,t),this.#e=e.uncertain||!1,this.#t=e.approximate||!1}get uncertain(){return this.#e}set uncertain(e){return this.#e=e}get approximate(){return this.#t}set approximate(e){return this.#t=e}isCertainAndPrecise(){return!this.approximate&&!this.uncertain}isEqual(e){return this.isCertainAndPrecise()&&super.isEqual(e)}isBefore(e){return this.isCertainAndPrecise()&&super.isBefore(e)}isAfter(e){return this.isCertainAndPrecise()&&super.isAfter(e)}toString(e=Gf.instance){return super.toString(e)}toSpec(){return{...super.toSpec(),uncertain:this.uncertain,approximate:this.approximate}}toJSON(){return this.toSpec()}}class yT extends gT{year=new Pi("year",-9999,9999,this.month);yearExtended=new Pi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const _0=new yT;class Qc extends Do{constructor(e,t=_0.year){super(e,t)}static fromString(e,t=_0.year,i=Be.get(Qc)){const s=i.parse(e),n=s.value.start;if(e.startsWith("Y")&&(t=_0.yearExtended),n!==void 0){const r=new Qc(Object.assign({...s},{value:Math.max(n,t.min)})),a=new Qc(Object.assign({...s},{value:Math.min(s.value.end,t.max)}));return{start:r,end:a}}else return new Qc(s,t)}}class wT extends Xg{monthValidator=new vT;validate(e){switch(e){case 21:case 22:case 23:case 24:return!0;default:return this.monthValidator.validate(e)}}}class el extends Do{constructor(e,t=new Pi(gt.month.name,1,24,gt.day,new wT)){super(e,t)}static fromString(e,t=Be.get(el)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.month;const r=new el(Object.assign({...i},{value:Math.max(s,n.min)})),a=new el(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new el(i)}toString(e){return super.toString(e).padStart(2,"0")}}class tl extends Do{constructor(e,t=gt.day){super(e,t)}static fromString(e,t=Be.get(tl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.day;const r=new tl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new tl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new tl(i)}toString(e){return super.toString(e).padStart(2,"0")}}class il extends Do{constructor(e,t=gt.hour){super(e,t)}static fromString(e,t=Be.get(il)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.hour;const r=new il(Object.assign({...i},{value:Math.max(s,n.min)})),a=new il(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new il(i)}}class sl extends Do{constructor(e,t=gt.minute){super(e,t)}static fromString(e,t=Be.get(sl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.minute,r=new sl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new sl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new sl(i)}toString(e=Gf.instance){return super.toString(e)}}class nl extends Do{constructor(e,t=gt.second){super(e,t)}static fromString(e,t=Be.get(nl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.second,r=new nl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new nl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new nl(i)}}class xh extends bl{static fromString(e,t=Be.get(xh),i=void 0){return new xh(t.parse(e,i))}}class MT extends Sw{constructor(e){super(e)}newYear(e){return new Qc(e,this.units.year)}newMonth(e){return new el(e,this.units.month)}newDay(e){return new tl(e,this.units.day)}newHour(e){return new il(e,this.units.hour)}newMinute(e){return new sl(e,this.units.minute)}newSecond(e){return new nl(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new xh(typeof e=="number"?e:e.value)}}const A5=new MT(_0),T5=new MT(Hf);class Pr extends Mn{constructor(e){super(e)}get factory(){return A5}get uncertain(){return this.year?.uncertain===!0||this.month?.uncertain===!0||this.day?.uncertain===!0||this.hour?.uncertain===!0||this.minute?.uncertain===!0||this.second?.uncertain===!0}get approximate(){return this.year?.approximate===!0||this.month?.approximate===!0||this.day?.approximate===!0||this.hour?.approximate===!0||this.minute?.approximate===!0||this.second?.approximate===!0}static fromDate(e){return new Pr({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static fromString(e,t=Be.get(Pr)){const i=t.parse(e);return new Pr(i)}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return Pr.fromString(i)}clone(){return new Pr(this.toSpec())}}const tn=Object.freeze({year:"year",month:"month",day:"day",hour:"hour",minute:"minute",second:"second",timeshift:"timeshift",uncertain:"uncertain",approximate:"approx"});class jg extends qg{static instance=new jg;render(e){return super.render(e)}}class qs extends Do{constructor(e){super(typeof e=="number"||e.hasOwnProperty("value")?e:{value:qs.getValue(e,tn.year)+qs.getValue(e,tn.month)+qs.getValue(e,tn.day)+qs.getValue(e,tn.hour)+qs.getValue(e,tn.minute)+qs.getValue(e,tn.second),uncertain:qs.getBoolean(e,tn.uncertain),approximate:qs.getBoolean(e,"approximate")},Hf.millisecond)}static getBoolean(e,t){return e[t]||e[tn.year+"s"]?.[t]||e[tn.month+"s"]?.[t]||e[tn.day+"s"]?.[t]||e[tn.hour+"s"]?.[t]||e[tn.minute+"s"]?.[t]||e[tn.second+"s"]?.[t]||!1}static getValue(e,t){let i=0,s=e[t+"s"];if(s instanceof Do?s=s.value:typeof e=="number"&&(s=e),s){const n=gt[t];i=s*n.duration}return i}static toSpec(e,t=T5){return{...Ua.toSpec(e,t),uncertain:e.uncertain||!1,approximate:e.approximate||!1}}static fromString(e,t=Be.get(qs)){const i=t.parse(e);return new qs(i)}static between(e,t){const i=t.getTime(),s=e.getTime();return new qs(i-s)}toString(e=jg.instance){return super.toString(e)}toSpec(){return qs.toSpec(this)}}class Xp extends Kp{constructor(e,t){super(e,t)}get start(){return this._start}set start(e){if(typeof e=="string"&&(super.start=Pr.fromString(e)),e&&!(e instanceof Pr)&&!(e instanceof qs))throw new Ur("Interval start is not a level 1 date or duration: "+e);this._start=e}get end(){return this._end}set end(e){if(typeof e=="string"&&(e=Pr.fromString(e)),e&&!(e instanceof Pr)&&!(e instanceof qs))throw new Ur("Interval end is not a level 1 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Xp)){const{start:i,end:s}=t.parse(e);return new Xp(i,s)}}class Iu extends Do{uncertainComponent;approximateComponent;constructor(e,t){super(e,t),this.uncertainComponent=e.uncertainComponent||!1,this.approximateComponent=e.approximateComponent||!1}get uncertain(){return super.uncertain||this.uncertainComponent}set uncertain(e){return super.uncertain=e}get approximate(){return super.approximate||this.approximateComponent}set approximate(e){return super.approximate=e}get uncertainGroup(){return super.uncertain}get approximateGroup(){return super.approximate}toSpec(){return{...super.toSpec(),uncertain:this.uncertainGroup,approximate:this.approximateGroup,uncertainComponent:this.uncertainComponent,approximateComponent:this.approximateComponent}}toJSON(){return this.toSpec()}}class I5 extends yT{year=new Pi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const _y=new I5;class tc extends Iu{constructor(e,t=_y.year){super(e,t)}static fromString(e,t=_y.year,i=Be.get(tc)){const s=i.parse(e),n=s.value.start;if(n!==void 0){const r=new tc(Object.assign({...s},{value:Math.max(n,t.min)})),a=new tc(Object.assign({...s},{value:Math.min(s.value.end,t.max)})),o={start:r,end:a},c=s.value.estimate;return c&&(o.estimate=c),o}else return new tc(s)}}class _5 extends wT{validate(e){switch(e){case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:return!0;default:return super.validate(e)}}}class ic extends Iu{constructor(e,t=new Pi(gt.month.name,1,41,gt.day,new _5)){super(e,t)}static fromString(e,t=Be.get(ic)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.month,r=new ic(Object.assign({...i},{value:Math.max(s,n.min)})),a=new ic(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new ic(i)}toString(e){return super.toString(e).padStart(2,"0")}}class sc extends Iu{constructor(e,t=gt.day){super(e,t)}static fromString(e,t=Be.get(sc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.day,r=new sc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new sc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new sc(i)}toString(e){return super.toString(e).padStart(2,"0")}}class nc extends Iu{constructor(e,t=gt.hour){super(e,t)}static fromString(e,t=Be.get(nc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.hour,r=new nc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new nc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new nc(i)}}class rc extends Iu{constructor(e,t=gt.minute){super(e,t)}static fromString(e,t=Be.get(rc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.minute,r=new rc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new rc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new rc(i)}}class ac extends Iu{constructor(e,t=gt.second){super(e,t)}static fromString(e,t=gt.second,i=Be.get(ac)){const s=i.parse(e),n=s.value.start;if(n!==void 0){const r=new ac(Object.assign({...s},{value:Math.max(n,t.min)})),a=new ac(Object.assign({...s},{value:Math.min(s.value.end,t.max)}));return{start:r,end:a}}else return new ac(s,t)}}class xT extends xh{}class D5 extends Gf{qualifier(){return""}}class Fc extends Yg{static instance=new Fc;static valueRenderer=new D5(Co.default);static names=["year","month","day","hour","minute","second"];static qualifier(e,t){return e?t?"%":"?":t?"~":""}renderComponent(e,t){const i=e[t],s=Fc.names.slice(Fc.names.indexOf(t)+1).map(a=>e[a]).filter(Boolean),n=Fc.qualifier(i.uncertainComponent,i.approximateComponent),r=Fc.qualifier(i.uncertainGroup&&!i.uncertainComponent&&!s.some(a=>a.uncertain),i.approximateGroup&&!i.approximateComponent&&!s.some(a=>a.approximate));return n+i.toString(Fc.valueRenderer)+r}}class ET extends Sw{constructor(e){super(e)}newYear(e){return new tc(e,this.units.year)}newMonth(e){return new ic(e,this.units.month)}newDay(e){return new sc(e,this.units.day)}newHour(e){return new nc(e,this.units.hour)}newMinute(e){return new rc(e,this.units.minute)}newSecond(e){return new ac(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new xT(typeof e=="number"?e:e.value)}}const k5=new ET(_y),R5=new ET(Hf);class gr extends Pr{constructor(e){super(e)}toString(e=Fc.instance){return super.toString(e)}get year(){return super.year}set year(e){super.year=e}get month(){return super.month}set month(e){super.month=e}get factory(){return k5}static fromDate(e){return new gr({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static fromString(e,t=Be.get(gr)){const i=t.parse(e);return new gr(i)}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return gr.fromString(i)}clone(){return new gr(this.toSpec())}}class wc{regExp;constructor(e,t){this.name=e,this.regExp=new RegExp(`^(?:${t})$`)}regexGroups(e){const t=this.regExp.exec(e);if(!t)throw new Ur(`Invalid ${this.name} "${e}"`);return t.groups}parseGroups(e){throw new Wl(`${this.constructor.name} is abstract`)}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}class Ad extends jg{static instance=new Ad;static designators=[["years","Y"],["months","MM"],["days","D"],["hours","H"],["minutes","M"],["seconds","S"]];static qualifier(e,t){return e?t?"%":"?":t?"~":""}render(e){const t=Ad.qualifier(e.uncertainDuration,e.approximateDuration);if(!e.hasQualifiedComponent)return t+super.render(e);let i=t+"P";for(const[s,n]of Ad.designators){const r=e.components[s];r&&(i+=Ad.qualifier(r.uncertainComponent,r.approximateComponent)+r.value+n)}return i}}class Xs extends qs{#e;constructor(e){if(super(typeof e=="number"?e:{value:Xs.valueFromSpec(e),uncertain:e.uncertain===!0,approximate:e.approximate===!0},Hf.millisecond),typeof e!="number"){const t={};for(const i of Xs.componentNames)e[i]instanceof Do&&(t[i]=e[i]);Object.keys(t).length>0&&(this.#e=t)}}static componentNames=["years","months","days","hours","minutes","seconds"];get components(){return this.#e}#t(e){return this.#e?Object.values(this.#e).some(t=>t[e]):!1}get uncertainDuration(){return super.uncertain}get approximateDuration(){return super.approximate}get uncertain(){return super.uncertain||this.#t("uncertain")}set uncertain(e){super.uncertain=e}get approximate(){return super.approximate||this.#t("approximate")}set approximate(e){super.approximate=e}get hasQualifiedComponent(){return this.#e?Object.values(this.#e).some(e=>e.uncertainComponent||e.approximateComponent):!1}static valueFromSpec(e){return Xs.getValue(e,tn.year)+Xs.getValue(e,tn.month)+Xs.getValue(e,tn.day)+Xs.getValue(e,tn.hour)+Xs.getValue(e,tn.minute)+Xs.getValue(e,tn.second)}static toSpec(e,t=R5){const i=qs.toSpec(e,t);if(e instanceof Xs&&e.hasQualifiedComponent)for(const s of Xs.componentNames)delete i[s],e.components[s]&&(i[s]=e.components[s]);return i}static fromString(e,t=Be.get(Xs)){const i=t.parse(e);return new Xs(i)}static between(e,t){const i=t.getTime(),s=e.getTime();return new Xs(i-s)}toSpec(){return Xs.toSpec(this)}toString(e=Ad.instance){return super.toString(e)}}class Yp extends Xp{get start(){return this._start}set start(e){if(typeof e=="string"&&(super.start=gr.fromString(e)),e&&!(e instanceof gr)&&!(e instanceof Xs))throw new Ur("Interval start is not a level 2 date or duration: "+e);this._start=e}get end(){return this._end}set end(e){if(typeof e=="string"&&(e=gr.fromString(e)),e&&!(e instanceof gr)&&!(e instanceof Xs))throw new Ur("Interval end is not a level 2 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Yp)){const{start:i,end:s}=t.parse(e);return new Yp(i,s)}}class K0 extends Set{constructor(e,t){super(e),this.exclusive=t}has(e){const t=e.toString().replace("..","/");for(const i of this)if(i.toString()===t)return!0;return!1}static fromString(e,t=Be.get(K0)){const{exclusive:i,values:s}=t.parse(e);return new K0(s,i)}}class Mc extends wc{constructor(e,t){super(e,t)}static read(e){return{value:e?parseInt(e,10):void 0}}parseGroups(e){return Mc.read(e[this.name])}parse(e){if(e.startsWith("-"))throw new Ur(`${this.name} cannot be negative`);return super.parse(e)}}class U{static groupName(...e){return e.reduce((t,i)=>t?t+i.charAt(0).toUpperCase()+i.substring(1):i,"")}static group(e,...t){return`(?<${e}>${t.join("")})`}static optional(e){return e+"?"}static nonCapturingGroup(...e){return`(?:${e.join("")})`}static optionalGroup(e,...t){return U.optional(U.group(e,...t))}static optionalNonCapturingGroup(...e){return U.optional(U.nonCapturingGroup(...e))}static numberGroup(e,t,i,s="\\d"){return U.group(e,`${i||""}[${s}]${t}`)}}const sx="yearValue";class qp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,sx),"{4}",void 0)}constructor(){super(sx,qp.format())}}const nx="monthValue";class jp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,nx),"{1,2}",void 0)}constructor(){super(nx,jp.format())}}const rx="dayValue";class Kd extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,rx),"{1,2}",void 0)}constructor(){super(rx,Kd.format())}}const ax="hourValue";class Xd extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,ax),"{1,2}",void 0)}constructor(){super(ax,Xd.format())}}const ox="minuteValue";class Zp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,ox),"{1,2}",void 0)}constructor(){super(ox,Zp.format())}}const cx="secondValue";class Jp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,cx),"{1,2}",void 0)}constructor(){super(cx,Jp.format())}}const lx="timeshiftValue",hx="shiftHour",dx="shiftMinute";class gu extends wc{static format(e=""){return ix.map(t=>t.name).join("|")+"|"+U.nonCapturingGroup(U.group(e+hx,U.numberGroup(U.groupName(e,lx),"{2}","[+-]")),U.optionalNonCapturingGroup(":?",U.numberGroup(U.groupName(e,dx),"{2}",void 0)))}constructor(){super(lx,gu.format())}parse(e,t){let i=0;const s=ix.find(n=>n.name===e);if(s){if(typeof s.timeshift=="function")try{return s.timeshift(t??{})}catch(n){throw new Ur(`The time zone ${e} depends on the date: ${n.message}`)}e=s.timeshift}if(e!=="Z"){const n=this.regexGroups(e),r=n[hx];r&&(i+=parseInt(r,10)*60);const a=n[dx];a&&(i+=parseInt(a,10))}return i}}const ux="year",px="month",fx="day",mx="hour",gx="minute",vx="second",bx="millisecond",yx="timeshift";class eh extends wc{static format(e=""){return U.group(U.groupName(e,ux),qp.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,px),jp.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,fx),Kd.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,mx),Xd.format(e)),":?",U.group(U.groupName(e,gx),Zp.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,vx),Jp.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,bx),"\\d+"))),"\\s*",U.optionalGroup(U.groupName(e,yx),gu.format(e)))))}constructor(){super("date",eh.format())}parse(e){const t=this.regexGroups(e),i=t[ux],s=t[px],n=t[fx],r=t[mx],a=t[gx],o=t[vx],c=t[bx],h=t[yx],d=i?new hu(qp.read(i)):void 0,u=s?jp.read(s):void 0;return{year:d,month:u?new du(u,Sd.create(u.value,d?.value)):void 0,day:n?new uu(Kd.read(n)):void 0,hour:r?new pu(Xd.read(r)):void 0,minute:a?new fu(Zp.read(a)):void 0,second:o?new mu(Jp.read(o)):void 0,millisecond:c?Tl.parseFraction(c):void 0,timeshift:h?bl.fromString(h,new gu,{year:d?.value,month:u?.value,day:n?Kd.read(n).value:void 0,hour:r?Xd.read(r).value:void 0}):void 0}}}const wx="years",Sv="months",C5="days",Mx="hours",xx="minutes",Ex="seconds";class Tw extends wc{static format(e=""){return"P"+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,wx),"+",void 0,"\\d"),"Y")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Sv),"+",void 0,"\\d"),"MM")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,C5),"+",void 0,"\\d"),"D")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Mx),"+",void 0,"\\d"),"H")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,xx),"+",void 0,"\\d"),"M")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Ex),"+",void 0,"\\d"),"S")}constructor(){super("duration",Tw.format())}parseGroups(e){return{years:e[wx],months:e[Sv],days:e[Sv],hours:e[Mx],minutes:e[xx],seconds:e[Ex]}}}const Av="start",Tv="end";class Iw extends wc{static format=U.group(Av,eh.format(Av))+"/"+U.group(Tv,eh.format(Tv));constructor(){super("interval",Iw.format)}parse(e){const t=this.regexGroups(e),i=t[Av],s=t[Tv];return{start:i?Mn.fromString(i,new eh):void 0,end:s?Mn.fromString(s,new eh):void 0}}}Be.register(Mn,()=>new eh);Be.register(uu,()=>new Kd);Be.register(Ua,()=>new Tw);Be.register(pu,()=>new Xd);Be.register(Kp,()=>new Iw);Be.register(fu,()=>new Zp);Be.register(du,()=>new jp);Be.register(mu,()=>new Jp);Be.register(bl,()=>new gu);Be.register(hu,()=>new qp);class Zi extends Mc{static uncertainGroup="uncertain";static approximateGroup="approx";static uncertainAndApproximateGroup=Zi.uncertainGroup+Zi.approximateGroup;constructor(e,t){super(e,t)}static qualifierFormat(e,t){return U.optionalGroup(e,`\\${t}`)}static formatSuffix(e){return this.qualifierFormat(U.groupName(Zi.uncertainGroup,e),"?")+this.qualifierFormat(U.groupName(Zi.approximateGroup,e),"~")+this.qualifierFormat(U.groupName(Zi.uncertainAndApproximateGroup,e),"%")}static numberFormat(e,t,i){return U.numberGroup(e,t,i,"\\dX")+this.formatSuffix(e)}getValueAndSign(e){let t=e[this.name],i;return t.charAt(0)==="-"?(i=-1,t=t.substring(1)):i=1,{valueStr:t,sign:i}}parseGroups(e){const{valueStr:t,sign:i}=this.getValueAndSign(e);let s=0,n;for(n=0;n<t.length;n++){const c=t[n];if(c==="X")break;s=s*10+parseInt(c,10)}if(n<t.length){let c=1;for(let u=0;u<t.length-n;u++)c*=10;const h=i*s*c,d=h+c-1;s={start:h,end:d}}else s*=i;const r=e[U.groupName(Zi.uncertainAndApproximateGroup,this.name)],a=e[U.groupName(Zi.approximateGroup,this.name)]||r,o=e[U.groupName(Zi.uncertainGroup,this.name)]||r;return{value:s,approximate:a?!!a:!1,uncertain:o?!!o:!1}}}const Sx="yearValue";class Qp extends Zi{constructor(){super(Sx,Qp.format())}static format(e=""){return"Y?"+Zi.numberFormat(U.groupName(e,Sx),"+","[-]?")}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}const Ax="monthValue";class ef extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Ax),"{1,2}",void 0)}constructor(){super(Ax,ef.format())}}const Tx="dayValue";class tf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Tx),"{1,2}",void 0)}constructor(){super(Tx,tf.format())}}const Ix="hourValue";class sf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Ix),"{1,2}",void 0)}constructor(){super(Ix,sf.format())}}const _x="minuteValue";class nf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,_x),"{1,2}",void 0)}constructor(){super(_x,nf.format())}}const Dx="secondValue";class rf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Dx),"{1,2}",void 0)}constructor(){super(Dx,rf.format())}}class af extends gu{}class os extends wc{static yearGroup="year";static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(e=os.format()){super("date",e)}static format(e=""){return U.group(U.groupName(e,os.yearGroup),Qp.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,os.monthGroup),ef.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,os.dayGroup),tf.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,os.hourGroup),sf.format(e)),":",U.group(U.groupName(e,os.minuteGroup),nf.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,os.secondGroup),rf.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,os.millisecondGroup),"\\d+"))),U.optionalGroup(U.groupName(e,os.timeshiftGroup),af.format(e)))))}parseGroups(e){const t=e[os.millisecondGroup],i=t?Tl.parseFraction(t):void 0,s=e[os.secondGroup],n=s?nl.fromString(s,new rf):void 0,r=e[os.minuteGroup];let a;r&&(a=sl.fromString(r,new nf),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[os.hourGroup];let c;o&&(c=il.fromString(o,new sf),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[os.dayGroup];let d;h&&(d=tl.fromString(h,new tf),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[os.monthGroup];let p;u&&(p=el.fromString(u,new ef),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[os.yearGroup];let m;f&&(m=Qc.fromString(f,void 0,new Qp),m.uncertain=m.uncertain||p?.uncertain||!1,m.approximate=m.approximate||p?.approximate||!1);const g=e[os.timeshiftGroup],v=g?xh.fromString(g,new af,{year:m?.value,month:p?.value,day:d?.value,hour:c?.value}):void 0;return{year:m,month:p,day:d,hour:c,minute:a,second:n,millisecond:i,timeshift:v}}}const kx="years",Rx="months",Cx="days",Ox="hours",Lx="minutes",Px="seconds";class th extends Zi{static format(e=""){return"P"+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,kx),"+",void 0,"\\d"),"Y")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Rx),"+",void 0,"\\d"),"MM")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Cx),"+",void 0,"\\d"),"D")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Ox),"+",void 0,"\\d"),"H")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Lx),"+",void 0,"\\d"),"M")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Px),"+",void 0,"\\d"),"S")+this.formatSuffix(e)}constructor(){super("duration",th.format())}parseGroups(e){return{years:e[kx],months:e[Rx],days:e[Cx],hours:e[Ox],minutes:e[Lx],seconds:e[Px],uncertain:!!e[Zi.uncertainGroup],approximate:!!e[Zi.approximateGroup]}}}const O5="dates",Iv="start",_v="end",Nx="durations",Dv="durationMin",kv="durationMax";class _w extends wc{static format=U.group(O5,U.optionalGroup(Iv,U.group("openStart","\\.\\.")+"|"+os.format(Iv))+"/"+U.optionalGroup(_v,U.group("openEnd","\\.\\.")+"|"+os.format(_v)))+"|"+U.group(Nx,U.group(Dv,th.format(Dv))+"/"+U.group(kv,th.format(kv)));constructor(e="interval",t=_w.format){super(e,t)}parseGroups(e){let t,i;if(e[Nx]){const n=e[Dv];t=qs.fromString(n,new th);const r=e[kv];i=qs.fromString(r,new th)}else{const n=e[Iv];switch(n){case void 0:t=null;break;case"..":t=void 0;break;default:t=Pr.fromString(n,new os)}const r=e[_v];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=Pr.fromString(r,new os)}}return{start:t,end:i}}}Be.register(Pr,()=>new os);Be.register(tl,()=>new tf);Be.register(qs,()=>new th);Be.register(il,()=>new sf);Be.register(Xp,()=>new _w);Be.register(sl,()=>new nf);Be.register(el,()=>new ef);Be.register(nl,()=>new rf);Be.register(xh,()=>new af);Be.register(Qc,()=>new Qp);class oi extends Zi{static uncertainGroup="uncertain1";static approximateGroup="approx1";static uncertainAndApproximateGroup=oi.uncertainGroup+oi.approximateGroup;constructor(e,t){super(e,t)}static numberFormat(e,t,i){return this.qualifierFormat(U.groupName(oi.uncertainGroup,e),"?")+this.qualifierFormat(U.groupName(oi.approximateGroup,e),"~")+this.qualifierFormat(U.groupName(oi.uncertainAndApproximateGroup,e),"%")+Zi.numberFormat(e,t,i)}parseGroups(e){const t=super.parseGroups(e),i=e[U.groupName(oi.uncertainAndApproximateGroup,this.name)];return(e[U.groupName(oi.uncertainGroup,this.name)]||i)&&(t.uncertainComponent=!0),(e[U.groupName(oi.approximateGroup,this.name)]||i)&&(t.approximateComponent=!0),t}}const Cu="yearValue",Fx="exp",Ux="signif";class of extends oi{constructor(){super(Cu,of.format())}static format(e=""){return"Y?"+U.nonCapturingGroup(U.group(U.groupName(e,Fx),"[-]?\\d+E\\d+")+"|"+oi.numberFormat(U.groupName(e,Cu),"+","[-]?")+U.optionalGroup(U.groupName(e,Ux),"S\\d+"))}parseGroups(e){const t=e[Fx];if(t){const r=t.indexOf("E"),a=parseInt(t.substring(r+1),10),c=parseInt(t.substring(0,r),10)*Math.pow(10,a);e[Cu]=c.toString()}const i=e[Ux],s=e[Cu];if(i){const r=parseInt(i.substring(1),10),{valueStr:a,sign:o}=this.getValueAndSign(e);let c="";for(let h=0;h<a.length;h++)c+=h<r?a.charAt(h):"X";e[Cu]=(o<0?"-":"")+c}const n=super.parseGroups(e);return i&&(n.value.estimate=parseInt(s,10)),n}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}const Bx="monthValue";class cf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Bx),"{1,2}",void 0)}constructor(){super(Bx,cf.format())}}const zx="dayValue";class lf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,zx),"{1,2}",void 0)}constructor(){super(zx,lf.format())}}const Hx="hourValue";class hf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Hx),"{1,2}",void 0)}constructor(){super(Hx,hf.format())}}const Gx="secondValue";class df extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Gx),"{1,2}",void 0)}constructor(){super(Gx,df.format())}}const Vx="minuteValue";class uf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Vx),"{1,2}",void 0)}constructor(){super(Vx,uf.format())}}class L5 extends af{}class pi extends wc{static yearGroup=os.yearGroup;static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(){super("date",pi.format())}static format(e=""){return U.group(U.groupName(e,pi.yearGroup),of.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,pi.monthGroup),cf.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,pi.dayGroup),lf.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,pi.hourGroup),hf.format(e)),":",U.group(U.groupName(e,pi.minuteGroup),uf.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,pi.secondGroup),df.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,pi.millisecondGroup),"\\d+"))),U.optionalGroup(U.groupName(e,pi.timeshiftGroup),L5.format(e)))))}parseGroups(e){const t=e[pi.millisecondGroup],i=t?Tl.parseFraction(t):void 0,s=e[pi.secondGroup];let n;s&&(n=ac.fromString(s,void 0,new df),n.uncertain=n?.uncertain||!1,n.approximate=n?.approximate||!1);const r=e[pi.minuteGroup];let a;r&&(a=rc.fromString(r,new uf),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[pi.hourGroup];let c;o&&(c=nc.fromString(o,new hf),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[pi.dayGroup];let d;h&&(d=sc.fromString(h,new lf),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[pi.monthGroup];let p;u&&(p=ic.fromString(u,new cf),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[pi.yearGroup];let m;f&&(m=tc.fromString(f,void 0,new of),m.uncertain=m.uncertain||p?.uncertain||!1,m.approximate=m.approximate||p?.approximate||!1);const g=e[pi.timeshiftGroup],v=g?xT.fromString(g,new af,{year:m?.value,month:p?.value,day:d?.value,hour:c?.value}):void 0;return{year:m,month:p,day:d,hour:c,minute:a,second:n,millisecond:i,timeshift:v}}}const Wx="durationValue";class Dw extends oi{static format(e=""){return"^"+oi.numberFormat(U.groupName(e,Wx),"+",void 0)}constructor(){super(Wx,Dw.format())}}class P5 extends Ew{millisecond=new Pi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0);second=new Pi("second",0,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new Pi("minute",0,Number.MAX_SAFE_INTEGER,this.second);hour=new Pi("hour",0,Number.MAX_SAFE_INTEGER,this.minute);day=new Pi("day",1,Number.MAX_SAFE_INTEGER,this.hour);month=new Pi("month",1,Number.MAX_SAFE_INTEGER,this.day);year=new Pi("year",0,Number.MAX_SAFE_INTEGER,this.month)}const Lh=new P5;class ht extends oi{static yearsGroup="years";static monthsGroup="months";static isoMonthsGroup="isoMonths";static daysGroup="days";static hoursGroup="hours";static minutesGroup="minutes";static secondsGroup="seconds";static durationGroup="duration";static suffixGroup="durationSuffix";static componentParser=new Dw;static componentFormat(e,t,i,s,n=""){const r=U.group(U.groupName(e,ht.quantityGroup(t)),oi.numberFormat(U.groupName(e,i),"+",void 0,"\\d"));return U.group(U.groupName(e,t),r,s,n)}static quantityGroup(e){return e+"Quantity"}static isoMonthsLookahead="(?=[?~%]?\\d+D|T)";constructor(){super("duration",ht.format())}static format(e=""){const t=U.groupName(e,ht.durationGroup);return this.qualifierFormat(U.groupName(oi.uncertainGroup,t),"?")+this.qualifierFormat(U.groupName(oi.approximateGroup,t),"~")+this.qualifierFormat(U.groupName(oi.uncertainAndApproximateGroup,t),"%")+"P"+U.optional(ht.componentFormat(e,ht.yearsGroup,pi.yearGroup,"Y"))+U.optionalNonCapturingGroup(ht.componentFormat(e,ht.monthsGroup,pi.monthGroup,"MM")+"|"+ht.componentFormat(e,ht.isoMonthsGroup,"isoMonth","M",ht.isoMonthsLookahead))+U.optional(ht.componentFormat(e,ht.daysGroup,pi.dayGroup,"D"))+"T?"+U.optional(ht.componentFormat(e,ht.hoursGroup,pi.hourGroup,"H"))+U.optional(ht.componentFormat(e,ht.minutesGroup,pi.minuteGroup,"M"))+U.optional(ht.componentFormat(e,ht.secondsGroup,pi.secondGroup,"S"))+U.optionalGroup(U.groupName(e,ht.suffixGroup),"[?~%]")}static parseComponent(e,t,i){const s=ht.componentParser.parse(e);return new t(s,i)}parseGroups(e){const t=e[ht.quantityGroup(ht.secondsGroup)];let i;t&&(i=ht.parseComponent(t,ac,Lh.second),i.uncertain=!!e[U.groupName(oi.uncertainGroup,ht.secondsGroup)]||!1,i.approximate=!!e[U.groupName(oi.approximateGroup,ht.secondsGroup)]||!1);const s=e[ht.quantityGroup(ht.minutesGroup)];let n;s&&(n=ht.parseComponent(s,rc,Lh.minute),n.uncertain=n.uncertain||i?.uncertain||!1,n.approximate=n.approximate||i?.approximate||!1);const r=e[ht.quantityGroup(ht.hoursGroup)];let a;r&&(a=ht.parseComponent(r,nc,Lh.hour),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[ht.quantityGroup(ht.daysGroup)];let c;o&&(c=ht.parseComponent(o,sc,Lh.day),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[ht.quantityGroup(ht.monthsGroup)]||e[ht.quantityGroup(ht.isoMonthsGroup)];let d;h&&(d=ht.parseComponent(h,ic,Lh.month),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[ht.quantityGroup(ht.yearsGroup)];let p;u&&(p=ht.parseComponent(u,tc,Lh.year),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[ht.suffixGroup],m=!!e[U.groupName(oi.uncertainAndApproximateGroup,ht.durationGroup)]||f==="%",g=m||!!e[U.groupName(oi.uncertainGroup,ht.durationGroup)]||f==="?",v=m||!!e[U.groupName(oi.approximateGroup,ht.durationGroup)]||f==="~";return{years:p,months:d,days:c,hours:a,minutes:n,seconds:i,uncertain:g,approximate:v}}}const N5="dates",Rv="start",Cv="end",$x="durations",Ov="durationMin",Lv="durationMax";class Zg extends wc{static format=U.group(N5,U.optionalGroup(Rv,U.group("openStart","\\.\\.")+"|"+pi.format(Rv))+"/"+U.optionalGroup(Cv,U.group("openEnd","\\.\\.")+"|"+pi.format(Cv)))+"|"+U.group($x,U.group(Ov,ht.format(Ov))+"/"+U.group(Lv,ht.format(Lv)));constructor(e="interval",t=Zg.format){super(e,t)}parseGroups(e){let t,i;if(e[$x]){const n=e[Ov];t=Xs.fromString(n,new ht);const r=e[Lv];i=Xs.fromString(r,new ht)}else{const n=e[Rv];switch(n){case void 0:t=null;break;case"..":t=void 0;break;default:t=gr.fromString(n,new pi)}const r=e[Cv];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=gr.fromString(r,new pi)}}return{start:t,end:i}}}class F5{parse(e){e=e.trim();const t=e.startsWith("["),s=e.substring(1,e.length-1).split(","),n=[];for(const r of s){let a;r.includes("..")?a=Yp.fromString(r.replace("..","/"),new Zg):a=gr.fromString(r,new pi),n.push(a)}return{values:n,exclusive:t}}}Be.register(gr,()=>new pi);Be.register(sc,()=>new lf);Be.register(Xs,()=>new ht);Be.register(nc,()=>new hf);Be.register(Yp,()=>new Zg);Be.register(rc,()=>new uf);Be.register(ic,()=>new cf);Be.register(ac,()=>new df);Be.register(K0,()=>new F5);Be.register(tc,()=>new of);class Fs{constructor(e){this.preferences=e}read(e){var t,i;if(e===void 0)return;if(typeof e=="string")return e===""?void 0:e;for(const n of this.preferences){const r=(t=e[n])!==null&&t!==void 0?t:e[Fs.base(n)];if(r)return r}const s=new Set(this.preferences.map(n=>Fs.base(n)));for(const[n,r]of Object.entries(e))if(r&&s.has(Fs.base(n)))return r;return(i=Object.values(e).find(n=>n))!==null&&i!==void 0?i:void 0}write(e,t,i){var s,n;const r=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return r;const a={...e},o=(n=(s=Object.keys(a).find(c=>c===i))!==null&&s!==void 0?s:Object.keys(a).find(c=>Fs.base(c)===Fs.base(i)))!==null&&n!==void 0?n:i;return r===void 0?delete a[o]:a[o]=r,Object.keys(a).length===0?void 0:a}static base(e){return e.toLowerCase().split("-")[0]}}Fs.any=new Fs([]);var Kx;(function(l){l.abductee="abductee",l.actor="actor",l.artist="artist",l.anthropologist="anthropologist",l.archeologist="archeologist",l.astronaut="astronaut",l.astronomer="astronomer",l.astrologist="astrologist",l.astrophysicist="astrophysicist",l.banker="banker",l.barman="barman",l.biologist="biologist",l.biochemist="biochemist",l.biophysicist="biophysicist",l.bishop="bishop",l.businessman="businessman",l.botanist="botanist",l.cameraman="cameraman",l.chemist="chemist",l.contactee="contactee",l.cryptozoologist="cryptozoologist",l.dentist="dentist",l.director="director",l.diplomat="diplomat",l.diver="diver",l.electronics="electronics",l.engineer="engineer",l.ethnologist="ethnologist",l.exobiologist="exobiologist",l.farmer="farmer",l.firefighter="firefighter",l.flightAttendant="flightAttendant",l.geologist="geologist",l.geophysicist="geophysicist",l.geographer="geographer",l.historian="historian",l.houseWife="houseWife",l.hypnotherapist="hypnotherapist",l.illusionist="illusionist",l.journalist="journalist",l.judge="judge",l.lawyer="lawyer",l.leader="leader",l.librarian="librarian",l.logger="logger",l.mathematician="mathematician",l.mechanic="mechanic",l.meteorologist="meteorologist",l.military="military",l.musician="musician",l.neurologist="neurologist",l.neuroscientist="neuroscientist",l.neuropsychiatrist="neuropsychiatrist",l.nurse="nurse",l.oceanographer="oceanographer",l.painter="painter",l.parapsychologist="parapsychologist",l.philosopher="philosopher",l.photographer="photographer",l.physician="physician",l.physicist="physicist",l.pilot="pilot",l.politician="politician",l.policeman="policeman",l.priest="priest",l.producer="producer",l.prospector="prospector",l.psychologist="psychologist",l.psychiatrist="psychiatrist",l.radioastronomer="radioastronomer",l.radioamateur="radioamateur",l.salesman="salesman",l.sailor="sailor",l.sociologist="sociologist",l.softwareEngineer="softwareEngineer",l.stuntman="stuntman",l.taxiDriver="taxiDriver",l.teacher="teacher",l.telegrapher="telegrapher",l.truckDriver="truckDriver",l.ufologist="ufologist",l.ufoWitness="ufoWitness",l.ufoWitness2="ufoWitness2",l.worker="worker",l.writer="writer"})(Kx||(Kx={}));var Xx;(function(l){l.neutral="neutral",l.male="male",l.female="female"})(Xx||(Xx={}));class U5 extends Error{constructor(e,t){super(e),this.cause=t}}class kw extends U5{constructor(e=kw.defaultMessage,t){super(e,t)}}kw.defaultMessage="Assertion failed";var Yx;(function(l){l.country="country",l.region="region",l.department="department",l.city="city",l.company="company"})(Yx||(Yx={}));var qx;(function(l){l.at="at",l.au="au",l.ar="ar",l.be="be",l.br="br",l.ca="ca",l.ch="ch",l.cn="cn",l.cl="cl",l.co="co",l.cy="cy",l.de="de",l.dk="dk",l.do="do",l.dz="dz",l.gr="gr",l.ec="ec",l.eg="eg",l.es="es",l.fi="fi",l.fr="fr",l.ga="ga",l.ge="ge",l.hu="hu",l.in="in",l.ie="ie",l.ir="ir",l.il="il",l.it="it",l.jp="jp",l.kr="kr",l.ma="ma",l.mx="mx",l.my="my",l.mz="mz",l.nl="nl",l.no="no",l.nz="nz",l.pa="pa",l.pe="pe",l.ph="ph",l.pl="pl",l.pt="pt",l.ro="ro",l.ru="ru",l.sc="sc",l.tr="tr",l.ua="ua",l.uk="uk",l.us="us",l.sa="sa",l.se="se",l.su="su",l.tn="tn",l.tw="tw",l.ve="ve",l.za="za"})(qx||(qx={}));class B5{static of(e){if(!(!e||e.length===0))return e.some(t=>t.outcome==="fails"&&t.against!=="supposed")?"incompatible":e.some(t=>t.outcome!=="holds")?"unsettled":"compatible"}}/**
|
|
443
|
+
`;class $d extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get($d.TAG)||customElements.define($d.TAG,$d)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=W_;const e=t=>this.shadow.getElementById(t);this.dialog=e("dialog"),this.linkField=e("link"),this.copyButton=e("copy"),this.linkBox=e("link-box"),this.embedBox=e("embed-box"),this.linkOption=e("link-option"),this.embedOption=e("embed-option"),this.pin=e("pin"),this.embedMarkup=e("embed-markup"),this.noteElement=e("note"),e("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",t=>{t.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(e){const t=++this.languageToken,i=await O_.load(e);if(t===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(e){this.noteElement.textContent=e??"",this.noteElement.hidden=e===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const e=this.subject;if(!e)return;const t=this.pin.checked;this.linkField.value=t?lo.pinnedLink(e.link(),"0.192.0"):e.link(),this.fitLink();const s=`<script type="module" src="${t?lo.pinned(e.module,"0.192.0"):lo.current(e.module,import.meta.url,lu.home())}"><\/script>
|
|
444
|
+
${e.element()}`;this.embedMarkup.value=s,this.codeEditor&&(this.codeEditor.text=s)}applyMessages(){const e=this.messages;if(!e)return;const t=(i,s)=>{this.shadow.getElementById(i).textContent=s};t("title",e.share),t("link-label",e.link),t("embed-label",e.embed),t("copy",e.copy),t("pin-label",e.pin.replace("{version}","0.192.0")),this.pin.parentElement.title=e.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",e.close),this.linkField.setAttribute("aria-label",e.link)}show(e){this.linkBox.hidden=e!=="link",this.embedBox.hidden=e!=="embed",this.linkOption.setAttribute("aria-pressed",String(e==="link")),this.embedOption.setAttribute("aria-pressed",String(e==="embed")),e==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=V(async()=>{const{ShareCodeEditor:e}=await import("./ShareCodeEditor-CF7IVeXv.js");return{ShareCodeEditor:e}},__vite__mapDeps([7,8]),import.meta.url).then(({ShareCodeEditor:e})=>{this.codeEditor=new e(this.shadow.getElementById("embed-code"),this.embedMarkup.value,t=>{this.embedMarkup.value=t},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(e,t){try{await navigator.clipboard.writeText(e),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{t.select()}}}class Ur extends Error{}class Xg{constructor(e){this.name=e}validate(e){return!0}}class mT extends Xg{min;max;constructor(e,t,i){super(e),this.min=t,this.max=i}validate(e){if(typeof e!="number")throw new Ur(`${this.name} value must be a number, but was ${e}`);if(e<this.min||e>this.max)throw new Ur(`${this.name} value must be >= ${this.min} and <= ${this.max}, but was ${e}`);return super.validate(e)}}class Pi{name;min;max;duration;subUnit;validator;constructor(e,t,i,s,n=new mT(e,t,i)){this.name=e,this.min=t,this.max=i,this.subUnit=s,this.duration=s?(s.max-s.min+1)*s.duration:1,this.validator=n}validate(e){return this.validator.validate(e)}[Symbol.iterator](){let e=this.min;return{next:()=>{const t={done:e>this.max,value:e};return e++,t}}}}class Ew{millisecond;second;minute;hour;day;month;year}class $_ extends Ew{}class gT extends $_{millisecond=new Pi("millisecond",0,999,void 0);second=new Pi("second",0,59,this.millisecond);minute=new Pi("minute",0,59,this.second);hour=new Pi("hour",0,23,this.minute);day=new Pi("day",1,31,this.hour);month=new Pi("month",1,12,this.day);year=new Pi("year",0,9999,this.month)}const gt=new gT;class vT extends mT{constructor(e=1,t=12){super("month",e,t)}}class Sd extends Pi{static Month28=new Sd(28);static Month29=new Sd(29);static ThirtyDays=new Sd(30);static ThirtyOneDays=new Sd(31);constructor(e,t=new vT(1,e)){super("month",1,e,gt.day,t)}static create(e,t){switch(e){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return this.ThirtyOneDays;case 2:return t%4===0?this.Month29:this.Month28;case 4:case 6:case 9:case 11:return this.ThirtyDays;default:throw new Ur("Unsupported month",e,t)}}}class yo{static instance=new yo;render(e){return e.value.toString()}}class jn{unit;#e;constructor(e,t){this.unit=t,this.value=typeof e=="number"?e:e.value}get value(){return this.#e}set value(e){this.unit.validate(e),this.#e=e}get duration(){return this.value*this.unit.duration}#t(e){if(this.constructor.name!==e.constructor.name)throw new Xg(`${this.unit.name} "${this.toString()}" cannot be compared with ${e.unit?.name} "${e.toString()}"`)}compare(e){return this.#t(e),this.value-e.value}isEqual(e){return this.compare(e)===0}isBefore(e){return this.compare(e)<0}isAfter(e){return this.compare(e)>0}previous(e=this.unit){const t=this.value-1;return new this.constructor(t,e)}next(e=this.unit){const t=this.value+1;return new this.constructor(t,e)}toString(e=yo.instance){return e.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class Be{static#e=new Map;static register(e,t){Be.#e.set(e,t)}static get(e){const t=Be.#e.get(e);if(!t)throw new Ur(`No default parser registered for ${e.name}: import "@rr0/time/defaults" or pass a parser to fromString()`);return t()}}class hu extends jn{constructor(e=new Date().getFullYear(),t=gt.year){super(e,t)}static fromString(e,t=Be.get(hu)){return new hu(t.parse(e))}}class Co extends yo{static default=new Co("0",2);constructor(e,t){super(),this.char=e,this.size=t}render(e){return super.render(e).padStart(this.size,this.char)}}class du extends jn{constructor(e=new Date().getMonth()+1,t=gt.month){super(e,t)}static fromString(e,t=Be.get(du)){return new du(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class uu extends jn{constructor(e=new Date().getDate(),t=gt.day){super(e,t)}static fromString(e,t=Be.get(uu)){const i=t.parse(e);return new uu(i)}toString(e=Co.default){return super.toString(e)}}class pu extends jn{constructor(e=new Date().getHours(),t=gt.hour){super(e,t)}static fromString(e,t=Be.get(pu)){return new pu(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class fu extends jn{constructor(e=new Date().getMinutes(),t=gt.minute){super(e,t)}static fromString(e,t=Be.get(fu)){return new fu(t.parse(e))}toString(e=Co.default){return super.toString(e)}}class mu extends jn{constructor(e=new Date().getSeconds(),t=gt.second){super(e,t)}static fromString(e,t=Be.get(mu)){return new mu(t.parse(e),gt.second)}toString(e=Co.default){return super.toString(e)}}class Tl extends jn{static renderer=new Co("0",3);constructor(e,t=gt.millisecond){super(e,t)}static parseFraction(e){return parseInt(e.padEnd(3,"0").substring(0,3),10)}toString(e=Tl.renderer){return super.toString(e)}}class K_{render(e){return e.toString()}}class X_ extends K_{render(e){const t=e.value,i=Math.abs(t),s=Math.floor(i/60),n=i%60;if(s===0&&n===0)return"Z";{const r=t<0?"-":"+",a=s.toString().padStart(2,"0"),o=n>0?":"+n.toString().padEnd(2,"0"):"";return r+a+o}}}class bl{value;name="timeshift";renderer;constructor(e=0){this.value=e}static fromString(e,t=Be.get(bl),i=void 0){const s=t.parse(e,i);return new bl(s)}toString(e=new X_){return e.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class Vn{static timeshift(e,t){return e+(Vn.isDaylight(t)?60:0)}static isDaylight(e){const{year:t,month:i,day:s}=e,n=e.hour??12;if(![t,i,s].every(Number.isInteger))throw new RangeError("Daylight saving time depends on the year, month and day");const r=Vn.rule(t);if(!r)return!1;const a=Vn.rank(i,s,n);return a>=Vn.rank(r.start.month,r.start.day,2)&&a<Vn.rank(r.end.month,r.end.day,2)}static rule(e){if(e<1967)return;const t={month:10,day:Vn.sunday(e,10,-1)};return e>=2007?{start:{month:3,day:Vn.sunday(e,3,2)},end:{month:11,day:Vn.sunday(e,11,1)}}:e>=1987?{start:{month:4,day:Vn.sunday(e,4,1)},end:t}:e===1975?{start:{month:2,day:23},end:t}:e===1974?{start:{month:1,day:6},end:t}:{start:{month:4,day:Vn.sunday(e,4,-1)},end:t}}static sunday(e,t,i){const s=new Date(Date.UTC(2e3,t-1,1));s.setUTCFullYear(e);const n=1+(7-s.getUTCDay())%7;if(i>0)return n+7*(i-1);const r=[31,Vn.isLeap(e)?29:28,31,30,31,30,31,31,30,31,30,31][t-1];let a=n;for(;a+7<=r;)a+=7;return a}static isLeap(e){return e%4===0&&(e%100!==0||e%400===0)}static rank(e,t,i){return(e*100+t)*100+i}}const Y_={name:"PST",timeshift:"-08",title:"Pacific Standard Time (US)"},q_={name:"PDT",timeshift:"-07",title:"Pacific Daylight Time (US)"},j_={name:"MDT",timeshift:"-06",title:"Mountain Standard Time (US)"},Z_={name:"MST",timeshift:"-07",title:"Mountain Daylight Time (US)"},J_={name:"PT",timeshift:l=>Vn.timeshift(-480,l),title:"Pacific Time (US)"},Q_={name:"MT",timeshift:l=>Vn.timeshift(-420,l),title:"Mountain Time (US)"},e5={name:"CT",timeshift:l=>Vn.timeshift(-360,l),title:"Central Time (US)"},t5={name:"ET",timeshift:l=>Vn.timeshift(-300,l),title:"Eastern Time (US)"},i5={name:"CWT",timeshift:"-05",title:"Central War Time (US)"},s5={name:"CDT",timeshift:"-05",title:"Central Daylight Time"},n5={name:"EST",timeshift:"-05",title:"Eastern Standard Time (US)"},r5={name:"EDT",timeshift:"-04",title:"Eastern Time (US)"},a5={name:"AST",timeshift:"-04",title:"Atlantic Standard Time (US)"},o5={name:"ADT",timeshift:"-03",title:"Atlantic Daylight Time (US)"},c5={name:"UTC",timeshift:"Z",title:"Coordinated Universal Time"},l5={name:"Z",timeshift:"Z",title:"UTC"},h5={name:"GMT",timeshift:"Z",title:"Greenwich Mean Time"},d5={name:"BST",timeshift:"+01",title:"British Summer Time"},u5={name:"CEST",timeshift:"+02",title:"Central European Summer Time"},p5={name:"CET",timeshift:"+01",title:"Central European Time"},f5={name:"MSK",timeshift:"+03",title:"Moscow Time (RU)"},m5={name:"IST",timeshift:"+05:30",title:"Indian Standard Time"},g5={name:"BJT",timeshift:"+08",title:"Beijing Time"},v5={name:"CST",timeshift:"-06",title:"Central Standard Time"},b5={name:"JST",timeshift:"+09",title:"Japan Standard Time"},y5={name:"AEST",timeshift:"+10",title:"Australian Eastern Standard Time"},w5={name:"NZST",timeshift:"+12",title:"New Zealand Standard Time"},M5={name:"LST",timeshift:"?",title:"Local Sideral Time"},ix=[o5,y5,a5,g5,d5,v5,s5,p5,u5,e5,i5,r5,n5,t5,h5,m5,b5,M5,j_,f5,Z_,Q_,w5,q_,Y_,J_,c5,l5];class Yg{static instance=new Yg;renderComponent(e,t){return e[t].toString()}renderSecond(e){return this.renderComponent(e,"second")+(e.millisecond?"."+e.millisecond.toString():"")}render(e){const t=[];e.year&&t.push(this.renderComponent(e,"year")),e.month&&t.push(this.renderComponent(e,"month")),e.day&&t.push(this.renderComponent(e,"day"));const i=[];e.hour&&i.push(this.renderComponent(e,"hour")),e.minute&&i.push(this.renderComponent(e,"minute")),e.second&&i.push(this.renderSecond(e));const s=t.join("-"),n=e.timeshift?e.timeshift.toString():"",r=i.join(":")+n;return s+(r.length>0?"T"+r:"")}}class Wl extends Ur{constructor(e="method is abstract"){super(e)}}class Sw{units;constructor(e){this.units=e}newYear(e){throw new Wl}newMonth(e){throw new Wl}newDay(e){throw new Wl}newHour(e){throw new Wl}newMinute(e){throw new Wl}newSecond(e){throw new Wl}}class x5 extends Ew{millisecond=new Pi("milliseconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,void 0);second=new Pi("seconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new Pi("minutes",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.second);hour=new Pi("hours",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.minutes);day=new Pi("days",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.hour);month=new Pi("months",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.day);year=new Pi("years",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const Hf=new x5;class qg{static instance=new qg;render(e){const t=Ua.toSpec(e);let i="P";const s=t.years;s&&(i+=s.toString()+"Y");const n=t.months;n&&(i+=n.toString(yo.instance)+"MM");const r=t.days;r&&(i+=r.toString(yo.instance)+"D");const a=t.hours;a&&(i+=a.toString(yo.instance)+"H");const o=t.minutes;o&&(i+=o.toString(yo.instance)+"M");const c=t.seconds;return c&&(i+=c.toString(yo.instance)+"S"),i}}class Ua extends jn{constructor(e={years:new Date().getFullYear(),months:new Date().getMonth(),days:new Date().getDate(),hours:new Date().getHours(),minutes:new Date().getMinutes(),seconds:new Date().getSeconds(),milliseconds:new Date().getMilliseconds()}){super({value:typeof e=="number"?e:+(e.years?e.years*gt.year.duration:0)+(e.months?e.months*gt.month.duration:0)+(e.days?e.days*gt.day.duration:0)+(e.hours?e.hours*gt.hour.duration:0)+(e.minutes?e.minutes*gt.minute.duration:0)+(e.seconds?e.seconds*gt.second.duration:0)},new Pi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0))}static toSpec(e,t=S5){let i=typeof e=="number"?e:e.value;const s=i>0?1:-1;i=Math.abs(i);const n={},r=i/gt.year.duration,a=Math.floor(r);a>0&&(n.years=t.newYear(s*a),i-=a*gt.year.duration);const o=i/gt.month.duration,c=Math.floor(o);c>0&&(n.months=t.newMonth(s*c),i-=c*gt.month.duration);const h=i/gt.day.duration,d=Math.floor(h);d>0&&(n.days=t.newDay(s*d),i-=d*gt.day.duration);const u=i/gt.hour.duration,p=Math.floor(u);p>0&&(n.hours=t.newHour(s*p),i-=p*gt.hour.duration);const f=i/gt.minute.duration,m=Math.floor(f);m>0&&(n.minutes=t.newMinute(s*m),i-=m*gt.minute.duration);const g=i/gt.second.duration,v=Math.floor(s*g);return v>0&&(n.seconds=t.newSecond(v)),n}static fromString(e,t=Be.get(Ua)){return new Ua(t.parse(e))}static between(e,t){const i=t.getTime(),s=e.getTime();return new Ua(i-s)}toSpec(){return Ua.toSpec(this)}toString(e=qg.instance){return e.render(this)}}class bT extends Sw{constructor(e){super(e)}newYear(e){return new hu(e,this.units.year)}newMonth(e){return new du(e,this.units.month)}newDay(e){return new uu(e,this.units.day)}newHour(e){return new pu(e,this.units.hour)}newMinute(e){return new fu(e,this.units.minute)}newSecond(e){return new mu(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new bl(typeof e=="number"?e:e.value)}}const E5=new bT(gt),S5=new bT(Hf);class Mn{#e;#t;#i;#s;#n;#r;#a;#o;constructor(e={year:new Date().getFullYear(),month:new Date().getMonth()+1,day:new Date().getDate(),hour:new Date().getHours(),minute:new Date().getMinutes(),second:new Date().getSeconds(),timeshift:Mn.timeshiftOf(new Date)}){this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.millisecond=e.millisecond,this.timeshift=e.timeshift}get year(){return this.#e}set year(e){const t=typeof e=="number";this.#e&&t?this.#e.value=e:this.#e=t?this.factory.newYear(e):!e||e.start||e instanceof jn?e:this.factory.newYear(e)}get month(){return this.#t}set month(e){const t=typeof e=="number";this.#t&&t?this.#t.value=e:this.#t=t?this.factory.newMonth(e):!e||e.start||e instanceof jn?e:this.factory.newMonth(e)}get day(){return this.#i}set day(e){const t=typeof e=="number";this.#i&&t?this.#i.value=e:this.#i=t?this.factory.newDay(e):!e||e.start||e instanceof jn?e:this.factory.newDay(e)}get hour(){return this.#s}set hour(e){const t=typeof e=="number";this.#s&&t?this.#s.value=e:this.#s=t?this.factory.newHour(e):!e||e.start||e instanceof jn?e:this.factory.newHour(e)}get minute(){return this.#n}set minute(e){const t=typeof e=="number";this.#n&&t?this.#n.value=e:this.#n=t?this.factory.newMinute(e):!e||e.start||e instanceof jn?e:this.factory.newMinute(e)}get second(){return this.#r}set second(e){const t=typeof e=="number";this.#r&&t?this.#r.value=e:this.#r=t?this.factory.newSecond(e):!e||e.start||e instanceof jn?e:this.factory.newSecond(e)}get millisecond(){return this.#a}set millisecond(e){const t=typeof e=="number";this.#a&&t?this.#a.value=e:this.#a=t||e&&!(e instanceof jn)?this.factory.newMillisecond(e):e}get timeshift(){return this.#o}set timeshift(e){const t=typeof e=="number";this.#o&&t?this.#o.value=e:this.#o=t||e&&!(e instanceof bl)?this.factory.newTimeshift(e):e}get factory(){return E5}static fromString(e,t=Be.get(Mn)){const{year:i,month:s,day:n,hour:r,minute:a,second:o,millisecond:c,timeshift:h}=t.parse(e);return new Mn({year:i,month:s,day:n,hour:r,minute:a,second:o,millisecond:c,timeshift:h})}static timeshiftOf(e){return-e.getTimezoneOffset()||0}static fromDate(e){return new Mn({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return Mn.fromString(i)}#c(e){if(this.constructor.name!==e.constructor.name)throw new Xg(`Date "${this.toString()}" cannot be compared with "${e.toString()}"`)}compare(e){return this.#c(e),this.getTime()-e.getTime()}delta(e){const t=this.compare(e);return new Ua(t)}getTime(){return(this.year?.duration||0)+(this.month?.duration||0)+(this.day?.duration||0)+(this.hour?.duration||0)+(this.minute?.duration||0)+(this.second?.duration||0)+(this.millisecond?.duration||0)}isEqual(e){return this.compare(e)===0}isBefore(e){return this.compare(e)<0}isAfter(e){return this.compare(e)>0}clone(){return new Mn(this.toSpec())}previous(){let e=this.clone();try{e.second=this.second.previous()}catch{try{e.minute=this.minute.previous()}catch{try{e.hour=this.hour.previous()}catch{try{e.day=this.day.previous()}catch{try{e.month=this.month.previous()}catch{e.year=this.year.previous()}}}}}return e}next(){let e=this.clone();try{e.second=this.second.next()}catch{try{e.minute=this.minute.next()}catch{try{e.hour=this.hour.next()}catch{try{e.day=this.day.next()}catch{try{e.month=this.month.next()}catch{e.year=this.year.next()}}}}}return e}toString(e=Yg.instance){return e.render(this)}toSpec(){const e={},t=this.year?.toSpec();t&&(e.year=t);const i=this.month?.toSpec();i&&(e.month=i);const s=this.day?.toSpec();s&&(e.day=s);const n=this.hour?.toSpec();n&&(e.hour=n);const r=this.minute?.toSpec();r&&(e.minute=r);const a=this.second?.toSpec();a&&(e.second=a);const o=this.millisecond?.toSpec();o&&(e.millisecond=o);const c=this.timeshift?.toSpec();return c&&(e.timeshift=c),e}toJSON(){return this.toSpec()}}class Aw{static instance=new Aw;render(e){return(e.start?e.start.toString():"")+"/"+(e.end?e.end.toString():"")}}class Kp{constructor(e,t){this.start=e,this.end=t}_start;get start(){return this._start}set start(e){if(typeof e=="string"&&(e=Mn.fromString(e)),e&&!(e instanceof Mn)&&!(e instanceof Ua))throw new Ur("Interval start is not a level 0 date or duration: "+e);this._start=e}_end;get end(){return this._end}set end(e){if(typeof e=="string"&&(e=Mn.fromString(e)),e&&!(e instanceof Mn)&&!(e instanceof Ua))throw new Ur("Interval end is not a level 0 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Kp)){const{start:i,end:s}=t.parse(e);return new Kp(i,s)}toString(e=Aw.instance){return e.render(this)}[Symbol.iterator](){let e=this.start;return{next:()=>{const t={done:e>this.end,value:e};return e++,t}}}}class Gf extends yo{static instance=new Gf(Co.default);constructor(e){super(),this.valueRenderer=e}render(e){return(this.valueRenderer?this.valueRenderer.render(e):super.render(e))+this.qualifier(e)}qualifier(e){return e.uncertain?e.approximate?"%":"?":e.approximate?"~":""}}class Do extends jn{#e;#t;constructor(e,t){super(e,t),this.#e=e.uncertain||!1,this.#t=e.approximate||!1}get uncertain(){return this.#e}set uncertain(e){return this.#e=e}get approximate(){return this.#t}set approximate(e){return this.#t=e}isCertainAndPrecise(){return!this.approximate&&!this.uncertain}isEqual(e){return this.isCertainAndPrecise()&&super.isEqual(e)}isBefore(e){return this.isCertainAndPrecise()&&super.isBefore(e)}isAfter(e){return this.isCertainAndPrecise()&&super.isAfter(e)}toString(e=Gf.instance){return super.toString(e)}toSpec(){return{...super.toSpec(),uncertain:this.uncertain,approximate:this.approximate}}toJSON(){return this.toSpec()}}class yT extends gT{year=new Pi("year",-9999,9999,this.month);yearExtended=new Pi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const _0=new yT;class Qc extends Do{constructor(e,t=_0.year){super(e,t)}static fromString(e,t=_0.year,i=Be.get(Qc)){const s=i.parse(e),n=s.value.start;if(e.startsWith("Y")&&(t=_0.yearExtended),n!==void 0){const r=new Qc(Object.assign({...s},{value:Math.max(n,t.min)})),a=new Qc(Object.assign({...s},{value:Math.min(s.value.end,t.max)}));return{start:r,end:a}}else return new Qc(s,t)}}class wT extends Xg{monthValidator=new vT;validate(e){switch(e){case 21:case 22:case 23:case 24:return!0;default:return this.monthValidator.validate(e)}}}class el extends Do{constructor(e,t=new Pi(gt.month.name,1,24,gt.day,new wT)){super(e,t)}static fromString(e,t=Be.get(el)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.month;const r=new el(Object.assign({...i},{value:Math.max(s,n.min)})),a=new el(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new el(i)}toString(e){return super.toString(e).padStart(2,"0")}}class tl extends Do{constructor(e,t=gt.day){super(e,t)}static fromString(e,t=Be.get(tl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.day;const r=new tl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new tl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new tl(i)}toString(e){return super.toString(e).padStart(2,"0")}}class il extends Do{constructor(e,t=gt.hour){super(e,t)}static fromString(e,t=Be.get(il)){const i=t.parse(e),s=i.value.start;if(s!==void 0){let n=gt.hour;const r=new il(Object.assign({...i},{value:Math.max(s,n.min)})),a=new il(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new il(i)}}class sl extends Do{constructor(e,t=gt.minute){super(e,t)}static fromString(e,t=Be.get(sl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.minute,r=new sl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new sl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new sl(i)}toString(e=Gf.instance){return super.toString(e)}}class nl extends Do{constructor(e,t=gt.second){super(e,t)}static fromString(e,t=Be.get(nl)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.second,r=new nl(Object.assign({...i},{value:Math.max(s,n.min)})),a=new nl(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new nl(i)}}class xh extends bl{static fromString(e,t=Be.get(xh),i=void 0){return new xh(t.parse(e,i))}}class MT extends Sw{constructor(e){super(e)}newYear(e){return new Qc(e,this.units.year)}newMonth(e){return new el(e,this.units.month)}newDay(e){return new tl(e,this.units.day)}newHour(e){return new il(e,this.units.hour)}newMinute(e){return new sl(e,this.units.minute)}newSecond(e){return new nl(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new xh(typeof e=="number"?e:e.value)}}const A5=new MT(_0),T5=new MT(Hf);class Pr extends Mn{constructor(e){super(e)}get factory(){return A5}get uncertain(){return this.year?.uncertain===!0||this.month?.uncertain===!0||this.day?.uncertain===!0||this.hour?.uncertain===!0||this.minute?.uncertain===!0||this.second?.uncertain===!0}get approximate(){return this.year?.approximate===!0||this.month?.approximate===!0||this.day?.approximate===!0||this.hour?.approximate===!0||this.minute?.approximate===!0||this.second?.approximate===!0}static fromDate(e){return new Pr({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static fromString(e,t=Be.get(Pr)){const i=t.parse(e);return new Pr(i)}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return Pr.fromString(i)}clone(){return new Pr(this.toSpec())}}const tn=Object.freeze({year:"year",month:"month",day:"day",hour:"hour",minute:"minute",second:"second",timeshift:"timeshift",uncertain:"uncertain",approximate:"approx"});class jg extends qg{static instance=new jg;render(e){return super.render(e)}}class qs extends Do{constructor(e){super(typeof e=="number"||e.hasOwnProperty("value")?e:{value:qs.getValue(e,tn.year)+qs.getValue(e,tn.month)+qs.getValue(e,tn.day)+qs.getValue(e,tn.hour)+qs.getValue(e,tn.minute)+qs.getValue(e,tn.second),uncertain:qs.getBoolean(e,tn.uncertain),approximate:qs.getBoolean(e,"approximate")},Hf.millisecond)}static getBoolean(e,t){return e[t]||e[tn.year+"s"]?.[t]||e[tn.month+"s"]?.[t]||e[tn.day+"s"]?.[t]||e[tn.hour+"s"]?.[t]||e[tn.minute+"s"]?.[t]||e[tn.second+"s"]?.[t]||!1}static getValue(e,t){let i=0,s=e[t+"s"];if(s instanceof Do?s=s.value:typeof e=="number"&&(s=e),s){const n=gt[t];i=s*n.duration}return i}static toSpec(e,t=T5){return{...Ua.toSpec(e,t),uncertain:e.uncertain||!1,approximate:e.approximate||!1}}static fromString(e,t=Be.get(qs)){const i=t.parse(e);return new qs(i)}static between(e,t){const i=t.getTime(),s=e.getTime();return new qs(i-s)}toString(e=jg.instance){return super.toString(e)}toSpec(){return qs.toSpec(this)}}class Xp extends Kp{constructor(e,t){super(e,t)}get start(){return this._start}set start(e){if(typeof e=="string"&&(super.start=Pr.fromString(e)),e&&!(e instanceof Pr)&&!(e instanceof qs))throw new Ur("Interval start is not a level 1 date or duration: "+e);this._start=e}get end(){return this._end}set end(e){if(typeof e=="string"&&(e=Pr.fromString(e)),e&&!(e instanceof Pr)&&!(e instanceof qs))throw new Ur("Interval end is not a level 1 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Xp)){const{start:i,end:s}=t.parse(e);return new Xp(i,s)}}class Iu extends Do{uncertainComponent;approximateComponent;constructor(e,t){super(e,t),this.uncertainComponent=e.uncertainComponent||!1,this.approximateComponent=e.approximateComponent||!1}get uncertain(){return super.uncertain||this.uncertainComponent}set uncertain(e){return super.uncertain=e}get approximate(){return super.approximate||this.approximateComponent}set approximate(e){return super.approximate=e}get uncertainGroup(){return super.uncertain}get approximateGroup(){return super.approximate}toSpec(){return{...super.toSpec(),uncertain:this.uncertainGroup,approximate:this.approximateGroup,uncertainComponent:this.uncertainComponent,approximateComponent:this.approximateComponent}}toJSON(){return this.toSpec()}}class I5 extends yT{year=new Pi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const _y=new I5;class tc extends Iu{constructor(e,t=_y.year){super(e,t)}static fromString(e,t=_y.year,i=Be.get(tc)){const s=i.parse(e),n=s.value.start;if(n!==void 0){const r=new tc(Object.assign({...s},{value:Math.max(n,t.min)})),a=new tc(Object.assign({...s},{value:Math.min(s.value.end,t.max)})),o={start:r,end:a},c=s.value.estimate;return c&&(o.estimate=c),o}else return new tc(s)}}class _5 extends wT{validate(e){switch(e){case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:return!0;default:return super.validate(e)}}}class ic extends Iu{constructor(e,t=new Pi(gt.month.name,1,41,gt.day,new _5)){super(e,t)}static fromString(e,t=Be.get(ic)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.month,r=new ic(Object.assign({...i},{value:Math.max(s,n.min)})),a=new ic(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new ic(i)}toString(e){return super.toString(e).padStart(2,"0")}}class sc extends Iu{constructor(e,t=gt.day){super(e,t)}static fromString(e,t=Be.get(sc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.day,r=new sc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new sc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new sc(i)}toString(e){return super.toString(e).padStart(2,"0")}}class nc extends Iu{constructor(e,t=gt.hour){super(e,t)}static fromString(e,t=Be.get(nc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.hour,r=new nc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new nc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new nc(i)}}class rc extends Iu{constructor(e,t=gt.minute){super(e,t)}static fromString(e,t=Be.get(rc)){const i=t.parse(e),s=i.value.start;if(s!==void 0){const n=gt.minute,r=new rc(Object.assign({...i},{value:Math.max(s,n.min)})),a=new rc(Object.assign({...i},{value:Math.min(i.value.end,n.max)}));return{start:r,end:a}}else return new rc(i)}}class ac extends Iu{constructor(e,t=gt.second){super(e,t)}static fromString(e,t=gt.second,i=Be.get(ac)){const s=i.parse(e),n=s.value.start;if(n!==void 0){const r=new ac(Object.assign({...s},{value:Math.max(n,t.min)})),a=new ac(Object.assign({...s},{value:Math.min(s.value.end,t.max)}));return{start:r,end:a}}else return new ac(s,t)}}class xT extends xh{}class D5 extends Gf{qualifier(){return""}}class Fc extends Yg{static instance=new Fc;static valueRenderer=new D5(Co.default);static names=["year","month","day","hour","minute","second"];static qualifier(e,t){return e?t?"%":"?":t?"~":""}renderComponent(e,t){const i=e[t],s=Fc.names.slice(Fc.names.indexOf(t)+1).map(a=>e[a]).filter(Boolean),n=Fc.qualifier(i.uncertainComponent,i.approximateComponent),r=Fc.qualifier(i.uncertainGroup&&!i.uncertainComponent&&!s.some(a=>a.uncertain),i.approximateGroup&&!i.approximateComponent&&!s.some(a=>a.approximate));return n+i.toString(Fc.valueRenderer)+r}}class ET extends Sw{constructor(e){super(e)}newYear(e){return new tc(e,this.units.year)}newMonth(e){return new ic(e,this.units.month)}newDay(e){return new sc(e,this.units.day)}newHour(e){return new nc(e,this.units.hour)}newMinute(e){return new rc(e,this.units.minute)}newSecond(e){return new ac(e,this.units.second)}newMillisecond(e){return new Tl(e,this.units.millisecond)}newTimeshift(e){return new xT(typeof e=="number"?e:e.value)}}const k5=new ET(_y),R5=new ET(Hf);class gr extends Pr{constructor(e){super(e)}toString(e=Fc.instance){return super.toString(e)}get year(){return super.year}set year(e){super.year=e}get month(){return super.month}set month(e){super.month=e}get factory(){return k5}static fromDate(e){return new gr({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),timeshift:Mn.timeshiftOf(e)})}static fromString(e,t=Be.get(gr)){const i=t.parse(e);return new gr(i)}static newInstance(){const e=new Date().toISOString(),t=e.indexOf("."),i=e.substring(0,t)+e.substring(t+4);return gr.fromString(i)}clone(){return new gr(this.toSpec())}}class wc{regExp;constructor(e,t){this.name=e,this.regExp=new RegExp(`^(?:${t})$`)}regexGroups(e){const t=this.regExp.exec(e);if(!t)throw new Ur(`Invalid ${this.name} "${e}"`);return t.groups}parseGroups(e){throw new Wl(`${this.constructor.name} is abstract`)}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}class Ad extends jg{static instance=new Ad;static designators=[["years","Y"],["months","MM"],["days","D"],["hours","H"],["minutes","M"],["seconds","S"]];static qualifier(e,t){return e?t?"%":"?":t?"~":""}render(e){const t=Ad.qualifier(e.uncertainDuration,e.approximateDuration);if(!e.hasQualifiedComponent)return t+super.render(e);let i=t+"P";for(const[s,n]of Ad.designators){const r=e.components[s];r&&(i+=Ad.qualifier(r.uncertainComponent,r.approximateComponent)+r.value+n)}return i}}class Xs extends qs{#e;constructor(e){if(super(typeof e=="number"?e:{value:Xs.valueFromSpec(e),uncertain:e.uncertain===!0,approximate:e.approximate===!0},Hf.millisecond),typeof e!="number"){const t={};for(const i of Xs.componentNames)e[i]instanceof Do&&(t[i]=e[i]);Object.keys(t).length>0&&(this.#e=t)}}static componentNames=["years","months","days","hours","minutes","seconds"];get components(){return this.#e}#t(e){return this.#e?Object.values(this.#e).some(t=>t[e]):!1}get uncertainDuration(){return super.uncertain}get approximateDuration(){return super.approximate}get uncertain(){return super.uncertain||this.#t("uncertain")}set uncertain(e){super.uncertain=e}get approximate(){return super.approximate||this.#t("approximate")}set approximate(e){super.approximate=e}get hasQualifiedComponent(){return this.#e?Object.values(this.#e).some(e=>e.uncertainComponent||e.approximateComponent):!1}static valueFromSpec(e){return Xs.getValue(e,tn.year)+Xs.getValue(e,tn.month)+Xs.getValue(e,tn.day)+Xs.getValue(e,tn.hour)+Xs.getValue(e,tn.minute)+Xs.getValue(e,tn.second)}static toSpec(e,t=R5){const i=qs.toSpec(e,t);if(e instanceof Xs&&e.hasQualifiedComponent)for(const s of Xs.componentNames)delete i[s],e.components[s]&&(i[s]=e.components[s]);return i}static fromString(e,t=Be.get(Xs)){const i=t.parse(e);return new Xs(i)}static between(e,t){const i=t.getTime(),s=e.getTime();return new Xs(i-s)}toSpec(){return Xs.toSpec(this)}toString(e=Ad.instance){return super.toString(e)}}class Yp extends Xp{get start(){return this._start}set start(e){if(typeof e=="string"&&(super.start=gr.fromString(e)),e&&!(e instanceof gr)&&!(e instanceof Xs))throw new Ur("Interval start is not a level 2 date or duration: "+e);this._start=e}get end(){return this._end}set end(e){if(typeof e=="string"&&(e=gr.fromString(e)),e&&!(e instanceof gr)&&!(e instanceof Xs))throw new Ur("Interval end is not a level 2 date or duration: "+e);this._end=e}static fromString(e,t=Be.get(Yp)){const{start:i,end:s}=t.parse(e);return new Yp(i,s)}}class K0 extends Set{constructor(e,t){super(e),this.exclusive=t}has(e){const t=e.toString().replace("..","/");for(const i of this)if(i.toString()===t)return!0;return!1}static fromString(e,t=Be.get(K0)){const{exclusive:i,values:s}=t.parse(e);return new K0(s,i)}}class Mc extends wc{constructor(e,t){super(e,t)}static read(e){return{value:e?parseInt(e,10):void 0}}parseGroups(e){return Mc.read(e[this.name])}parse(e){if(e.startsWith("-"))throw new Ur(`${this.name} cannot be negative`);return super.parse(e)}}class U{static groupName(...e){return e.reduce((t,i)=>t?t+i.charAt(0).toUpperCase()+i.substring(1):i,"")}static group(e,...t){return`(?<${e}>${t.join("")})`}static optional(e){return e+"?"}static nonCapturingGroup(...e){return`(?:${e.join("")})`}static optionalGroup(e,...t){return U.optional(U.group(e,...t))}static optionalNonCapturingGroup(...e){return U.optional(U.nonCapturingGroup(...e))}static numberGroup(e,t,i,s="\\d"){return U.group(e,`${i||""}[${s}]${t}`)}}const sx="yearValue";class qp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,sx),"{4}",void 0)}constructor(){super(sx,qp.format())}}const nx="monthValue";class jp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,nx),"{1,2}",void 0)}constructor(){super(nx,jp.format())}}const rx="dayValue";class Kd extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,rx),"{1,2}",void 0)}constructor(){super(rx,Kd.format())}}const ax="hourValue";class Xd extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,ax),"{1,2}",void 0)}constructor(){super(ax,Xd.format())}}const ox="minuteValue";class Zp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,ox),"{1,2}",void 0)}constructor(){super(ox,Zp.format())}}const cx="secondValue";class Jp extends Mc{static format(e=""){return U.numberGroup(U.groupName(e,cx),"{1,2}",void 0)}constructor(){super(cx,Jp.format())}}const lx="timeshiftValue",hx="shiftHour",dx="shiftMinute";class gu extends wc{static format(e=""){return ix.map(t=>t.name).join("|")+"|"+U.nonCapturingGroup(U.group(e+hx,U.numberGroup(U.groupName(e,lx),"{2}","[+-]")),U.optionalNonCapturingGroup(":?",U.numberGroup(U.groupName(e,dx),"{2}",void 0)))}constructor(){super(lx,gu.format())}parse(e,t){let i=0;const s=ix.find(n=>n.name===e);if(s){if(typeof s.timeshift=="function")try{return s.timeshift(t??{})}catch(n){throw new Ur(`The time zone ${e} depends on the date: ${n.message}`)}e=s.timeshift}if(e!=="Z"){const n=this.regexGroups(e),r=n[hx];r&&(i+=parseInt(r,10)*60);const a=n[dx];a&&(i+=parseInt(a,10))}return i}}const ux="year",px="month",fx="day",mx="hour",gx="minute",vx="second",bx="millisecond",yx="timeshift";class eh extends wc{static format(e=""){return U.group(U.groupName(e,ux),qp.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,px),jp.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,fx),Kd.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,mx),Xd.format(e)),":?",U.group(U.groupName(e,gx),Zp.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,vx),Jp.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,bx),"\\d+"))),"\\s*",U.optionalGroup(U.groupName(e,yx),gu.format(e)))))}constructor(){super("date",eh.format())}parse(e){const t=this.regexGroups(e),i=t[ux],s=t[px],n=t[fx],r=t[mx],a=t[gx],o=t[vx],c=t[bx],h=t[yx],d=i?new hu(qp.read(i)):void 0,u=s?jp.read(s):void 0;return{year:d,month:u?new du(u,Sd.create(u.value,d?.value)):void 0,day:n?new uu(Kd.read(n)):void 0,hour:r?new pu(Xd.read(r)):void 0,minute:a?new fu(Zp.read(a)):void 0,second:o?new mu(Jp.read(o)):void 0,millisecond:c?Tl.parseFraction(c):void 0,timeshift:h?bl.fromString(h,new gu,{year:d?.value,month:u?.value,day:n?Kd.read(n).value:void 0,hour:r?Xd.read(r).value:void 0}):void 0}}}const wx="years",Sv="months",C5="days",Mx="hours",xx="minutes",Ex="seconds";class Tw extends wc{static format(e=""){return"P"+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,wx),"+",void 0,"\\d"),"Y")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Sv),"+",void 0,"\\d"),"MM")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,C5),"+",void 0,"\\d"),"D")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Mx),"+",void 0,"\\d"),"H")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,xx),"+",void 0,"\\d"),"M")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Ex),"+",void 0,"\\d"),"S")}constructor(){super("duration",Tw.format())}parseGroups(e){return{years:e[wx],months:e[Sv],days:e[Sv],hours:e[Mx],minutes:e[xx],seconds:e[Ex]}}}const Av="start",Tv="end";class Iw extends wc{static format=U.group(Av,eh.format(Av))+"/"+U.group(Tv,eh.format(Tv));constructor(){super("interval",Iw.format)}parse(e){const t=this.regexGroups(e),i=t[Av],s=t[Tv];return{start:i?Mn.fromString(i,new eh):void 0,end:s?Mn.fromString(s,new eh):void 0}}}Be.register(Mn,()=>new eh);Be.register(uu,()=>new Kd);Be.register(Ua,()=>new Tw);Be.register(pu,()=>new Xd);Be.register(Kp,()=>new Iw);Be.register(fu,()=>new Zp);Be.register(du,()=>new jp);Be.register(mu,()=>new Jp);Be.register(bl,()=>new gu);Be.register(hu,()=>new qp);class Zi extends Mc{static uncertainGroup="uncertain";static approximateGroup="approx";static uncertainAndApproximateGroup=Zi.uncertainGroup+Zi.approximateGroup;constructor(e,t){super(e,t)}static qualifierFormat(e,t){return U.optionalGroup(e,`\\${t}`)}static formatSuffix(e){return this.qualifierFormat(U.groupName(Zi.uncertainGroup,e),"?")+this.qualifierFormat(U.groupName(Zi.approximateGroup,e),"~")+this.qualifierFormat(U.groupName(Zi.uncertainAndApproximateGroup,e),"%")}static numberFormat(e,t,i){return U.numberGroup(e,t,i,"\\dX")+this.formatSuffix(e)}getValueAndSign(e){let t=e[this.name],i;return t.charAt(0)==="-"?(i=-1,t=t.substring(1)):i=1,{valueStr:t,sign:i}}parseGroups(e){const{valueStr:t,sign:i}=this.getValueAndSign(e);let s=0,n;for(n=0;n<t.length;n++){const c=t[n];if(c==="X")break;s=s*10+parseInt(c,10)}if(n<t.length){let c=1;for(let u=0;u<t.length-n;u++)c*=10;const h=i*s*c,d=h+c-1;s={start:h,end:d}}else s*=i;const r=e[U.groupName(Zi.uncertainAndApproximateGroup,this.name)],a=e[U.groupName(Zi.approximateGroup,this.name)]||r,o=e[U.groupName(Zi.uncertainGroup,this.name)]||r;return{value:s,approximate:a?!!a:!1,uncertain:o?!!o:!1}}}const Sx="yearValue";class Qp extends Zi{constructor(){super(Sx,Qp.format())}static format(e=""){return"Y?"+Zi.numberFormat(U.groupName(e,Sx),"+","[-]?")}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}const Ax="monthValue";class ef extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Ax),"{1,2}",void 0)}constructor(){super(Ax,ef.format())}}const Tx="dayValue";class tf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Tx),"{1,2}",void 0)}constructor(){super(Tx,tf.format())}}const Ix="hourValue";class sf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Ix),"{1,2}",void 0)}constructor(){super(Ix,sf.format())}}const _x="minuteValue";class nf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,_x),"{1,2}",void 0)}constructor(){super(_x,nf.format())}}const Dx="secondValue";class rf extends Zi{static format(e=""){return Zi.numberFormat(U.groupName(e,Dx),"{1,2}",void 0)}constructor(){super(Dx,rf.format())}}class af extends gu{}class os extends wc{static yearGroup="year";static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(e=os.format()){super("date",e)}static format(e=""){return U.group(U.groupName(e,os.yearGroup),Qp.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,os.monthGroup),ef.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,os.dayGroup),tf.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,os.hourGroup),sf.format(e)),":",U.group(U.groupName(e,os.minuteGroup),nf.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,os.secondGroup),rf.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,os.millisecondGroup),"\\d+"))),U.optionalGroup(U.groupName(e,os.timeshiftGroup),af.format(e)))))}parseGroups(e){const t=e[os.millisecondGroup],i=t?Tl.parseFraction(t):void 0,s=e[os.secondGroup],n=s?nl.fromString(s,new rf):void 0,r=e[os.minuteGroup];let a;r&&(a=sl.fromString(r,new nf),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[os.hourGroup];let c;o&&(c=il.fromString(o,new sf),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[os.dayGroup];let d;h&&(d=tl.fromString(h,new tf),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[os.monthGroup];let p;u&&(p=el.fromString(u,new ef),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[os.yearGroup];let m;f&&(m=Qc.fromString(f,void 0,new Qp),m.uncertain=m.uncertain||p?.uncertain||!1,m.approximate=m.approximate||p?.approximate||!1);const g=e[os.timeshiftGroup],v=g?xh.fromString(g,new af,{year:m?.value,month:p?.value,day:d?.value,hour:c?.value}):void 0;return{year:m,month:p,day:d,hour:c,minute:a,second:n,millisecond:i,timeshift:v}}}const kx="years",Rx="months",Cx="days",Ox="hours",Lx="minutes",Px="seconds";class th extends Zi{static format(e=""){return"P"+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,kx),"+",void 0,"\\d"),"Y")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Rx),"+",void 0,"\\d"),"MM")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Cx),"+",void 0,"\\d"),"D")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Ox),"+",void 0,"\\d"),"H")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Lx),"+",void 0,"\\d"),"M")+U.optionalNonCapturingGroup(U.numberGroup(U.groupName(e,Px),"+",void 0,"\\d"),"S")+this.formatSuffix(e)}constructor(){super("duration",th.format())}parseGroups(e){return{years:e[kx],months:e[Rx],days:e[Cx],hours:e[Ox],minutes:e[Lx],seconds:e[Px],uncertain:!!e[Zi.uncertainGroup],approximate:!!e[Zi.approximateGroup]}}}const O5="dates",Iv="start",_v="end",Nx="durations",Dv="durationMin",kv="durationMax";class _w extends wc{static format=U.group(O5,U.optionalGroup(Iv,U.group("openStart","\\.\\.")+"|"+os.format(Iv))+"/"+U.optionalGroup(_v,U.group("openEnd","\\.\\.")+"|"+os.format(_v)))+"|"+U.group(Nx,U.group(Dv,th.format(Dv))+"/"+U.group(kv,th.format(kv)));constructor(e="interval",t=_w.format){super(e,t)}parseGroups(e){let t,i;if(e[Nx]){const n=e[Dv];t=qs.fromString(n,new th);const r=e[kv];i=qs.fromString(r,new th)}else{const n=e[Iv];switch(n){case void 0:t=null;break;case"..":t=void 0;break;default:t=Pr.fromString(n,new os)}const r=e[_v];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=Pr.fromString(r,new os)}}return{start:t,end:i}}}Be.register(Pr,()=>new os);Be.register(tl,()=>new tf);Be.register(qs,()=>new th);Be.register(il,()=>new sf);Be.register(Xp,()=>new _w);Be.register(sl,()=>new nf);Be.register(el,()=>new ef);Be.register(nl,()=>new rf);Be.register(xh,()=>new af);Be.register(Qc,()=>new Qp);class oi extends Zi{static uncertainGroup="uncertain1";static approximateGroup="approx1";static uncertainAndApproximateGroup=oi.uncertainGroup+oi.approximateGroup;constructor(e,t){super(e,t)}static numberFormat(e,t,i){return this.qualifierFormat(U.groupName(oi.uncertainGroup,e),"?")+this.qualifierFormat(U.groupName(oi.approximateGroup,e),"~")+this.qualifierFormat(U.groupName(oi.uncertainAndApproximateGroup,e),"%")+Zi.numberFormat(e,t,i)}parseGroups(e){const t=super.parseGroups(e),i=e[U.groupName(oi.uncertainAndApproximateGroup,this.name)];return(e[U.groupName(oi.uncertainGroup,this.name)]||i)&&(t.uncertainComponent=!0),(e[U.groupName(oi.approximateGroup,this.name)]||i)&&(t.approximateComponent=!0),t}}const Cu="yearValue",Fx="exp",Ux="signif";class of extends oi{constructor(){super(Cu,of.format())}static format(e=""){return"Y?"+U.nonCapturingGroup(U.group(U.groupName(e,Fx),"[-]?\\d+E\\d+")+"|"+oi.numberFormat(U.groupName(e,Cu),"+","[-]?")+U.optionalGroup(U.groupName(e,Ux),"S\\d+"))}parseGroups(e){const t=e[Fx];if(t){const r=t.indexOf("E"),a=parseInt(t.substring(r+1),10),c=parseInt(t.substring(0,r),10)*Math.pow(10,a);e[Cu]=c.toString()}const i=e[Ux],s=e[Cu];if(i){const r=parseInt(i.substring(1),10),{valueStr:a,sign:o}=this.getValueAndSign(e);let c="";for(let h=0;h<a.length;h++)c+=h<r?a.charAt(h):"X";e[Cu]=(o<0?"-":"")+c}const n=super.parseGroups(e);return i&&(n.value.estimate=parseInt(s,10)),n}parse(e){const t=this.regexGroups(e);return this.parseGroups(t)}}const Bx="monthValue";class cf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Bx),"{1,2}",void 0)}constructor(){super(Bx,cf.format())}}const zx="dayValue";class lf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,zx),"{1,2}",void 0)}constructor(){super(zx,lf.format())}}const Hx="hourValue";class hf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Hx),"{1,2}",void 0)}constructor(){super(Hx,hf.format())}}const Gx="secondValue";class df extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Gx),"{1,2}",void 0)}constructor(){super(Gx,df.format())}}const Vx="minuteValue";class uf extends oi{static format(e=""){return oi.numberFormat(U.groupName(e,Vx),"{1,2}",void 0)}constructor(){super(Vx,uf.format())}}class L5 extends af{}class pi extends wc{static yearGroup=os.yearGroup;static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(){super("date",pi.format())}static format(e=""){return U.group(U.groupName(e,pi.yearGroup),of.format(e))+U.optionalNonCapturingGroup("-",U.group(U.groupName(e,pi.monthGroup),cf.format(e)),U.optionalNonCapturingGroup("-",U.group(U.groupName(e,pi.dayGroup),lf.format(e)),U.optionalNonCapturingGroup("[T ]",U.group(U.groupName(e,pi.hourGroup),hf.format(e)),":",U.group(U.groupName(e,pi.minuteGroup),uf.format(e)),U.optionalNonCapturingGroup(":",U.group(U.groupName(e,pi.secondGroup),df.format(e)),U.optionalNonCapturingGroup("[.,]",U.group(U.groupName(e,pi.millisecondGroup),"\\d+"))),U.optionalGroup(U.groupName(e,pi.timeshiftGroup),L5.format(e)))))}parseGroups(e){const t=e[pi.millisecondGroup],i=t?Tl.parseFraction(t):void 0,s=e[pi.secondGroup];let n;s&&(n=ac.fromString(s,void 0,new df),n.uncertain=n?.uncertain||!1,n.approximate=n?.approximate||!1);const r=e[pi.minuteGroup];let a;r&&(a=rc.fromString(r,new uf),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[pi.hourGroup];let c;o&&(c=nc.fromString(o,new hf),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[pi.dayGroup];let d;h&&(d=sc.fromString(h,new lf),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[pi.monthGroup];let p;u&&(p=ic.fromString(u,new cf),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[pi.yearGroup];let m;f&&(m=tc.fromString(f,void 0,new of),m.uncertain=m.uncertain||p?.uncertain||!1,m.approximate=m.approximate||p?.approximate||!1);const g=e[pi.timeshiftGroup],v=g?xT.fromString(g,new af,{year:m?.value,month:p?.value,day:d?.value,hour:c?.value}):void 0;return{year:m,month:p,day:d,hour:c,minute:a,second:n,millisecond:i,timeshift:v}}}const Wx="durationValue";class Dw extends oi{static format(e=""){return"^"+oi.numberFormat(U.groupName(e,Wx),"+",void 0)}constructor(){super(Wx,Dw.format())}}class P5 extends Ew{millisecond=new Pi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0);second=new Pi("second",0,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new Pi("minute",0,Number.MAX_SAFE_INTEGER,this.second);hour=new Pi("hour",0,Number.MAX_SAFE_INTEGER,this.minute);day=new Pi("day",1,Number.MAX_SAFE_INTEGER,this.hour);month=new Pi("month",1,Number.MAX_SAFE_INTEGER,this.day);year=new Pi("year",0,Number.MAX_SAFE_INTEGER,this.month)}const Lh=new P5;class ht extends oi{static yearsGroup="years";static monthsGroup="months";static isoMonthsGroup="isoMonths";static daysGroup="days";static hoursGroup="hours";static minutesGroup="minutes";static secondsGroup="seconds";static durationGroup="duration";static suffixGroup="durationSuffix";static componentParser=new Dw;static componentFormat(e,t,i,s,n=""){const r=U.group(U.groupName(e,ht.quantityGroup(t)),oi.numberFormat(U.groupName(e,i),"+",void 0,"\\d"));return U.group(U.groupName(e,t),r,s,n)}static quantityGroup(e){return e+"Quantity"}static isoMonthsLookahead="(?=[?~%]?\\d+D|T)";constructor(){super("duration",ht.format())}static format(e=""){const t=U.groupName(e,ht.durationGroup);return this.qualifierFormat(U.groupName(oi.uncertainGroup,t),"?")+this.qualifierFormat(U.groupName(oi.approximateGroup,t),"~")+this.qualifierFormat(U.groupName(oi.uncertainAndApproximateGroup,t),"%")+"P"+U.optional(ht.componentFormat(e,ht.yearsGroup,pi.yearGroup,"Y"))+U.optionalNonCapturingGroup(ht.componentFormat(e,ht.monthsGroup,pi.monthGroup,"MM")+"|"+ht.componentFormat(e,ht.isoMonthsGroup,"isoMonth","M",ht.isoMonthsLookahead))+U.optional(ht.componentFormat(e,ht.daysGroup,pi.dayGroup,"D"))+"T?"+U.optional(ht.componentFormat(e,ht.hoursGroup,pi.hourGroup,"H"))+U.optional(ht.componentFormat(e,ht.minutesGroup,pi.minuteGroup,"M"))+U.optional(ht.componentFormat(e,ht.secondsGroup,pi.secondGroup,"S"))+U.optionalGroup(U.groupName(e,ht.suffixGroup),"[?~%]")}static parseComponent(e,t,i){const s=ht.componentParser.parse(e);return new t(s,i)}parseGroups(e){const t=e[ht.quantityGroup(ht.secondsGroup)];let i;t&&(i=ht.parseComponent(t,ac,Lh.second),i.uncertain=!!e[U.groupName(oi.uncertainGroup,ht.secondsGroup)]||!1,i.approximate=!!e[U.groupName(oi.approximateGroup,ht.secondsGroup)]||!1);const s=e[ht.quantityGroup(ht.minutesGroup)];let n;s&&(n=ht.parseComponent(s,rc,Lh.minute),n.uncertain=n.uncertain||i?.uncertain||!1,n.approximate=n.approximate||i?.approximate||!1);const r=e[ht.quantityGroup(ht.hoursGroup)];let a;r&&(a=ht.parseComponent(r,nc,Lh.hour),a.uncertain=a.uncertain||n?.uncertain||!1,a.approximate=a.approximate||n?.approximate||!1);const o=e[ht.quantityGroup(ht.daysGroup)];let c;o&&(c=ht.parseComponent(o,sc,Lh.day),c.uncertain=c.uncertain||a?.uncertain||!1,c.approximate=c.approximate||a?.approximate||!1);const h=e[ht.quantityGroup(ht.monthsGroup)]||e[ht.quantityGroup(ht.isoMonthsGroup)];let d;h&&(d=ht.parseComponent(h,ic,Lh.month),d.uncertain=d.uncertain||c?.uncertain||!1,d.approximate=d.approximate||c?.approximate||!1);const u=e[ht.quantityGroup(ht.yearsGroup)];let p;u&&(p=ht.parseComponent(u,tc,Lh.year),p.uncertain=p.uncertain||d?.uncertain||!1,p.approximate=p.approximate||d?.approximate||!1);const f=e[ht.suffixGroup],m=!!e[U.groupName(oi.uncertainAndApproximateGroup,ht.durationGroup)]||f==="%",g=m||!!e[U.groupName(oi.uncertainGroup,ht.durationGroup)]||f==="?",v=m||!!e[U.groupName(oi.approximateGroup,ht.durationGroup)]||f==="~";return{years:p,months:d,days:c,hours:a,minutes:n,seconds:i,uncertain:g,approximate:v}}}const N5="dates",Rv="start",Cv="end",$x="durations",Ov="durationMin",Lv="durationMax";class Zg extends wc{static format=U.group(N5,U.optionalGroup(Rv,U.group("openStart","\\.\\.")+"|"+pi.format(Rv))+"/"+U.optionalGroup(Cv,U.group("openEnd","\\.\\.")+"|"+pi.format(Cv)))+"|"+U.group($x,U.group(Ov,ht.format(Ov))+"/"+U.group(Lv,ht.format(Lv)));constructor(e="interval",t=Zg.format){super(e,t)}parseGroups(e){let t,i;if(e[$x]){const n=e[Ov];t=Xs.fromString(n,new ht);const r=e[Lv];i=Xs.fromString(r,new ht)}else{const n=e[Rv];switch(n){case void 0:t=null;break;case"..":t=void 0;break;default:t=gr.fromString(n,new pi)}const r=e[Cv];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=gr.fromString(r,new pi)}}return{start:t,end:i}}}class F5{parse(e){e=e.trim();const t=e.startsWith("["),s=e.substring(1,e.length-1).split(","),n=[];for(const r of s){let a;r.includes("..")?a=Yp.fromString(r.replace("..","/"),new Zg):a=gr.fromString(r,new pi),n.push(a)}return{values:n,exclusive:t}}}Be.register(gr,()=>new pi);Be.register(sc,()=>new lf);Be.register(Xs,()=>new ht);Be.register(nc,()=>new hf);Be.register(Yp,()=>new Zg);Be.register(rc,()=>new uf);Be.register(ic,()=>new cf);Be.register(ac,()=>new df);Be.register(K0,()=>new F5);Be.register(tc,()=>new of);class Fs{constructor(e){this.preferences=e}read(e){var t,i;if(e===void 0)return;if(typeof e=="string")return e===""?void 0:e;for(const n of this.preferences){const r=(t=e[n])!==null&&t!==void 0?t:e[Fs.base(n)];if(r)return r}const s=new Set(this.preferences.map(n=>Fs.base(n)));for(const[n,r]of Object.entries(e))if(r&&s.has(Fs.base(n)))return r;return(i=Object.values(e).find(n=>n))!==null&&i!==void 0?i:void 0}write(e,t,i){var s,n;const r=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return r;const a={...e},o=(n=(s=Object.keys(a).find(c=>c===i))!==null&&s!==void 0?s:Object.keys(a).find(c=>Fs.base(c)===Fs.base(i)))!==null&&n!==void 0?n:i;return r===void 0?delete a[o]:a[o]=r,Object.keys(a).length===0?void 0:a}static base(e){return e.toLowerCase().split("-")[0]}}Fs.any=new Fs([]);var Kx;(function(l){l.abductee="abductee",l.actor="actor",l.artist="artist",l.anthropologist="anthropologist",l.archeologist="archeologist",l.astronaut="astronaut",l.astronomer="astronomer",l.astrologist="astrologist",l.astrophysicist="astrophysicist",l.banker="banker",l.barman="barman",l.biologist="biologist",l.biochemist="biochemist",l.biophysicist="biophysicist",l.bishop="bishop",l.businessman="businessman",l.botanist="botanist",l.cameraman="cameraman",l.chemist="chemist",l.contactee="contactee",l.cryptozoologist="cryptozoologist",l.dentist="dentist",l.director="director",l.diplomat="diplomat",l.diver="diver",l.electronics="electronics",l.engineer="engineer",l.ethnologist="ethnologist",l.exobiologist="exobiologist",l.farmer="farmer",l.firefighter="firefighter",l.flightAttendant="flightAttendant",l.geologist="geologist",l.geophysicist="geophysicist",l.geographer="geographer",l.historian="historian",l.houseWife="houseWife",l.hypnotherapist="hypnotherapist",l.illusionist="illusionist",l.journalist="journalist",l.judge="judge",l.lawyer="lawyer",l.leader="leader",l.librarian="librarian",l.logger="logger",l.mathematician="mathematician",l.mechanic="mechanic",l.meteorologist="meteorologist",l.military="military",l.musician="musician",l.neurologist="neurologist",l.neuroscientist="neuroscientist",l.neuropsychiatrist="neuropsychiatrist",l.nurse="nurse",l.oceanographer="oceanographer",l.painter="painter",l.parapsychologist="parapsychologist",l.philosopher="philosopher",l.photographer="photographer",l.physician="physician",l.physicist="physicist",l.pilot="pilot",l.politician="politician",l.policeman="policeman",l.priest="priest",l.producer="producer",l.prospector="prospector",l.psychologist="psychologist",l.psychiatrist="psychiatrist",l.radioastronomer="radioastronomer",l.radioamateur="radioamateur",l.salesman="salesman",l.sailor="sailor",l.sociologist="sociologist",l.softwareEngineer="softwareEngineer",l.stuntman="stuntman",l.taxiDriver="taxiDriver",l.teacher="teacher",l.telegrapher="telegrapher",l.truckDriver="truckDriver",l.ufologist="ufologist",l.ufoWitness="ufoWitness",l.ufoWitness2="ufoWitness2",l.worker="worker",l.writer="writer"})(Kx||(Kx={}));var Xx;(function(l){l.neutral="neutral",l.male="male",l.female="female"})(Xx||(Xx={}));class U5 extends Error{constructor(e,t){super(e),this.cause=t}}class kw extends U5{constructor(e=kw.defaultMessage,t){super(e,t)}}kw.defaultMessage="Assertion failed";var Yx;(function(l){l.country="country",l.region="region",l.department="department",l.city="city",l.company="company"})(Yx||(Yx={}));var qx;(function(l){l.at="at",l.au="au",l.ar="ar",l.be="be",l.br="br",l.ca="ca",l.ch="ch",l.cn="cn",l.cl="cl",l.co="co",l.cy="cy",l.de="de",l.dk="dk",l.do="do",l.dz="dz",l.gr="gr",l.ec="ec",l.eg="eg",l.es="es",l.fi="fi",l.fr="fr",l.ga="ga",l.ge="ge",l.hu="hu",l.in="in",l.ie="ie",l.ir="ir",l.il="il",l.it="it",l.jp="jp",l.kr="kr",l.ma="ma",l.mx="mx",l.my="my",l.mz="mz",l.nl="nl",l.no="no",l.nz="nz",l.pa="pa",l.pe="pe",l.ph="ph",l.pl="pl",l.pt="pt",l.ro="ro",l.ru="ru",l.sc="sc",l.tr="tr",l.ua="ua",l.uk="uk",l.us="us",l.sa="sa",l.se="se",l.su="su",l.tn="tn",l.tw="tw",l.ve="ve",l.za="za"})(qx||(qx={}));class B5{static of(e){if(!(!e||e.length===0))return e.some(t=>t.outcome==="fails"&&t.against!=="supposed")?"incompatible":e.some(t=>t.outcome!=="holds")?"unsettled":"compatible"}}/**
|
|
419
445
|
@preserve
|
|
420
446
|
|
|
421
447
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4611,7 +4637,7 @@ button.open { display: inline-flex; align-items: center; gap: 6px; cursor: point
|
|
|
4611
4637
|
.option input { margin: 2px 0 0; }
|
|
4612
4638
|
${Js.css(".menu")}
|
|
4613
4639
|
.menu:popover-open { position-area: bottom span-left; margin: .35em 0 0; }
|
|
4614
|
-
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Xl.TAG)||customElements.define(Xl.TAG,Xl)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Us.preferencesFor(this),this.language=Ha([...this.preferences],Ba),this.messages=await B_.load(this.language),this.draw()}draw(){const e=this.messages,t=document.createElement("style");t.textContent=Xl.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=e.hint,i.setAttribute("aria-label",e.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Xl.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:e.button}));const s=document.createElement("div");s.className="menu",s.setAttribute("role","menu"),Js.attach(i,s);const n=[["html",e.html,e.htmlHint],["print",e.print,e.printHint],["json",e.json,e.jsonHint],["csv",e.csv,e.csvHint]];s.append(...n.map(([o,c,h])=>{const d=document.createElement("button");return d.type="button",d.setAttribute("role","menuitem"),d.append(Object.assign(document.createElement("strong"),{textContent:c}),Object.assign(document.createElement("small"),{textContent:h})),d.addEventListener("click",()=>void this.export(o,s)),d}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:e.pictures}),Object.assign(document.createElement("small"),{textContent:e.picturesHint})),r.append(this.withPictures,a),s.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),s.append(this.status),i.addEventListener("click",()=>Js.show(s,s.hidden)),this.shadowRoot.replaceChildren(t,i,s)}async export(e,t){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:s},n]=await Promise.all([V(()=>import("./CaseReportExport-CKuvpQqy.js"),[],import.meta.url),this.source()]);await s.make(e,n,this.language,this.preferences,this.withPictures?.checked??!1,(r,a)=>{this.status.textContent=i.drawing.replace("{done}",String(r)).replace("{total}",String(a))}),this.status.hidden=!0,Js.show(t,!1)}catch{this.status.textContent=i.failed}}}}const kN=yi.catalog({en:()=>V(()=>import("./ReadingCheckTexts_en-eq6teExJ.js"),[],import.meta.url).then(l=>l.readingCheckTexts_en),fr:()=>V(()=>import("./ReadingCheckTexts_fr-pcDleIvY.js"),[],import.meta.url).then(l=>l.readingCheckTexts_fr),es:()=>V(()=>import("./ReadingCheckTexts_es-CR_JJZMV.js"),[],import.meta.url).then(l=>l.readingCheckTexts_es),it:()=>V(()=>import("./ReadingCheckTexts_it-MFKeoXnq.js"),[],import.meta.url).then(l=>l.readingCheckTexts_it)});class ur{constructor(e,t){this.json=e,this.url=t,this.tracks=(e.events??[]).filter(i=>i.eventType===ji.SIGHTING_EVENT&&typeof i.url=="string"&&i.url!=="").map(i=>({event:i,url:new URL(i.url,t).href,kind:i.interpretationOf===void 0?"observer":"reading"}))}tracks;caseChanged=!1;transcripts=new Map;static around(e,t,i,s,n){const r=(e.observer?.id??e.id??"observation").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"observation",a={id:e.id??"case",...t!==void 0?{time:t}:{},events:[{type:"event",eventType:ji.SIGHTING_EVENT,...t!==void 0?{time:t}:{},...i!==void 0?{title:i}:{},url:`observer-${r}.json`}]},o=new ur(a,new URL("case.json",n).href),c=o.tracks[0];return c.recording=e,c.base={url:s},c.event.id=o.proposedId(c),o.caseChanged=!0,o}accountOf(e){if(e.kind!=="reading")return;const t=[e.event.interpretationOf].flat(),i=this.tracks.filter(s=>s.kind==="observer");return i.find(s=>s.event.id!==void 0&&t.includes(s.event.id))??i.find(s=>s.recording?.id!==void 0&&t.includes(s.recording.id))}get interviews(){return(this.json.events??[]).filter(e=>e.eventType===ji.INTERVIEW_EVENT)}intervieweeOf(e){return this.intervieweesOf(e)[0]}intervieweesOf(e){const t=this.tracks.filter(i=>i.kind==="observer");return[e.interviewOf].flat().filter(i=>typeof i=="string").flatMap(i=>{const s=t.find(n=>n.event.id===i)??t.find(n=>n.recording?.id===i);return s?[s]:[]})}addInterview(e,t,i,s,n){const r=this.eventIds(),a=e?e.event.id??this.proposedId(e):"case";let o=1;for(;r.has(`interview-${a}-${o}`);)o++;const c={type:"event",eventType:ji.INTERVIEW_EVENT,id:`interview-${a}-${o}`,...e?{interviewOf:this.ensureId(e)}:{},time:t,...n!==void 0?{medium:n}:{},...s!==void 0&&s.length>0?{by:s}:{},...i!==void 0?{title:i}:{}};return this.json.events=[...this.json.events??[],c],this.caseChanged=!0,c}transcriptText(e){return this.transcripts.get(e)?.text}keepTranscript(e,t){this.transcripts.set(e,{text:t,loaded:this.transcripts.get(e)?.loaded})}transcriptChanged(e){return e.loaded!==e.text}deleteInterview(e){return this.interviews.includes(e)?(this.json.events=(this.json.events??[]).filter(t=>t!==e),this.transcripts.delete(e),this.caseChanged=!0,!0):!1}static sealed(e){return e.sealed===!0}seal(e,t){t?e.event.sealed=!0:delete e.event.sealed,this.caseChanged=!0}clone(e,t){if(!e.recording)return;const i=e.kind==="reading"?this.accountOf(e):void 0;if(e.kind==="reading"&&!i)return;const s=t??e.event.title;return this.addObservation(structuredClone(e.recording),e.event.time,s,i?{account:i,by:e.event.by}:void 0)}keep(e,t,i=!1){!i&&ur.sealed(e.event)||(t=En.recording(t),e.recording=t,i&&(e.loaded=JSON.stringify(t)),e.kind==="reading"&&t.interpretation?.title!==void 0&&(e.event.title=t.interpretation.title))}replaceJson(e){const i=(e.events??[]).filter(n=>n.eventType===ji.SIGHTING_EVENT&&typeof n.url=="string"&&n.url!=="").map(n=>{const r=new URL(n.url,this.url).href,a=n.interpretationOf===void 0?"observer":"reading",o=this.tracks.find(c=>c.url===r);return o?(o.event=n,o.kind=a,o):{event:n,url:r,kind:a}});this.tracks.splice(0,this.tracks.length,...i);const s=new Map;for(const[n,r]of this.transcripts){const a=(e.events??[]).find(o=>o.eventType===ji.INTERVIEW_EVENT&&(n.id!==void 0&&o.id===n.id||n.url!==void 0&&o.url===n.url));a&&s.set(a,r)}this.transcripts.clear();for(const[n,r]of s)this.transcripts.set(n,r);this.json=e,this.caseChanged=!0}touch(){this.caseChanged=!0}get dirty(){return this.caseChanged||this.tracks.some(e=>this.changed(e))||[...this.transcripts.values()].some(e=>this.transcriptChanged(e))}markExported(e){if(this.caseChanged=!1,!!e){for(const t of this.tracks)t.recording&&(t.loaded=JSON.stringify(t.recording));for(const t of this.transcripts.values())t.loaded=t.text}}changed(e){return e.recording!==void 0&&(e.loaded===void 0||JSON.stringify(e.recording)!==e.loaded)}static ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;eventIds(e){return new Set((this.json.events??[]).filter(t=>t!==e?.event).map(t=>t.id).filter(t=>t!==void 0))}proposedId(e){const t=a=>(a??"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),i=typeof e.event.title=="string"?e.event.title:void 0,s=t(e.recording?.observer?.lastName)||t(e.recording?.observer?.id)||t(i),n=this.eventIds(e);if(s!==""){let a=s;for(let o=2;n.has(a);o++)a=`${s}-${o}`;return a}let r=1;for(;n.has(`sighting-${r}`);)r++;return`sighting-${r}`}ensureId(e){return e.event.id===void 0&&(e.event.id=this.proposedId(e),this.caseChanged=!0),e.event.id}setId(e,t){const i=e.event.id,s=a=>a===i||a===e.recording?.id,n=(this.json.events??[]).filter(a=>a.eventType===ji.SIGHTING_EVENT&&a.interpretationOf!==void 0&&[a.interpretationOf].flat().some(o=>o!==void 0&&s(o))),r=this.interviews.filter(a=>[a.interviewOf].flat().some(o=>o!==void 0&&s(o)));if(t==="")return i===void 0?"ok":n.length>0||r.length>0?"empty":(delete e.event.id,this.caseChanged=!0,"ok");if(!ur.ID_PATTERN.test(t))return"invalid";if(this.eventIds(e).has(t))return"taken";if(t===i)return"ok";for(const a of n){const o=[a.interpretationOf].flat().map(c=>s(c)?t:c);a.interpretationOf=Array.isArray(a.interpretationOf)?o:o[0]}for(const a of r){const o=[a.interviewOf].flat().map(c=>c!==void 0&&s(c)?t:c);a.interviewOf=Array.isArray(a.interviewOf)?o:o[0]}return e.event.id=t,this.caseChanged=!0,"ok"}problems(){return ji.problems(this.json,this.tracks.map(e=>e.recording?.id).filter(e=>e!==void 0))}addReading(e,t,i,s){const n=e.recording;if(!n)throw new Error("A reading is added to an account that has been loaded");const r=e.event.url.replace(/^.*\//,"").replace(/^observer-/,"").replace(/\.json$/,""),a=new Set(this.tracks.map(T=>T.event.url)),o=new Set(this.tracks.map(T=>T.recording?.id));let c=this.tracks.filter(T=>T.kind==="reading").length+1;for(;a.has(`interpretation-${r}-${c}.json`)||o.has(`${n.id??r}-interpretation-${c}`);)c++;const h=`interpretation-${r}-${c}.json`,d=e.event.url.includes("/")?e.event.url.replace(/[^/]*$/,""):"",{id:u,version:p,observer:f,account:m,description:g,sources:v,tags:b,timeline:w,milestones:y,interpretation:M,...x}=structuredClone(n),S={version:4,id:`${n.id??r}-interpretation-${c}`,...x,tags:["interpretation"],timeline:{keyframes:[],order:[],groups:[]},interpretation:{...i!==void 0?{title:i}:{},bodies:[]}},E={type:"event",eventType:"sighting",interpretationOf:this.ensureId(e),time:t,...s!==void 0&&s.length>0?{by:s}:{},...i!==void 0?{title:i}:{},url:d+h};this.json.events=[...this.json.events??[],E],this.caseChanged=!0;const A={event:E,url:new URL(E.url,this.url).href,kind:"reading",recording:S};return this.tracks.push(A),A}idsOf(e){return[e.event.id,e.recording?.id].filter(t=>t!==void 0)}readingsOf(e){const t=this.idsOf(e);return this.tracks.filter(i=>i.kind==="reading"&&[i.event.interpretationOf].flat().some(s=>s!==void 0&&t.includes(s)))}addObservation(e,t,i,s){const n=new Set(this.tracks.map(m=>m.event.url)),r=new Set(this.tracks.map(m=>m.recording?.id)),a=(e.id??"observation").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"observation",o=s?"interpretation":"observer";let c=`${o}-${a}.json`,h=e.id??a;for(let m=2;n.has(c)||r.has(h);m++)c=`${o}-${a}-${m}.json`,h=`${e.id??a}-${m}`;const d={...e,id:h},u=this.tracks[0]?.event.url?.includes("/")?this.tracks[0].event.url.replace(/[^/]*$/,""):"",p={type:"event",eventType:"sighting",...s?{interpretationOf:this.ensureId(s.account)}:{},...t!==void 0?{time:t}:{},...s?.by&&s.by.length>0?{by:s.by}:{},...i!==void 0?{title:i}:{},url:u+c};this.json.events=[...this.json.events??[],p],this.caseChanged=!0;const f={event:p,url:new URL(p.url,this.url).href,kind:s?"reading":"observer",recording:d};return this.tracks.push(f),s||(p.id=this.proposedId(f)),f}deleteObservation(e){if(e.kind!=="observer")return{deleted:!1,readings:0};if(ur.sealed(e.event))return{deleted:!1,readings:0};const t=this.readingsOf(e).length;if(t>0)return{deleted:!1,readings:t};const i=this.tracks.indexOf(e);return i<0?{deleted:!1,readings:0}:(this.tracks.splice(i,1),this.json.events=(this.json.events??[]).filter(s=>s!==e.event),this.caseChanged=!0,{deleted:!0})}deleteReading(e){if(e.kind!=="reading"||ur.sealed(e.event))return!1;const t=this.tracks.indexOf(e);return t<0?!1:(this.tracks.splice(t,1),this.json.events=(this.json.events??[]).filter(i=>i!==e.event),this.caseChanged=!0,!0)}files(e=!0,t=!1){const i=this.url.replace(/[^/]*$/,""),s=o=>o.startsWith(i)?o.slice(i.length):o,n=this.tracks.filter(o=>e&&o.recording!==void 0&&(t||this.changed(o))).map(o=>({path:s(o.url),content:JSON.stringify(o.recording,null,2)+`
|
|
4640
|
+
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Xl.TAG)||customElements.define(Xl.TAG,Xl)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Us.preferencesFor(this),this.language=Ha([...this.preferences],Ba),this.messages=await B_.load(this.language),this.draw()}draw(){const e=this.messages,t=document.createElement("style");t.textContent=Xl.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=e.hint,i.setAttribute("aria-label",e.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Xl.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:e.button}));const s=document.createElement("div");s.className="menu",s.setAttribute("role","menu"),Js.attach(i,s);const n=[["html",e.html,e.htmlHint],["print",e.print,e.printHint],["json",e.json,e.jsonHint],["csv",e.csv,e.csvHint]];s.append(...n.map(([o,c,h])=>{const d=document.createElement("button");return d.type="button",d.setAttribute("role","menuitem"),d.append(Object.assign(document.createElement("strong"),{textContent:c}),Object.assign(document.createElement("small"),{textContent:h})),d.addEventListener("click",()=>void this.export(o,s)),d}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:e.pictures}),Object.assign(document.createElement("small"),{textContent:e.picturesHint})),r.append(this.withPictures,a),s.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),s.append(this.status),i.addEventListener("click",()=>Js.show(s,s.hidden)),this.shadowRoot.replaceChildren(t,i,s)}async export(e,t){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:s},n]=await Promise.all([V(()=>import("./CaseReportExport-ByPXoIiq.js"),[],import.meta.url),this.source()]);await s.make(e,n,this.language,this.preferences,this.withPictures?.checked??!1,(r,a)=>{this.status.textContent=i.drawing.replace("{done}",String(r)).replace("{total}",String(a))}),this.status.hidden=!0,Js.show(t,!1)}catch{this.status.textContent=i.failed}}}}const kN=yi.catalog({en:()=>V(()=>import("./ReadingCheckTexts_en-eq6teExJ.js"),[],import.meta.url).then(l=>l.readingCheckTexts_en),fr:()=>V(()=>import("./ReadingCheckTexts_fr-pcDleIvY.js"),[],import.meta.url).then(l=>l.readingCheckTexts_fr),es:()=>V(()=>import("./ReadingCheckTexts_es-CR_JJZMV.js"),[],import.meta.url).then(l=>l.readingCheckTexts_es),it:()=>V(()=>import("./ReadingCheckTexts_it-MFKeoXnq.js"),[],import.meta.url).then(l=>l.readingCheckTexts_it)});class ur{constructor(e,t){this.json=e,this.url=t,this.tracks=(e.events??[]).filter(i=>i.eventType===ji.SIGHTING_EVENT&&typeof i.url=="string"&&i.url!=="").map(i=>({event:i,url:new URL(i.url,t).href,kind:i.interpretationOf===void 0?"observer":"reading"}))}tracks;caseChanged=!1;transcripts=new Map;static around(e,t,i,s,n){const r=(e.observer?.id??e.id??"observation").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"observation",a={id:e.id??"case",...t!==void 0?{time:t}:{},events:[{type:"event",eventType:ji.SIGHTING_EVENT,...t!==void 0?{time:t}:{},...i!==void 0?{title:i}:{},url:`observer-${r}.json`}]},o=new ur(a,new URL("case.json",n).href),c=o.tracks[0];return c.recording=e,c.base={url:s},c.event.id=o.proposedId(c),o.caseChanged=!0,o}accountOf(e){if(e.kind!=="reading")return;const t=[e.event.interpretationOf].flat(),i=this.tracks.filter(s=>s.kind==="observer");return i.find(s=>s.event.id!==void 0&&t.includes(s.event.id))??i.find(s=>s.recording?.id!==void 0&&t.includes(s.recording.id))}get interviews(){return(this.json.events??[]).filter(e=>e.eventType===ji.INTERVIEW_EVENT)}intervieweeOf(e){return this.intervieweesOf(e)[0]}intervieweesOf(e){const t=this.tracks.filter(i=>i.kind==="observer");return[e.interviewOf].flat().filter(i=>typeof i=="string").flatMap(i=>{const s=t.find(n=>n.event.id===i)??t.find(n=>n.recording?.id===i);return s?[s]:[]})}addInterview(e,t,i,s,n){const r=this.eventIds(),a=e?e.event.id??this.proposedId(e):"case";let o=1;for(;r.has(`interview-${a}-${o}`);)o++;const c={type:"event",eventType:ji.INTERVIEW_EVENT,id:`interview-${a}-${o}`,...e?{interviewOf:this.ensureId(e)}:{},time:t,...n!==void 0?{medium:n}:{},...s!==void 0&&s.length>0?{by:s}:{},...i!==void 0?{title:i}:{}};return this.json.events=[...this.json.events??[],c],this.caseChanged=!0,c}transcriptText(e){return this.transcripts.get(e)?.text}keepTranscript(e,t){this.transcripts.set(e,{text:t,loaded:this.transcripts.get(e)?.loaded})}transcriptChanged(e){return e.loaded!==e.text}deleteInterview(e){return this.interviews.includes(e)?(this.json.events=(this.json.events??[]).filter(t=>t!==e),this.transcripts.delete(e),this.caseChanged=!0,!0):!1}static sealed(e){return e.sealed===!0}seal(e,t){t?e.event.sealed=!0:delete e.event.sealed,this.caseChanged=!0}clone(e,t){if(!e.recording)return;const i=e.kind==="reading"?this.accountOf(e):void 0;if(e.kind==="reading"&&!i)return;const s=t??e.event.title;return this.addObservation(structuredClone(e.recording),e.event.time,s,i?{account:i,by:e.event.by}:void 0)}keep(e,t,i=!1){!i&&ur.sealed(e.event)||(t=En.recording(t),e.recording=t,i&&(e.loaded=JSON.stringify(t)),e.kind==="reading"&&t.interpretation?.title!==void 0&&(e.event.title=t.interpretation.title))}replaceJson(e){const i=(e.events??[]).filter(n=>n.eventType===ji.SIGHTING_EVENT&&typeof n.url=="string"&&n.url!=="").map(n=>{const r=new URL(n.url,this.url).href,a=n.interpretationOf===void 0?"observer":"reading",o=this.tracks.find(c=>c.url===r);return o?(o.event=n,o.kind=a,o):{event:n,url:r,kind:a}});this.tracks.splice(0,this.tracks.length,...i);const s=new Map;for(const[n,r]of this.transcripts){const a=(e.events??[]).find(o=>o.eventType===ji.INTERVIEW_EVENT&&(n.id!==void 0&&o.id===n.id||n.url!==void 0&&o.url===n.url));a&&s.set(a,r)}this.transcripts.clear();for(const[n,r]of s)this.transcripts.set(n,r);this.json=e,this.caseChanged=!0}touch(){this.caseChanged=!0}get dirty(){return this.caseChanged||this.tracks.some(e=>this.changed(e))||[...this.transcripts.values()].some(e=>this.transcriptChanged(e))}markExported(e){if(this.caseChanged=!1,!!e){for(const t of this.tracks)t.recording&&(t.loaded=JSON.stringify(t.recording));for(const t of this.transcripts.values())t.loaded=t.text}}changed(e){return e.recording!==void 0&&(e.loaded===void 0||JSON.stringify(e.recording)!==e.loaded)}static ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;eventIds(e){return new Set((this.json.events??[]).filter(t=>t!==e?.event).map(t=>t.id).filter(t=>t!==void 0))}proposedId(e){const t=a=>(a??"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),i=typeof e.event.title=="string"?e.event.title:void 0,s=t(e.recording?.observer?.lastName)||t(e.recording?.observer?.id)||t(i),n=this.eventIds(e);if(s!==""){let a=s;for(let o=2;n.has(a);o++)a=`${s}-${o}`;return a}let r=1;for(;n.has(`sighting-${r}`);)r++;return`sighting-${r}`}ensureId(e){return e.event.id===void 0&&(e.event.id=this.proposedId(e),this.caseChanged=!0),e.event.id}setId(e,t){const i=e.event.id,s=a=>a===i||a===e.recording?.id,n=(this.json.events??[]).filter(a=>a.eventType===ji.SIGHTING_EVENT&&a.interpretationOf!==void 0&&[a.interpretationOf].flat().some(o=>o!==void 0&&s(o))),r=this.interviews.filter(a=>[a.interviewOf].flat().some(o=>o!==void 0&&s(o)));if(t==="")return i===void 0?"ok":n.length>0||r.length>0?"empty":(delete e.event.id,this.caseChanged=!0,"ok");if(!ur.ID_PATTERN.test(t))return"invalid";if(this.eventIds(e).has(t))return"taken";if(t===i)return"ok";for(const a of n){const o=[a.interpretationOf].flat().map(c=>s(c)?t:c);a.interpretationOf=Array.isArray(a.interpretationOf)?o:o[0]}for(const a of r){const o=[a.interviewOf].flat().map(c=>c!==void 0&&s(c)?t:c);a.interviewOf=Array.isArray(a.interviewOf)?o:o[0]}return e.event.id=t,this.caseChanged=!0,"ok"}problems(){return ji.problems(this.json,this.tracks.map(e=>e.recording?.id).filter(e=>e!==void 0))}addReading(e,t,i,s){const n=e.recording;if(!n)throw new Error("A reading is added to an account that has been loaded");const r=e.event.url.replace(/^.*\//,"").replace(/^observer-/,"").replace(/\.json$/,""),a=new Set(this.tracks.map(T=>T.event.url)),o=new Set(this.tracks.map(T=>T.recording?.id));let c=this.tracks.filter(T=>T.kind==="reading").length+1;for(;a.has(`interpretation-${r}-${c}.json`)||o.has(`${n.id??r}-interpretation-${c}`);)c++;const h=`interpretation-${r}-${c}.json`,d=e.event.url.includes("/")?e.event.url.replace(/[^/]*$/,""):"",{id:u,version:p,observer:f,account:m,description:g,sources:v,tags:b,timeline:w,milestones:y,interpretation:M,...x}=structuredClone(n),S={version:4,id:`${n.id??r}-interpretation-${c}`,...x,tags:["interpretation"],timeline:{keyframes:[],order:[],groups:[]},interpretation:{...i!==void 0?{title:i}:{},bodies:[]}},E={type:"event",eventType:"sighting",interpretationOf:this.ensureId(e),time:t,...s!==void 0&&s.length>0?{by:s}:{},...i!==void 0?{title:i}:{},url:d+h};this.json.events=[...this.json.events??[],E],this.caseChanged=!0;const A={event:E,url:new URL(E.url,this.url).href,kind:"reading",recording:S};return this.tracks.push(A),A}idsOf(e){return[e.event.id,e.recording?.id].filter(t=>t!==void 0)}readingsOf(e){const t=this.idsOf(e);return this.tracks.filter(i=>i.kind==="reading"&&[i.event.interpretationOf].flat().some(s=>s!==void 0&&t.includes(s)))}addObservation(e,t,i,s){const n=new Set(this.tracks.map(m=>m.event.url)),r=new Set(this.tracks.map(m=>m.recording?.id)),a=(e.id??"observation").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"observation",o=s?"interpretation":"observer";let c=`${o}-${a}.json`,h=e.id??a;for(let m=2;n.has(c)||r.has(h);m++)c=`${o}-${a}-${m}.json`,h=`${e.id??a}-${m}`;const d={...e,id:h},u=this.tracks[0]?.event.url?.includes("/")?this.tracks[0].event.url.replace(/[^/]*$/,""):"",p={type:"event",eventType:"sighting",...s?{interpretationOf:this.ensureId(s.account)}:{},...t!==void 0?{time:t}:{},...s?.by&&s.by.length>0?{by:s.by}:{},...i!==void 0?{title:i}:{},url:u+c};this.json.events=[...this.json.events??[],p],this.caseChanged=!0;const f={event:p,url:new URL(p.url,this.url).href,kind:s?"reading":"observer",recording:d};return this.tracks.push(f),s||(p.id=this.proposedId(f)),f}deleteObservation(e){if(e.kind!=="observer")return{deleted:!1,readings:0};if(ur.sealed(e.event))return{deleted:!1,readings:0};const t=this.readingsOf(e).length;if(t>0)return{deleted:!1,readings:t};const i=this.tracks.indexOf(e);return i<0?{deleted:!1,readings:0}:(this.tracks.splice(i,1),this.json.events=(this.json.events??[]).filter(s=>s!==e.event),this.caseChanged=!0,{deleted:!0})}deleteReading(e){if(e.kind!=="reading"||ur.sealed(e.event))return!1;const t=this.tracks.indexOf(e);return t<0?!1:(this.tracks.splice(t,1),this.json.events=(this.json.events??[]).filter(i=>i!==e.event),this.caseChanged=!0,!0)}files(e=!0,t=!1){const i=this.url.replace(/[^/]*$/,""),s=o=>o.startsWith(i)?o.slice(i.length):o,n=this.tracks.filter(o=>e&&o.recording!==void 0&&(t||this.changed(o))).map(o=>({path:s(o.url),content:JSON.stringify(o.recording,null,2)+`
|
|
4615
4641
|
`})),r=decodeURIComponent(this.url.replace(/[?#].*$/,"").replace(/^.*\//,""))||"case.json",a=[...this.transcripts].filter(([o,c])=>e&&o.url!==void 0&&(t||this.transcriptChanged(c))).map(([o,c])=>({path:s(new URL(o.url,this.url).href),content:c.text}));return[{path:r,content:JSON.stringify(this.json,null,2)+`
|
|
4616
4642
|
`},...n,...a]}}class Cf{constructor(e,t,i,s){this.button=e,this.onPick=i,this.idOf=s;const n=this.panel=e.ownerDocument.createElement("div");n.id=t,n.className="add-menu",n.setAttribute("popover",""),n.setAttribute("role","menu");const r=`--add-menu-${t}`;e.style.setProperty("anchor-name",r),n.style.setProperty("position-anchor",r),e.setAttribute("popovertarget",t),e.setAttribute("aria-haspopup","menu"),e.after(n)}static CSS=`
|
|
4617
4643
|
.add-menu { padding: .3em 0; border: 1px solid color-mix(in srgb, CanvasText 30%, transparent); border-radius: 4px; background: Canvas; color: CanvasText;
|
|
@@ -8881,9 +8907,9 @@ canvas[data-cursor="rotate"] {
|
|
|
8881
8907
|
`;class vh{constructor(e){this.points=e}static STATIONARY_M=5;static of(e){const t=[];for(const i of e.observerTrack.allKeyframes){const{lat:s,lng:n,headingDeg:r}=i.pose;s===void 0||n===void 0||t.push({t:i.t,lat:s,lng:n,headingDeg:r})}if(t.length===0){const i=e.event.place?.[0];if(!i)return;t.push({t:0,lat:i.lat,lng:i.lng})}return new vh(t)}static TRAVEL_M=50;get travels(){return this.spanM>vh.TRAVEL_M}get moved(){return this.spanM>vh.STATIONARY_M}get spanM(){const e=this.box,t=(e.south+e.north)/2,i=(e.west+e.east)/2;return Math.max(Math.abs(lt(t,e.east,t,e.west).x),Math.abs(lt(e.north,i,e.south,i).z))}get center(){const e=this.box;return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}boundsAround(e,t){const{lat:i,lng:s}=this.center,n=Math.max(this.spanM*(1+t),e)/2;return{north:br(0,-n,i,s).lat,south:br(0,n,i,s).lat,east:br(n,0,i,s).lng,west:br(-n,0,i,s).lng}}get box(){const e=this.points.map(i=>i.lat),t=this.points.map(i=>i.lng);return{south:Math.min(...e),north:Math.max(...e),west:Math.min(...t),east:Math.max(...t)}}}class ca{constructor(e,t){this.rotationPassed=e,this.scale=t}static SWAY_M=.012;static BREATH_M=.003;static DRIFT_YAW_DEG=.5;static DRIFT_PITCH_DEG=.4;static DRIFT_ROLL_DEG=.3;static GAZE_DRIFT_SHARE=.35;static HAND_HELD_S=.5;static HZ=[.11,.23,.17,.29,.37,.07];static of(e){if(e.instrument.mounted)return;const t=e.event.tags?.includes("paralysis")||(e.exposure??0)>ca.HAND_HELD_S,i=e.sway??(t?0:1);if(i>0)return new ca(Math.max(1-(e.instrument.stabilization??0),ca.GAZE_DRIFT_SHARE),i)}offsetAt(e){const t=e/1e3,i=this.scale,s=(d,u)=>Math.sin(2*Math.PI*d*t+u),[n,r,a,o,c,h]=ca.HZ;return{eastM:i*ca.SWAY_M*(.7*s(n,.3)+.3*s(o,1.9)),northM:i*ca.SWAY_M*(.6*s(a,2.2)+.4*s(c,.8)),upM:i*ca.BREATH_M*s(r,0),yawDeg:i*this.rotationPassed*ca.DRIFT_YAW_DEG*(.6*s(h,1.1)+.4*s(o,2.7)),pitchDeg:i*this.rotationPassed*ca.DRIFT_PITCH_DEG*(.5*s(r,1.6)+.5*s(a,.4)),rollDeg:i*this.rotationPassed*ca.DRIFT_ROLL_DEG*s(n,2.9)}}}class Ti{constructor(e,t){this.stretches=e,this.rotationPassed=t}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STOP_LURCH_M=.035;static STOP_PITCH_DEG=3;static START_LURCH_M=.015;static START_PITCH_DEG=1.2;static JOLT_HZ=1.4;static JOLT_DECAY_S=.35;static JOLT_LASTS_MS=1500;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(e){const t=vh.of(e);if(!t||t.points.length<2)return;const i=[];let s=0;for(let n=1;n<t.points.length;n++){const r=t.points[n-1],a=t.points[n],o=(a.t-r.t)/1e3;if(o<=0)continue;const c=lt(a.lat,a.lng,r.lat,r.lng),h=c.x,d=-c.z,u=Math.hypot(h,d),p=u/o,f=Ti.stepHzFor(p);i.push({startMs:r.t,endMs:a.t,speedMPerS:p,eastUnit:u>0?h/u:0,northUnit:u>0?d/u:0,stepHz:f,stepsBefore:s,rampsIn:!0,rampsOut:!0}),s+=f*o}for(let n=0;n<i.length;n++){const r=i[n-1],a=i[n+1];i[n].rampsIn=r===void 0||r.stepHz===0,i[n].rampsOut=a===void 0||a.stepHz===0}if(i.some(n=>n.stepHz>0))return new Ti(i,1-(e.instrument.stabilization??0))}static bodyAt(e,t,i=!1){const s=Ti.of(e)?.offsetAt(t)??Ti.STILL;return i?s:Ti.add(s,ca.of(e)?.offsetAt(t))}static stepHzFor(e){return e<Ti.SLOWEST_WALK_M_PER_S||e>Ti.FASTEST_WALK_M_PER_S?0:Ti.REFERENCE_STEP_HZ*Math.pow(e/Ti.REFERENCE_SPEED_M_PER_S,Ti.CADENCE_EXPONENT)}offsetAt(e){return Ti.add(this.cycleAt(e),this.joltAt(e))}joltAt(e){for(const t of this.stretches){if(t.stepHz===0)continue;const i=t.speedMPerS/Ti.REFERENCE_SPEED_M_PER_S,s=(a,o,c,h)=>{if(a<0||a>Ti.JOLT_LASTS_MS)return;const d=a/1e3,u=Math.exp(-d/Ti.JOLT_DECAY_S)*Math.sin(2*Math.PI*Ti.JOLT_HZ*d),p=h*o*i*u;return{eastM:p*t.eastUnit,northM:p*t.northUnit,upM:-Math.abs(p)*.3,rollDeg:0,pitchDeg:-h*c*i*u*this.rotationPassed,yawDeg:0}},n=t.rampsOut?s(e-t.endMs,Ti.STOP_LURCH_M,Ti.STOP_PITCH_DEG,1):void 0;if(n)return n;const r=t.rampsIn?s(e-t.startMs,Ti.START_LURCH_M,Ti.START_PITCH_DEG,-1):void 0;if(r)return r}}static add(e,t){return t?{eastM:e.eastM+t.eastM,northM:e.northM+t.northM,upM:e.upM+t.upM,rollDeg:e.rollDeg+t.rollDeg,pitchDeg:e.pitchDeg+t.pitchDeg,yawDeg:e.yawDeg+t.yawDeg}:e}cycleAt(e){const t=this.stretches.find(o=>e>=o.startMs&&e<=o.endMs);if(!t||t.stepHz===0)return Ti.STILL;const i=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,s=2*Math.PI*i,n=this.amplitudeAt(t,e),r=Ti.SWAY_M*n*Math.cos(s/2),a=n*this.rotationPassed*t.speedMPerS/Ti.REFERENCE_SPEED_M_PER_S;return{eastM:r*t.northUnit,northM:-r*t.eastUnit,upM:Ti.RISE_M_PER_M_PER_S*t.speedMPerS*n*Math.cos(s),rollDeg:Ti.HEAD_ROLL_DEG*a*Math.cos(s/2),pitchDeg:-1.25*a*Math.cos(s),yawDeg:Ti.HEAD_YAW_DEG*a*Math.cos(s/2)}}amplitudeAt(e,t){const i=1e3/e.stepHz,s=Math.min(i,(e.endMs-e.startMs)/2);if(s<=0)return 1;const n=t-e.startMs,r=e.endMs-t,a=Math.min(e.rampsIn?n/s:1,e.rampsOut?r/s:1,1);return(1-Math.cos(Math.PI*Math.max(a,0)))/2}}class f8{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const i of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(e,i);s&&t.set(i,s)}this.onFrame(e,t)}}class ta{static sessionDeclared=!1;static isLive(e){return e!==void 0&&typeof AudioContext<"u"&&e instanceof AudioContext}static unlock(e){if(ta.declarePlayback(),e.state!=="running")try{Promise.resolve(e.resume()).catch(()=>{});const t=e.createBufferSource();t.buffer=e.createBuffer(1,1,22050),t.connect(e.destination),t.start(0)}catch{}}static declarePlayback(){if(!(ta.sessionDeclared||typeof navigator>"u")){ta.sessionDeclared=!0;try{const e=navigator.audioSession;e&&(e.type="playback")}catch{}}}}const a2=.05,o2=.08,c2=2,l2=3,m8=14,g8=.02;class h2{context;constructor(e){this.context=e}voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;level=1;master;output(e){return this.master||(this.master=e.createGain(),this.master.gain.value=this.level,this.master.connect(e.destination)),this.master}setLevel(e){this.level=e,this.master&&(this.master.gain.value=e)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}ta.isLive(this.context)&&ta.unlock(this.context)}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const i=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,i):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),ta.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const i=this.context;if(!e||!i)return;const s=i.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,s,a2);for(const{param:n,ratio:r}of e.pitch)n.setTargetAtTime(Math.min(t.pitchHz*r,i.sampleRate/2-1),s,a2)}buildSynthesizedVoice(e,t){const i=this.context;if(i)switch(e.kind){case"hum":return this.buildHum(i,t);case"whistle":return this.buildWhistle(i,t);case"rumble":return this.buildRumble(i,t);case"crackle":return this.buildCrackle(i,t);default:return}}buildHum(e,t){const i=e.createOscillator();i.type="sawtooth";const s=e.createOscillator();s.type="sawtooth";const n=e.createBiquadFilter();n.type="lowpass",n.Q.value=1;const r=e.createGain();return r.gain.value=0,i.connect(n),s.connect(n),n.connect(r).connect(this.output(e)),i.start(),s.start(),{key:t,nodes:[n,r],sources:[i,s],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:s.frequency,ratio:1.006},{param:n.frequency,ratio:6}]}}buildWhistle(e,t){const i=e.createOscillator();i.type="sine";const s=e.createOscillator();s.type="sine",s.frequency.value=5;const n=e.createGain(),r=e.createGain();return r.gain.value=0,s.connect(n).connect(i.frequency),i.connect(r).connect(this.output(e)),i.start(),s.start(),{key:t,nodes:[n,r],sources:[i,s],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:n.gain,ratio:.012}]}}buildRumble(e,t){const i=e.createBufferSource();i.buffer=this.brownNoise(e),i.loop=!0;const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const n=e.createGain();return n.gain.value=0,i.connect(s).connect(n).connect(this.output(e)),i.start(),{key:t,nodes:[s,n],sources:[i],volumeParam:n.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(e,t){const i=e.createBufferSource();i.buffer=this.whiteNoise(e),i.loop=!0;const s=e.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const n=e.createGain();n.gain.value=0;const r=e.createBufferSource();r.buffer=this.crackleEnvelope(e),r.loop=!0;const a=e.createGain();return a.gain.value=0,r.connect(a).connect(n.gain),i.connect(s).connect(n).connect(this.output(e)),i.start(),r.start(),{key:t,nodes:[s,n,a],sources:[i,r],volumeParam:a.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(e,t,i){const s=this.context;if(!s)return;let n;try{n=await this.getBuffer(e)}catch(o){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",o);return}if(i!==this.voiceToken||!this.context)return;const r=s.createBufferSource();r.buffer=n,r.loop=!0;const a=s.createGain();a.gain.value=0,r.connect(a).connect(this.output(s)),r.start(),this.voice={key:t,nodes:[a],sources:[r],volumeParam:a.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,i)),i}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*c2),e.sampleRate),i=t.getChannelData(0);for(let s=0;s<i.length;s++)i[s]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*c2),e.sampleRate),i=t.getChannelData(0);let s=0,n=0;for(let r=0;r<i.length;r++)s=(s+.02*(Math.random()*2-1))/1.02,i[r]=s,n=Math.max(n,Math.abs(s));if(n>0)for(let r=0;r<i.length;r++)i[r]/=n;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*l2),e.sampleRate),i=t.getChannelData(0),s=Math.max(1,Math.floor(g8*e.sampleRate)),n=Math.round(l2*m8);for(let r=0;r<n;r++){const a=Math.floor(Math.random()*i.length),o=.4+Math.random()*.6;for(let c=0;c<s&&a+c<i.length;c++)i[a+c]=Math.max(i[a+c],o*(1-c/s))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const i=t.currentTime;e.volumeParam.cancelScheduledValues(i),e.volumeParam.setTargetAtTime(0,i,o2/3);const s=i+o2;for(const n of e.sources){n.onended=()=>{n.disconnect();for(const r of e.nodes)r.disconnect()};try{n.stop(s)}catch{n.disconnect();for(const r of e.nodes)r.disconnect()}}}}class Lf{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(e,t=Lf.EN){return t[e.kind].replace("{path}",e.path).replace("{expected}",e.expected??"").replace("{found}",e.found??"")}static warn(e,t){if(e.length===0)return;const i=e.map(s=>` ${Lf.text(s)}`);console.warn(`UFO@home: ${e.length} problem(s) in ${t??"this recording"}:
|
|
8882
8908
|
${i.join(`
|
|
8883
8909
|
`)}`)}}class la{constructor(e){this.format=e}issues(e){const t=[];return this.object(e,this.format,"",t),t}object(e,t,i,s){if(!la.isObject(e)){s.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:la.typeOf(e)});return}for(const[n,r]of Object.entries(e)){const a=i?`${i}.${n}`:n,o=t[n];o?this.field(r,o,a,s):s.push({kind:"unknown-key",path:a})}}field(e,t,i,s){if(la.isStated(e)){this.field(e.value,t,i,s);return}if(!(t.loose||e===void 0||e===null))switch(t.type){case"enum":(typeof e!="string"||!t.values?.includes(e))&&s.push({kind:"not-in-list",path:i,expected:(t.values??[]).map(n=>`"${n}"`).join(", "),found:JSON.stringify(e)});return;case"object":t.fields?this.object(e,t.fields,i,s):la.isObject(e)||s.push({kind:"wrong-type",path:i,expected:"object",found:la.typeOf(e)});return;case"array":Array.isArray(e)?t.fields&&e.forEach((n,r)=>{const a=la.isStated(n)?n.value:n;this.object(a,t.fields,`${i}.${r}`,s)}):s.push({kind:"wrong-type",path:i,expected:"array",found:la.typeOf(e)});return;default:typeof e!==t.type?s.push({kind:"wrong-type",path:i,expected:t.type,found:la.typeOf(e)}):typeof e=="number"&&(t.minimum!==void 0&&e<t.minimum||t.maximum!==void 0&&e>t.maximum)&&s.push({kind:"out-of-range",path:i,expected:`${t.minimum??"−∞"}–${t.maximum??"∞"}`,found:String(e)})}}static STATED_KEYS=new Set(["value","basis","rationale","how","range","source"]);static isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}static isStated(e){return la.isObject(e)&&"value"in e&&Object.keys(e).every(t=>la.STATED_KEYS.has(t))}static typeOf(e){return Array.isArray(e)?"array":e===null?"null":typeof e}}class $n{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(e,t){const i=Number.isFinite(t)?Math.max(0,t):0,s=Math.max(0,e-i*1e3),n=Math.max(0,e-s);return{fromMs:s,toMs:e,ms:n,seconds:n/1e3}}static instants(e,t,i,s,n){if(!(s>0))return 1;const r=n>0?$n.travelDegOver(e,t,i,i+s*1e3)/n/$n.PIXELS_PER_INSTANT:0,a=$n.flashesOver(e,s)*$n.INSTANTS_PER_FLASH,o=Math.ceil(Math.max(r,a));return o<2?1:Math.min($n.MAX_INSTANTS,o)}static travelDegOver(e,t,i,s){let n=0;for(const r of e){if(!r.track||r.track.length<2)continue;const a=$n.directionAt(r,t,i),o=$n.directionAt(r,t,s),c=Math.min(1,Math.max(-1,a.x*o.x+a.y*o.y+a.z*o.z));n=Math.max(n,Math.acos(c)*180/Math.PI)}return n}static flashesOver(e,t){let i=0;for(const s of e)for(const n of s.lights??[])n.pattern.kind==="flash"&&(i=Math.max(i,n.pattern.perMinute));return i/60*t}static directionAt(e,t,i){const s=Qr(e,i),n=s.eastM,r=s.altitudeM-t,a=s.northM,o=Math.hypot(n,r,a);return o===0?{x:0,y:1,z:0}:{x:n/o,y:r/o,z:a/o}}static bodyInstants(e,t,i,s,n){if(!(s>i)||!(n>0))return 1;let r=0;for(const o of e){const c=$n.bodyAt(o,i),h=$n.bodyAt(o,s);if(!c||!h)continue;const d={x:c.eastM,y:c.upM-t,z:c.northM},u={x:h.eastM,y:h.upM-t,z:h.northM},p=Math.hypot(d.x,d.y,d.z),f=Math.hypot(u.x,u.y,u.z);if(p===0||f===0)continue;const m=Math.min(1,Math.max(-1,(d.x*u.x+d.y*u.y+d.z*u.z)/p/f));let g=Math.acos(m)*180/Math.PI,v=0;for(const b of Object.keys(h.motions))v=Math.max(v,Math.abs(h.motions[b]-(c.motions[b]??h.motions[b])));v>0&&(g+=v*2*(h.halfWidthM/Math.max(f,.001))*180/Math.PI),r=Math.max(r,g)}const a=Math.ceil(r/n/$n.PIXELS_PER_INSTANT);return a<2?1:Math.min($n.MAX_INSTANTS,a)}static bodyAt(e,t){const i=e.track;if(i.length===0||t<i[0].t||t>i[i.length-1].t)return;let s=0,n=i.length-1;for(;n-s>1;){const u=s+n>>1;i[u].t<=t?s=u:n=u}const r=i[s],a=i[n];if(r.eastM===void 0||r.northM===void 0||a.eastM===void 0||a.northM===void 0)return;const o=a.t>r.t?(t-r.t)/(a.t-r.t):0,c=(u,p)=>u+(p-u)*o,h={};for(const u of Object.keys(a.motions??{})){const p=r.motions?.[u],f=a.motions[u];h[u]=p===void 0?f:c(p,f)}const d=i.find(u=>u.sizeM)?.sizeM?.widthM??1;return{eastM:c(r.eastM,a.eastM),northM:c(r.northM,a.northM),upM:c(r.altitudeM??0,a.altitudeM??0),halfWidthM:d/2,motions:h}}}const fI=Math.PI/180,v8=180/Math.PI,b8=256,mI=19,y8=1.25;function gI(l,e){return 156543.03392*Math.cos(l*fI)/2**e}function vI(l,e){return gI(l,e)*b8}function w8(l,e){let t=0;for(;t<mI&&vI(l,t+1)>=e;)t++;return t}function wM(l,e){return vI(l,e)}function bI(l,e){const t=e*y8;let i=0;for(;i<mI&&gI(l,i)>t;)i++;return i}function U0(l){const e=l*fI;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function yI(l,e,t){const i=2**t;return{x:(l+180)/360*i,y:U0(e)*i}}function wI(l,e,t){const i=U0(l.north),s=U0(l.south);return{x:(e-l.west)/(l.east-l.west),y:(U0(t)-i)/(s-i)}}function M8(l,e,t){const{x:i,y:s}=yI(l,e,t);return{x:Math.floor(i),y:Math.floor(s),z:t}}function x8(l){const e=2**l.z,t=l.x/e*360-180,i=(l.x+1)/e*360-180,s=d2(l.y,e);return{south:d2(l.y+1,e),north:s,west:t,east:i}}function d2(l,e){const t=l/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*v8}function MI(l,e,t,i){const s=M8(l,e,t),n=Math.floor(i/2),r=[];for(let c=-n;c<=n;c++)for(let h=-n;h<=n;h++)r.push({x:s.x+h,y:s.y+c,z:t});const a=r.map(x8),o={south:Math.min(...a.map(c=>c.south)),north:Math.max(...a.map(c=>c.north)),west:Math.min(...a.map(c=>c.west)),east:Math.max(...a.map(c=>c.east))};return{tiles:r,bounds:o}}const E8="#2ec4ff";class ql{constructor(e){this.ctx=e}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(e,t){let i,s=1/0;for(const n of this.targets){const r=Math.hypot(n.x-e,n.y-t);r>n.radius||r>s||(i=n,s=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(e){const{ctx:t}=this;t.save(),this.targets=[],t.clearRect(0,0,this.width,this.height),this.paintGround(e),this.paintNight(e.nightFraction),this.paintPath(e),this.paintTraces(e),e.position?(this.paintCone(e,e.position),this.paintDecor(e),this.paintMarkers(e),this.paintObserver(e,e.position)):(this.paintDecor(e),this.paintMarkers(e)),this.paintNorth(),this.paintFooter(e.bounds,e.attribution),t.restore()}toCanvas(e,t,i){const s=wI(e,i,t);return{x:s.x*this.width,y:s.y*this.height}}paintGround(e){const{ctx:t}=this;t.fillStyle="#1d2321",t.fillRect(0,0,this.width,this.height);const i=e.imagery;if(!i)return;const s=this.toCanvas(e.bounds,i.bounds.north,i.bounds.west),n=this.toCanvas(e.bounds,i.bounds.south,i.bounds.east);t.drawImage(i.source,s.x,s.y,n.x-s.x,n.y-s.y)}paintNight(e=0){if(e<=0)return;const{ctx:t}=this;t.save(),t.fillStyle=`rgba(6, 12, 30, ${Math.min(e,1)*.78})`,t.fillRect(0,0,this.width,this.height),t.restore()}paintDecor(e){const{ctx:t}=this;for(const i of e.decor){const s=this.toCanvas(e.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:s.x,y:s.y,radius:7}),t.beginPath(),t.rect(s.x-3.5,s.y-3.5,7,7),t.fillStyle="rgba(120, 220, 255, 0.85)",t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.7)",t.stroke(),i.headingDeg===void 0)continue;const n=(i.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(s.x+Math.cos(n)*10,s.y+Math.sin(n)*10),t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.6)",t.stroke(),t.lineWidth=1.5,t.strokeStyle="rgba(120, 220, 255, 0.9)",t.stroke()}}paintPath(e){if(!e.path.moved)return;const{ctx:t}=this,i=e.path.points.map(s=>this.toCanvas(e.bounds,s.lat,s.lng));t.beginPath(),t.moveTo(i[0].x,i[0].y);for(const s of i.slice(1))t.lineTo(s.x,s.y);t.lineJoin="round",t.lineCap="round",t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=5,t.stroke(),t.strokeStyle="rgba(255, 255, 255, 0.9)",t.lineWidth=2,t.stroke()}paintTraces(e){const{ctx:t}=this;for(const i of e.traces??[]){const s=i.points.map(r=>this.toCanvas(e.bounds,r.lat,r.lng));if(s.length===0)continue;const n=i.color??E8;if(i.kind==="point")t.beginPath(),t.moveTo(s[0].x,s[0].y-6),t.lineTo(s[0].x+6,s[0].y),t.lineTo(s[0].x,s[0].y+6),t.lineTo(s[0].x-6,s[0].y),t.closePath(),t.fillStyle=n,t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.8)",t.stroke();else{t.beginPath(),t.moveTo(s[0].x,s[0].y);for(const r of s.slice(1))t.lineTo(r.x,r.y);i.kind==="polygon"&&t.closePath(),t.lineJoin="round",t.setLineDash([]),t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=4.5,t.stroke(),t.setLineDash([9,5]),t.strokeStyle=n,t.lineWidth=2.5,t.stroke(),t.setLineDash([])}if(i.label){t.font="11px sans-serif",t.textAlign="left",t.textBaseline="middle";let r=s[0];if(i.kind==="line"&&e.position){const a=this.toCanvas(e.bounds,e.position.lat,e.position.lng);r=s.reduce((o,c)=>Math.hypot(c.x-a.x,c.y-a.y)>Math.hypot(o.x-a.x,o.y-a.y)?c:o)}this.paintOutlinedText(i.label,r.x+9,r.y-9)}}}paintCone(e,t){const{headingDeg:i,coneHalfAngleDeg:s}=e;if(i===void 0||s===void 0)return;const{ctx:n}=this,r=this.toCanvas(e.bounds,t.lat,t.lng),a=Math.hypot(this.width,this.height),o=(i-90)*Math.PI/180,c=s*Math.PI/180;n.save(),n.beginPath(),n.moveTo(r.x,r.y),n.arc(r.x,r.y,a,o-c,o+c),n.closePath();const h=n.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)"),n.fillStyle=h,n.fill(),n.restore()}paintMarkers(e){const{ctx:t}=this;t.textAlign="center",t.textBaseline="middle",t.font="bold 10px sans-serif";for(const i of[...e.markers].sort((s,n)=>Number(s.current)-Number(n.current))){const s=this.toCanvas(e.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:s.x,y:s.y,radius:ql.MARKER_RADIUS_PX}),t.beginPath(),t.arc(s.x,s.y,ql.MARKER_RADIUS_PX,0,Math.PI*2),t.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",t.fill(),t.lineWidth=2,t.strokeStyle="rgba(255, 255, 255, 0.9)",t.stroke(),t.fillStyle=i.current?"#1d2321":"#fff",t.fillText(i.label,s.x,s.y)}}paintObserver(e,t){const{ctx:i}=this,s=this.toCanvas(e.bounds,t.lat,t.lng);e.observerLabel&&this.targets.push({kind:"observer",label:e.observerLabel,lat:t.lat,lng:t.lng,x:s.x,y:s.y,radius:8});const n=e.markers.some(r=>{if(!r.current)return!1;const a=lt(r.lat,r.lng,t.lat,t.lng);return Math.hypot(a.x,a.z)<=ql.ON_MARKER_M});i.beginPath(),i.arc(s.x,s.y,n?ql.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),n||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=n?3:2.5,i.strokeStyle=n?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:e}=this,t=this.width-14,i=16;e.beginPath(),e.moveTo(t,i-9),e.lineTo(t-4.5,i+5),e.lineTo(t,i+2),e.lineTo(t+4.5,i+5),e.closePath(),e.fillStyle="rgba(255, 255, 255, 0.92)",e.strokeStyle="rgba(0, 0, 0, 0.6)",e.lineWidth=1,e.fill(),e.stroke(),e.font="bold 9px sans-serif",e.textAlign="center",e.textBaseline="top",e.strokeText("N",t,i+6),e.fillText("N",t,i+6)}paintFooter(e,t){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const s=t?this.wrap(t,this.width-20):[];let n=this.height-4;i.textAlign="right";for(const p of s.slice().reverse())this.paintOutlinedText(p,this.width-6,n),n-=11;const r=(e.south+e.north)/2,o=Math.abs(lt(r,e.east,r,e.west).x)/this.width,c=ql.SCALE_STEPS_M.find(p=>p/o<=this.width/3);if(c===void 0)return;const h=c/o,d=8,u=n-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(d,u),i.lineTo(d+h,u),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(c>=1e3?`${c/1e3} km`:`${c} m`,d,u-3)}paintOutlinedText(e,t,i){const{ctx:s}=this;s.lineWidth=3,s.strokeStyle="rgba(0, 0, 0, 0.75)",s.strokeText(e,t,i),s.fillStyle="#fff",s.fillText(e,t,i)}wrap(e,t){const i=[];let s="";for(const n of e.split(" ")){const r=s?`${s} ${n}`:n;s&&this.ctx.measureText(r).width>t?(i.push(s),s=n):s=r}return s&&i.push(s),i}}class vi{static MIN_ZOOM=.25;static MAX_ZOOM=64;static MIN_SPAN_M=400;static MARGIN=.6;static IMAGERY_PX=768;static fitted(e,t){return vi.including(e.boundsAround(vi.MIN_SPAN_M,vi.MARGIN),t)}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(e,t,i){const s=Math.min(vi.MAX_ZOOM,Math.max(vi.MIN_ZOOM,this.zoom*i)),n=this.centerX+(e-.5)/this.zoom,r=this.centerY+(t-.5)/this.zoom;this.centerX=n-(e-.5)/s,this.centerY=r-(t-.5)/s,this.zoom=s}panBy(e,t){this.centerX-=e/this.zoom,this.centerY-=t/this.zoom}refit(e,t){if(!this.changed)return;const i=this.boundsWithin(e),s=vi.mercatorY01(t.north),n=vi.mercatorY01(t.south),r=vi.mercatorY01(i.north),a=vi.mercatorY01(i.south);this.zoom=(t.east-t.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-t.west)/(t.east-t.west),this.centerY=((r+a)/2-s)/(n-s)}keepInView(e,t,i){if(!this.changed)return!1;const s=this.boundsWithin(e),n=vi.mercatorY01(s.north),r=vi.mercatorY01(s.south),a=(t.lng-s.west)/(s.east-s.west),o=(vi.mercatorY01(t.lat)-n)/(r-n);return a>=i&&a<=1-i&&o>=i&&o<=1-i?!1:(this.panBy(.5-a,.5-o),!0)}boundsWithin(e){if(!this.changed)return e;const t=.5/this.zoom,i=vi.mercatorY01(e.north),s=vi.mercatorY01(e.south),n=e.east-e.west;return{west:e.west+(this.centerX-t)*n,east:e.west+(this.centerX+t)*n,north:vi.latitudeAt(i+(this.centerY-t)*(s-i)),south:vi.latitudeAt(i+(this.centerY+t)*(s-i))}}static including(e,t,i=3){const s=(e.north+e.south)/2,n=(e.east+e.west)/2,r=lt(s,e.east,s,n).x;let a=r;for(const o of t){const{x:c,z:h}=lt(o.lat,o.lng,s,n),d=Math.max(Math.abs(c),Math.abs(h));d<=r*i&&(a=Math.max(a,d*1.15))}return a<=r?e:{north:br(0,-a,s,n).lat,south:br(0,a,s,n).lat,east:br(a,0,s,n).lng,west:br(-a,0,s,n).lng}}static expand(e,t){const i=e.east-e.west,s=e.north-e.south;return{west:e.west-i*t,east:e.east+i*t,south:e.south-s*t,north:e.north+s*t}}static pointAt(e,t,i){const s=vi.mercatorY01(e.north),n=vi.mercatorY01(e.south);return{lat:vi.latitudeAt(s+i*(n-s)),lng:e.west+t*(e.east-e.west)}}static mercatorY01(e){const t=e*Math.PI/180;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}static latitudeAt(e){return Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI}}const aa=256,S8=3,A8=129,T8=7,I8=32768;class xI{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const i=(e.south+e.north)/2,s=(e.west+e.east)/2,n=Math.abs(lt(i,e.east,i,e.west).x),r=Math.abs(lt(e.north,s,e.south,s).z),a=Math.max(n,r);let o=w8(i,a),c=S8;if(t.width>=A8){const m=v=>2*Math.ceil((a/wM(i,v)+1)/2)+1;let g=bI(i,a/(t.width-1)/2);for(;g>o&&m(g)>T8;)g--;g>o&&(o=g,c=m(g))}const{tiles:h}=MI(s,i,o,c),d=c*aa,u=new Float32Array(d*d),p=h[0];await Promise.all(h.map(m=>this.decodeTileInto(m,p,u,d)));const f=new Float32Array(t.width*t.height);for(let m=0;m<t.height;m++){const g=e.north+(e.south-e.north)*(m/(t.height-1));for(let v=0;v<t.width;v++){const b=e.west+(e.east-e.west)*(v/(t.width-1));f[m*t.width+v]=this.sampleAt(g,b,o,p,u,d)}}return{heights:f,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,i,s){const n=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),r=await this.fetchImpl(n);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${n}`);const a=await createImageBitmap(await r.blob()),o=document.createElement("canvas");o.width=aa,o.height=aa;const c=o.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(a,0,0);const{data:h}=c.getImageData(0,0,aa,aa),d=(e.x-t.x)*aa,u=(e.y-t.y)*aa;for(let p=0;p<aa;p++)for(let f=0;f<aa;f++){const m=(p*aa+f)*4,g=h[m]*256+h[m+1]+h[m+2]/256-I8,v=d+f,b=u+p;i[b*s+v]=g}}sampleAt(e,t,i,s,n,r){const{x:a,y:o}=yI(t,e,i),c=(a-s.x)*aa,h=(o-s.y)*aa,d=Math.max(0,Math.min(r-1,Math.floor(c))),u=Math.max(0,Math.min(r-1,Math.floor(h))),p=Math.min(r-1,d+1),f=Math.min(r-1,u+1),m=c-d,g=h-u,v=n[u*r+d],b=n[u*r+p],w=n[f*r+d],y=n[f*r+p],M=v+(b-v)*m,x=w+(y-w)*m;return M+(x-M)*g}}class mv{constructor(e,t,i,s){this.width=e,this.height=t,this.samples=i,this.values=s}at(e,t,i=0){return this.values[(t*this.width+e)*this.samples+i]}static parse(e){const t=new DataView(e);if(e.byteLength<8||t.getUint16(0)!==18761||t.getUint16(2,!0)!==42)throw new Error("Not a little-endian TIFF");const i=t.getUint32(4,!0),s=t.getUint16(i,!0),n=new Map;for(let v=0;v<s;v++){const b=i+2+v*12;n.set(t.getUint16(b,!0),{type:t.getUint16(b+2,!0),count:t.getUint32(b+4,!0),value:t.getUint32(b+8,!0)})}const r=(v,b)=>{const w=n.get(v);if(w===void 0){if(b===void 0)throw new Error(`TIFF without tag ${v}`);return b}return w.type===3?w.value&65535:w.value},a=v=>{const b=n.get(v);if(b===void 0)throw new Error(`TIFF without tag ${v}`);const w=b.type===3?2:4,y=[];if(b.count*w<=4){const M=new DataView(new ArrayBuffer(4));M.setUint32(0,b.value,!0);for(let x=0;x<b.count;x++)y.push(w===2?M.getUint16(x*2,!0):M.getUint32(0,!0))}else for(let M=0;M<b.count;M++)y.push(w===2?t.getUint16(b.value+M*2,!0):t.getUint32(b.value+M*4,!0));return y};if(r(259,1)!==1)throw new Error("Compressed TIFF");if(n.has(322))throw new Error("Tiled TIFF");const o=r(256),c=r(257),h=r(277,1),d=a(258)[0],u=r(339,1)===3;if(!(u&&d===32||!u&&d===8))throw new Error(`Unsupported TIFF samples: ${d} bits`);const p=a(273),f=a(279),m=new Uint8Array(o*c*h*(d/8));let g=0;for(let v=0;v<p.length&&g<m.length;v++){const b=Math.min(f[v],m.length-g);m.set(new Uint8Array(e,p[v],b),g),g+=b}if(g<m.length)throw new Error("Truncated TIFF");return new mv(o,c,h,u?new Float32Array(m.buffer):m)}}class _8{constructor(e,t,i,s,n){this.heights=e,this.plants=t,this.buildings=i,this.size=s,this.metresPerPixel=n}structureAt(e,t){const i=Math.floor(e/this.metresPerPixel+this.size/2),s=Math.floor(this.size/2-t/this.metresPerPixel);if(i<0||s<0||i>=this.size||s>=this.size)return;const n=s*this.size+i;if(!(this.plants[n]||this.buildings[n]))return this.heights[n]}tallestStructureNear(e,t,i){let s;const n=Math.ceil(i/this.metresPerPixel);for(let r=-n;r<=n;r++)for(let a=-n;a<=n;a++){if(Math.hypot(a,r)*this.metresPerPixel>i)continue;const o=this.structureAt(e+a*this.metresPerPixel,t+r*this.metresPerPixel);o!==void 0&&(s===void 0||o>s)&&(s=o)}return s}}class Re{static METRES_PER_DEGREE=111320;static MIN_BRIDGE_M=4;static DEFAULT_DECK_M=6;static FOOTBRIDGE_DECK_M=2.5;static DECK_MARGIN_M=2.4;static JOIN_M=1;static JOIN_DEG=25;static RAIL_MATCH_M=6;static ROAD_MATCH_M=12;static DECK_SEEN_M=1.5;static DECK_STEP_M=.5;static DECK_GAP_M=2;static DECK_REACH_M=20;static DECK_MEETS_M=.3;static DECK_BEARING_M=4;static DEFAULT_DECK_HEIGHT_M=4;static MIN_POLE_M=6;static MAX_POLE_M=70;static MAX_SPAN_M=800;static MAX_LINES=16;static BY_VOLTAGE=[{upToKv:25,poleM:11,dropM:1.2,spreadM:.8},{upToKv:70,poleM:20,dropM:3,spreadM:3},{upToKv:100,poleM:22,dropM:3.5,spreadM:3.5},{upToKv:170,poleM:27,dropM:4.5,spreadM:4.5},{upToKv:250,poleM:32,dropM:5.5,spreadM:5.5},{upToKv:1e3,poleM:42,dropM:7,spreadM:7.5}];static toMetres(e,t){const[i,s]=e;return{east:(i-t.lng)*Re.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180),north:(s-t.lat)*Re.METRES_PER_DEGREE}}static path(e,t){return e.geometry.type!=="LineString"?[]:e.geometry.coordinates.map(i=>Re.toMetres(i,t))}static bearing(e,t){return(Math.atan2(t.east-e.east,t.north-e.north)*180/Math.PI+360)%360}static distanceToSegment(e,t,i){const s=i.east-t.east,n=i.north-t.north,r=s*s+n*n,a=r===0?0:Math.max(0,Math.min(1,((e.east-t.east)*s+(e.north-t.north)*n)/r));return Math.hypot(e.east-(t.east+a*s),e.north-(t.north+a*n))}static bridges(e,t,i,s){const n=e.elevatedRoads.map(o=>({path:Re.path(o,t),properties:o.properties})),r=(e.elevatedRailways??[]).map(o=>Re.path(o,t)),a=[];for(const o of Re.joined(e.bridges.map(c=>Re.path(c,t)))){const c=o[0],h=o[o.length-1],d=Math.hypot(h.east-c.east,h.north-c.north);if(d<Re.MIN_BRIDGE_M)continue;const u={east:(c.east+h.east)/2,north:(c.north+h.north)/2};if(Math.hypot(u.east,u.north)>i+d/2||Re.carriesRailway(c,h,r))continue;const[p,f]=Re.deckReach(c,h,s);a.push({eastM:Re.tenth((p.east+f.east)/2),northM:Re.tenth((p.north+f.north)/2),lengthM:Re.tenth(Math.hypot(f.east-p.east,f.north-p.north)),widthM:Re.roadOf(u,n).width,heightM:Re.tenth(Re.deckHeight(c,h,s)),headingDeg:Re.tenth(Re.bearing(c,h)%180),...Re.roadOf(u,n).name?{name:Re.roadOf(u,n).name}:{}})}return a.sort((o,c)=>Math.hypot(o.eastM,o.northM)-Math.hypot(c.eastM,c.northM)),a}static carriesRailway(e,t,i){const s={east:(e.east+t.east)/2,north:(e.north+t.north)/2},n=Re.bearing(e,t)%180;for(const r of i)for(let a=0;a+1<r.length;a++){if(Re.distanceToSegment(s,r[a],r[a+1])>Re.RAIL_MATCH_M)continue;const o=Math.abs(Re.bearing(r[a],r[a+1])%180-n);if(Math.min(o,180-o)<=Re.JOIN_DEG)return!0}return!1}static joined(e){const t=e.filter(i=>i.length>=2);for(let i=0;i<t.length;i++)for(let s=i+1;s<t.length;s++){const n=Re.join(t[i],t[s]);n!==void 0&&(t[i]=n,t.splice(s,1),s=i)}return t}static join(e,t){for(const i of[e,[...e].reverse()])for(const s of[t,[...t].reverse()]){const n=i[i.length-1],r=s[0];if(Math.hypot(n.east-r.east,n.north-r.north)>Re.JOIN_M)continue;const a=Math.abs(Re.bearing(i[0],n)-Re.bearing(r,s[s.length-1]));if(Math.min(a,360-a)<=Re.JOIN_DEG)return[...i,...s.slice(1)]}}static roadOf(e,t){let i;for(const a of t)for(let o=0;o+1<a.path.length;o++){const c=Re.distanceToSegment(e,a.path[o],a.path[o+1]);(i===void 0||c<i.distance)&&(i={distance:c,properties:a.properties})}if(i===void 0||i.distance>Re.ROAD_MATCH_M)return{width:Re.DEFAULT_DECK_M};const s=[i.properties.nom_voie_ban_gauche,i.properties.nom_voie_ban_droite,i.properties.cpx_toponyme_route_nommee].find(a=>typeof a=="string"&&a.length>0),n=Number(i.properties.largeur_de_chaussee),r=Number.isFinite(n)&&n>0?Re.tenth(n+Re.DECK_MARGIN_M):i.properties.nature==="Sentier"?Re.FOOTBRIDGE_DECK_M:Re.DEFAULT_DECK_M;return s?{width:r,name:s}:{width:r}}static deckReach(e,t,i){const s=Math.hypot(t.east-e.east,t.north-e.north);if(i===void 0||s===0)return[e,t];const n={east:(e.east+t.east)/2,north:(e.north+t.north)/2},r={east:(t.east-e.east)/s,north:(t.north-e.north)/s},a=u=>(i.structureAt(n.east+r.east*u,n.north+r.north*u)??0)>=Re.DECK_SEEN_M,o=u=>i.structureAt(n.east+r.east*u,n.north+r.north*u)??0,c=u=>{let p;for(let m=0;m<=s/2+Re.DECK_REACH_M;m+=Re.DECK_STEP_M)if(a(u*m))p=m;else if(p!==void 0&&m-p>Re.DECK_GAP_M)break;if(p===void 0)return s/2;let f=p;for(;f-p<Re.DECK_REACH_M&&o(u*(f+Re.DECK_STEP_M))>=Re.DECK_MEETS_M;)f+=Re.DECK_STEP_M;return Math.max(s/2,f+Re.DECK_BEARING_M)},h=c(-1),d=c(1);return[{east:n.east-r.east*h,north:n.north-r.north*h},{east:n.east+r.east*d,north:n.north+r.north*d}]}static deckHeight(e,t,i){if(i===void 0)return Re.DEFAULT_DECK_HEIGHT_M;const s=[],n=20;for(let r=4;r<=n-4;r++){const a=i.structureAt(e.east+(t.east-e.east)*r/n,e.north+(t.north-e.north)*r/n);a!==void 0&&a>=1.5&&s.push(a)}return s.length===0?Re.DEFAULT_DECK_HEIGHT_M:(s.sort((r,a)=>r-a),s[Math.floor(s.length/2)])}static lines(e,t,i,s){const n=[];for(const r of e.lines){const a=String(r.properties.voltage??""),o=Re.kilovolts(a);if(o===void 0)continue;const c=Re.BY_VOLTAGE.find(d=>o<=d.upToKv)??Re.BY_VOLTAGE[Re.BY_VOLTAGE.length-1],h=Re.path(r,t);for(let d=0;d+1<h.length;d++){const u=h[d],p=h[d+1],f=Math.hypot(p.east-u.east,p.north-u.north);if(f<5||f>Re.MAX_SPAN_M||Re.distanceToSegment({east:0,north:0},u,p)>i)continue;const m=Re.poleHeight(u,p,s)??c.poleM;n.push({eastM:Re.tenth((u.east+p.east)/2),northM:Re.tenth((u.north+p.north)/2),lengthM:Re.tenth(f),headingDeg:Re.tenth(Re.bearing(u,p)),heightM:Re.tenth(Math.max(4,m-c.dropM)),poleHeightM:Re.tenth(m),acrossM:[-c.spreadM,0,c.spreadM],voltage:a})}}return n.sort((r,a)=>Math.hypot(r.eastM,r.northM)-Math.hypot(a.eastM,a.northM)),n.slice(0,Re.MAX_LINES)}static kilovolts(e){const t=/([\d.,]+)\s*kV/i.exec(e);if(t===null)return;const i=Number(t[1].replace(",","."));return Number.isFinite(i)&&i>0?i:void 0}static poleHeight(e,t,i){if(i===void 0)return;const s=[e,t].map(n=>i.tallestStructureNear(n.east,n.north,3)).filter(n=>n!==void 0&&n>=Re.MIN_POLE_M&&n<=Re.MAX_POLE_M);return s.length===0?void 0:s.reduce((n,r)=>n+r,0)/s.length}static tenth(e){return Math.round(e*10)/10}}class Xt{static covers(e,t){return e>=41.2&&e<=51.3&&t>=-5.4&&t<=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(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.wms=e.wmsEndpoint??Xt.WMS,this.wfs=e.wfsEndpoint??Xt.WFS}static radius(e){return Math.min(e,Xt.MAX_RADIUS_M)}static lidarRadius(e){return Math.min(e,Xt.MAX_LIDAR_RADIUS_M)}async lidar(e,t){const i=Xt.lidarRadius(t),s=Math.ceil(2*i/Xt.METRES_PER_PIXEL),[n,r]=await Promise.all([this.raster(e,i,s,Xt.HEIGHT_LAYER),this.raster(e,i,s,Xt.CLASS_LAYER)]);if(n.samples!==1||r.samples<3)throw new Ia("unreachable","The survey answered in a layout this does not read");const a=n.values;if(a.every(d=>d===Xt.NO_DATA))throw new Ia("no-coverage","No LiDAR HD survey here yet");const o=new Uint8Array(s*s),c=new Uint8Array(s*s);for(let d=0;d<s*s;d++){const u=r.values[d*r.samples],p=r.values[d*r.samples+1],f=r.values[d*r.samples+2];o[d]=p>u&&p>f?1:0,c[d]=u>120&&p<90&&f<90?1:0}const h=2*i/s;return{size:s,metresPerPixel:h,heights:a,vegetation:o,building:c,structures:new _8(a,o,c,s,h)}}async laserDate(e){return Xt.latest(await this.dated("IGNF_LIDAR-HD_METADONNEE:metadata","geom","date_fin_acquisition",e))}async photoDate(e){return Xt.latest(await this.dated("ORTHOIMAGERY.ORTHOPHOTOS.GRAPHE-MOSAIQUAGE:graphe_bdortho","geom","date_vol",e))}static latest(e){return e.map(i=>/^\d{4}-\d{2}-\d{2}/.exec(String(i??""))?.[0]).filter(i=>i!==void 0).sort().at(-1)}async dated(e,t,i,s){const r=[s.lng-1e-4,s.lat-1e-4,s.lng+1e-4,s.lat+1e-4].map(a=>a.toFixed(6)).join(",");try{return(await this.features(e,`BBOX(${t},${r},'EPSG:4326')`,i,20)).map(a=>a.properties[i])}catch{return[]}}async photo(e,t){const i=Xt.radius(t),s=Math.min(Xt.MAX_PHOTO_PIXELS,Math.ceil(2*i/Xt.METRES_PER_PIXEL)),n=await this.raster(e,i,s,Xt.PHOTO_LAYER);if(n.samples<3)throw new Ia("unreachable","The photograph came in a layout this does not read");return{size:s,metresPerPixel:2*i/s,samples:n.samples,values:n.values}}async vectors(e,t,i){const s=Xt.radius(t),n=s/Xt.METRES_PER_DEGREE,r=s/(Xt.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180)),o=`BBOX(geometrie,${[e.lng-r,e.lat-n,e.lng+r,e.lat+n].map(v=>v.toFixed(6)).join(",")},'EPSG:4326')`,[c,h,d,u,p,f]=await Promise.all([this.features("construction_lineaire",`${o} AND nature='Pont'`,"nature,geometrie"),this.features("troncon_de_route",`${o} 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",`${o} AND position_par_rapport_au_sol>'0'`,"position_par_rapport_au_sol,geometrie").catch(()=>[]),this.features("ligne_electrique",o,"voltage,geometrie"),i?this.features("batiment",o,Xt.BUILDING_PROPERTIES,5e3):Promise.resolve([]),i?this.features("zone_d_activite_ou_d_interet",o,"toponyme,categorie,geometrie",100).catch(()=>[]):Promise.resolve([])]),m=i?await this.wholeWorship(f,p,[e.lng-r,e.lat-n,e.lng+r,e.lat+n]):[],g=[...p,...m];return{bridges:c,elevatedRoads:h,elevatedRailways:d,lines:u,buildings:g,zones:f,mapDate:Xt.latest(g.map(v=>v.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(e,t,i){const[s,n,r,a]=i,o=Xt.MAX_WHOLE_M/Xt.METRES_PER_DEGREE;let c;for(const d of e){if(d.properties.categorie!=="Religieux")continue;const[u,p,f,m]=Xt.extent(d);if(u>=s&&p>=n&&f<=r&&m<=a)continue;const g=[Math.max(u,s-o),Math.max(p,n-o),Math.min(f,r+o),Math.min(m,a+o)];c=c?[Math.min(c[0],g[0]),Math.min(c[1],g[1]),Math.max(c[2],g[2]),Math.max(c[3],g[3])]:g}if(!c)return[];const h=new Set(t.map(d=>d.properties.cleabs));try{return(await this.features("batiment",`BBOX(geometrie,${c.map(u=>u.toFixed(6)).join(",")},'EPSG:4326')`,Xt.BUILDING_PROPERTIES,1e3)).filter(u=>!h.has(u.properties.cleabs))}catch{return[]}}static extent(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;const r=a=>{Array.isArray(a)&&typeof a[0]=="number"?(t=Math.min(t,a[0]),s=Math.max(s,a[0]),i=Math.min(i,a[1]),n=Math.max(n,a[1])):Array.isArray(a)&&a.forEach(r)};return r(e.geometry.coordinates),[t,i,s,n]}async elevatedRoadLines(e){const t=`BBOX(geometrie,${[e.west,e.south,e.east,e.north].map(n=>n.toFixed(6)).join(",")},'EPSG:4326')`,i=await this.features("troncon_de_route",`${t} AND position_par_rapport_au_sol>'0'`,"geometrie",300),s=[];for(const n of i){const{type:r,coordinates:a}=n.geometry,o=r==="LineString"?[a]:r==="MultiLineString"?a:[];for(const c of o)s.push(c.map(h=>({lat:h[1],lng:h[0]})))}return s}async waterSurfaces(e){const t=`BBOX(geometrie,${[e.west,e.south,e.east,e.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("surface_hydrographique",`${t} AND position_par_rapport_au_sol='0' AND persistance='Permanent'`,"cleabs,nature,geometrie",500)}async roads(e){const t=`BBOX(geometrie,${[e.west,e.south,e.east,e.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_route",`${t} 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(e){const t=`BBOX(geometrie,${[e.west,e.south,e.east,e.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_voie_ferree",`${t} 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(e,t,i,s){const n=t/Xt.METRES_PER_DEGREE,r=t/(Xt.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180)),a=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:s,STYLES:"",CRS:"EPSG:4326",BBOX:[e.lat-n,e.lng-r,e.lat+n,e.lng+r].map(c=>c.toFixed(6)).join(","),WIDTH:String(i),HEIGHT:String(i),FORMAT:"image/geotiff"});let o;try{o=await this.fetchImpl(`${this.wms}?${a}`)}catch(c){throw new Ia("unreachable",c instanceof Error?c.message:String(c))}if(!o.ok)throw new Ia("unreachable",`The survey answered ${o.status}`);try{return mv.parse(await o.arrayBuffer())}catch(c){throw new Ia("unreachable",c instanceof Error?c.message:String(c))}}async features(e,t,i,s=200){const n=new URLSearchParams({SERVICE:"WFS",VERSION:"2.0.0",REQUEST:"GetFeature",TYPENAMES:e.includes(":")?e:`BDTOPO_V3:${e}`,SRSNAME:"EPSG:4326",OUTPUTFORMAT:"application/json",COUNT:String(s),CQL_FILTER:t,PROPERTYNAME:i});let r;try{r=await this.fetchImpl(`${this.wfs}?${n}`)}catch(o){throw new Ia("unreachable",o instanceof Error?o.message:String(o))}if(!r.ok)throw new Ia("unreachable",`The map answered ${r.status}`);return(await r.json()).features??[]}}class Vc{static NEAR_M=15;static ALIGNED_DEG=30;static LONG_ENOUGH_M=15;static SAMPLE_M=5;static follows(e,t){if(e.length<2||t.length<2)return!1;const i=t[0],s=t.map(a=>lt(a.lat,a.lng,i.lat,i.lng)),n=e.map(a=>lt(a.lat,a.lng,i.lat,i.lng));let r=0;for(let a=0;a<n.length-1;a++){const o=n[a],c=n[a+1],h=Math.hypot(c.x-o.x,c.z-o.z);if(h<1e-6)continue;const d=Math.max(1,Math.ceil(h/Vc.SAMPLE_M)),u=Math.atan2(c.x-o.x,-(c.z-o.z));for(let p=0;p<=d;p++){const f=p/d,m=Vc.nearest(s,o.x+(c.x-o.x)*f,o.z+(c.z-o.z)*f);m.distanceM>Vc.NEAR_M||Vc.angleBetween(u,m.heading)<=Vc.ALIGNED_DEG&&(r+=h/d)}}return r>=Vc.LONG_ENOUGH_M}static nearest(e,t,i){let s={distanceM:1/0,heading:0};for(let n=0;n<e.length-1;n++){const r=e[n],a=e[n+1],o=a.x-r.x,c=a.z-r.z,h=o*o+c*c,d=h<1e-9?0:Math.max(0,Math.min(1,((t-r.x)*o+(i-r.z)*c)/h)),u=Math.hypot(t-(r.x+o*d),i-(r.z+c*d));u<s.distanceM&&(s={distanceM:u,heading:Math.atan2(o,-c)})}return s}static angleBetween(e,t){const i=Math.abs((e-t)*180/Math.PI%180);return Math.min(i,180-i)}}class Bt{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(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.wms=e.wmsEndpoint??Bt.WMS,this.timeoutMs=e.timeoutMs??Bt.DEFAULT_TIMEOUT_MS,this.maxWindowM=e.maxWindowM??Bt.MAX_WINDOW_M,this.geoplatform=new Xt({fetchImpl:this.fetchImpl,wmsEndpoint:this.wms,wfsEndpoint:e.wfsEndpoint})}async getElevationGrid(e,t,i){const s={lat:(e.south+e.north)/2,lng:(e.west+e.east)/2};if(!Xt.covers(s.lat,s.lng))throw new Error("The IGN's relief covers France only");const n=Math.abs(lt(s.lat,e.east,s.lat,e.west).x),r=Math.abs(lt(e.north,s.lng,e.south,s.lng).z);t=this.finer(t,n,r);const a={x:n/Math.max(1,t.width-1),y:r/Math.max(1,t.height-1)},o={x:Math.min(a.x,this.maxWindowM),y:Math.min(a.y,this.maxWindowM)},c={south:e.south-o.y/Bt.METRES_PER_DEGREE,north:e.north+o.y/Bt.METRES_PER_DEGREE,west:e.west-o.x/(Bt.METRES_PER_DEGREE*Math.cos(s.lat*Math.PI/180)),east:e.east+o.x/(Bt.METRES_PER_DEGREE*Math.cos(s.lat*Math.PI/180))},h=m=>Math.min(Bt.MAX_PIXELS,Math.max(Bt.MIN_PIXELS,Math.ceil(m/Bt.METRES_PER_PIXEL))),d={width:h(n+2*o.x),height:h(r+2*o.y)},u={x:(n+2*o.x)/d.width,y:(r+2*o.y)/d.height};let p=new Error("No layer of the IGN's relief answered");const f=Math.max(u.x,u.y)>Bt.COARSE_METRES_PER_PIXEL;for(const m of f?[...Bt.LAYERS].reverse():Bt.LAYERS)try{const g=await this.heights(c,d,m);m===Bt.LAYERS[0]&&await this.layBridgeDecks(g,c,d,i?.route);const v=this.sample(g,t,e,c,u,a);if(v)return{heights:v,width:t.width,height:t.height,bounds:e};p=new Error(`${m} does not cover this place`)}catch(g){p=g}throw p}finer(e,t,i){if(e.width<Bt.MESH_FROM_VERTICES||e.height<Bt.MESH_FROM_VERTICES)return e;const s=(n,r)=>{const a=Math.ceil(n/Bt.FINE_SPACING_M),o=Math.max(r-1,Math.min(Bt.MAX_SEGMENTS,a));return o%2===0?o:o+1};return{width:s(t,e.width)+1,height:s(i,e.height)+1}}async raster(e,t,i){const s=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:i,STYLES:"",CRS:"EPSG:4326",BBOX:[e.south,e.west,e.north,e.east].map(r=>r.toFixed(6)).join(","),WIDTH:String(t.width),HEIGHT:String(t.height),FORMAT:"image/geotiff"}),n=await this.fetchImpl(`${this.wms}?${s}`,{signal:AbortSignal.timeout(this.timeoutMs)});if(!n.ok)throw new Error(`The IGN's relief answered ${n.status}`);return mv.parse(await n.arrayBuffer())}async heights(e,t,i){const s=await this.raster(e,t,i);if(s.samples!==1||!(s.values instanceof Float32Array))throw new Error("The IGN's relief came in a layout this does not read");return s}async layBridgeDecks(e,t,i,s){if(!(!s||s.length<2)&&!(!(e.values instanceof Float32Array)||!e.values.some(n=>n>Bt.NO_DATA_BELOW)))try{const n=(await this.geoplatform.elevatedRoadLines({west:t.west,south:t.south,east:t.east,north:t.north})).filter(a=>Vc.follows(s,a));if(n.length===0)return;const r=Float32Array.from(e.values);await this.layClassifiedDecks(e,t,i,n),this.layRouteDecks(e,r,t,n)}catch{}}async layClassifiedDecks(e,t,i,s){try{const n=await this.raster(t,i,Bt.CLASS_LAYER);if(n.samples<3||n.width!==e.width||n.height!==e.height)return;const r=(g,[v,b,w])=>n.values[g*n.samples]===v&&n.values[g*n.samples+1]===b&&n.values[g*n.samples+2]===w,a=e.width,o=e.height,c=new Uint8Array(a*o);let h=!1;for(let g=0;g<c.length;g++)r(g,Bt.DECK)&&(c[g]=1,h=!0);if(!h)return;const d=Bt.DECK_END_PIXELS,u=[];for(let g=0;g<c.length;g++){if(c[g]!==1)continue;const v=g%a,b=(g-v)/a;for(let w=-d;w<=d;w++)for(let y=-d;y<=d;y++){const M=v+y,x=b+w;if(M<0||x<0||M>=a||x>=o)continue;const S=x*a+M;c[S]===0&&r(S,Bt.NO_CLASS)&&u.push(S)}}for(const g of u)c[g]=1;const p=this.paint(s,t,a,o),f=this.touching(c,p,a,o);if(f.every(g=>g===0))return;const m=await this.heights(t,i,Bt.SURFACE_LAYER);if(m.width!==a||m.height!==o)return;for(let g=0;g<f.length;g++){if(f[g]===0)continue;const v=m.values[g];Number.isFinite(v)&&v>Bt.NO_DATA_BELOW&&v>e.values[g]&&(e.values[g]=v)}}catch{}}layRouteDecks(e,t,i,s){const{width:n,height:r}=e,a=(i.north+i.south)/2,o=(i.east-i.west)*Bt.METRES_PER_DEGREE*Math.cos(a*Math.PI/180),c=(i.north-i.south)*Bt.METRES_PER_DEGREE,h=o/n,d=c/r,u=v=>({x:(v.lng-i.west)/(i.east-i.west)*o,y:(i.north-v.lat)/(i.north-i.south)*c}),p=(v,b)=>{const w=Math.floor(v/h),y=Math.floor(b/d);if(w<0||y<0||w>=n||y>=r)return;const M=t[y*n+w];return Number.isFinite(M)&&M>Bt.NO_DATA_BELOW?M:void 0},f=Bt.DECK_HALF_WIDTH_M,m=Bt.DECK_APPROACH_M,g=(v,b)=>{const w=Math.hypot(v.x-b.x,v.y-b.y)||1,y={x:(v.x-b.x)/w,y:(v.y-b.y)/w},M=[0,m/2,m].map(x=>p(v.x+y.x*x,v.y+y.y*x)).filter(x=>x!==void 0);return M.length>0?Math.max(...M):void 0};for(const v of Bt.chains(s.map(b=>b.map(u)))){const b=[0];for(let D=1;D<v.length;D++)b.push(b[D-1]+Math.hypot(v[D].x-v[D-1].x,v[D].y-v[D-1].y));const w=b[b.length-1];if(w<1||w>Bt.DECK_STRAIGHT_MAX_M)continue;const y=g(v[0],v[1]),M=g(v[v.length-1],v[v.length-2]);if(y===void 0||M===void 0)continue;const x=f+m,S=Math.max(0,Math.floor((Math.min(...v.map(D=>D.x))-x)/h)),E=Math.min(n-1,Math.ceil((Math.max(...v.map(D=>D.x))+x)/h)),A=Math.max(0,Math.floor((Math.min(...v.map(D=>D.y))-x)/d)),T=Math.min(r-1,Math.ceil((Math.max(...v.map(D=>D.y))+x)/d));for(let D=A;D<=T;D++)for(let k=S;k<=E;k++){const O=Bt.nearestAlong(v,b,{x:(k+.5)*h,y:(D+.5)*d});if(O.distance>f||O.s<-m||O.s>w+m)continue;const N=y+(M-y)*Math.min(1,Math.max(0,O.s/w)),C=D*n+k;t[C]>=N||(e.values[C]=N)}}}static chains(e){const t=e.filter(n=>n.length>=2).map(n=>[...n]),i=[],s=(n,r)=>Math.hypot(n.x-r.x,n.y-r.y)<=1;for(;t.length>0;){let n=t.shift(),r=!0;for(;r;){r=!1;for(let a=0;a<t.length;a++){const o=t[a],c=n[0],h=n[n.length-1];if(s(h,o[0]))n=[...n,...o.slice(1)];else if(s(h,o[o.length-1]))n=[...n,...[...o].reverse().slice(1)];else if(s(c,o[o.length-1]))n=[...o.slice(0,-1),...n];else if(s(c,o[0]))n=[...[...o].reverse().slice(0,-1),...n];else continue;t.splice(a,1),r=!0;break}}i.push(n)}return i}static nearestAlong(e,t,i){let s={s:0,distance:1/0};for(let n=0;n<e.length-1;n++){const r=e[n],a=e[n+1],o=a.x-r.x,c=a.y-r.y,h=o*o+c*c;if(h<1e-9)continue;let d=((i.x-r.x)*o+(i.y-r.y)*c)/h;n>0&&(d=Math.max(0,d)),n<e.length-2&&(d=Math.min(1,d));const u=Math.hypot(i.x-(r.x+o*d),i.y-(r.y+c*d));u<s.distance&&(s={s:t[n]+d*Math.sqrt(h),distance:u})}return s}paint(e,t,i,s){const n=new Uint8Array(i*s),r=o=>(o-t.west)/(t.east-t.west)*i,a=o=>(t.north-o)/(t.north-t.south)*s;for(const o of e)for(let c=0;c<o.length-1;c++){const h=r(o[c].lng),d=a(o[c].lat),u=r(o[c+1].lng),p=a(o[c+1].lat),f=Math.max(1,Math.ceil(Math.hypot(u-h,p-d)*2));for(let m=0;m<=f;m++){const g=Math.floor(h+(u-h)*m/f),v=Math.floor(d+(p-d)*m/f);for(let b=-1;b<=1;b++)for(let w=-1;w<=1;w++){const y=g+w,M=v+b;y>=0&&M>=0&&y<i&&M<s&&(n[M*i+y]=1)}}}return n}touching(e,t,i,s){const n=new Uint8Array(e.length),r=new Uint8Array(e.length);for(let a=0;a<e.length;a++){if(e[a]===0||r[a]===1)continue;const o=[],c=[a];r[a]=1;let h=!1;for(;c.length>0;){const d=c.pop();o.push(d),t[d]===1&&(h=!0);const u=d%i,p=(d-u)/i;for(let f=-1;f<=1;f++)for(let m=-1;m<=1;m++){const g=u+m,v=p+f;if(g<0||v<0||g>=i||v>=s)continue;const b=v*i+g;e[b]===1&&r[b]===0&&(r[b]=1,c.push(b))}}if(h)for(const d of o)n[d]=1}return n}sample(e,t,i,s,n,r){const{width:a,height:o}=t,c=new Float32Array(a*o),h=new Uint8Array(a*o),d=Math.min(r.x,this.maxWindowM)/n.x,u=Math.min(r.y,this.maxWindowM)/n.y;let p=0;for(let f=0;f<o;f++){const m=i.north+(i.south-i.north)*(o===1?.5:f/(o-1)),g=(s.north-m)/(s.north-s.south)*e.height-.5;for(let v=0;v<a;v++){const w=(i.west+(i.east-i.west)*(a===1?.5:v/(a-1))-s.west)/(s.east-s.west)*e.width-.5,y=d>1||u>1?this.tent(e,w,g,Math.max(1,d),Math.max(1,u)):this.bilinear(e,w,g),M=f*a+v;y===void 0?p++:(c[M]=y,h[M]=1)}}if(!(p===a*o||p/(a*o)>Bt.MAX_HOLE_SHARE))return this.fill(c,h,a,o),c}tent(e,t,i,s,n){let r=0,a=0,o=0;const c=Math.max(0,Math.ceil(i-n)),h=Math.min(e.height-1,Math.floor(i+n)),d=Math.max(0,Math.ceil(t-s)),u=Math.min(e.width-1,Math.floor(t+s));for(let p=c;p<=h;p++){const f=1-Math.abs(p-i)/n;if(!(f<=0))for(let m=d;m<=u;m++){const g=f*(1-Math.abs(m-t)/s);if(g<=0)continue;o+=g;const v=e.at(m,p);!Number.isFinite(v)||v<Bt.NO_DATA_BELOW||(r+=g*v,a+=g)}}return o>0&&a>=o*.5?r/a:void 0}bilinear(e,t,i){const s=Math.max(0,Math.min(e.width-1,Math.floor(t))),n=Math.max(0,Math.min(e.height-1,Math.floor(i))),r=Math.min(e.width-1,s+1),a=Math.min(e.height-1,n+1),o=Math.max(0,Math.min(1,t-s)),c=Math.max(0,Math.min(1,i-n)),h=e.at(s,n),d=e.at(r,n),u=e.at(s,a),p=e.at(r,a);for(const g of[h,d,u,p])if(!Number.isFinite(g)||g<Bt.NO_DATA_BELOW)return;const f=h+(d-h)*o,m=u+(p-u)*o;return f+(m-f)*c}fill(e,t,i,s){let n=t.reduce((r,a)=>r+(a?0:1),0);for(;n>0;){const r=[];for(let a=0;a<s;a++)for(let o=0;o<i;o++){const c=a*i+o;if(t[c])continue;let h=0,d=0;for(let u=-1;u<=1;u++)for(let p=-1;p<=1;p++){const f=a+u,m=o+p;f<0||m<0||f>=s||m>=i||!t[f*i+m]||(h+=e[f*i+m],d++)}d>0&&r.push([c,h/d])}if(r.length===0)return;for(const[a,o]of r)e[a]=o,t[a]=1;n-=r.length}}}class D8{providers;constructor(...e){this.providers=e}async getElevationGrid(e,t,i){let s=new Error("No source of relief to ask");for(const n of this.providers)try{return await n.getElevationGrid(e,t,i)}catch(r){s=r}throw s}}const B0=256,k8=5;async function EI(l,e,t,i){const s=(l.south+l.north)/2,n=(l.west+l.east)/2,r=Math.abs(lt(s,l.east,s,l.west).x),a=Math.abs(lt(l.north,n,l.south,n).z),o=Math.max(r,a),{zoom:c,gridSize:h}=R8(s,o,Math.max(e.width,e.height)),{tiles:d,bounds:u}=MI(n,s,c,h),p=h*B0,f=document.createElement("canvas");f.width=p,f.height=p;const m=f.getContext("2d");if(!m)throw new Error("2D canvas context unavailable");const g=d[0];await Promise.all(d.map(async y=>{const M=t(y),x=await i(M);if(!x.ok)throw new Error(`Imagery tile fetch failed (${x.status}): ${M}`);const S=await createImageBitmap(await x.blob());m.drawImage(S,(y.x-g.x)*B0,(y.y-g.y)*B0)}));const v=Math.min(Math.max(e.width,e.height),p);if(v===p)return{source:f,width:p,height:p,bounds:u};const b=document.createElement("canvas");b.width=v,b.height=v;const w=b.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(f,0,0,p,p,0,0,v,v),{source:b,width:v,height:v,bounds:u}}function R8(l,e,t){let i=bI(l,e/Math.max(1,t)),s=u2(l,i,e);for(;s>k8&&i>0;)i--,s=u2(l,i,e);return{zoom:i,gridSize:s,mPerPixel:wM(l,i)/B0}}function u2(l,e,t){const i=Math.ceil(t/2/wM(l,e));return Math.max(3,2*i+1)}class SI{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return EI(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Or{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(e,t=Or.ENDPOINTS){const i=/\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/.exec(e);if(!i)return[...t];const[s,n,r,a]=i.slice(1).map(Number),o=(s+r)/2,c=(n+a)/2,h=Or.FRANCE;return o>=h.south&&o<=h.north&&c>=h.west&&c<=h.east?[Or.FRANCE_ENDPOINT,...t.filter(u=>u!==Or.FRANCE_ENDPOINT)]:[...t]}fetchImpl;endpoints;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.endpoints=e.endpoints}static queue=Promise.resolve();static HANG_MS=4e4;static RETRY_MS=4e3;query(e){return this.queued(()=>this.ask(e))}queued(e){const t=Or.queue.then(e,e);return Or.queue=t.catch(()=>{}),t}async ask(e){let t;for(const i of this.endpoints??Or.endpointsFor(e))for(let s=0;s<2;s++){try{const n=await this.fetchImpl(`${i}?data=${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(Or.HANG_MS)});if(n.ok)return await n.json();if(t=new Error(`${new URL(i).host} refused (${n.status})`),n.status!==429&&n.status!==504)break}catch(n){t=new Error(`${new URL(i).host} unreachable (${String(n)})`);break}await new Promise(n=>setTimeout(n,Or.RETRY_MS))}throw t??new Error("No Overpass instance answered")}}class Wc{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(e={}){this.client=new Or(e)}async getRoads(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Wc.DRIVABLE.join("|")})$"](${t});out geom;`;return this.waysFrom(await this.client.query(i))}waysFrom(e){const t=[];for(const i of e.elements??[]){const s=i.geometry,n=i.tags;!n||!s||s.length<2||t.push({id:`osm-${i.id??t.length}`,name:n.name,surface:Wc.surfaceOf(n),widthM:Wc.widthOf(n),...Wc.paintOf(n),points:s.map(r=>({lat:r.lat,lng:r.lon}))})}return t}static paintOf(e){const t=e.highway??"",i=e.junction==="roundabout"||e.junction==="circular",s=e.oneway,n=s==="yes"||s==="1"||s==="true"||s===void 0&&(t==="motorway"||i),r=s==="-1"||s==="reverse",a=Number.parseInt(e.lanes??"",10),o=Number.parseInt(e.maxspeed??"",10),c=i?"roundabout":t==="motorway"?"motorway":t.endsWith("_link")?"slip":(t==="trunk"||t==="primary")&&(n||r)?"dual":t?"road":void 0;return{...c?{kind:c}:{},...Number.isFinite(a)&&a>0?{lanes:a}:{},...s!==void 0||t==="motorway"||i?{direction:r?"backward":n?"forward":"both"}:{},...Number.isFinite(o)&&o>0?{speedKmh:o}:{}}}static widthOf(e){const t=Number.parseFloat(e.width??e.est_width??"");if(Number.isFinite(t)&&t>0)return t;const i=Number.parseInt(e.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Wc.WIDTH_M[e.highway]??Wc.DEFAULT_WIDTH_M}static surfaceOf(e){const t=e.surface;return t==="dirt"||t==="earth"||t==="mud"?"dirt":t==="gravel"||t==="fine_gravel"||t==="compacted"||t==="ground"||t==="sand"||t==="unpaved"?"gravel":t?"paved":e.highway==="track"?"gravel":"paved"}}const kb="https://ufoathome.org/roads/index.json";class Rd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(e={}){this.sharing=!e.fetchImpl,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Rd.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getRoads(e);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(e){let t;try{t=await this.load()}catch{return}const i=t.find(({entry:s})=>s.north>=e.north&&s.south<=e.south&&s.east>=e.east&&s.west<=e.west);if(i)try{const s=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!s.ok)return;const n=await s.json();return Array.isArray(n?.ways)?(this.attributionRead=n.attribution,this.contemporaryRead=n.contemporary,n.ways):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const e=this.indexUrls.join(`
|
|
8884
|
-
`);let t=Rd.shared.get(e);return t||(t=this.fetchFirstAvailable(),Rd.shared.set(e,t),t.then(i=>{i.length===0&&Rd.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.
|
|
8885
|
-
`);let t=Cd.shared.get(e);return t||(t=this.fetchFirstAvailable(),Cd.shared.set(e,t),t.then(i=>{i.length===0&&Cd.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.191.1")}`,t=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(t&&t!==Rb?[t,Rb]:[Rb]).map(i=>i+e)}}class Sr{constructor(e){this.water=e}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(e){const t=Sr.key(e);let i=Sr.asked.get(t);return i===void 0&&(i=this.recalled(t,e),Sr.asked.set(t,i),i.catch(()=>Sr.asked.delete(t))),structuredClone(await i)}static forget(){Sr.asked.clear()}static key(e){return`v${Sr.FORMAT}/${[e.north,e.south,e.east,e.west].map(t=>t.toFixed(5)).join("/")}`}async recalled(e,t){const i=await Sr.openCache(),s=Sr.request(e);if(i)try{const r=await i.match(s);if(r){const{savedAt:a,surfaces:o}=await r.json();if(Date.now()-a<Sr.MAX_AGE_MS&&Array.isArray(o))return o;await i.delete(s)}}catch{}const n=await this.water.getWater(t);return i&&Sr.store(i,s,n),n}static async store(e,t,i){try{const s={savedAt:Date.now(),surfaces:i};await e.put(t,new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}}));const n=await e.keys();for(const r of n.slice(0,Math.max(0,n.length-Sr.MAX_STORED)))await e.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Sr.CACHE_NAME)}catch{return}}static request(e){const t=typeof location>"u"?"http://localhost":location.origin;return new Request(`${t}/__water__/${encodeURIComponent(e)}`)}}class Zc{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(e={}){this.platform=new Xt(e)}static covers(e){return Xt.covers((e.south+e.north)/2,(e.west+e.east)/2)}async getRailways(e){return(await this.platform.railways(e)).flatMap((i,s)=>Zc.linesOf(i,s))}static linesOf(e,t){const{type:i,coordinates:s}=e.geometry,n=i==="LineString"?[s]:i==="MultiLineString"?s:[],r=Zc.BY_NATURE[String(e.properties.nature??"")];if(!r)return[];const a=String(e.properties.cleabs??`ign-rail-${t}`),o=Number(e.properties.nombre_de_voies),c=Number(e.properties.position_par_rapport_au_sol),h=e.properties.cpx_toponyme,d=Zc.GAUGE_MM[String(e.properties.largeur??"")]??1435,u=Zc.electrificationOf(r.kind,d,e.properties.electrifie);return n.flatMap((p,f)=>{const m=p.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>Zc.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.length<2?[]:[{id:n.length>1?`${a}-${f}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:d,tracks:Number.isInteger(o)&&o>0?o:1,...u?{electrification:u}:{},level:Number.isFinite(c)?c:0,points:m}]})}static electrificationOf(e,t,i){if(i===!1)return"none";if(i===!0){if(e==="subway")return"third_rail";if(!(e==="funicular"||t<1435))return"overhead"}}}class kn{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(e={}){this.client=new Or(e)}async named(e,t){if(e.length===0)return[...e];const i=`${t.south},${t.west},${t.north},${t.east}`,s=`[out:json][timeout:120];way["railway"~"^(${kn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${kn.ROUTES})$"];out body;`;return kn.apply(e,await this.client.query(s),t)}static apply(e,t,i){const s={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},n=kn.ways(t,s);return n.length===0?[...e]:e.map(r=>{const a=r.points.map(v=>lt(v.lat,v.lng,s.lat,s.lng)),o=new Map,c=new Map,h=new Map;let d=0;const u=n.filter(v=>v.service===!!r.service);for(const v of kn.samples(a)){d++;const b=kn.waysAt(u,v);if(b.length===0)continue;const[w]=b;w.name&&o.set(w.name,(o.get(w.name)??0)+1),w.voltageV&&c.set(w.voltageV,(c.get(w.voltageV)??0)+1);for(const y of new Set(b.flatMap(M=>M.services)))h.set(y,(h.get(y)??0)+1)}const p=v=>[...v.entries()].sort((b,w)=>w[1]-b[1])[0]?.[0],f=r.name??p(o),m=r.voltageV??(r.electrification==="none"?void 0:p(c)),g=[...h.entries()].filter(([,v])=>v*4>=d).sort((v,b)=>b[1]-v[1]||v[0].localeCompare(b[0])).map(([v])=>v);return{...r,...f?{name:f}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}static serviceOf(e){const t=e.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return t||[e.network,e.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(e){const t=new Map;for(const i of e.elements??[]){if(i.type!=="relation"||!i.tags)continue;const s=kn.serviceOf(i.tags);if(s)for(const n of i.members??[]){if(n.type!=="way"||n.ref===void 0)continue;const r=t.get(n.ref)??new Set;r.add(s),t.set(n.ref,r)}}return t}static voltageOf(e){const t=Number.parseInt((e.voltage??"").split(";")[0],10);return Number.isFinite(t)&&t>0?t:void 0}static ways(e,t){const i=kn.servicesByWay(e),s=[];for(const n of e.elements??[]){if(n.type!=="way"||!n.geometry||n.geometry.length<2)continue;const r=n.tags??{},a=kn.voltageOf(r);s.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(n.id??-1)??[]],path:n.geometry.map(o=>lt(o.lat,o.lon,t.lat,t.lng))})}return s}static samples(e){const t=[];for(let i=0;i<e.length-1;i++){const s=Math.hypot(e[i+1].x-e[i].x,e[i+1].z-e[i].z);if(s<1e-6)continue;const n=(e[i+1].x-e[i].x)/s,r=(e[i+1].z-e[i].z)/s;for(let a=kn.SAMPLE_M/2;a<s;a+=kn.SAMPLE_M)t.push({x:e[i].x+n*a,z:e[i].z+r*a,dx:n,dz:r})}return t}static waysAt(e,t){const i=Math.cos(kn.ALIGNED_DEG*Math.PI/180),s=[];for(const n of e){let r;for(let a=0;a<n.path.length-1;a++){const o=n.path[a],c=n.path[a+1],h=c.x-o.x,d=c.z-o.z,u=Math.hypot(h,d);if(u<1e-6||Math.abs((h*t.dx+d*t.dz)/u)<i)continue;const p=Math.max(0,Math.min(1,((t.x-o.x)*h+(t.z-o.z)*d)/(u*u))),f=Math.hypot(t.x-(o.x+h*p),t.z-(o.z+d*p));f<=kn.NEAR_M&&(r===void 0||f<r)&&(r=f)}r!==void 0&&s.push({way:n,distance:r})}return s.sort((n,r)=>n.distance-r.distance).map(({way:n})=>n)}}class Od{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(e={}){this.client=new Or(e)}async getRailways(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Od.KINDS.join("|")})$"](${t})->.w;.w out tags geom;rel(bw.w)["route"~"^(${kn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(e){const t=[],i=kn.servicesByWay(e);for(const s of e.elements??[]){const n=s.geometry,r=s.tags;if(s.type==="relation"||!r||!n||n.length<2)continue;const a=[...i.get(s.id??-1)??[]].sort(),o=kn.voltageOf(r),c=Od.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),d=Number.parseInt(r.tracks??"",10),u=Od.electrificationOf(r.electrified),p=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;t.push({id:`osm-rail-${s.id??t.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...o?{voltageV:o}:{},kind:c,...r.service||r.usage==="industrial"?{service:!0}:{},...p?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(d)&&d>0?d:1,...u?{electrification:u}:{},level:Od.levelOf(r),points:n.map(f=>({lat:f.lat,lng:f.lon}))})}return t}static kindOf(e){switch(e.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(e){if(e!==void 0){if(e==="no")return"none";if(e==="contact_line"||e==="yes")return"overhead";if(e==="rail"||e==="4th_rail"||e==="ground-level_power_supply")return"third_rail"}}static levelOf(e){const t=Number.parseInt(e.layer??"",10);return e.tunnel&&e.tunnel!=="no"?Number.isFinite(t)&&t<0?t:-1:e.covered==="yes"&&e.location==="underground"?-1:e.bridge&&e.bridge!=="no"?Number.isFinite(t)&&t>0?t:1:0}}class L8{constructor(e,t){this.regional=e,this.worldwide=t}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(e){if(!Zc.covers(e))return this.worldwide.getRailways(e);let t;try{if(t=await this.regional.getRailways(e),t.length>0)return t}catch{}try{return await this.worldwide.getRailways(e)}catch(i){if(t)return t;throw i}}}class Ws{constructor(e,t=Date.now){this.railways=e,this.now=t}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(e){const t=Ws.key(e);let i=Ws.asked.get(t)??Ws.containing(e);if(i===void 0){const s=this.recalled(t,e);i={bounds:e,answer:s},Ws.asked.set(t,i),s.catch(()=>Ws.asked.delete(t))}return structuredClone(await i.answer)}static forget(){Ws.asked.clear(),Ws.failedAt=-1/0}static key(e){return`v${Ws.FORMAT}/${[e.north,e.south,e.east,e.west].map(t=>t.toFixed(5)).join("/")}`}static containing(e){for(const t of Ws.asked.values()){const i=t.bounds;if(i.north>=e.north&&i.south<=e.south&&i.east>=e.east&&i.west<=e.west)return t}}async recalled(e,t){const i=await Ws.openCache(),s=Ws.request(e);let n;if(i)try{const a=await i.match(s);if(a){const{savedAt:o,lines:c}=await a.json();if(Array.isArray(c)){if(this.now()-o<Ws.MAX_AGE_MS)return c;n=c}}}catch{}if(this.now()-Ws.failedAt<Ws.RETRY_AFTER_MS){if(n)return n;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(t)}catch(a){if(Ws.failedAt=this.now(),n)return n;throw a}return i&&Ws.store(i,s,{savedAt:this.now(),lines:r}),r}static async store(e,t,i){try{await e.delete(t),await e.put(t,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const s=await e.keys();for(const n of s.slice(0,Math.max(0,s.length-Ws.MAX_STORED)))await e.delete(n)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Ws.CACHE_NAME)}catch{return}}static request(e){const t=typeof location>"u"?"http://localhost":location.origin;return new Request(`${t}/__railways__/${encodeURIComponent(e)}`)}}const Cb="https://ufoathome.org/railways/index.json";class Ld{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(e={}){this.sharing=!e.fetchImpl,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Ld.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getRailways(e);return this.attributionRead=this.fallback.attribution,i}async held(e){const i=(await this.load().catch(()=>[])).find(({entry:s})=>s.north>=e.north&&s.south<=e.south&&s.east>=e.east&&s.west<=e.west);if(i)try{const s=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!s.ok)return;const n=await s.json();return Array.isArray(n?.lines)?(this.attributionRead=n.attribution,n.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const e=this.indexUrls.join(`
|
|
8886
|
-
`);let t=Ld.shared.get(e);return t||(t=this.fetchFirstAvailable(),Ld.shared.set(e,t),t.then(i=>{i.length===0&&Ld.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.191.1")}`,t=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(t&&t!==Cb?[t,Cb]:[Cb]).map(i=>i+e)}}function AI(){return{elevation:TI(),imagery:II(),roads:_I(),water:DI(),railways:kI()}}function TI(){return new D8(new Bt,new xI)}function II(){return new SI}function _I(){return new Rd({fallback:new C8(new jc,new Wc)})}function DI(){return new Cd({fallback:new Sr(new O8(new Pf,new jl))})}function kI(){return new Ld({fallback:new Ws(new L8(new Zc,new Od))})}const P8=new Set,tu="show-observer-map",iu="hide-milestones",ah="minified";class Zt extends HTMLElement{static get observedAttributes(){return["src",tu,iu,ah]}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 vi;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=rv.create();issues=[];issueCheck=0;sightingAudio=new h2;liveSightingAudio;hearInto(e){e?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new h2(e)):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>Zt.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 e=this.controlsRow,t=e.classList.contains("more-open"),i=()=>e.scrollWidth>e.clientWidth+1,s=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,e.classList.remove("narrow","more-open","nomoments","compact","tiny"),e.clientWidth>0&&i()){e.classList.add("narrow");for(const n of["nomoments","compact","tiny"]){if(!i())break;e.classList.add(n)}t&&e.classList.add("more-open")}this.momentsMenu.hidden=!s,this.updateMoreButton()}setControlsFolded(e){this.controlsRow.classList.toggle("more-open",!e),this.updateMoreButton()}updateMoreButton(){const e=this.controlsRow.classList.contains("more-open");Zt.setIcon(this.moreButton,e?Je.UNFOLDED:Je.FOLDED);const t=e?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=t,this.moreButton.setAttribute("aria-label",t),this.moreButton.setAttribute("aria-expanded",String(e))}addControl(e){this.controlsRight.insertBefore(e,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(e){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!e){this.fitControls();return}const t=document.createElement("button");t.type="button",t.id="video-button",t.innerHTML=Je.VIDEO,this.videoElement=t,this.labelVideoButton(),t.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(e,t)},{once:!0}),this.moreButton.after(t),this.fitControls()}async loadVideoButton(e,t){const{VideoButton:i}=await V(async()=>{const{VideoButton:n}=await import("./VideoButton-CqCZ65oK.js");return{VideoButton:n}},[],import.meta.url);if(this.videoElement!==t)return;const s=new i(e,t);this.videoButton=s,this.messages&&(s.messages=this.messages),this.stageElement.append(s.panel),s.open()}labelVideoButton(){const e=this.videoElement;!e||this.videoButton||(e.title=this.messages?.recordVideo??"",e.setAttribute("aria-label",e.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(e){e!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,e&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(e){const t=this.currentTime,i=e.caption&&this.sighting.milestones.length>0?Bm(this.sighting.milestones,t):void 0,s=i?this.said.read(i.label)??"":void 0,n=this.canvas.getBoundingClientRect(),r=e.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:s,note:this.said.read(i.note)}}:{},...e.time?{time:this.formatPosition(t)}:{},...r&&n.width>0&&n.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-n.left)/n.width,top:(r.top-n.top)/n.height,width:r.width/n.width,height:r.height/n.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=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),i=t&&this.shapeAt(t.x,t.y),s=this.said.read(i?.shape.title);if(!s){this.tooltip.hidden=!0;return}this.tooltip.textContent=s,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-n.left+12}px`,this.tooltip.style.top=`${e.clientY-n.top+12}px`};handleObserverMapPointerMove=e=>{if(this.dragObserverMap(e))return;const t=this.observerMapTargetFrom(e);if(!t){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(e,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(e,t.label)};showObserverMapTooltip(e,t){this.tooltip.textContent=t,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-i.left+12}px`,this.tooltip.style.top=`${e.clientY-i.top+12}px`}handleObserverMapClick=e=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const t=this.observerMapTargetFrom(e);if(!t){this.observerPlacing&&this.placeObserverFrom(e);return}if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(e){const t=this.observerMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.observerMapRenderer.hitTest((e.clientX-t.left)/t.width*this.observerMapCanvas.width,(e.clientY-t.top)/t.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=e=>{e.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:!1})};handleObserverMapPointerUp=e=>{const t=this.observerMapDrag;!t||t.pointerId!==e.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),t.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(e.pointerId)&&this.observerMapCanvas.releasePointerCapture(e.pointerId)))};dragObserverMap(e){const t=this.observerMapDrag;if(!t||t.pointerId!==e.pointerId)return!1;if(!t.moved){if(Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<Zt.OBSERVER_MAP_DRAG_PX)return!1;t.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(e.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((e.clientX-t.lastX)/i.width,(e.clientY-t.lastY)/i.height),this.observerMapViewChanged()),t.lastX=e.clientX,t.lastY=e.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=e=>{e.preventDefault();const t=this.observerMapCanvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=e.deltaMode===0?e.deltaY:e.deltaY*40;this.zoomObserverMap((e.clientX-t.left)/t.width,(e.clientY-t.top)/t.height,Math.exp(-i*.002))};zoomObserverMap(e,t,i){this.observerMapView.zoomAt(e,t,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=vi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=vi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Zt.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(e){const t=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!t||i.width===0||i.height===0)return;const s=vi.pointAt(t,(e.clientX-i.left)/i.width,(e.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:s,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${p8}</style>${u8}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Au(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 ql(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 t=this.shadow.getElementById("mini-bar"),i=t.querySelector(".mini-track"),s=a=>{const o=i.getBoundingClientRect(),c=this.player.seekableDuration;if(o.width<=0||c<=0)return;const h=Math.min(Math.max((a.clientX-o.left)/o.width,0),1)*c;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let n=!1;t.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),t.setPointerCapture(a.pointerId),t.classList.add("scrubbing"),n=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,s(a))}),t.addEventListener("pointermove",a=>{t.hasPointerCapture(a.pointerId)&&s(a)});const r=a=>{t.classList.contains("scrubbing")&&(t.classList.remove("scrubbing"),t.hasPointerCapture(a.pointerId)&&t.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,n&&this.play())};t.addEventListener("pointerup",r),t.addEventListener("pointercancel",r),t.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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}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(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),e===tu&&this.applyObserverMapDefault(),e===iu&&this.setMilestonesShown(!this.hasAttribute(iu)),e===ah){const s=this.minified;this.stageElement.classList.toggle("minified",s),s&&t===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(ah)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=e=>{!this.minified||e.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=e=>{!this.minified||e.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(RI)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const e=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",e),e&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(e){this.sightingData=await Fa.recording(e)}get sightingData(){return Rf(this.currentSighting)}set sightingData(e){const t=En.recording(e);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=qf(t),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,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(e){this.titleOverride=e,this.syncPlayerTitle()}titleOverride;set titleShown(e){this.titleHidden=!e,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const e=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=e,this.playerTitleBox.hidden=e===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(e,t){const i=++this.issueCheck;let s=[];try{const{default:n}=await V(async()=>{const{default:r}=await import("./sightingSchema-CgwoRMl-.js");return{default:r}},[],import.meta.url);s=new la(n).issues(e)}catch{}i===this.issueCheck&&(this.issues=[...s,...t.loadIssues],Lf.warn(this.issues,t.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(F8,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const e=this.issues.length;this.issuesBox.hidden=e===0,this.shadow.getElementById("issues-count").textContent=String(e);const t=(this.messages?.recordingIssues??"").replace("{count}",String(e));this.issuesButton.title=t,this.issuesButton.setAttribute("aria-label",t),this.shadow.getElementById("issues-title").textContent=t,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const s=document.createElement("li");return s.textContent=Lf.text(i,this.messages.issueTemplates),s}))}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){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(e){if(e!==this.clockHeld){if(this.clockHeld=e,e){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(e){this.cited=[...e],this.refreshCitedMarks()}refreshCitedMarks(){const e=this.player.seekableDuration;this.citedMarks.replaceChildren(...(e>0?this.cited:[]).map(t=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=de.INTERVIEW,i.style.left=`${Math.min(Math.max(t.at*1e3/e,0),1)*100}%`;const s=t.quote??"";return i.title=s,i.setAttribute("aria-label",s),i.addEventListener("click",()=>this.player.seek(t.at*1e3)),i}))}sayTimeMoved(e){Math.abs(e-this.timeSaid)<Zt.TIME_SAID_EVERY_MS||(this.timeSaid=e,this.dispatchEvent(new CustomEvent(N8,{bubbles:!0,composed:!0,detail:{at:e/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(e){this.toolbar.classList.toggle("hidden",!e),e?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(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=t,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==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(e){const t=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(e)for(const i of t)e.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const s of t)this.controlsRight.insertBefore(s,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 e=this.currentSighting.references;if(!this.referenceOpacityTouched&&e.length>0){const t=String(e[0].opacity);this.referenceOpacityInput.value!==t&&(this.referenceOpacityInput.value=t,this.severalReferences||this.dispatchReferenceView())}for(const t of[...this.referenceViews.keys()])e.some(i=>i.id===t)||this.referenceViews.delete(t);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(e){let t=this.referenceViews.get(e.id);return t||(t={shown:!0,opacity:e.opacity},this.referenceViews.set(e.id,t)),t}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=e=>{const t=e.composedPath();t.includes(this.referencesMenu)||t.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=e=>{e.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const e=this.referencesButton.getBoundingClientRect(),t=this.referencesMenu,i=4;t.style.bottom=`${Math.max(i,window.innerHeight-e.top+i)}px`,t.style.top="auto";const s=t.getBoundingClientRect().width;t.style.left=`${Math.max(i,Math.min(e.left,window.innerWidth-s-i))}px`}renderReferencesMenu(){const e=this.currentSighting.references.map(t=>{const i=this.viewOfReference(t),s=this.said.read(t.title)??t.id,n=document.createElement("div");n.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const o=document.createElement("span");o.textContent=s,o.title=s,r.append(a,o);const c=document.createElement("input");return c.type="range",c.min="0",c.max="1",c.step="0.05",c.value=String(i.opacity),c.title=this.messages?.referenceOpacity??"",c.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${s}`),c.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,c.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),c.addEventListener("input",()=>{i.opacity=Number(c.value),this.dispatchReferenceView()}),n.append(r,c),n});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...e)}updateReferencesButton(){const e=this.currentSighting.references.length>0,t=this.severalReferences,i=t?this.currentSighting.references.some(n=>this.viewOfReference(n).shown):this.referencesShownState;this.referencesButton.hidden=!e,this.referenceOpacityInput.hidden=!e||!this.referencesShownState||t,this.referencesButton.setAttribute("aria-pressed",String(i)),t?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),Zt.setIcon(this.referencesButton,i?Je.PICTURES_ON:Je.PICTURES_OFF);const s=t?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=s,this.referencesButton.setAttribute("aria-label",s),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)),Zt.setIcon(this.tracesButton,this.tracesShownState?Je.TRACES_ON:Je.TRACES_OFF);const e=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=e,this.tracesButton.setAttribute("aria-label",e)}dispatchReferenceView(){const e=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(t=>[t.id,{...this.viewOfReference(t)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:e}}))}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?mh(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(i=>{const s=document.createElement("button");s.type="button",s.className="milestone-mark",s.style.left=`${Math.min(Math.max(i.t/e,0),1)*100}%`;const n=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${n} — ${r}`:n;return s.title=a,s.setAttribute("aria-label",a),s.dataset.t=String(i.t),s.addEventListener("click",()=>this.player.seek(i.t)),s})),this.refreshCitedMarks(),this.refreshSeekSegments(e,t.map(i=>i.t)),this.refreshMomentsPicker(t)}refreshMomentsPicker(e){const t=this.milestonesShown&&e.length>0;this.momentsBox.hidden=!t,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...e.map(i=>{const s=document.createElement("li"),n=document.createElement("button");n.type="button",n.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return n.textContent=a?`${r} — ${a}`:r,n.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),s.appendChild(n),s})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(e){const i=(e?this.said.read(e.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const s of this.momentsMenu.querySelectorAll("button")){const n=e!==void 0&&Number(s.dataset.t)===e.t;s.getAttribute("aria-current")==="true"!==n&&s.setAttribute("aria-current",String(n))}}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=e=>{if(!this.momentsMenu.hidden){if(e instanceof KeyboardEvent){e.key==="Escape"&&this.closeMomentsMenu();return}e.composedPath().some(t=>t===this.momentsMenu||t===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(e,t){const s=[0,...this.milestonesShown&&e>0?[...new Set(t.filter(r=>r>0&&r<e))].sort((r,a)=>r-a):[],Math.max(e,0)];this.seekSegmentList=[];const n=[];for(let r=0;r<s.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(s[r+1]-s[r],1));const o=document.createElement("i");o.className="seek-hover";const c=document.createElement("i");c.className="seek-played",a.append(o,c),n.push(a),this.seekSegmentList.push({start:s[r],end:s[r+1],element:a,played:c,hover:o})}this.seekSegments.replaceChildren(...n),this.paintSeekProgress(this.player.time)}static fillOf(e,t){const i=e.end-e.start,s=i>0?(t-e.start)/i:t>=e.end?1:0;return`${Math.min(Math.max(s,0),1)*100}%`}paintMiniProgress(e){const t=this.player.seekableDuration,i=`${t>0?Math.min(Math.max(e/t,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(e)}miniDot;miniScrubTime;paintSeekProgress(e){for(const i of this.seekSegmentList)i.played.style.width=Zt.fillOf(i,e);const t=this.player.seekableDuration;this.seekDot.style.left=`${t>0?Math.min(Math.max(e/t,0),1)*100:0}%`}hoverSeek(e){if(e.buttons!==0){this.seekPreview.hidden=!0;return}const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=Math.min(Math.max((e.clientX-t.left)/t.width,0),1),n=s*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((p,f)=>{p.hover.style.width=Zt.fillOf(p,n),p.element.classList.toggle("hovered",n>=p.start&&(n<p.end||f===r))});const a=this.milestonesShown?this.sighting.milestones:[],o=a.length>0?Bm(a,n):void 0,c=o?this.said.read(o.label)??"":"",h=o?this.said.read(o.note):void 0,d=h?`${c} — ${h}`:c;this.seekPreviewTitle.textContent=d,this.seekPreviewTime.textContent=this.formatPosition(n),this.seekPreview.hidden=!1;const u=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(s*t.width-u/2,0),Math.max(t.width-u,0))}px`,this.paintSeekPreview(n)}leaveSeek(){for(const e of this.seekSegmentList)e.hover.style.width="0",e.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(e){const t=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=t===void 0,t?.(e,this.seekPreviewCanvas)}paintChrome(e){const t=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const s=this.chromeCanvas.clientWidth,n=this.chromeCanvas.clientHeight;if(!t||typeof t.setTransform!="function"||s===0||n===0){e(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(s*r)),o=Math.max(1,Math.round(n*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==o&&(this.chromeCanvas.height=o),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,a,o),this.chromeDirty=!1,i&&(t.setTransform(a/this.canvas.width,0,0,o/this.canvas.height,0,0),this.chromeRenderer??=new Au(t),this.chromeDirty=!0,e(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(e){if(e.pointerType!=="mouse"){this.scrubbingPointer=e.pointerId;try{this.seekInput.setPointerCapture(e.pointerId)}catch{}this.seekToPointer(e)}}touchScrub(e){e.pointerId===this.scrubbingPointer&&this.seekToPointer(e)}endTouchScrub(e){e.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(e))}seekToPointer(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=Math.min(Math.max((e.clientX-t.left)/t.width,0),1);this.player.seek(this.snapSeekToMark(s*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(e){const t=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(t<=0||i<=0)return;const s=Zt.MARK_SNAP_PX/i*t;let n;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-e)>s||(!n||Math.abs(a-e)<Math.abs(n.t-e))&&(n={t:a,name:r.title})}return n}snapSeekToMark(e){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(e)?.t??e):e}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=(e.clientX-t.left)/t.width*i,n=this.markNear(s);n?this.seekInput.title=n.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?Bm(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,this.showCurrentMoment(t),!t)return;const i=document.createElement("b");i.textContent=this.said.read(t.label)??"";const s=this.said.read(t.note),n=s?` — ${s}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(n))}exposureInstants(e){const t=this.exposureTimes(e),i=1/t.length;return t.map(s=>({shapes:this.shapesAt(s),share:i}))}exposureTimes(e=this.currentTime){const t=$n.windowEndingAt(e,this.currentSighting.exposure??0);if(t.ms<Zt.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const i=Math.min(Zt.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t.ms/Zt.SHORTEST_VISIBLE_EXPOSURE_MS))),s=Math.ceil(this.travelPxOver(t.fromMs,t.ms)/Zt.EXPOSURE_STEP_PX),n=Math.min(Zt.MAX_TRAVEL_STEPS,Math.max(i,s)),r=[];for(let a=0;a<n;a++)r.push(t.fromMs+t.ms*a/(n-1));return r}travelPxOver(e,t){const i=this.shapesAt(e),s=this.shapesAt(e+t);let n=0;for(const[r,a]of i){const o=s.get(r);if(!o)continue;const c=o.bounds.x+o.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=o.bounds.y+o.bounds.height/2-(a.bounds.y+a.bounds.height/2);n=Math.max(n,Math.hypot(c,h))}return n}shapeAt(e,t,i){if(!this.accountHidden)for(const s of this.exposureTimes()){const n=this.currentSighting.timeline.hitTest(s,e,t,i);if(n)return n}}shapesAt(e){const t=new Map;for(const i of this.currentSighting.timeline.sourceIds){const s=this.currentSighting.timeline.getInterpolatedShapeAt(e,i);s&&t.set(i,s)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=Vt.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(e,t){this.sayTimeMoved(e),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:P8;this.canvasRenderer.setStarPoints(Vt.starPointsOf(this.sighting.instrument,et(this.sighting,e)?.fNumber));const s=(et(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(s*Math.PI/180);const n=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of n)for(const[,c]of o.shapes){const h=o.share,d=h===1?c:{...c,transparency:1-(1-c.transparency)*h};this.canvasRenderer.paintShape(this.shifted(d,r))}for(const[o,c]of n[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));const a=this.selectionShown&&i.size>1?ai.groupBoundsFor([...t].filter(([o])=>i.has(o)).map(([,o])=>o.bounds)):void 0;this.chromeDraw=o=>{a&&o.paintGroupHandles(a),this.overlayPainter?.(o)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=n.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(e),this.paintSeekProgress(e),this.minified&&this.paintMiniProgress(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintObserverMap(e),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(Vw(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new f8(this.currentSighting.timeline,(t,i)=>this.onFrame(t,i));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=e=>{e.key.toLowerCase()!=="f"||e.altKey||e.ctrlKey||e.metaKey||!this.enableClickToPlay||e.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(e.preventDefault(),this.toggleFullscreen())};handleSeekKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;const t=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0;if(t){e.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+t*Zt.SEEK_KEY_STEP_MS)))}else e.key===" "&&(e.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 e=this.playbackFlash;e.innerHTML=this.player.playbackState==="playing"?Je.PLAY:Je.PAUSE,e.classList.remove("flashing"),e.offsetWidth,e.classList.add("flashing")}static icons=new WeakMap;static setIcon(e,t){Zt.icons.get(e)!==t&&(Zt.icons.set(e,t),e.innerHTML=t)}set captionHeld(e){this.stageElement.classList.toggle("caption-held",e)}set controlsHeld(e){this.stageElement.classList.toggle("controls-held",e)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(e){this.quietControlsValue=e,this.stageElement.classList.toggle("quiet",e)}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},Zt.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!e),e!==this.wasPlaying&&e&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=e,this.updateStartState(),Zt.setIcon(this.playPauseButton,e?Je.PAUSE:Je.PLAY);const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const i=t?e?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 e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const e=this.observerMapPanel.hidden;this.observerMapAsked=e,this.setObserverMapOpen(e),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:e}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const e=this.getAttribute(tu),t=e===null?this.sighting.observerMap??this.observerPath?.travels===!0:e!=="false";this.setObserverMapOpen(t&&this.observerPath!==void 0)}setObserverMapOpen(e){this.observerMapPanel.hidden=!e,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(e)),this.updateObserverMapButton(),e&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const e=!this.observerMapPanel.hidden;Zt.setIcon(this.observerMapButton,e?Je.MAP_ON:Je.MAP_OFF);const t=e?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=t,this.observerMapButton.setAttribute("aria-label",t);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[s,n]of i)s.title=n,s.setAttribute("aria-label",n)}updateObserverMap(){const e=this.observerPath!==void 0;if(this.observerPath=vh.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!e&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const t=this.tracesShownState?this.currentSighting.traces.flatMap(s=>s.points):[],i=vi.fitted(this.observerPath,t);(!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(e,t){const i=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<i&&Math.abs(e.south-t.south)<i&&Math.abs(e.west-t.west)<i&&Math.abs(e.east-t.east)<i}async loadObserverMapImagery(){const e=this.observerMapViewBounds;if(!e||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(e)))return;const t=this.observerMapView.changed,i=t?vi.expand(e,Zt.OBSERVER_MAP_IMAGERY_AHEAD):e,s=vi.IMAGERY_PX*(t?1+2*Zt.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=e.east-e.west,this.observerMapImageryLoading=!0;const n=this.observerMapSnapshotImagery,r=n?void 0:II();try{const a=r?await r.getImageryTexture(i,{width:s,height:s}):await n.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??n).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(e){const t=this.observerMapImageryBounds;if(!t)return!0;const i=this.observerMapImagery?.bounds??t,s=this.observerMapView.changed?vi.expand(e,Zt.OBSERVER_MAP_IMAGERY_LOOKAHEAD):e,n=s.west>=i.west&&s.east<=i.east&&s.south>=i.south&&s.north<=i.north,r=e.east-e.west>this.observerMapImageryViewWidth/2;return!n||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(e){e!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=e,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(e){this.mapSceneBounds=e.map(t=>({x:t.x*this.canvas.width,y:t.y*this.canvas.height,width:t.width*this.canvas.width,height:t.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const e=this.observerMapBoxPx;if(!e)return;const t=[...this.mapShapeBounds,...this.mapSceneBounds],i=(c,h,d)=>{for(const u of t)if(!(u.x+u.width<c-d||u.x>h+d)&&!(u.y>e.bottom+d||u.y+u.height<e.top-d))return!0;return!1},s=[this.canvas.width-e.width,this.canvas.width],n=[0,e.width],r=Zt.OBSERVER_MAP_CLEARANCE_PX,a=i(...s,0),o=i(...n,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&o&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(o||!i(s[0],s[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(s[0],s[1],0)&&!i(n[0],n[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const e=this.observerMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==t&&(this.observerMapCanvas.width=t,this.observerMapCanvas.height=t)}measureObserverMapBox(){const e=this.observerMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=this.canvas.width/t.width,s=this.canvas.height/t.height;this.observerMapBoxPx={width:e.width*i,top:(e.top-t.top)*s,bottom:(e.bottom-t.top)*s}}paintObserverMap(e){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const t=et(this.currentSighting,e);t?.lat!==void 0&&t.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:t.lat,lng:t.lng},Zt.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,s=[],n=this.currentSighting.milestones.length>0?Bm(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?mh(this.currentSighting.milestones):[]){const a=et(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||s.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===n})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?jr.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(Vt.aspectOf(i)):void 0,markers:s,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(e),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.momentsBox.hidden=!e||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,mh(this.sighting.milestones).map(t=>t.t)),this.milestonesButton.setAttribute("aria-pressed",String(e)),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??"",Zt.setIcon(this.milestonesButton,this.milestonesShown?Je.MILESTONES_ON:Je.MILESTONES_OFF);const e=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}observerMapDecorAt(e){const t=et(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const s=Qr(i,e),{lat:n,lng:r}=br(s.eastM,-s.northM,t.lat,t.lng);return{lat:n,lng:r,headingDeg:s.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.observerMapNightFraction&&(this.observerMapNightFraction=t,this.paintObserverMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,i=this.lookPitchDeg+e.pitchDeg;if(t===0&&i===0)return{x:0,y:0};const s=et(this.currentSighting,this.currentTime),n=jr.of(this.currentSighting.instrument,this.canvas.height,s?.fovDeg??60);return{x:-n.angleDegToRadiusPx(t),y:n.angleDegToRadiusPx(i)}}gaitAt(e){return Ti.bodyAt(this.currentSighting,e,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(e){e!==this.mutedState&&(this.mutedState=e,!e&&this.volumeState===0&&(this.volumeState=Zt.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(e){this.setVolume(e)}setVolume(e){this.volumeState=Math.min(Math.max(e,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 e=!this.hasSound;this.miniMuteButton.hidden=e,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),Zt.setIcon(this.miniMuteButton,this.mutedState?Je.MUTED:Je.VOLUME);const t=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=t,this.miniMuteButton.setAttribute("aria-label",t),this.muteButton.disabled=e,this.volumeInput.hidden=e,e){Zt.setIcon(this.muteButton,Je.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}Zt.setIcon(this.muteButton,this.mutedState?Je.MUTED:Je.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 e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;Zt.setIcon(this.fullscreenButton,e?Je.EXIT_FULLSCREEN:Je.ENTER_FULLSCREEN),this.fullscreenButton.title=e?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Fs(Us.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Ha(Us.preferencesFor(this),Ba);if(e===this.messagesLanguage)return;this.messagesLanguage=e;const t=await k_.load(e);this.messagesLanguage===e&&this.applyMessages(t)}messagesLanguage;updateTimeLabelTitles(){const e=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+t,this.timeEndLabel.title=(this.messages?.duration??"")+t,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(e){this.messages=e,this.videoButton&&(this.videoButton.messages=e),this.labelVideoButton(),this.volumeInput.title=e.volume,this.volumeInput.setAttribute("aria-label",e.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 e=this.currentSighting.event,t=Ah(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Yy(e.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(e){if(this.realDurationMs===void 0)return Cc(e);const t=this.currentSighting.timeline.duration,i=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?f2(p2(this.realStartMs+i)):Cc(i)}formatElapsedAt(e){const t=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?Cc(e):Cc(t>0&&e<=t?e/t*this.realDurationMs:e)}formatRemaining(e){const t=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return Cc(Math.max(0,t-e));const i=t>0&&e<=t?e/t*this.realDurationMs:e;return Cc(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?Cc(this.currentSighting.timeline.duration):this.canShowClockTime?f2(p2(this.realStartMs+this.realDurationMs)):Cc(this.realDurationMs)}}function p2(l){const e=new Date(l);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function f2(l){if(l.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return l.second?`${e(l.hour)}:${e(l.minute??0)}:${e(l.second)}`:`${e(l.hour)}:${e(l.minute??0)}`}function Cc(l){const e=Math.round(l/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const Y1="rr0-ufo";function gv(){customElements.get(Y1)||customElements.define(Y1,Zt)}const N8="timechange",F8="recordingissues",RI="minifiedreset";class Ip{constructor(e,t){this.seekInput=e,this.layer=t,e.addEventListener("pointerdown",i=>{this.snapArmed=!0,this.nameMarkUnder(i)}),e.addEventListener("pointerup",()=>this.snapArmed=!1),e.addEventListener("pointermove",i=>this.nameMarkUnder(i)),e.addEventListener("pointerleave",()=>e.removeAttribute("title"))}static SNAP_PX=6;marks=[];duration=0;drawn="";snapArmed=!1;show(e,t){const i=t>0?[...e].sort((n,r)=>n.t-r.t):[],s=`${t}|${i.map(n=>`${n.kind}:${n.t}:${n.label}`).join("|")}`;s!==this.drawn&&(this.drawn=s,this.marks=i,this.duration=t,this.layer.replaceChildren(...i.map(n=>{const r=document.createElement("span");return r.className=`timeline-mark ${n.kind}`,r.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`,r})))}snap(e){return this.snapArmed?(this.snapArmed=!1,this.markNear(e)?.t??e):e}next(e){return this.marks.find(t=>t.t>e+Ip.SAME_INSTANT)?.t}previous(e){return[...this.marks].reverse().find(t=>t.t<e-Ip.SAME_INSTANT)?.t}static SAME_INSTANT=.5;markNear(e){const t=this.seekInput.getBoundingClientRect().width;if(this.duration<=0||t<=0)return;const i=Ip.SNAP_PX/t*this.duration;let s;for(const n of this.marks)Math.abs(n.t-e)>i||(!s||Math.abs(n.t-e)<Math.abs(s.t-e)||n.t===s.t&&n.kind==="milestone")&&(s=n);return s}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect();if(t.width<=0||this.duration<=0)return;const i=this.marksNear((e.clientX-t.left)/t.width*this.duration);i?this.seekInput.title=i:this.seekInput.removeAttribute("title")}marksNear(e){const t=this.markNear(e);if(t)return[...new Set(this.marks.filter(i=>i.t===t.t).map(i=>i.label))].join(" · ")}}class Pd{static HALF_SPAN_MS=2e3;static MIN_SPEED_MS=1;static at(e,t,i){const s=e.event.place?.[0],n=e.observerTrack;if(!s)return 0;const r=m=>{const g=n.getInterpolatedPoseAt(Math.max(0,m));if(!g||g.lat===void 0||g.lng===void 0)return;const v=lt(g.lat,g.lng,s.lat,s.lng);return{eastM:v.x,northM:-v.z,heading:g.headingDeg,aboveM:g.elevationM??0,altitudeM:g.altitudeM}},a=r(t-Pd.HALF_SPAN_MS),o=r(t+Pd.HALF_SPAN_MS),c=r(t);if(!a||!o||!c)return 0;const h=Math.hypot(o.eastM-a.eastM,o.northM-a.northM),d=2*Pd.HALF_SPAN_MS/1e3;if(h/d<Pd.MIN_SPEED_MS)return 0;const u=o.altitudeM!==void 0&&a.altitudeM!==void 0?o.altitudeM-a.altitudeM:i.heightAt(o.eastM,o.northM)+o.aboveM-i.heightAt(a.eastM,a.northM)-a.aboveM,p=Math.atan2(u,h)*180/Math.PI;if(c.heading===void 0)return p;const f=Math.atan2(o.eastM-a.eastM,o.northM-a.northM)*180/Math.PI;return p*Math.max(0,Math.cos((c.heading-f)*Math.PI/180))}}const U8=.08,m2=.15,g2=2,B8=2e3;class v2{context;constructor(e){this.context=e}noiseBuffer;voices=new Map;level=1;master;paused=!0;requested=[];resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("VehicleAudio: Web Audio unavailable, vehicles stay silent:",e);return}}ta.isLive(this.context)&&ta.unlock(this.context),this.apply()}setLevel(e){this.level=e,this.master&&(this.master.gain.value=e)}setPaused(e){e!==this.paused&&(this.paused=e,this.apply())}setVoices(e){this.requested=e,this.apply()}dispose(){for(const e of[...this.voices.keys()])this.release(e);ta.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0}masterOf(e){return this.master||(this.master=e.createGain(),this.master.gain.value=this.level,this.master.connect(e.destination)),this.master}apply(){const e=this.context;if(!e)return;const t=this.paused?[]:this.requested.filter(s=>s.inside||s.distanceM<B8),i=new Set(t.map(s=>s.id));for(const s of[...this.voices.keys()])i.has(s)||this.release(s);for(const s of t){const n=this.voices.get(s.id)??this.build(e,s.id);this.retarget(e,n,s)}}build(e,t){const i=e.createGain();i.gain.value=0;const s=e.createBiquadFilter();s.type="lowpass",s.connect(i).connect(this.masterOf(e));const n=e.createOscillator();n.type="sawtooth";const r=e.createOscillator();r.type="sine";const a=e.createGain(),o=e.createBiquadFilter();o.type="lowpass",o.frequency.value=900,n.connect(o),r.connect(o),o.connect(a).connect(s);const c=()=>{const M=e.createBufferSource();return M.buffer=this.noise(e),M.loop=!0,M.loopStart=Math.random()*g2*.5,M},h=c(),d=e.createBiquadFilter();d.type="bandpass",d.Q.value=4;const u=e.createGain();h.connect(d).connect(u).connect(s);const p=c(),f=e.createBiquadFilter();f.type="lowpass",f.frequency.value=600;const m=e.createGain();p.connect(f).connect(m).connect(s);const g=c(),v=e.createBiquadFilter();v.type="bandpass",v.frequency.value=1400,v.Q.value=.7;const b=e.createGain();g.connect(v).connect(b).connect(s);const w=[n,r,h,p,g];for(const M of w)M.start();const y={nodes:[i,s,a,o,d,u,f,m,v,b,...w],sources:w,firing:n,crank:r,knock:d,engineGain:a,knockGain:u,roadGain:m,windGain:b,cabin:s,output:i};return this.voices.set(t,y),y}retarget(e,t,{profile:i,state:s,noise:n,inside:r,windowsOpen:a,distanceM:o}){const c=e.currentTime,h=(b,w)=>b.setTargetAtTime(w,c,U8),d=s.rpm/60,u=d*i.cylinders/2,p=Math.min(1,s.rpm/i.shiftUpRpm),f=Math.min(1.5,s.speedMps/30);h(t.firing.frequency,u),h(t.crank.frequency,d),h(t.knock.frequency,u*3),h(t.engineGain.gain,i.engineGain*(.25+.75*s.load)*(.5+.5*p)*.3),h(t.knockGain.gain,i.roughness*(.2+.8*s.load)*.4),h(t.roadGain.gain,i.roadGain*f**1.5*.8);const m=!r||a;h(t.windGain.gain,f**2*(m?.5:.06));const g=r?a?3500:700:8e3/(1+o/60);h(t.cabin.frequency,g);const v=r?.5:Math.min(1,8/Math.max(o,1));h(t.output.gain,v*n)}release(e){const t=this.voices.get(e);if(!t)return;this.voices.delete(e);const i=this.context;i&&(t.output.gain.setTargetAtTime(0,i.currentTime,m2/3),setTimeout(()=>{for(const s of t.sources)try{s.stop()}catch{}for(const s of t.nodes)s.disconnect()},m2*1e3*3))}noise(e){if(this.noiseBuffer)return this.noiseBuffer;const t=e.createBuffer(1,e.sampleRate*g2,e.sampleRate),i=t.getChannelData(0);for(let s=0;s<i.length;s++)i[s]=Math.random()*2-1;return this.noiseBuffer=t,t}}class Nf{static BY_KIND={car:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},generic:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},van:{cylinders:4,idleRpm:750,kmhPer1000Rpm:[7,12,19,27,35,42],shiftUpRpm:2600,shiftDownRpm:1200,engineGain:.8,roadGain:.7,roughness:.45},truck:{cylinders:6,idleRpm:600,kmhPer1000Rpm:[5,8,12,17,23,30,38,48],shiftUpRpm:1900,shiftDownRpm:1e3,engineGain:1,roadGain:.9,roughness:.55},motorcycle:{cylinders:2,idleRpm:1100,kmhPer1000Rpm:[12,18,24,30,35,40],shiftUpRpm:6e3,shiftDownRpm:2500,engineGain:.9,roadGain:.3,roughness:.3}};static of(e){return Nf.BY_KIND[e??"generic"]??Nf.BY_KIND.generic}}class Rn{static ROAD_KINDS=["car","van","truck","motorcycle","generic"];static OPEN_AIR=[0,0,0,0,0,0,0,0];static ROAD_CLOSED_DB=[10,14,18,22,25,28,30,32];static WINDOWS_OPEN_DB=[2,3,4,5,6,7,8,9];static FUSELAGE_DB=[14,18,23,28,32,36,38,40];static CANOPY_DB=[3,4,6,8,10,12,14,16];static CANOPIED=["glider","balloon","ultralight"];static isRoad(e){return Rn.ROAD_KINDS.includes(e)}static roadOf(e){return e&&Rn.isRoad(e.kind)?e.kind:void 0}static aircraftOf(e){return e&&!Rn.isRoad(e.kind)?e.kind:void 0}static transmission(e){const t=Rn.insulationDb(e),i=[3,4,5].map(s=>t[s]);return 10**(-(i.reduce((s,n)=>s+n,0)/i.length)/20)}static insulationDb(e){return e?e.windowsOpen===!0?Rn.WINDOWS_OPEN_DB:Rn.isRoad(e.kind)?Rn.ROAD_CLOSED_DB:Rn.CANOPIED.includes(e.kind)?Rn.CANOPY_DB:Rn.FUSELAGE_DB:Rn.OPEN_AIR}}class oh{constructor(e,t){this.samples=e,this.startMs=t}static SAMPLE_MS=100;static STANDING_MPS=.3;static of(e,t,i,s){const n=oh.SAMPLE_MS,r=[];for(let c=i;c<=s+n/2;c+=n){const h=t(c-n/2),d=t(c+n/2);if(!h||!d)return;r.push(Math.hypot(d.eastM-h.eastM,d.northM-h.northM)/(n/1e3))}const a=[];let o=1;for(let c=0;c<r.length;c++){const h=r[c],d=(r[Math.min(c+1,r.length-1)]-r[Math.max(c-1,0)])/(2*n/1e3);if(h<oh.STANDING_MPS){o=1,a.push({speedMps:h,rpm:e.idleRpm,load:.1,gear:0});continue}const u=h*3.6,p=v=>u/e.kmhPer1000Rpm[v-1]*1e3;for(;o<e.kmhPer1000Rpm.length&&p(o)>e.shiftUpRpm;)o++;for(;o>1&&p(o)<e.shiftDownRpm;)o--;const f=Math.max(p(o),e.idleRpm*(1+.3*Math.min(1,h/3))),m=.15+.5*Math.min(1,(h/35)**2),g=d>.15?Math.min(1,m+d/2.5):d<-.3?.05:m;a.push({speedMps:h,rpm:f,load:g,gear:o})}return new oh(a,i)}at(e){const t=(e-this.startMs)/oh.SAMPLE_MS,i=Math.min(Math.max(Math.floor(t),0),this.samples.length-1),s=this.samples[i],n=this.samples[Math.min(i+1,this.samples.length-1)],r=Math.min(Math.max(t-i,0),1);return{speedMps:s.speedMps+(n.speedMps-s.speedMps)*r,rpm:s.rpm+(n.rpm-s.rpm)*r,load:s.load+(n.load-s.load)*r,gear:r<.5?s.gear:n.gear}}}class Sg{drives=new Map;at(e,t){const i=[],s=e.event.place?.[0],n=h=>{const d=e.observerTrack.getInterpolatedPoseAt(h),u=d?.lat??s?.lat,p=d?.lng??s?.lng;if(u===void 0||p===void 0||!s)return;const f=lt(u,p,s.lat,s.lng);return{eastM:f.x,northM:-f.z}},r=Math.max(e.observerTrack.duration,(e.event.durationSeconds??0)*1e3),a=e.vehicle,o=Rn.roadOf(a);if(a&&o){const h=Nf.of(o),d=this.drive(`observer:${o}`,Sg.trackKey(e),()=>oh.of(h,n,0,r));d&&i.push({id:"observer",profile:h,state:d.at(t),noise:a.noise??1,inside:!0,windowsOpen:a.windowsOpen===!0,distanceM:0})}const c=n(t);for(const h of e.decor){if(!h.engine||!c)continue;const d=Nf.of(h.engine.kind),u=g=>{const v=Qr(h,g);return{eastM:v.eastM,northM:v.northM}},p=this.drive(`decor:${h.id}`,Sg.decorKey(h,r),()=>oh.of(d,u,0,r));if(!p)continue;const f=Qr(h,t),m=Math.hypot(f.eastM-c.eastM,f.northM-c.northM,f.altitudeM);i.push({id:`decor:${h.id}`,profile:d,state:p.at(t),noise:h.engine.noise??1,inside:!1,windowsOpen:!0,distanceM:m})}return i}drive(e,t,i){const s=this.drives.get(e);if(s&&s.key===t)return s.drive;const n=i();return this.drives.set(e,{key:t,drive:n}),n}static trackKey(e){return e.observerTrack.allKeyframes.map(i=>`${i.t}:${i.pose.lat}:${i.pose.lng}`).join(";")}static decorKey(e,t){return`${t}|${e.eastM},${e.northM}|`+(e.track??[]).map(i=>`${i.t}:${i.eastM}:${i.northM}`).join(";")}}const z8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAARVBMVEX9sST/uyTfoCjNlSikfCqRcCx8Yy21hipTSi4TITEMHTEuMzBqWC3/wSRUX207SFj8/PyaoakmNUd5gYxBPy90fIfMz9RsB4kZAAACEUlEQVRo3u2XyXbDIAxFLeapjts6/f9PrQA3JymT25Cd3iY5xtYVIB6wLCQSiUQikUgk0nzBoVdFZ1xIpaTQbJnPACaNdYeskWwuAhaZoltnUemfnNkL4N49KEI8n0YAEXMvEWISAWQZPw2Xk1MIoF1dSNAzCMy6JsGyCR0wrkMwT3cBeDt+FH8aEHoA68LbM8HRHXQ3f0RE3/jXOOFX+s4djrKpIbzS7K+MmLrxlWCNR8mczjMw92Ar4dZLDXG4kzXinAECcOUPL3jMdN2294/GQGVG4EMHxORNJXoCfG6oT1trvDGM7iIA9N6aTOuuEbB9ra6FyCYr2gjge+fjA4CIi2uujYRoOBSw0A5/D0hT0X4PW0xtuotNpQPYtkt/fdtyM0LP6ZvOI2DtvoxtJWHvx38AxIkevLwXQ2TOA66DziYfLwC4r5wbIlwJo1ys8+VOBMy7/sxdjwIap49lVC3UePZp1mmyit4SuGUf11pjoTHVRVzXUaXFVt87kuEBsWZ055Q+2sXA76LbZYsvKR1ubvJqbKd5swl+GPI31p6L/sNYuDTe3jo+GBdr1J+P9PGawbRUw9VhleD/3ffT9uZ7DhtX1JNHL2CmNRXxYZhwSwBd3aJTyU85/GKOwhxBf5RnVk+75OSiuu+Ax4PQ3Jsg1hTeMUMwJgQp+PKCe2a+JuefFwQnkUgkEolEIpFerW8TL0hlNl2QVAAAAABJRU5ErkJggg==",H8=`
|
|
8910
|
+
`);let t=Rd.shared.get(e);return t||(t=this.fetchFirstAvailable(),Rd.shared.set(e,t),t.then(i=>{i.length===0&&Rd.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.192.0")}`,t=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(t&&t!==kb?[t,kb]:[kb]).map(i=>i+e)}}class jc{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(e={}){this.platform=new Xt(e)}static covers(e){return Xt.covers((e.south+e.north)/2,(e.west+e.east)/2)}async getRoads(e){return(await this.platform.roads(e)).flatMap((i,s)=>jc.wayOf(i,s))}static wayOf(e,t){if(e.geometry.type!=="LineString")return[];const i=e.geometry.coordinates.map(([u,p])=>({lat:p,lng:u}));if(i.length<2)return[];const s=String(e.properties.nature??""),n=jc.BY_NATURE[s]??jc.DEFAULT,r=Number(e.properties.largeur_de_chaussee),a=Number(e.properties.nombre_de_voies),o=Number(e.properties.vitesse_moyenne_vl),c=jc.DIRECTIONS[String(e.properties.sens_de_circulation??"")],h=jc.KINDS[s],d=[e.properties.cpx_toponyme_route_nommee,e.properties.nom_voie_ban_gauche,e.properties.nom_voie_ban_droite].find(u=>typeof u=="string"&&u.length>0);return[{id:String(e.properties.cleabs??`ign-${t}`),...d?{name:d}:{},surface:n.surface,widthM:Number.isFinite(r)&&r>0?r:n.widthM,...e.properties.urbain===!0?{urban:!0}:{},...h?{kind:h}:{},...Number.isInteger(a)&&a>0?{lanes:a}:{},...c?{direction:c}:{},...Number.isFinite(o)&&o>0?{speedKmh:o}:{},points:i}]}}class C8{constructor(e,t){this.regional=e,this.worldwide=t}attribution="Roads © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRoads(e){if(jc.covers(e))try{const t=await this.regional.getRoads(e);if(t.length>0)return t}catch{}return this.worldwide.getRoads(e)}}class Pf{attribution="Water © IGN, BD TOPO (Licence Ouverte 2.0)";platform;constructor(e={}){this.platform=new Xt(e)}static covers(e){return Xt.covers((e.south+e.north)/2,(e.west+e.east)/2)}async getWater(e){return(await this.platform.waterSurfaces(e)).flatMap((i,s)=>Pf.surfacesOf(i,s))}static surfacesOf(e,t){const{type:i,coordinates:s}=e.geometry,n=i==="Polygon"?[s]:i==="MultiPolygon"?s:[],r=String(e.properties.cleabs??`ign-water-${t}`);return n.flatMap((a,o)=>{const c=a.map(h=>Pf.open(h.map(d=>({lat:d[1],lng:d[0]})))).filter(h=>h.length>=3);return c.length>0?[{id:n.length>1?`${r}-${o}`:r,rings:c}]:[]})}static open(e){const t=e[0],i=e[e.length-1];return e.length>1&&t.lat===i.lat&&t.lng===i.lng?e.slice(0,-1):e}}class jl{attribution="Water © OpenStreetMap contributors";client;constructor(e={}){this.client=new Or(e)}async getWater(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:30];(way["natural"="water"](${t});way["waterway"="riverbank"](${t});)->.w;(relation["natural"="water"](${t});relation["waterway"="riverbank"](${t});)->.r;.w out geom;.r out body;way(r.r)(${t});out geom;`;return jl.surfacesFrom(await this.client.query(i))}static surfacesFrom(e){const t=e.elements??[],i=new Map;for(const r of t)r.type==="way"&&r.id!==void 0&&r.geometry&&i.set(r.id,r.geometry.map(a=>({lat:a.lat,lng:a.lon})));const s=[],n=new Set;for(const r of t){if(r.type!=="relation")continue;const a=c=>(r.members??[]).filter(h=>h.type==="way"&&h.role===c&&h.ref!==void 0&&i.has(h.ref)).map(h=>(n.add(h.ref),i.get(h.ref))),o=jl.rings(a("inner"));for(const[c,h]of jl.rings(a("outer")).entries()){const d=o.filter(u=>jl.contains(h,u[0]));s.push({id:`osm-r${r.id}-${c}`,rings:[h,...d]})}}for(const r of t)if(!(r.type!=="way"||!r.tags||r.id===void 0||n.has(r.id))&&!(r.tags.natural!=="water"&&r.tags.waterway!=="riverbank"))for(const a of jl.rings([i.get(r.id)??[]]))s.push({id:`osm-w${r.id}`,rings:[a]});return s}static rings(e){const t=(n,r)=>n.lat===r.lat&&n.lng===r.lng,i=e.filter(n=>n.length>=2).map(n=>[...n]),s=[];for(;i.length>0;){let n=i.pop(),r=!0;for(;!t(n[0],n[n.length-1])&&r;){r=!1;for(let a=0;a<i.length;a++){const o=i[a],c=n[n.length-1];if(t(c,o[0]))n=[...n,...o.slice(1)];else if(t(c,o[o.length-1]))n=[...n,...[...o].reverse().slice(1)];else continue;i.splice(a,1),r=!0;break}}n.length>=4&&t(n[0],n[n.length-1])&&s.push(n.slice(0,-1))}return s}static contains(e,t){let i=!1;for(let s=0,n=e.length-1;s<e.length;n=s++){const r=e[s],a=e[n];r.lat>t.lat!=a.lat>t.lat&&t.lng<(a.lng-r.lng)*(t.lat-r.lat)/(a.lat-r.lat)+r.lng&&(i=!i)}return i}}class O8{constructor(e,t){this.regional=e,this.worldwide=t}attribution="Water © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere";async getWater(e){if(Pf.covers(e))try{const t=await this.regional.getWater(e);if(t.length>0)return t}catch{}return this.worldwide.getWater(e)}}const Rb="https://ufoathome.org/water/index.json";class Cd{attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(e={}){this.sharing=!e.fetchImpl,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Cd.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Water © OpenStreetMap contributors"}async getWater(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getWater(e);return this.attributionRead=this.fallback.attribution,i}async held(e){const i=(await this.load().catch(()=>[])).find(({entry:s})=>s.north>=e.north&&s.south<=e.south&&s.east>=e.east&&s.west<=e.west);if(i)try{const s=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!s.ok)return;const n=await s.json();return Array.isArray(n?.surfaces)?(this.attributionRead=n.attribution,n.surfaces):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const e=this.indexUrls.join(`
|
|
8911
|
+
`);let t=Cd.shared.get(e);return t||(t=this.fetchFirstAvailable(),Cd.shared.set(e,t),t.then(i=>{i.length===0&&Cd.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.192.0")}`,t=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(t&&t!==Rb?[t,Rb]:[Rb]).map(i=>i+e)}}class Sr{constructor(e){this.water=e}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(e){const t=Sr.key(e);let i=Sr.asked.get(t);return i===void 0&&(i=this.recalled(t,e),Sr.asked.set(t,i),i.catch(()=>Sr.asked.delete(t))),structuredClone(await i)}static forget(){Sr.asked.clear()}static key(e){return`v${Sr.FORMAT}/${[e.north,e.south,e.east,e.west].map(t=>t.toFixed(5)).join("/")}`}async recalled(e,t){const i=await Sr.openCache(),s=Sr.request(e);if(i)try{const r=await i.match(s);if(r){const{savedAt:a,surfaces:o}=await r.json();if(Date.now()-a<Sr.MAX_AGE_MS&&Array.isArray(o))return o;await i.delete(s)}}catch{}const n=await this.water.getWater(t);return i&&Sr.store(i,s,n),n}static async store(e,t,i){try{const s={savedAt:Date.now(),surfaces:i};await e.put(t,new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}}));const n=await e.keys();for(const r of n.slice(0,Math.max(0,n.length-Sr.MAX_STORED)))await e.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Sr.CACHE_NAME)}catch{return}}static request(e){const t=typeof location>"u"?"http://localhost":location.origin;return new Request(`${t}/__water__/${encodeURIComponent(e)}`)}}class Zc{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(e={}){this.platform=new Xt(e)}static covers(e){return Xt.covers((e.south+e.north)/2,(e.west+e.east)/2)}async getRailways(e){return(await this.platform.railways(e)).flatMap((i,s)=>Zc.linesOf(i,s))}static linesOf(e,t){const{type:i,coordinates:s}=e.geometry,n=i==="LineString"?[s]:i==="MultiLineString"?s:[],r=Zc.BY_NATURE[String(e.properties.nature??"")];if(!r)return[];const a=String(e.properties.cleabs??`ign-rail-${t}`),o=Number(e.properties.nombre_de_voies),c=Number(e.properties.position_par_rapport_au_sol),h=e.properties.cpx_toponyme,d=Zc.GAUGE_MM[String(e.properties.largeur??"")]??1435,u=Zc.electrificationOf(r.kind,d,e.properties.electrifie);return n.flatMap((p,f)=>{const m=p.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>Zc.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.length<2?[]:[{id:n.length>1?`${a}-${f}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:d,tracks:Number.isInteger(o)&&o>0?o:1,...u?{electrification:u}:{},level:Number.isFinite(c)?c:0,points:m}]})}static electrificationOf(e,t,i){if(i===!1)return"none";if(i===!0){if(e==="subway")return"third_rail";if(!(e==="funicular"||t<1435))return"overhead"}}}class kn{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(e={}){this.client=new Or(e)}async named(e,t){if(e.length===0)return[...e];const i=`${t.south},${t.west},${t.north},${t.east}`,s=`[out:json][timeout:120];way["railway"~"^(${kn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${kn.ROUTES})$"];out body;`;return kn.apply(e,await this.client.query(s),t)}static apply(e,t,i){const s={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},n=kn.ways(t,s);return n.length===0?[...e]:e.map(r=>{const a=r.points.map(v=>lt(v.lat,v.lng,s.lat,s.lng)),o=new Map,c=new Map,h=new Map;let d=0;const u=n.filter(v=>v.service===!!r.service);for(const v of kn.samples(a)){d++;const b=kn.waysAt(u,v);if(b.length===0)continue;const[w]=b;w.name&&o.set(w.name,(o.get(w.name)??0)+1),w.voltageV&&c.set(w.voltageV,(c.get(w.voltageV)??0)+1);for(const y of new Set(b.flatMap(M=>M.services)))h.set(y,(h.get(y)??0)+1)}const p=v=>[...v.entries()].sort((b,w)=>w[1]-b[1])[0]?.[0],f=r.name??p(o),m=r.voltageV??(r.electrification==="none"?void 0:p(c)),g=[...h.entries()].filter(([,v])=>v*4>=d).sort((v,b)=>b[1]-v[1]||v[0].localeCompare(b[0])).map(([v])=>v);return{...r,...f?{name:f}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}static serviceOf(e){const t=e.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return t||[e.network,e.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(e){const t=new Map;for(const i of e.elements??[]){if(i.type!=="relation"||!i.tags)continue;const s=kn.serviceOf(i.tags);if(s)for(const n of i.members??[]){if(n.type!=="way"||n.ref===void 0)continue;const r=t.get(n.ref)??new Set;r.add(s),t.set(n.ref,r)}}return t}static voltageOf(e){const t=Number.parseInt((e.voltage??"").split(";")[0],10);return Number.isFinite(t)&&t>0?t:void 0}static ways(e,t){const i=kn.servicesByWay(e),s=[];for(const n of e.elements??[]){if(n.type!=="way"||!n.geometry||n.geometry.length<2)continue;const r=n.tags??{},a=kn.voltageOf(r);s.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(n.id??-1)??[]],path:n.geometry.map(o=>lt(o.lat,o.lon,t.lat,t.lng))})}return s}static samples(e){const t=[];for(let i=0;i<e.length-1;i++){const s=Math.hypot(e[i+1].x-e[i].x,e[i+1].z-e[i].z);if(s<1e-6)continue;const n=(e[i+1].x-e[i].x)/s,r=(e[i+1].z-e[i].z)/s;for(let a=kn.SAMPLE_M/2;a<s;a+=kn.SAMPLE_M)t.push({x:e[i].x+n*a,z:e[i].z+r*a,dx:n,dz:r})}return t}static waysAt(e,t){const i=Math.cos(kn.ALIGNED_DEG*Math.PI/180),s=[];for(const n of e){let r;for(let a=0;a<n.path.length-1;a++){const o=n.path[a],c=n.path[a+1],h=c.x-o.x,d=c.z-o.z,u=Math.hypot(h,d);if(u<1e-6||Math.abs((h*t.dx+d*t.dz)/u)<i)continue;const p=Math.max(0,Math.min(1,((t.x-o.x)*h+(t.z-o.z)*d)/(u*u))),f=Math.hypot(t.x-(o.x+h*p),t.z-(o.z+d*p));f<=kn.NEAR_M&&(r===void 0||f<r)&&(r=f)}r!==void 0&&s.push({way:n,distance:r})}return s.sort((n,r)=>n.distance-r.distance).map(({way:n})=>n)}}class Od{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(e={}){this.client=new Or(e)}async getRailways(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Od.KINDS.join("|")})$"](${t})->.w;.w out tags geom;rel(bw.w)["route"~"^(${kn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(e){const t=[],i=kn.servicesByWay(e);for(const s of e.elements??[]){const n=s.geometry,r=s.tags;if(s.type==="relation"||!r||!n||n.length<2)continue;const a=[...i.get(s.id??-1)??[]].sort(),o=kn.voltageOf(r),c=Od.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),d=Number.parseInt(r.tracks??"",10),u=Od.electrificationOf(r.electrified),p=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;t.push({id:`osm-rail-${s.id??t.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...o?{voltageV:o}:{},kind:c,...r.service||r.usage==="industrial"?{service:!0}:{},...p?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(d)&&d>0?d:1,...u?{electrification:u}:{},level:Od.levelOf(r),points:n.map(f=>({lat:f.lat,lng:f.lon}))})}return t}static kindOf(e){switch(e.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(e){if(e!==void 0){if(e==="no")return"none";if(e==="contact_line"||e==="yes")return"overhead";if(e==="rail"||e==="4th_rail"||e==="ground-level_power_supply")return"third_rail"}}static levelOf(e){const t=Number.parseInt(e.layer??"",10);return e.tunnel&&e.tunnel!=="no"?Number.isFinite(t)&&t<0?t:-1:e.covered==="yes"&&e.location==="underground"?-1:e.bridge&&e.bridge!=="no"?Number.isFinite(t)&&t>0?t:1:0}}class L8{constructor(e,t){this.regional=e,this.worldwide=t}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(e){if(!Zc.covers(e))return this.worldwide.getRailways(e);let t;try{if(t=await this.regional.getRailways(e),t.length>0)return t}catch{}try{return await this.worldwide.getRailways(e)}catch(i){if(t)return t;throw i}}}class Ws{constructor(e,t=Date.now){this.railways=e,this.now=t}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(e){const t=Ws.key(e);let i=Ws.asked.get(t)??Ws.containing(e);if(i===void 0){const s=this.recalled(t,e);i={bounds:e,answer:s},Ws.asked.set(t,i),s.catch(()=>Ws.asked.delete(t))}return structuredClone(await i.answer)}static forget(){Ws.asked.clear(),Ws.failedAt=-1/0}static key(e){return`v${Ws.FORMAT}/${[e.north,e.south,e.east,e.west].map(t=>t.toFixed(5)).join("/")}`}static containing(e){for(const t of Ws.asked.values()){const i=t.bounds;if(i.north>=e.north&&i.south<=e.south&&i.east>=e.east&&i.west<=e.west)return t}}async recalled(e,t){const i=await Ws.openCache(),s=Ws.request(e);let n;if(i)try{const a=await i.match(s);if(a){const{savedAt:o,lines:c}=await a.json();if(Array.isArray(c)){if(this.now()-o<Ws.MAX_AGE_MS)return c;n=c}}}catch{}if(this.now()-Ws.failedAt<Ws.RETRY_AFTER_MS){if(n)return n;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(t)}catch(a){if(Ws.failedAt=this.now(),n)return n;throw a}return i&&Ws.store(i,s,{savedAt:this.now(),lines:r}),r}static async store(e,t,i){try{await e.delete(t),await e.put(t,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const s=await e.keys();for(const n of s.slice(0,Math.max(0,s.length-Ws.MAX_STORED)))await e.delete(n)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Ws.CACHE_NAME)}catch{return}}static request(e){const t=typeof location>"u"?"http://localhost":location.origin;return new Request(`${t}/__railways__/${encodeURIComponent(e)}`)}}const Cb="https://ufoathome.org/railways/index.json";class Ld{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(e={}){this.sharing=!e.fetchImpl,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Ld.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getRailways(e);return this.attributionRead=this.fallback.attribution,i}async held(e){const i=(await this.load().catch(()=>[])).find(({entry:s})=>s.north>=e.north&&s.south<=e.south&&s.east>=e.east&&s.west<=e.west);if(i)try{const s=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!s.ok)return;const n=await s.json();return Array.isArray(n?.lines)?(this.attributionRead=n.attribution,n.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const e=this.indexUrls.join(`
|
|
8912
|
+
`);let t=Ld.shared.get(e);return t||(t=this.fetchFirstAvailable(),Ld.shared.set(e,t),t.then(i=>{i.length===0&&Ld.shared.delete(e)})),this.index=t}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(s=>({entry:s,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.192.0")}`,t=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(t&&t!==Cb?[t,Cb]:[Cb]).map(i=>i+e)}}function AI(){return{elevation:TI(),imagery:II(),roads:_I(),water:DI(),railways:kI()}}function TI(){return new D8(new Bt,new xI)}function II(){return new SI}function _I(){return new Rd({fallback:new C8(new jc,new Wc)})}function DI(){return new Cd({fallback:new Sr(new O8(new Pf,new jl))})}function kI(){return new Ld({fallback:new Ws(new L8(new Zc,new Od))})}const P8=new Set,tu="show-observer-map",iu="hide-milestones",ah="minified";class Zt extends HTMLElement{static get observedAttributes(){return["src",tu,iu,ah]}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 vi;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=rv.create();issues=[];issueCheck=0;sightingAudio=new h2;liveSightingAudio;hearInto(e){e?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new h2(e)):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>Zt.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 e=this.controlsRow,t=e.classList.contains("more-open"),i=()=>e.scrollWidth>e.clientWidth+1,s=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,e.classList.remove("narrow","more-open","nomoments","compact","tiny"),e.clientWidth>0&&i()){e.classList.add("narrow");for(const n of["nomoments","compact","tiny"]){if(!i())break;e.classList.add(n)}t&&e.classList.add("more-open")}this.momentsMenu.hidden=!s,this.updateMoreButton()}setControlsFolded(e){this.controlsRow.classList.toggle("more-open",!e),this.updateMoreButton()}updateMoreButton(){const e=this.controlsRow.classList.contains("more-open");Zt.setIcon(this.moreButton,e?Je.UNFOLDED:Je.FOLDED);const t=e?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=t,this.moreButton.setAttribute("aria-label",t),this.moreButton.setAttribute("aria-expanded",String(e))}addControl(e){this.controlsRight.insertBefore(e,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(e){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!e){this.fitControls();return}const t=document.createElement("button");t.type="button",t.id="video-button",t.innerHTML=Je.VIDEO,this.videoElement=t,this.labelVideoButton(),t.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(e,t)},{once:!0}),this.moreButton.after(t),this.fitControls()}async loadVideoButton(e,t){const{VideoButton:i}=await V(async()=>{const{VideoButton:n}=await import("./VideoButton-CqCZ65oK.js");return{VideoButton:n}},[],import.meta.url);if(this.videoElement!==t)return;const s=new i(e,t);this.videoButton=s,this.messages&&(s.messages=this.messages),this.stageElement.append(s.panel),s.open()}labelVideoButton(){const e=this.videoElement;!e||this.videoButton||(e.title=this.messages?.recordVideo??"",e.setAttribute("aria-label",e.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(e){e!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,e&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(e){const t=this.currentTime,i=e.caption&&this.sighting.milestones.length>0?Bm(this.sighting.milestones,t):void 0,s=i?this.said.read(i.label)??"":void 0,n=this.canvas.getBoundingClientRect(),r=e.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:s,note:this.said.read(i.note)}}:{},...e.time?{time:this.formatPosition(t)}:{},...r&&n.width>0&&n.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-n.left)/n.width,top:(r.top-n.top)/n.height,width:r.width/n.width,height:r.height/n.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=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),i=t&&this.shapeAt(t.x,t.y),s=this.said.read(i?.shape.title);if(!s){this.tooltip.hidden=!0;return}this.tooltip.textContent=s,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-n.left+12}px`,this.tooltip.style.top=`${e.clientY-n.top+12}px`};handleObserverMapPointerMove=e=>{if(this.dragObserverMap(e))return;const t=this.observerMapTargetFrom(e);if(!t){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(e,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(e,t.label)};showObserverMapTooltip(e,t){this.tooltip.textContent=t,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-i.left+12}px`,this.tooltip.style.top=`${e.clientY-i.top+12}px`}handleObserverMapClick=e=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const t=this.observerMapTargetFrom(e);if(!t){this.observerPlacing&&this.placeObserverFrom(e);return}if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(e){const t=this.observerMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.observerMapRenderer.hitTest((e.clientX-t.left)/t.width*this.observerMapCanvas.width,(e.clientY-t.top)/t.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=e=>{e.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:!1})};handleObserverMapPointerUp=e=>{const t=this.observerMapDrag;!t||t.pointerId!==e.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),t.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(e.pointerId)&&this.observerMapCanvas.releasePointerCapture(e.pointerId)))};dragObserverMap(e){const t=this.observerMapDrag;if(!t||t.pointerId!==e.pointerId)return!1;if(!t.moved){if(Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<Zt.OBSERVER_MAP_DRAG_PX)return!1;t.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(e.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((e.clientX-t.lastX)/i.width,(e.clientY-t.lastY)/i.height),this.observerMapViewChanged()),t.lastX=e.clientX,t.lastY=e.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=e=>{e.preventDefault();const t=this.observerMapCanvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=e.deltaMode===0?e.deltaY:e.deltaY*40;this.zoomObserverMap((e.clientX-t.left)/t.width,(e.clientY-t.top)/t.height,Math.exp(-i*.002))};zoomObserverMap(e,t,i){this.observerMapView.zoomAt(e,t,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=vi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=vi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Zt.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(e){const t=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!t||i.width===0||i.height===0)return;const s=vi.pointAt(t,(e.clientX-i.left)/i.width,(e.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:s,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${p8}</style>${u8}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Au(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 ql(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 t=this.shadow.getElementById("mini-bar"),i=t.querySelector(".mini-track"),s=a=>{const o=i.getBoundingClientRect(),c=this.player.seekableDuration;if(o.width<=0||c<=0)return;const h=Math.min(Math.max((a.clientX-o.left)/o.width,0),1)*c;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let n=!1;t.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),t.setPointerCapture(a.pointerId),t.classList.add("scrubbing"),n=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,s(a))}),t.addEventListener("pointermove",a=>{t.hasPointerCapture(a.pointerId)&&s(a)});const r=a=>{t.classList.contains("scrubbing")&&(t.classList.remove("scrubbing"),t.hasPointerCapture(a.pointerId)&&t.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,n&&this.play())};t.addEventListener("pointerup",r),t.addEventListener("pointercancel",r),t.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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}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(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),e===tu&&this.applyObserverMapDefault(),e===iu&&this.setMilestonesShown(!this.hasAttribute(iu)),e===ah){const s=this.minified;this.stageElement.classList.toggle("minified",s),s&&t===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(ah)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=e=>{!this.minified||e.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=e=>{!this.minified||e.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(RI)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const e=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",e),e&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(e){this.sightingData=await Fa.recording(e)}get sightingData(){return Rf(this.currentSighting)}set sightingData(e){const t=En.recording(e);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=qf(t),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,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(e){this.titleOverride=e,this.syncPlayerTitle()}titleOverride;set titleShown(e){this.titleHidden=!e,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const e=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=e,this.playerTitleBox.hidden=e===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(e,t){const i=++this.issueCheck;let s=[];try{const{default:n}=await V(async()=>{const{default:r}=await import("./sightingSchema-CgwoRMl-.js");return{default:r}},[],import.meta.url);s=new la(n).issues(e)}catch{}i===this.issueCheck&&(this.issues=[...s,...t.loadIssues],Lf.warn(this.issues,t.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(F8,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const e=this.issues.length;this.issuesBox.hidden=e===0,this.shadow.getElementById("issues-count").textContent=String(e);const t=(this.messages?.recordingIssues??"").replace("{count}",String(e));this.issuesButton.title=t,this.issuesButton.setAttribute("aria-label",t),this.shadow.getElementById("issues-title").textContent=t,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const s=document.createElement("li");return s.textContent=Lf.text(i,this.messages.issueTemplates),s}))}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){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(e){if(e!==this.clockHeld){if(this.clockHeld=e,e){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(e){this.cited=[...e],this.refreshCitedMarks()}refreshCitedMarks(){const e=this.player.seekableDuration;this.citedMarks.replaceChildren(...(e>0?this.cited:[]).map(t=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=de.INTERVIEW,i.style.left=`${Math.min(Math.max(t.at*1e3/e,0),1)*100}%`;const s=t.quote??"";return i.title=s,i.setAttribute("aria-label",s),i.addEventListener("click",()=>this.player.seek(t.at*1e3)),i}))}sayTimeMoved(e){Math.abs(e-this.timeSaid)<Zt.TIME_SAID_EVERY_MS||(this.timeSaid=e,this.dispatchEvent(new CustomEvent(N8,{bubbles:!0,composed:!0,detail:{at:e/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(e){this.toolbar.classList.toggle("hidden",!e),e?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(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=t,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==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(e){const t=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(e)for(const i of t)e.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const s of t)this.controlsRight.insertBefore(s,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 e=this.currentSighting.references;if(!this.referenceOpacityTouched&&e.length>0){const t=String(e[0].opacity);this.referenceOpacityInput.value!==t&&(this.referenceOpacityInput.value=t,this.severalReferences||this.dispatchReferenceView())}for(const t of[...this.referenceViews.keys()])e.some(i=>i.id===t)||this.referenceViews.delete(t);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(e){let t=this.referenceViews.get(e.id);return t||(t={shown:!0,opacity:e.opacity},this.referenceViews.set(e.id,t)),t}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=e=>{const t=e.composedPath();t.includes(this.referencesMenu)||t.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=e=>{e.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const e=this.referencesButton.getBoundingClientRect(),t=this.referencesMenu,i=4;t.style.bottom=`${Math.max(i,window.innerHeight-e.top+i)}px`,t.style.top="auto";const s=t.getBoundingClientRect().width;t.style.left=`${Math.max(i,Math.min(e.left,window.innerWidth-s-i))}px`}renderReferencesMenu(){const e=this.currentSighting.references.map(t=>{const i=this.viewOfReference(t),s=this.said.read(t.title)??t.id,n=document.createElement("div");n.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const o=document.createElement("span");o.textContent=s,o.title=s,r.append(a,o);const c=document.createElement("input");return c.type="range",c.min="0",c.max="1",c.step="0.05",c.value=String(i.opacity),c.title=this.messages?.referenceOpacity??"",c.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${s}`),c.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,c.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),c.addEventListener("input",()=>{i.opacity=Number(c.value),this.dispatchReferenceView()}),n.append(r,c),n});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...e)}updateReferencesButton(){const e=this.currentSighting.references.length>0,t=this.severalReferences,i=t?this.currentSighting.references.some(n=>this.viewOfReference(n).shown):this.referencesShownState;this.referencesButton.hidden=!e,this.referenceOpacityInput.hidden=!e||!this.referencesShownState||t,this.referencesButton.setAttribute("aria-pressed",String(i)),t?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),Zt.setIcon(this.referencesButton,i?Je.PICTURES_ON:Je.PICTURES_OFF);const s=t?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=s,this.referencesButton.setAttribute("aria-label",s),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)),Zt.setIcon(this.tracesButton,this.tracesShownState?Je.TRACES_ON:Je.TRACES_OFF);const e=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=e,this.tracesButton.setAttribute("aria-label",e)}dispatchReferenceView(){const e=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(t=>[t.id,{...this.viewOfReference(t)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:e}}))}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?mh(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(i=>{const s=document.createElement("button");s.type="button",s.className="milestone-mark",s.style.left=`${Math.min(Math.max(i.t/e,0),1)*100}%`;const n=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${n} — ${r}`:n;return s.title=a,s.setAttribute("aria-label",a),s.dataset.t=String(i.t),s.addEventListener("click",()=>this.player.seek(i.t)),s})),this.refreshCitedMarks(),this.refreshSeekSegments(e,t.map(i=>i.t)),this.refreshMomentsPicker(t)}refreshMomentsPicker(e){const t=this.milestonesShown&&e.length>0;this.momentsBox.hidden=!t,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...e.map(i=>{const s=document.createElement("li"),n=document.createElement("button");n.type="button",n.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return n.textContent=a?`${r} — ${a}`:r,n.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),s.appendChild(n),s})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(e){const i=(e?this.said.read(e.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const s of this.momentsMenu.querySelectorAll("button")){const n=e!==void 0&&Number(s.dataset.t)===e.t;s.getAttribute("aria-current")==="true"!==n&&s.setAttribute("aria-current",String(n))}}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=e=>{if(!this.momentsMenu.hidden){if(e instanceof KeyboardEvent){e.key==="Escape"&&this.closeMomentsMenu();return}e.composedPath().some(t=>t===this.momentsMenu||t===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(e,t){const s=[0,...this.milestonesShown&&e>0?[...new Set(t.filter(r=>r>0&&r<e))].sort((r,a)=>r-a):[],Math.max(e,0)];this.seekSegmentList=[];const n=[];for(let r=0;r<s.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(s[r+1]-s[r],1));const o=document.createElement("i");o.className="seek-hover";const c=document.createElement("i");c.className="seek-played",a.append(o,c),n.push(a),this.seekSegmentList.push({start:s[r],end:s[r+1],element:a,played:c,hover:o})}this.seekSegments.replaceChildren(...n),this.paintSeekProgress(this.player.time)}static fillOf(e,t){const i=e.end-e.start,s=i>0?(t-e.start)/i:t>=e.end?1:0;return`${Math.min(Math.max(s,0),1)*100}%`}paintMiniProgress(e){const t=this.player.seekableDuration,i=`${t>0?Math.min(Math.max(e/t,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(e)}miniDot;miniScrubTime;paintSeekProgress(e){for(const i of this.seekSegmentList)i.played.style.width=Zt.fillOf(i,e);const t=this.player.seekableDuration;this.seekDot.style.left=`${t>0?Math.min(Math.max(e/t,0),1)*100:0}%`}hoverSeek(e){if(e.buttons!==0){this.seekPreview.hidden=!0;return}const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=Math.min(Math.max((e.clientX-t.left)/t.width,0),1),n=s*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((p,f)=>{p.hover.style.width=Zt.fillOf(p,n),p.element.classList.toggle("hovered",n>=p.start&&(n<p.end||f===r))});const a=this.milestonesShown?this.sighting.milestones:[],o=a.length>0?Bm(a,n):void 0,c=o?this.said.read(o.label)??"":"",h=o?this.said.read(o.note):void 0,d=h?`${c} — ${h}`:c;this.seekPreviewTitle.textContent=d,this.seekPreviewTime.textContent=this.formatPosition(n),this.seekPreview.hidden=!1;const u=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(s*t.width-u/2,0),Math.max(t.width-u,0))}px`,this.paintSeekPreview(n)}leaveSeek(){for(const e of this.seekSegmentList)e.hover.style.width="0",e.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(e){const t=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=t===void 0,t?.(e,this.seekPreviewCanvas)}paintChrome(e){const t=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const s=this.chromeCanvas.clientWidth,n=this.chromeCanvas.clientHeight;if(!t||typeof t.setTransform!="function"||s===0||n===0){e(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(s*r)),o=Math.max(1,Math.round(n*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==o&&(this.chromeCanvas.height=o),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,a,o),this.chromeDirty=!1,i&&(t.setTransform(a/this.canvas.width,0,0,o/this.canvas.height,0,0),this.chromeRenderer??=new Au(t),this.chromeDirty=!0,e(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(e){if(e.pointerType!=="mouse"){this.scrubbingPointer=e.pointerId;try{this.seekInput.setPointerCapture(e.pointerId)}catch{}this.seekToPointer(e)}}touchScrub(e){e.pointerId===this.scrubbingPointer&&this.seekToPointer(e)}endTouchScrub(e){e.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(e))}seekToPointer(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=Math.min(Math.max((e.clientX-t.left)/t.width,0),1);this.player.seek(this.snapSeekToMark(s*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(e){const t=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(t<=0||i<=0)return;const s=Zt.MARK_SNAP_PX/i*t;let n;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-e)>s||(!n||Math.abs(a-e)<Math.abs(n.t-e))&&(n={t:a,name:r.title})}return n}snapSeekToMark(e){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(e)?.t??e):e}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const s=(e.clientX-t.left)/t.width*i,n=this.markNear(s);n?this.seekInput.title=n.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?Bm(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,this.showCurrentMoment(t),!t)return;const i=document.createElement("b");i.textContent=this.said.read(t.label)??"";const s=this.said.read(t.note),n=s?` — ${s}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(n))}exposureInstants(e){const t=this.exposureTimes(e),i=1/t.length;return t.map(s=>({shapes:this.shapesAt(s),share:i}))}exposureTimes(e=this.currentTime){const t=$n.windowEndingAt(e,this.currentSighting.exposure??0);if(t.ms<Zt.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const i=Math.min(Zt.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t.ms/Zt.SHORTEST_VISIBLE_EXPOSURE_MS))),s=Math.ceil(this.travelPxOver(t.fromMs,t.ms)/Zt.EXPOSURE_STEP_PX),n=Math.min(Zt.MAX_TRAVEL_STEPS,Math.max(i,s)),r=[];for(let a=0;a<n;a++)r.push(t.fromMs+t.ms*a/(n-1));return r}travelPxOver(e,t){const i=this.shapesAt(e),s=this.shapesAt(e+t);let n=0;for(const[r,a]of i){const o=s.get(r);if(!o)continue;const c=o.bounds.x+o.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=o.bounds.y+o.bounds.height/2-(a.bounds.y+a.bounds.height/2);n=Math.max(n,Math.hypot(c,h))}return n}shapeAt(e,t,i){if(!this.accountHidden)for(const s of this.exposureTimes()){const n=this.currentSighting.timeline.hitTest(s,e,t,i);if(n)return n}}shapesAt(e){const t=new Map;for(const i of this.currentSighting.timeline.sourceIds){const s=this.currentSighting.timeline.getInterpolatedShapeAt(e,i);s&&t.set(i,s)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=Vt.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(e,t){this.sayTimeMoved(e),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:P8;this.canvasRenderer.setStarPoints(Vt.starPointsOf(this.sighting.instrument,et(this.sighting,e)?.fNumber));const s=(et(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(s*Math.PI/180);const n=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of n)for(const[,c]of o.shapes){const h=o.share,d=h===1?c:{...c,transparency:1-(1-c.transparency)*h};this.canvasRenderer.paintShape(this.shifted(d,r))}for(const[o,c]of n[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));const a=this.selectionShown&&i.size>1?ai.groupBoundsFor([...t].filter(([o])=>i.has(o)).map(([,o])=>o.bounds)):void 0;this.chromeDraw=o=>{a&&o.paintGroupHandles(a),this.overlayPainter?.(o)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=n.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(e),this.paintSeekProgress(e),this.minified&&this.paintMiniProgress(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintObserverMap(e),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(Vw(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new f8(this.currentSighting.timeline,(t,i)=>this.onFrame(t,i));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=e=>{e.key.toLowerCase()!=="f"||e.altKey||e.ctrlKey||e.metaKey||!this.enableClickToPlay||e.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(e.preventDefault(),this.toggleFullscreen())};handleSeekKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;const t=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0;if(t){e.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+t*Zt.SEEK_KEY_STEP_MS)))}else e.key===" "&&(e.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 e=this.playbackFlash;e.innerHTML=this.player.playbackState==="playing"?Je.PLAY:Je.PAUSE,e.classList.remove("flashing"),e.offsetWidth,e.classList.add("flashing")}static icons=new WeakMap;static setIcon(e,t){Zt.icons.get(e)!==t&&(Zt.icons.set(e,t),e.innerHTML=t)}set captionHeld(e){this.stageElement.classList.toggle("caption-held",e)}set controlsHeld(e){this.stageElement.classList.toggle("controls-held",e)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(e){this.quietControlsValue=e,this.stageElement.classList.toggle("quiet",e)}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},Zt.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!e),e!==this.wasPlaying&&e&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=e,this.updateStartState(),Zt.setIcon(this.playPauseButton,e?Je.PAUSE:Je.PLAY);const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const i=t?e?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 e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const e=this.observerMapPanel.hidden;this.observerMapAsked=e,this.setObserverMapOpen(e),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:e}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const e=this.getAttribute(tu),t=e===null?this.sighting.observerMap??this.observerPath?.travels===!0:e!=="false";this.setObserverMapOpen(t&&this.observerPath!==void 0)}setObserverMapOpen(e){this.observerMapPanel.hidden=!e,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(e)),this.updateObserverMapButton(),e&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const e=!this.observerMapPanel.hidden;Zt.setIcon(this.observerMapButton,e?Je.MAP_ON:Je.MAP_OFF);const t=e?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=t,this.observerMapButton.setAttribute("aria-label",t);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[s,n]of i)s.title=n,s.setAttribute("aria-label",n)}updateObserverMap(){const e=this.observerPath!==void 0;if(this.observerPath=vh.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!e&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const t=this.tracesShownState?this.currentSighting.traces.flatMap(s=>s.points):[],i=vi.fitted(this.observerPath,t);(!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(e,t){const i=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<i&&Math.abs(e.south-t.south)<i&&Math.abs(e.west-t.west)<i&&Math.abs(e.east-t.east)<i}async loadObserverMapImagery(){const e=this.observerMapViewBounds;if(!e||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(e)))return;const t=this.observerMapView.changed,i=t?vi.expand(e,Zt.OBSERVER_MAP_IMAGERY_AHEAD):e,s=vi.IMAGERY_PX*(t?1+2*Zt.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=e.east-e.west,this.observerMapImageryLoading=!0;const n=this.observerMapSnapshotImagery,r=n?void 0:II();try{const a=r?await r.getImageryTexture(i,{width:s,height:s}):await n.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??n).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(e){const t=this.observerMapImageryBounds;if(!t)return!0;const i=this.observerMapImagery?.bounds??t,s=this.observerMapView.changed?vi.expand(e,Zt.OBSERVER_MAP_IMAGERY_LOOKAHEAD):e,n=s.west>=i.west&&s.east<=i.east&&s.south>=i.south&&s.north<=i.north,r=e.east-e.west>this.observerMapImageryViewWidth/2;return!n||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(e){e!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=e,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(e){this.mapSceneBounds=e.map(t=>({x:t.x*this.canvas.width,y:t.y*this.canvas.height,width:t.width*this.canvas.width,height:t.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const e=this.observerMapBoxPx;if(!e)return;const t=[...this.mapShapeBounds,...this.mapSceneBounds],i=(c,h,d)=>{for(const u of t)if(!(u.x+u.width<c-d||u.x>h+d)&&!(u.y>e.bottom+d||u.y+u.height<e.top-d))return!0;return!1},s=[this.canvas.width-e.width,this.canvas.width],n=[0,e.width],r=Zt.OBSERVER_MAP_CLEARANCE_PX,a=i(...s,0),o=i(...n,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&o&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(o||!i(s[0],s[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(s[0],s[1],0)&&!i(n[0],n[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const e=this.observerMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==t&&(this.observerMapCanvas.width=t,this.observerMapCanvas.height=t)}measureObserverMapBox(){const e=this.observerMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=this.canvas.width/t.width,s=this.canvas.height/t.height;this.observerMapBoxPx={width:e.width*i,top:(e.top-t.top)*s,bottom:(e.bottom-t.top)*s}}paintObserverMap(e){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const t=et(this.currentSighting,e);t?.lat!==void 0&&t.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:t.lat,lng:t.lng},Zt.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,s=[],n=this.currentSighting.milestones.length>0?Bm(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?mh(this.currentSighting.milestones):[]){const a=et(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||s.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===n})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?jr.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(Vt.aspectOf(i)):void 0,markers:s,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(e),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.momentsBox.hidden=!e||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,mh(this.sighting.milestones).map(t=>t.t)),this.milestonesButton.setAttribute("aria-pressed",String(e)),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??"",Zt.setIcon(this.milestonesButton,this.milestonesShown?Je.MILESTONES_ON:Je.MILESTONES_OFF);const e=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}observerMapDecorAt(e){const t=et(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const s=Qr(i,e),{lat:n,lng:r}=br(s.eastM,-s.northM,t.lat,t.lng);return{lat:n,lng:r,headingDeg:s.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.observerMapNightFraction&&(this.observerMapNightFraction=t,this.paintObserverMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,i=this.lookPitchDeg+e.pitchDeg;if(t===0&&i===0)return{x:0,y:0};const s=et(this.currentSighting,this.currentTime),n=jr.of(this.currentSighting.instrument,this.canvas.height,s?.fovDeg??60);return{x:-n.angleDegToRadiusPx(t),y:n.angleDegToRadiusPx(i)}}gaitAt(e){return Ti.bodyAt(this.currentSighting,e,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(e){e!==this.mutedState&&(this.mutedState=e,!e&&this.volumeState===0&&(this.volumeState=Zt.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(e){this.setVolume(e)}setVolume(e){this.volumeState=Math.min(Math.max(e,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 e=!this.hasSound;this.miniMuteButton.hidden=e,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),Zt.setIcon(this.miniMuteButton,this.mutedState?Je.MUTED:Je.VOLUME);const t=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=t,this.miniMuteButton.setAttribute("aria-label",t),this.muteButton.disabled=e,this.volumeInput.hidden=e,e){Zt.setIcon(this.muteButton,Je.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}Zt.setIcon(this.muteButton,this.mutedState?Je.MUTED:Je.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 e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;Zt.setIcon(this.fullscreenButton,e?Je.EXIT_FULLSCREEN:Je.ENTER_FULLSCREEN),this.fullscreenButton.title=e?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Fs(Us.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Ha(Us.preferencesFor(this),Ba);if(e===this.messagesLanguage)return;this.messagesLanguage=e;const t=await k_.load(e);this.messagesLanguage===e&&this.applyMessages(t)}messagesLanguage;updateTimeLabelTitles(){const e=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+t,this.timeEndLabel.title=(this.messages?.duration??"")+t,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(e){this.messages=e,this.videoButton&&(this.videoButton.messages=e),this.labelVideoButton(),this.volumeInput.title=e.volume,this.volumeInput.setAttribute("aria-label",e.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 e=this.currentSighting.event,t=Ah(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Yy(e.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(e){if(this.realDurationMs===void 0)return Cc(e);const t=this.currentSighting.timeline.duration,i=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?f2(p2(this.realStartMs+i)):Cc(i)}formatElapsedAt(e){const t=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?Cc(e):Cc(t>0&&e<=t?e/t*this.realDurationMs:e)}formatRemaining(e){const t=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return Cc(Math.max(0,t-e));const i=t>0&&e<=t?e/t*this.realDurationMs:e;return Cc(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?Cc(this.currentSighting.timeline.duration):this.canShowClockTime?f2(p2(this.realStartMs+this.realDurationMs)):Cc(this.realDurationMs)}}function p2(l){const e=new Date(l);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function f2(l){if(l.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return l.second?`${e(l.hour)}:${e(l.minute??0)}:${e(l.second)}`:`${e(l.hour)}:${e(l.minute??0)}`}function Cc(l){const e=Math.round(l/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const Y1="rr0-ufo";function gv(){customElements.get(Y1)||customElements.define(Y1,Zt)}const N8="timechange",F8="recordingissues",RI="minifiedreset";class Ip{constructor(e,t){this.seekInput=e,this.layer=t,e.addEventListener("pointerdown",i=>{this.snapArmed=!0,this.nameMarkUnder(i)}),e.addEventListener("pointerup",()=>this.snapArmed=!1),e.addEventListener("pointermove",i=>this.nameMarkUnder(i)),e.addEventListener("pointerleave",()=>e.removeAttribute("title"))}static SNAP_PX=6;marks=[];duration=0;drawn="";snapArmed=!1;show(e,t){const i=t>0?[...e].sort((n,r)=>n.t-r.t):[],s=`${t}|${i.map(n=>`${n.kind}:${n.t}:${n.label}`).join("|")}`;s!==this.drawn&&(this.drawn=s,this.marks=i,this.duration=t,this.layer.replaceChildren(...i.map(n=>{const r=document.createElement("span");return r.className=`timeline-mark ${n.kind}`,r.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`,r})))}snap(e){return this.snapArmed?(this.snapArmed=!1,this.markNear(e)?.t??e):e}next(e){return this.marks.find(t=>t.t>e+Ip.SAME_INSTANT)?.t}previous(e){return[...this.marks].reverse().find(t=>t.t<e-Ip.SAME_INSTANT)?.t}static SAME_INSTANT=.5;markNear(e){const t=this.seekInput.getBoundingClientRect().width;if(this.duration<=0||t<=0)return;const i=Ip.SNAP_PX/t*this.duration;let s;for(const n of this.marks)Math.abs(n.t-e)>i||(!s||Math.abs(n.t-e)<Math.abs(s.t-e)||n.t===s.t&&n.kind==="milestone")&&(s=n);return s}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect();if(t.width<=0||this.duration<=0)return;const i=this.marksNear((e.clientX-t.left)/t.width*this.duration);i?this.seekInput.title=i:this.seekInput.removeAttribute("title")}marksNear(e){const t=this.markNear(e);if(t)return[...new Set(this.marks.filter(i=>i.t===t.t).map(i=>i.label))].join(" · ")}}class Pd{static HALF_SPAN_MS=2e3;static MIN_SPEED_MS=1;static at(e,t,i){const s=e.event.place?.[0],n=e.observerTrack;if(!s)return 0;const r=m=>{const g=n.getInterpolatedPoseAt(Math.max(0,m));if(!g||g.lat===void 0||g.lng===void 0)return;const v=lt(g.lat,g.lng,s.lat,s.lng);return{eastM:v.x,northM:-v.z,heading:g.headingDeg,aboveM:g.elevationM??0,altitudeM:g.altitudeM}},a=r(t-Pd.HALF_SPAN_MS),o=r(t+Pd.HALF_SPAN_MS),c=r(t);if(!a||!o||!c)return 0;const h=Math.hypot(o.eastM-a.eastM,o.northM-a.northM),d=2*Pd.HALF_SPAN_MS/1e3;if(h/d<Pd.MIN_SPEED_MS)return 0;const u=o.altitudeM!==void 0&&a.altitudeM!==void 0?o.altitudeM-a.altitudeM:i.heightAt(o.eastM,o.northM)+o.aboveM-i.heightAt(a.eastM,a.northM)-a.aboveM,p=Math.atan2(u,h)*180/Math.PI;if(c.heading===void 0)return p;const f=Math.atan2(o.eastM-a.eastM,o.northM-a.northM)*180/Math.PI;return p*Math.max(0,Math.cos((c.heading-f)*Math.PI/180))}}const U8=.08,m2=.15,g2=2,B8=2e3;class v2{context;constructor(e){this.context=e}noiseBuffer;voices=new Map;level=1;master;paused=!0;requested=[];resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("VehicleAudio: Web Audio unavailable, vehicles stay silent:",e);return}}ta.isLive(this.context)&&ta.unlock(this.context),this.apply()}setLevel(e){this.level=e,this.master&&(this.master.gain.value=e)}setPaused(e){e!==this.paused&&(this.paused=e,this.apply())}setVoices(e){this.requested=e,this.apply()}dispose(){for(const e of[...this.voices.keys()])this.release(e);ta.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0}masterOf(e){return this.master||(this.master=e.createGain(),this.master.gain.value=this.level,this.master.connect(e.destination)),this.master}apply(){const e=this.context;if(!e)return;const t=this.paused?[]:this.requested.filter(s=>s.inside||s.distanceM<B8),i=new Set(t.map(s=>s.id));for(const s of[...this.voices.keys()])i.has(s)||this.release(s);for(const s of t){const n=this.voices.get(s.id)??this.build(e,s.id);this.retarget(e,n,s)}}build(e,t){const i=e.createGain();i.gain.value=0;const s=e.createBiquadFilter();s.type="lowpass",s.connect(i).connect(this.masterOf(e));const n=e.createOscillator();n.type="sawtooth";const r=e.createOscillator();r.type="sine";const a=e.createGain(),o=e.createBiquadFilter();o.type="lowpass",o.frequency.value=900,n.connect(o),r.connect(o),o.connect(a).connect(s);const c=()=>{const M=e.createBufferSource();return M.buffer=this.noise(e),M.loop=!0,M.loopStart=Math.random()*g2*.5,M},h=c(),d=e.createBiquadFilter();d.type="bandpass",d.Q.value=4;const u=e.createGain();h.connect(d).connect(u).connect(s);const p=c(),f=e.createBiquadFilter();f.type="lowpass",f.frequency.value=600;const m=e.createGain();p.connect(f).connect(m).connect(s);const g=c(),v=e.createBiquadFilter();v.type="bandpass",v.frequency.value=1400,v.Q.value=.7;const b=e.createGain();g.connect(v).connect(b).connect(s);const w=[n,r,h,p,g];for(const M of w)M.start();const y={nodes:[i,s,a,o,d,u,f,m,v,b,...w],sources:w,firing:n,crank:r,knock:d,engineGain:a,knockGain:u,roadGain:m,windGain:b,cabin:s,output:i};return this.voices.set(t,y),y}retarget(e,t,{profile:i,state:s,noise:n,inside:r,windowsOpen:a,distanceM:o}){const c=e.currentTime,h=(b,w)=>b.setTargetAtTime(w,c,U8),d=s.rpm/60,u=d*i.cylinders/2,p=Math.min(1,s.rpm/i.shiftUpRpm),f=Math.min(1.5,s.speedMps/30);h(t.firing.frequency,u),h(t.crank.frequency,d),h(t.knock.frequency,u*3),h(t.engineGain.gain,i.engineGain*(.25+.75*s.load)*(.5+.5*p)*.3),h(t.knockGain.gain,i.roughness*(.2+.8*s.load)*.4),h(t.roadGain.gain,i.roadGain*f**1.5*.8);const m=!r||a;h(t.windGain.gain,f**2*(m?.5:.06));const g=r?a?3500:700:8e3/(1+o/60);h(t.cabin.frequency,g);const v=r?.5:Math.min(1,8/Math.max(o,1));h(t.output.gain,v*n)}release(e){const t=this.voices.get(e);if(!t)return;this.voices.delete(e);const i=this.context;i&&(t.output.gain.setTargetAtTime(0,i.currentTime,m2/3),setTimeout(()=>{for(const s of t.sources)try{s.stop()}catch{}for(const s of t.nodes)s.disconnect()},m2*1e3*3))}noise(e){if(this.noiseBuffer)return this.noiseBuffer;const t=e.createBuffer(1,e.sampleRate*g2,e.sampleRate),i=t.getChannelData(0);for(let s=0;s<i.length;s++)i[s]=Math.random()*2-1;return this.noiseBuffer=t,t}}class Nf{static BY_KIND={car:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},generic:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},van:{cylinders:4,idleRpm:750,kmhPer1000Rpm:[7,12,19,27,35,42],shiftUpRpm:2600,shiftDownRpm:1200,engineGain:.8,roadGain:.7,roughness:.45},truck:{cylinders:6,idleRpm:600,kmhPer1000Rpm:[5,8,12,17,23,30,38,48],shiftUpRpm:1900,shiftDownRpm:1e3,engineGain:1,roadGain:.9,roughness:.55},motorcycle:{cylinders:2,idleRpm:1100,kmhPer1000Rpm:[12,18,24,30,35,40],shiftUpRpm:6e3,shiftDownRpm:2500,engineGain:.9,roadGain:.3,roughness:.3}};static of(e){return Nf.BY_KIND[e??"generic"]??Nf.BY_KIND.generic}}class Rn{static ROAD_KINDS=["car","van","truck","motorcycle","generic"];static OPEN_AIR=[0,0,0,0,0,0,0,0];static ROAD_CLOSED_DB=[10,14,18,22,25,28,30,32];static WINDOWS_OPEN_DB=[2,3,4,5,6,7,8,9];static FUSELAGE_DB=[14,18,23,28,32,36,38,40];static CANOPY_DB=[3,4,6,8,10,12,14,16];static CANOPIED=["glider","balloon","ultralight"];static isRoad(e){return Rn.ROAD_KINDS.includes(e)}static roadOf(e){return e&&Rn.isRoad(e.kind)?e.kind:void 0}static aircraftOf(e){return e&&!Rn.isRoad(e.kind)?e.kind:void 0}static transmission(e){const t=Rn.insulationDb(e),i=[3,4,5].map(s=>t[s]);return 10**(-(i.reduce((s,n)=>s+n,0)/i.length)/20)}static insulationDb(e){return e?e.windowsOpen===!0?Rn.WINDOWS_OPEN_DB:Rn.isRoad(e.kind)?Rn.ROAD_CLOSED_DB:Rn.CANOPIED.includes(e.kind)?Rn.CANOPY_DB:Rn.FUSELAGE_DB:Rn.OPEN_AIR}}class oh{constructor(e,t){this.samples=e,this.startMs=t}static SAMPLE_MS=100;static STANDING_MPS=.3;static of(e,t,i,s){const n=oh.SAMPLE_MS,r=[];for(let c=i;c<=s+n/2;c+=n){const h=t(c-n/2),d=t(c+n/2);if(!h||!d)return;r.push(Math.hypot(d.eastM-h.eastM,d.northM-h.northM)/(n/1e3))}const a=[];let o=1;for(let c=0;c<r.length;c++){const h=r[c],d=(r[Math.min(c+1,r.length-1)]-r[Math.max(c-1,0)])/(2*n/1e3);if(h<oh.STANDING_MPS){o=1,a.push({speedMps:h,rpm:e.idleRpm,load:.1,gear:0});continue}const u=h*3.6,p=v=>u/e.kmhPer1000Rpm[v-1]*1e3;for(;o<e.kmhPer1000Rpm.length&&p(o)>e.shiftUpRpm;)o++;for(;o>1&&p(o)<e.shiftDownRpm;)o--;const f=Math.max(p(o),e.idleRpm*(1+.3*Math.min(1,h/3))),m=.15+.5*Math.min(1,(h/35)**2),g=d>.15?Math.min(1,m+d/2.5):d<-.3?.05:m;a.push({speedMps:h,rpm:f,load:g,gear:o})}return new oh(a,i)}at(e){const t=(e-this.startMs)/oh.SAMPLE_MS,i=Math.min(Math.max(Math.floor(t),0),this.samples.length-1),s=this.samples[i],n=this.samples[Math.min(i+1,this.samples.length-1)],r=Math.min(Math.max(t-i,0),1);return{speedMps:s.speedMps+(n.speedMps-s.speedMps)*r,rpm:s.rpm+(n.rpm-s.rpm)*r,load:s.load+(n.load-s.load)*r,gear:r<.5?s.gear:n.gear}}}class Sg{drives=new Map;at(e,t){const i=[],s=e.event.place?.[0],n=h=>{const d=e.observerTrack.getInterpolatedPoseAt(h),u=d?.lat??s?.lat,p=d?.lng??s?.lng;if(u===void 0||p===void 0||!s)return;const f=lt(u,p,s.lat,s.lng);return{eastM:f.x,northM:-f.z}},r=Math.max(e.observerTrack.duration,(e.event.durationSeconds??0)*1e3),a=e.vehicle,o=Rn.roadOf(a);if(a&&o){const h=Nf.of(o),d=this.drive(`observer:${o}`,Sg.trackKey(e),()=>oh.of(h,n,0,r));d&&i.push({id:"observer",profile:h,state:d.at(t),noise:a.noise??1,inside:!0,windowsOpen:a.windowsOpen===!0,distanceM:0})}const c=n(t);for(const h of e.decor){if(!h.engine||!c)continue;const d=Nf.of(h.engine.kind),u=g=>{const v=Qr(h,g);return{eastM:v.eastM,northM:v.northM}},p=this.drive(`decor:${h.id}`,Sg.decorKey(h,r),()=>oh.of(d,u,0,r));if(!p)continue;const f=Qr(h,t),m=Math.hypot(f.eastM-c.eastM,f.northM-c.northM,f.altitudeM);i.push({id:`decor:${h.id}`,profile:d,state:p.at(t),noise:h.engine.noise??1,inside:!1,windowsOpen:!0,distanceM:m})}return i}drive(e,t,i){const s=this.drives.get(e);if(s&&s.key===t)return s.drive;const n=i();return this.drives.set(e,{key:t,drive:n}),n}static trackKey(e){return e.observerTrack.allKeyframes.map(i=>`${i.t}:${i.pose.lat}:${i.pose.lng}`).join(";")}static decorKey(e,t){return`${t}|${e.eastM},${e.northM}|`+(e.track??[]).map(i=>`${i.t}:${i.eastM}:${i.northM}`).join(";")}}const z8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAARVBMVEX9sST/uyTfoCjNlSikfCqRcCx8Yy21hipTSi4TITEMHTEuMzBqWC3/wSRUX207SFj8/PyaoakmNUd5gYxBPy90fIfMz9RsB4kZAAACEUlEQVRo3u2XyXbDIAxFLeapjts6/f9PrQA3JymT25Cd3iY5xtYVIB6wLCQSiUQikUgk0nzBoVdFZ1xIpaTQbJnPACaNdYeskWwuAhaZoltnUemfnNkL4N49KEI8n0YAEXMvEWISAWQZPw2Xk1MIoF1dSNAzCMy6JsGyCR0wrkMwT3cBeDt+FH8aEHoA68LbM8HRHXQ3f0RE3/jXOOFX+s4djrKpIbzS7K+MmLrxlWCNR8mczjMw92Ar4dZLDXG4kzXinAECcOUPL3jMdN2294/GQGVG4EMHxORNJXoCfG6oT1trvDGM7iIA9N6aTOuuEbB9ra6FyCYr2gjge+fjA4CIi2uujYRoOBSw0A5/D0hT0X4PW0xtuotNpQPYtkt/fdtyM0LP6ZvOI2DtvoxtJWHvx38AxIkevLwXQ2TOA66DziYfLwC4r5wbIlwJo1ys8+VOBMy7/sxdjwIap49lVC3UePZp1mmyit4SuGUf11pjoTHVRVzXUaXFVt87kuEBsWZ055Q+2sXA76LbZYsvKR1ubvJqbKd5swl+GPI31p6L/sNYuDTe3jo+GBdr1J+P9PGawbRUw9VhleD/3ffT9uZ7DhtX1JNHL2CmNRXxYZhwSwBd3aJTyU85/GKOwhxBf5RnVk+75OSiuu+Ax4PQ3Jsg1hTeMUMwJgQp+PKCe2a+JuefFwQnkUgkEolEIpFerW8TL0hlNl2QVAAAAABJRU5ErkJggg==",H8=`
|
|
8887
8913
|
<div class="stage" id="stage">
|
|
8888
8914
|
<div class="frame" id="frame">
|
|
8889
8915
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -11507,7 +11533,7 @@ ${c.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissive
|
|
|
11507
11533
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
11508
11534
|
}
|
|
11509
11535
|
`,transparent:!0,depthWrite:!1,side:on,fog:!1,blending:Th,blendSrc:Ih,blendDst:yf})}static wallReflectance(e,t,i){const s=i(e,1,t);return 2*s/(1+s)}static DISCS={uDiscDirection:{value:[new I(0,1,0),new I(0,1,0)]},uDiscCosRadius:{value:[2,2]},uDiscRadiance:{value:[new I,new I]}};static DISC_INDEX={sun:0,moon:1};static setDisc(e,t){const i=Zn.DISC_INDEX[e],s=Zn.DISCS;if(!t){s.uDiscCosRadius.value[i]=2,s.uDiscRadiance.value[i].set(0,0,0);return}s.uDiscDirection.value[i].set(...t.direction).normalize(),s.uDiscCosRadius.value[i]=Math.cos(t.radiusRad),s.uDiscRadiance.value[i].set(...t.radiance)}setSurroundings(e){this.uniforms.uSurroundings.value=e}static reflectedResponse(e,t){return Ke.respond(t*Ke.relativeOfResponse(Math.max(e,1e-5)))}}class Tr{static SIZE=64;static MOVE_M=.01;holder=new ns;cameras=[];faces=[];target=new di(Tr.SIZE,Tr.SIZE);white=new yr({color:new ce(1,1,1),side:on});scene=new ia;cabin;meshes=0;eye=new I;scratch=new I;constructor(){const e=[[new I(1,0,0),new I(0,1,0)],[new I(-1,0,0),new I(0,1,0)],[new I(0,1,0),new I(0,0,1)],[new I(0,-1,0),new I(0,0,-1)],[new I(0,0,1),new I(0,1,0)],[new I(0,0,-1),new I(0,1,0)]];for(const[t,i]of e){const s=new On(90,1,.02,20);s.up.copy(i),s.lookAt(t),this.holder.add(s),this.cameras.push(s),this.faces.push(new Uint8Array(Tr.SIZE*Tr.SIZE*4))}this.scene.background=new ce(0,0,0)}get any(){return this.cabin!==void 0}update(e,t,i){if(!t){this.forget();return}t.updateWorldMatrix(!0,!0);const s=this.scratch.copy(i);t.worldToLocal(s);let n=0;t.traverse(r=>{r.isMesh&&n++}),!(t===this.cabin&&n===this.meshes&&s.distanceTo(this.eye)<Tr.MOVE_M)&&(this.cabin=t,this.meshes=n,this.eye.copy(s),this.draw(e,t))}hides(e){if(!this.cabin)return!1;this.holder.updateWorldMatrix(!0,!0);for(let t=0;t<6;t++){const i=this.cameras[t],s=this.scratch.copy(e).transformDirection(i.matrixWorldInverse);if(s.z>=0)continue;const n=s.x/-s.z,r=s.y/-s.z;if(Math.abs(n)>1||Math.abs(r)>1)continue;const a=Math.min(Tr.SIZE-1,Math.floor((n+1)/2*Tr.SIZE)),o=Math.min(Tr.SIZE-1,Math.floor((r+1)/2*Tr.SIZE));return this.faces[t][(o*Tr.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(e,t){t.add(this.holder),this.holder.position.copy(this.eye),this.holder.updateWorldMatrix(!0,!0);const i=[];t.traverse(r=>{const a=r;if(!a.isMesh||!a.visible||(Array.isArray(a.material)?a.material:[a.material]).every(h=>h instanceof Zn))return;const c=new ve(a.geometry,this.white);c.matrixAutoUpdate=!1,c.matrix.copy(a.matrixWorld),c.matrixWorld.copy(a.matrixWorld),i.push(c)});for(const r of i)this.scene.add(r);const s=e.getRenderTarget(),n=e.shadowMap.autoUpdate;e.shadowMap.autoUpdate=!1;for(let r=0;r<6;r++){const a=this.cameras[r];a.updateMatrixWorld(!0),e.setRenderTarget(this.target),e.clear(),e.render(this.scene,a),Cg.now(e,this.target,0,0,Tr.SIZE,Tr.SIZE,this.faces[r])}e.setRenderTarget(s),e.shadowMap.autoUpdate=n;for(const r of i)r.removeFromParent()}}const Vb="https://ufoathome.org/models/index.json";class Np{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;static shared=new Map;sharing;constructor(e={}){this.sharing=!e.fetchImpl,this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??l7()}async entries(e){const t=await this.load();return e?t.filter(i=>[i.kind].flat().includes(e)):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){if(this.loading)return this.loading;if(!this.sharing)return this.loading=this.fetchFirstAvailable();const e=this.indexUrls.join(`
|
|
11510
|
-
`);let t=Np.shared.get(e);return t||(t=this.fetchFirstAvailable(),Np.shared.set(e,t),t.then(i=>{i.length===0&&Np.shared.delete(e)})),this.loading=t}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const i=await t.json();return Array.isArray(i?.models)?i.models.map(({file:s,...n})=>({...n,url:new URL(s,e).href})):void 0}catch{return}}}function l7(){const l=`?v=${encodeURIComponent("0.
|
|
11536
|
+
`);let t=Np.shared.get(e);return t||(t=this.fetchFirstAvailable(),Np.shared.set(e,t),t.then(i=>{i.length===0&&Np.shared.delete(e)})),this.loading=t}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const i=await t.json();return Array.isArray(i?.models)?i.models.map(({file:s,...n})=>({...n,url:new URL(s,e).href})):void 0}catch{return}}}function l7(){const l=`?v=${encodeURIComponent("0.192.0")}`,e=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(e&&e!==Vb?[e,Vb]:[Vb]).map(t=>t+l)}const ow=Xe.point("decorModels").provide(Xe.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 Np}]);class Fp{constructor(e,t=ow){this.preferredId=e,this.sources=t}attribution="3D models, each under its own author's licence";built=new Map;catalogues(){const e=this.sources.find(i=>i.id===this.preferredId)??this.sources[0];return(e?[e,...this.sources.filter(i=>i!==e)]:[]).map(i=>{let s=this.built.get(i);return s||(s=i.create(),this.built.set(i,s)),s})}entries(e){const t=this.catalogues()[0];return t?t.entries(e):Promise.resolve([])}async entry(e){for(const t of this.catalogues()){const i=await t.entry(e).catch(()=>{});if(i)return i}}async moduleOf(e){const t=Xe.point("decorModels");for(const i of this.sources){const s=t.ownerOf(i.id);if(!(s===void 0||s===Xe.BUILT_IN)&&await this.catalogueOf(i).entry(e).catch(()=>{}))return s}}catalogueOf(e){return this.catalogues(),this.built.get(e)}}async function Wb(l){const{GLTFLoader:e}=await V(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-DdijxzcI.js");return{GLTFLoader:i}},[],import.meta.url),t=new e;return new Promise((i,s)=>{t.load(l,n=>i(Object.assign(n.scene,{animations:n.animations})),void 0,n=>s(new Error(`Could not load 3D model ${l}: ${n instanceof Error?n.message:String(n)}`)))})}class Yr{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(e,t){this.mesh=new ve(new nr(2,2),new Nt({uniforms:{uColor:{value:new ce(0,0,0)},uRadius:{value:1}},vertexShader:Yr.VERTEX,fragmentShader:Yr.FRAGMENT,transparent:!0,depthWrite:!1,blending:dn,toneMapped:!1})),this.mesh.name=e,this.mesh.frustumCulled=!1,this.mesh.renderOrder=t,this.mesh.visible=!1}shine(e,t,i){this.mesh.visible=!0,this.mesh.position.set(e.x,e.y,e.z),this.mesh.material.uniforms.uRadius.value=t,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(e,t,i,s){const n=Math.max(e,s*Yr.MIN_ANGLE_RAD),r=Yr.FILL*Math.PI*n*n;return{radiusM:n,luminanceCdM2:i*Math.min(Yr.MAX_SHARE,t/r)}}static conserving(e){return Math.sqrt(e/(Yr.MAX_SHARE*Yr.FILL*Math.PI))}static VERTEX=`
|
|
11511
11537
|
uniform float uRadius;
|
|
11512
11538
|
varying vec2 vOffset;
|
|
11513
11539
|
void main() {
|
|
@@ -12149,7 +12175,7 @@ void main() {
|
|
|
12149
12175
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
12150
12176
|
}
|
|
12151
12177
|
`;function LA(l){const t=document.createElement("canvas");t.width=128,t.height=128;const i=t.getContext("2d"),s=128/2-2,n=128/2,r=128/2,a="#010101",o="#f4f1e2";i.fillStyle=a,i.beginPath(),i.arc(n,r,s,0,Math.PI*2),i.fill();const c=so(l.illuminatedFraction,0,1),h=l.phaseFraction<.5,d=s*Math.abs(1-2*c),u=c<.5;return i.save(),i.beginPath(),i.arc(n,r,s,0,Math.PI*2),i.clip(),i.fillStyle=o,i.beginPath(),h?(i.arc(n,r,s,-Math.PI/2,Math.PI/2,!1),i.ellipse(n,r,d,s,0,Math.PI/2,-Math.PI/2,u)):(i.arc(n,r,s,Math.PI/2,-Math.PI/2,!1),i.ellipse(n,r,d,s,0,-Math.PI/2,Math.PI/2,u)),i.fill(),i.restore(),new _l(t)}function cU(l){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(l,64,68),new _l(e)}function by(l){let e=l;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}class Fg{constructor(e,t){this.source=e,this.create=t}scene;wanted;pumping=!1;disposed=!1;static PATIENCE_FRAMES=600;static SCENE_WIDTH_PX=480;paint(e,t){this.disposed||(this.wanted={t:e,canvas:t},this.pumping||this.pump())}recordingChanged(e){this.scene&&(this.scene.sightingData=e)}dispose(){this.disposed=!0,this.scene?.remove(),this.scene=void 0}ensureScene(){if(this.scene)return this.scene;const e=this.create();return e.setAttribute("max-pixel-ratio","1"),e.setAttribute("always-live",""),Object.assign(e.style,{position:"fixed",left:"-10000px",top:"0",width:`${Fg.SCENE_WIDTH_PX}px`,visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(e),e.documentUrl=this.source.documentUrl,e.accountInTheRound=this.source.accountInTheRound,e.sightingData=this.source.sightingData,this.scene=e,e}async pump(){this.pumping=!0;try{for(;this.wanted&&!this.disposed;){const{t:e,canvas:t}=this.wanted;this.wanted=void 0;const i=this.ensureScene();i.interpretation!==this.source.interpretation&&(i.interpretation=this.source.interpretation),i.compareAccount!==this.source.compareAccount&&(i.compareAccount=this.source.compareAccount),i.showAt(e);for(let s=0;s<Fg.PATIENCE_FRAMES&&!this.wanted&&!this.disposed&&(await new Promise(n=>requestAnimationFrame(()=>n())),!this.wanted);s++)if(i.snapshotTo(t)){t.dataset.ready="true";break}}}finally{this.pumping=!1}}}class Lt{static held=new Map;static loaded=new Map;static generation=0;static address(e,t){const i=t??(typeof location>"u"?"http://localhost/":location.href);return new URL(e,i).href}static hold(e,t){Lt.held.set(e,t),Lt.loaded.delete(e),Lt.generation++}static release(){if(Lt.held.size!==0){for(const e of Lt.held.keys())Lt.loaded.delete(e);Lt.held.clear(),Lt.generation++}}static bytes(e,t=fetch.bind(globalThis)){const i=Lt.held.get(e);if(i)return Promise.resolve(i);let s=Lt.loaded.get(e);return s||(s=t(e).then(async n=>{if(!n.ok)throw new Error(`Frozen data not found (${n.status}): ${e}`);return new Uint8Array(await n.arrayBuffer())}),Lt.loaded.set(e,s),s.catch(()=>Lt.loaded.delete(e))),s}static async json(e){return JSON.parse(new TextDecoder().decode(await Lt.bytes(e)))}static async zip(e){const t=await Lt.bytes(e),{unzipSync:i}=await V(async()=>{const{unzipSync:s}=await import("./browser-CltifEM0.js");return{unzipSync:s}},[],import.meta.url);return i(t)}}class wr{static SAME_BOUNDS_DEG=1e-9;loaded=!1;ready;list=[];constructor(e){this.ready=e.then(t=>{this.list=t},()=>{}).finally(()=>{this.loaded=!0})}nearest(e,t){let i,s=1/0;for(const n of this.list){if(n.far)continue;const{x:r,z:a}=lt(n.lat,n.lng,e,t),o=Math.hypot(r,a);o<s&&(s=o,i=n)}return i}farRingOf(e,t){return this.list.find(i=>i.far&&Math.abs(i.lat-e)<=wr.SAME_BOUNDS_DEG&&Math.abs(i.lng-t)<=wr.SAME_BOUNDS_DEG)}static boundsOf(e){return Op(e.lat,e.lng,e.radiusM)}static sameBounds(e,t){const i=(s,n)=>Math.abs(s-n)<=wr.SAME_BOUNDS_DEG;return i(e.north,t.north)&&i(e.south,t.south)&&i(e.east,t.east)&&i(e.west,t.west)}static contains(e,t){return e.north>=t.north&&e.south<=t.south&&e.east>=t.east&&e.west<=t.west}static samePatches(e,t){return e.length===t.length&&e.every((i,s)=>i.lat===t[s].lat&&i.lng===t[s].lng&&i.radiusM===t[s].radiusM&&i.far===t[s].far)}}class Uf{static async encode(e){const{zipSync:t,strToU8:i}=await V(async()=>{const{zipSync:r,strToU8:a}=await import("./browser-CltifEM0.js");return{zipSync:r,strToU8:a}},[],import.meta.url),s={},n={version:1,takenOn:e.takenOn,attribution:e.attribution,patches:e.patches.map((r,a)=>{const o=`${a}.f32`;return s[o]=Uf.byPlane(r.grid.heights),{lat:r.lat,lng:r.lng,radiusM:r.radiusM,...r.far?{far:r.far}:{},bounds:r.grid.bounds,width:r.grid.width,height:r.grid.height,file:o}})};return s["index.json"]=i(JSON.stringify(n,null,1)),t(s,{level:9})}static decode(e){const t=e["index.json"];if(!t)throw new Error("A relief annex without its index");const i=JSON.parse(new TextDecoder().decode(t));return{takenOn:i.takenOn,attribution:i.attribution,patches:i.patches.flatMap(s=>{const n=e[s.file];if(!n||n.length!==s.width*s.height*4)return[];const r={heights:Uf.fromPlanes(n),width:s.width,height:s.height,bounds:s.bounds};return[{lat:s.lat,lng:s.lng,radiusM:s.radiusM,...s.far?{far:s.far}:{},grid:r}]})}}static byPlane(e){const t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=e.length,s=new Uint8Array(t.length);for(let n=0;n<i;n++)for(let r=0;r<4;r++)s[r*i+n]=t[n*4+r];return s}static fromPlanes(e){const t=e.length/4,i=new Uint8Array(e.length);for(let s=0;s<t;s++)for(let n=0;n<4;n++)i[s*4+n]=e[n*t+s];return new Float32Array(i.buffer)}}class DM{constructor(e){this.annex=e}async getElevationGrid(e,t,i){const{patches:s}=await this.annex,n=s.find(a=>wr.sameBounds(wr.boundsOf(a),e));if(n)return{...n.grid,heights:new Float32Array(n.grid.heights)};const r=s.find(a=>wr.contains(a.grid.bounds,e));if(r)return DM.resample(r.grid,e,t);throw new Error("The snapshots relief does not hold this ground")}static resample(e,t,i){const{width:s,height:n}=i,r=new Float32Array(s*n),a=e.bounds.east-e.bounds.west,o=e.bounds.north-e.bounds.south;for(let c=0;c<n;c++){const h=t.north-(t.north-t.south)*(n>1?c/(n-1):0),d=Math.min(e.height-1,Math.max(0,(e.bounds.north-h)/o*(e.height-1))),u=Math.floor(d),p=Math.min(e.height-1,u+1),f=d-u;for(let m=0;m<s;m++){const g=t.west+(t.east-t.west)*(s>1?m/(s-1):0),v=Math.min(e.width-1,Math.max(0,(g-e.bounds.west)/a*(e.width-1))),b=Math.floor(v),w=Math.min(e.width-1,b+1),y=v-b,M=(E,A)=>e.heights[E*e.width+A],x=M(u,b)*(1-y)+M(u,w)*y,S=M(p,b)*(1-y)+M(p,w)*y;r[c*s+m]=x*(1-f)+S*f}}return{heights:r,width:s,height:n,bounds:t}}}function Yi(l,e){return l.find(t=>t.id===e)??l[0]}class lU{attribution;fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis);const t=e.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${t}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${t})`}async getImageryTexture(e,t){return EI(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}const b0=Xe.point("elevation").provide(Xe.BUILT_IN,[{id:"ign-mnt",name:"IGN LiDAR HD / RGE ALTI",credit:"Relief © IGN, LiDAR HD and RGE ALTI (Licence Ouverte 2.0) in France; © AWS Open Data (SRTM, ETOPO1) elsewhere",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>TI()},{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new xI}]),wh=Xe.point("imagery").provide(Xe.BUILT_IN,[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:l=>new SI({fetchImpl:l})},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:l=>new lU({fetchImpl:l})}]);class PA{constructor(e=fetch.bind(globalThis)){this.fetchImpl=e}tiles=new Map;fetch=async(e,t)=>{const i=await this.fetchImpl(e,t);if(i.ok){const s=typeof e=="string"?e:e instanceof URL?e.href:e.url,n=new Uint8Array(await i.clone().arrayBuffer());this.tiles.set(s,{bytes:n,type:i.headers.get("content-type")??"image/jpeg"})}return i}}class Ug{static async encode(e){const{zipSync:t,strToU8:i}=await V(async()=>{const{zipSync:o,strToU8:c}=await import("./browser-CltifEM0.js");return{zipSync:o,strToU8:c}},[],import.meta.url),s={},n={};let r=0;for(const[o,c]of e.tiles){const h=`tiles/${r++}`;s[h]=c.bytes,n[o]={file:h,type:c.type}}const a={version:1,takenOn:e.takenOn,source:e.source,attribution:e.attribution,patches:e.patches,map:e.map,tiles:n};return s["index.json"]=i(JSON.stringify(a,null,1)),t(s,{level:0})}static decode(e){const t=e["index.json"];if(!t)throw new Error("An imagery annex without its index");const i=JSON.parse(new TextDecoder().decode(t)),s=new Map;for(const[n,{file:r,type:a}]of Object.entries(i.tiles)){const o=e[r];o&&s.set(n,{bytes:o,type:a})}return{takenOn:i.takenOn,source:i.source,attribution:i.attribution,patches:i.patches,map:i.map,tiles:s}}}class Mv{constructor(e,t=""){this.annex=e,this.attributionStated=t}provider;attributionRead;get attribution(){return this.attributionRead??this.attributionStated}async getImageryTexture(e,t){return(await(this.provider??=this.annex.then(s=>(this.attributionRead=s.attribution,Yi(wh,s.source).create(Mv.fetchFrom(s.tiles)))))).getImageryTexture(e,t)}static fetchFrom(e){return async t=>{const i=typeof t=="string"?t:t instanceof URL?t.href:t.url,s=e.get(i);return s?new Response(s.bytes,{status:200,headers:{"content-type":s.type}}):new Response(null,{status:404})}}}class hU{constructor(e,t=""){this.annex=e,this.attributionStated=t}picture;attributionRead;get attribution(){return this.attributionRead??this.attributionStated}getImagery(){return this.picture??=this.annex.then(e=>{if(!e.map)throw new Error("An imagery annex that holds no map");return this.attributionRead=e.attribution,Yi(wh,e.source).create(Mv.fetchFrom(e.tiles)).getImageryTexture(e.map.bounds,{width:e.map.pixels,height:e.map.pixels})})}}class kM{constructor(e){this.annex=e}attributionRead;contemporaryRead;async itemsFor(e){const t=await this.annex;return this.attributionRead=t.attribution,this.contemporaryRead=t.contemporary,t.patches.find(i=>wr.sameBounds(wr.boundsOf(i),e))?.items??[]}}class dU{constructor(e,t=""){this.attributionStated=t,this.reader=new kM(e)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}get contemporary(){return this.reader.contemporaryRead??!0}getRoads(e){return this.reader.itemsFor(e)}}class uU{constructor(e,t=""){this.attributionStated=t,this.reader=new kM(e)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}getWater(e){return this.reader.itemsFor(e)}}class pU{constructor(e,t=""){this.attributionStated=t,this.reader=new kM(e)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}get contemporary(){return this.reader.contemporaryRead??!0}getRailways(e){return this.reader.itemsFor(e)}}class Bg{static providers(e,t,i){const s=p=>us.held(e,p),n=s("relief"),r=s("imagery"),a=s("roads"),o=s("water"),c=s("railways");if(!n&&!r&&!a&&!o&&!c)return i;const h=p=>Lt.address(p.src,t),d=[],u={...i};if(n){const p=Lt.zip(h(n)).then(f=>Uf.decode(f));u.elevation=new DM(p),d.push(p.then(f=>f.patches))}if(r){const p=Lt.zip(h(r)).then(f=>Ug.decode(f));u.imagery=new Mv(p,r.attribution),d.push(p.then(f=>f.patches))}if(a){const p=Lt.json(h(a));u.roads=new dU(p,a.attribution),d.push(p.then(f=>f.patches))}if(o){const p=Lt.json(h(o));u.water=new uU(p,o.attribution),d.push(p.then(f=>f.patches))}if(c){const p=Lt.json(h(c));u.railways=new pU(p,c.attribution),d.push(p.then(f=>f.patches))}return u.patches=new wr(Bg.firstRead(d)),u}static map(e,t){const i=Lt.zip(Lt.address(e.src,t)).then(s=>Ug.decode(s));return new hU(i,e.attribution)}static async firstRead(e){for(const t of e)try{const i=await t;if(i.length>0)return i.map(({lat:s,lng:n,radiusM:r,far:a})=>({lat:s,lng:n,radiusM:r,...a?{far:a}:{}}))}catch{}return[]}}const vd="https://en.wikipedia.org/wiki/Kodachrome",Gl="https://en.wikipedia.org/wiki/Kodacolor_(still_photography)",fU="https://en.wikipedia.org/wiki/Kodak_Tri-X",bd="https://en.wikipedia.org/wiki/List_of_discontinued_photographic_films",Go="https://www.kodak.com/en/motion/page/chronology-of-film/",Gr=(l,e)=>[{format:"135",from:l,to:e},{format:"120",from:l,to:e}],Vo=(l,e)=>[{format:"35mm-cine",from:l,to:e}],NA=[{id:"kodacolor",name:"Kodacolor",kind:"negative",iso:32,formats:Gr(1942,1963),source:Gl},{id:"kodacolor-x",name:"Kodacolor-X",kind:"negative",iso:80,formats:[...Gr(1963,1974),{format:"126",from:1963,to:1974}],source:Gl},{id:"kodacolor-ii",name:"Kodacolor II",kind:"negative",iso:100,formats:[...Gr(1973),{format:"126",from:1973}],source:Gl},{id:"kodacolor-400",name:"Kodacolor 400",kind:"negative",iso:400,formats:Gr(1977),source:Gl},{id:"kodacolor-vr-100",name:"Kodacolor VR 100",kind:"negative",iso:100,formats:Gr(1982,1986),source:Gl},{id:"kodacolor-vr-200",name:"Kodacolor VR 200",kind:"negative",iso:200,formats:[...Gr(1982,1986),{format:"126",from:1982,to:1986}],source:Gl},{id:"kodacolor-vr-400",name:"Kodacolor VR 400",kind:"negative",iso:400,formats:Gr(1982,1986),source:Gl},{id:"agfacolor-cn17",name:"Agfacolor CN17",kind:"negative",iso:40,formats:Gr(1956,1971),source:bd},{id:"agfacolor-cns",name:"Agfacolor CNS",kind:"negative",iso:80,formats:[...Gr(1968,1975),{format:"126",from:1968,to:1975}],source:bd},{id:"agfacolor-cns-2",name:"Agfacolor CNS 2",kind:"negative",iso:80,formats:[...Gr(1971,1982),{format:"126",from:1971,to:1982}],source:bd},{id:"agfacolor-cns-400",name:"Agfacolor CNS 400",kind:"negative",iso:400,formats:Gr(1978,1984),source:bd},{id:"kodachrome",name:"Kodachrome",kind:"slide",iso:10,formats:[{format:"135",from:1936,to:1962}],source:vd},{id:"kodachrome-ii",name:"Kodachrome II",kind:"slide",iso:25,formats:[{format:"135",from:1961,to:1974}],source:vd},{id:"kodachrome-x",name:"Kodachrome-X",kind:"slide",iso:64,formats:[{format:"135",from:1962,to:1974},{format:"126",from:1963,to:1974}],source:vd},{id:"kodachrome-25",name:"Kodachrome 25",kind:"slide",iso:25,formats:[{format:"135",from:1974,to:2001}],source:vd},{id:"kodachrome-64",name:"Kodachrome 64",kind:"slide",iso:64,formats:[{format:"135",from:1974,to:2009},{format:"126",from:1974,to:1993}],source:vd},{id:"kodachrome-200",name:"Kodachrome 200",kind:"slide",iso:200,formats:[{format:"135",from:1988,to:2007}],source:vd},{id:"agfachrome-ct18",name:"Agfachrome CT18",kind:"slide",iso:50,formats:[...Gr(1958,1984),{format:"126",from:1958,to:1984}],source:bd},{id:"agfachrome-ct21",name:"Agfachrome CT21",kind:"slide",iso:100,formats:[{format:"135",from:1974,to:1984}],source:bd},{id:"tri-x",name:"Kodak Tri-X",kind:"negative",monochrome:!0,iso:400,formats:Gr(1954),source:fU},{id:"eastman-5247-1950",name:"Eastman Color Negative 5247 (1950)",kind:"negative",iso:16,formats:Vo(1950,1952),source:Go},{id:"eastman-5248-1952",name:"Eastman Color Negative 5248 (1952)",kind:"negative",iso:16,formats:Vo(1952,1959),source:Go},{id:"eastman-5250",name:"Eastman Color Negative 5250",kind:"negative",iso:32,formats:Vo(1959,1962),source:Go},{id:"eastman-5251",name:"Eastman Color Negative 5251",kind:"negative",iso:50,light:"tungsten",formats:Vo(1962,1968),source:Go},{id:"eastman-5254",name:"Eastman Color Negative 5254",kind:"negative",iso:100,light:"tungsten",formats:Vo(1968,1976),source:Go},{id:"eastman-5247-1974",name:"Eastman Color Negative II 5247 (1974)",kind:"negative",iso:64,formats:Vo(1974,1983),source:Go},{id:"eastman-5294",name:"Eastman High Speed Negative 5294",kind:"negative",iso:400,light:"tungsten",formats:Vo(1983),source:Go},{id:"eastman-5297",name:"Eastman High Speed Daylight 5297",kind:"negative",iso:250,formats:Vo(1986,1997),source:Go},{id:"eastman-5245",name:"Eastman EXR 50D 5245",kind:"negative",iso:50,formats:Vo(1989),source:Go}];class lc{static byId(e){return NA.find(t=>t.id===e)}static forInstrument(e){return NA.filter(t=>t.formats.some(i=>i.format===e.filmFormat))}static gap(e,t,i){const s=e.formats.find(n=>n.format===t.filmFormat);if(!(!s||i===void 0)){if(i<s.from)return{kind:"before",from:s.from};if(s.to!==void 0&&i>s.to)return{kind:"after",to:s.to}}}static possible(e,t){return lc.forInstrument(e).filter(i=>lc.gap(i,e,t)===void 0)}static mediumOf(e,t){return!e||!t?e:{...e,kind:t.kind,iso:t.iso,monochrome:t.monochrome}}}class Vd{constructor(e){this.annex=e}static SAME_PLACE_DEG=1e-6;static SAME_TIME_MS=1e3;async between(e,t,i){let s;try{s=await this.annex}catch{return{status:"failed"}}const n=o=>Math.abs(o.lat-e.lat)<=Vd.SAME_PLACE_DEG&&Math.abs(o.lng-e.lng)<=Vd.SAME_PLACE_DEG,a=s.answers.find(o=>n(o)&&Math.abs(o.startMs-t)<=Vd.SAME_TIME_MS&&Math.abs(o.endMs-i)<=Vd.SAME_TIME_MS)??s.answers.find(o=>o.startMs<=t&&o.endMs>=i);return a?a.answer:{status:"failed"}}}const yy=7.5,zp=9;class no{static cache=new Map;static load(e){let t=no.cache.get(e);return t||(t=fetch(e).then(i=>i.arrayBuffer()).then(i=>no.parse(i)),no.cache.set(e,t)),t}static upTo(e,t){const i=e.filter((r,a)=>a===0||e[a-1].magnitudeLimit<t);if(i.length<=1)return no.load(e[0].url);const s=i.map(r=>r.url).join(`
|
|
12152
|
-
`);let n=no.cache.get(s);return n||(n=Promise.all(i.map(r=>no.load(r.url))).then(r=>r.reduce((a,o)=>no.concat(a,o))),no.cache.set(s,n)),n}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){const i=(s,n)=>{const r=new Float32Array(s.length+n.length);return r.set(s,0),r.set(n,s.length),r};return{count:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}class Ei{constructor(e){if(this.heights=e,e.length!==Ei.WIDTH*Ei.HEIGHT)throw new Error(`a lunar relief has ${Ei.WIDTH*Ei.HEIGHT} samples, not ${e.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*Ei.SAMPLES_PER_DEGREE;static HEIGHT=180*Ei.SAMPLES_PER_DEGREE;static UNIT_KM=.1;static REFERENCE_RADIUS_KM=1737.4;static BAND_FROM_DEG=74;static BAND_TO_DEG=106;heightKm(e,t){const i=Ei.SAMPLES_PER_DEGREE,s=(t%360+360)%360*i-.5,n=(90-e)*i-.5,r=Math.floor(s),a=Math.floor(n),o=s-r,c=n-a,h=(p,f)=>{const m=(p%Ei.WIDTH+Ei.WIDTH)%Ei.WIDTH,g=Math.min(Ei.HEIGHT-1,Math.max(0,f));return this.heights[g*Ei.WIDTH+m]},d=h(r,a)*(1-o)+h(r+1,a)*o,u=h(r,a+1)*(1-o)+h(r+1,a+1)*o;return(d*(1-c)+u*c)*Ei.UNIT_KM}static inBand(e,t){const i=Math.PI/180,s=Math.acos(Math.cos(e*i)*Math.cos(t*i))*180/Math.PI;return s>=Ei.BAND_FROM_DEG&&s<=Ei.BAND_TO_DEG}static withBump(e,t,i,s=.4){const n=new Int8Array(Ei.WIDTH*Ei.HEIGHT),r=Ei.SAMPLES_PER_DEGREE,a=Math.ceil(s*r),o=Math.floor(t*r),c=Math.floor((90-e)*r);for(let h=-a;h<=a;h++)for(let d=-a;d<=a;d++)Math.hypot(d,h)<=a&&(n[(c+h)*Ei.WIDTH+(o+d+Ei.WIDTH)%Ei.WIDTH]=Math.round(i/Ei.UNIT_KM));return new Ei(n)}static smooth(){return new Ei(new Int8Array(Ei.WIDTH*Ei.HEIGHT))}}class ua{static SAMPLES=5760;static SEARCH_FROM_DEG=87;static SEARCH_TO_DEG=90.2;static SEARCH_STEP_DEG=.0625;static profile(e,t,i,s=ua.SAMPLES){const{s:n,u:r,w:a,distanceKm:o}=ua.frame(e,t),c=Math.PI/180,h=new Float32Array(s),d=Ei.REFERENCE_RADIUS_KM;for(let u=0;u<s;u++){const p=u/s*2*Math.PI,f=Math.cos(p),m=Math.sin(p),g=f*r[0]+m*a[0],v=f*r[1]+m*a[1],b=f*r[2]+m*a[2];let w=0;for(let y=ua.SEARCH_FROM_DEG;y<=ua.SEARCH_TO_DEG;y+=ua.SEARCH_STEP_DEG){const M=Math.cos(y*c),x=Math.sin(y*c),S=M*n[0]+x*g,E=M*n[1]+x*v,A=M*n[2]+x*b,T=Math.asin(Math.max(-1,Math.min(1,A)))/c,D=Math.atan2(E,S)/c,k=d+i.heightKm(T,D),O=Math.atan2(k*x,o-k*M);O>w&&(w=O)}h[u]=w/c}return{radiusDeg:h,meanRadiusDeg:Math.asin(d/o)/c}}static frame(e,t){const i=new yl(t.lat,t.lng,t.elevationM),s=mc(e),n=Ny(e,i,!1),r=new jt(n.x-s.x,n.y-s.y,n.z-s.z,s.t),a=Math.hypot(r.x,r.y,r.z)*ua.AU_KM,o=ua.bodyFixed(e),c=o(r),h=Math.hypot(c[0],c[1],c[2]),d=[c[0]/h,c[1]/h,c[2]/h],u=FD(e,i),p=Uw(u),f=uc(u,new jt(-r.x,-r.y,-r.z,s.t)),m=Math.asin(f.z/Math.hypot(f.x,f.y,f.z)),g=Math.atan2(-f.y,f.x),v=new jt(-Math.sin(m)*Math.cos(g),Math.sin(m)*Math.sin(g),Math.cos(m),s.t),b=new jt(-Math.sin(g),-Math.cos(g),0,s.t);return{s:d,u:o(uc(p,v)),w:o(uc(p,b)),distanceKm:a}}static surfacePoint(e,t,i,s){const{s:n,u:r,w:a}=ua.frame(e,t),o=Math.PI/180,c=[0,1,2].map(d=>Math.cos(i*o)*r[d]+Math.sin(i*o)*a[d]),h=[0,1,2].map(d=>Math.cos(s*o)*n[d]+Math.sin(s*o)*c[d]);return{latDeg:Math.asin(h[2])/o,lonDeg:Math.atan2(h[1],h[0])/o}}static radiusAt(e,t){const i=e.radiusDeg.length,s=(t/360*i%i+i)%i,n=Math.floor(s),r=s-n;return e.radiusDeg[n]*(1-r)+e.radiusDeg[(n+1)%i]*r}static uncoveredFraction(e,t,i){const s=e.radiusDeg.length,n=i.upDeg*i.upDeg+i.rightDeg*i.rightDeg;let r=0;for(let a=0;a<s;a++){const o=a/s*2*Math.PI,c=Math.cos(o),h=Math.sin(o),d=c*i.upDeg+h*i.rightDeg,u=d*d-n+t*t;if(u<=0)continue;const p=Math.sqrt(u),f=d+p;if(f<=0)continue;const m=Math.max(0,d-p),g=Math.max(m,e.radiusDeg[a]);f>g&&(r+=.5*(f*f-g*g))}return Math.min(1,Math.max(0,r*(2*Math.PI/s)/(Math.PI*t*t)))}static AU_KM=1495978707e-1;static bodyFixed(e){const t=QD(ye.Moon,e),i=Math.PI/180,s=t.ra*15*i,n=t.dec*i,r=t.spin*i,a=(c,[h,d,u])=>[Math.cos(c)*h+Math.sin(c)*d,-Math.sin(c)*h+Math.cos(c)*d,u],o=(c,[h,d,u])=>[h,Math.cos(c)*d+Math.sin(c)*u,-Math.sin(c)*d+Math.cos(c)*u];return c=>a(r,o(Math.PI/2-n,a(Math.PI/2+s,[c.x,c.y,c.z])))}static subObserverPoint(e,t){const i=new yl(t.lat,t.lng,t.elevationM),s=mc(e),n=Ny(e,i,!1),r=ua.bodyFixed(e)(new jt(n.x-s.x,n.y-s.y,n.z-s.z,s.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 Hp{static cache=new Map;static load(e){let t=Hp.cache.get(e);return t||(t=Hp.fetchRelief(e).catch(()=>{}),Hp.cache.set(e,t)),t}static async fetchRelief(e){const t=await fetch(e);if(!t.ok)return;let i=new Uint8Array(await t.arrayBuffer());if(i[0]===31&&i[1]===139){if(typeof DecompressionStream>"u")return;const s=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip"));i=new Uint8Array(await new Response(s).arrayBuffer())}return new Ei(new Int8Array(i.buffer,i.byteOffset,i.length))}}const RM=yi.catalog({en:()=>V(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(l=>l.perceptionMessages_en),fr:()=>V(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(l=>l.perceptionMessages_fr),es:()=>V(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(l=>l.perceptionMessages_es),it:()=>V(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(l=>l.perceptionMessages_it)});class zg{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=zg.ID;messages=RM;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(e){const t=zg.MATRICES[String(e.type)];if(!t)return Fr.NONE;const i=Number(e.severity??100),s=Math.max(0,Math.min(100,Number.isFinite(i)?i:100))/100;return{colorMatrix:t.map((r,a)=>Fr.IDENTITY[a]+(r-Fr.IDENTITY[a])*s),contrastGain:1}}}class CM{static ID="fatigue";id=CM.ID;messages=RM;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(e){return Fr.NONE}}class Zl{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=Zl.ID;messages=RM;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:Zl.MAX_LEVEL,step:.01,unit:"%",also:{unit:"g/L",factor:10,digits:1}}];perceive(e){const t=Number(e.bloodAlcohol??0),i=Math.max(0,Math.min(Zl.MAX_EFFECT_LEVEL,Number.isFinite(t)?t:0));if(i===0)return Fr.NONE;const s=i/Zl.MEASURED_LEVEL*Zl.MEASURED_LOSS_DB;return{colorMatrix:Fr.IDENTITY,contrastGain:10**(-s/20)}}}const mU=l=>l.sources[0]??l.id,gU=Xe.point("perception").provide(Xe.BUILT_IN,[new zg,new Zl,new CM].map(l=>({id:l.id,name:l.id,credit:mU(l),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>l})));class Na{static built=new WeakMap;static get ALL(){return gU.map(e=>{let t=Na.built.get(e);return t||(t=e.create(),Na.built.set(e,t)),t})}static byId(e){return Na.ALL.find(t=>t.id===e)}static perceptionOf(e){return Na.ALL.reduce((t,i)=>Fr.combine(t,i.perceive(e?.[i.id]??{})),Fr.NONE)}static compact(e){const t={},i=Na.ALL;for(const[s,n]of Object.entries(e))!i.some(r=>r.id===s)&&Object.keys(n??{}).length>0&&(t[s]=n);for(const s of i){const n=e[s.id]??{},r=Object.fromEntries(s.settings.filter(a=>n[a.id]!==void 0&&n[a.id]!==a.default).map(a=>[a.id,n[a.id]]));Object.keys(r).length>0&&(t[s.id]=r)}return Object.keys(t).length>0?t:void 0}}class Hg{names;constructor(e){this.names=e??yi.blank(),this.loaded=e!==void 0}loaded;body(e){return this.names.bodies[e]??e}star(e){return this.names.stars[e.name]??e.name}comet(e){return this.names.comets[e.id]??e.name}nova(e){return this.names.novae[e.id]??e.name}satelliteClass(e){return this.names.satelliteClasses[e.id]??e.name}shower(e){return this.names.showers[e.id]??e.name}lightRig(e){return this.names.lightRigs[e.id]??e.name}instrument(e){return this.names.instruments[e.id]??e.name}decorKind(e){return this.names.decorKinds[e]}point(e){return yh.point(e,this.loaded?this.names.compassPoints:void 0)}towards(e){return yh.towards(e,this.loaded?this.names:void 0)}}class co{static STANDARD_GAUGE_MM=1435;static METRE_GAUGE_MM=1e3;static kind(e,t){return e.highSpeed?t.highSpeed:e.service?t.service:t.kinds[e.kind]}static name(e,t){const i=e.name??co.kind(e,t);return e.services?.length?`${i} — ${e.services.join(", ")}`:i}static voltage(e,t){return e>=1e3?`${(e/1e3).toLocaleString(t,{maximumFractionDigits:1})} kV`:`${e.toLocaleString(t)} V`}static detail(e,t,i,s){const{line:n}=e,r=[];n.name&&r.push(co.kind(n,t).toLocaleLowerCase(s)),r.push(n.tracks>1?t.tracks.replace("{count}",String(n.tracks)):t.singleTrack);const a=n.voltageV?co.voltage(n.voltageV,s):void 0;if(e.contactM!==void 0){const o=e.contactM.toLocaleString(s,{minimumFractionDigits:2,maximumFractionDigits:2});r.push((a?t.overheadVoltage.replace("{voltage}",a):t.overhead).replace("{height}",o))}else n.electrification==="third_rail"?r.push(a?t.thirdRailVoltage.replace("{voltage}",a):t.thirdRail):n.electrification==="none"&&r.push(t.notElectrified);return n.gaugeMm===co.METRE_GAUGE_MM?r.push(t.metreGauge):n.gaugeMm!==co.STANDARD_GAUGE_MM&&r.push(t.gauge.replace("{mm}",n.gaugeMm.toLocaleString(s))),r.push(t.distance.replace("{distance}",i(e.distanceM))),n.services?.length?`${co.name(n,t)}; ${r.join(", ")}`:`${co.name(n,t)} — ${r.join(", ")}`}}class Gp{constructor(e,t){this.element=e,this.onChange=t,e.addEventListener("error",()=>{this.url=void 0,this.release()})}shown=!1;url;get up(){return this.shown}show(e,t,i=!0){const s=Gp.resolve(e,t);if(this.url=s,!s||!i){this.release();return}this.element.src=s,this.element.hidden=!1;const n=this.shown;this.shown=!0,n||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(e,t){if(!(typeof e!="string"||e.trim()===""))try{const i=new URL(e.trim(),t??location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?void 0:i.origin===Gp.PUBLISHED_ORIGIN&&Gp.isDevelopmentHost(location.hostname)?location.origin+i.pathname:i.href}catch{return}}static PUBLISHED_ORIGIN="https://ufoathome.org";static isDevelopmentHost(e){return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".localhost")}}const vU="Global Meteor Network",bU="https://globalmeteornetwork.org/data/",yU="“Thunder” by Jerimee",wU="https://creativecommons.org/licenses/by/3.0/",MU="CC BY 3.0";class zn{static fill(e,t){e.innerHTML="";const i=u=>e.appendChild(u),s=t.currentTerrainAttribution;s&&i(zn.text(s));const n=t.currentRoadAttribution;n&&i(zn.text(n));const r=t.currentWaterAttribution;r&&i(zn.text(r));const a=t.currentRailwayAttribution;a&&i(zn.text(a));const o=t.ufoElement.observerMapCredit;o&&!s?.includes(o)&&i(zn.text(o));for(const u of t.decorModelCredits){const p=u.author?` — ${u.author}`:"",f=document.createElement("li");u.sourceUrl?f.append(zn.link(u.sourceUrl,u.title),document.createTextNode(`${p} (${u.license})`)):f.textContent=`${u.title}${p} (${u.license})`,i(f)}for(const u of t.ufoElement.sighting.references){if(!u.credit)continue;const p=document.createElement("li");u.creditUrl?p.appendChild(zn.link(u.creditUrl,u.credit)):p.textContent=u.credit,i(p)}if(t.ufoElement.sighting.traces.length>0){const u=new Fs(Us.preferencesFor(t)),p=new Set(t.ufoElement.sighting.traces.map(f=>u.read(f.source)).filter(f=>!!f));for(const f of p)i(zn.text(f))}const c=t.satelliteState;if(c.status==="ready"&&c.credit){const u=document.createElement("li");u.appendChild(zn.link(c.creditUrl??"",c.credit)),i(u)}if(t.fireballState.status==="ready"&&t.fireballState.records.length>0){const u=document.createElement("li");u.append(zn.link(bU,vU),document.createTextNode(" (CC BY 4.0)")),i(u)}const h=t.aircraftState;if(h.status==="ready"&&h.shown>0){const u=document.createElement("li");if(u.appendChild(zn.link(h.creditUrl,h.credit)),i(u),h.trailCredit){const p=document.createElement("li");p.appendChild(zn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(p)}}const d=zn.text(`${yU} (`);d.append(zn.link(wU,MU),document.createTextNode(")")),i(d)}static text(e){const t=document.createElement("li");return t.textContent=e,t}static link(e,t){const i=document.createElement("a");return i.href=e,i.target="_blank",i.rel="noopener",i.textContent=t,i}}const xU=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,EU=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,FA=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,SU=20,AU=1,TU=7,IU=.35,UA=.4,BA=40,zA=.5,_U=Math.SQRT2;class uh{context;constructor(e){this.context=e}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};around;aroundRequested={rms:0,shape:[]};level=1;share=1;master;output(e){return this.master||(this.master=e.createGain(),this.master.gain.value=this.gain,this.master.connect(e.destination)),this.master}get gain(){return this.level*this.share}setLevel(e){this.level=e,this.master&&(this.master.gain.value=this.gain)}setOutsideHeard(e){this.share=Math.min(1,Math.max(0,e)),this.master&&(this.master.gain.value=this.gain)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}ta.isLive(this.context)&&ta.unlock(this.context),this.applyAround()}setAround(e,t){const i=this.aroundRequested;i.rms===Math.max(0,e)&&i.shape.length===t.length&&i.shape.every((s,n)=>s===t[n])||(this.aroundRequested={rms:Math.max(0,e),shape:t},this.applyAround())}applyAround(){const e=this.context;if(!e)return;const{rms:t,shape:i}=this.aroundRequested,s=this.paused?0:t;if(s===0&&!this.around)return;const n=this.around??(this.around=this.buildAround(e)),r=e.currentTime;n.gain.gain.setTargetAtTime(s,r,zA),ms.OCTAVES.forEach((a,o)=>{const c=Math.sqrt(Math.min(1,1.11*a/(e.sampleRate/2)))/Math.sqrt(3);n.bands[o].gain.setTargetAtTime((i[o]??0)/c,r,zA)})}buildAround(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*TU),e.sampleRate),i=t.getChannelData(0);for(let m=0;m<i.length;m++)i[m]=Math.random()*2-1;const s=e.createBufferSource();s.buffer=t,s.loop=!0;const n=Math.floor(e.sampleRate*BA),r=e.createBuffer(1,n,e.sampleRate),a=Array.from({length:Math.round(BA*UA)},()=>Math.random()*2-1),o=r.getChannelData(0),c=e.sampleRate/UA;for(let m=0;m<n;m++){const g=m/c,v=Math.floor(g),b=g-v,w=b*b*(3-2*b);o[m]=a[v%a.length]*(1-w)+a[(v+1)%a.length]*w}const h=e.createBufferSource();h.buffer=r,h.loop=!0;const d=e.createGain();d.gain.value=IU;const u=e.createGain();u.gain.value=1,h.connect(d).connect(u.gain);const p=e.createGain();p.gain.value=0,u.connect(p).connect(this.output(e));const f=ms.OCTAVES.map(m=>{const g=e.createBiquadFilter();g.type="bandpass",g.frequency.value=m,g.Q.value=_U;const v=e.createGain();return v.gain.value=0,s.connect(g).connect(v).connect(u),v});return s.start(),h.start(),{sources:[s,h],nodes:[d,u,p,...f],bands:f,gain:p}}setAmbient(e,t,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const s=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=s==="hail"?Math.min(1,t*1.3+.2):s==="rain"?t:0,s!==this.ambientKey){this.ambientKey=s;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(xU,this.ambientVolume).then(a=>this.applyIfCurrent(a,r,()=>this.ambientToken,o=>{this.ambientSource=o?.source,this.ambientGain=o?.gain,o&&(o.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/SU,1);const n=i>AU;if(n!==this.windActive){this.windActive=n;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,n&&this.startLoop(EU,this.windVolume).then(a=>this.applyIfCurrent(a,r,()=>this.windToken,o=>{this.windSource=o?.source,this.windGain=o?.gain,o&&(o.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:s}=this.requested;this.setAmbient(t,i,s),this.applyAround()}playThunder(){!this.context||this.paused||this.playOneShot(FA,.9)}playDetonation(e){const t=this.context;if(!t||this.paused)return;const i=Math.min(1,Math.max(0,e)),s=t.createBufferSource();s.buffer=this.crackBuffer(t);const n=t.createBiquadFilter();n.type="lowpass",n.frequency.value=uh.CRACK_CUTOFF_HZ;const r=t.createGain();r.gain.value=i,s.connect(n).connect(r).connect(this.output(t)),s.start(),this.playOneShot(FA,i,uh.DETONATION_RATE)}static DETONATION_RATE=.8;static CRACK_CUTOFF_HZ=2500;static CRACK_DECAY_S=.25;crackBuffer(e){if(this.crack?.sampleRate===e.sampleRate)return this.crack;const t=Math.round(e.sampleRate*uh.CRACK_DECAY_S*6),i=e.createBuffer(1,t,e.sampleRate),s=i.getChannelData(0);for(let n=0;n<t;n++){const r=n/e.sampleRate;s[n]=(Math.random()*2-1)*Math.min(1,r/.005)*Math.exp(-r/uh.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;for(const e of this.around?.sources??[])try{e.stop()}catch{}for(const e of this.around?.nodes??[])e.disconnect();this.around=void 0,ta.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(e,t,i,s){if(t!==i()){e?.source.stop();return}s(e)}async startLoop(e,t){const i=this.context;if(i)try{const s=await this.getBuffer(e),n=i.createBufferSource();n.buffer=s,n.loop=!0;const r=i.createGain();return r.gain.value=t,n.connect(r).connect(this.output(i)),n.start(),{source:n,gain:r}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(e,t,i=1){const s=this.context;if(s)try{const n=await this.getBuffer(e),r=s.createBufferSource();r.buffer=n,r.playbackRate.value=i;const a=s.createGain();a.gain.value=t,r.connect(a).connect(this.output(s)),r.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class Bi{static BASE_DB_A=30;static OUTDOOR_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEADROOM_DB=10.5;static AROUND_BED_PLAYED=!1;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(e,t){const i=[Bi.BASE_DB_A,Bi.along(Bi.WIND_DB_A,e.windSpeed),Es.dbA(t)].filter(Number.isFinite);return(e.precipitationType==="rain"||e.precipitationType==="hail")&&i.push(Bi.along(Bi.RAIN_DB_A,e.precipitationIntensity)),10*Math.log10(i.filter(s=>s>0).reduce((s,n)=>s+10**(n/10),0))}static bedVolume(e){const t=e.windSpeed>Bi.WIND_BED_MIN_MS?Math.min(e.windSpeed/Bi.WIND_BED_FULL_MS,1):0,i=e.precipitationType==="hail"?Math.min(1,e.precipitationIntensity*1.3+.2):e.precipitationType==="rain"?e.precipitationIntensity:0;return Math.hypot(t,i)}static referenceAmplitude(e,t){return Math.max(Math.hypot(Bi.BED_RMS*Bi.bedVolume(e),Bi.aroundReference(t)),Bi.MINIMUM_REFERENCE)}static aroundReference(e){const t=Es.dbA(e);return!Number.isFinite(t)||t<=Bi.BASE_DB_A?0:Bi.MINIMUM_REFERENCE*10**((t-Bi.BASE_DB_A)/20)}static aroundBedRms(e){if(!Bi.AROUND_BED_PLAYED)return 0;const t=Es.dbA(e,!1);return!Number.isFinite(t)||t<=Bi.BASE_DB_A?0:Math.min(Bi.BED_RMS,Bi.MINIMUM_REFERENCE*10**((t-Bi.BASE_DB_A-Bi.HEADROOM_DB)/20))}static bedPlays(e,t){return Bi.bedVolume(e)>0||Bi.aroundBedRms(t)>0}static shapeDb(e,t){const i=10**(Bi.dbA(e,t)/10),s=Es.dbA(t,!1),n=Number.isFinite(s)?10**(s/10):0,r=Math.max(0,i-n),a=Bi.OUTDOOR_SHAPE_DB,o=10**(ms.sumDb(a)/10),h=Es.vehicleShape(t)?.map((f,m)=>f*f*10**(ms.aWeightingDb(ms.OCTAVES[m])/10)),d=h?.reduce((f,m)=>f+m,0)??1,u=ms.OCTAVES.map((f,m)=>r*10**(a[m]/10)/o+(h?n*h[m]/d:0)),p=u.reduce((f,m)=>f+m,0);return u.map(f=>10*Math.log10(f/p))}static aroundBedShape(e){return Es.vehicleShape(e)}static along(e,t){if(t<=e[0][0])return e[0][1];for(let i=1;i<e.length;i++)if(t<=e[i][0]){const[s,n]=e[i-1],[r,a]=e[i];return n+(a-n)*(t-s)/(r-s)}return e[e.length-1][1]}}class Yo{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[s,n]=this.perifocalAxes(),r=Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(s,i),this.perihelionVelocity=this.scale(n,r),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),s=this.inverseSemiMajorAxis*i*i,n=this.elements.perihelionAu,r=1-i*i/n*Yo.stumpffC(s),a=t-i*i*i/Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2)*Yo.stumpffS(s);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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=a=>{const o=this.inverseSemiMajorAxis*a*a,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*a*a*a*Yo.stumpffS(o)+c*a};let n=Math.max(1,i/this.elements.perihelionAu);for(;s(n)<i;)n*=2;let r=0;for(let a=0;a<Yo.MAX_ITERATIONS&&n-r>1e-13*Math.max(1,n);a++){const o=(r+n)/2;s(o)<i?r=o:n=o}return t*(r+n)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(e),n=Math.sin(e),r=Math.cos(t),a=Math.sin(t),o=Math.cos(i),c=Math.sin(i);return[{x:s*r-n*a*o,y:n*r+s*a*o,z:a*c},{x:-s*a-n*r*o,y:-n*a+s*r*o,z:r*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const n_=[{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 $0{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return n_.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,s)=>i.magnitude-s.magnitude)[0]}static appearanceOf(e,t,i){const s=Ci(t),n=this.earthPositionAt(s),r=this.apparentPositionOf(e,2451545+s.tt,n),a=this.subtract(r,n),o=this.length(r),c=this.length(a),h=this.tailEndAt(e,r,n,o,s,t,i),d=this.horizontalOf(a,s,t,i);return{apparition:e,position:d,...h,heliocentricDistanceAu:o,earthDistanceAu:c,elongationDeg:this.angleBetween(a,this.subtract({x:0,y:0,z:0},n)),magnitude:this.magnitudeAt(e,o,c)}}static magnitudeAt(e,t,i){const s=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(s,e.peakMagnitude)}static tailEndAt(e,t,i,s,n,r,a){if(e.tailLengthAu===void 0)return{};const o=1+e.tailLengthAu/s,c=this.subtract({x:t.x*o,y:t.y*o,z:t.z*o},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(c,n,r,a),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,i){const s=this.orbitOf(e);let n=s.positionAt(t);for(let r=0;r<2;r++){const a=this.length(this.subtract(n,i))/this.LIGHT_SPEED_AU_PER_DAY;n=s.positionAt(t-a)}return n}static horizontalOf(e,t,i,s){const n=uc(OD(),new jt(e.x,e.y,e.z,t)),r=uc(VT(t),n),a=Ny(t,new yl(s.lat,s.lng,s.elevationM),!0),o=new jt(r.x-a.x,r.y-a.y,r.z-a.z,t),c=sv(o);return mf(c.ra,c.dec,i,s)}static earthPositionAt(e){return uc(CD(),pl(ye.Earth,e))}static julianDayOf(e){return 2451545+Ci(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new Yo(e.orbit);return this.orbits.set(e.id,i),i}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const i=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const wy=[{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 Gg{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return wy.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),s=[];for(const n of wy){const r=this.magnitudeAt(n,i);r!==void 0&&s.push({outburst:n,position:ka.ofJ2000(n.raHours,n.decDeg,e,t),magnitude:r})}return s.sort((n,r)=>n.magnitude-r.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return wy.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,s=t-e.startJd;if(i.length===0||s<i[0][0]||s>i[i.length-1][0])return;let n=1;for(;n<i.length-1&&i[n][0]<s;)n++;const[r,a]=i[n-1]??i[0],[o,c]=i[n]??i[0];if(o===r)return a;const h=Math.min(1,Math.max(0,(s-r)/(o-r)));return a+h*(c-a)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const DU=[{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}],Tu=6.5;class cu{static activeAt(e){return DU.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),s=this.dayOfYear(this.asDate(e.start)),n=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),a=this.wrappedDelta(i,n),o=this.wrappedDelta(n,s),c=this.wrappedDelta(r,n);return a<0?a<-o?0:1+a/o:a>0?a>c?0:1-a/c:1}static observedRatePerHour(e,t,i,s=Tu){if(t<=0)return 0;const n=Tu-s;return e*Math.sin(t*Math.PI/180)/Math.pow(i,n)}static radiantPosition(e,t,i){return ka.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const i=e-t;return i>182?i-365:i<-182?i+365:i}}class ls{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Ci(e),s=new Qg(0,dD(e).elon-90,1),n=uc(UD(i),zw(s,i)),r=sv(n);return mf(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=Tu){const i=ls.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=Tu-t;return(ls.QUIET_RATE_PER_HOUR+i)/Math.pow(ls.POPULATION_INDEX,s)}static schedule(e){const t=new bv(e.seed^1542469173);return pa.schedule(e).map(i=>{const s=ls.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),n=i.fromRadiantDeg*Math.PI/180,r=ls.turnAround(s,t.between(0,360)),a={x:s.x*Math.cos(n)+r.x*Math.sin(n),y:s.y*Math.cos(n)+r.y*Math.sin(n),z:s.z*Math.cos(n)+r.z*Math.sin(n)};return{...i,radiant:ls.toHorizontal(a),bearingDeg:ls.bearingFrom(a,s)}})}static turnAround(e,t){const[i,s]=ls.basisAround(e),n=t*Math.PI/180;return{x:i.x*Math.cos(n)+s.x*Math.sin(n),y:i.y*Math.cos(n)+s.y*Math.sin(n),z:i.z*Math.cos(n)+s.z*Math.sin(n)}}static bearingFrom(e,t){const[i,s]=ls.basisAround(e),n=e.x*t.x+e.y*t.y+e.z*t.z,r=ls.normalise({x:t.x-e.x*n,y:t.y-e.y*n,z:t.z-e.z*n});return(Math.atan2(r.x*s.x+r.y*s.y+r.z*s.z,r.x*i.x+r.y*i.y+r.z*i.z)*180/Math.PI%360+360)%360}static basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ls.normalise(ls.cross(e,t));return[i,ls.normalise(ls.cross(e,i))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=ls.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ls.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return ls.toHorizontal({x:t.x*Math.cos(s)+i.x*Math.sin(s),y:t.y*Math.cos(s)+i.y*Math.sin(s),z:t.z*Math.cos(s)+i.z*Math.sin(s)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,s=Math.cos(t);return{x:s*Math.sin(i),y:Math.sin(t),z:-s*Math.cos(i)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}const HA="https://ufoathome.org/tle/index.json";class Hn{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Hn.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(HA)||e.push(HA),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Hn.FIRST_SNAPSHOT}T00:00:00Z`)-Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(s=>e.getTime()>=Date.parse(s.from)-Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS&&e.getTime()<=Date.parse(s.to)+Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:s}=t,n=[],r=[];for(const a of Object.keys(i.kinds)){const o=await this.kindAt(a,e,i,s);n.push(...o),r.push(this.coverageOf(a,e,i,o.length>0))}return{objects:n,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,s){const n=t.getTime(),r=i.binDays*Hn.DAY_MS,a=Math.floor(n/r),o=n-a*r<r/2?a-1:a+1,c=new Set(i.kinds[e].bins),h=[a,o].map(m=>new Date(m*r).toISOString().slice(0,10)).filter(m=>c.has(m));if(h.length===0)return[];const[d,...u]=await Promise.all([this.json(new URL(`objects-${e}.json`,s).href),...h.map(m=>this.binary(new URL(`${e}/${m}.bin`,s).href))]),p=new Map;for(const m of u)for(const g of Hn.decode(m,i.recordBytes)){const v=p.get(g.norad);(!v||Math.abs(g.epochMs-n)<Math.abs(v.epochMs-n))&&p.set(g.norad,g)}const f=[];for(const m of p.values()){const g=Math.abs(m.epochMs-n)/Hn.DAY_MS;if(g>Hn.MAX_ELEMENT_AGE_DAYS)continue;const v=d[m.norad]??{name:String(m.norad)};v.launch&&Date.parse(`${v.launch}T00:00:00Z`)>n||f.push({norad:m.norad,name:v.name,kind:e,launch:v.launch,stdMag:v.stdMag,elements:m,ageDays:g})}return f}coverageOf(e,t,i,s){const{from:n,to:r}=i.kinds[e],a=t.getTime(),o=Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS,c=s?"covered":a<Date.parse(n)-o?"before":a>Date.parse(r)+o?"after":"gap";return{kind:e,status:c,from:n,to:r}}static decode(e,t){const i=new DataView(e),s=[];for(let n=0;n+t<=e.byteLength;n+=t)s.push({norad:i.getUint32(n,!0),epochMs:i.getFloat64(n+4,!0),bstar:i.getFloat32(n+12,!0),inclinationDeg:i.getFloat32(n+16,!0),raanDeg:i.getFloat32(n+20,!0),eccentricity:i.getFloat32(n+24,!0),argOfPerigeeDeg:i.getFloat32(n+28,!0),meanAnomalyDeg:i.getFloat32(n+32,!0),meanMotion:i.getFloat64(n+36,!0)});return s}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(s=>{if(!s.ok)throw new Error(`${e}: ${s.status}`);return t(s)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class kU{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=Ft.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=Ft.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:Ft.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Ft.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Mh{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Mh.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=Mh.degOver(e)/t;return i<1?1:Math.min(Mh.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class bn{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 Mh.DEG_PER_SECOND*3600}static graspOf(e,t={}){if(e.visualAid)return bn.visualAidGrasp(e,t.focalLengthMm);const i=t.exposureSeconds??e.exposureSeconds,s=t.fNumber??e.fNumber;if(i===void 0||s===void 0||!(i>0)||!(s>0))return bn.EYE;const n=t.focalLengthMm??e.frame?.focalLengthMm??bn.UNKNOWN_CAMERA_FOCAL_MM,r=n/s,a=bn.resolutionArcsec(e,n,r);return{apertureMm:r,exposureSeconds:Math.min(i,bn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(e,t){const i=e.visualAid,s=bn.EYE,n=t??e.frame?.focalLengthMm,r=i.magnification??(n!==void 0&&i.eyepieceFocalMm?n/i.eyepieceFocalMm:1),a=Math.min(i.apertureMm,s.apertureMm*r);return{apertureMm:Math.max(a,s.apertureMm),exposureSeconds:s.exposureSeconds,resolutionArcsec:s.resolutionArcsec/Math.max(1,Math.min(r,i.apertureMm/s.apertureMm))}}static resolutionArcsec(e,t,i){const n=(e.detailUm??bn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*bn.ARCSEC_PER_RADIAN,r=1.22*bn.WAVELENGTH_M/(i/1e3)*bn.ARCSEC_PER_RADIAN;return Math.max(n,r)}static trailLimitedSeconds(e){return e/bn.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=bn.graspOf(e,t),s=bn.EYE,n=(i.apertureMm/s.apertureMm)**2,r=i.exposureSeconds/s.exposureSeconds,a=(s.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(n*r*a)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:Vt.focalLengthMmFor(e,t.fieldOfViewDeg);return bn.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const GA=111320,hp=Math.PI/180,RU=1.02,CU=1;class Vp{static of(e,t){const i=Vp.sightings(e,t);if(i.length<2)return;const s=Vp.baseline(i);if(!s)return;const{near:n,far:r,closedM:a}=s,o=Math.tan(r.widthDeg/2*hp)===0?0:Math.tan(n.widthDeg/2*hp)/Math.tan(r.widthDeg/2*hp);if(o<RU)return;const c=a/(o-1),h=Ft.sizeMAt(c,n.widthDeg),d=i.map(u=>({t:u.t,m:Ft.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:r.t,toT:n.t,closedM:a}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const s=i.shapes.find(a=>a.sourceId===t)?.shape,n=s?.angular?.widthDeg,r=et(e,i.t);return n===void 0||n<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:n,lat:r.lat,lng:r.lng,sightAzimuthDeg:s?.aim?.azimuthDeg??r.headingDeg}]}).sort((i,s)=>i.t-s.t)}static baseline(e){let t;for(const i of e)for(const s of e){if(i.t>=s.t)continue;const n=Vp.closedAlongSight(i,s),[r,a,o]=n>=0?[s,i,n]:[i,s,-n];o<CU||r.widthDeg<=a.widthDeg||(!t||o>t.closedM)&&(t={near:r,far:a,closedM:o})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*GA,s=(t.lng-e.lng)*GA*Math.cos(e.lat*hp),n=(e.sightAzimuthDeg??0)*hp;return i*Math.cos(n)+s*Math.sin(n)}}class cr{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:cr.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:cr.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:cr.atLeastNearest(e.derivedM),basis:"derived"};const t=cr.largest(e.range?.minM,e.crossing?.behindM),i=cr.smallest(e.range?.maxM,e.crossing?.inFrontM),s=t===void 0?void 0:t*cr.MARGIN,n=i===void 0?void 0:i/cr.MARGIN;return s!==void 0&&n!==void 0?{distanceM:cr.atLeastNearest(s<=n?Math.sqrt(s*n):s),basis:"bounded"}:s!==void 0?{distanceM:cr.atLeastNearest(s),basis:"bounded"}:n!==void 0&&n<cr.CONVENTIONAL_M?{distanceM:cr.atLeastNearest(n),basis:"bounded"}:{distanceM:cr.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(cr.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}class hc{static typed=new Map;static of(e){return hc.typed.get(e)}static set(e,t){const i=t.trim();i===""?hc.typed.delete(e):hc.typed.set(e,i)}static forget(){hc.typed.clear()}}class OM{static FIRST_DAY="2022-01-01";static mayCover(e){return new Date(e).toISOString().slice(0,10)>=OM.FIRST_DAY}}class VA{constructor(e,t,i){this.citation=e,this.covers=t,this.load=i}loading;mayCover(e){return this.covers(e)}async between(e,t,i,s){try{return await(await this.provider()).between(e,t,i,s)}catch{return{status:"failed"}}}async describe(e,t){try{return await(await this.provider()).describe?.(e,t)}catch{return}}provider(){if(!this.loading){const e=this.load();this.loading=e,e.catch(()=>{this.loading===e&&(this.loading=void 0)})}return this.loading}}const OU="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",LU="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",WA="flightradar24",Mw=Xe.point("aircraft").provide(Xe.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 VA(OU,l=>OM.mayCover(l),async()=>new(await V(async()=>{const{AdsbLolArchiveProvider:l}=await import("./AdsbLolArchiveProvider-BrZzIuec.js");return{AdsbLolArchiveProvider:l}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:WA,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new VA(LU,l=>l>=Date.UTC(2016,4,11)&&l<=Date.now(),async()=>new(await V(async()=>{const{Flightradar24Provider:l}=await import("./Flightradar24Provider-DUVcPAF2.js");return{Flightradar24Provider:l}},[],import.meta.url)).Flightradar24Provider({token:()=>hc.of(WA)}))}]);class wn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(e,t,i){const s=wn.positionAt(e,i);if(!s)return;const n=Ce.seenFrom(t,s.geo);if(!(n.altitudeDeg<0))return{track:e,sky:n,altitudeFt:s.altitudeFt,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg,angularRateDegPerS:wn.angularRate(e,t,i)}}static viewsAt(e,t,i){return e.flatMap(s=>wn.seenFrom(s,t,i)??[])}static groundDistanceKm(e,t){const i=Math.PI/180,s=Math.sin((t.lat-e.lat)*i/2)**2+Math.cos(e.lat*i)*Math.cos(t.lat*i)*Math.sin((t.lng-e.lng)*i/2)**2;return 2*wn.EARTH_RADIUS_KM*Math.asin(Math.min(1,Math.sqrt(s)))}static wrapLongitude(e){return((e+180)%360+360)%360-180}static positionAt(e,t){const i=e.points;if(i.length===0||t<i[0].t||t>i[i.length-1].t)return;let s=0;for(;s<i.length-1&&i[s+1].t<=t;)s++;const n=i[s],r=i[s+1]??n,a=r.t-n.t;if(a>wn.MAX_GAP_S*1e3)return;const o=a>0?(t-n.t)/a:0,c=n.altitudeFt+(r.altitudeFt-n.altitudeFt)*o,h=(r.lng-n.lng+540)%360-180;return{geo:{lat:n.lat+(r.lat-n.lat)*o,lng:wn.wrapLongitude(n.lng+h*o),heightM:c*wn.FT_TO_M},altitudeFt:c,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg}}static angularRate(e,t,i){const s=wn.positionAt(e,i-500),n=wn.positionAt(e,i+500);if(!s||!n)return;const r=wn.unit(Ce.seenFrom(t,s.geo)),a=wn.unit(Ce.seenFrom(t,n.geo)),o=Math.min(1,Math.max(-1,r[0]*a[0]+r[1]*a[1]+r[2]*a[2]));return Math.acos(o)*180/Math.PI}static unit(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180;return[Math.cos(t)*Math.sin(i),Math.cos(t)*Math.cos(i),Math.sin(t)]}}class vn{constructor(e){this.boxes=e;for(const i of e){const s=Math.hypot(i.halfWidthM,i.halfLengthM),[n,r]=[vn.cell(i.eastM-s),vn.cell(i.eastM+s)],[a,o]=[vn.cell(i.northM-s),vn.cell(i.northM+s)];for(let c=n;c<=r;c++)for(let h=a;h<=o;h++){const d=vn.key(c,h),u=this.cells.get(d);u?u.push(i):this.cells.set(d,[i])}}let t=2166136261;for(const i of e)for(const s of[i.eastM,i.northM,i.cos,i.halfWidthM,i.halfLengthM,i.topM])t=Math.imul(t^Math.round(s*10),16777619);this.signature=e.length===0?"":`${e.length}:${(t>>>0).toString(36)}`}static NONE=new vn([]);static SOLID=new Set(["building","tree","wall","mound","terrace","shrub"]);static CELL_M=16;static last;signature;cells=new Map;static of(e,t){const i=[];for(const n of e){if(!vn.SOLID.has(n.kind)||(n.track?.length??0)>0)continue;const r=t(n);if(!(r.heightM>0)||!(r.widthM>0)||!(r.lengthM>0))continue;const a=(n.headingDeg??0)*Math.PI/180;i.push({eastM:n.eastM,northM:n.northM,cos:Math.cos(a),sin:Math.sin(a),halfWidthM:r.widthM/2,halfLengthM:r.lengthM/2,topM:r.heightM})}const s=new vn(i);return vn.last?.signature===s.signature?vn.last.obstacles:(vn.last={signature:s.signature,obstacles:s},s)}get empty(){return this.boxes.length===0}inside(e,t,i,s=0){const n=this.cells.get(vn.key(vn.cell(e),vn.cell(t)));if(n)for(const r of n){if(i>r.topM+s)continue;const a=e-r.eastM,o=t-r.northM,c=a*r.sin+o*r.cos,h=a*r.cos-o*r.sin,d=r.halfLengthM+s-Math.abs(c),u=r.halfWidthM+s-Math.abs(h);if(d<=0||u<=0)continue;const p=r.topM+s-i;if(d<u){const m=Math.sign(c)||1;return{box:r,nx:r.sin*m,ny:r.cos*m,depthM:d,belowTopM:p}}const f=Math.sign(h)||1;return{box:r,nx:r.cos*f,ny:-r.sin*f,depthM:u,belowTopM:p}}}static cell(e){return Math.floor(e/vn.CELL_M)}static key(e,t){return(e+32768)*65536+(t+32768)}}const $A="https://ufoathome.org/fireballs/index.json";class fa{static FIRST_MONTH="2018-12";static STRIKING_MAGNITUDE=-1;static COLOR="#eef2ff";static TRAIN_S=.3;fetchImpl;indexUrls;index;months=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??fa.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/fireballs/index.json",location.href).href),e.includes($A)||e.push($A),e}static mayCover(e){return new Date(e).toISOString().slice(0,7)>=fa.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(e,t){if(!fa.mayCover(t))return;const i=await this.loadIndex();if(!i)return;const s=new Set([new Date(e).toISOString().slice(0,7),new Date(t).toISOString().slice(0,7)]);return[...s].some(r=>r>=i.index.from&&r<=i.index.to)?(await Promise.all([...s].filter(r=>i.index.months.includes(r)).map(r=>this.monthOf(r,i.base)))).flat().filter(r=>r.t>=e&&r.t<=t):void 0}static seenFrom(e,t){const i=fa.peakFraction(e),s={lat:e.from[0]+(e.to[0]-e.from[0])*i,lng:e.from[1]+(e.to[1]-e.from[1])*i,heightM:e.peakHeightKm*1e3},n=Ce.seenFrom(t,s);if(!(n.altitudeDeg<0))return{record:e,peak:n,magnitude:e.peakMagnitude+5*Math.log10(n.distanceKm/Ce.STANDARD_DISTANCE_KM)}}static asReentry(e,t){const i=e.t-t,s=i+Math.max(e.durationS,.1)*1e3;return{id:`gmn-${e.id}`,track:[{t:i,lat:e.from[0],lng:e.from[1],altitudeKm:e.from[2]},{t:s,lat:e.to[0],lng:e.to[1],altitudeKm:e.to[2]}],fragments:[{absoluteMagnitude:e.peakMagnitude,color:fa.COLOR,trainS:fa.TRAIN_S}]}}static peakFraction(e){const t=e.from[2]-e.to[2];return Math.abs(t)<1e-6?.5:Math.min(1,Math.max(0,(e.from[2]-e.peakHeightKm)/t))}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(t.ok)return{index:await t.json(),base:e}}catch{}})(),this.index}monthOf(e,t){let i=this.months.get(e);return i||(i=this.fetchImpl(new URL(`${e}.json`,t).href).then(s=>s.ok?s.json():[]).catch(()=>[]),this.months.set(e,i)),i}}gv();const LM="satellites-change",PM="fireballs-change",NM="references-change",FM="aircraft-change",r_="rr0-confrontation",KA="comet:",XA="nova:",PU=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,NU=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,FU=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,UU=-18,BU={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},y0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class At extends HTMLElement{creditsButton;set ownCredits(e){this.creditsButton.hidden=!e}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",tu,iu,ah]}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 I;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationTolerance;confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Hn;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new fa;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=Mw[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return At.trafficRuntimeLoading??=V(()=>import("./trafficRuntime-Cqj3IpvH.js"),__vite__mapDeps([24,21]),import.meta.url).then(e=>At.trafficRuntime=e),At.trafficRuntimeLoading.catch(()=>{At.trafficRuntimeLoading=void 0}),At.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new uh;vehicleAudio=new v2;aircraftAudio;vehicleHearing=new Sg;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;decorModelsAsked=new Set;thunderTimeoutId;handleFullscreenChange=()=>{this.resizeToStage(),this.hoverTooltip.hidden=!0;for(const e of[this.hoverTooltip,this.shadow.getElementById("credits-panel")])e&&typeof e.hidePopover=="function"&&e.matches(":popover-open")&&e.hidePopover();this.tooltipOver=document.fullscreenElement};handlePointerMove=e=>{if(this.lastHover={clientX:e.clientX,clientY:e.clientY,altKey:e.altKey},this.ghostMissedSinceMs=void 0,this.hoverFrame!==void 0&&e.altKey===this.hoverAlt){this.hoverPending=!0;return}this.hoverAlt=e.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(e,t){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return!0;const s=(e.clientX-i.left)/i.width*2-1,n=1-(e.clientY-i.top)/i.height*2;return this.sceneRenderer.ghostsReadableAt(s,n)?this.sceneRenderer.pickGhostAt(s,n)?(this.ghostMissedSinceMs=void 0,!0):(this.ghostMissedSinceMs??=t,t-this.ghostMissedSinceMs>At.GHOST_KEPT_MS):!1}hoverFrame;hoverPending=!1;hoverAlt=!1;lastPlayingHoverMs=0;static PLAYING_HOVER_MS=150;lastHover;tooltipOver=null;hoverAt(e){if(this.showCompassFor({hovered:!0}),this.holding){this.hoverTooltip.hidden=!0;return}const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const s=(e.clientX-i.left)/i.width*t.width,n=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(s,n)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-i.left)/i.width*2-1,a=-((e.clientY-i.top)/i.height*2-1);if(!this.ghostPath.hasAttribute("hidden")&&!this.sceneRenderer.ghostsReadableAt(r,a))return;const o=this.pickAt(r,a,!0,e.altKey);o?this.showHoverTooltip(e,e.altKey&&o.detail?o.detail():o.name):this.hoverTooltip.hidden=!0,this.showGhostPath(o?.path,i)}showGhostPath(e,t){if(!e){this.ghostPath.toggleAttribute("hidden",!0);return}const i=this.stageElement.getBoundingClientRect(),s=u=>({x:t.left-i.left+(u.x+1)/2*t.width,y:t.top-i.top+(1-u.y)/2*t.height}),n=s(e.from),r=s(e.to),a=s({x:0,y:0});this.ghostPath.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);const[o,c,h,d]=Array.from(this.ghostPath.children);for(const u of[o,c])u.setAttribute("x1",String(n.x)),u.setAttribute("y1",String(n.y)),u.setAttribute("x2",String(r.x)),u.setAttribute("y2",String(r.y));h.setAttribute("cx",String(a.x)),h.setAttribute("cy",String(a.y)),d.setAttribute("cx",String(r.x)),d.setAttribute("cy",String(r.y)),this.ghostPath.toggleAttribute("hidden",!1)}pickAt(e,t,i=!0,s=!1){const n=this.naming,r=n.names;if(s&&this.sceneRenderer.pickDropAt(e,t)){const x=r.ghostTooltip,S=x.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:S,detail:()=>x.dropDetail.replace("{name}",S)}}const a=this.sceneRenderer.pickBodyAt(e,t);if(a)return{kind:"sky",id:a,name:this.bodyName(a)};const o=this.interpretationShown?this.sceneRenderer.pickInterpretationBodyAt(e,t):void 0,c=o?this.interpretationShown?.bodies.find(x=>x.id===o):void 0,h=c?this.said.read(c.title)||this.explainedName(c.explains)||this.kindName(c):void 0;if(o!==void 0&&h)return{kind:"body",id:o,name:h};const d=this.skyEventPickAt(e,t,(x,S)=>!S.inSky);if(d)return d;const u=i?this.ghostPick(e,t):void 0;if(u)return u;if(this.sceneRenderer.pickAfterimageAt(e,t)){const x=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:x.name,detail:()=>x.detail.replace("{name}",x.name)}}const p=this.pickDecorAt(e,t)??this.sceneRenderer.pickPeakAt(e,t),f=p?this.ufoElement.sighting.decor.find(x=>x.id===p):void 0;if(f){const x=this.said.read(f.title)||n.decorKind(f.kind);return{kind:"decor",id:f.id,name:x,detail:()=>this.decorTooltip(f,x)}}const m=this.sceneRenderer.pickRailwayAt(e,t);if(m){const x=r.railwayTooltip;return{kind:"railway",id:m.line.id,name:co.name(m.line,x),detail:()=>co.detail(m,x,S=>this.distanceText(S))}}const g=this.trafficTooltipAt(e,t);if(g)return{kind:"traffic",name:g};const v=this.skyEventPickAt(e,t,(x,S)=>S.inSky===!0&&!x.pickedAfterSatellites);if(v)return v;const b=this.sceneRenderer.pickSatelliteAt(e,t);if(b)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",b.name).replace("{mag}",b.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(b.heightKm).toLocaleString())};const w=this.skyEventPickAt(e,t,(x,S)=>S.inSky===!0&&x.pickedAfterSatellites===!0);if(w)return w;const y=this.sceneRenderer.pickOpticsAt(e,t);if(y){const x=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:x.split(" — ")[0],detail:()=>x}}const M=this.sceneRenderer.pickStarAt(e,t);if(M){const x=M.star.mag,S=M.altitudeDeg,E=S<0?r.starTooltipBelow:r.starTooltip,A=n.star(M.star);return{kind:"star",name:A,detail:()=>E.replace("{name}",A).replace("{mag}",x.toLocaleString(void 0,{maximumFractionDigits:Math.abs(x)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(S))))}}}ghostLights=new Map;static GHOST_LIGHT_KEPT_MS=1e3;lightOfGhost(e,t){const i=this.ufoElement.canvasElement,s={x:8/Math.max(1,i.clientWidth),y:8/Math.max(1,i.clientHeight)},n=`${Math.round(e/s.x)}:${Math.round(t/s.y)}`,r=performance.now(),a=this.ghostLights.get(n);if(a&&r-a.atMs<At.GHOST_LIGHT_KEPT_MS)return a.light;let o=this.shiningDecorNear(e,t,2*Math.max(s.x,s.y)),c;if(!o)for(const[h,d]of[[0,0],[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){const u=this.pickAt(e+h*s.x,t+d*s.y,!1);if(u?.kind==="star")c??=u;else if(u){o=u;break}}return o??=this.shiningDecorNear(e,t,6*Math.max(s.x,s.y)),o??=c,this.ghostLights.size>256&&this.ghostLights.clear(),this.ghostLights.set(n,{light:o??null,atMs:r}),o??null}ghostPick(e,t){const i=this.sceneRenderer.pickGhostAt(e,t);if(!i)return;const s=this.naming.names.ghostTooltip,n=i.beyond?{kind:"sky",id:"sun",name:this.bodyName("sun")}:this.lightOfGhost(i.source.x,i.source.y)??void 0,r=(n?.kind==="star"?n.name.split(" — ")[0]:n?.name)??s.unnamed,a=i.ghost,c=(zt.scatters(a)?s.halo:a.cause==="glass"?s.double:s.ghost).replace("{name}",r),h=a.scale<0?s.opposite:a.scale===1?s.around:s.sameSide;return{kind:"ghost",id:n?.id,name:c,detail:()=>s.detail.replace("{name}",c).replace("{cause}",s.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(e,t,i){let s;for(const n of this.ufoElement.sighting.decor){if(!(n.kind==="streetlight"||n.kind==="trafficlight"||(n.lights?.length??0)>0||n.kind==="vehicle"&&n.lit))continue;const a=this.sceneRenderer.decorScreenBox(n.id);if(!a)continue;const o=Math.hypot(Math.max(a.minX-e,0,e-a.maxX),Math.max(a.minY-t,0,t-a.maxY));if(o>i||s&&o>=s.distance)continue;const c=this.said.read(n.title)||this.naming.decorKind(n.kind);s={distance:o,pick:{kind:"decor",id:n.id,name:c}}}return s?.pick}glassWettingOf(e){const t=JSON.stringify([e.lens,e.instrumentId,e.weatherTrack.allKeyframes.map(i=>[i.t,i.weather.precipitationType,i.weather.precipitationIntensity,i.weather.windDirectionDeg,i.weather.windSpeed])]);if(this.glassWetting?.sighting!==e||this.glassWetting.key!==t){const i=new rh(s=>{if(!zt.records(e.instrument)||!zt.falling(e.lens))return 0;const n=Lu(e,s*1e3),r=et(e,s*1e3);return(n.precipitationAmount??1)*zt.impactRate(n,e.lens?.glass,r&&{headingDeg:r.headingDeg??0,pitchDeg:r.pitchDeg,windFromDeg:n.windDirectionDeg,windSpeedMS:n.windSpeed})});this.glassWetting={sighting:e,key:t,wetting:i}}return this.glassWetting.wetting}glassWetting;get skyEventsShown(){return this.skyEventsOf(this.ufoElement.sighting)}skyEventsStartDate;skyEventsMerged;skyEventsOf(e){const t=e.skyEvents,i=this.fireballs?.reentries,s=this.skyEventsMerged;if(s&&s.stated===t&&s.fireballs===i)return s.shown;const n=i?.length?{...t,reentries:[...t?.reentries??[],...i]}:t;return this.skyEventsMerged={stated:t,fireballs:i,shown:n},n}skyEventTexts=new Map;skyEventTextsLanguage;loadSkyEventTexts(e){const t=Ha(Us.preferencesFor(this),Ba);t!==this.skyEventTextsLanguage&&(this.skyEventTexts.clear(),this.skyEventTextsLanguage=t);for(const i of e)this.skyEventTexts.has(i)||i.messages.load(t).then(s=>{this.skyEventTextsLanguage===t&&this.skyEventTexts.set(i,s)},()=>{})}skyEventPickAt(e,t,i){const s=this.skyEventsShown;if(!s)return;const n=this.sceneRenderer.pickSkyEventAt(e,t,i),r=n?Of.map(u=>ea.of(u)).find(u=>u.key===n.kind):void 0,a=n&&r?ea.eventsOf(s,r).find(u=>u.id===n.id):void 0;if(!n||!r||!a)return;const o=this.skyEventTexts.get(r);if(!o){this.loadSkyEventTexts([r]);return}const c=this.said.read(a.title)||o.name,h=r.describe?.(a,n,{said:this.said,texts:o,name:c,distance:u=>this.distanceText(u)}),d=h?.detail??(n.distanceM!==void 0?`${c}, ${this.distanceText(n.distanceM)}`:void 0);return{kind:r.pickKind??"skyEvent",id:a.id,name:h?.name??c,...d!==void 0?{detail:()=>d}:{}}}distanceText(e){return e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} km`:`${e.toLocaleString(void 0,{maximumFractionDigits:e<10?1:0})} m`}decorTooltip(e,t){const i=h=>h.toLocaleString(void 0,{maximumFractionDigits:h<10?1:0}),s=pe.sizeOf(e),n=this.sceneRenderer.decorDistanceM(e.id),r=n===void 0?"":this.distanceText(n),o=this.naming.names.decorTooltip.replace("{name}",t).replace("{size}",`${i(s.widthM)} × ${i(s.lengthM)} × ${i(s.heightM)} m`),c=this.said.read(e.note);return c?`${o.replace("{distance}",r)}. ${c}`:o.replace("{distance}",r)}computedKinds=new Map;computedKindTexts=new Map;bodyModelKinds=new Map;showInterpretation(e){const t=dc.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:s,kindOf:n}=hi.expandWithKinds(e,t,{obstacles:i});if(this.interpretationAsked=e,this.interpretationShown=s,this.computedKinds=n,this.loadComputedKindTexts(),hi.loaded(e,t))return;const r=hi.load(e,t);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==e||!hi.loaded(e,t)||(this.showInterpretation(e),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=vn.NONE;obstaclesMadeOf;obstaclesOf(e){return this.obstaclesMadeOf?.decor!==e&&(this.obstaclesMadeOf={decor:e,obstacles:vn.of(e,t=>pe.sizeOf(t))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const e=this.interpretationAsked;!e||!hi.computes(e,dc.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(e),this.ufoElement.refreshSoundControls())}computedInterpretation(e){const t=dc.kinds(),i=hi.loaded(e,t)?Promise.resolve():hi.load(e,t),{interpretation:s,phenomenonOf:n}=hi.expandWithKinds(e,t,{obstacles:this.obstaclesOf(this.ufoElement.sighting.decor)});return{interpretation:s??e,phenomenonOf:n,loaded:i}}loadComputedKindTexts(){const e=this.namesLanguage;if(e)for(const t of new Set(this.computedKinds.values()))this.computedKindTexts.has(t)||t.messages.load(e).then(i=>{e===this.namesLanguage&&this.computedKindTexts.set(t,i)}).catch(()=>{})}kindName(e){const t=this.computedKinds.get(e.id),i=t?this.computedKindTexts.get(t):void 0;if(i?.name)return i.name;const s=e.model.id;if(s==="figure")return this.naming.decorKind("entity");if(!s||e.model.url!==void 0)return;if(!this.bodyModelKinds.has(s)){this.bodyModelKinds.set(s,void 0),this.sceneRenderer.entryOfDecorModel(s).then(r=>this.bodyModelKinds.set(s,[r?.kind].flat()[0])).catch(()=>{});return}const n=this.bodyModelKinds.get(s);return n&&this.naming.decorKind(n)||void 0}explainedName(e){if(!e?.length)return;const t=this.ufoElement.sighting.timeline.allKeyframes,i=e.map(s=>{for(const n of t){const r=this.said.read(n.shapes.find(a=>a.sourceId===s)?.shape.title);if(r)return r}}).filter(s=>!!s);return i.length?i.join(", "):void 0}bodyName(e){const t=e.startsWith(KA)?e.slice(KA.length):void 0,i=t?n_.find(n=>n.id===t):void 0;if(i)return this.naming.comet(i);const s=e.startsWith(XA)?Gg.byId(e.slice(XA.length)):void 0;return s?this.naming.nova(s):this.naming.body(e)}get naming(){return this.sceneNaming}sceneNaming=new Hg;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const e=Ha(Us.preferencesFor(this),Ba);if(e===this.namesLanguage)return;this.namesLanguage=e;const t=await fT(e);e===this.namesLanguage&&(this.applySceneNaming(new Hg(t)),this.computedKindTexts.clear(),this.loadComputedKindTexts())}setBusy(e,t=""){this.busyElement.hidden=!e,this.busyNote.textContent=e?t:"",this.busyElement.setAttribute("aria-label",t),this.busyElement.setAttribute("aria-busy",String(e))}renderLoaderText(e,t){let i=0;const s=(n,r)=>{n.setAttribute("aria-label",r),n.replaceChildren(),r.split(" ").forEach((a,o)=>{o>0&&n.append(" ");const c=document.createElement("span");c.className="scene-loader-word",c.setAttribute("aria-hidden","true");for(const h of a){const d=document.createElement("span");d.className="scene-loader-letter",d.style.setProperty("--i",String(i++)),d.textContent=h,c.append(d)}n.append(c),i++})};s(this.loaderNotVideo,e),i+=6,s(this.loaderNote,t)}applySceneNaming(e){this.sceneNaming=e,e.loaded&&(this.creditsButton.title=e.names.credits,this.creditsButton.setAttribute("aria-label",e.names.credits),this.renderLoaderText(e.names.notAVideo,e.names.isASimulation),this.sceneRenderer.setCompassPoints(e.names.compassPoints))}showHoverTooltip(e,t){const i=this.hoverTooltip;if(i.textContent=t,i.hidden=!1,typeof i.showPopover=="function"){const d=document.fullscreenElement;i.matches(":popover-open")&&d!==this.tooltipOver&&i.hidePopover(),i.matches(":popover-open")||i.showPopover(),this.tooltipOver=d}const{innerWidth:s,innerHeight:n}=window,r=12,a=4,o=Math.min(e.clientX+r,s-i.offsetWidth-a),c=e.clientY+r,h=c+i.offsetHeight+a>n?e.clientY-r-i.offsetHeight:c;i.style.left=`${Math.max(a,o)}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(e,t,i,s){const n=`${i.lat.toFixed(4)},${i.lng.toFixed(4)}`,r=this.detonationsFor;(!r||n!==r.key||e.length!==r.reentries.length||e.some((c,h)=>c!==r.reentries[h]))&&(this.detonationsFor={reentries:[...e],key:n,detonations:e.length?Ce.detonationsOf(e,i):[]});const a=this.detonationsFor.detonations;if(s)return;const o=this.lastDetonationT;if(this.lastDetonationT=t,!(o===void 0||t<o||t-o>At.DETONATION_JUMP_MS||this.ufoElement.playbackState!=="playing"))for(const c of a)c.t>o&&c.t<=t&&this.weatherAudio.playDetonation(c.loudness)}detonates(e){const t=[...e.skyEvents?.reentries??[],...this.fireballs?.reentries??[]],i=et(e,0),s=e.event.place?.[0],n=i?.lat??s?.lat,r=i?.lng??s?.lng;return t.length>0&&n!==void 0&&r!==void 0&&Ce.detonationsOf(t,{lat:n,lng:r,heightM:this.altitudeOf(i)}).length>0}detonationsFor;lastDetonationT;static DETONATION_JUMP_MS=2e3;handleLightningFlash(e){if(clearTimeout(this.thunderTimeoutId),this.filmSound){this.filmThunderAtMs=this.lastTimeMs+Ks.thunderDelayMs(e)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),Ks.thunderDelayMs(e))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(Lu(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;applyLevel(){if(this.filmSound)return;const e=this.ufoElement.level;this.weatherAudio.setLevel(e),this.vehicleAudio.setLevel(e),this.aircraftAudio?.setLevel(e)}handlePageGesture=()=>{this.ufoElement.playbackState==="playing"&&this.handleFirstInteraction()};unlockIfAlreadyActivated(){this.interacted||navigator.userActivation?.hasBeenActive&&this.handleFirstInteraction()}static GESTURES=["pointerdown","pointerup","touchend","click","keydown"];handleTimeUpdate=e=>{if(this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"){this.sceneRenderer.frame(performance.now());const t=performance.now();this.lastHover&&!this.ghostPath.hasAttribute("hidden")&&t-this.lastPlayingHoverMs>=At.PLAYING_HOVER_MS&&(this.lastPlayingHoverMs=t,this.ghostStillUnder(this.lastHover,t)&&this.hoverAt(this.lastHover))}this.placeFlightMark(),this.ufoElement.repaintChrome()};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.filming;this.sceneRenderer.setAnimationsRunning(t,t);const i=e||this.filmSound!==void 0;this.weatherAudio.setPaused(!i),this.vehicleAudio.setPaused(!i),this.aircraftAudio?.setPaused(!i),e&&this.unlockIfAlreadyActivated(),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${G8}</style>${H8}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new he(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(NM));const t=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=t,this.poster=new Gp(this.shadow.getElementById("scene-poster"),()=>{this.loader.style.animationDelay=!this.poster.up&&this.holding?"0s":"",this.applyHold()}),this.sceneRenderer.onFirstFrameHold=n=>{this.holding=n,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(Y1),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.ufoElement.observerMapSnapshotSource=n=>this.snapshotMapOf(n),this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",n=>this.lookToward(n.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"),s=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",n=>{n.newState==="open"&&zn.fill(s,this)}),this.sceneRenderer.onMapSubjectBounds=n=>this.ufoElement.setMapSubjectBounds(n),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("revealrequest",()=>this.poster.release()),this.ufoElement.addEventListener(RI,()=>this.poster.restore()),this.ufoElement.seekPreviewPainter=(n,r)=>this.seekPreviewOf(r).paint(n,r),typeof VideoEncoder<"u"&&typeof OffscreenCanvas<"u"&&(this.ufoElement.filmer={film:(n,r,a)=>this.film(n,r,a),generativeKit:(n,r,a)=>this.generativeKit(n,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=n=>n.vehicle!==void 0||n.decor.some(r=>r.engine!==void 0)||n.decor.some(r=>Df.kindOf(r,this.decorModelSounds.get(r.model?.id??""))!==void 0)||this.interpretationShown?.bodies.some(r=>r.sound)===!0||n.weatherTrack.allKeyframes.some(r=>r.weather.precipitationType!=="none"||r.weather.windSpeed>1)||this.detonates(n)||(this.traffic?.audible?.size??0)>0,this.ufoElement.addEventListener("referenceview",n=>this.applyReferenceView(n.detail)),this.ufoElement.addEventListener("traceview",n=>this.sceneRenderer.setTracesShown(n.detail.shown)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const n of At.GESTURES)this.addEventListener(n,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Fs(Us.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(e,t){const i=e.vehicle;return!i||!Rn.isRoad(i.kind)?void 0:{setting:xl.at(i.headlights??"auto",i.headlightKeyframes,t)??"auto",headingDeg:this.travelHeadingAt(e,t)}}travelHeadingAt(e,t){const i=et(e,t);if(!i)return 0;for(const s of[400,-400]){const n=et(e,t+s);if(!n||i.lat===void 0||i.lng===void 0||n.lat===void 0||n.lng===void 0)break;const r=lt(n.lat,n.lng,i.lat,i.lng);if(Math.hypot(r.x,r.z)<.8)continue;return(Math.atan2(r.x,-r.z)*180/Math.PI+(s<0?180:0)+360)%360}return i.headingDeg??0}routeCache;routeOf(e){const t=e.allKeyframes;if(this.routeCache?.track===e&&this.routeCache.count===t.length)return this.routeCache.route;const i=t.flatMap(n=>n.pose.lat!==void 0&&n.pose.lng!==void 0?[{lat:n.pose.lat,lng:n.pose.lng}]:[]),s=i.length>=2?i:void 0;return this.routeCache={track:e,count:t.length,route:s},s}traceLabels(e){const t=Us.preferencesFor(this).join();if(this.traceLabelsFor?.traces!==e||this.traceLabelsFor.language!==t){const i=new Map;for(const s of e){const n=this.said.read(s.title);n&&i.set(s.id,n)}this.traceLabelsFor={traces:e,language:t,labels:i}}return this.traceLabelsFor.labels}connectedCallback(){Xe.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 t of At.GESTURES)document.addEventListener(t,this.handlePageGesture,!0);const e=this.getAttribute("src");e&&this.loadFromSrc(e)}watchVisibility(){this.visibilityObserver?.disconnect(),!(typeof IntersectionObserver>"u"||this.hasAttribute("always-live"))&&(this.visibilityObserver=new IntersectionObserver(e=>{if(e[e.length-1].isIntersecting){this.sceneRenderer.resume();return}this.ufoElement.pause(),this.sceneRenderer.suspend()},{rootMargin:"100px"}),this.visibilityObserver.observe(this))}visibilityObserver;disconnectedCallback(){Xe.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const e of At.GESTURES)document.removeEventListener(e,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(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const s=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(s)&&s>0?s:Math.min(window.devicePixelRatio||1,2))}(e===tu||e===iu||e===ah)&&i!==t&&this.forwardPlayerAttributes(),e===ah&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const e of[tu,iu,ah]){const t=this.getAttribute(e);t===null?this.ufoElement.removeAttribute(e):this.ufoElement.setAttribute(e,t)}}setCompassForced(e){this.showCompassFor({forced:e})}compassHovered=!1;compassForced=!1;showCompassFor(e){this.compassHovered=e.hovered??this.compassHovered,this.compassForced=e.forced??this.compassForced,this.sceneRenderer.setCompassForced(this.compassForced||this.compassHovered)}lookToward(e){const t=et(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="observer"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:s}=lt(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,s)<1)return this.setLookOffset(0,0);const n=(Math.atan2(i,-s)*180/Math.PI+360)%360;this.setLookOffset(((n-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setOutsideHeard(Rn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity*(e.precipitationAmount??1),e.windSpeed);const t=this.ufoElement.sighting.around;this.weatherAudio.setAround(Bi.aroundBedRms(t),Bi.aroundBedShape(t)??[])}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}decorScreenBox(e){return this.sceneRenderer.decorScreenBox(e)}decorDrawnOffset(e){return this.sceneRenderer.decorDrawnOffset(e)}decorGroundPointAt(e,t,i,s=0){return this.sceneRenderer.decorGroundPointAt(e,t,i,s)}decorMetresPerNdcY(e){return this.sceneRenderer.decorMetresPerNdcY(e)}decorGrabHeightAt(e,t,i){return this.sceneRenderer.decorGrabHeightAt(e,t,i)}bodyScreenBox(e){return this.sceneRenderer.bodyScreenBox(e)}pickPlacedBodyAt(e,t){return this.sceneRenderer.pickPlacedBodyAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume()}async loadFromSrc(e){const t=Fa.recording(e);this.holdForNewScene(t);const i=await t;this.documentUrl=new URL(e,location.href).href,this.showPoster(i.image,this.documentUrl,!this.ufoElement.playRequested),this.sightingData=i}loader;poster;showPoster(e,t,i=!0){this.poster.show(e,t,i)}applyHold(){const e=this.holding,t=this.poster.up;this.loader.hidden=!e||t,e&&(this.hoverTooltip.hidden=!0),this.ufoElement.captionHeld=e||t,this.ufoElement.controlsHeld=e||t,this.ufoElement.holdClock(e)}holdForNewScene(e){this.sceneRenderer.holdForNewScene(e)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(e){this.sceneRenderer.documentUrl=e}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){const t=En.recording(e);this.ufoElement.playerTitle=void 0,this.ufoElement.sightingData=t,this.requireModules(t.modules),this.upperAirHeardLive=void 0,this.seekPreview?.recordingChanged(t),this.showInterpretation(this.inTheRound?this.ufoElement.sighting.interpretation:void 0),this.syncAccountHidden(),this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}onModulesChanged=e=>{e.detail==="skyEvents"&&this.sceneRenderer.setSkyEvents(this.skyEventsShown,!0,this.skyEventsStartDate)};requireModules(e){if(!e?.length)return;const t=this.documentUrl,i=V(async()=>{const{ModuleSession:s}=await import("./ModuleSession-Cxe0BJue.js");return{ModuleSession:s}},[],import.meta.url).then(({ModuleSession:s})=>s.shared.require(e,t)).then(()=>this.sceneRenderer.setDecorModelProvider(new Fp));this.sceneRenderer.holdUntil(i)}seekPreview;seekPreviewOf(e){const t=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(e.width/t);return e.height!==i&&(e.height=i),this.seekPreview??=new Fg(this,()=>document.createElement(Bf))}showAt(e){this.ufoElement.currentTime=e,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(e){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const t=e.getContext("2d");return t?(t.imageSmoothingQuality="high",t.drawImage(this.sceneCanvas,0,0,e.width,e.height),!0):!1}filmName;filmFileName(){return`${(this.filmName??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim()||"observation"}.mp4`}filming=!1;async film(e,t,i){const[{VideoExport:s},{FilmChrome:n}]=await Promise.all([V(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),V(()=>import("./FilmChrome-DYiyzoB_.js"),[],import.meta.url)]),r=await n.loadLogo();return this.filmScene(e,a=>s.film({...a,frameAt:(o,c,h)=>a.frameAt(o,c,h)?(n.paint(h,this.ufoElement.filmChrome(e),r),!0):!1},t,i))}async generativeKit(e,t,i){const[{GenerativeKit:s},{generativeKitMessages:n},{toSightingJson:r}]=await Promise.all([V(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([25,26,27]),import.meta.url),V(()=>import("./GenerativeKitMessages-I8xH2ec9.js"),[],import.meta.url),V(()=>Promise.resolve().then(()=>_N),void 0,import.meta.url)]),a=Ha(Us.preferencesFor(this),Ba),[o]=await Promise.all([n.load(a),this.sceneRenderer.loadControlPasses()]),c=this.sceneRenderer.areReferencesShown;this.sceneRenderer.setReferencesShown(!1);try{return await this.filmScene({...e,caption:!1,time:!1,map:!1},h=>s.make({film:h,drawControlPasses:()=>this.sceneRenderer.drawControlPasses(),recording:r(this.ufoElement.sighting),title:this.filmName??"",source:h.about?.source,language:a},o,t,i))}finally{this.sceneRenderer.setReferencesShown(c)}}async filmScene(e,t){if(this.filming)throw new Error("Already filming");const i=this.ufoElement,s=i.currentTime;i.pause();const n={width:this.sceneCanvas.clientWidth,height:this.sceneCanvas.clientHeight},r=e.height&&n.height>0?e.height/n.height:this.sceneRenderer.maxPixelRatio;this.filming=!0,this.sceneRenderer.holdPixelRatio(r),i.filmMap(e.map),this.syncAnimationsToPlayback();try{const a=e.height??this.sceneCanvas.height,o=e.height&&n.height>0?Math.round(e.height*n.width/n.height):this.sceneCanvas.width,c=this.filmRate(),h=Math.min(i.seekableDuration,e.toS!==void 0?e.toS*1e3*c:i.seekableDuration),d=Math.min(h,Math.max(0,(e.fromS??0)*1e3*c));return await t({fromMs:d,toMs:h,rate:c,width:o,height:a,frameAt:(u,p,f)=>this.filmFrameAt(u,p,f),hearInto:u=>this.hearInto(u),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=s,this.syncAnimationsToPlayback()}}filmRate(){const e=this.ufoElement.playbackRate;return e>0?e:1}filmPictureSize(){const e=this.sceneRenderer.maxPixelRatio;return{width:Math.round(this.sceneCanvas.clientWidth*e),height:Math.round(this.sceneCanvas.clientHeight*e)}}filmSound;liveSound;filmThunderAtMs;hearInto(e){if(e){this.liveSound??={weather:this.weatherAudio,vehicle:this.vehicleAudio,aircraft:this.aircraftAudio},this.filmSound=e,this.weatherAudio=new uh(e),this.vehicleAudio=new v2(e);const t=At.trafficRuntime;this.aircraftAudio=this.liveSound.aircraft&&t?this.newAircraftAudio(t):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(e),this.syncAnimationsToPlayback()}filmFrameAt(e,t,i){this.ufoElement.currentTime!==e&&(this.ufoElement.currentTime=e),this.filmThunderAtMs!==void 0&&e>=this.filmThunderAtMs&&(this.filmThunderAtMs=void 0,this.weatherAudio.playThunder()),this.sceneRenderer.render();const s=this.sceneRenderer.framesDrawn;return this.sceneRenderer.frame(t),this.sceneRenderer.framesDrawn===s?!1:(i.drawImage(this.sceneCanvas,0,0,i.canvas.width,i.canvas.height),!0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}horizonPointAt(e){const t=e*Math.PI/180,i=this.sceneRenderer.screenPointOf(new I(Math.sin(t),0,-Math.cos(t)));return i&&{x:(i.ndcX+1)/2,y:(1-i.ndcY)/2}}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailure(e){return this.sceneRenderer.referenceFailure(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references){const i=e.views?.[t.id];this.sceneRenderer.setReferenceView(t.id,{opacity:i?i.shown?i.opacity:0:e.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(e){this.liveTerrainProviders=e,this.snapshotKey=void 0,this.applySnapshots(this.ufoElement.sighting.snapshots)}liveTerrainProviders;snapshotKey="none";applySnapshots(e){const t=us.isEmpty(e)?"none":`${JSON.stringify(e)}
|
|
12178
|
+
`);let n=no.cache.get(s);return n||(n=Promise.all(i.map(r=>no.load(r.url))).then(r=>r.reduce((a,o)=>no.concat(a,o))),no.cache.set(s,n)),n}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){const i=(s,n)=>{const r=new Float32Array(s.length+n.length);return r.set(s,0),r.set(n,s.length),r};return{count:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}class Ei{constructor(e){if(this.heights=e,e.length!==Ei.WIDTH*Ei.HEIGHT)throw new Error(`a lunar relief has ${Ei.WIDTH*Ei.HEIGHT} samples, not ${e.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*Ei.SAMPLES_PER_DEGREE;static HEIGHT=180*Ei.SAMPLES_PER_DEGREE;static UNIT_KM=.1;static REFERENCE_RADIUS_KM=1737.4;static BAND_FROM_DEG=74;static BAND_TO_DEG=106;heightKm(e,t){const i=Ei.SAMPLES_PER_DEGREE,s=(t%360+360)%360*i-.5,n=(90-e)*i-.5,r=Math.floor(s),a=Math.floor(n),o=s-r,c=n-a,h=(p,f)=>{const m=(p%Ei.WIDTH+Ei.WIDTH)%Ei.WIDTH,g=Math.min(Ei.HEIGHT-1,Math.max(0,f));return this.heights[g*Ei.WIDTH+m]},d=h(r,a)*(1-o)+h(r+1,a)*o,u=h(r,a+1)*(1-o)+h(r+1,a+1)*o;return(d*(1-c)+u*c)*Ei.UNIT_KM}static inBand(e,t){const i=Math.PI/180,s=Math.acos(Math.cos(e*i)*Math.cos(t*i))*180/Math.PI;return s>=Ei.BAND_FROM_DEG&&s<=Ei.BAND_TO_DEG}static withBump(e,t,i,s=.4){const n=new Int8Array(Ei.WIDTH*Ei.HEIGHT),r=Ei.SAMPLES_PER_DEGREE,a=Math.ceil(s*r),o=Math.floor(t*r),c=Math.floor((90-e)*r);for(let h=-a;h<=a;h++)for(let d=-a;d<=a;d++)Math.hypot(d,h)<=a&&(n[(c+h)*Ei.WIDTH+(o+d+Ei.WIDTH)%Ei.WIDTH]=Math.round(i/Ei.UNIT_KM));return new Ei(n)}static smooth(){return new Ei(new Int8Array(Ei.WIDTH*Ei.HEIGHT))}}class ua{static SAMPLES=5760;static SEARCH_FROM_DEG=87;static SEARCH_TO_DEG=90.2;static SEARCH_STEP_DEG=.0625;static profile(e,t,i,s=ua.SAMPLES){const{s:n,u:r,w:a,distanceKm:o}=ua.frame(e,t),c=Math.PI/180,h=new Float32Array(s),d=Ei.REFERENCE_RADIUS_KM;for(let u=0;u<s;u++){const p=u/s*2*Math.PI,f=Math.cos(p),m=Math.sin(p),g=f*r[0]+m*a[0],v=f*r[1]+m*a[1],b=f*r[2]+m*a[2];let w=0;for(let y=ua.SEARCH_FROM_DEG;y<=ua.SEARCH_TO_DEG;y+=ua.SEARCH_STEP_DEG){const M=Math.cos(y*c),x=Math.sin(y*c),S=M*n[0]+x*g,E=M*n[1]+x*v,A=M*n[2]+x*b,T=Math.asin(Math.max(-1,Math.min(1,A)))/c,D=Math.atan2(E,S)/c,k=d+i.heightKm(T,D),O=Math.atan2(k*x,o-k*M);O>w&&(w=O)}h[u]=w/c}return{radiusDeg:h,meanRadiusDeg:Math.asin(d/o)/c}}static frame(e,t){const i=new yl(t.lat,t.lng,t.elevationM),s=mc(e),n=Ny(e,i,!1),r=new jt(n.x-s.x,n.y-s.y,n.z-s.z,s.t),a=Math.hypot(r.x,r.y,r.z)*ua.AU_KM,o=ua.bodyFixed(e),c=o(r),h=Math.hypot(c[0],c[1],c[2]),d=[c[0]/h,c[1]/h,c[2]/h],u=FD(e,i),p=Uw(u),f=uc(u,new jt(-r.x,-r.y,-r.z,s.t)),m=Math.asin(f.z/Math.hypot(f.x,f.y,f.z)),g=Math.atan2(-f.y,f.x),v=new jt(-Math.sin(m)*Math.cos(g),Math.sin(m)*Math.sin(g),Math.cos(m),s.t),b=new jt(-Math.sin(g),-Math.cos(g),0,s.t);return{s:d,u:o(uc(p,v)),w:o(uc(p,b)),distanceKm:a}}static surfacePoint(e,t,i,s){const{s:n,u:r,w:a}=ua.frame(e,t),o=Math.PI/180,c=[0,1,2].map(d=>Math.cos(i*o)*r[d]+Math.sin(i*o)*a[d]),h=[0,1,2].map(d=>Math.cos(s*o)*n[d]+Math.sin(s*o)*c[d]);return{latDeg:Math.asin(h[2])/o,lonDeg:Math.atan2(h[1],h[0])/o}}static radiusAt(e,t){const i=e.radiusDeg.length,s=(t/360*i%i+i)%i,n=Math.floor(s),r=s-n;return e.radiusDeg[n]*(1-r)+e.radiusDeg[(n+1)%i]*r}static uncoveredFraction(e,t,i){const s=e.radiusDeg.length,n=i.upDeg*i.upDeg+i.rightDeg*i.rightDeg;let r=0;for(let a=0;a<s;a++){const o=a/s*2*Math.PI,c=Math.cos(o),h=Math.sin(o),d=c*i.upDeg+h*i.rightDeg,u=d*d-n+t*t;if(u<=0)continue;const p=Math.sqrt(u),f=d+p;if(f<=0)continue;const m=Math.max(0,d-p),g=Math.max(m,e.radiusDeg[a]);f>g&&(r+=.5*(f*f-g*g))}return Math.min(1,Math.max(0,r*(2*Math.PI/s)/(Math.PI*t*t)))}static AU_KM=1495978707e-1;static bodyFixed(e){const t=QD(ye.Moon,e),i=Math.PI/180,s=t.ra*15*i,n=t.dec*i,r=t.spin*i,a=(c,[h,d,u])=>[Math.cos(c)*h+Math.sin(c)*d,-Math.sin(c)*h+Math.cos(c)*d,u],o=(c,[h,d,u])=>[h,Math.cos(c)*d+Math.sin(c)*u,-Math.sin(c)*d+Math.cos(c)*u];return c=>a(r,o(Math.PI/2-n,a(Math.PI/2+s,[c.x,c.y,c.z])))}static subObserverPoint(e,t){const i=new yl(t.lat,t.lng,t.elevationM),s=mc(e),n=Ny(e,i,!1),r=ua.bodyFixed(e)(new jt(n.x-s.x,n.y-s.y,n.z-s.z,s.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 Hp{static cache=new Map;static load(e){let t=Hp.cache.get(e);return t||(t=Hp.fetchRelief(e).catch(()=>{}),Hp.cache.set(e,t)),t}static async fetchRelief(e){const t=await fetch(e);if(!t.ok)return;let i=new Uint8Array(await t.arrayBuffer());if(i[0]===31&&i[1]===139){if(typeof DecompressionStream>"u")return;const s=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip"));i=new Uint8Array(await new Response(s).arrayBuffer())}return new Ei(new Int8Array(i.buffer,i.byteOffset,i.length))}}const RM=yi.catalog({en:()=>V(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(l=>l.perceptionMessages_en),fr:()=>V(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(l=>l.perceptionMessages_fr),es:()=>V(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(l=>l.perceptionMessages_es),it:()=>V(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(l=>l.perceptionMessages_it)});class zg{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=zg.ID;messages=RM;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(e){const t=zg.MATRICES[String(e.type)];if(!t)return Fr.NONE;const i=Number(e.severity??100),s=Math.max(0,Math.min(100,Number.isFinite(i)?i:100))/100;return{colorMatrix:t.map((r,a)=>Fr.IDENTITY[a]+(r-Fr.IDENTITY[a])*s),contrastGain:1}}}class CM{static ID="fatigue";id=CM.ID;messages=RM;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(e){return Fr.NONE}}class Zl{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=Zl.ID;messages=RM;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:Zl.MAX_LEVEL,step:.01,unit:"%",also:{unit:"g/L",factor:10,digits:1}}];perceive(e){const t=Number(e.bloodAlcohol??0),i=Math.max(0,Math.min(Zl.MAX_EFFECT_LEVEL,Number.isFinite(t)?t:0));if(i===0)return Fr.NONE;const s=i/Zl.MEASURED_LEVEL*Zl.MEASURED_LOSS_DB;return{colorMatrix:Fr.IDENTITY,contrastGain:10**(-s/20)}}}const mU=l=>l.sources[0]??l.id,gU=Xe.point("perception").provide(Xe.BUILT_IN,[new zg,new Zl,new CM].map(l=>({id:l.id,name:l.id,credit:mU(l),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>l})));class Na{static built=new WeakMap;static get ALL(){return gU.map(e=>{let t=Na.built.get(e);return t||(t=e.create(),Na.built.set(e,t)),t})}static byId(e){return Na.ALL.find(t=>t.id===e)}static perceptionOf(e){return Na.ALL.reduce((t,i)=>Fr.combine(t,i.perceive(e?.[i.id]??{})),Fr.NONE)}static compact(e){const t={},i=Na.ALL;for(const[s,n]of Object.entries(e))!i.some(r=>r.id===s)&&Object.keys(n??{}).length>0&&(t[s]=n);for(const s of i){const n=e[s.id]??{},r=Object.fromEntries(s.settings.filter(a=>n[a.id]!==void 0&&n[a.id]!==a.default).map(a=>[a.id,n[a.id]]));Object.keys(r).length>0&&(t[s.id]=r)}return Object.keys(t).length>0?t:void 0}}class Hg{names;constructor(e){this.names=e??yi.blank(),this.loaded=e!==void 0}loaded;body(e){return this.names.bodies[e]??e}star(e){return this.names.stars[e.name]??e.name}comet(e){return this.names.comets[e.id]??e.name}nova(e){return this.names.novae[e.id]??e.name}satelliteClass(e){return this.names.satelliteClasses[e.id]??e.name}shower(e){return this.names.showers[e.id]??e.name}lightRig(e){return this.names.lightRigs[e.id]??e.name}instrument(e){return this.names.instruments[e.id]??e.name}decorKind(e){return this.names.decorKinds[e]}point(e){return yh.point(e,this.loaded?this.names.compassPoints:void 0)}towards(e){return yh.towards(e,this.loaded?this.names:void 0)}}class co{static STANDARD_GAUGE_MM=1435;static METRE_GAUGE_MM=1e3;static kind(e,t){return e.highSpeed?t.highSpeed:e.service?t.service:t.kinds[e.kind]}static name(e,t){const i=e.name??co.kind(e,t);return e.services?.length?`${i} — ${e.services.join(", ")}`:i}static voltage(e,t){return e>=1e3?`${(e/1e3).toLocaleString(t,{maximumFractionDigits:1})} kV`:`${e.toLocaleString(t)} V`}static detail(e,t,i,s){const{line:n}=e,r=[];n.name&&r.push(co.kind(n,t).toLocaleLowerCase(s)),r.push(n.tracks>1?t.tracks.replace("{count}",String(n.tracks)):t.singleTrack);const a=n.voltageV?co.voltage(n.voltageV,s):void 0;if(e.contactM!==void 0){const o=e.contactM.toLocaleString(s,{minimumFractionDigits:2,maximumFractionDigits:2});r.push((a?t.overheadVoltage.replace("{voltage}",a):t.overhead).replace("{height}",o))}else n.electrification==="third_rail"?r.push(a?t.thirdRailVoltage.replace("{voltage}",a):t.thirdRail):n.electrification==="none"&&r.push(t.notElectrified);return n.gaugeMm===co.METRE_GAUGE_MM?r.push(t.metreGauge):n.gaugeMm!==co.STANDARD_GAUGE_MM&&r.push(t.gauge.replace("{mm}",n.gaugeMm.toLocaleString(s))),r.push(t.distance.replace("{distance}",i(e.distanceM))),n.services?.length?`${co.name(n,t)}; ${r.join(", ")}`:`${co.name(n,t)} — ${r.join(", ")}`}}class Gp{constructor(e,t){this.element=e,this.onChange=t,e.addEventListener("error",()=>{this.url=void 0,this.release()})}shown=!1;url;get up(){return this.shown}show(e,t,i=!0){const s=Gp.resolve(e,t);if(this.url=s,!s||!i){this.release();return}this.element.src=s,this.element.hidden=!1;const n=this.shown;this.shown=!0,n||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(e,t){if(!(typeof e!="string"||e.trim()===""))try{const i=new URL(e.trim(),t??location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?void 0:i.origin===Gp.PUBLISHED_ORIGIN&&Gp.isDevelopmentHost(location.hostname)?location.origin+i.pathname:i.href}catch{return}}static PUBLISHED_ORIGIN="https://ufoathome.org";static isDevelopmentHost(e){return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".localhost")}}const vU="Global Meteor Network",bU="https://globalmeteornetwork.org/data/",yU="“Thunder” by Jerimee",wU="https://creativecommons.org/licenses/by/3.0/",MU="CC BY 3.0";class zn{static fill(e,t){e.innerHTML="";const i=u=>e.appendChild(u),s=t.currentTerrainAttribution;s&&i(zn.text(s));const n=t.currentRoadAttribution;n&&i(zn.text(n));const r=t.currentWaterAttribution;r&&i(zn.text(r));const a=t.currentRailwayAttribution;a&&i(zn.text(a));const o=t.ufoElement.observerMapCredit;o&&!s?.includes(o)&&i(zn.text(o));for(const u of t.decorModelCredits){const p=u.author?` — ${u.author}`:"",f=document.createElement("li");u.sourceUrl?f.append(zn.link(u.sourceUrl,u.title),document.createTextNode(`${p} (${u.license})`)):f.textContent=`${u.title}${p} (${u.license})`,i(f)}for(const u of t.ufoElement.sighting.references){if(!u.credit)continue;const p=document.createElement("li");u.creditUrl?p.appendChild(zn.link(u.creditUrl,u.credit)):p.textContent=u.credit,i(p)}if(t.ufoElement.sighting.traces.length>0){const u=new Fs(Us.preferencesFor(t)),p=new Set(t.ufoElement.sighting.traces.map(f=>u.read(f.source)).filter(f=>!!f));for(const f of p)i(zn.text(f))}const c=t.satelliteState;if(c.status==="ready"&&c.credit){const u=document.createElement("li");u.appendChild(zn.link(c.creditUrl??"",c.credit)),i(u)}if(t.fireballState.status==="ready"&&t.fireballState.records.length>0){const u=document.createElement("li");u.append(zn.link(bU,vU),document.createTextNode(" (CC BY 4.0)")),i(u)}const h=t.aircraftState;if(h.status==="ready"&&h.shown>0){const u=document.createElement("li");if(u.appendChild(zn.link(h.creditUrl,h.credit)),i(u),h.trailCredit){const p=document.createElement("li");p.appendChild(zn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(p)}}const d=zn.text(`${yU} (`);d.append(zn.link(wU,MU),document.createTextNode(")")),i(d)}static text(e){const t=document.createElement("li");return t.textContent=e,t}static link(e,t){const i=document.createElement("a");return i.href=e,i.target="_blank",i.rel="noopener",i.textContent=t,i}}const xU=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,EU=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,FA=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,SU=20,AU=1,TU=7,IU=.35,UA=.4,BA=40,zA=.5,_U=Math.SQRT2;class uh{context;constructor(e){this.context=e}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};around;aroundRequested={rms:0,shape:[]};level=1;share=1;master;output(e){return this.master||(this.master=e.createGain(),this.master.gain.value=this.gain,this.master.connect(e.destination)),this.master}get gain(){return this.level*this.share}setLevel(e){this.level=e,this.master&&(this.master.gain.value=this.gain)}setOutsideHeard(e){this.share=Math.min(1,Math.max(0,e)),this.master&&(this.master.gain.value=this.gain)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}ta.isLive(this.context)&&ta.unlock(this.context),this.applyAround()}setAround(e,t){const i=this.aroundRequested;i.rms===Math.max(0,e)&&i.shape.length===t.length&&i.shape.every((s,n)=>s===t[n])||(this.aroundRequested={rms:Math.max(0,e),shape:t},this.applyAround())}applyAround(){const e=this.context;if(!e)return;const{rms:t,shape:i}=this.aroundRequested,s=this.paused?0:t;if(s===0&&!this.around)return;const n=this.around??(this.around=this.buildAround(e)),r=e.currentTime;n.gain.gain.setTargetAtTime(s,r,zA),ms.OCTAVES.forEach((a,o)=>{const c=Math.sqrt(Math.min(1,1.11*a/(e.sampleRate/2)))/Math.sqrt(3);n.bands[o].gain.setTargetAtTime((i[o]??0)/c,r,zA)})}buildAround(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*TU),e.sampleRate),i=t.getChannelData(0);for(let m=0;m<i.length;m++)i[m]=Math.random()*2-1;const s=e.createBufferSource();s.buffer=t,s.loop=!0;const n=Math.floor(e.sampleRate*BA),r=e.createBuffer(1,n,e.sampleRate),a=Array.from({length:Math.round(BA*UA)},()=>Math.random()*2-1),o=r.getChannelData(0),c=e.sampleRate/UA;for(let m=0;m<n;m++){const g=m/c,v=Math.floor(g),b=g-v,w=b*b*(3-2*b);o[m]=a[v%a.length]*(1-w)+a[(v+1)%a.length]*w}const h=e.createBufferSource();h.buffer=r,h.loop=!0;const d=e.createGain();d.gain.value=IU;const u=e.createGain();u.gain.value=1,h.connect(d).connect(u.gain);const p=e.createGain();p.gain.value=0,u.connect(p).connect(this.output(e));const f=ms.OCTAVES.map(m=>{const g=e.createBiquadFilter();g.type="bandpass",g.frequency.value=m,g.Q.value=_U;const v=e.createGain();return v.gain.value=0,s.connect(g).connect(v).connect(u),v});return s.start(),h.start(),{sources:[s,h],nodes:[d,u,p,...f],bands:f,gain:p}}setAmbient(e,t,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const s=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=s==="hail"?Math.min(1,t*1.3+.2):s==="rain"?t:0,s!==this.ambientKey){this.ambientKey=s;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(xU,this.ambientVolume).then(a=>this.applyIfCurrent(a,r,()=>this.ambientToken,o=>{this.ambientSource=o?.source,this.ambientGain=o?.gain,o&&(o.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/SU,1);const n=i>AU;if(n!==this.windActive){this.windActive=n;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,n&&this.startLoop(EU,this.windVolume).then(a=>this.applyIfCurrent(a,r,()=>this.windToken,o=>{this.windSource=o?.source,this.windGain=o?.gain,o&&(o.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:s}=this.requested;this.setAmbient(t,i,s),this.applyAround()}playThunder(){!this.context||this.paused||this.playOneShot(FA,.9)}playDetonation(e){const t=this.context;if(!t||this.paused)return;const i=Math.min(1,Math.max(0,e)),s=t.createBufferSource();s.buffer=this.crackBuffer(t);const n=t.createBiquadFilter();n.type="lowpass",n.frequency.value=uh.CRACK_CUTOFF_HZ;const r=t.createGain();r.gain.value=i,s.connect(n).connect(r).connect(this.output(t)),s.start(),this.playOneShot(FA,i,uh.DETONATION_RATE)}static DETONATION_RATE=.8;static CRACK_CUTOFF_HZ=2500;static CRACK_DECAY_S=.25;crackBuffer(e){if(this.crack?.sampleRate===e.sampleRate)return this.crack;const t=Math.round(e.sampleRate*uh.CRACK_DECAY_S*6),i=e.createBuffer(1,t,e.sampleRate),s=i.getChannelData(0);for(let n=0;n<t;n++){const r=n/e.sampleRate;s[n]=(Math.random()*2-1)*Math.min(1,r/.005)*Math.exp(-r/uh.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;for(const e of this.around?.sources??[])try{e.stop()}catch{}for(const e of this.around?.nodes??[])e.disconnect();this.around=void 0,ta.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(e,t,i,s){if(t!==i()){e?.source.stop();return}s(e)}async startLoop(e,t){const i=this.context;if(i)try{const s=await this.getBuffer(e),n=i.createBufferSource();n.buffer=s,n.loop=!0;const r=i.createGain();return r.gain.value=t,n.connect(r).connect(this.output(i)),n.start(),{source:n,gain:r}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(e,t,i=1){const s=this.context;if(s)try{const n=await this.getBuffer(e),r=s.createBufferSource();r.buffer=n,r.playbackRate.value=i;const a=s.createGain();a.gain.value=t,r.connect(a).connect(this.output(s)),r.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class Bi{static BASE_DB_A=30;static OUTDOOR_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEADROOM_DB=10.5;static AROUND_BED_PLAYED=!1;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(e,t){const i=[Bi.BASE_DB_A,Bi.along(Bi.WIND_DB_A,e.windSpeed),Es.dbA(t)].filter(Number.isFinite);return(e.precipitationType==="rain"||e.precipitationType==="hail")&&i.push(Bi.along(Bi.RAIN_DB_A,e.precipitationIntensity)),10*Math.log10(i.filter(s=>s>0).reduce((s,n)=>s+10**(n/10),0))}static bedVolume(e){const t=e.windSpeed>Bi.WIND_BED_MIN_MS?Math.min(e.windSpeed/Bi.WIND_BED_FULL_MS,1):0,i=e.precipitationType==="hail"?Math.min(1,e.precipitationIntensity*1.3+.2):e.precipitationType==="rain"?e.precipitationIntensity:0;return Math.hypot(t,i)}static referenceAmplitude(e,t){return Math.max(Math.hypot(Bi.BED_RMS*Bi.bedVolume(e),Bi.aroundReference(t)),Bi.MINIMUM_REFERENCE)}static aroundReference(e){const t=Es.dbA(e);return!Number.isFinite(t)||t<=Bi.BASE_DB_A?0:Bi.MINIMUM_REFERENCE*10**((t-Bi.BASE_DB_A)/20)}static aroundBedRms(e){if(!Bi.AROUND_BED_PLAYED)return 0;const t=Es.dbA(e,!1);return!Number.isFinite(t)||t<=Bi.BASE_DB_A?0:Math.min(Bi.BED_RMS,Bi.MINIMUM_REFERENCE*10**((t-Bi.BASE_DB_A-Bi.HEADROOM_DB)/20))}static bedPlays(e,t){return Bi.bedVolume(e)>0||Bi.aroundBedRms(t)>0}static shapeDb(e,t){const i=10**(Bi.dbA(e,t)/10),s=Es.dbA(t,!1),n=Number.isFinite(s)?10**(s/10):0,r=Math.max(0,i-n),a=Bi.OUTDOOR_SHAPE_DB,o=10**(ms.sumDb(a)/10),h=Es.vehicleShape(t)?.map((f,m)=>f*f*10**(ms.aWeightingDb(ms.OCTAVES[m])/10)),d=h?.reduce((f,m)=>f+m,0)??1,u=ms.OCTAVES.map((f,m)=>r*10**(a[m]/10)/o+(h?n*h[m]/d:0)),p=u.reduce((f,m)=>f+m,0);return u.map(f=>10*Math.log10(f/p))}static aroundBedShape(e){return Es.vehicleShape(e)}static along(e,t){if(t<=e[0][0])return e[0][1];for(let i=1;i<e.length;i++)if(t<=e[i][0]){const[s,n]=e[i-1],[r,a]=e[i];return n+(a-n)*(t-s)/(r-s)}return e[e.length-1][1]}}class Yo{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[s,n]=this.perifocalAxes(),r=Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(s,i),this.perihelionVelocity=this.scale(n,r),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),s=this.inverseSemiMajorAxis*i*i,n=this.elements.perihelionAu,r=1-i*i/n*Yo.stumpffC(s),a=t-i*i*i/Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2)*Yo.stumpffS(s);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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(Yo.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=a=>{const o=this.inverseSemiMajorAxis*a*a,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*a*a*a*Yo.stumpffS(o)+c*a};let n=Math.max(1,i/this.elements.perihelionAu);for(;s(n)<i;)n*=2;let r=0;for(let a=0;a<Yo.MAX_ITERATIONS&&n-r>1e-13*Math.max(1,n);a++){const o=(r+n)/2;s(o)<i?r=o:n=o}return t*(r+n)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(e),n=Math.sin(e),r=Math.cos(t),a=Math.sin(t),o=Math.cos(i),c=Math.sin(i);return[{x:s*r-n*a*o,y:n*r+s*a*o,z:a*c},{x:-s*a-n*r*o,y:-n*a+s*r*o,z:r*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const n_=[{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 $0{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return n_.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,s)=>i.magnitude-s.magnitude)[0]}static appearanceOf(e,t,i){const s=Ci(t),n=this.earthPositionAt(s),r=this.apparentPositionOf(e,2451545+s.tt,n),a=this.subtract(r,n),o=this.length(r),c=this.length(a),h=this.tailEndAt(e,r,n,o,s,t,i),d=this.horizontalOf(a,s,t,i);return{apparition:e,position:d,...h,heliocentricDistanceAu:o,earthDistanceAu:c,elongationDeg:this.angleBetween(a,this.subtract({x:0,y:0,z:0},n)),magnitude:this.magnitudeAt(e,o,c)}}static magnitudeAt(e,t,i){const s=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(s,e.peakMagnitude)}static tailEndAt(e,t,i,s,n,r,a){if(e.tailLengthAu===void 0)return{};const o=1+e.tailLengthAu/s,c=this.subtract({x:t.x*o,y:t.y*o,z:t.z*o},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(c,n,r,a),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,i){const s=this.orbitOf(e);let n=s.positionAt(t);for(let r=0;r<2;r++){const a=this.length(this.subtract(n,i))/this.LIGHT_SPEED_AU_PER_DAY;n=s.positionAt(t-a)}return n}static horizontalOf(e,t,i,s){const n=uc(OD(),new jt(e.x,e.y,e.z,t)),r=uc(VT(t),n),a=Ny(t,new yl(s.lat,s.lng,s.elevationM),!0),o=new jt(r.x-a.x,r.y-a.y,r.z-a.z,t),c=sv(o);return mf(c.ra,c.dec,i,s)}static earthPositionAt(e){return uc(CD(),pl(ye.Earth,e))}static julianDayOf(e){return 2451545+Ci(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new Yo(e.orbit);return this.orbits.set(e.id,i),i}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const i=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const wy=[{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 Gg{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return wy.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),s=[];for(const n of wy){const r=this.magnitudeAt(n,i);r!==void 0&&s.push({outburst:n,position:ka.ofJ2000(n.raHours,n.decDeg,e,t),magnitude:r})}return s.sort((n,r)=>n.magnitude-r.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return wy.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,s=t-e.startJd;if(i.length===0||s<i[0][0]||s>i[i.length-1][0])return;let n=1;for(;n<i.length-1&&i[n][0]<s;)n++;const[r,a]=i[n-1]??i[0],[o,c]=i[n]??i[0];if(o===r)return a;const h=Math.min(1,Math.max(0,(s-r)/(o-r)));return a+h*(c-a)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const DU=[{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}],Tu=6.5;class cu{static activeAt(e){return DU.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),s=this.dayOfYear(this.asDate(e.start)),n=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),a=this.wrappedDelta(i,n),o=this.wrappedDelta(n,s),c=this.wrappedDelta(r,n);return a<0?a<-o?0:1+a/o:a>0?a>c?0:1-a/c:1}static observedRatePerHour(e,t,i,s=Tu){if(t<=0)return 0;const n=Tu-s;return e*Math.sin(t*Math.PI/180)/Math.pow(i,n)}static radiantPosition(e,t,i){return ka.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const i=e-t;return i>182?i-365:i<-182?i+365:i}}class ls{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Ci(e),s=new Qg(0,dD(e).elon-90,1),n=uc(UD(i),zw(s,i)),r=sv(n);return mf(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=Tu){const i=ls.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=Tu-t;return(ls.QUIET_RATE_PER_HOUR+i)/Math.pow(ls.POPULATION_INDEX,s)}static schedule(e){const t=new bv(e.seed^1542469173);return pa.schedule(e).map(i=>{const s=ls.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),n=i.fromRadiantDeg*Math.PI/180,r=ls.turnAround(s,t.between(0,360)),a={x:s.x*Math.cos(n)+r.x*Math.sin(n),y:s.y*Math.cos(n)+r.y*Math.sin(n),z:s.z*Math.cos(n)+r.z*Math.sin(n)};return{...i,radiant:ls.toHorizontal(a),bearingDeg:ls.bearingFrom(a,s)}})}static turnAround(e,t){const[i,s]=ls.basisAround(e),n=t*Math.PI/180;return{x:i.x*Math.cos(n)+s.x*Math.sin(n),y:i.y*Math.cos(n)+s.y*Math.sin(n),z:i.z*Math.cos(n)+s.z*Math.sin(n)}}static bearingFrom(e,t){const[i,s]=ls.basisAround(e),n=e.x*t.x+e.y*t.y+e.z*t.z,r=ls.normalise({x:t.x-e.x*n,y:t.y-e.y*n,z:t.z-e.z*n});return(Math.atan2(r.x*s.x+r.y*s.y+r.z*s.z,r.x*i.x+r.y*i.y+r.z*i.z)*180/Math.PI%360+360)%360}static basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ls.normalise(ls.cross(e,t));return[i,ls.normalise(ls.cross(e,i))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=ls.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ls.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return ls.toHorizontal({x:t.x*Math.cos(s)+i.x*Math.sin(s),y:t.y*Math.cos(s)+i.y*Math.sin(s),z:t.z*Math.cos(s)+i.z*Math.sin(s)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,s=Math.cos(t);return{x:s*Math.sin(i),y:Math.sin(t),z:-s*Math.cos(i)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}const HA="https://ufoathome.org/tle/index.json";class Hn{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Hn.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(HA)||e.push(HA),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Hn.FIRST_SNAPSHOT}T00:00:00Z`)-Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(s=>e.getTime()>=Date.parse(s.from)-Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS&&e.getTime()<=Date.parse(s.to)+Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:s}=t,n=[],r=[];for(const a of Object.keys(i.kinds)){const o=await this.kindAt(a,e,i,s);n.push(...o),r.push(this.coverageOf(a,e,i,o.length>0))}return{objects:n,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,s){const n=t.getTime(),r=i.binDays*Hn.DAY_MS,a=Math.floor(n/r),o=n-a*r<r/2?a-1:a+1,c=new Set(i.kinds[e].bins),h=[a,o].map(m=>new Date(m*r).toISOString().slice(0,10)).filter(m=>c.has(m));if(h.length===0)return[];const[d,...u]=await Promise.all([this.json(new URL(`objects-${e}.json`,s).href),...h.map(m=>this.binary(new URL(`${e}/${m}.bin`,s).href))]),p=new Map;for(const m of u)for(const g of Hn.decode(m,i.recordBytes)){const v=p.get(g.norad);(!v||Math.abs(g.epochMs-n)<Math.abs(v.epochMs-n))&&p.set(g.norad,g)}const f=[];for(const m of p.values()){const g=Math.abs(m.epochMs-n)/Hn.DAY_MS;if(g>Hn.MAX_ELEMENT_AGE_DAYS)continue;const v=d[m.norad]??{name:String(m.norad)};v.launch&&Date.parse(`${v.launch}T00:00:00Z`)>n||f.push({norad:m.norad,name:v.name,kind:e,launch:v.launch,stdMag:v.stdMag,elements:m,ageDays:g})}return f}coverageOf(e,t,i,s){const{from:n,to:r}=i.kinds[e],a=t.getTime(),o=Hn.MAX_ELEMENT_AGE_DAYS*Hn.DAY_MS,c=s?"covered":a<Date.parse(n)-o?"before":a>Date.parse(r)+o?"after":"gap";return{kind:e,status:c,from:n,to:r}}static decode(e,t){const i=new DataView(e),s=[];for(let n=0;n+t<=e.byteLength;n+=t)s.push({norad:i.getUint32(n,!0),epochMs:i.getFloat64(n+4,!0),bstar:i.getFloat32(n+12,!0),inclinationDeg:i.getFloat32(n+16,!0),raanDeg:i.getFloat32(n+20,!0),eccentricity:i.getFloat32(n+24,!0),argOfPerigeeDeg:i.getFloat32(n+28,!0),meanAnomalyDeg:i.getFloat32(n+32,!0),meanMotion:i.getFloat64(n+36,!0)});return s}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(s=>{if(!s.ok)throw new Error(`${e}: ${s.status}`);return t(s)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class kU{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=Ft.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=Ft.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:Ft.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Ft.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Mh{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Mh.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=Mh.degOver(e)/t;return i<1?1:Math.min(Mh.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class bn{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 Mh.DEG_PER_SECOND*3600}static graspOf(e,t={}){if(e.visualAid)return bn.visualAidGrasp(e,t.focalLengthMm);const i=t.exposureSeconds??e.exposureSeconds,s=t.fNumber??e.fNumber;if(i===void 0||s===void 0||!(i>0)||!(s>0))return bn.EYE;const n=t.focalLengthMm??e.frame?.focalLengthMm??bn.UNKNOWN_CAMERA_FOCAL_MM,r=n/s,a=bn.resolutionArcsec(e,n,r);return{apertureMm:r,exposureSeconds:Math.min(i,bn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(e,t){const i=e.visualAid,s=bn.EYE,n=t??e.frame?.focalLengthMm,r=i.magnification??(n!==void 0&&i.eyepieceFocalMm?n/i.eyepieceFocalMm:1),a=Math.min(i.apertureMm,s.apertureMm*r);return{apertureMm:Math.max(a,s.apertureMm),exposureSeconds:s.exposureSeconds,resolutionArcsec:s.resolutionArcsec/Math.max(1,Math.min(r,i.apertureMm/s.apertureMm))}}static resolutionArcsec(e,t,i){const n=(e.detailUm??bn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*bn.ARCSEC_PER_RADIAN,r=1.22*bn.WAVELENGTH_M/(i/1e3)*bn.ARCSEC_PER_RADIAN;return Math.max(n,r)}static trailLimitedSeconds(e){return e/bn.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=bn.graspOf(e,t),s=bn.EYE,n=(i.apertureMm/s.apertureMm)**2,r=i.exposureSeconds/s.exposureSeconds,a=(s.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(n*r*a)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:Vt.focalLengthMmFor(e,t.fieldOfViewDeg);return bn.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const GA=111320,hp=Math.PI/180,RU=1.02,CU=1;class Vp{static of(e,t){const i=Vp.sightings(e,t);if(i.length<2)return;const s=Vp.baseline(i);if(!s)return;const{near:n,far:r,closedM:a}=s,o=Math.tan(r.widthDeg/2*hp)===0?0:Math.tan(n.widthDeg/2*hp)/Math.tan(r.widthDeg/2*hp);if(o<RU)return;const c=a/(o-1),h=Ft.sizeMAt(c,n.widthDeg),d=i.map(u=>({t:u.t,m:Ft.distanceMAt(h,u.widthDeg)}));return{widthM:h,distanceM:d,nearestM:Math.min(...d.map(u=>u.m)),fromT:r.t,toT:n.t,closedM:a}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const s=i.shapes.find(a=>a.sourceId===t)?.shape,n=s?.angular?.widthDeg,r=et(e,i.t);return n===void 0||n<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:n,lat:r.lat,lng:r.lng,sightAzimuthDeg:s?.aim?.azimuthDeg??r.headingDeg}]}).sort((i,s)=>i.t-s.t)}static baseline(e){let t;for(const i of e)for(const s of e){if(i.t>=s.t)continue;const n=Vp.closedAlongSight(i,s),[r,a,o]=n>=0?[s,i,n]:[i,s,-n];o<CU||r.widthDeg<=a.widthDeg||(!t||o>t.closedM)&&(t={near:r,far:a,closedM:o})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*GA,s=(t.lng-e.lng)*GA*Math.cos(e.lat*hp),n=(e.sightAzimuthDeg??0)*hp;return i*Math.cos(n)+s*Math.sin(n)}}class cr{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:cr.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:cr.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:cr.atLeastNearest(e.derivedM),basis:"derived"};const t=cr.largest(e.range?.minM,e.crossing?.behindM),i=cr.smallest(e.range?.maxM,e.crossing?.inFrontM),s=t===void 0?void 0:t*cr.MARGIN,n=i===void 0?void 0:i/cr.MARGIN;return s!==void 0&&n!==void 0?{distanceM:cr.atLeastNearest(s<=n?Math.sqrt(s*n):s),basis:"bounded"}:s!==void 0?{distanceM:cr.atLeastNearest(s),basis:"bounded"}:n!==void 0&&n<cr.CONVENTIONAL_M?{distanceM:cr.atLeastNearest(n),basis:"bounded"}:{distanceM:cr.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(cr.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}class hc{static typed=new Map;static of(e){return hc.typed.get(e)}static set(e,t){const i=t.trim();i===""?hc.typed.delete(e):hc.typed.set(e,i)}static forget(){hc.typed.clear()}}class OM{static FIRST_DAY="2022-01-01";static mayCover(e){return new Date(e).toISOString().slice(0,10)>=OM.FIRST_DAY}}class VA{constructor(e,t,i){this.citation=e,this.covers=t,this.load=i}loading;mayCover(e){return this.covers(e)}async between(e,t,i,s){try{return await(await this.provider()).between(e,t,i,s)}catch{return{status:"failed"}}}async describe(e,t){try{return await(await this.provider()).describe?.(e,t)}catch{return}}provider(){if(!this.loading){const e=this.load();this.loading=e,e.catch(()=>{this.loading===e&&(this.loading=void 0)})}return this.loading}}const OU="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",LU="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",WA="flightradar24",Mw=Xe.point("aircraft").provide(Xe.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 VA(OU,l=>OM.mayCover(l),async()=>new(await V(async()=>{const{AdsbLolArchiveProvider:l}=await import("./AdsbLolArchiveProvider-BrZzIuec.js");return{AdsbLolArchiveProvider:l}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:WA,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new VA(LU,l=>l>=Date.UTC(2016,4,11)&&l<=Date.now(),async()=>new(await V(async()=>{const{Flightradar24Provider:l}=await import("./Flightradar24Provider-DUVcPAF2.js");return{Flightradar24Provider:l}},[],import.meta.url)).Flightradar24Provider({token:()=>hc.of(WA)}))}]);class wn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(e,t,i){const s=wn.positionAt(e,i);if(!s)return;const n=Ce.seenFrom(t,s.geo);if(!(n.altitudeDeg<0))return{track:e,sky:n,altitudeFt:s.altitudeFt,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg,angularRateDegPerS:wn.angularRate(e,t,i)}}static viewsAt(e,t,i){return e.flatMap(s=>wn.seenFrom(s,t,i)??[])}static groundDistanceKm(e,t){const i=Math.PI/180,s=Math.sin((t.lat-e.lat)*i/2)**2+Math.cos(e.lat*i)*Math.cos(t.lat*i)*Math.sin((t.lng-e.lng)*i/2)**2;return 2*wn.EARTH_RADIUS_KM*Math.asin(Math.min(1,Math.sqrt(s)))}static wrapLongitude(e){return((e+180)%360+360)%360-180}static positionAt(e,t){const i=e.points;if(i.length===0||t<i[0].t||t>i[i.length-1].t)return;let s=0;for(;s<i.length-1&&i[s+1].t<=t;)s++;const n=i[s],r=i[s+1]??n,a=r.t-n.t;if(a>wn.MAX_GAP_S*1e3)return;const o=a>0?(t-n.t)/a:0,c=n.altitudeFt+(r.altitudeFt-n.altitudeFt)*o,h=(r.lng-n.lng+540)%360-180;return{geo:{lat:n.lat+(r.lat-n.lat)*o,lng:wn.wrapLongitude(n.lng+h*o),heightM:c*wn.FT_TO_M},altitudeFt:c,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg}}static angularRate(e,t,i){const s=wn.positionAt(e,i-500),n=wn.positionAt(e,i+500);if(!s||!n)return;const r=wn.unit(Ce.seenFrom(t,s.geo)),a=wn.unit(Ce.seenFrom(t,n.geo)),o=Math.min(1,Math.max(-1,r[0]*a[0]+r[1]*a[1]+r[2]*a[2]));return Math.acos(o)*180/Math.PI}static unit(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180;return[Math.cos(t)*Math.sin(i),Math.cos(t)*Math.cos(i),Math.sin(t)]}}class vn{constructor(e){this.boxes=e;for(const i of e){const s=Math.hypot(i.halfWidthM,i.halfLengthM),[n,r]=[vn.cell(i.eastM-s),vn.cell(i.eastM+s)],[a,o]=[vn.cell(i.northM-s),vn.cell(i.northM+s)];for(let c=n;c<=r;c++)for(let h=a;h<=o;h++){const d=vn.key(c,h),u=this.cells.get(d);u?u.push(i):this.cells.set(d,[i])}}let t=2166136261;for(const i of e)for(const s of[i.eastM,i.northM,i.cos,i.halfWidthM,i.halfLengthM,i.topM])t=Math.imul(t^Math.round(s*10),16777619);this.signature=e.length===0?"":`${e.length}:${(t>>>0).toString(36)}`}static NONE=new vn([]);static SOLID=new Set(["building","tree","wall","mound","terrace","shrub"]);static CELL_M=16;static last;signature;cells=new Map;static of(e,t){const i=[];for(const n of e){if(!vn.SOLID.has(n.kind)||(n.track?.length??0)>0)continue;const r=t(n);if(!(r.heightM>0)||!(r.widthM>0)||!(r.lengthM>0))continue;const a=(n.headingDeg??0)*Math.PI/180;i.push({eastM:n.eastM,northM:n.northM,cos:Math.cos(a),sin:Math.sin(a),halfWidthM:r.widthM/2,halfLengthM:r.lengthM/2,topM:r.heightM})}const s=new vn(i);return vn.last?.signature===s.signature?vn.last.obstacles:(vn.last={signature:s.signature,obstacles:s},s)}get empty(){return this.boxes.length===0}inside(e,t,i,s=0){const n=this.cells.get(vn.key(vn.cell(e),vn.cell(t)));if(n)for(const r of n){if(i>r.topM+s)continue;const a=e-r.eastM,o=t-r.northM,c=a*r.sin+o*r.cos,h=a*r.cos-o*r.sin,d=r.halfLengthM+s-Math.abs(c),u=r.halfWidthM+s-Math.abs(h);if(d<=0||u<=0)continue;const p=r.topM+s-i;if(d<u){const m=Math.sign(c)||1;return{box:r,nx:r.sin*m,ny:r.cos*m,depthM:d,belowTopM:p}}const f=Math.sign(h)||1;return{box:r,nx:r.cos*f,ny:-r.sin*f,depthM:u,belowTopM:p}}}static cell(e){return Math.floor(e/vn.CELL_M)}static key(e,t){return(e+32768)*65536+(t+32768)}}const $A="https://ufoathome.org/fireballs/index.json";class fa{static FIRST_MONTH="2018-12";static STRIKING_MAGNITUDE=-1;static COLOR="#eef2ff";static TRAIN_S=.3;fetchImpl;indexUrls;index;months=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??fa.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/fireballs/index.json",location.href).href),e.includes($A)||e.push($A),e}static mayCover(e){return new Date(e).toISOString().slice(0,7)>=fa.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(e,t){if(!fa.mayCover(t))return;const i=await this.loadIndex();if(!i)return;const s=new Set([new Date(e).toISOString().slice(0,7),new Date(t).toISOString().slice(0,7)]);return[...s].some(r=>r>=i.index.from&&r<=i.index.to)?(await Promise.all([...s].filter(r=>i.index.months.includes(r)).map(r=>this.monthOf(r,i.base)))).flat().filter(r=>r.t>=e&&r.t<=t):void 0}static seenFrom(e,t){const i=fa.peakFraction(e),s={lat:e.from[0]+(e.to[0]-e.from[0])*i,lng:e.from[1]+(e.to[1]-e.from[1])*i,heightM:e.peakHeightKm*1e3},n=Ce.seenFrom(t,s);if(!(n.altitudeDeg<0))return{record:e,peak:n,magnitude:e.peakMagnitude+5*Math.log10(n.distanceKm/Ce.STANDARD_DISTANCE_KM)}}static asReentry(e,t){const i=e.t-t,s=i+Math.max(e.durationS,.1)*1e3;return{id:`gmn-${e.id}`,track:[{t:i,lat:e.from[0],lng:e.from[1],altitudeKm:e.from[2]},{t:s,lat:e.to[0],lng:e.to[1],altitudeKm:e.to[2]}],fragments:[{absoluteMagnitude:e.peakMagnitude,color:fa.COLOR,trainS:fa.TRAIN_S}]}}static peakFraction(e){const t=e.from[2]-e.to[2];return Math.abs(t)<1e-6?.5:Math.min(1,Math.max(0,(e.from[2]-e.peakHeightKm)/t))}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(t.ok)return{index:await t.json(),base:e}}catch{}})(),this.index}monthOf(e,t){let i=this.months.get(e);return i||(i=this.fetchImpl(new URL(`${e}.json`,t).href).then(s=>s.ok?s.json():[]).catch(()=>[]),this.months.set(e,i)),i}}gv();const LM="satellites-change",PM="fireballs-change",NM="references-change",FM="aircraft-change",r_="rr0-confrontation",KA="comet:",XA="nova:",PU=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,NU=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,FU=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,UU=-18,BU={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},y0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class At extends HTMLElement{creditsButton;set ownCredits(e){this.creditsButton.hidden=!e}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",tu,iu,ah]}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 I;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationTolerance;confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Hn;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new fa;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=Mw[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return At.trafficRuntimeLoading??=V(()=>import("./trafficRuntime-DwnTE9-7.js"),__vite__mapDeps([24,21]),import.meta.url).then(e=>At.trafficRuntime=e),At.trafficRuntimeLoading.catch(()=>{At.trafficRuntimeLoading=void 0}),At.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new uh;vehicleAudio=new v2;aircraftAudio;vehicleHearing=new Sg;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;decorModelsAsked=new Set;thunderTimeoutId;handleFullscreenChange=()=>{this.resizeToStage(),this.hoverTooltip.hidden=!0;for(const e of[this.hoverTooltip,this.shadow.getElementById("credits-panel")])e&&typeof e.hidePopover=="function"&&e.matches(":popover-open")&&e.hidePopover();this.tooltipOver=document.fullscreenElement};handlePointerMove=e=>{if(this.lastHover={clientX:e.clientX,clientY:e.clientY,altKey:e.altKey},this.ghostMissedSinceMs=void 0,this.hoverFrame!==void 0&&e.altKey===this.hoverAlt){this.hoverPending=!0;return}this.hoverAlt=e.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(e,t){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return!0;const s=(e.clientX-i.left)/i.width*2-1,n=1-(e.clientY-i.top)/i.height*2;return this.sceneRenderer.ghostsReadableAt(s,n)?this.sceneRenderer.pickGhostAt(s,n)?(this.ghostMissedSinceMs=void 0,!0):(this.ghostMissedSinceMs??=t,t-this.ghostMissedSinceMs>At.GHOST_KEPT_MS):!1}hoverFrame;hoverPending=!1;hoverAlt=!1;lastPlayingHoverMs=0;static PLAYING_HOVER_MS=150;lastHover;tooltipOver=null;hoverAt(e){if(this.showCompassFor({hovered:!0}),this.holding){this.hoverTooltip.hidden=!0;return}const t=this.ufoElement.canvasElement,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const s=(e.clientX-i.left)/i.width*t.width,n=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(s,n)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-i.left)/i.width*2-1,a=-((e.clientY-i.top)/i.height*2-1);if(!this.ghostPath.hasAttribute("hidden")&&!this.sceneRenderer.ghostsReadableAt(r,a))return;const o=this.pickAt(r,a,!0,e.altKey);o?this.showHoverTooltip(e,e.altKey&&o.detail?o.detail():o.name):this.hoverTooltip.hidden=!0,this.showGhostPath(o?.path,i)}showGhostPath(e,t){if(!e){this.ghostPath.toggleAttribute("hidden",!0);return}const i=this.stageElement.getBoundingClientRect(),s=u=>({x:t.left-i.left+(u.x+1)/2*t.width,y:t.top-i.top+(1-u.y)/2*t.height}),n=s(e.from),r=s(e.to),a=s({x:0,y:0});this.ghostPath.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);const[o,c,h,d]=Array.from(this.ghostPath.children);for(const u of[o,c])u.setAttribute("x1",String(n.x)),u.setAttribute("y1",String(n.y)),u.setAttribute("x2",String(r.x)),u.setAttribute("y2",String(r.y));h.setAttribute("cx",String(a.x)),h.setAttribute("cy",String(a.y)),d.setAttribute("cx",String(r.x)),d.setAttribute("cy",String(r.y)),this.ghostPath.toggleAttribute("hidden",!1)}pickAt(e,t,i=!0,s=!1){const n=this.naming,r=n.names;if(s&&this.sceneRenderer.pickDropAt(e,t)){const x=r.ghostTooltip,S=x.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:S,detail:()=>x.dropDetail.replace("{name}",S)}}const a=this.sceneRenderer.pickBodyAt(e,t);if(a)return{kind:"sky",id:a,name:this.bodyName(a)};const o=this.interpretationShown?this.sceneRenderer.pickInterpretationBodyAt(e,t):void 0,c=o?this.interpretationShown?.bodies.find(x=>x.id===o):void 0,h=c?this.said.read(c.title)||this.explainedName(c.explains)||this.kindName(c):void 0;if(o!==void 0&&h)return{kind:"body",id:o,name:h};const d=this.skyEventPickAt(e,t,(x,S)=>!S.inSky);if(d)return d;const u=i?this.ghostPick(e,t):void 0;if(u)return u;if(this.sceneRenderer.pickAfterimageAt(e,t)){const x=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:x.name,detail:()=>x.detail.replace("{name}",x.name)}}const p=this.pickDecorAt(e,t)??this.sceneRenderer.pickPeakAt(e,t),f=p?this.ufoElement.sighting.decor.find(x=>x.id===p):void 0;if(f){const x=this.said.read(f.title)||n.decorKind(f.kind);return{kind:"decor",id:f.id,name:x,detail:()=>this.decorTooltip(f,x)}}const m=this.sceneRenderer.pickRailwayAt(e,t);if(m){const x=r.railwayTooltip;return{kind:"railway",id:m.line.id,name:co.name(m.line,x),detail:()=>co.detail(m,x,S=>this.distanceText(S))}}const g=this.trafficTooltipAt(e,t);if(g)return{kind:"traffic",name:g};const v=this.skyEventPickAt(e,t,(x,S)=>S.inSky===!0&&!x.pickedAfterSatellites);if(v)return v;const b=this.sceneRenderer.pickSatelliteAt(e,t);if(b)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",b.name).replace("{mag}",b.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(b.heightKm).toLocaleString())};const w=this.skyEventPickAt(e,t,(x,S)=>S.inSky===!0&&x.pickedAfterSatellites===!0);if(w)return w;const y=this.sceneRenderer.pickOpticsAt(e,t);if(y){const x=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:x.split(" — ")[0],detail:()=>x}}const M=this.sceneRenderer.pickStarAt(e,t);if(M){const x=M.star.mag,S=M.altitudeDeg,E=S<0?r.starTooltipBelow:r.starTooltip,A=n.star(M.star);return{kind:"star",name:A,detail:()=>E.replace("{name}",A).replace("{mag}",x.toLocaleString(void 0,{maximumFractionDigits:Math.abs(x)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(S))))}}}ghostLights=new Map;static GHOST_LIGHT_KEPT_MS=1e3;lightOfGhost(e,t){const i=this.ufoElement.canvasElement,s={x:8/Math.max(1,i.clientWidth),y:8/Math.max(1,i.clientHeight)},n=`${Math.round(e/s.x)}:${Math.round(t/s.y)}`,r=performance.now(),a=this.ghostLights.get(n);if(a&&r-a.atMs<At.GHOST_LIGHT_KEPT_MS)return a.light;let o=this.shiningDecorNear(e,t,2*Math.max(s.x,s.y)),c;if(!o)for(const[h,d]of[[0,0],[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){const u=this.pickAt(e+h*s.x,t+d*s.y,!1);if(u?.kind==="star")c??=u;else if(u){o=u;break}}return o??=this.shiningDecorNear(e,t,6*Math.max(s.x,s.y)),o??=c,this.ghostLights.size>256&&this.ghostLights.clear(),this.ghostLights.set(n,{light:o??null,atMs:r}),o??null}ghostPick(e,t){const i=this.sceneRenderer.pickGhostAt(e,t);if(!i)return;const s=this.naming.names.ghostTooltip,n=i.beyond?{kind:"sky",id:"sun",name:this.bodyName("sun")}:this.lightOfGhost(i.source.x,i.source.y)??void 0,r=(n?.kind==="star"?n.name.split(" — ")[0]:n?.name)??s.unnamed,a=i.ghost,c=(zt.scatters(a)?s.halo:a.cause==="glass"?s.double:s.ghost).replace("{name}",r),h=a.scale<0?s.opposite:a.scale===1?s.around:s.sameSide;return{kind:"ghost",id:n?.id,name:c,detail:()=>s.detail.replace("{name}",c).replace("{cause}",s.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(e,t,i){let s;for(const n of this.ufoElement.sighting.decor){if(!(n.kind==="streetlight"||n.kind==="trafficlight"||(n.lights?.length??0)>0||n.kind==="vehicle"&&n.lit))continue;const a=this.sceneRenderer.decorScreenBox(n.id);if(!a)continue;const o=Math.hypot(Math.max(a.minX-e,0,e-a.maxX),Math.max(a.minY-t,0,t-a.maxY));if(o>i||s&&o>=s.distance)continue;const c=this.said.read(n.title)||this.naming.decorKind(n.kind);s={distance:o,pick:{kind:"decor",id:n.id,name:c}}}return s?.pick}glassWettingOf(e){const t=JSON.stringify([e.lens,e.instrumentId,e.weatherTrack.allKeyframes.map(i=>[i.t,i.weather.precipitationType,i.weather.precipitationIntensity,i.weather.windDirectionDeg,i.weather.windSpeed])]);if(this.glassWetting?.sighting!==e||this.glassWetting.key!==t){const i=new rh(s=>{if(!zt.records(e.instrument)||!zt.falling(e.lens))return 0;const n=Lu(e,s*1e3),r=et(e,s*1e3);return(n.precipitationAmount??1)*zt.impactRate(n,e.lens?.glass,r&&{headingDeg:r.headingDeg??0,pitchDeg:r.pitchDeg,windFromDeg:n.windDirectionDeg,windSpeedMS:n.windSpeed})});this.glassWetting={sighting:e,key:t,wetting:i}}return this.glassWetting.wetting}glassWetting;get skyEventsShown(){return this.skyEventsOf(this.ufoElement.sighting)}skyEventsStartDate;skyEventsMerged;skyEventsOf(e){const t=e.skyEvents,i=this.fireballs?.reentries,s=this.skyEventsMerged;if(s&&s.stated===t&&s.fireballs===i)return s.shown;const n=i?.length?{...t,reentries:[...t?.reentries??[],...i]}:t;return this.skyEventsMerged={stated:t,fireballs:i,shown:n},n}skyEventTexts=new Map;skyEventTextsLanguage;loadSkyEventTexts(e){const t=Ha(Us.preferencesFor(this),Ba);t!==this.skyEventTextsLanguage&&(this.skyEventTexts.clear(),this.skyEventTextsLanguage=t);for(const i of e)this.skyEventTexts.has(i)||i.messages.load(t).then(s=>{this.skyEventTextsLanguage===t&&this.skyEventTexts.set(i,s)},()=>{})}skyEventPickAt(e,t,i){const s=this.skyEventsShown;if(!s)return;const n=this.sceneRenderer.pickSkyEventAt(e,t,i),r=n?Of.map(u=>ea.of(u)).find(u=>u.key===n.kind):void 0,a=n&&r?ea.eventsOf(s,r).find(u=>u.id===n.id):void 0;if(!n||!r||!a)return;const o=this.skyEventTexts.get(r);if(!o){this.loadSkyEventTexts([r]);return}const c=this.said.read(a.title)||o.name,h=r.describe?.(a,n,{said:this.said,texts:o,name:c,distance:u=>this.distanceText(u)}),d=h?.detail??(n.distanceM!==void 0?`${c}, ${this.distanceText(n.distanceM)}`:void 0);return{kind:r.pickKind??"skyEvent",id:a.id,name:h?.name??c,...d!==void 0?{detail:()=>d}:{}}}distanceText(e){return e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} km`:`${e.toLocaleString(void 0,{maximumFractionDigits:e<10?1:0})} m`}decorTooltip(e,t){const i=h=>h.toLocaleString(void 0,{maximumFractionDigits:h<10?1:0}),s=pe.sizeOf(e),n=this.sceneRenderer.decorDistanceM(e.id),r=n===void 0?"":this.distanceText(n),o=this.naming.names.decorTooltip.replace("{name}",t).replace("{size}",`${i(s.widthM)} × ${i(s.lengthM)} × ${i(s.heightM)} m`),c=this.said.read(e.note);return c?`${o.replace("{distance}",r)}. ${c}`:o.replace("{distance}",r)}computedKinds=new Map;computedKindTexts=new Map;bodyModelKinds=new Map;showInterpretation(e){const t=dc.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:s,kindOf:n}=hi.expandWithKinds(e,t,{obstacles:i});if(this.interpretationAsked=e,this.interpretationShown=s,this.computedKinds=n,this.loadComputedKindTexts(),hi.loaded(e,t))return;const r=hi.load(e,t);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==e||!hi.loaded(e,t)||(this.showInterpretation(e),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=vn.NONE;obstaclesMadeOf;obstaclesOf(e){return this.obstaclesMadeOf?.decor!==e&&(this.obstaclesMadeOf={decor:e,obstacles:vn.of(e,t=>pe.sizeOf(t))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const e=this.interpretationAsked;!e||!hi.computes(e,dc.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(e),this.ufoElement.refreshSoundControls())}computedInterpretation(e){const t=dc.kinds(),i=hi.loaded(e,t)?Promise.resolve():hi.load(e,t),{interpretation:s,phenomenonOf:n}=hi.expandWithKinds(e,t,{obstacles:this.obstaclesOf(this.ufoElement.sighting.decor)});return{interpretation:s??e,phenomenonOf:n,loaded:i}}loadComputedKindTexts(){const e=this.namesLanguage;if(e)for(const t of new Set(this.computedKinds.values()))this.computedKindTexts.has(t)||t.messages.load(e).then(i=>{e===this.namesLanguage&&this.computedKindTexts.set(t,i)}).catch(()=>{})}kindName(e){const t=this.computedKinds.get(e.id),i=t?this.computedKindTexts.get(t):void 0;if(i?.name)return i.name;const s=e.model.id;if(s==="figure")return this.naming.decorKind("entity");if(!s||e.model.url!==void 0)return;if(!this.bodyModelKinds.has(s)){this.bodyModelKinds.set(s,void 0),this.sceneRenderer.entryOfDecorModel(s).then(r=>this.bodyModelKinds.set(s,[r?.kind].flat()[0])).catch(()=>{});return}const n=this.bodyModelKinds.get(s);return n&&this.naming.decorKind(n)||void 0}explainedName(e){if(!e?.length)return;const t=this.ufoElement.sighting.timeline.allKeyframes,i=e.map(s=>{for(const n of t){const r=this.said.read(n.shapes.find(a=>a.sourceId===s)?.shape.title);if(r)return r}}).filter(s=>!!s);return i.length?i.join(", "):void 0}bodyName(e){const t=e.startsWith(KA)?e.slice(KA.length):void 0,i=t?n_.find(n=>n.id===t):void 0;if(i)return this.naming.comet(i);const s=e.startsWith(XA)?Gg.byId(e.slice(XA.length)):void 0;return s?this.naming.nova(s):this.naming.body(e)}get naming(){return this.sceneNaming}sceneNaming=new Hg;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const e=Ha(Us.preferencesFor(this),Ba);if(e===this.namesLanguage)return;this.namesLanguage=e;const t=await fT(e);e===this.namesLanguage&&(this.applySceneNaming(new Hg(t)),this.computedKindTexts.clear(),this.loadComputedKindTexts())}setBusy(e,t=""){this.busyElement.hidden=!e,this.busyNote.textContent=e?t:"",this.busyElement.setAttribute("aria-label",t),this.busyElement.setAttribute("aria-busy",String(e))}renderLoaderText(e,t){let i=0;const s=(n,r)=>{n.setAttribute("aria-label",r),n.replaceChildren(),r.split(" ").forEach((a,o)=>{o>0&&n.append(" ");const c=document.createElement("span");c.className="scene-loader-word",c.setAttribute("aria-hidden","true");for(const h of a){const d=document.createElement("span");d.className="scene-loader-letter",d.style.setProperty("--i",String(i++)),d.textContent=h,c.append(d)}n.append(c),i++})};s(this.loaderNotVideo,e),i+=6,s(this.loaderNote,t)}applySceneNaming(e){this.sceneNaming=e,e.loaded&&(this.creditsButton.title=e.names.credits,this.creditsButton.setAttribute("aria-label",e.names.credits),this.renderLoaderText(e.names.notAVideo,e.names.isASimulation),this.sceneRenderer.setCompassPoints(e.names.compassPoints))}showHoverTooltip(e,t){const i=this.hoverTooltip;if(i.textContent=t,i.hidden=!1,typeof i.showPopover=="function"){const d=document.fullscreenElement;i.matches(":popover-open")&&d!==this.tooltipOver&&i.hidePopover(),i.matches(":popover-open")||i.showPopover(),this.tooltipOver=d}const{innerWidth:s,innerHeight:n}=window,r=12,a=4,o=Math.min(e.clientX+r,s-i.offsetWidth-a),c=e.clientY+r,h=c+i.offsetHeight+a>n?e.clientY-r-i.offsetHeight:c;i.style.left=`${Math.max(a,o)}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(e,t,i,s){const n=`${i.lat.toFixed(4)},${i.lng.toFixed(4)}`,r=this.detonationsFor;(!r||n!==r.key||e.length!==r.reentries.length||e.some((c,h)=>c!==r.reentries[h]))&&(this.detonationsFor={reentries:[...e],key:n,detonations:e.length?Ce.detonationsOf(e,i):[]});const a=this.detonationsFor.detonations;if(s)return;const o=this.lastDetonationT;if(this.lastDetonationT=t,!(o===void 0||t<o||t-o>At.DETONATION_JUMP_MS||this.ufoElement.playbackState!=="playing"))for(const c of a)c.t>o&&c.t<=t&&this.weatherAudio.playDetonation(c.loudness)}detonates(e){const t=[...e.skyEvents?.reentries??[],...this.fireballs?.reentries??[]],i=et(e,0),s=e.event.place?.[0],n=i?.lat??s?.lat,r=i?.lng??s?.lng;return t.length>0&&n!==void 0&&r!==void 0&&Ce.detonationsOf(t,{lat:n,lng:r,heightM:this.altitudeOf(i)}).length>0}detonationsFor;lastDetonationT;static DETONATION_JUMP_MS=2e3;handleLightningFlash(e){if(clearTimeout(this.thunderTimeoutId),this.filmSound){this.filmThunderAtMs=this.lastTimeMs+Ks.thunderDelayMs(e)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),Ks.thunderDelayMs(e))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(Lu(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;applyLevel(){if(this.filmSound)return;const e=this.ufoElement.level;this.weatherAudio.setLevel(e),this.vehicleAudio.setLevel(e),this.aircraftAudio?.setLevel(e)}handlePageGesture=()=>{this.ufoElement.playbackState==="playing"&&this.handleFirstInteraction()};unlockIfAlreadyActivated(){this.interacted||navigator.userActivation?.hasBeenActive&&this.handleFirstInteraction()}static GESTURES=["pointerdown","pointerup","touchend","click","keydown"];handleTimeUpdate=e=>{if(this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"){this.sceneRenderer.frame(performance.now());const t=performance.now();this.lastHover&&!this.ghostPath.hasAttribute("hidden")&&t-this.lastPlayingHoverMs>=At.PLAYING_HOVER_MS&&(this.lastPlayingHoverMs=t,this.ghostStillUnder(this.lastHover,t)&&this.hoverAt(this.lastHover))}this.placeFlightMark(),this.ufoElement.repaintChrome()};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.filming;this.sceneRenderer.setAnimationsRunning(t,t);const i=e||this.filmSound!==void 0;this.weatherAudio.setPaused(!i),this.vehicleAudio.setPaused(!i),this.aircraftAudio?.setPaused(!i),e&&this.unlockIfAlreadyActivated(),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${G8}</style>${H8}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new he(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(NM));const t=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=t,this.poster=new Gp(this.shadow.getElementById("scene-poster"),()=>{this.loader.style.animationDelay=!this.poster.up&&this.holding?"0s":"",this.applyHold()}),this.sceneRenderer.onFirstFrameHold=n=>{this.holding=n,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(Y1),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.ufoElement.observerMapSnapshotSource=n=>this.snapshotMapOf(n),this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",n=>this.lookToward(n.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"),s=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",n=>{n.newState==="open"&&zn.fill(s,this)}),this.sceneRenderer.onMapSubjectBounds=n=>this.ufoElement.setMapSubjectBounds(n),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("revealrequest",()=>this.poster.release()),this.ufoElement.addEventListener(RI,()=>this.poster.restore()),this.ufoElement.seekPreviewPainter=(n,r)=>this.seekPreviewOf(r).paint(n,r),typeof VideoEncoder<"u"&&typeof OffscreenCanvas<"u"&&(this.ufoElement.filmer={film:(n,r,a)=>this.film(n,r,a),generativeKit:(n,r,a)=>this.generativeKit(n,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=n=>n.vehicle!==void 0||n.decor.some(r=>r.engine!==void 0)||n.decor.some(r=>Df.kindOf(r,this.decorModelSounds.get(r.model?.id??""))!==void 0)||this.interpretationShown?.bodies.some(r=>r.sound)===!0||n.weatherTrack.allKeyframes.some(r=>r.weather.precipitationType!=="none"||r.weather.windSpeed>1)||this.detonates(n)||(this.traffic?.audible?.size??0)>0,this.ufoElement.addEventListener("referenceview",n=>this.applyReferenceView(n.detail)),this.ufoElement.addEventListener("traceview",n=>this.sceneRenderer.setTracesShown(n.detail.shown)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const n of At.GESTURES)this.addEventListener(n,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Fs(Us.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(e,t){const i=e.vehicle;return!i||!Rn.isRoad(i.kind)?void 0:{setting:xl.at(i.headlights??"auto",i.headlightKeyframes,t)??"auto",headingDeg:this.travelHeadingAt(e,t)}}travelHeadingAt(e,t){const i=et(e,t);if(!i)return 0;for(const s of[400,-400]){const n=et(e,t+s);if(!n||i.lat===void 0||i.lng===void 0||n.lat===void 0||n.lng===void 0)break;const r=lt(n.lat,n.lng,i.lat,i.lng);if(Math.hypot(r.x,r.z)<.8)continue;return(Math.atan2(r.x,-r.z)*180/Math.PI+(s<0?180:0)+360)%360}return i.headingDeg??0}routeCache;routeOf(e){const t=e.allKeyframes;if(this.routeCache?.track===e&&this.routeCache.count===t.length)return this.routeCache.route;const i=t.flatMap(n=>n.pose.lat!==void 0&&n.pose.lng!==void 0?[{lat:n.pose.lat,lng:n.pose.lng}]:[]),s=i.length>=2?i:void 0;return this.routeCache={track:e,count:t.length,route:s},s}traceLabels(e){const t=Us.preferencesFor(this).join();if(this.traceLabelsFor?.traces!==e||this.traceLabelsFor.language!==t){const i=new Map;for(const s of e){const n=this.said.read(s.title);n&&i.set(s.id,n)}this.traceLabelsFor={traces:e,language:t,labels:i}}return this.traceLabelsFor.labels}connectedCallback(){Xe.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 t of At.GESTURES)document.addEventListener(t,this.handlePageGesture,!0);const e=this.getAttribute("src");e&&this.loadFromSrc(e)}watchVisibility(){this.visibilityObserver?.disconnect(),!(typeof IntersectionObserver>"u"||this.hasAttribute("always-live"))&&(this.visibilityObserver=new IntersectionObserver(e=>{if(e[e.length-1].isIntersecting){this.sceneRenderer.resume();return}this.ufoElement.pause(),this.sceneRenderer.suspend()},{rootMargin:"100px"}),this.visibilityObserver.observe(this))}visibilityObserver;disconnectedCallback(){Xe.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const e of At.GESTURES)document.removeEventListener(e,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(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const s=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(s)&&s>0?s:Math.min(window.devicePixelRatio||1,2))}(e===tu||e===iu||e===ah)&&i!==t&&this.forwardPlayerAttributes(),e===ah&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const e of[tu,iu,ah]){const t=this.getAttribute(e);t===null?this.ufoElement.removeAttribute(e):this.ufoElement.setAttribute(e,t)}}setCompassForced(e){this.showCompassFor({forced:e})}compassHovered=!1;compassForced=!1;showCompassFor(e){this.compassHovered=e.hovered??this.compassHovered,this.compassForced=e.forced??this.compassForced,this.sceneRenderer.setCompassForced(this.compassForced||this.compassHovered)}lookToward(e){const t=et(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="observer"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:s}=lt(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,s)<1)return this.setLookOffset(0,0);const n=(Math.atan2(i,-s)*180/Math.PI+360)%360;this.setLookOffset(((n-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setOutsideHeard(Rn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity*(e.precipitationAmount??1),e.windSpeed);const t=this.ufoElement.sighting.around;this.weatherAudio.setAround(Bi.aroundBedRms(t),Bi.aroundBedShape(t)??[])}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}decorScreenBox(e){return this.sceneRenderer.decorScreenBox(e)}decorDrawnOffset(e){return this.sceneRenderer.decorDrawnOffset(e)}decorGroundPointAt(e,t,i,s=0){return this.sceneRenderer.decorGroundPointAt(e,t,i,s)}decorMetresPerNdcY(e){return this.sceneRenderer.decorMetresPerNdcY(e)}decorGrabHeightAt(e,t,i){return this.sceneRenderer.decorGrabHeightAt(e,t,i)}bodyScreenBox(e){return this.sceneRenderer.bodyScreenBox(e)}pickPlacedBodyAt(e,t){return this.sceneRenderer.pickPlacedBodyAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume()}async loadFromSrc(e){const t=Fa.recording(e);this.holdForNewScene(t);const i=await t;this.documentUrl=new URL(e,location.href).href,this.showPoster(i.image,this.documentUrl,!this.ufoElement.playRequested),this.sightingData=i}loader;poster;showPoster(e,t,i=!0){this.poster.show(e,t,i)}applyHold(){const e=this.holding,t=this.poster.up;this.loader.hidden=!e||t,e&&(this.hoverTooltip.hidden=!0),this.ufoElement.captionHeld=e||t,this.ufoElement.controlsHeld=e||t,this.ufoElement.holdClock(e)}holdForNewScene(e){this.sceneRenderer.holdForNewScene(e)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(e){this.sceneRenderer.documentUrl=e}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){const t=En.recording(e);this.ufoElement.playerTitle=void 0,this.ufoElement.sightingData=t,this.requireModules(t.modules),this.upperAirHeardLive=void 0,this.seekPreview?.recordingChanged(t),this.showInterpretation(this.inTheRound?this.ufoElement.sighting.interpretation:void 0),this.syncAccountHidden(),this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}onModulesChanged=e=>{e.detail==="skyEvents"&&this.sceneRenderer.setSkyEvents(this.skyEventsShown,!0,this.skyEventsStartDate)};requireModules(e){if(!e?.length)return;const t=this.documentUrl,i=V(async()=>{const{ModuleSession:s}=await import("./ModuleSession-Cxe0BJue.js");return{ModuleSession:s}},[],import.meta.url).then(({ModuleSession:s})=>s.shared.require(e,t)).then(()=>this.sceneRenderer.setDecorModelProvider(new Fp));this.sceneRenderer.holdUntil(i)}seekPreview;seekPreviewOf(e){const t=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(e.width/t);return e.height!==i&&(e.height=i),this.seekPreview??=new Fg(this,()=>document.createElement(Bf))}showAt(e){this.ufoElement.currentTime=e,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(e){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const t=e.getContext("2d");return t?(t.imageSmoothingQuality="high",t.drawImage(this.sceneCanvas,0,0,e.width,e.height),!0):!1}filmName;filmFileName(){return`${(this.filmName??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim()||"observation"}.mp4`}filming=!1;async film(e,t,i){const[{VideoExport:s},{FilmChrome:n}]=await Promise.all([V(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),V(()=>import("./FilmChrome-DYiyzoB_.js"),[],import.meta.url)]),r=await n.loadLogo();return this.filmScene(e,a=>s.film({...a,frameAt:(o,c,h)=>a.frameAt(o,c,h)?(n.paint(h,this.ufoElement.filmChrome(e),r),!0):!1},t,i))}async generativeKit(e,t,i){const[{GenerativeKit:s},{generativeKitMessages:n},{toSightingJson:r}]=await Promise.all([V(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([25,26,27]),import.meta.url),V(()=>import("./GenerativeKitMessages-I8xH2ec9.js"),[],import.meta.url),V(()=>Promise.resolve().then(()=>_N),void 0,import.meta.url)]),a=Ha(Us.preferencesFor(this),Ba),[o]=await Promise.all([n.load(a),this.sceneRenderer.loadControlPasses()]),c=this.sceneRenderer.areReferencesShown;this.sceneRenderer.setReferencesShown(!1);try{return await this.filmScene({...e,caption:!1,time:!1,map:!1},h=>s.make({film:h,drawControlPasses:()=>this.sceneRenderer.drawControlPasses(),recording:r(this.ufoElement.sighting),title:this.filmName??"",source:h.about?.source,language:a},o,t,i))}finally{this.sceneRenderer.setReferencesShown(c)}}async filmScene(e,t){if(this.filming)throw new Error("Already filming");const i=this.ufoElement,s=i.currentTime;i.pause();const n={width:this.sceneCanvas.clientWidth,height:this.sceneCanvas.clientHeight},r=e.height&&n.height>0?e.height/n.height:this.sceneRenderer.maxPixelRatio;this.filming=!0,this.sceneRenderer.holdPixelRatio(r),i.filmMap(e.map),this.syncAnimationsToPlayback();try{const a=e.height??this.sceneCanvas.height,o=e.height&&n.height>0?Math.round(e.height*n.width/n.height):this.sceneCanvas.width,c=this.filmRate(),h=Math.min(i.seekableDuration,e.toS!==void 0?e.toS*1e3*c:i.seekableDuration),d=Math.min(h,Math.max(0,(e.fromS??0)*1e3*c));return await t({fromMs:d,toMs:h,rate:c,width:o,height:a,frameAt:(u,p,f)=>this.filmFrameAt(u,p,f),hearInto:u=>this.hearInto(u),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=s,this.syncAnimationsToPlayback()}}filmRate(){const e=this.ufoElement.playbackRate;return e>0?e:1}filmPictureSize(){const e=this.sceneRenderer.maxPixelRatio;return{width:Math.round(this.sceneCanvas.clientWidth*e),height:Math.round(this.sceneCanvas.clientHeight*e)}}filmSound;liveSound;filmThunderAtMs;hearInto(e){if(e){this.liveSound??={weather:this.weatherAudio,vehicle:this.vehicleAudio,aircraft:this.aircraftAudio},this.filmSound=e,this.weatherAudio=new uh(e),this.vehicleAudio=new v2(e);const t=At.trafficRuntime;this.aircraftAudio=this.liveSound.aircraft&&t?this.newAircraftAudio(t):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(e),this.syncAnimationsToPlayback()}filmFrameAt(e,t,i){this.ufoElement.currentTime!==e&&(this.ufoElement.currentTime=e),this.filmThunderAtMs!==void 0&&e>=this.filmThunderAtMs&&(this.filmThunderAtMs=void 0,this.weatherAudio.playThunder()),this.sceneRenderer.render();const s=this.sceneRenderer.framesDrawn;return this.sceneRenderer.frame(t),this.sceneRenderer.framesDrawn===s?!1:(i.drawImage(this.sceneCanvas,0,0,i.canvas.width,i.canvas.height),!0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}horizonPointAt(e){const t=e*Math.PI/180,i=this.sceneRenderer.screenPointOf(new I(Math.sin(t),0,-Math.cos(t)));return i&&{x:(i.ndcX+1)/2,y:(1-i.ndcY)/2}}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailure(e){return this.sceneRenderer.referenceFailure(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references){const i=e.views?.[t.id];this.sceneRenderer.setReferenceView(t.id,{opacity:i?i.shown?i.opacity:0:e.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(e){this.liveTerrainProviders=e,this.snapshotKey=void 0,this.applySnapshots(this.ufoElement.sighting.snapshots)}liveTerrainProviders;snapshotKey="none";applySnapshots(e){const t=us.isEmpty(e)?"none":`${JSON.stringify(e)}
|
|
12153
12179
|
${this.documentUrl??""}
|
|
12154
12180
|
${Lt.generation}`;if(t===this.snapshotKey)return;const i=this.snapshotKey!==void 0&&this.traffic?.set!==void 0;this.snapshotKey=t,this.sceneRenderer.setTerrainProviders(Bg.providers(e,this.documentUrl,this.liveTerrainProviders??AI())),this.ufoElement.observerMapSnapshot=this.snapshotMapOf(e),i&&(this.traffic=void 0,this.decorMemo=void 0)}snapshotMapOf(e){const t=us.held(e,"map");if(!t)return;const i=`${Lt.address(t.src,this.documentUrl)}
|
|
12155
12181
|
${Lt.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,imagery:Bg.map(t,this.documentUrl)}),this.snapshotMap.imagery}snapshotMap;setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return[...new Map(this.sceneRenderer.currentDecorModelCredits.map(t=>[`${t.title}|${t.author??""}|${t.license}|${t.sourceUrl??""}`,t])).values()]}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=Ft.CANVAS_HEIGHT_PX,i=Vt.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=i,this.sceneRenderer.resize(t,i)}async loadStars(){const e=[{magnitudeLimit:yy,url:this.getAttribute("star-catalog-src")??NU},{magnitudeLimit:zp,url:this.getAttribute("deep-star-catalog-src")??FU}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>yy?zp:yy;const s=await no.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=s,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=zp||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=bn.gainFor(e.instrument,{fNumber:et(e,0)?.fNumber,fieldOfViewDeg:Li.fovOf(e,0),exposureSeconds:e.exposure});return uo(UU,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=$n.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,s=this.degreesPerPixelAt(e),n=Mh.instants(i,s),r=Math.max(n,this.ufoElement.exposureTimes(e).length,$n.instants(this.decorWithTraffic(this.ufoElement.sighting),et(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,s),$n.bodyInstants(this.interpretationShown?.bodies??[],et(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,e,s));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=this.ufoElement.sighting.observerTrack.turnIsViewOnly(t.fromMs,e)?e:void 0;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t.fromMs+t.ms*o/(r-1),{viewAt:a,sky:Math.floor(o*n/r)!==Math.floor((o-1)*n/r),stepMs:t.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Li.fovOf(this.ufoElement.sighting,e)/t}roadGradeAt(e,t){return e.observerTrack.allKeyframes.length<2?0:Pd.at(e,t,this.sceneRenderer.bodyGround)}get roadGradeDeg(){return this.roadGradeAt(this.ufoElement.sighting,this.ufoElement.currentTime)}applySceneAt(e,t){const i=this.ufoElement.sighting;t||this.sceneRenderer.setRecordingTime(e),this.setWeather(Lu(i,e)),this.sceneRenderer.setInstrument(i.instrument,et(i,e)?.fNumber),this.sceneRenderer.setLightPollution(i.lightPollution),t||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,e)),t||this.pushAircraftSound(i,e),this.updateMeteorShower(i,e),this.updateLightning(i,e,t!==void 0),this.sceneRenderer.setDecor(this.seatedDecor(this.decorWithTraffic(i),e)),this.recomputeAmongNewDecor(),this.sceneRenderer.setDecorPresence(this.traffic?.set?.presence??At.NO_PRESENCE),this.sceneRenderer.setDecorSunlight(this.trafficSunlight(e)),this.sceneRenderer.setContrails(this.traffic?.contrails??At.NO_CONTRAILS),this.sceneRenderer.setContrailSunlight(this.contrailSunlight(e));const s=et(i,e);this.sceneRenderer.setReferences(i.references,s?.lat!==void 0&&s.lng!==void 0?{lat:s.lat,lng:s.lng}:void 0),t||this.sceneRenderer.setReferencesTime({t:e,playing:this.ufoElement.playbackState==="playing",timeScale:this.ufoElement.playbackRate});const n=et(i,0),r=Ts(i,0),a=js(i.event.time??{},s?.lng??y0.lng,i.event.utcOffsetHours),o=i.weatherSource!==void 0&&a?NN(a):void 0,c=Object.fromEntries(fl(Ts(i,e)).map(O=>[O.id,bg(e,i.weatherTrack,r,n,s,O.id,O.instances?.length?void 0:o)]));this.sceneRenderer.setCloudOffset(bg(e,i.weatherTrack,r,n,s,void 0,o),c);const h=t?.viewAt!==void 0?et(i,t.viewAt):void 0,d=s&&h?{...s,headingDeg:h.headingDeg,pitchDeg:h.pitchDeg,rollDeg:h.rollDeg,fovDeg:h.fovDeg}:s;this.sceneRenderer.setObserverPose(d?{...d,pitchDeg:d.pitchDeg+this.roadGradeAt(i,t?.viewAt??e)}:y0),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(bn.gainFor(i.instrument,{fNumber:s?.fNumber,fieldOfViewDeg:Li.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0,is.byId(s?.filter).opticalDensity),this.sceneRenderer.setMedium(lc.mediumOf(i.instrument.medium,lc.byId(i.film)),i.exposure,s?.fNumber??i.instrument.fNumber,i.iso,i.metering),this.sceneRenderer.setLensGhosts(zt.optics(i.instrument,s?.fNumber??i.instrument.fNumber,i.lens,this.glassWettingOf(i).stateAt(e/1e3),e)),this.sceneRenderer.setPerception(Na.perceptionOf(i.account?.observerPerception)),this.sceneRenderer.setGait(Ti.bodyAt(i,e,this.ufoElement.steadyBody)),this.sceneRenderer.updateDecorAnchoring(et(i,0),s,e),this.placeBodiesAt(e,t===void 0),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.applySnapshots(i.snapshots),this.sceneRenderer.setObserverRoute(this.routeOf(i.observerTrack)),this.sceneRenderer.setObserverHeadlights(this.observerHeadlightsAt(i,e)),this.sceneRenderer.setTerrainOrigin(s?.lat,s?.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(e);const u=s?.lat??y0.lat,p=s?.lng??y0.lng,f=js(i.event.time??{},p,i.event.utcOffsetHours),m={lat:u,lng:p,elevationM:this.altitudeOf(s)};this.pushSatellitesAt(f,e,m),this.ensureFireballs(f);const g=this.skyEventsOf(i),v=g?.reentries??[];this.hearDetonations(v,e,{lat:u,lng:p,heightM:m.elevationM},t!==void 0);const b=v.filter(O=>Ce.mayDazzle(O));if(this.sceneRenderer.setRetinaHistory(b.length===0?void 0:O=>{const N=et(i,O),C={lat:N?.lat??u,lng:N?.lng??p,heightM:N?this.altitudeOf(N):m.elevationM};return{views:Ce.viewsAt(b,O,C),pose:N}},i),this.skyEventsStartDate=f,this.sceneRenderer.setSkyEvents(g,!1,f),g&&this.loadSkyEventTexts(Of.map(O=>ea.of(O)).filter(O=>ea.eventsOf(g,O).length>0&&!this.skyEventTexts.has(O))),t&&!t.sky)return;if(this.sceneRenderer.setSkyUnknown(!f),!f){this.sceneRenderer.setAstronomy(BU);return}const w=new Date(f.getTime()+e),y=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/Mh.DEG_PER_SECOND*1e3)),M=Math.max(1e-8,this.degreesPerPixelAt(e)*.1),x=`${Math.floor(w.getTime()/y)}|${Math.round(u/M)}|${Math.round(p/M)}|${Math.round(m.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(x===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=x;const S=Di("Sun",w,m),E=Di("Moon",w,m);let A=As.separationOf(S,E)<1?As.viewAt(w,m):void 0;if(A){const O=As.offsetOf(S,E,A.separationDeg);if(A.obscuration>At.LIMB_FROM_OBSCURATION){const N=this.limbFor(w,m);N&&(A={...A,obscuration:1-ua.uncoveredFraction(N,A.sunRadiusDeg,O),limb:N})}A={...A,horizonShare:As.horizonShare(A,O,S.altitudeDeg,S.azimuthDeg,Jn.distanceKm(w,m))}}const T={...S,magnitude:k0("Sun",w)-2.5*Math.log10(As.beamFraction(A))};this.lastSun={altitudeDeg:T.altitudeDeg,azimuthDeg:T.azimuthDeg};const D={...E,phase:$l(w),magnitude:k0("Moon",w),radiusDeg:Jn.apparentRadiusDeg(w,m)},k=ek.map(O=>({body:O,position:Di(O,w,m),magnitude:k0(O,w)}));this.sceneRenderer.setAstronomy({sun:T,moon:D,planets:k,comet:this.cometAt(w,m),novae:Gg.appearancesAt(w,m).map(({outburst:O,position:N,magnitude:C})=>({id:O.id,position:N,magnitude:C})),stars:this.starCatalog?{catalog:this.starCatalog,date:w,observer:m}:void 0,frame:{date:w,observer:m},localHour:((w.getUTCHours()+w.getUTCMinutes()/60+(i.event.utcOffsetHours??Math.round(p/15)))%24+24)%24,eclipse:A}),this.ufoElement.setSunAltitude(T.altitudeDeg)}static LIMB_FROM_OBSCURATION=.98;limbRelief;limbRequested=!1;limbCache;limbFor(e,t){if(!this.limbRelief){this.limbRequested||(this.limbRequested=!0,Hp.load(PU).then(n=>{this.limbRelief=n,this.lastSkyKey="",n&&this.isConnected&&this.updateAstronomy(this.lastTimeMs)}));return}const i=this.limbCache;if(i&&Math.abs(e.getTime()-i.atMs)<5e3&&i.lat===t.lat&&i.lng===t.lng&&i.elevationM===t.elevationM)return i.profile;const s=ua.profile(e,t,this.limbRelief);return this.limbCache={profile:s,atMs:e.getTime(),lat:t.lat,lng:t.lng,elevationM:t.elevationM},s}pushSatellitesAt(e,t,i){if(this.ensureSatellites(e),!e||!this.satellites){this.sceneRenderer.setSatellites([]);return}const s=new Date(e.getTime()+t),n=[];for(const r of this.satellites.passes.positionsAt(s,i,-1))r.magnitude!==void 0&&n.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(n)}ensureFireballs(e){const t=this.ufoElement.sighting,i=Math.max((t.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),s=e?.getTime(),n=t.skySources!==!1,r=s===void 0||!n?"":`${s}+${i}`;if(this.fireballs?.key===r)return;if(!n){this.fireballs={key:r,status:"outside",reentries:[]};return}if(s===void 0||!fa.mayCover(s+i)){this.fireballs={key:r,status:"outside",reentries:[]};return}const a={key:r,status:"loading",reentries:[]};this.fireballs=a,At.fireballArchive.between(s,s+i).then(o=>{a.status=o?"ready":"unavailable",a.records=o??[],a.reentries=a.records.map(c=>fa.asReentry(c,s)),!(this.fireballs!==a||!this.isConnected)&&(this.dispatchEvent(new CustomEvent(PM)),a.reentries.length>0&&this.updateAstronomy(this.lastTimeMs))})}decorWithTraffic(e){const t=this.ensureTraffic(e);if(!t||t.objects.length===0)return e.decor;const i=this.decorMemo;if(i&&i.base===e.decor&&i.traffic===t.objects)return i.merged;const s=[...e.decor,...t.objects];return this.decorMemo={base:e.decor,traffic:t.objects,merged:s},s}seatedDecor(e,t){if(!e.some(r=>r.observerKeyframes?.length))return e;const i=e.map(r=>{if(!r.observerKeyframes?.length)return"";const a=HS(r,t);return`${a.side??"-"}/${a.facing??"-"}`}).join("|"),s=this.seatedMemo;if(s&&s.base===e&&s.seats===i)return s.seated;const n=e.map(r=>{if(!r.observerKeyframes?.length)return r;const a=HS(r,t);return{...r,observerSide:a.side,observerFacing:a.facing}});return this.seatedMemo={base:e,seats:i,seated:n},n}ensureTraffic(e){const t=et(e,0),i=t?.lng===void 0?void 0:js(e.event.time??{},t.lng,e.event.utcOffsetHours),s=Math.max((e.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),n=i?.getTime(),r=n===void 0||t?.lat===void 0||t.lng===void 0?"":`${this.aircraftSource.id}|${n}+${s}|${t.lat.toFixed(3)},${t.lng.toFixed(3)}|${Math.round(t.elevationM??0)}|${Math.round(this.sceneRenderer.groundAltitudeM)}`;if(e.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===""||n===void 0||t?.lat===void 0||t.lng===void 0){this.traffic={key:r,status:"outside"};return}let a=At.aircraftProviders.get(this.aircraftSource.id);if(a||At.aircraftProviders.set(this.aircraftSource.id,a=this.aircraftSource.create()),a.mayCover&&!a.mayCover(n+s)){this.traffic={key:r,status:"outside"};return}const o={key:r,status:"loading",startMs:n,observer:{lat:t.lat,lng:t.lng}};this.traffic=o;const c={lat:t.lat,lng:t.lng,heightM:this.sceneRenderer.groundAltitudeM},h=wn.MAX_GAP_S*1e3,d=At.SOUND_LOOKBACK_MS,u={lat:t.lat,lng:t.lng,elevationM:this.altitudeOf(t)},p=(f,m)=>f.TrafficDecor.from(o.tracks??[],c,n,f.TrafficDecor.MAX_OBJECTS,{models:m,sunElevationAt:g=>this.sunElevationAt(g,u)});a.between(c,n-d,n+s+h).then(async f=>{if(this.traffic!==o)return;if(f.status!=="found"){o.status=f.status==="outside"?"outside":"unavailable",f.status==="failed"&&(o.problem=f.problem,o.creditsSpent=f.creditsSpent),this.announceTraffic();return}let m;try{m=await At.loadTrafficRuntime()}catch{this.traffic===o&&(o.status="unavailable",this.announceTraffic());return}this.traffic===o&&(o.status="ready",o.tracks=f.tracks,o.partial=f.partial,o.creditsSpent=f.creditsSpent,o.set=p(m),this.startAircraftSound(o,m),this.announceTraffic(),this.describeTraffic(a,o,m,p),o.set.shown>0&&(this.readUpperAir(o,m,n-d,n+s+h),this.readTrailTraffic(a,o,m,c,n-At.TRAIL_LOOKBACK_MS,n+s+h)))})}trafficSunlight(e){const t=new Map,i=this.traffic,s=i?.set,n=this.lastSun;if(!s||!n||i.startMs===void 0||!i.observer)return t;for(const[r,a]of s.presence){if(e<a.fromMs||e>a.untilMs)continue;const o=s.flights.get(r),c=o?wn.positionAt(o,i.startMs+e):void 0;c&&t.set(r,{heightM:c.geo.heightM,sunElevationDeg:pr.sunElevationDeg(n,i.observer,c.geo)})}return t}trafficTooltipAt(e,t){const i=this.sceneRenderer.pickTrafficAt(e,t),s=i?this.trafficInfoAt(i):void 0;if(!s)return;const n=this.naming;return At.trafficRuntime?.TrafficTooltip.text(s,n.names.trafficTooltip,a=>n.towards(a))}trafficInfoAt(e){const t=this.traffic,i=t?.set?.flights.get(e);if(!t||!i||t.startMs===void 0||!t.observer)return;const s=At.trafficRuntime;if(!s)return;const n=t.descriptions?.get(ui.keyOf(i)),r=et(this.ufoElement.sighting,this.lastTimeMs),a={lat:t.observer.lat,lng:t.observer.lng,heightM:this.altitudeOf(r)},o=Lu(this.ufoElement.sighting,this.lastTimeMs),c=this.ufoElement.sighting.around,h=s.AmbientNoise.dbA(o,c),d=s.TrafficInfos.at(i,n,a,t.startMs+this.lastTimeMs,{ambientDbA:h,ambientShapeDb:s.AmbientNoise.shapeDb(o,c)}),u=d&&this.contrailAt(e,this.lastTimeMs);return d&&u?{...d,contrail:u}:d}contrailAt(e,t){const i=this.traffic?.contrails?.find(n=>n.id===e);if(!i)return;let s;for(const n of i.points){if(n.tMs>t)break;s=n}return s?.forms?{persistent:s.persistent,iceRelativeHumidity:s.iceRelativeHumidity}:void 0}startAircraftSound(e,t){this.aircraftAudio??=this.newAircraftAudio(t),this.sortOutAudible(e,t)}sortOutAudible(e,t){if(!e.set||!e.observer)return;const i={windSpeed:0,precipitationType:"none",precipitationIntensity:0};e.audible=t.TrafficSound.candidates(e.set.flights,e.descriptions??new Map,ui.keyOf,{...e.observer,heightM:this.sceneRenderer.groundAltitudeM},{ambientDbA:t.AmbientNoise.dbA(i,this.ufoElement.sighting.around),ambientShapeDb:t.AmbientNoise.shapeDb(i,this.ufoElement.sighting.around)}),this.ufoElement.refreshSoundControls()}pushAircraftSound(e,t){this.startDecorAircraftSound(e),this.startBodySound(),this.startRideSound(e);const i=this.aircraftAudio;if(!i)return;const s=At.trafficRuntime;if(!s){i.setVoices([]);return}const n=et(e,t),r=Lu(e,t),a={ambientDbA:s.AmbientNoise.dbA(r,e.around),referenceAmplitude:s.AmbientNoise.referenceAmplitude(r,e.around),ambientShapeDb:s.AmbientNoise.shapeDb(r,e.around),expandUnderKnee:!s.AmbientNoise.bedPlays(r,e.around)},o=e.event.place?.[0],c={lat:n?.lat??o?.lat,lng:n?.lng??o?.lng},h=c.lat!==void 0&&c.lng!==void 0?{lat:c.lat,lng:c.lng,heightM:n?.elevationM??0}:void 0,d=v=>this.decorModelSounds.get(v.model?.id??""),u=!e.vehicle&&h?s.DecorAircraftHearing.ridden(e,t,h,d):void 0,p=e.vehicle??(u?{kind:u.kind}:void 0),f=p?s.CabinHearing.voice(p,a):void 0,m={...a,ambientDbA:Math.max(a.ambientDbA,f?.levelDbA??0),...p?{throughDb:Rn.insulationDb(p)}:{}},g=this.trafficVoices(t,n,m,s);h&&(this.decorAircraftHearing??=new s.DecorAircraftHearing,g.push(...this.decorAircraftHearing.voices(e,t,h,m,d)),g.push(...this.bodyVoices(e,t,m,s)),f&&g.push(f),g.sort((v,b)=>b.levelDbA-v.levelDbA),g.length=Math.min(g.length,4)),i.setVoices(g,n?.headingDeg??0)}startRideSound(e){this.aircraftAudio||Rn.aircraftOf(e.vehicle)===void 0||(At.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(At.trafficRuntime):At.loadTrafficRuntime().catch(()=>{}))}startBodySound(){this.aircraftAudio||!this.interpretationShown?.bodies.some(e=>e.sound)||(At.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(At.trafficRuntime):At.loadTrafficRuntime().catch(()=>{}))}bodyVoices(e,t,i,s){const n=this.interpretationShown,r=e.event.place?.[0];if(!n||!r||!n.bodies.some(p=>p.sound))return[];const a=this.sceneRenderer.bodyGround,o=p=>Ne.eyeOf(e,p,a),c=o(t);if(!c)return[];const h=new Map,d=(p,f)=>{let m=h.get(p.id);return m||h.set(p.id,m=new Ne(p,a,o)),m.at(f)};this.bodyHearing??=new s.BodyHearing;const u=Math.max(e.observerTrack.duration,(e.event.durationSeconds??0)*1e3);return this.bodyHearing.voices(n.bodies,d,c,r,t,u,i)}trafficVoices(e,t,i,s){const n=this.traffic,r=n?.set;if(!n||!r||!n.audible||n.startMs===void 0||!n.observer)return[];const a={lat:n.observer.lat,lng:n.observer.lng,heightM:this.altitudeOf(t)};return s.TrafficSound.voices(n.audible,r.flights,n.descriptions??new Map,ui.keyOf,a,n.startMs+e,i)}startDecorAircraftSound(e){const t=e.decor.filter(s=>s.kind==="aircraft"&&s.track?.some(n=>(n.altitudeM??0)>0));if(t.length===0)return;for(const s of t){const n=s.model?.id;s.aircraftSound||!n||s.model?.url!==void 0||this.decorModelSounds.has(n)||(this.decorModelSounds.set(n,void 0),this.decorModelsAsked.add(n),this.sceneRenderer.entryOfDecorModel(n).then(r=>{this.decorModelSounds.set(n,r?.parameters?.sound),this.decorModelsAsked.delete(n),this.ufoElement.refreshSoundControls(),this.startDecorAircraftSound(e)}))}if(t.some(s=>{if(s.aircraftSound)return s.aircraftSound!=="silent";const n=s.model?.id;return!n||s.model?.url!==void 0?!0:!this.decorModelsAsked.has(n)&&this.decorModelSounds.get(n)!=="silent"})){if(this.aircraftAudio||At.trafficRuntime){!this.aircraftAudio&&At.trafficRuntime&&(this.aircraftAudio=this.newAircraftAudio(At.trafficRuntime));return}At.loadTrafficRuntime().catch(()=>{})}}newAircraftAudio(e){const t=new e.AircraftAudio(this.filmSound);return this.filmSound||t.setLevel(this.ufoElement.level),(this.interacted||this.filmSound)&&t.resume(),t.setPaused(this.ufoElement.playbackState!=="playing"&&!this.filmSound),t}get aircraftFlights(){return[...this.declaredFlights,...this.recordedFlights]}get declaredFlights(){return this.ufoElement.sighting.decor.filter(e=>e.kind==="aircraft"&&Df.flies(e)).map(e=>{const t=this.sceneRenderer.decorSkyPoint(e.id);return{key:ui.declaredKeyOf(e.id),type:this.said.read(e.title)||this.naming.decorKind(e.kind),sky:t?.sky,altitudeFt:t?t.altitudeM/.3048:void 0,firstMs:0,drawn:t!==void 0,declared:!0}})}get recordedFlights(){const e=this.traffic;if(!e?.tracks||e.startMs===void 0||!e.observer)return[];const t=e.startMs,i=this.observerAt(this.lastTimeMs,e.observer),s=new Set([...e.set?.flights.values()??[]].map(a=>ui.keyOf(a))),n=e.nearestPassKm??=new Map(e.tracks.map(a=>[ui.keyOf(a),Math.min(...a.points.map(o=>wn.groundDistanceKm(e.observer,o)))])),r=this.ufoElement.seekableDuration;return[...e.tracks].sort((a,o)=>n.get(ui.keyOf(a))-n.get(ui.keyOf(o))).map(a=>{const o=ui.keyOf(a),c=e.descriptions?.get(o),h=e.models?.get(o),d=wn.seenFrom(a,i,t+this.lastTimeMs),u=a.points.find(p=>p.t>=t)?.t;return{key:o,type:h?.basis==="type"?h.name:c?.type,registration:c?.registration,sky:d?.sky,altitudeFt:d?.altitudeFt,firstMs:u!==void 0&&u-t<=r?u-t:void 0,drawn:s.has(o)}})}lookAtFlight(e,t=this.lastTimeMs){const i=this.traffic,s=et(this.ufoElement.sighting,t),n=ui.declaredIdOf(e);if(n!==void 0){const o=this.sceneRenderer.decorSkyPoint(n);return!o||s?.headingDeg===void 0?!1:(this.setLookOffset(((o.sky.azimuthDeg-s.headingDeg)%360+540)%360-180,o.sky.altitudeDeg-(s.pitchDeg??0)),!0)}const r=i?.tracks?.find(o=>ui.keyOf(o)===e);if(!i?.observer||i.startMs===void 0||!r||s?.headingDeg===void 0)return!1;const a=wn.seenFrom(r,this.observerAt(t,i.observer),i.startMs+t);return a?(this.setLookOffset(((a.sky.azimuthDeg-s.headingDeg)%360+540)%360-180,a.sky.altitudeDeg-(s.pitchDeg??0)),!0):!1}markFlight(e){this.markedFlight=e,this.placeFlightMark()}placeFlightMark(){const e=this.markedFlight,t=e===void 0?void 0:this.sceneRenderer.flightScreenPoint(e);if(this.flightMark.toggleAttribute("hidden",!t),!t)return;const i=this.sceneCanvas.getBoundingClientRect(),s=this.stageElement.getBoundingClientRect(),n=i.left-s.left+(t.ndcX+1)/2*i.width,r=i.top-s.top+(1-t.ndcY)/2*i.height;for(const a of Array.from(this.flightMark.children))a.setAttribute("cx",String(n)),a.setAttribute("cy",String(r))}altitudeOf(e){return this.sceneRenderer.groundAltitudeM+(e?.elevationM??0)}observerAt(e,t){const i=et(this.ufoElement.sighting,e);return{lat:i?.lat??t.lat,lng:i?.lng??t.lng,heightM:this.altitudeOf(i)}}announceTraffic(){this.isConnected&&(this.dispatchEvent(new CustomEvent(FM)),this.updateAstronomy(this.lastTimeMs))}async describeTraffic(e,t,i,s){if(!e.describe||!t.set||!t.tracks)return;const n=new Set([...t.set.flights.values()].map(c=>ui.keyOf(c))),r=t.tracks.filter(c=>n.has(ui.keyOf(c))&&c.points.length>0),a=new Map,o=new Map;await Promise.all(r.map(async c=>{const h=new Date(c.points[0].t).toISOString().slice(0,10),d=await e.describe(c,h).catch(()=>{});d&&(o.set(ui.keyOf(c),d),a.set(ui.keyOf(c),i.AircraftModels.of(d)))})),!(this.traffic!==t||a.size===0)&&(t.descriptions=o,t.models=a,t.set=s(i,a),this.planContrails(t,i),this.sortOutAudible(t,i),this.announceTraffic())}async readTrailTraffic(e,t,i,s,n,r){if(t.startMs===void 0)return;const a=await e.between(s,n,r).catch(()=>{});if(this.traffic!==t||a?.status!=="found")return;const o=a.tracks.filter(d=>d.points.some(u=>u.altitudeFt>=i.AircraftContrails.MIN_ALTITUDE_FT)),c=new Map(t.models??[]);if(e.describe&&await Promise.all(o.filter(d=>d.points.length>0&&!c.has(ui.keyOf(d))).map(async d=>{const u=await e.describe(d,new Date(d.points[0].t).toISOString().slice(0,10)).catch(()=>{});u&&c.set(ui.keyOf(d),i.AircraftModels.of(u))})),this.traffic!==t||t.startMs===void 0)return;const h=i.TrafficDecor.from(o,s,t.startMs,At.TRAIL_MAX_AIRCRAFT,{models:c});t.trailSet=At.alignTrailIds(h,t.set),t.models=new Map([...c,...t.models??[]]),this.planContrails(t,i),this.announceTraffic()}static alignTrailIds(e,t){if(!t)return e;const i=new Map;for(const[a,o]of t.flights){const c=t.presence.get(a);if(c)for(const[h,d]of e.flights){const u=e.presence.get(h);!u||ui.keyOf(d)!==ui.keyOf(o)||u.fromMs<=c.untilMs&&c.fromMs<=u.untilMs&&i.set(h,a)}}const s=a=>i.get(a)??`${a}-trail`,n=new Set(i.values()),r=t.objects.filter(a=>!n.has(a.id));return{...e,objects:[...e.objects.map(a=>({...a,id:s(a.id)})),...r],presence:new Map([...[...e.presence].map(([a,o])=>[s(a),o]),...r.map(a=>[a.id,t.presence.get(a.id)])]),flights:new Map([...[...e.flights].map(([a,o])=>[s(a),o]),...r.map(a=>[a.id,t.flights.get(a.id)])])}}async readUpperAir(e,t,i,s){if(!e.observer)return;const n=us.held(this.ufoElement.sighting.snapshots,"upperAir");let r;if(n){const c=Lt.address(n.src,this.documentUrl);r=At.upperAirProviders.get(c),r||At.upperAirProviders.set(c,r=new Vd(Lt.json(c)))}else{const c=this.upperAirSource??t.UPPER_AIR_SOURCES[0];r=At.upperAirProviders.get(c.id),r||At.upperAirProviders.set(c.id,r=c.create())}const a={lat:e.observer.lat,lng:e.observer.lng},o=await r.between(a,i,s);this.traffic!==e||o.status!=="found"||(n||(this.upperAirHeardLive={...a,startMs:i,endMs:s,answer:o}),e.air=o.samples,e.airSource=o.source,this.planContrails(e,t),this.announceTraffic())}planContrails(e,t){const i=e.trailSet??e.set;!i||!e.air||e.startMs===void 0||(e.contrails=t.AircraftContrails.plan(i,e.models,e.air,e.startMs))}contrailSunlight(e){const t=new Map,i=this.traffic,s=i?.trailSet??i?.set,n=this.lastSun;if(!i||!s||!n||!i.contrails?.length||i.startMs===void 0||!i.observer)return t;for(const r of i.contrails){const a=s.presence.get(r.id),o=s.flights.get(r.id);if(!a||!o)continue;const c=wn.positionAt(o,i.startMs+Math.min(a.untilMs,Math.max(a.fromMs,e)));c&&t.set(r.id,{heightM:c.geo.heightM,sunElevationDeg:pr.sunElevationDeg(n,i.observer,c.geo)})}return t}sunElevationAt(e,t){const i=Di("Sun",new Date(e.t),t);return pr.sunElevationDeg(i,t,e)}upperAirSource;upperAirHeardLive;get upperAirHeard(){return this.upperAirHeardLive}setUpperAirSource(e){e.id!==this.upperAirSource?.id&&(this.upperAirSource=e,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}setAircraftSource(e,t=!1){!t&&e.id===this.aircraftSource.id||(this.aircraftSource=e,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}get aircraftState(){const e=this.traffic?.contrails?.length?this.upperAirSource??At.trafficRuntime?.UPPER_AIR_SOURCES[0]:void 0;return{trailCredit:e&&{credit:e.credit,creditUrl:e.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(e){this.ufoElement.sighting.skySources===!1&&(e=void 0);const t=e?String(e.getTime()):"";if(t===this.satellitesFor)return;this.satellitesFor=t,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!e){this.satelliteStatus="none";return}this.satelliteStatus="loading";const s=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.isConnected&&this.dispatchEvent(new CustomEvent(LM)))},n=At.tleArchive;(async()=>{if(!await n.covers(e))return s("outside");const[r,a]=await Promise.all([n.at(e),V(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return s("unavailable");this.satellites={snapshot:r,passes:new a.SatellitePasses(r.objects)},s("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>s("unavailable"))}get satelliteState(){const e=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:e?.coverage,credit:e?.credit,creditUrl:e?.creditUrl}}burningCandidates(){return{reentries:this.ufoElement.sighting.skyEvents?.reentries??[],fireballs:this.fireballs?.reentries??[]}}trafficCandidates(){const e=this.traffic;if(!(e?.status!=="ready"||!e.tracks||e.startMs===void 0))return{tracks:e.tracks,startMs:e.startMs,describe:t=>e.descriptions?.get(ui.keyOf(t))}}satellitePositionsAt(e){const t=this.satellites,i=this.ufoElement.sighting,s=et(i,0),n=i.event.place?.[0],r=s?.lat??n?.lat,a=s?.lng??n?.lng;if(!(!t||r===void 0||a===void 0))return t.passes.positionsAt(e,{lat:r,lng:a,elevationM:this.altitudeOf(s)})}satellitePassesDuring(e){const t=this.satellites,i=this.ufoElement.sighting,s=et(i,0),n=i.event.place?.[0],r=s?.lat??n?.lat,a=s?.lng??n?.lng;if(!t||r===void 0||a===void 0)return[];const o=js(i.event.time??{},a,i.event.utcOffsetHours);if(!o)return[];const c=Math.min(Math.max(e,0),4*36e5),h={lat:r,lng:a,elevationM:this.altitudeOf(s)},d=JSON.stringify([this.satellitesFor,o.getTime(),r,a,h.elevationM,c]);if(this.satellitePassesMemo?.key===d)return this.satellitePassesMemo.passes;const u=Math.max(10,Math.ceil(c/1e3/600)),p=t.passes.passesDuring(o,new Date(o.getTime()+c),h,u);return this.satellitePassesMemo={key:d,passes:p},p}cometAt(e,t){const i=$0.brightestAt(e,t);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}approachOf(e,t){return this.approaches.of.has(t)||this.approaches.of.set(t,Vp.of(e,t)),this.approaches.of.get(t)}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const i=JSON.stringify([t.timeline.allKeyframes.map(m=>[m.t,m.shapes.map(g=>[g.sourceId,g.shape.angular?.widthDeg,g.shape.aim?.azimuthDeg])]),t.observerTrack.allKeyframes,t.event.place?.[0]]);i!==this.approaches.key&&(this.approaches={key:i,of:new Map});const s=t.timeline,n=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(e),o=new Map,c=new Map,h=new Set;for(const m of s.sourceIds){const g=s.getInterpolatedShapeAt(e,m);if(!g)continue;const v={...g,bounds:{...g.bounds,x:g.bounds.x+r.x,y:g.bounds.y+r.y}};o.set(m,v);const b=g.aim?this.sceneRenderer.screenPointOf(Rr.directionOf(g.aim,this.directionScratch)):{ndcX:(v.bounds.x+v.bounds.width/2)/n.width*2-1,ndcY:-((v.bounds.y+v.bounds.height/2)/n.height*2-1)},w=b!==void 0&&Math.abs(b.ndcX)<=1&&Math.abs(b.ndcY)<=1,y=w?this.sceneRenderer.decorDistancesAt(b.ndcX,b.ndcY,m):{};h.add(m),(w||g.aim)&&h.delete(m);const M=g.angular?.widthDeg??a.pxToDeg(g.bounds.width),x=this.sizeEstimateOf(m);x.add(M,y);const S=this.approachOf(t,m);c.set(m,cr.resolve({hypothesisM:this.distanceHypotheses.get(m),derivedM:S&&M>0?Ft.distanceMAt(S.widthM,M):void 0,range:x.distanceRangeAt(M),crossing:y}))}for(const[m,g]of o)for(const[v,b]of o){if(v===m||b.transparency>=1||b.bounds.width*b.bounds.height<=g.bounds.width*g.bounds.height||!(g.bounds.x>=b.bounds.x&&g.bounds.y>=b.bounds.y&&g.bounds.x+g.bounds.width<=b.bounds.x+b.bounds.width&&g.bounds.y+g.bounds.height<=b.bounds.y+b.bounds.height))continue;const y=c.get(v);y&&c.set(m,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=c;const d=s.sourceIds,u=[];for(const[m,g]of o)u.push({sourceId:m,shape:g,distanceM:c.get(m).distanceM,renderOrder:d.indexOf(m),aim:g.aim,hidden:h.has(m)||this.interpretationShown!==void 0&&(!this.comparing||g.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const p=et(t,e),f=(p?.rollDeg??0)+Ti.bodyAt(t,e,this.ufoElement.steadyBody).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:Vt.starPointsOf(t.instrument,p?.fNumber),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(e){this.showInterpretation(e),this.ufoElement.playerTitle=e?.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(e){this.inTheRound=e}get compareAccount(){return this.comparing}set compareAccount(e){e!==this.comparing&&(this.comparing=e,this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())}get confrontation(){return this.confrontationReadings}groundAlong(e,t,i){const s=this.sceneRenderer.bodyGround,n=Ne.eyeOf(this.ufoElement.sighting,i,s);return n?Ne.lineOfSightMeetsGround(n,e,t,s):void 0}bodyMaskedBy(e,t){return this.sceneRenderer.bodyMaskedByDecor(e,t)}bodyReading(e,t){const i=this.sceneRenderer.bodyGround,s=this.ufoElement.sighting,n=u=>Ne.eyeOf(s,u,i),r=new Ne(e,i,n).at(t),a=n(t);if(!r||!a)return;const o=r.eastM-a.eastM,c=r.northM-a.northM,h=r.upM-a.upM,d=Math.hypot(o,c);return{azimuthDeg:(Math.atan2(o,c)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,d)*180/Math.PI,distanceM:Math.hypot(d,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(e,t){const i=this.sceneRenderer.bodyGround,s=this.ufoElement.sighting,n=o=>Ne.eyeOf(s,o,i),r=new Ne(e,i,n).at(t),a=n(t);return r&&a?ri.projectionOf(r,a):void 0}directionToDecor(e){return this.sceneRenderer.directionToDecor(e)}directionToBody(e,t){const i=this.sceneRenderer.bodyGround,s=this.ufoElement.sighting,n=f=>Ne.eyeOf(s,f,i),r=new Ne(e,i,n),a=r.at(t)?t:e.track[0]?.t,o=a===void 0?void 0:r.at(a),c=a===void 0?void 0:n(a);if(!o||!c)return;const h=o.eastM-c.eastM,d=o.northM-c.northM,u=o.upM-c.upM,p=Math.hypot(h,d);if(!(p===0&&u===0))return{azimuthDeg:(Math.atan2(h,d)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(u,p)*180/Math.PI}}placeBodiesAt(e,t){const i=this.interpretationShown,s=this.ufoElement.sighting;let n=[],r=[];const a=this.sceneRenderer.bodyGround,o=f=>Ne.eyeOf(s,f,a);i&&(n=i.bodies.map(f=>new Ne(f,a,o).at(e)).filter(f=>f!==void 0));const c=Ts(s,e),h=c.windDirectionDeg*Math.PI/180,d={x:c.windSpeed*Math.sin(h),z:-c.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(n,e/1e3,i?.bodies.map(f=>f.id)??[],i?.smoke??[],d);const u=i&&this.comparing?o(e):void 0;if(u&&(r=new ri(s.timeline,this.confrontationTolerance,ri.sizeHows(s.timeline,s.provenance),Cr.seeingOf(s)).at(e,n,u,f=>f.outlineNode?this.sceneRenderer.bodyOutline?.(f.id,f.outlineNode):void 0)),this.confrontationReadings=r,!t)return;const p=JSON.stringify(r);p!==this.confrontationSignature&&(this.confrontationSignature=p,this.dispatchEvent(new CustomEvent(r_,{detail:r})))}async pictureAt(e,t=640){const i=document.createElement("canvas");i.width=t,i.height=Math.round(t*(this.sceneCanvas.height||9)/(this.sceneCanvas.width||16));let s=!1;for(const n of[1200,0]){this.showAt(e),s=!1;for(let r=0;r<900&&!s;r++)await new Promise(a=>requestAnimationFrame(()=>a())),s=this.snapshotTo(i);if(!s)return;n&&await new Promise(r=>setTimeout(r,n))}return i.toDataURL("image/jpeg",.85)}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!i)return{};const s=i.angular?.widthDeg??this.projectionAt(t).pxToDeg(i.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(s)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}updateLightning(e,t,i){if(this.ensureLightningSchedule(e),this.sceneRenderer.updateLightning(t),i)return;const s=this.lastLightningT;if(this.lastLightningT=t,s===void 0||t<s||this.ufoElement.playbackState!=="playing")return;const n=this.lightningFlashes.filter(r=>r.t>s&&r.t<=t).pop();n&&Ts(e,n.t).storm&&this.handleLightningFlash(n)}ensureLightningSchedule(e){const t=Ts(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const s=e.event.time,n=e.event.place?.[0],r=s?.year!==void 0?js(s,n?.lng??0,e.event.utcOffsetHours):void 0,a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round((r?.getTime()??0)/1e3)+Math.round((n?.lat??0)*1e3)+7;this.lightningFlashes=Ks.schedule({durationMs:a,seed:o,intensity:t}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],i=e.event.time;return JSON.stringify([t?.lat,t?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration,e.skySources])}scheduleMeteors(e){const t=e.event.place?.[0],i=e.event.time,s=t?.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?js(i,t.lng,e.event.utcOffsetHours):void 0;if(!s||t?.lat===void 0||t.lng===void 0||e.skySources===!1){this.sceneRenderer.setMeteorShower([],0,0);return}const n={lat:t.lat,lng:t.lng,elevationM:0},r=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,a=Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3),o=ls.schedule({ratePerHour:ls.observedRatePerHour(ls.apexPosition(s,n).altitudeDeg),durationMs:r,velocityKmS:ls.TYPICAL_VELOCITY_KM_S,seed:a}),c=cu.activeAt(s).map(d=>{const u=cu.radiantPosition(d.shower,s,n);return{entry:d,position:u,rate:cu.observedRatePerHour(d.zhr,u.altitudeDeg,d.shower.populationIndex)}}).sort((d,u)=>u.rate-d.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(o,0,0);return}const h=pa.schedule({ratePerHour:c.rate,durationMs:r,velocityKmS:c.entry.shower.velocityKmS,seed:a+1});this.sceneRenderer.setMeteorShower([...h,...o],c.position.altitudeDeg,c.position.azimuthDeg)}groundHides(e,t){return this.sceneRenderer.groundHidesDirection(e,t)}get groundKey(){return this.sceneRenderer.groundKey}meteorByRank(e,t=Number.POSITIVE_INFINITY){this.ensureMeteorSchedule(this.ufoElement.sighting);const i=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).filter(r=>pa.magnitudeOf(r)<=t).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 s=i[e%i.length],n=this.sceneRenderer.meteorMidpoint(s);if(n)return{t:Math.round(s.t+s.durationMs*.45),...n}}lensOpticsAt(e){const t=this.ufoElement.sighting,i=t.instrument,s=i.frame,n=et(t,e),r=n?.fNumber??i.fNumber;if(!s||r===void 0)return;const a=Vt.focalLengthMmFor(i,Li.fovOf(t,e));if(a!==void 0)return{focalLengthMm:a,fNumber:r,focusDistance:n?.focusDistanceM??0,frameHeightMm:s.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return jr.of(t.instrument,Ft.CANVAS_HEIGHT_PX,Li.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new kU,this.sizeEstimates.set(e,t)),t}}const Bf="rr0-scene";function a_(){gv(),customElements.get(Bf)||customElements.define(Bf,At)}const fz=Object.freeze(Object.defineProperty({__proto__:null,AIRCRAFT_CHANGE_EVENT:FM,CONFRONTATION_EVENT:r_,FIREBALLS_CHANGE_EVENT:PM,REFERENCES_CHANGE_EVENT:NM,SATELLITES_CHANGE_EVENT:LM,SCENE_ELEMENT_NAME:Bf,SceneElement:At,registerScene:a_},Symbol.toStringTag,{value:"Module"}));class zU{constructor(e,t,i){this.container=e,this.aim=t,this.compassPoint=i}rows=new Map;selected;show(e,t,i=!1){const s=e.length===this.rows.size&&e.every(n=>this.rows.has(n.key));(i||!s)&&this.build(e,t);for(const n of e)this.write(this.rows.get(n.key),n,t)}get selectedKey(){return this.selected}select(e,t){this.selected=e;for(const i of this.rows.values())this.write(i,i.flight,t)}build(e,t){if(this.rows=new Map,e.some(p=>p.key===this.selected)||(this.selected=void 0),e.length===0){this.container.replaceChildren();return}const i=document.createElement("p");i.className="message-info",i.textContent=e.every(p=>p.declared)?t.aircraftFlightsDeclaredIntro:t.aircraftFlightsIntro;const s=document.createElement("table");s.className="aircraft-flights-table";const n=s.createTHead().insertRow(),{flight:r,distance:a,direction:o,height:c,altitude:h}=t.aircraftFlightsColumns;for(const p of[r,a,o,c,h]){const f=document.createElement("th");f.scope="col",f.textContent=p,n.append(f)}const d=s.createTBody();for(const p of e){const f=d.insertRow();f.dataset.flight=p.key;const m=f.insertCell(),g={distance:f.insertCell(),direction:f.insertCell(),height:f.insertCell(),altitude:f.insertCell()};f.addEventListener("click",()=>{const v=this.rows.get(p.key)?.flight;v&&this.aim(v)}),this.rows.set(p.key,{row:f,flight:p,label:m,...g})}const u=document.createElement("div");u.className="aircraft-flights-scroll",u.append(s),this.container.replaceChildren(i,u)}write(e,t,i){if(e.flight=t,e.label.textContent=[t.type??i.aircraftFlightUnknown,t.registration].filter(Boolean).join(" · "),t.declared){const d=document.createElement("span");d.className="flight-basis",d.textContent=i.aircraftFlightDeclared,e.label.append(" ",d)}const{row:s}=e,n=t.sky,r=(d,u=0)=>d.toLocaleString(void 0,{maximumFractionDigits:u});e.distance.textContent=n?`${r(n.distanceKm,n.distanceKm<10?1:0)} km`:"",e.direction.textContent=n?`${this.compassPoint(n.azimuthDeg)} ${r(n.azimuthDeg)}°`:"",e.height.textContent=n?`${r(n.altitudeDeg,1)}°`:"",e.altitude.textContent=t.altitudeFt!==void 0?`${r(t.altitudeFt)} ft`:"",s.classList.toggle("absent",!n),s.setAttribute("aria-disabled",String(!n&&t.firstMs===void 0));const a=n?i.aircraftFlightAim:t.firstMs!==void 0?i.aircraftFlightLater:i.aircraftFlightAbsent,o=t.key===this.selected;s.setAttribute("aria-selected",String(o));const c=o?i.aircraftFlightMarked:a,h=t.drawn||t.declared?c:`${c}. ${i.aircraftFlightNotDrawn}`;s.title=t.declared?`${i.aircraftFlightDeclaredHint}. ${h}`:h}}class UM{constructor(e,t,i=UM.TOLERANCE_PX){this.timeline=e,this.clock=t,this.tolerancePx=i}static TOLERANCE_PX=1;currentPointer=null;shapePrototype=null;sourceId="";samples=[];start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.samples=[],this.clock.start(i=>this.recordSample(i))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop(),this.thin()}thin(){const e=this.samples;if(e.length<=2)return;const t=new Set([0,e.length-1]),i=[[0,e.length-1]];for(;i.length>0;){const[s,n]=i.pop(),r=e[s],a=e[n];let o=0,c=-1;for(let h=s+1;h<n;h++){const d=e[h],u=(d.t-r.t)/(a.t-r.t),p=Math.hypot(r.x+(a.x-r.x)*u-d.x,r.y+(a.y-r.y)*u-d.y);p>o&&(o=p,c=h)}c!==-1&&o>this.tolerancePx&&(t.add(c),i.push([s,c],[c,n]))}e.forEach((s,n)=>{t.has(n)||this.timeline.removeShapeAt(s.t,this.sourceId)}),this.samples=[]}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=jT(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}]),this.samples[this.samples.length-1]?.t===e&&this.samples.pop(),this.samples.push({t:e,x:this.currentPointer.x,y:this.currentPointer.y})}}class HU{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const i=performance.now()-this.startTime;i-this.lastTick>=this.intervalMs&&(this.lastTick=i,e(i)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}class Zo{constructor(e,t,i,s={}){this.id=e,this.aspect=t,this.parts=i,this.minimum=s}static ALL=[new Zo("triangle",.9,[{points:[[.5,0],[1,1],[0,1]],fx:0,fy:0,fw:1,fh:1}]),new Zo("saucer",.6,[{part:"dome",fx:.28,fy:0,fw:.44,fh:.62},{part:"disc",fx:0,fy:.42,fw:1,fh:.42}]),new Zo("cigar",.25,[{fx:0,fy:0,fw:1,fh:1}]),new Zo("chevron",.55,[{points:[[.5,0],[1,1],[.5,.6],[0,1]],fx:0,fy:0,fw:1,fh:1}]),new Zo("light",1,[{fx:.3,fy:.3,fw:.4,fh:.4}],{haloScale:2.5,brightness:.5})];static byId(e){return Zo.ALL.find(t=>t.id===e)}get partNames(){return this.parts.map(e=>e.part)}boundsAt(e){const t=e.width*this.aspect;return{x:e.x,y:e.y+e.height/2-t/2,width:e.width,height:t}}shapesIn(e,t){return this.parts.map(i=>{const s={x:e.x+i.fx*e.width,y:e.y+i.fy*e.height,width:i.fw*e.width,height:i.fh*e.height};return{...i.points?qT(s,i.points.map(([r,a])=>({x:r*s.width,y:a*s.height})),t.color):YT(s,t.color),transparency:t.transparency,haloScale:Math.max(t.haloScale,this.minimum.haloScale??0),blur:t.blur,brightness:Math.max(t.brightness,this.minimum.brightness??0)}})}}const YA="rr0-provider-settings",GU=`
|