@rr0/ufoathome 0.197.0 → 0.198.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist-embed-scene/rr0-scene.mjs +122 -122
  2. package/dist-embed-sighting/{CaseReportExport-CCjvTS2q.js → CaseReportExport-BetcYOov.js} +1 -1
  3. package/dist-embed-sighting/rr0-sighting.mjs +300 -286
  4. package/dist-embed-sighting-editor/{CaseEditorMessages_en-u4MyW2Ah.js → CaseEditorMessages_en-CpJLWbJD.js} +1 -1
  5. package/{dist-embed-ufoathome/CaseEditorMessages_es-BuLTG_5Q.js → dist-embed-sighting-editor/CaseEditorMessages_es-C5YOqVpF.js} +1 -1
  6. package/{dist-embed-ufoathome/CaseEditorMessages_fr-Car1_lOm.js → dist-embed-sighting-editor/CaseEditorMessages_fr-rMlMgrqV.js} +1 -1
  7. package/{dist-embed-ufoathome/CaseEditorMessages_it-DAHTKU_c.js → dist-embed-sighting-editor/CaseEditorMessages_it-Bkiv2Hun.js} +1 -1
  8. package/dist-embed-sighting-editor/CaseElement-IzaexO7n.js +121 -0
  9. package/dist-embed-sighting-editor/{CaseReportExport-CAEcShgX.js → CaseReportExport-U-dk4A7z.js} +1 -1
  10. package/dist-embed-sighting-editor/{SightingElement-Ddf6hzfp.js → SightingElement-BhyoU_gg.js} +3 -3
  11. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +214 -192
  12. package/dist-embed-ufoathome/{AdsbLolArchiveProvider-B-IiOm3p.js → AdsbLolArchiveProvider-CUkfGJbL.js} +1 -1
  13. package/dist-embed-ufoathome/{BallesterGuaspAssessor-CKFQRcfa.js → BallesterGuaspAssessor-CB2F8A6P.js} +1 -1
  14. package/dist-embed-ufoathome/{BeamEditor-BWkQrCPy.js → BeamEditor-Q_m3KK0S.js} +1 -1
  15. package/dist-embed-ufoathome/{BeamSystem-D6XsTULo.js → BeamSystem-CVMU5DeE.js} +1 -1
  16. package/dist-embed-ufoathome/{BirdEditor-6vr7bLHy.js → BirdEditor-07sg3Pt0.js} +1 -1
  17. package/dist-embed-ufoathome/{BodyEditor-D1odTty_.js → BodyEditor-BwsMj37A.js} +1 -1
  18. package/dist-embed-ufoathome/{CaseEditorElement-3g_c6R7G.js → CaseEditorElement-BrcX9sp0.js} +130 -113
  19. package/dist-embed-ufoathome/{CaseEditorMessages_en-u4MyW2Ah.js → CaseEditorMessages_en-CpJLWbJD.js} +1 -1
  20. package/{dist-embed-sighting-editor/CaseEditorMessages_es-BuLTG_5Q.js → dist-embed-ufoathome/CaseEditorMessages_es-C5YOqVpF.js} +1 -1
  21. package/{dist-embed-sighting-editor/CaseEditorMessages_fr-Car1_lOm.js → dist-embed-ufoathome/CaseEditorMessages_fr-rMlMgrqV.js} +1 -1
  22. package/{dist-embed-sighting-editor/CaseEditorMessages_it-DAHTKU_c.js → dist-embed-ufoathome/CaseEditorMessages_it-Bkiv2Hun.js} +1 -1
  23. package/dist-embed-ufoathome/CaseElement-Ca8ctACA.js +121 -0
  24. package/dist-embed-ufoathome/{CaseReportExport-ZNhCiJjJ.js → CaseReportExport--IhmS67e.js} +3 -3
  25. package/dist-embed-ufoathome/{ColumnResize-UnDz8hFM.js → ColumnResize-CMfGWQHi.js} +20 -15
  26. package/dist-embed-ufoathome/{ContrailSystem-1Y9tarlk.js → ContrailSystem-CuFduINP.js} +1 -1
  27. package/dist-embed-ufoathome/{ControlPasses-CNOyd9SV.js → ControlPasses-BS7yyZOR.js} +1 -1
  28. package/dist-embed-ufoathome/{CoverageAssessor-BDtOq9aQ.js → CoverageAssessor-BwXJv4OD.js} +1 -1
  29. package/dist-embed-ufoathome/{DroneEditor-C3SH8yYq.js → DroneEditor-ByVlCauS.js} +1 -1
  30. package/dist-embed-ufoathome/{Flightradar24Provider-2yiCbULq.js → Flightradar24Provider-Cd4o260r.js} +1 -1
  31. package/dist-embed-ufoathome/{GLTFLoader-BTxAZ2H9.js → GLTFLoader-BegH9SUA.js} +1 -1
  32. package/dist-embed-ufoathome/{GeoJsonExport-taSDSkPz.js → GeoJsonExport-Czm1iAIW.js} +1 -1
  33. package/dist-embed-ufoathome/{GeographicFigures-BTNgtesN.js → GeographicFigures-CKg7JYgf.js} +1 -1
  34. package/dist-embed-ufoathome/{HeadlightSystem-DrcLjLtQ.js → HeadlightSystem-DIk-C7_5.js} +1 -1
  35. package/dist-embed-ufoathome/{HynekAssessor-B29m-sN8.js → HynekAssessor-BybLMdda.js} +1 -1
  36. package/dist-embed-ufoathome/{InterviewEditorElement-2QYSmoHm.js → InterviewEditorElement-CbTakhyi.js} +1 -1
  37. package/dist-embed-ufoathome/{InterviewElement-dtYF5S-4.js → InterviewElement-fI19BieO.js} +1 -1
  38. package/dist-embed-ufoathome/{KmlExport-BmpKnlBj.js → KmlExport-De-2dnYz.js} +1 -1
  39. package/dist-embed-ufoathome/{LanternEditor-BaRDgTw-.js → LanternEditor-BRqgj1S6.js} +1 -1
  40. package/dist-embed-ufoathome/{LaserBeam-ejbRCvnX.js → LaserBeam-CouNB7Pe.js} +1 -1
  41. package/dist-embed-ufoathome/{LaunchEditor-DlL4ZqRi.js → LaunchEditor-BNInX90c.js} +1 -1
  42. package/dist-embed-ufoathome/{LaunchPlume-oAya2eEa.js → LaunchPlume-DVxzb0wy.js} +1 -1
  43. package/dist-embed-ufoathome/{LaunchSimulation-DkwJLwOo.js → LaunchSimulation-CCvSd6qD.js} +1 -1
  44. package/dist-embed-ufoathome/{ModelSource-B_nU_FPQ.js → ModelSource-BZ1U1VU1.js} +1 -1
  45. package/dist-embed-ufoathome/{ModelThumbnails-DaDiyuM2.js → ModelThumbnails-Ckdb3qoW.js} +1 -1
  46. package/dist-embed-ufoathome/{ModelViewer-iv0GdyTZ.js → ModelViewer-B9PZN5c7.js} +1 -1
  47. package/dist-embed-ufoathome/{ModuleConformance-BDZbbpPz.js → ModuleConformance-8JN5JVgE.js} +2 -2
  48. package/dist-embed-ufoathome/{ModuleSession-DbiU7Mg7.js → ModuleSession-ClSpEZMn.js} +3 -3
  49. package/dist-embed-ufoathome/{ModuleThree-CLOnw_DZ.js → ModuleThree-CRG8PTLA.js} +1 -1
  50. package/dist-embed-ufoathome/{ModulesPanelElement-CMyuCril.js → ModulesPanelElement-D4Hos-mF.js} +3 -3
  51. package/dist-embed-ufoathome/{NearestApproach-DM8py_qI.js → NearestApproach-DrJN7h_1.js} +1 -1
  52. package/dist-embed-ufoathome/{ParameterForm-DfpJQGku.js → ParameterForm-DcVFxrcO.js} +1 -1
  53. package/dist-embed-ufoathome/{PictureRegistration-rU4sVWnY.js → PictureRegistration-LxhNTA4v.js} +1 -1
  54. package/dist-embed-ufoathome/{PoherAssessor-DXsufNSL.js → PoherAssessor-RyKMyps7.js} +1 -1
  55. package/dist-embed-ufoathome/{RailwaySystem-DZ1rEPSL.js → RailwaySystem-BOQvJ2r4.js} +1 -1
  56. package/dist-embed-ufoathome/{ReentryEditor-BVDyVhGo.js → ReentryEditor-B1H_TUMf.js} +1 -1
  57. package/dist-embed-ufoathome/{ReentrySimulation-DFisNsmn.js → ReentrySimulation-C7XZlAED.js} +1 -1
  58. package/dist-embed-ufoathome/{ReferenceSystem-DnHhAxWO.js → ReferenceSystem-BcsjHgaw.js} +1 -1
  59. package/dist-embed-ufoathome/{RoadMarkings-BsN3rh0W.js → RoadMarkings-DDRxawvf.js} +1 -1
  60. package/dist-embed-ufoathome/SaidPosition-CXZLm-ck.js +4 -0
  61. package/dist-embed-ufoathome/{ShareDialogElement-C5QkyK7i.js → ShareDialogElement-DHlxoHWP.js} +13 -13
  62. package/dist-embed-ufoathome/{Sighting-CBpJpdm9.js → Sighting-Ch4eiBNK.js} +1 -1
  63. package/dist-embed-ufoathome/{SightingElement-cd7C-Ge-.js → SightingElement-COJwKNNg.js} +3 -3
  64. package/dist-embed-ufoathome/{TimelineTracks-X_GEZi12.js → TimelineTracks-BgZmkKhn.js} +1 -1
  65. package/dist-embed-ufoathome/{TraceSystem-CM4QYSkU.js → TraceSystem-BBCpq8-v.js} +1 -1
  66. package/dist-embed-ufoathome/{VideoButton-CZlR9Bk0.js → VideoButton-CGQI7iUA.js} +1 -1
  67. package/dist-embed-ufoathome/{WaterSystem-C8MrXEEk.js → WaterSystem-BrIS0Wzy.js} +1 -1
  68. package/dist-embed-ufoathome/rr0-ufoathome.mjs +3 -3
  69. package/dist-embed-ufoathome/{surroundingsSources-CKDz9k9A.js → surroundingsSources-Dg6vMWL7.js} +1 -1
  70. package/dist-embed-ufoathome/{trafficRuntime-AtbE4bAN.js → trafficRuntime-BT5Ol_v5.js} +1 -1
  71. package/package.json +1 -1
  72. package/dist-embed-sighting-editor/CaseElement-DYeBpKhp.js +0 -112
  73. package/dist-embed-ufoathome/CaseElement-CZzC4Bj8.js +0 -112
  74. package/dist-embed-ufoathome/SaidPosition-CWiVNaNW.js +0 -4
@@ -1,2 +1,2 @@
1
- import{aT as et,aU as g,aV as It,aW as Z,p as j,aX as N,aY as Dt,aZ as st,a_ as it}from"./ShareDialogElement-C5QkyK7i.js";import{C as ot}from"./ContrailGrowth-DwHS8If9.js";import{U as Ae}from"./upperAirSources-BGuLpdwu.js";import{p as V,r as Tt}from"./Decor-Dn-cvniW.js";import{l as at}from"./SaidPosition-CWiVNaNW.js";import"./rr0-ufoathome.mjs";import"./Sighting-CBpJpdm9.js";import"./VisualAids-DI-hEL46.js";import"./RecordingIssue-BlWT8Xsu.js";import"./Obstacles-v9SkfBD7.js";const Rt=.25,rt=.4,ct=6,X=12,Bt=3,lt=.2,vt=.2,ht=24,Nt=3,Ct=24,ut=1,_t=.7,Ht=1.5,wt=.8,yt=1.3,dt=.02,Pt=700,kt=-30,pt=.9,mt=5,Lt=25,Ft=.5,jt=.12,Mt=[.13,.31],Gt=.16,Ut=1.6,Kt=2,zt=3.6,At=1.1,Wt=.3,Vt=1e3,gt=.7,Xt=.7;class Y{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const i=t.createGain(),o=e.character?.modulationDepth??0;i.gain.value=1-o/2;const r=t.createOscillator();r.type="sine";const l=t.createGain();l.gain.value=o/2,r.connect(l).connect(i.gain),i.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*ct*.5;const u=[],d=[],h=[];for(const D of g.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=ut;const H=t.createBiquadFilter();H.type="bandpass",H.frequency.value=D,H.Q.value=ut;const P=t.createGain();P.gain.value=0,c.connect(I).connect(H).connect(P).connect(i),u.push(I),d.push(H),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let H=1;H<=Nt;H++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*H;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:H,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const E=Mt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??lt;const B=t.createBufferSource();B.buffer=this.roughTable(t,Bt),B.loop=!0,B.loopStart=Math.random()*X*.5,B.connect(O).connect(i.gain);const v=t.createGain();v.gain.value=(e.character?.roughness??lt)*vt;const S=t.createBufferSource();S.buffer=this.roughTable(t,ht),S.loop=!0,S.loopStart=Math.random()*X*.5,S.connect(v).connect(i.gain);let F;const x=this.busOf(t)&&this.reverb;x&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(x));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(dt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Pt,I.gain.value=0;const H=t.createGain();H.gain.value=0,a.connect(D).connect(I).connect(H).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ht),_.loop=!0,_.loopStart=Math.random()*X*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:H}}const k=[c,B,S,r,...p.map(D=>D.oscillator),...E,..._?[_]:[]];for(const D of k)D.start();const $={nodes:[a,i,l,O,v,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:r,lfoDepth:l,wander:E,wanderDepth:m,roughDepth:O,crackleDepth:v,beat:i,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,$),$}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Rt),i=Math.min(Ht,Math.max(_t,a.dopplerRatio)),o=Math.min(yt,Math.max(wt,Math.sqrt(a.dopplerRatio))),r=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*Y.unweighting(g.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-mt)/(Lt-mt)));g.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(r,p*o)),s(e.seconds[m].frequency,Math.min(r,p*o)),s(e.gains[m].gain,l[m]*Math.sqrt(Vt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:E,baseHz:O,share:B}of e.tones){const v=O*E;s(p.frequency,v*i);const S=v*i;s(m.gain,S<r?B*Gt*l[Y.bandOf(S)]/E:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*i);const h=c>0?Y.saturated(c)/c:1;if(s(e.output.gain,h*(1-Wt*u)),s(e.wanderDepth.gain,h*jt*u/Mt.length),e.send&&s(e.send.gain,Y.reverbSend(a.distanceKm)),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(dt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(kt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-pt,Math.min(pt,Math.sin(p)))*(1-Ft*u);s(e.panner.pan,m)}}static saturated(t){const e=Xt*gt;if(t<=e)return t;const a=gt-e;return e+a*(1-Math.exp(-(t-e)/a))}static reverbSend(t){return Math.min(Ut,Math.sqrt(Math.max(0,t)/Kt))}static unweighting(t){return 10**(Math.min(Ct,Math.max(0,-g.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return g.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/g.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*X),s=t.createBuffer(1,n,t.sampleRate),i=s.getChannelData(0),o=Array.from({length:X*e},()=>(Math.random()*2-1)**3),r=t.sampleRate/e;for(let l=0;l<i.length;l++){const c=l/r,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);i[l]=o[u%o.length]*(1-h)+o[(u+1)%o.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*zt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let i=0;for(let o=0;o<e;o++){const r=o/t.sampleRate,l=.6*Math.exp(-r/(At*2))+.04;i+=l*(Math.random()*2-1-i),s[o]=i*Math.exp(-r/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,rt/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},rt*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*ct,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=It.find(h=>h.id===(n?"helicopter":"airliner")).create(),[i,o]=n?[5,7]:[17,18],r=t.spanM/2/i,l=t.lengthM/2/o,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*r,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const i=C.LANDING_INTENSITY*n,o=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?i:0}]:[]),r=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*r,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?i:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:o}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class J{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(J.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?J.BY_TYPE.get(t.toUpperCase()):void 0}}class R{static ID_PREFIX=Z.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=R.MAX_OBJECTS,s={}){return new Yt(t,e,a,n,s).build()}static idOf(t,e){return Z.idOf(t,e)}static keyOf(t){return Z.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*R.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*R.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*R.DEG);return{eastM:s*Math.sin(a.azimuthDeg*R.DEG),northM:s*Math.cos(a.azimuthDeg*R.DEG),upM:n*Math.sin(a.altitudeDeg*R.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/R.DEG+360)%360}}class Yt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=R.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);R.segments(a).forEach((i,o)=>{const r=i.map(h=>({point:h,at:R.offsetOf(this.observer,h)}));if(!r.some(h=>h.at.altitudeDeg>=0))return;const l=r.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<r.length?R.bearingDeg(h.at,r[p+1].at):R.bearingDeg(r[p-1].at,h.at))})),c=R.idOf(a,o),u=r[Math.floor(r.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:R.sizeOf(s),model:J.idOf(s.code)?{id:J.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,i.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:i},closestKm:Math.min(...r.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const qt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],Jt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],bt=.16,xt=1,$t=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],Zt=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],Qt=1.5,Et=-40,te=1.5,ee={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class w{static bandsDb(t,e,a=340){const n=ee[e],s=w.fan(t)-w.fan(90),i=.62*Math.max(0,n.jetMps-n.flightMps)/a,o=-30*Math.log10(1+i/(1+i**5)**.2*Math.cos(t*Math.PI/180));return g.OCTAVES.map((r,l)=>{const c=o+w.jetRemainder(t,r*te/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=w.loudest.get(t);if(e)return e;const a=g.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)w.bandsDb(n,t).forEach((s,i)=>a[i]=Math.max(a[i],s));return w.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,i,o)=>s+i*e[o],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=w.read($t,t,!0),a=w.read(Zt,t,!0)+Qt;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/bt)/Math.log(xt/bt)));return(1-a)*w.read(qt,t)+a*w.read(Jt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[i,o]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=o[0])return a?Math.max(Et,o[1]+(o[1]-i[1])/(o[0]-i[0])*(e-o[0])):o[1];for(let r=1;r<t.length;r++){const[l,c]=[t[r-1],t[r]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return o[1]}}class A{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=A.GRASS){const[n,s]=A.impedance(t,a);return A.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=A.GRASS){const a=A.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,i,o]=[t*a-1,e*a,t*a+1,e*a],r=i*i+o*o;return{re:(n*i+s*o)/r,im:(s*i-n*o)/r}}static delayS(t,e=A.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=A.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=A.overheads.get(n);return s||A.overheads.set(n,s=A.bandsDb(90,e,a)),A.bandsDb(t,e,a).map((i,o)=>i-s[o])}static echo(t,e=A.GRASS,a=340){const n=A.delayS(t,e,a);if(n<=A.ECHO_UNDER_S)return;const s=Math.min(1,(n-A.ECHO_UNDER_S)/(A.ECHO_FROM_S-A.ECHO_UNDER_S)),i=s*s*(3-2*s),o=r=>{const l=A.reflection(r,t,e);return i*A.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:o(A.LOW_HZ),highGain:o(A.HIGH_HZ),jitterS:A.JITTER_S}}static overheads=new Map;static thirds=g.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=A.delayS(t,e,a),s=A.COHERENCE,i=Math.sin(Math.max(0,t)*Math.PI/180);let o=A.impedances.get(e.flowResistivityKPa);return o||A.impedances.set(e.flowResistivityKPa,o=A.thirds.map(r=>r.map(l=>A.impedance(l.middle,e)))),A.thirds.map((r,l)=>{let c=0;return r.forEach((u,d)=>{const h=A.reflected(o[l][d][0],o[l][d][1],i),p=2*Math.PI*n*(u.to-u.from),[m,E]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*E)}),10*Math.log10(c/r.length)})}}const q={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},ae={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Ot=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:q},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:ae},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:q},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:q},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:q},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ft=(b,t)=>b.map(e=>e+t-g.sumDb(b));function ne(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const St=Ot.map(b=>{const t=b.regimes===q?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:ft(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:ft(b.shapeDb.map((i,o)=>i+s.shapeDb[o]),b.totalDbA+s.levelDb),character:ne(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Dt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Ot.find(a=>a.kinds.includes(t));return St.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=g.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return g.OCTAVES.map((s,i)=>t.soundPowerA[i]-n-g.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=g.STANDARD,s){const i=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([r,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?w.loudestDb(r)[u]:0)).some((c,u)=>c>=Math.max(i[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=g.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??g.STANDARD,i=g.speedOfSound(s.temperatureC),o=t.points[t.points.length-1]?.t;if(o===void 0)return;let r=Math.min(a,o),l=N.positionAt(t,r);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/i,$=Math.abs(k-r);if(r=k,l=N.positionAt(t,r),!l)return;if(c=j.seenFrom(e,l.geo),$<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,r,e),p=M.inRegime(n.noise??St[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,E=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,r),B=p.directivity==="turbofan"?w.bandsDb(O,h,i):void 0,v=n.ground===null?g.OCTAVES.map(()=>0):A.excessDb(c.altitudeDeg,n.ground,i),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(B?.[k]??0)+v[k]),F=S.map((_,k)=>_>=Math.max(E[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),x=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:g.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-r)/1e3,emittedAtMs:r,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,r,i),dominantHz:g.OCTAVES[x],cutoffHz:L<0?void 0:g.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),i=N.positionAt(t,a+n),o=N.positionAt(t,a);if(!s||!i||!o)return 90;const r=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,E=h.distanceKm*1e3;return[E*Math.cos(p)*Math.sin(m),E*Math.cos(p)*Math.cos(m),E*Math.sin(p)]},[l,c,u]=[r(s.geo),r(i.geo),r(o.geo)];return w.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),i=N.positionAt(t,e+n)??N.positionAt(t,e),o=N.positionAt(t,e);if(!s||!i||!o)return"overflight";const r=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(r<=0)return"overflight";const l=(i.altitudeFt-s.altitudeFt)*.3048/r;return o.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,i={}){const o=[];let r,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,i);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?r?r.untilMs=u:o.push(r={fromMs:u,untilMs:u}):r=void 0}return{track:t,audible:o,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,i]=a(t),[o,r,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*o+s*r+i*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,i=N.positionAt(t,a-s),o=N.positionAt(t,a+s);if(!i||!o)return 1;const r=j.seenFrom(e,i.geo).distanceKm*1e3,l=j.seenFrom(e,o.geo).distanceKm*1e3;return 1/(1-(r-l)/(2*s/1e3)/n)}}class pe{static at(t,e,a,n,s={}){const i=N.seenFrom(t,a,n);if(!i)return;const o=U.of(e),r=M.heardAt(t,a,n,{noise:M.noiseOfKind(o.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:o.code??e?.type,name:o.basis==="nothing"?void 0:o.name,kind:o.kind,basis:o.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:i.altitudeFt,groundSpeedKt:i.groundSpeedKt,trackDeg:i.trackDeg,sky:i.sky,angularRateDegPerS:i.angularRateDegPerS,hearing:r&&{audible:r.audible,levelDbA:r.levelDbA,ambientDbA:r.ambientDbA,delayS:r.delayS,lagDeg:r.lagDeg,dopplerRatio:r.dopplerRatio,cutoffHz:r.cutoffHz,dominantHz:r.dominantHz}}}}class T{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Dt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const i=new Set;for(const[o,r]of t){const l=M.noiseOfKind(U.of(e.get(a(r))).kind);let c=1/0;for(const u of r.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&i.add(o)}return i}static voices(t,e,a,n,s,i,o={}){const r=[];for(const l of t){const c=e.get(l);if(!c||o.only?.(l)===!1)continue;const u=o.kindOf?.(l)??U.of(a.get(n(c))).kind,d=o.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,i,{...o,noise:d});if(!h?.audible)continue;const p=o.throughDb,m=p?h.bandsDbA.map((E,O)=>E-(p[O]??0)):h.bandsDbA;p&&!T.noticed(m,h.ambientDbA,o.ambientShapeDb)||r.push({id:l,kind:u,bandAmplitudes:T.bandAmplitudes(m,h.ambientDbA,o.referenceAmplitude,{ambientShapeDb:o.ambientShapeDb,expandUnderKnee:o.expandUnderKnee}),levelDbA:p?g.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:o.ground===null?void 0:A.echo(h.sound.altitudeDeg,o.ground,g.speedOfSound((o.air??g.STANDARD).temperatureC))})}return r.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,o.maxVoices??T.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,i)=>s>=n[i]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=T.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),i=n.expandUnderKnee===!1?1:T.EXPANSION_RATIO,o=M.DETECTION_MARGIN_DB,r=g.sumDb(t),l=r-e,c=l>=T.KNEE_DB?T.KNEE_DB+(l-T.KNEE_DB)/T.COMPRESSION_RATIO:T.KNEE_DB-(T.KNEE_DB-l)*i,u=a*10**((c-T.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-o+T.MASKING_RANGE_DB)/(2*T.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-r)/20)})}static BANDS_HZ=g.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),i=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),o=[],r=[t.registration,t.name].filter(Boolean).join(" · ");o.push(r||i(e.unnamed,{hex:t.hex}));const l=[i(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:i(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:i(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);o.push(l.join(" · ")),o.push(i(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)o.push(e.soundUnknown);else if(!c.audible)o.push(i(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":i(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});o.push(i(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:i(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&o.push(i(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&o.push(u.join(" · ")),o.push(e.candidate),o.join(`
1
+ import{aT as et,aU as g,aV as It,aW as Z,p as j,aX as N,aY as Dt,aZ as st,a_ as it}from"./ShareDialogElement-DHlxoHWP.js";import{C as ot}from"./ContrailGrowth-DwHS8If9.js";import{U as Ae}from"./upperAirSources-BGuLpdwu.js";import{p as V,r as Tt}from"./Decor-Dn-cvniW.js";import{l as at}from"./SaidPosition-CXZLm-ck.js";import"./rr0-ufoathome.mjs";import"./Sighting-Ch4eiBNK.js";import"./VisualAids-DI-hEL46.js";import"./RecordingIssue-BlWT8Xsu.js";import"./Obstacles-v9SkfBD7.js";const Rt=.25,rt=.4,ct=6,X=12,Bt=3,lt=.2,vt=.2,ht=24,Nt=3,Ct=24,ut=1,_t=.7,Ht=1.5,wt=.8,yt=1.3,dt=.02,Pt=700,kt=-30,pt=.9,mt=5,Lt=25,Ft=.5,jt=.12,Mt=[.13,.31],Gt=.16,Ut=1.6,Kt=2,zt=3.6,At=1.1,Wt=.3,Vt=1e3,gt=.7,Xt=.7;class Y{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const i=t.createGain(),o=e.character?.modulationDepth??0;i.gain.value=1-o/2;const r=t.createOscillator();r.type="sine";const l=t.createGain();l.gain.value=o/2,r.connect(l).connect(i.gain),i.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*ct*.5;const u=[],d=[],h=[];for(const D of g.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=ut;const H=t.createBiquadFilter();H.type="bandpass",H.frequency.value=D,H.Q.value=ut;const P=t.createGain();P.gain.value=0,c.connect(I).connect(H).connect(P).connect(i),u.push(I),d.push(H),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let H=1;H<=Nt;H++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*H;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:H,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const E=Mt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??lt;const B=t.createBufferSource();B.buffer=this.roughTable(t,Bt),B.loop=!0,B.loopStart=Math.random()*X*.5,B.connect(O).connect(i.gain);const v=t.createGain();v.gain.value=(e.character?.roughness??lt)*vt;const S=t.createBufferSource();S.buffer=this.roughTable(t,ht),S.loop=!0,S.loopStart=Math.random()*X*.5,S.connect(v).connect(i.gain);let F;const x=this.busOf(t)&&this.reverb;x&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(x));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(dt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Pt,I.gain.value=0;const H=t.createGain();H.gain.value=0,a.connect(D).connect(I).connect(H).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ht),_.loop=!0,_.loopStart=Math.random()*X*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:H}}const k=[c,B,S,r,...p.map(D=>D.oscillator),...E,..._?[_]:[]];for(const D of k)D.start();const $={nodes:[a,i,l,O,v,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:r,lfoDepth:l,wander:E,wanderDepth:m,roughDepth:O,crackleDepth:v,beat:i,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,$),$}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Rt),i=Math.min(Ht,Math.max(_t,a.dopplerRatio)),o=Math.min(yt,Math.max(wt,Math.sqrt(a.dopplerRatio))),r=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*Y.unweighting(g.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-mt)/(Lt-mt)));g.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(r,p*o)),s(e.seconds[m].frequency,Math.min(r,p*o)),s(e.gains[m].gain,l[m]*Math.sqrt(Vt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:E,baseHz:O,share:B}of e.tones){const v=O*E;s(p.frequency,v*i);const S=v*i;s(m.gain,S<r?B*Gt*l[Y.bandOf(S)]/E:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*i);const h=c>0?Y.saturated(c)/c:1;if(s(e.output.gain,h*(1-Wt*u)),s(e.wanderDepth.gain,h*jt*u/Mt.length),e.send&&s(e.send.gain,Y.reverbSend(a.distanceKm)),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(dt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(kt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-pt,Math.min(pt,Math.sin(p)))*(1-Ft*u);s(e.panner.pan,m)}}static saturated(t){const e=Xt*gt;if(t<=e)return t;const a=gt-e;return e+a*(1-Math.exp(-(t-e)/a))}static reverbSend(t){return Math.min(Ut,Math.sqrt(Math.max(0,t)/Kt))}static unweighting(t){return 10**(Math.min(Ct,Math.max(0,-g.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return g.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/g.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*X),s=t.createBuffer(1,n,t.sampleRate),i=s.getChannelData(0),o=Array.from({length:X*e},()=>(Math.random()*2-1)**3),r=t.sampleRate/e;for(let l=0;l<i.length;l++){const c=l/r,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);i[l]=o[u%o.length]*(1-h)+o[(u+1)%o.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*zt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let i=0;for(let o=0;o<e;o++){const r=o/t.sampleRate,l=.6*Math.exp(-r/(At*2))+.04;i+=l*(Math.random()*2-1-i),s[o]=i*Math.exp(-r/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,rt/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},rt*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*ct,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=It.find(h=>h.id===(n?"helicopter":"airliner")).create(),[i,o]=n?[5,7]:[17,18],r=t.spanM/2/i,l=t.lengthM/2/o,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*r,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const i=C.LANDING_INTENSITY*n,o=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?i:0}]:[]),r=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*r,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?i:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:o}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class J{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(J.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?J.BY_TYPE.get(t.toUpperCase()):void 0}}class R{static ID_PREFIX=Z.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=R.MAX_OBJECTS,s={}){return new Yt(t,e,a,n,s).build()}static idOf(t,e){return Z.idOf(t,e)}static keyOf(t){return Z.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*R.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*R.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*R.DEG);return{eastM:s*Math.sin(a.azimuthDeg*R.DEG),northM:s*Math.cos(a.azimuthDeg*R.DEG),upM:n*Math.sin(a.altitudeDeg*R.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/R.DEG+360)%360}}class Yt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=R.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);R.segments(a).forEach((i,o)=>{const r=i.map(h=>({point:h,at:R.offsetOf(this.observer,h)}));if(!r.some(h=>h.at.altitudeDeg>=0))return;const l=r.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<r.length?R.bearingDeg(h.at,r[p+1].at):R.bearingDeg(r[p-1].at,h.at))})),c=R.idOf(a,o),u=r[Math.floor(r.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:R.sizeOf(s),model:J.idOf(s.code)?{id:J.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,i.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:i},closestKm:Math.min(...r.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const qt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],Jt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],bt=.16,xt=1,$t=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],Zt=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],Qt=1.5,Et=-40,te=1.5,ee={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class w{static bandsDb(t,e,a=340){const n=ee[e],s=w.fan(t)-w.fan(90),i=.62*Math.max(0,n.jetMps-n.flightMps)/a,o=-30*Math.log10(1+i/(1+i**5)**.2*Math.cos(t*Math.PI/180));return g.OCTAVES.map((r,l)=>{const c=o+w.jetRemainder(t,r*te/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=w.loudest.get(t);if(e)return e;const a=g.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)w.bandsDb(n,t).forEach((s,i)=>a[i]=Math.max(a[i],s));return w.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,i,o)=>s+i*e[o],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=w.read($t,t,!0),a=w.read(Zt,t,!0)+Qt;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/bt)/Math.log(xt/bt)));return(1-a)*w.read(qt,t)+a*w.read(Jt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[i,o]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=o[0])return a?Math.max(Et,o[1]+(o[1]-i[1])/(o[0]-i[0])*(e-o[0])):o[1];for(let r=1;r<t.length;r++){const[l,c]=[t[r-1],t[r]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return o[1]}}class A{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=A.GRASS){const[n,s]=A.impedance(t,a);return A.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=A.GRASS){const a=A.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,i,o]=[t*a-1,e*a,t*a+1,e*a],r=i*i+o*o;return{re:(n*i+s*o)/r,im:(s*i-n*o)/r}}static delayS(t,e=A.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=A.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=A.overheads.get(n);return s||A.overheads.set(n,s=A.bandsDb(90,e,a)),A.bandsDb(t,e,a).map((i,o)=>i-s[o])}static echo(t,e=A.GRASS,a=340){const n=A.delayS(t,e,a);if(n<=A.ECHO_UNDER_S)return;const s=Math.min(1,(n-A.ECHO_UNDER_S)/(A.ECHO_FROM_S-A.ECHO_UNDER_S)),i=s*s*(3-2*s),o=r=>{const l=A.reflection(r,t,e);return i*A.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:o(A.LOW_HZ),highGain:o(A.HIGH_HZ),jitterS:A.JITTER_S}}static overheads=new Map;static thirds=g.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=A.delayS(t,e,a),s=A.COHERENCE,i=Math.sin(Math.max(0,t)*Math.PI/180);let o=A.impedances.get(e.flowResistivityKPa);return o||A.impedances.set(e.flowResistivityKPa,o=A.thirds.map(r=>r.map(l=>A.impedance(l.middle,e)))),A.thirds.map((r,l)=>{let c=0;return r.forEach((u,d)=>{const h=A.reflected(o[l][d][0],o[l][d][1],i),p=2*Math.PI*n*(u.to-u.from),[m,E]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*E)}),10*Math.log10(c/r.length)})}}const q={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},ae={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Ot=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:q},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:ae},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:q},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:q},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:q},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ft=(b,t)=>b.map(e=>e+t-g.sumDb(b));function ne(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const St=Ot.map(b=>{const t=b.regimes===q?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:ft(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:ft(b.shapeDb.map((i,o)=>i+s.shapeDb[o]),b.totalDbA+s.levelDb),character:ne(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Dt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Ot.find(a=>a.kinds.includes(t));return St.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=g.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return g.OCTAVES.map((s,i)=>t.soundPowerA[i]-n-g.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=g.STANDARD,s){const i=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([r,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?w.loudestDb(r)[u]:0)).some((c,u)=>c>=Math.max(i[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=g.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??g.STANDARD,i=g.speedOfSound(s.temperatureC),o=t.points[t.points.length-1]?.t;if(o===void 0)return;let r=Math.min(a,o),l=N.positionAt(t,r);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/i,$=Math.abs(k-r);if(r=k,l=N.positionAt(t,r),!l)return;if(c=j.seenFrom(e,l.geo),$<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,r,e),p=M.inRegime(n.noise??St[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,E=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,r),B=p.directivity==="turbofan"?w.bandsDb(O,h,i):void 0,v=n.ground===null?g.OCTAVES.map(()=>0):A.excessDb(c.altitudeDeg,n.ground,i),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(B?.[k]??0)+v[k]),F=S.map((_,k)=>_>=Math.max(E[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),x=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:g.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-r)/1e3,emittedAtMs:r,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,r,i),dominantHz:g.OCTAVES[x],cutoffHz:L<0?void 0:g.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),i=N.positionAt(t,a+n),o=N.positionAt(t,a);if(!s||!i||!o)return 90;const r=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,E=h.distanceKm*1e3;return[E*Math.cos(p)*Math.sin(m),E*Math.cos(p)*Math.cos(m),E*Math.sin(p)]},[l,c,u]=[r(s.geo),r(i.geo),r(o.geo)];return w.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),i=N.positionAt(t,e+n)??N.positionAt(t,e),o=N.positionAt(t,e);if(!s||!i||!o)return"overflight";const r=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(r<=0)return"overflight";const l=(i.altitudeFt-s.altitudeFt)*.3048/r;return o.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,i={}){const o=[];let r,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,i);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?r?r.untilMs=u:o.push(r={fromMs:u,untilMs:u}):r=void 0}return{track:t,audible:o,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,i]=a(t),[o,r,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*o+s*r+i*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,i=N.positionAt(t,a-s),o=N.positionAt(t,a+s);if(!i||!o)return 1;const r=j.seenFrom(e,i.geo).distanceKm*1e3,l=j.seenFrom(e,o.geo).distanceKm*1e3;return 1/(1-(r-l)/(2*s/1e3)/n)}}class pe{static at(t,e,a,n,s={}){const i=N.seenFrom(t,a,n);if(!i)return;const o=U.of(e),r=M.heardAt(t,a,n,{noise:M.noiseOfKind(o.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:o.code??e?.type,name:o.basis==="nothing"?void 0:o.name,kind:o.kind,basis:o.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:i.altitudeFt,groundSpeedKt:i.groundSpeedKt,trackDeg:i.trackDeg,sky:i.sky,angularRateDegPerS:i.angularRateDegPerS,hearing:r&&{audible:r.audible,levelDbA:r.levelDbA,ambientDbA:r.ambientDbA,delayS:r.delayS,lagDeg:r.lagDeg,dopplerRatio:r.dopplerRatio,cutoffHz:r.cutoffHz,dominantHz:r.dominantHz}}}}class T{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Dt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const i=new Set;for(const[o,r]of t){const l=M.noiseOfKind(U.of(e.get(a(r))).kind);let c=1/0;for(const u of r.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&i.add(o)}return i}static voices(t,e,a,n,s,i,o={}){const r=[];for(const l of t){const c=e.get(l);if(!c||o.only?.(l)===!1)continue;const u=o.kindOf?.(l)??U.of(a.get(n(c))).kind,d=o.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,i,{...o,noise:d});if(!h?.audible)continue;const p=o.throughDb,m=p?h.bandsDbA.map((E,O)=>E-(p[O]??0)):h.bandsDbA;p&&!T.noticed(m,h.ambientDbA,o.ambientShapeDb)||r.push({id:l,kind:u,bandAmplitudes:T.bandAmplitudes(m,h.ambientDbA,o.referenceAmplitude,{ambientShapeDb:o.ambientShapeDb,expandUnderKnee:o.expandUnderKnee}),levelDbA:p?g.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:o.ground===null?void 0:A.echo(h.sound.altitudeDeg,o.ground,g.speedOfSound((o.air??g.STANDARD).temperatureC))})}return r.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,o.maxVoices??T.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,i)=>s>=n[i]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=T.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),i=n.expandUnderKnee===!1?1:T.EXPANSION_RATIO,o=M.DETECTION_MARGIN_DB,r=g.sumDb(t),l=r-e,c=l>=T.KNEE_DB?T.KNEE_DB+(l-T.KNEE_DB)/T.COMPRESSION_RATIO:T.KNEE_DB-(T.KNEE_DB-l)*i,u=a*10**((c-T.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-o+T.MASKING_RANGE_DB)/(2*T.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-r)/20)})}static BANDS_HZ=g.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),i=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),o=[],r=[t.registration,t.name].filter(Boolean).join(" · ");o.push(r||i(e.unnamed,{hex:t.hex}));const l=[i(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:i(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:i(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);o.push(l.join(" · ")),o.push(i(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)o.push(e.soundUnknown);else if(!c.audible)o.push(i(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":i(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});o.push(i(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:i(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&o.push(i(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&o.push(u.join(" · ")),o.push(e.candidate),o.join(`
2
2
  `)}}class nt{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return nt.EFFICIENCY[t]}}class f{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*f.FT_TO_M;return e<=f.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:f.TROPOPAUSE_HPA*Math.exp(-(e-f.TROPOPAUSE_M)/f.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*f.saturationOverWaterPa(t)/f.saturationOverIcePa(t)}static mixingSlope(t,e){return f.EMISSION_INDEX_WATER*f.AIR_HEAT_CAPACITY*t*100/(f.MOLAR_MASS_RATIO*f.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(f.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=f.criticalTemperatureC(t,e);return(f.mixingSlope(t,e)*(a-n)+f.saturationOverWaterPa(n))/f.saturationOverWaterPa(a)}static evaluate(t,e){const a=f.criticalTemperatureC(t.pressureHpa,e),n=f.requiredHumidity(t.pressureHpa,e,t.temperatureC),s=f.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),i=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:i,persistent:i&&s>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:s}}}class G{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],s=t[t.length-1];if(e<n.t-G.HOLD_MS||e>s.t+G.HOLD_MS)return;const i=t.findIndex(h=>h.t>e),o=i===0?t[0]:t[(i===-1?t.length:i)-1],r=i===-1||i===0?o:t[i],l=G.atLevel(o,a),c=G.atLevel(r,a);if(!l||!c)return;const u=r.t>o.t?Math.min(1,Math.max(0,(e-o.t)/(r.t-o.t))):0,d=(h,p)=>h+(p-h)*u;return{pressureHpa:a,temperatureC:d(l.temperatureC,c.temperatureC),relativeHumidity:d(l.relativeHumidity,c.relativeHumidity),driftEastMs:d(l.driftEastMs,c.driftEastMs),driftNorthMs:d(l.driftNorthMs,c.driftNorthMs),shearPerS:d(l.shearPerS,c.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const s=a[n],i=a[n+1];if(e>s.pressureHpa||e<i.pressureHpa)continue;const o=(Math.log(s.pressureHpa)-Math.log(e))/(Math.log(s.pressureHpa)-Math.log(i.pressureHpa)),r=(h,p)=>h+(p-h)*o,l=h=>{const p=h.windFromDeg*G.DEG;return{east:-h.windSpeedMs*Math.sin(p),north:-h.windSpeedMs*Math.cos(p)}},c=l(s),u=l(i),d=G.GAS_CONSTANT_OVER_GRAVITY*((s.temperatureC+i.temperatureC)/2+273.15)*Math.log(s.pressureHpa/i.pressureHpa);return{pressureHpa:e,temperatureC:r(s.temperatureC,i.temperatureC),relativeHumidity:r(s.relativeHumidity,i.relativeHumidity),driftEastMs:r(c.east,u.east),driftNorthMs:r(c.north,u.north),shearPerS:Math.hypot(u.east-c.east,u.north-c.north)/d}}}}class K{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const s=[],i=new Map,o=(r,l,c)=>{const u=Math.round(l/K.PRESSURE_STEP_HPA)*K.PRESSURE_STEP_HPA,d=K.SATURATION_STEP_MS,h=Math.floor(r/d)*d,p=`${u}|${h}`,m=i.get(p);if(m!==void 0)return m+(h-r)/1e3;let E=1/0;for(let O=d;O<=K.SATURATION_HORIZON_MS;O+=d){const B=G.at(a,h+O,u);if(!B)break;if(f.evaluate(B,c).iceRelativeHumidity<1){E=O/1e3;break}}return i.set(p,E),E+(h-r)/1e3};for(const r of t.objects){const l=t.flights.get(r.id),c=r.track;if(!l||!c||c.length!==l.points.length)continue;const u=e?.get(Z.keyOf(l))??U.of(void 0),d=nt.efficiencyOf(u.kind);if(d===void 0)continue;const h=[];let p=-1/0;c.forEach((m,E)=>{if(m.t<-K.DENSE_MS&&E+1<c.length&&m.t-p<K.SPARSE_STEP_MS)return;p=m.t;const O=l.points[E],B=f.pressureAtAltitudeFt(O.altitudeFt),v=G.at(a,n+m.t,B),S=v&&f.evaluate(v,d);h.push({tMs:m.t,eastM:m.eastM,northM:m.northM,upM:m.altitudeM??0,forms:S?.forms??!1,persistent:S?.persistent??!1,lifetimeS:S?ot.lifetimeS(S.iceRelativeHumidity):0,driftEastMs:v?.driftEastMs??0,driftNorthMs:v?.driftNorthMs??0,shearPerS:v?.shearPerS??ot.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:S?.iceRelativeHumidity??0,saturatedForS:S?.persistent?o(n+m.t,B,d):0})}),h.some((m,E)=>m.forms&&h[E+1]?.forms)&&s.push({id:r.id,spanM:u.spanM,points:h})}return s}}class y{static DEFAULT_KIND=V.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return V.kindOf(t,e)}static flies(t){return V.flies(t)}static ridden(t,e,a,n=()=>{}){const s=st.originOf(t);if(s)for(const i of t.decor){const o=V.kindOf(i,n(i));if(!o)continue;const r=i.sizeM,l=Math.max(r?.widthM??0,r?.lengthM??0,r?.heightM??0)/2;if(l<=0)continue;const c=y.pointAt(i,e,s),{distanceKm:u}=j.seenFrom(a,{lat:c.lat,lng:c.lng,heightM:c.altitudeFt/y.FT_PER_M});if(u*1e3<=l)return{decor:i,kind:o}}}voices(t,e,a,n={},s=()=>{}){const i=st.originOf(t);if(!i)return[];const o=new Map,r=new Map,l=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),c=y.ridden(t,e,a,s)?.decor;for(const u of t.decor){const d=u===c?void 0:V.kindOf(u,s(u));if(!d)continue;const h=`${y.ID_PREFIX}${u.id}`;o.set(h,this.trackOf(u,h,i,l)),r.set(h,d)}for(const u of this.tracks.keys())o.has(u)||this.tracks.delete(u);return o.size===0?[]:T.voices(new Set(o.keys()),o,new Map,u=>String(u.icao),a,e,{...n,kindOf:u=>r.get(u)})}trackOf(t,e,a,n){const s=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),i=this.tracks.get(e);if(i?.key===s)return i.track;const o=[];for(let d=0;d<=n;d+=y.STEP_MS)o.push(y.pointAt(t,d,a));(o.length===0||o[o.length-1].t<n)&&o.push(y.pointAt(t,n,a));const r=o[0],l=o[1]??r,c=d=>(l[d]-r[d])/(l.t-r.t||1);for(let d=y.STEP_MS*10;d<=y.LEAD_MS;d+=y.STEP_MS*10)o.unshift({t:-d,lat:r.lat-c("lat")*d,lng:r.lng-c("lng")*d,altitudeFt:Math.max(0,r.altitudeFt-c("altitudeFt")*d)});const u={icao:y.hash(e),nonIcao:!0,points:o};return this.tracks.set(e,{key:s,track:u}),u}static pointAt(t,e,a){const n=Tt(t,e),s=at(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:s.lat,lng:s.lng,altitudeFt:n.altitudeM*y.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class z{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"piston-heavy":90,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static JET_CABINS=["airliner-narrow","airliner-wide","airliner-supersonic","regional-jet","business-jet"];static JET_CABIN_SHAPE_DB=[-3,-4,-13,-24,-33,-36,-42,-55];static DEFAULT_DB_A=78;static voice(t,e={}){const a=it.aircraftOf(t);if(!a)return;const n=M.noiseOfKind(a),s=it.insulationDb(t),i=z.JET_CABINS.includes(a)&&t?.windowsOpen!==!0?z.JET_CABIN_SHAPE_DB.map((c,u)=>c+g.aWeightingDb(g.OCTAVES[u])):n.soundPowerA.map((c,u)=>c-s[u]),o=g.sumDb(i),r=z.levelDbA(a,t?.noise),l=i.map(c=>c-o+r);return{id:"observer:cabin",kind:a,bandAmplitudes:T.bandAmplitudes(l,e.ambientDbA??0,e.referenceAmplitude,{ambientShapeDb:e.ambientShapeDb,expandUnderKnee:e.expandUnderKnee}),levelDbA:r,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(z.CABIN_DB_A[t]??z.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class W{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=M.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,s,i,o={}){const r=new Map,l=new Map,c=new Map;for(const d of t){if(!d.sound)continue;const h=`${W.ID_PREFIX}${d.id}`,p=this.trackOf(d,h,e,n,i);p&&(r.set(h,p),l.set(h,d.sound.kind),c.set(h,W.noiseOf(d.sound)))}for(const d of this.tracks.keys())r.has(d)||this.tracks.delete(d);if(r.size===0)return[];const u=at(a.eastM,-a.northM,n.lat,n.lng);return T.voices(new Set(r.keys()),r,new Map,d=>String(d.icao),{lat:u.lat,lng:u.lng,heightM:a.upM},s,{...o,kindOf:d=>l.get(d),noiseOf:d=>c.get(d)})}trackOf(t,e,a,n,s){const i=`${n.lat},${n.lng},${s}`,o=this.tracks.get(e);if(o&&o.body===t&&o.origin===i)return o.track;const r=[];for(let c=-12e4;c<=s;c+=W.STEP_MS){const u=a(t,c);if(!u)continue;const d=at(u.eastM,-u.northM,n.lat,n.lng);r.push({t:c,lat:d.lat,lng:d.lng,altitudeFt:u.upM*W.FT_PER_M})}if(r.length<2)return;const l={icao:W.hash(e),nonIcao:!0,points:r};return this.tracks.set(e,{body:t,origin:i,track:l}),l}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{Y as AircraftAudio,K as AircraftContrails,U as AircraftModels,Dt as AmbientNoise,W as BodyHearing,z as CabinHearing,y as DecorAircraftHearing,R as TrafficDecor,pe as TrafficInfos,T as TrafficSound,Q as TrafficTooltip,Ae as UPPER_AIR_SOURCES};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rr0/ufoathome",
3
3
  "type": "module",
4
- "version": "0.197.0",
4
+ "version": "0.198.1",
5
5
  "description": "UFO@home — record and replay a UFO sighting's shape, movement and appearance",
6
6
  "author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
7
7
  "license": "MIT",
@@ -1,112 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./InterviewElement-B3tm7y49.js","./rr0-sighting-editor.mjs","./interviewJson-CsMHIcZ-.js"])))=>i.map(i=>d[i]);
2
- import{a9 as y,aa as p,a as I,ab as M,ac as _,f as E,i as L,ad as $,ae as U,a6 as j,af as S,ag as H,ah as V,ai as P,s as q,U as z,c as B,aj as G,ak as k,_ as D,I as K}from"./rr0-sighting-editor.mjs";import{SHOW_INFO_ATTRIBUTE as A,OBSERVER_ATTRIBUTE as m,registerSighting as F,HIDE_PICKERS_ATTRIBUTE as C,SIGHTING_ELEMENT_NAME as c,INTERPRETATION_ATTRIBUTE as b,CASE_NAMED_ATTRIBUTE as W,OBSERVER_CHANGE_EVENT as O,INTERPRETATION_CHANGE_EVENT as Y}from"./SightingElement-Ddf6hzfp.js";const Z=`
3
- <header class="case-head">
4
- <div class="case-bar">
5
- <p id="case-kind" class="case-kind"></p>
6
- <h2 id="case-title" class="case-title"></h2>
7
- <!-- The same pair the observation carries, for the case: the way into the editor, and what the case says of itself. -->
8
- <!-- The same three in the same order as an observation carries (see sightingTemplate): the way into the editor, this element's own
9
- toggle, and what it says of itself. A reader moving between a case and an observation finds the buttons where they were. -->
10
- <span class="case-actions">
11
- <!-- Sharing the case: its address and the element that shows it whole (an observation of it is shared from its own player). -->
12
- <button id="share" type="button" class="icon-btn" aria-haspopup="dialog"></button>
13
- <rr0-case-export id="export" class="case-export"></rr0-case-export>
14
- <button id="edit" type="button" class="icon-btn"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M11.3 1.3a1 1 0 0 1 1.4 0l2 2a1 1 0 0 1 0 1.4l-8.5 8.5-3.4.9.9-3.4 8.6-8.4Zm-7 9.2-.5 1.7 1.7-.5 6.9-6.9-1.2-1.2-6.9 6.9Z" fill="currentColor"/></svg></button>
15
- <button id="timeline-button" type="button" class="icon-btn" aria-pressed="true"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M8 4.6V8l2.4 1.6"/></svg></button>
16
- <button id="info" type="button" class="icon-btn" aria-expanded="false"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><circle cx="8" cy="3.6" r="1.4" fill="currentColor"/><path d="M6 6.5h3v6h1.5V14h-4.5v-1.5H7.5V8H6Z" fill="currentColor"/></svg></button>
17
- </span>
18
- </div>
19
- <p id="case-summary" class="case-summary" hidden></p>
20
- <rr0-share-dialog id="share-dialog"></rr0-share-dialog>
21
- </header>
22
- <!-- The chronology and what is open, one above the other; side by side when the case is given the width for both (see .case-layout). -->
23
- <div class="case-layout">
24
- <!-- The chronology, in the upper part: choosing an event opens it alone below; its mark on the rail shows it beside what is open, or puts
25
- it away. Several can be open at once that way. -->
26
- <section class="case-timeline">
27
- <div class="events-bar">
28
- <h3 class="events-heading"><span id="events-icon" class="events-icon" aria-hidden="true"></span><span id="events-heading"></span></h3>
29
- <!-- Each reading under the observation it reads, or every event in the order of time: the reader's choice, remembered. -->
30
- <button id="group-readings" type="button" class="icon-btn" aria-pressed="false"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="4" cy="3.5" r="1.6"/><path d="M4 5.1v7.4M4 8.5h3.5M4 12.5h3.5"/><path d="M9.5 8.5h4M9.5 12.5h4"/></svg></button>
31
- </div>
32
- <ol id="case-events" class="event-list"></ol>
33
- <rr0-readings-comparison id="readings-comparison" class="readings-comparison"></rr0-readings-comparison>
34
- </section>
35
- <!-- The grip between the two, on the history's edge: its width, dragged. -->
36
- <div id="column-resize" class="column-resize"></div>
37
- <!-- What is open, in the order of time whatever the order they were opened in. -->
38
- <div id="open-events" class="open-events"></div>
39
- </div>
40
- `,J=`
41
- :host { display: block; color: var(--rr0-ink, inherit); container-type: inline-size; }
42
- /* The buttons' own colours, light and dark, the very ones an observation's popups are drawn with (see sightingTemplate's --pop-*): a page
43
- that gives its own (--rr0-button-bg, -fg, -border, -hover, -on, -ring, inherited from anywhere, :root included) has them win. */
44
- :host { --btn-bg: #f2f2f2; --btn-fg: #222; --btn-border: #ccc; --btn-hover: #e4e4e4; --btn-on: #dbe6f7; --btn-ring: #9bb6e0; }
45
- @media (prefers-color-scheme: dark) {
46
- :host { --btn-bg: #2c2e33; --btn-fg: #e6e6e6; --btn-border: #4a4c52; --btn-hover: #3a3d43; --btn-on: #274066; --btn-ring: #4f7bc4; }
47
- }
48
- .case-head { display: grid; gap: 6px; margin: 0 0 12px; }
49
- .case-bar { display: flex; align-items: baseline; gap: 10px; }
50
- .case-kind { margin: 0; font: 600 12px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
51
- .case-title { margin: 0; font: 600 24px/1.25 var(--rr0-serif, Georgia, serif); }
52
- .case-actions { display: flex; gap: 4px; margin-left: auto; }
53
- /* The very square the observation's own row wears (see sightingTemplate's .edit-link and .info-btn): same size, same border, same
54
- background, so that the two rows are one set of buttons seen in two places. */
55
- .icon-btn {
56
- flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em; box-sizing: border-box;
57
- padding: 0; border: 1px solid var(--rr0-button-border, var(--btn-border)); border-radius: 3px; background: var(--rr0-button-bg, var(--btn-bg));
58
- color: var(--rr0-button-fg, var(--btn-fg)); cursor: pointer;
59
- }
60
- .icon-btn:hover, .icon-btn:focus-visible { background: var(--rr0-button-hover, var(--btn-hover)); }
61
- /* The report's export wears the same square, its button being its own (see CaseExportElement). */
62
- .case-export { display: inline-flex; }
63
- .case-export::part(button) {
64
- display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em; box-sizing: border-box;
65
- padding: 0; border: 1px solid var(--rr0-button-border, var(--btn-border)); border-radius: 3px; background: var(--rr0-button-bg, var(--btn-bg));
66
- color: var(--rr0-button-fg, var(--btn-fg));
67
- }
68
- .case-export::part(button):hover { background: var(--rr0-button-hover, var(--btn-hover)); }
69
- .icon-btn[aria-expanded="true"], .icon-btn[aria-pressed="false"] { background: var(--rr0-button-on, var(--btn-on)); }
70
- .case-summary { margin: 0; font-size: 15px; line-height: 1.5; opacity: .85; }
71
- .case-summary[hidden] { display: none; }
72
- /* The chronology itself is common to the editor (see CaseTimeline): what cannot be done while reading is absent, not greyed out. */
73
- .case-timeline { margin: 0 0 14px; }
74
- .case-timeline[hidden] { display: none; }
75
- .readings-comparison { margin-top: 12px; }
76
- .events-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
77
- .events-bar .icon-btn { margin-left: auto; }
78
- /* Lit when grouping, as a switch is: not the history's own button, which is lit when the history is put away. */
79
- #group-readings[aria-pressed="false"] { background: var(--rr0-button-bg, var(--btn-bg)); }
80
- #group-readings:is(:hover, :focus-visible) { background: var(--rr0-button-hover, var(--btn-hover)); }
81
- #group-readings[aria-pressed="true"] { background: var(--rr0-button-on, var(--btn-on)); }
82
- #group-readings[hidden], #share[hidden] { display: none; }
83
- .events-heading { display: flex; align-items: center; gap: 6px; margin: 0; font: 600 12px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
84
- .events-icon { display: inline-flex; }
85
- .events-icon svg { width: 14px; height: 14px; }
86
- /* What is open: one block per event, each saying which it is, in the order of time. */
87
- /* One column as wide as the case, never as wide as what is in it: an implicit "auto" column grew to the player's own widest content,
88
- McMinnville's longest reading in its choice (228 letters), and the stage, 16:9 of that, put the photograph beyond the case's edge. */
89
- .open-events { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
90
- /* Given the width (the app on a computer), the chronology in a column of its own beside what is open, kept in view as that scrolls; the
91
- whole width to what is open when the chronology is put away. The width the case is given, never the window's. */
92
- @container (min-width: 760px) {
93
- .case-layout { display: grid; grid-template-columns: var(${y.PROPERTY}, minmax(16rem, 1fr)) minmax(0, 2.6fr); gap: 20px; align-items: start; }
94
- .case-layout > .case-timeline { grid-column: 1; grid-row: 1; }
95
- .case-layout > .open-events { grid-column: 2; grid-row: 1; }
96
- .case-layout > .column-resize { display: block; grid-column: 1; grid-row: 1; margin-right: -16px; }
97
- .case-layout:has(> .case-timeline[hidden]) { grid-template-columns: minmax(0, 1fr); }
98
- .case-layout:has(> .case-timeline[hidden]) > :is(.open-events, .column-resize) { grid-column: 1; }
99
- .case-layout:has(> .case-timeline[hidden]) > .column-resize { display: none; }
100
- .case-layout > .case-timeline { position: sticky; top: 0; max-height: 100dvh; overflow-y: auto; margin: 0; }
101
- /* A dialogue open alone beside the chronology has the height the chronology has (dicté : « toute la hauteur »), not the 22 lines kept
102
- under a player when they are one above the other; kept in view as the page scrolls, as the chronology is. */
103
- .case-layout > .open-events:has(> .open-event:only-child rr0-interview) { position: sticky; top: 0; }
104
- .open-event:only-child rr0-interview { max-height: calc(var(--rr0-editor-height, 100dvh) - 3rem); }
105
- }
106
- .open-event { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
107
- .open-event > .open-title { margin: 0; font: 600 13px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
108
- .open-event rr0-interview { padding: 10px 12px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 10px;
109
- font-size: 14px; line-height: 1.5; max-height: 22em; overflow-y: auto; }
110
- ${p.CSS}
111
- ${y.CSS}
112
- `,g="rr0-case",v="show-timeline",w="open-events",Q="openchange";class u extends HTMLElement{static get observedAttributes(){return["src","show-labels",A,v,w,m]}static PASSED_ON=["show-labels"];shadow;openEvents;timeline;shown=new Map;messages;said=new I(["en"]);json;url;shareMessages;entries=[];grouping=!1;folded=new Set;columns;constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=J;const i=document.createElement("div");i.innerHTML=Z,this.shadow.append(e,i),F(),this.timeline=new p(this.byId("case-events"),n=>void this.only(n),n=>void this.only(n),n=>void this.toggle(n),n=>{this.folded.delete(n)||this.folded.add(n),this.draw()}),this.grouping=p.groupingRemembered(),this.columns=new y(this.byId("column-resize"),this.shadow.querySelector(".case-layout"),()=>this.shadow.querySelector(".case-timeline"),y.CASE_HISTORY_KEY),this.byId("group-readings").addEventListener("click",()=>{this.grouping=!this.grouping,p.rememberGrouping(this.grouping),this.order(),this.draw()}),M.register(),_.register(),this.byId("export").source=async()=>{const n=this.json,o=new Map;return await Promise.all(this.entries.filter(a=>a.kind!=="interview"&&a.url).map(async a=>{try{o.set(a.url,await E.recording(a.url))}catch{}})),{caseJson:n,caseUrl:this.url,recordings:o}},this.openEvents=this.byId("open-events"),this.openEvents.addEventListener(L,n=>{const{at:o,sighting:a}=n.detail;this.seekObservation(o,a)}),this.openEvents.addEventListener($,n=>{const o=n.target?.closest?.(".open-event");this.followReplay(o??void 0)}),U.register();const t=this.byId("share");t.innerHTML=j.SHARE;const s=this.byId("share-dialog");s.subject=this.shareSubject,t.addEventListener("click",()=>{this.url&&(s.note=S.changed(this.url,...this.entries.map(n=>n.url))?this.shareMessages?.unsaved:void 0,s.open())}),this.byId("edit").addEventListener("click",()=>{if(this.url&&H.ask(this,V,{src:this.url}))return;const n=this.editorUrl();n&&window.open(n,"_blank","noopener")}),this.byId("info").addEventListener("click",()=>this.showSummary(this.byId("case-summary").hidden)),this.byId("timeline-button").addEventListener("click",()=>{this.showTimeline(this.byId("case-events").parentElement.hidden)})}shareSubject={module:"rr0-sighting",link:()=>{const e=this.openKeys();return`${P.home()}/play/?file=${encodeURIComponent(this.url??"")}${e?`&events=${encodeURIComponent(e)}`:""}`+(this.timelineShown()?"":"&timeline=0")},element:()=>{const e=this.openKeys();return`<${g} src="${this.url??""}"${e?` ${w}="${e}"`:""}${this.timelineShown()?"":` ${v}="false"`}></${g}>`}};timelineShown(){return!this.byId("case-events").parentElement.hidden}openKeys(){const e=[...this.shown.keys()].sort((i,t)=>i-t);return e.length===1&&e[0]===this.firstObservation()?"":e.map(i=>u.keyOf(this.entries[i])).join(",")}static keyOf(e){return e.event.id??u.fileNameOf(e)}static fileNameOf(e){return(e.url??"").split("/").pop().replace(/[.]json$/i,"")}asked(e){if(e===null)return[];if(e.trim()==="all")return this.entries.map((t,s)=>s);const i=e.split(",").map(t=>t.trim().replace(/[.]json$/i,"")).filter(t=>t!=="");return this.entries.map((t,s)=>({entry:t,at:s})).filter(({entry:t})=>i.some(s=>s===t.event.id||s===u.fileNameOf(t))).map(({at:t})=>t)}firstObservation(){return this.entries.findIndex(e=>e.kind!=="interview")}byId(e){return this.shadow.getElementById(e)}showSummary(e){this.byId("case-summary").hidden=!e,this.byId("info").setAttribute("aria-expanded",String(e))}showTimeline(e){this.byId("case-events").parentElement.hidden=!e,this.byId("timeline-button").setAttribute("aria-pressed",String(e));for(const i of this.players())i.toggleAttribute(C,e)}connectedCallback(){this.loadMessages(),this.showTimeline(this.getAttribute(v)!=="false"),this.showSummary(this.hasAttribute(A));const e=this.getAttribute("src");e&&this.load(e).catch(i=>console.warn(`<${g}> could not read ${e}:`,i))}attributeChangedCallback(e,i,t){if(!(!this.isConnected||t===i))if(e==="src"&&t)this.load(t);else if(e===v)this.showTimeline(t!=="false");else if(e===w)for(const s of this.asked(t))this.open(s);else for(const s of this.players())t===null?s.removeAttribute(e):s.setAttribute(e,t)}async loadMessages(){const e=q(B.preferencesFor(this),z);this.said=new I([e,"en"]),this.messages=await G(e),this.shareMessages=await this.byId("share-dialog").useLanguage(e),this.draw()}async load(e){this.url=new URL(e,location.href).href;const i=await E.recording(this.url);if(!k.isCase(i))throw new Error(`${e} is not a case: <${g}> reads a case.json`);this.json=i,this.byId("share").hidden=S.local(this.url),this.entries=u.inTime((i.events??[]).map(r=>this.entryOf(r)).filter(r=>r!==void 0)),this.shown.clear(),this.folded.clear(),this.openEvents.replaceChildren(),this.draw(),this.compareReadings();const t=this.asked(this.getAttribute(w));if(t.length>0){for(const r of t)await this.open(r);return}const s=this.firstObservation();s>=0&&this.open(s)}static inTime(e){const i=new Map(e.filter(t=>t.event.id!==void 0).map(t=>[t.event.id,t]));return p.inTime(e,{when:t=>t.when,kind:t=>t.kind,read:t=>[t.event.interpretationOf].flat().map(s=>s===void 0?void 0:i.get(s)).filter(s=>s!==void 0)}).map(({item:t})=>t)}entryOf(e){if(typeof e.url!="string"||e.url==="")return;const i=e.eventType===k.INTERVIEW_EVENT?"interview":e.eventType===k.SIGHTING_EVENT?e.interpretationOf===void 0?"observation":"reading":void 0;if(i)return{event:e,kind:i,url:new URL(e.url,this.url??location.href).href,title:this.said.read(e.title)??e.id??"",when:String(e.time??"")}}compareReadings(){const e=this.byId("readings-comparison"),i=new Map,t=r=>{let n=i.get(r);return n||(n=E.recording(r).then(o=>o,()=>{}),i.set(r,n)),n},s=async r=>Promise.all(this.entries.flatMap((n,o)=>{if(n.kind!=="reading")return[];const a=this.accountOf(n);return[(async()=>({title:n.title,witness:a?.title??"",...r&&a?.url&&n.url?{account:await t(a.url),reading:await t(n.url)}:{},open:()=>void this.only(o).then(()=>this.shown.get(o)?.scrollIntoView({block:"start",behavior:"smooth"}))}))()]}));s(!1).then(r=>e.show(r,()=>s(!0)))}accountOf(e){return this.accountsOf(e)[0]}accountsOf(e){const i=[e.event.interpretationOf].flat().filter(t=>t!==void 0);return this.entries.filter(t=>t.kind==="observation"&&i.includes(t.event.id??""))}editorUrl(){if(!this.url)return;const e=new URL("/edit/",location.href);return e.searchParams.set("file",this.url),e.href}async only(e){const i=this.turn(e);for(const t of[...this.shown.keys()])t!==e&&this.shut(t);i||await this.open(e)}turn(e){const i=this.entries[e];if(!i?.url||this.shown.has(e)||i.kind!=="observation"&&i.kind!=="reading")return!1;const[t,s]=[...this.shown.entries()].find(([n,o])=>{const a=this.entries[n]?.kind;return(a==="observation"||a==="reading")&&o.querySelector(c)})??[],r=s?.querySelector(c);return t===void 0||!s||!r?!1:(this.shown.delete(t),this.shown.set(e,s),s.dataset.at=String(e),i.kind==="reading"?(r.setAttribute(b,i.url),r.setAttribute(m,this.accountOf(i)?.url??i.url)):(r.setAttribute(m,i.url),r.removeAttribute(b)),this.order(),this.draw(),window.setTimeout(()=>this.markCitedMoments(),300),this.announceOpen(),!0)}async toggle(e){this.shown.has(e)?this.shut(e):await this.open(e)}async open(e){const i=this.entries[e];if(!i||!i.url||this.shown.has(e))return;const t=document.createElement("section");if(t.className="open-event",t.dataset.at=String(e),i.kind==="interview"){const s=document.createElement("p");s.className="open-title",s.textContent=i.title,t.append(s)}if(i.kind==="interview"){const{register:s}=await D(async()=>{const{register:n}=await import("./InterviewElement-B3tm7y49.js");return{register:n}},__vite__mapDeps([0,1,2]),import.meta.url);s();const r=document.createElement("rr0-interview");r.setAttribute("src",i.url),t.append(r),window.setTimeout(()=>{this.followReplay(),this.markCitedMoments()},300)}else{const s=document.createElement(c);s.setAttribute(W,""),s.toggleAttribute(C,!this.byId("case-events").parentElement.hidden),s.setAttribute("src",this.url??"");const r=i.kind==="reading"?this.accountOf(i):void 0;s.setAttribute(m,(r??i).url??""),i.kind==="reading"&&s.setAttribute(b,i.url),queueMicrotask(()=>{for(const n of u.PASSED_ON){const o=this.getAttribute(n);o!==null&&s.setAttribute(n,o)}}),s.addEventListener(O,n=>{this.dispatchEvent(new CustomEvent(O,{detail:n.detail})),this.follow(t,s)}),s.addEventListener(Y,()=>this.follow(t,s)),t.append(s)}this.shown.set(e,t),this.order(),this.draw(),i.kind!=="interview"&&window.setTimeout(()=>this.markCitedMoments(),300),this.announceOpen()}follow(e,i){const t=Number(e.dataset.at),s=i.shownReadingUrl,r=i.shownRecordingUrl,n=(h,f)=>h!==void 0&&f!==void 0&&new URL(h,this.url??location.href).href===new URL(f,this.url??location.href).href,o=s?this.entries.findIndex(h=>h.kind==="reading"&&n(h.url,s)):this.entries.findIndex(h=>h.kind==="observation"&&n(h.url,r));if(o<0||o===t||this.shown.get(t)!==e||this.shown.has(o))return;this.shown.delete(t),this.shown.set(o,e),e.dataset.at=String(o);const a=this.entries[o];a.kind==="reading"?i.setAttribute(b,a.url):(i.removeAttribute(b),a.url&&i.setAttribute(m,a.url)),this.order(),this.draw(),this.announceOpen()}announceOpen(){this.dispatchEvent(new CustomEvent(Q,{detail:{events:this.openKeys()}}))}followReplay(e){const i=e??[...this.shown.values()].find(n=>n.querySelector(c)),t=i?Number(i.dataset.at):NaN,s=Number.isNaN(t)?void 0:this.entries[t],r=i?.querySelector(c);if(!(!s||!r)){for(const[n,o]of this.shown){if(this.entries[n]?.kind!=="interview")continue;o.querySelector("rr0-interview")?.revealAt?.(r.playedSeconds,s.event.id)}return i}}markCitedMoments(){for(const[e,i]of this.shown){const t=this.entries[e],s=i.querySelector(c);if(!t||!s)continue;const r=[];for(const[n,o]of this.shown){if(this.entries[n]?.kind!=="interview")continue;const a=o.querySelector("rr0-interview");r.push(...a?.momentsCited?.(t.event.id)??[])}s.citedMoments=r.sort((n,o)=>n.at-o.at)}}shut(e){this.shown.get(e)?.remove(),this.shown.delete(e),this.markCitedMoments(),this.draw(),this.announceOpen()}order(){const e=new Map(this.listed().map(({index:t},s)=>[t,s])),i=[...this.shown.entries()].sort(([t],[s])=>(e.get(t)??t)-(e.get(s)??s)).map(([,t])=>t);i.length===this.openEvents.children.length&&i.every((t,s)=>this.openEvents.children[s]===t)||this.openEvents.replaceChildren(...i)}listed(){const e=this.entries.map((i,t)=>({item:i,index:t}));return this.grouping?p.grouped(e,{kind:i=>i.kind,read:i=>this.accountsOf(i)}):e}async seekObservation(e,i){const t=this.entries.findIndex(n=>n.kind!=="interview"&&(n.event.id===i||i!==void 0&&n.url?.endsWith(`/${i}.json`))),s=t>=0?t:this.entries.findIndex(n=>n.kind!=="interview");if(s<0)return;this.shown.has(s)||await this.open(s),this.shown.get(s)?.querySelector(c)?.seekTo(e,i),this.shown.get(s)?.scrollIntoView({block:"nearest",behavior:"smooth"})}authors(e){const i=this.messages,t=(e??[]).map(s=>"people"in s?s.people:"org"in s?s.org:this.said.read(s.title)??"").filter(s=>s!=="");return t.length<2||!i?t.join(", "):`${t.slice(0,-1).join(", ")} ${i.linkAnd} ${t[t.length-1]}`}linkedTo(e){const i=this.messages;if(i){if(e.kind==="reading"){const t=[e.event.interpretationOf].flat().filter(r=>r!==void 0),s=this.entries.map((r,n)=>t.includes(r.event.id??"")?n:-1).filter(r=>r>=0);return s.length>0?{heading:i.interpretationOf,to:s}:void 0}if(e.kind==="observation"){const t=this.entries.map((s,r)=>s.kind==="interview"&&[s.event.interviewOf].flat().includes(e.event.id)?r:-1).filter(s=>s>=0);return t.length>0?{heading:i.passagesHeading,to:t}:void 0}}}draw(){const e=this.messages,i=this.json;if(!e||!i)return;this.byId("case-kind").textContent=e.caseHeading,this.byId("case-title").textContent=this.said.read(i.title)??i.id??"";const t=this.said.read(i.summary)??"",s=this.byId("case-summary");s.textContent=t;const r=this.byId("info");r.hidden=t==="",r.title=e.caseSummary,r.setAttribute("aria-label",e.caseSummary),t===""&&this.showSummary(!1),this.byId("events-heading").textContent=e.eventsHeading,this.byId("events-icon").innerHTML=K.CLOCK;const n=this.byId("share");n.title=e.shareCase,n.setAttribute("aria-label",e.shareCase);const o=this.byId("edit");o.title=e.editCase,o.setAttribute("aria-label",e.editCase);const a=this.byId("group-readings");a.title=e.groupReadings,a.setAttribute("aria-label",e.groupReadings),this.columns.label(e.resizeColumns),a.setAttribute("aria-pressed",String(this.grouping)),a.hidden=!this.entries.some(d=>d.kind==="reading");const h=this.listed(),f=d=>h.filter(({under:l})=>l===d).length,N=new Map(this.entries.map((d,l)=>[d,l]));this.timeline.render(h.filter(({index:d,under:l})=>l===void 0||!this.folded.has(N.get(l))||this.shown.has(d)).map(({item:d,index:l,under:R})=>{const x=this.card(d,l,R),T=this.grouping&&d.kind==="observation"?f(d):0;return T>0?{...x,readings:{count:T,folded:this.folded.has(l)}}:x}),e)}card(e,i,t){const s=this.linkedTo(e),r=(s?.to??[]).filter(o=>this.entries[o]!==t),n=t?this.messages.alsoAbout:s?.heading??"";return{at:i,kind:e.kind,title:e.title,meta:e.when.replace("T"," "),open:this.shown.has(i),...r.length>0?{links:{heading:n,to:r.map(o=>({at:o,title:this.entries[o].title}))}}:{},by:e.kind==="observation"?"":this.authors(e.event.by),...t?{nested:!0}:{}}}async loadFromSrc(e){await this.load(e),await this.player?.loaded}get scene(){return this.players()[0]?.scene}players(){return[...this.shown.entries()].sort(([e],[i])=>e-i).map(([,e])=>e.querySelector(c)).filter(e=>e!==null)}get sightingData(){return this.players()[0]?.sightingData}get player(){return this.players()[0]}}function te(){customElements.get(g)||customElements.define(g,u)}export{g as CASE_ELEMENT_NAME,u as CaseElement,Q as OPEN_CHANGE_EVENT,w as OPEN_EVENTS_ATTRIBUTE,v as SHOW_TIMELINE_ATTRIBUTE,te as register};
@@ -1,112 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./InterviewElement-dtYF5S-4.js","./SaidPosition-CWiVNaNW.js","./rr0-ufoathome.mjs","./ColumnResize-UnDz8hFM.js","./ShareDialogElement-C5QkyK7i.js","./Sighting-CBpJpdm9.js","./VisualAids-DI-hEL46.js","./Decor-Dn-cvniW.js","./RecordingIssue-BlWT8Xsu.js","./Obstacles-v9SkfBD7.js","./interviewJson-D-i14LTf.js"])))=>i.map(i=>d[i]);
2
- import{S as E,O as I,R as M,E as _,s as L,U as $,H,l as U,C as k,_ as j}from"./rr0-ufoathome.mjs";import{C as y,a as p,R as V,b as P,I as q}from"./ColumnResize-UnDz8hFM.js";import{S,I as z}from"./SaidPosition-CWiVNaNW.js";import{T as B,S as G,P as D,A as K}from"./ShareDialogElement-C5QkyK7i.js";import{SHOW_INFO_ATTRIBUTE as A,OBSERVER_ATTRIBUTE as m,registerSighting as F,HIDE_PICKERS_ATTRIBUTE as C,SIGHTING_ELEMENT_NAME as c,INTERPRETATION_ATTRIBUTE as b,CASE_NAMED_ATTRIBUTE as W,OBSERVER_CHANGE_EVENT as O,INTERPRETATION_CHANGE_EVENT as Y}from"./SightingElement-cd7C-Ge-.js";import"./Sighting-CBpJpdm9.js";import"./VisualAids-DI-hEL46.js";import"./Decor-Dn-cvniW.js";import"./RecordingIssue-BlWT8Xsu.js";import"./Obstacles-v9SkfBD7.js";const Z=`
3
- <header class="case-head">
4
- <div class="case-bar">
5
- <p id="case-kind" class="case-kind"></p>
6
- <h2 id="case-title" class="case-title"></h2>
7
- <!-- The same pair the observation carries, for the case: the way into the editor, and what the case says of itself. -->
8
- <!-- The same three in the same order as an observation carries (see sightingTemplate): the way into the editor, this element's own
9
- toggle, and what it says of itself. A reader moving between a case and an observation finds the buttons where they were. -->
10
- <span class="case-actions">
11
- <!-- Sharing the case: its address and the element that shows it whole (an observation of it is shared from its own player). -->
12
- <button id="share" type="button" class="icon-btn" aria-haspopup="dialog"></button>
13
- <rr0-case-export id="export" class="case-export"></rr0-case-export>
14
- <button id="edit" type="button" class="icon-btn"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M11.3 1.3a1 1 0 0 1 1.4 0l2 2a1 1 0 0 1 0 1.4l-8.5 8.5-3.4.9.9-3.4 8.6-8.4Zm-7 9.2-.5 1.7 1.7-.5 6.9-6.9-1.2-1.2-6.9 6.9Z" fill="currentColor"/></svg></button>
15
- <button id="timeline-button" type="button" class="icon-btn" aria-pressed="true"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M8 4.6V8l2.4 1.6"/></svg></button>
16
- <button id="info" type="button" class="icon-btn" aria-expanded="false"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><circle cx="8" cy="3.6" r="1.4" fill="currentColor"/><path d="M6 6.5h3v6h1.5V14h-4.5v-1.5H7.5V8H6Z" fill="currentColor"/></svg></button>
17
- </span>
18
- </div>
19
- <p id="case-summary" class="case-summary" hidden></p>
20
- <rr0-share-dialog id="share-dialog"></rr0-share-dialog>
21
- </header>
22
- <!-- The chronology and what is open, one above the other; side by side when the case is given the width for both (see .case-layout). -->
23
- <div class="case-layout">
24
- <!-- The chronology, in the upper part: choosing an event opens it alone below; its mark on the rail shows it beside what is open, or puts
25
- it away. Several can be open at once that way. -->
26
- <section class="case-timeline">
27
- <div class="events-bar">
28
- <h3 class="events-heading"><span id="events-icon" class="events-icon" aria-hidden="true"></span><span id="events-heading"></span></h3>
29
- <!-- Each reading under the observation it reads, or every event in the order of time: the reader's choice, remembered. -->
30
- <button id="group-readings" type="button" class="icon-btn" aria-pressed="false"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="4" cy="3.5" r="1.6"/><path d="M4 5.1v7.4M4 8.5h3.5M4 12.5h3.5"/><path d="M9.5 8.5h4M9.5 12.5h4"/></svg></button>
31
- </div>
32
- <ol id="case-events" class="event-list"></ol>
33
- <rr0-readings-comparison id="readings-comparison" class="readings-comparison"></rr0-readings-comparison>
34
- </section>
35
- <!-- The grip between the two, on the history's edge: its width, dragged. -->
36
- <div id="column-resize" class="column-resize"></div>
37
- <!-- What is open, in the order of time whatever the order they were opened in. -->
38
- <div id="open-events" class="open-events"></div>
39
- </div>
40
- `,J=`
41
- :host { display: block; color: var(--rr0-ink, inherit); container-type: inline-size; }
42
- /* The buttons' own colours, light and dark, the very ones an observation's popups are drawn with (see sightingTemplate's --pop-*): a page
43
- that gives its own (--rr0-button-bg, -fg, -border, -hover, -on, -ring, inherited from anywhere, :root included) has them win. */
44
- :host { --btn-bg: #f2f2f2; --btn-fg: #222; --btn-border: #ccc; --btn-hover: #e4e4e4; --btn-on: #dbe6f7; --btn-ring: #9bb6e0; }
45
- @media (prefers-color-scheme: dark) {
46
- :host { --btn-bg: #2c2e33; --btn-fg: #e6e6e6; --btn-border: #4a4c52; --btn-hover: #3a3d43; --btn-on: #274066; --btn-ring: #4f7bc4; }
47
- }
48
- .case-head { display: grid; gap: 6px; margin: 0 0 12px; }
49
- .case-bar { display: flex; align-items: baseline; gap: 10px; }
50
- .case-kind { margin: 0; font: 600 12px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
51
- .case-title { margin: 0; font: 600 24px/1.25 var(--rr0-serif, Georgia, serif); }
52
- .case-actions { display: flex; gap: 4px; margin-left: auto; }
53
- /* The very square the observation's own row wears (see sightingTemplate's .edit-link and .info-btn): same size, same border, same
54
- background, so that the two rows are one set of buttons seen in two places. */
55
- .icon-btn {
56
- flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em; box-sizing: border-box;
57
- padding: 0; border: 1px solid var(--rr0-button-border, var(--btn-border)); border-radius: 3px; background: var(--rr0-button-bg, var(--btn-bg));
58
- color: var(--rr0-button-fg, var(--btn-fg)); cursor: pointer;
59
- }
60
- .icon-btn:hover, .icon-btn:focus-visible { background: var(--rr0-button-hover, var(--btn-hover)); }
61
- /* The report's export wears the same square, its button being its own (see CaseExportElement). */
62
- .case-export { display: inline-flex; }
63
- .case-export::part(button) {
64
- display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em; box-sizing: border-box;
65
- padding: 0; border: 1px solid var(--rr0-button-border, var(--btn-border)); border-radius: 3px; background: var(--rr0-button-bg, var(--btn-bg));
66
- color: var(--rr0-button-fg, var(--btn-fg));
67
- }
68
- .case-export::part(button):hover { background: var(--rr0-button-hover, var(--btn-hover)); }
69
- .icon-btn[aria-expanded="true"], .icon-btn[aria-pressed="false"] { background: var(--rr0-button-on, var(--btn-on)); }
70
- .case-summary { margin: 0; font-size: 15px; line-height: 1.5; opacity: .85; }
71
- .case-summary[hidden] { display: none; }
72
- /* The chronology itself is common to the editor (see CaseTimeline): what cannot be done while reading is absent, not greyed out. */
73
- .case-timeline { margin: 0 0 14px; }
74
- .case-timeline[hidden] { display: none; }
75
- .readings-comparison { margin-top: 12px; }
76
- .events-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
77
- .events-bar .icon-btn { margin-left: auto; }
78
- /* Lit when grouping, as a switch is: not the history's own button, which is lit when the history is put away. */
79
- #group-readings[aria-pressed="false"] { background: var(--rr0-button-bg, var(--btn-bg)); }
80
- #group-readings:is(:hover, :focus-visible) { background: var(--rr0-button-hover, var(--btn-hover)); }
81
- #group-readings[aria-pressed="true"] { background: var(--rr0-button-on, var(--btn-on)); }
82
- #group-readings[hidden], #share[hidden] { display: none; }
83
- .events-heading { display: flex; align-items: center; gap: 6px; margin: 0; font: 600 12px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
84
- .events-icon { display: inline-flex; }
85
- .events-icon svg { width: 14px; height: 14px; }
86
- /* What is open: one block per event, each saying which it is, in the order of time. */
87
- /* One column as wide as the case, never as wide as what is in it: an implicit "auto" column grew to the player's own widest content,
88
- McMinnville's longest reading in its choice (228 letters), and the stage, 16:9 of that, put the photograph beyond the case's edge. */
89
- .open-events { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
90
- /* Given the width (the app on a computer), the chronology in a column of its own beside what is open, kept in view as that scrolls; the
91
- whole width to what is open when the chronology is put away. The width the case is given, never the window's. */
92
- @container (min-width: 760px) {
93
- .case-layout { display: grid; grid-template-columns: var(${y.PROPERTY}, minmax(16rem, 1fr)) minmax(0, 2.6fr); gap: 20px; align-items: start; }
94
- .case-layout > .case-timeline { grid-column: 1; grid-row: 1; }
95
- .case-layout > .open-events { grid-column: 2; grid-row: 1; }
96
- .case-layout > .column-resize { display: block; grid-column: 1; grid-row: 1; margin-right: -16px; }
97
- .case-layout:has(> .case-timeline[hidden]) { grid-template-columns: minmax(0, 1fr); }
98
- .case-layout:has(> .case-timeline[hidden]) > :is(.open-events, .column-resize) { grid-column: 1; }
99
- .case-layout:has(> .case-timeline[hidden]) > .column-resize { display: none; }
100
- .case-layout > .case-timeline { position: sticky; top: 0; max-height: 100dvh; overflow-y: auto; margin: 0; }
101
- /* A dialogue open alone beside the chronology has the height the chronology has (dicté : « toute la hauteur »), not the 22 lines kept
102
- under a player when they are one above the other; kept in view as the page scrolls, as the chronology is. */
103
- .case-layout > .open-events:has(> .open-event:only-child rr0-interview) { position: sticky; top: 0; }
104
- .open-event:only-child rr0-interview { max-height: calc(var(--rr0-editor-height, 100dvh) - 3rem); }
105
- }
106
- .open-event { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
107
- .open-event > .open-title { margin: 0; font: 600 13px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
108
- .open-event rr0-interview { padding: 10px 12px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 10px;
109
- font-size: 14px; line-height: 1.5; max-height: 22em; overflow-y: auto; }
110
- ${p.CSS}
111
- ${y.CSS}
112
- `,g="rr0-case",v="show-timeline",w="open-events",Q="openchange";class u extends HTMLElement{static get observedAttributes(){return["src","show-labels",A,v,w,m]}static PASSED_ON=["show-labels"];shadow;openEvents;timeline;shown=new Map;messages;said=new S(["en"]);json;url;shareMessages;entries=[];grouping=!1;folded=new Set;columns;constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=J;const i=document.createElement("div");i.innerHTML=Z,this.shadow.append(e,i),F(),this.timeline=new p(this.byId("case-events"),n=>void this.only(n),n=>void this.only(n),n=>void this.toggle(n),n=>{this.folded.delete(n)||this.folded.add(n),this.draw()}),this.grouping=p.groupingRemembered(),this.columns=new y(this.byId("column-resize"),this.shadow.querySelector(".case-layout"),()=>this.shadow.querySelector(".case-timeline"),y.CASE_HISTORY_KEY),this.byId("group-readings").addEventListener("click",()=>{this.grouping=!this.grouping,p.rememberGrouping(this.grouping),this.order(),this.draw()}),V.register(),P.register(),this.byId("export").source=async()=>{const n=this.json,o=new Map;return await Promise.all(this.entries.filter(a=>a.kind!=="interview"&&a.url).map(async a=>{try{o.set(a.url,await E.recording(a.url))}catch{}})),{caseJson:n,caseUrl:this.url,recordings:o}},this.openEvents=this.byId("open-events"),this.openEvents.addEventListener(q,n=>{const{at:o,sighting:a}=n.detail;this.seekObservation(o,a)}),this.openEvents.addEventListener(B,n=>{const o=n.target?.closest?.(".open-event");this.followReplay(o??void 0)}),G.register();const t=this.byId("share");t.innerHTML=D.SHARE;const s=this.byId("share-dialog");s.subject=this.shareSubject,t.addEventListener("click",()=>{this.url&&(s.note=I.changed(this.url,...this.entries.map(n=>n.url))?this.shareMessages?.unsaved:void 0,s.open())}),this.byId("edit").addEventListener("click",()=>{if(this.url&&M.ask(this,_,{src:this.url}))return;const n=this.editorUrl();n&&window.open(n,"_blank","noopener")}),this.byId("info").addEventListener("click",()=>this.showSummary(this.byId("case-summary").hidden)),this.byId("timeline-button").addEventListener("click",()=>{this.showTimeline(this.byId("case-events").parentElement.hidden)})}shareSubject={module:"rr0-sighting",link:()=>{const e=this.openKeys();return`${K.home()}/play/?file=${encodeURIComponent(this.url??"")}${e?`&events=${encodeURIComponent(e)}`:""}`+(this.timelineShown()?"":"&timeline=0")},element:()=>{const e=this.openKeys();return`<${g} src="${this.url??""}"${e?` ${w}="${e}"`:""}${this.timelineShown()?"":` ${v}="false"`}></${g}>`}};timelineShown(){return!this.byId("case-events").parentElement.hidden}openKeys(){const e=[...this.shown.keys()].sort((i,t)=>i-t);return e.length===1&&e[0]===this.firstObservation()?"":e.map(i=>u.keyOf(this.entries[i])).join(",")}static keyOf(e){return e.event.id??u.fileNameOf(e)}static fileNameOf(e){return(e.url??"").split("/").pop().replace(/[.]json$/i,"")}asked(e){if(e===null)return[];if(e.trim()==="all")return this.entries.map((t,s)=>s);const i=e.split(",").map(t=>t.trim().replace(/[.]json$/i,"")).filter(t=>t!=="");return this.entries.map((t,s)=>({entry:t,at:s})).filter(({entry:t})=>i.some(s=>s===t.event.id||s===u.fileNameOf(t))).map(({at:t})=>t)}firstObservation(){return this.entries.findIndex(e=>e.kind!=="interview")}byId(e){return this.shadow.getElementById(e)}showSummary(e){this.byId("case-summary").hidden=!e,this.byId("info").setAttribute("aria-expanded",String(e))}showTimeline(e){this.byId("case-events").parentElement.hidden=!e,this.byId("timeline-button").setAttribute("aria-pressed",String(e));for(const i of this.players())i.toggleAttribute(C,e)}connectedCallback(){this.loadMessages(),this.showTimeline(this.getAttribute(v)!=="false"),this.showSummary(this.hasAttribute(A));const e=this.getAttribute("src");e&&this.load(e).catch(i=>console.warn(`<${g}> could not read ${e}:`,i))}attributeChangedCallback(e,i,t){if(!(!this.isConnected||t===i))if(e==="src"&&t)this.load(t);else if(e===v)this.showTimeline(t!=="false");else if(e===w)for(const s of this.asked(t))this.open(s);else for(const s of this.players())t===null?s.removeAttribute(e):s.setAttribute(e,t)}async loadMessages(){const e=L(H.preferencesFor(this),$);this.said=new S([e,"en"]),this.messages=await U(e),this.shareMessages=await this.byId("share-dialog").useLanguage(e),this.draw()}async load(e){this.url=new URL(e,location.href).href;const i=await E.recording(this.url);if(!k.isCase(i))throw new Error(`${e} is not a case: <${g}> reads a case.json`);this.json=i,this.byId("share").hidden=I.local(this.url),this.entries=u.inTime((i.events??[]).map(r=>this.entryOf(r)).filter(r=>r!==void 0)),this.shown.clear(),this.folded.clear(),this.openEvents.replaceChildren(),this.draw(),this.compareReadings();const t=this.asked(this.getAttribute(w));if(t.length>0){for(const r of t)await this.open(r);return}const s=this.firstObservation();s>=0&&this.open(s)}static inTime(e){const i=new Map(e.filter(t=>t.event.id!==void 0).map(t=>[t.event.id,t]));return p.inTime(e,{when:t=>t.when,kind:t=>t.kind,read:t=>[t.event.interpretationOf].flat().map(s=>s===void 0?void 0:i.get(s)).filter(s=>s!==void 0)}).map(({item:t})=>t)}entryOf(e){if(typeof e.url!="string"||e.url==="")return;const i=e.eventType===k.INTERVIEW_EVENT?"interview":e.eventType===k.SIGHTING_EVENT?e.interpretationOf===void 0?"observation":"reading":void 0;if(i)return{event:e,kind:i,url:new URL(e.url,this.url??location.href).href,title:this.said.read(e.title)??e.id??"",when:String(e.time??"")}}compareReadings(){const e=this.byId("readings-comparison"),i=new Map,t=r=>{let n=i.get(r);return n||(n=E.recording(r).then(o=>o,()=>{}),i.set(r,n)),n},s=async r=>Promise.all(this.entries.flatMap((n,o)=>{if(n.kind!=="reading")return[];const a=this.accountOf(n);return[(async()=>({title:n.title,witness:a?.title??"",...r&&a?.url&&n.url?{account:await t(a.url),reading:await t(n.url)}:{},open:()=>void this.only(o).then(()=>this.shown.get(o)?.scrollIntoView({block:"start",behavior:"smooth"}))}))()]}));s(!1).then(r=>e.show(r,()=>s(!0)))}accountOf(e){return this.accountsOf(e)[0]}accountsOf(e){const i=[e.event.interpretationOf].flat().filter(t=>t!==void 0);return this.entries.filter(t=>t.kind==="observation"&&i.includes(t.event.id??""))}editorUrl(){if(!this.url)return;const e=new URL("/edit/",location.href);return e.searchParams.set("file",this.url),e.href}async only(e){const i=this.turn(e);for(const t of[...this.shown.keys()])t!==e&&this.shut(t);i||await this.open(e)}turn(e){const i=this.entries[e];if(!i?.url||this.shown.has(e)||i.kind!=="observation"&&i.kind!=="reading")return!1;const[t,s]=[...this.shown.entries()].find(([n,o])=>{const a=this.entries[n]?.kind;return(a==="observation"||a==="reading")&&o.querySelector(c)})??[],r=s?.querySelector(c);return t===void 0||!s||!r?!1:(this.shown.delete(t),this.shown.set(e,s),s.dataset.at=String(e),i.kind==="reading"?(r.setAttribute(b,i.url),r.setAttribute(m,this.accountOf(i)?.url??i.url)):(r.setAttribute(m,i.url),r.removeAttribute(b)),this.order(),this.draw(),window.setTimeout(()=>this.markCitedMoments(),300),this.announceOpen(),!0)}async toggle(e){this.shown.has(e)?this.shut(e):await this.open(e)}async open(e){const i=this.entries[e];if(!i||!i.url||this.shown.has(e))return;const t=document.createElement("section");if(t.className="open-event",t.dataset.at=String(e),i.kind==="interview"){const s=document.createElement("p");s.className="open-title",s.textContent=i.title,t.append(s)}if(i.kind==="interview"){const{register:s}=await j(async()=>{const{register:n}=await import("./InterviewElement-dtYF5S-4.js");return{register:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url);s();const r=document.createElement("rr0-interview");r.setAttribute("src",i.url),t.append(r),window.setTimeout(()=>{this.followReplay(),this.markCitedMoments()},300)}else{const s=document.createElement(c);s.setAttribute(W,""),s.toggleAttribute(C,!this.byId("case-events").parentElement.hidden),s.setAttribute("src",this.url??"");const r=i.kind==="reading"?this.accountOf(i):void 0;s.setAttribute(m,(r??i).url??""),i.kind==="reading"&&s.setAttribute(b,i.url),queueMicrotask(()=>{for(const n of u.PASSED_ON){const o=this.getAttribute(n);o!==null&&s.setAttribute(n,o)}}),s.addEventListener(O,n=>{this.dispatchEvent(new CustomEvent(O,{detail:n.detail})),this.follow(t,s)}),s.addEventListener(Y,()=>this.follow(t,s)),t.append(s)}this.shown.set(e,t),this.order(),this.draw(),i.kind!=="interview"&&window.setTimeout(()=>this.markCitedMoments(),300),this.announceOpen()}follow(e,i){const t=Number(e.dataset.at),s=i.shownReadingUrl,r=i.shownRecordingUrl,n=(h,f)=>h!==void 0&&f!==void 0&&new URL(h,this.url??location.href).href===new URL(f,this.url??location.href).href,o=s?this.entries.findIndex(h=>h.kind==="reading"&&n(h.url,s)):this.entries.findIndex(h=>h.kind==="observation"&&n(h.url,r));if(o<0||o===t||this.shown.get(t)!==e||this.shown.has(o))return;this.shown.delete(t),this.shown.set(o,e),e.dataset.at=String(o);const a=this.entries[o];a.kind==="reading"?i.setAttribute(b,a.url):(i.removeAttribute(b),a.url&&i.setAttribute(m,a.url)),this.order(),this.draw(),this.announceOpen()}announceOpen(){this.dispatchEvent(new CustomEvent(Q,{detail:{events:this.openKeys()}}))}followReplay(e){const i=e??[...this.shown.values()].find(n=>n.querySelector(c)),t=i?Number(i.dataset.at):NaN,s=Number.isNaN(t)?void 0:this.entries[t],r=i?.querySelector(c);if(!(!s||!r)){for(const[n,o]of this.shown){if(this.entries[n]?.kind!=="interview")continue;o.querySelector("rr0-interview")?.revealAt?.(r.playedSeconds,s.event.id)}return i}}markCitedMoments(){for(const[e,i]of this.shown){const t=this.entries[e],s=i.querySelector(c);if(!t||!s)continue;const r=[];for(const[n,o]of this.shown){if(this.entries[n]?.kind!=="interview")continue;const a=o.querySelector("rr0-interview");r.push(...a?.momentsCited?.(t.event.id)??[])}s.citedMoments=r.sort((n,o)=>n.at-o.at)}}shut(e){this.shown.get(e)?.remove(),this.shown.delete(e),this.markCitedMoments(),this.draw(),this.announceOpen()}order(){const e=new Map(this.listed().map(({index:t},s)=>[t,s])),i=[...this.shown.entries()].sort(([t],[s])=>(e.get(t)??t)-(e.get(s)??s)).map(([,t])=>t);i.length===this.openEvents.children.length&&i.every((t,s)=>this.openEvents.children[s]===t)||this.openEvents.replaceChildren(...i)}listed(){const e=this.entries.map((i,t)=>({item:i,index:t}));return this.grouping?p.grouped(e,{kind:i=>i.kind,read:i=>this.accountsOf(i)}):e}async seekObservation(e,i){const t=this.entries.findIndex(n=>n.kind!=="interview"&&(n.event.id===i||i!==void 0&&n.url?.endsWith(`/${i}.json`))),s=t>=0?t:this.entries.findIndex(n=>n.kind!=="interview");if(s<0)return;this.shown.has(s)||await this.open(s),this.shown.get(s)?.querySelector(c)?.seekTo(e,i),this.shown.get(s)?.scrollIntoView({block:"nearest",behavior:"smooth"})}authors(e){const i=this.messages,t=(e??[]).map(s=>"people"in s?s.people:"org"in s?s.org:this.said.read(s.title)??"").filter(s=>s!=="");return t.length<2||!i?t.join(", "):`${t.slice(0,-1).join(", ")} ${i.linkAnd} ${t[t.length-1]}`}linkedTo(e){const i=this.messages;if(i){if(e.kind==="reading"){const t=[e.event.interpretationOf].flat().filter(r=>r!==void 0),s=this.entries.map((r,n)=>t.includes(r.event.id??"")?n:-1).filter(r=>r>=0);return s.length>0?{heading:i.interpretationOf,to:s}:void 0}if(e.kind==="observation"){const t=this.entries.map((s,r)=>s.kind==="interview"&&[s.event.interviewOf].flat().includes(e.event.id)?r:-1).filter(s=>s>=0);return t.length>0?{heading:i.passagesHeading,to:t}:void 0}}}draw(){const e=this.messages,i=this.json;if(!e||!i)return;this.byId("case-kind").textContent=e.caseHeading,this.byId("case-title").textContent=this.said.read(i.title)??i.id??"";const t=this.said.read(i.summary)??"",s=this.byId("case-summary");s.textContent=t;const r=this.byId("info");r.hidden=t==="",r.title=e.caseSummary,r.setAttribute("aria-label",e.caseSummary),t===""&&this.showSummary(!1),this.byId("events-heading").textContent=e.eventsHeading,this.byId("events-icon").innerHTML=z.CLOCK;const n=this.byId("share");n.title=e.shareCase,n.setAttribute("aria-label",e.shareCase);const o=this.byId("edit");o.title=e.editCase,o.setAttribute("aria-label",e.editCase);const a=this.byId("group-readings");a.title=e.groupReadings,a.setAttribute("aria-label",e.groupReadings),this.columns.label(e.resizeColumns),a.setAttribute("aria-pressed",String(this.grouping)),a.hidden=!this.entries.some(d=>d.kind==="reading");const h=this.listed(),f=d=>h.filter(({under:l})=>l===d).length,R=new Map(this.entries.map((d,l)=>[d,l]));this.timeline.render(h.filter(({index:d,under:l})=>l===void 0||!this.folded.has(R.get(l))||this.shown.has(d)).map(({item:d,index:l,under:N})=>{const x=this.card(d,l,N),T=this.grouping&&d.kind==="observation"?f(d):0;return T>0?{...x,readings:{count:T,folded:this.folded.has(l)}}:x}),e)}card(e,i,t){const s=this.linkedTo(e),r=(s?.to??[]).filter(o=>this.entries[o]!==t),n=t?this.messages.alsoAbout:s?.heading??"";return{at:i,kind:e.kind,title:e.title,meta:e.when.replace("T"," "),open:this.shown.has(i),...r.length>0?{links:{heading:n,to:r.map(o=>({at:o,title:this.entries[o].title}))}}:{},by:e.kind==="observation"?"":this.authors(e.event.by),...t?{nested:!0}:{}}}async loadFromSrc(e){await this.load(e),await this.player?.loaded}get scene(){return this.players()[0]?.scene}players(){return[...this.shown.entries()].sort(([e],[i])=>e-i).map(([,e])=>e.querySelector(c)).filter(e=>e!==null)}get sightingData(){return this.players()[0]?.sightingData}get player(){return this.players()[0]}}function de(){customElements.get(g)||customElements.define(g,u)}export{g as CASE_ELEMENT_NAME,u as CaseElement,Q as OPEN_CHANGE_EVENT,w as OPEN_EVENTS_ATTRIBUTE,v as SHOW_TIMELINE_ATTRIBUTE,de as register};