@rr0/ufoathome 0.194.0 → 0.196.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist-embed-scene/rr0-scene.mjs +4 -4
  2. package/dist-embed-sighting/CaseMessages_en-G5J5w1_d.js +1 -0
  3. package/dist-embed-sighting/CaseMessages_es-D7Rp1_1K.js +1 -0
  4. package/dist-embed-sighting/CaseMessages_fr-B8eZ1NIJ.js +1 -0
  5. package/dist-embed-sighting/CaseMessages_it-Cu02nVVo.js +1 -0
  6. package/dist-embed-sighting/{CaseReportExport-B9iaGKNP.js → CaseReportExport-CdRgJb5M.js} +1 -1
  7. package/dist-embed-sighting/rr0-sighting.mjs +343 -324
  8. package/dist-embed-sighting-editor/{AdsbLolArchiveProvider--KjPxNqw.js → AdsbLolArchiveProvider-BqEnqRP0.js} +1 -1
  9. package/dist-embed-sighting-editor/{BallesterGuaspAssessor-BTmq0r-G.js → BallesterGuaspAssessor-BL_yzudf.js} +1 -1
  10. package/dist-embed-sighting-editor/{BeamEditor-CI8-9VOc.js → BeamEditor-DA29mfqm.js} +1 -1
  11. package/dist-embed-sighting-editor/{BeamSystem-odg570aR.js → BeamSystem-DYohqXlF.js} +1 -1
  12. package/dist-embed-sighting-editor/{BirdEditor-DV3ndYff.js → BirdEditor-CAoRqqRV.js} +1 -1
  13. package/dist-embed-sighting-editor/{BirdFlock-O7K_g8y7.js → BirdFlock-TI63ZAKZ.js} +1 -1
  14. package/dist-embed-sighting-editor/{CaseEditorMessages_en-CoFukfwf.js → CaseEditorMessages_en-BPdxQsTX.js} +1 -1
  15. package/dist-embed-sighting-editor/{CaseEditorMessages_es-DZptbzB7.js → CaseEditorMessages_es-B48BAICC.js} +1 -1
  16. package/dist-embed-sighting-editor/{CaseEditorMessages_fr-DXl2GNmR.js → CaseEditorMessages_fr-DTWi9mIY.js} +1 -1
  17. package/dist-embed-sighting-editor/{CaseEditorMessages_it-ss10VmRM.js → CaseEditorMessages_it-CMLxgu8y.js} +1 -1
  18. package/dist-embed-sighting-editor/CaseElement-AXaERD8m.js +112 -0
  19. package/dist-embed-sighting-editor/CaseMessages_en-G5J5w1_d.js +1 -0
  20. package/dist-embed-sighting-editor/CaseMessages_es-D7Rp1_1K.js +1 -0
  21. package/dist-embed-sighting-editor/CaseMessages_fr-B8eZ1NIJ.js +1 -0
  22. package/dist-embed-sighting-editor/CaseMessages_it-Cu02nVVo.js +1 -0
  23. package/dist-embed-sighting-editor/{CaseReportExport-D0GXupCT.js → CaseReportExport-CDZp6xGk.js} +2 -2
  24. package/dist-embed-sighting-editor/{ContrailSystem-BddkU7fj.js → ContrailSystem-B0cQbaHc.js} +1 -1
  25. package/dist-embed-sighting-editor/{ControlPasses-CNlCUT1L.js → ControlPasses-BvS8haeS.js} +1 -1
  26. package/dist-embed-sighting-editor/{CoverageAssessor-DjY8iKp5.js → CoverageAssessor-DD1kSvun.js} +1 -1
  27. package/dist-embed-sighting-editor/{DroneEditor-DRsM2ash.js → DroneEditor-BRB2-dAw.js} +1 -1
  28. package/dist-embed-sighting-editor/{DroneFlight-Fr4Vgso3.js → DroneFlight-BpnBgJ9K.js} +1 -1
  29. package/dist-embed-sighting-editor/{Flightradar24Provider-BxeduRam.js → Flightradar24Provider-D5OdIL0L.js} +1 -1
  30. package/dist-embed-sighting-editor/{GLTFLoader-C6nlGTTi.js → GLTFLoader-DuqJVU4y.js} +1 -1
  31. package/dist-embed-sighting-editor/{HeadlightSystem-DI5wHYZu.js → HeadlightSystem-BejdfHqe.js} +1 -1
  32. package/dist-embed-sighting-editor/{HynekAssessor-DlXalbph.js → HynekAssessor-CwzpS7YP.js} +1 -1
  33. package/dist-embed-sighting-editor/{LanternEditor-M887ltwe.js → LanternEditor-BnXAwLuQ.js} +1 -1
  34. package/dist-embed-sighting-editor/{LaserBeam-Drpkr84G.js → LaserBeam-tqM2fwHf.js} +1 -1
  35. package/dist-embed-sighting-editor/{LaunchEditor-BjAk4XZR.js → LaunchEditor-vwecAGwH.js} +1 -1
  36. package/dist-embed-sighting-editor/{LaunchPlume-CrzPcqw7.js → LaunchPlume-DWyU0YyJ.js} +1 -1
  37. package/dist-embed-sighting-editor/{LaunchSimulation-C1ZWpKZT.js → LaunchSimulation-C_OJQoKC.js} +1 -1
  38. package/dist-embed-sighting-editor/{ModelSource-Bko_3OJt.js → ModelSource-D1Wt6VYS.js} +1 -1
  39. package/dist-embed-sighting-editor/{ModelThumbnails-DSshyLu2.js → ModelThumbnails-C_8KCF7H.js} +1 -1
  40. package/dist-embed-sighting-editor/{ModelViewer-_yhAYvNy.js → ModelViewer-Cy-6IZBY.js} +1 -1
  41. package/dist-embed-sighting-editor/{ModuleConformance-B6iFVb8X.js → ModuleConformance-DYi4XZdB.js} +2 -2
  42. package/dist-embed-sighting-editor/{ModuleSession-jKFl1FMo.js → ModuleSession-BDbaoiCf.js} +2 -2
  43. package/dist-embed-sighting-editor/ModuleThree-DRf9SEr_.js +1 -0
  44. package/dist-embed-sighting-editor/{ModulesPanelElement-VPRCdjmv.js → ModulesPanelElement-hDjGLhRa.js} +3 -3
  45. package/dist-embed-sighting-editor/{NearestApproach-O8k2n_qL.js → NearestApproach-D6tQo7dk.js} +1 -1
  46. package/dist-embed-sighting-editor/{PoherAssessor-sTJEnlmb.js → PoherAssessor-BTYpHucH.js} +1 -1
  47. package/dist-embed-sighting-editor/{RailwaySystem-BZqNSSFA.js → RailwaySystem-D_8D64Bu.js} +1 -1
  48. package/dist-embed-sighting-editor/{ReentryEditor-DfDGpL5C.js → ReentryEditor-D7HxkvKP.js} +2 -2
  49. package/dist-embed-sighting-editor/{ReentrySimulation-BuUK0niI.js → ReentrySimulation-Bom073AV.js} +1 -1
  50. package/dist-embed-sighting-editor/{ReferenceSystem-DvcQp167.js → ReferenceSystem-D_eueNAb.js} +1 -1
  51. package/dist-embed-sighting-editor/{SightingElement-BfxNhmfn.js → SightingElement-DukKlaH1.js} +4 -4
  52. package/dist-embed-sighting-editor/{SkyLantern-B7UlFgmB.js → SkyLantern-BDpxvmY3.js} +1 -1
  53. package/dist-embed-sighting-editor/{TraceSystem-vZF4B5EC.js → TraceSystem-B1mmypS3.js} +2 -2
  54. package/dist-embed-sighting-editor/{WaterSystem-DSWmZbiL.js → WaterSystem-mZ-f2CcD.js} +2 -2
  55. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +378 -366
  56. package/dist-embed-sighting-editor/{trafficRuntime-C5BXL-G6.js → trafficRuntime-CvK_m6bC.js} +1 -1
  57. package/dist-embed-ufoathome/{AdsbLolArchiveProvider-DXRO-h2K.js → AdsbLolArchiveProvider-BAZqWk1I.js} +1 -1
  58. package/dist-embed-ufoathome/{BallesterGuaspAssessor-ZSDHMhXN.js → BallesterGuaspAssessor-D5DnaJGn.js} +1 -1
  59. package/dist-embed-ufoathome/{BeamEditor-BvF4J204.js → BeamEditor-DmuKTRqU.js} +1 -1
  60. package/dist-embed-ufoathome/{BeamSystem-Yg5JRiCT.js → BeamSystem-KHzcEosy.js} +1 -1
  61. package/dist-embed-ufoathome/{BodyEditor-CRJFVGzZ.js → BodyEditor-Blkm_Xmd.js} +1 -1
  62. package/dist-embed-ufoathome/{CaseEditorElement-MwO-zwnP.js → CaseEditorElement-BTZu9wey.js} +41 -36
  63. package/dist-embed-ufoathome/{CaseEditorMessages_en-CoFukfwf.js → CaseEditorMessages_en-BPdxQsTX.js} +1 -1
  64. package/dist-embed-ufoathome/{CaseEditorMessages_es-DZptbzB7.js → CaseEditorMessages_es-B48BAICC.js} +1 -1
  65. package/dist-embed-ufoathome/{CaseEditorMessages_fr-DXl2GNmR.js → CaseEditorMessages_fr-DTWi9mIY.js} +1 -1
  66. package/dist-embed-ufoathome/{CaseEditorMessages_it-ss10VmRM.js → CaseEditorMessages_it-CMLxgu8y.js} +1 -1
  67. package/dist-embed-ufoathome/CaseElement-Cr3vTWdf.js +112 -0
  68. package/dist-embed-ufoathome/CaseMessages_en-G5J5w1_d.js +1 -0
  69. package/dist-embed-ufoathome/CaseMessages_es-D7Rp1_1K.js +1 -0
  70. package/dist-embed-ufoathome/CaseMessages_fr-B8eZ1NIJ.js +1 -0
  71. package/dist-embed-ufoathome/CaseMessages_it-Cu02nVVo.js +1 -0
  72. package/dist-embed-ufoathome/{CaseReportExport-D9YyGZHP.js → CaseReportExport-CyuSf3U_.js} +3 -3
  73. package/dist-embed-ufoathome/{CaseTimeline-CnP5rqaK.js → ColumnResize-DifCqMt1.js} +14 -7
  74. package/dist-embed-ufoathome/{ContrailSystem-O_yvjart.js → ContrailSystem-DqZ8PoEd.js} +1 -1
  75. package/dist-embed-ufoathome/{ControlPasses-BaglOE-7.js → ControlPasses-BtU_MVQU.js} +1 -1
  76. package/dist-embed-ufoathome/{CoverageAssessor-CBh0sDI1.js → CoverageAssessor-DkVligEj.js} +1 -1
  77. package/dist-embed-ufoathome/{Flightradar24Provider-C8Uj-qTs.js → Flightradar24Provider-GYjtvwah.js} +1 -1
  78. package/dist-embed-ufoathome/{GLTFLoader-B4SVqjkZ.js → GLTFLoader-DzEwUqtj.js} +1 -1
  79. package/dist-embed-ufoathome/{GeoJsonExport-C-daFhc2.js → GeoJsonExport-B1i0YjqN.js} +1 -1
  80. package/dist-embed-ufoathome/{GeographicFigures-N4WyX3J_.js → GeographicFigures-D5ZCRN0K.js} +1 -1
  81. package/dist-embed-ufoathome/{HeadlightSystem-7mtgTwud.js → HeadlightSystem-x2xYh-cs.js} +1 -1
  82. package/dist-embed-ufoathome/{HynekAssessor-DdoHR-Qt.js → HynekAssessor-DOUPfuRV.js} +1 -1
  83. package/dist-embed-ufoathome/{InterviewEditorElement-BSXLlt4e.js → InterviewEditorElement-Dt-KQiv0.js} +1 -1
  84. package/dist-embed-ufoathome/{InterviewElement-Dwk9iHNv.js → InterviewElement-BPsBLXlf.js} +1 -1
  85. package/dist-embed-ufoathome/{KmlExport-CX-tTjIv.js → KmlExport-JEXMAssj.js} +1 -1
  86. package/dist-embed-ufoathome/{LaserBeam-DUL1O57g.js → LaserBeam-Cy9lfcCE.js} +1 -1
  87. package/dist-embed-ufoathome/{LaunchEditor-X_zWEOTY.js → LaunchEditor-zWZhMyLf.js} +1 -1
  88. package/dist-embed-ufoathome/{LaunchPlume-CcfhClxb.js → LaunchPlume-CcUQvACB.js} +1 -1
  89. package/dist-embed-ufoathome/{LaunchSimulation-C9gbGzGM.js → LaunchSimulation-DRH0rTE7.js} +1 -1
  90. package/dist-embed-ufoathome/{ModelSource-BtuW2Ztg.js → ModelSource-Dljnl-RW.js} +1 -1
  91. package/dist-embed-ufoathome/{ModelThumbnails-CacTTCW4.js → ModelThumbnails-DeaPuKSb.js} +1 -1
  92. package/dist-embed-ufoathome/{ModelViewer-BlFPQJAr.js → ModelViewer-B-ZLBTmq.js} +1 -1
  93. package/dist-embed-ufoathome/{ModuleConformance-qYpBoQH9.js → ModuleConformance-Bd8yK7Ic.js} +2 -2
  94. package/dist-embed-ufoathome/{ModuleSession-D4LhYKvL.js → ModuleSession-DXdpVejH.js} +3 -3
  95. package/dist-embed-ufoathome/{ModuleThree-DLikU-uy.js → ModuleThree-BL59t48W.js} +1 -1
  96. package/dist-embed-ufoathome/{ModulesPanelElement-GY7cTQ5t.js → ModulesPanelElement-6KUAMJcl.js} +3 -3
  97. package/dist-embed-ufoathome/{NearestApproach-4ntSx6IQ.js → NearestApproach-wbFbwOAh.js} +1 -1
  98. package/dist-embed-ufoathome/{PictureRegistration-BLs4DkTI.js → PictureRegistration-CfSYGbeh.js} +1 -1
  99. package/dist-embed-ufoathome/{PoherAssessor-6t5qvmJy.js → PoherAssessor-CVIeQpd7.js} +1 -1
  100. package/dist-embed-ufoathome/{RailwaySystem-Dm-PbG_D.js → RailwaySystem-DTXetaSg.js} +1 -1
  101. package/dist-embed-ufoathome/{ReentryEditor-C7A3Kh3_.js → ReentryEditor-7Fxkxq-Q.js} +1 -1
  102. package/dist-embed-ufoathome/{ReentrySimulation-BlgfVSxb.js → ReentrySimulation-T3H0mJI3.js} +1 -1
  103. package/dist-embed-ufoathome/{ReferenceSystem-Bv62TprV.js → ReferenceSystem-CJaq2UzO.js} +1 -1
  104. package/dist-embed-ufoathome/{ShareDialogElement-DLr5u_tk.js → ShareDialogElement-ClhewPap.js} +11 -11
  105. package/dist-embed-ufoathome/{SightingElement-DuNE_Yt0.js → SightingElement-BtHQ5LDE.js} +4 -4
  106. package/dist-embed-ufoathome/{TraceSystem-Cl5kzaIr.js → TraceSystem-B42kzZXG.js} +1 -1
  107. package/dist-embed-ufoathome/{VideoButton-DXPI7_Vt.js → VideoButton-DhanY6AD.js} +1 -1
  108. package/dist-embed-ufoathome/{WaterSystem-CTGGh-Y-.js → WaterSystem-DyJivqCq.js} +1 -1
  109. package/dist-embed-ufoathome/rr0-ufoathome.mjs +3 -3
  110. package/dist-embed-ufoathome/{surroundingsSources-CVKKb8h6.js → surroundingsSources-DEMGw8rm.js} +1 -1
  111. package/dist-embed-ufoathome/{trafficRuntime-DvKPyJcx.js → trafficRuntime-BJFdLEcT.js} +1 -1
  112. package/package.json +1 -1
  113. package/dist-embed-sighting/CaseMessages_en-BbbbikHH.js +0 -1
  114. package/dist-embed-sighting/CaseMessages_es-AHBxl8Ka.js +0 -1
  115. package/dist-embed-sighting/CaseMessages_fr-CD33PQCH.js +0 -1
  116. package/dist-embed-sighting/CaseMessages_it-DyMACGSU.js +0 -1
  117. package/dist-embed-sighting-editor/CaseElement-DzwFIDZZ.js +0 -100
  118. package/dist-embed-sighting-editor/CaseMessages_en-BbbbikHH.js +0 -1
  119. package/dist-embed-sighting-editor/CaseMessages_es-AHBxl8Ka.js +0 -1
  120. package/dist-embed-sighting-editor/CaseMessages_fr-CD33PQCH.js +0 -1
  121. package/dist-embed-sighting-editor/CaseMessages_it-DyMACGSU.js +0 -1
  122. package/dist-embed-sighting-editor/ModuleThree-Fvr5G-Yh.js +0 -1
  123. package/dist-embed-ufoathome/CaseElement-Ch0QzF7-.js +0 -100
  124. package/dist-embed-ufoathome/CaseMessages_en-BbbbikHH.js +0 -1
  125. package/dist-embed-ufoathome/CaseMessages_es-AHBxl8Ka.js +0 -1
  126. package/dist-embed-ufoathome/CaseMessages_fr-CD33PQCH.js +0 -1
  127. package/dist-embed-ufoathome/CaseMessages_it-DyMACGSU.js +0 -1
@@ -1,4 +1,4 @@
1
- import{P as W,j as Y,R as B,k as K,B as H,m as Q,n as P,_ as Z,o as J,a as C,p as F}from"./rr0-sighting-editor.mjs";class j{static of(t,n,a,s,i,e=new Date){const r=t.events??[],c=f=>f.url?new URL(f.url,n).href:void 0,o=r.filter(f=>f.eventType==="sighting"&&c(f)),u=o.filter(f=>f.interpretationOf===void 0),p=u.map(f=>j.witnessOf(f,c(f),a.get(c(f)),s)),l=f=>{const w=[f.interpretationOf].flat().filter(b=>typeof b=="string");return u.find(b=>b.id!==void 0&&w.includes(b.id))??u.find(b=>w.includes(a.get(c(b))?.id??""))},m=o.filter(f=>f.interpretationOf!==void 0).map(f=>{const w=l(f),b=w?p[u.indexOf(w)]:void 0;return j.readingOf(f,c(f),a.get(c(f)),b,w?a.get(c(w)):void 0,s,i)}),d=r.filter(f=>f.eventType==="interview").map(f=>{const w=u.find(b=>b.id!==void 0&&[f.interviewOf].flat().includes(b.id));return{title:s.read(f.title)??f.id??"",...w?{witness:p[u.indexOf(w)].title}:{},...f.time?{time:f.time}:{},by:j.names(f.by,s),...f.medium?{medium:f.medium}:{}}});j.placeOnMap(p,m);const g=s.read(t.summary);return{generatedAt:e.toISOString(),case:{...t.id?{id:t.id}:{},...t.title?{title:t.title}:{},...t.time?{time:t.time}:{},url:n,...g?{summary:g}:{}},witnesses:p,readings:m,interviews:d}}static witnessOf(t,n,a,s){const i=s.read(t.title)??s.read(a?.observer?.title)??t.id??n,e={...t.id?{id:t.id}:{},title:i,url:n,...t.time?{time:t.time}:{},indications:[],values:[],sources:[],moments:[]};if(!a)return e;const{recording:r,provenance:c}=W.strip(a),o=s.read(r.description);o&&(e.description=o);const u=r.place?.name;u&&(e.place=u),!e.time&&r.time&&(e.time=r.time),typeof r.durationSeconds=="number"&&(e.durationSeconds=r.durationSeconds),r.instrument&&(e.instrument=r.instrument),e.sources=(r.sources??[]).map(b=>{const v=b,y=s.read(v.title);return{...y?{title:y}:{},...v.authors?.length?{authors:v.authors}:{},...v.publication?.publisher?{publisher:v.publication.publisher}:{},...v.publication?.time?{time:v.publication.time}:{},...v.url?{url:v.url}:{},...v.index?{index:v.index}:{}}}),e.moments=[...r.milestones??[]].sort((b,v)=>b.t-v.t).map(b=>{const v=s.read(b.note);return{t:b.t,label:s.read(b.label)??"",...v?{note:v}:{}}});const p=r.observerTrack?.keyframes?.[0]?.pose,l=r.place?.locations?.[0],m=p?.lat??l?.lat,d=p?.lng??l?.lng;typeof m=="number"&&typeof d=="number"&&Object.assign(e,{lat:m,lng:d}),e.values=j.valuesOf(c,r,()=>!0,s);const g=Y.MODELS[0],f=r.account?.conditions,w=new Map;for(const b of r.timeline?.keyframes??[])for(const v of b.shapes){const y=s.read(v.shape.title);y&&!w.has(v.sourceId)&&w.set(v.sourceId,y)}return e.phenomena=Object.fromEntries(w),(r.timeline?.keyframes??[]).forEach((b,v)=>b.shapes.forEach((y,h)=>{const M=`timeline.keyframes.${v}.shapes.${h}.shape`,E=B.traced(c,`${M}.aim`),O=B.traced(c,`${M}.angular`);if(!E&&!O)return;const $=y.shape,x=c.at(`${M}.aim`)??c.at(`${M}.angular`),I={t:b.t,sourceId:y.sourceId,directionSaid:E,sizeSaid:O,...w.has(y.sourceId)?{phenomenon:w.get(y.sourceId)}:{},...$.aim?{aim:{azimuthDeg:$.aim.azimuthDeg,altitudeDeg:$.aim.altitudeDeg}}:{},...$.angular?{angular:$.angular}:{},...x?{basis:x.basis}:{},...x?.rationale?{rationale:s.read(x.rationale)??""}:{},...x?.source?{source:x.source}:{}};if(E&&$.aim){const L=(G,A,R)=>{const V=c.at(`${M}.aim.${R}`)??c.at(`${M}.aim`),q=g.law({kind:G,value:A,basis:V?.basis,how:V?.how},f);return[q.low??A,q.high??A]};I.uncertainty={azimuthDeg:L("heading",$.aim.azimuthDeg,"azimuthDeg"),altitudeDeg:L("elevation",$.aim.altitudeDeg,"altitudeDeg")}}e.indications.push(I)})),e}static readingOf(t,n,a,s,i,e,r){const c={...t.id?{id:t.id}:{},title:e.read(t.title)??e.read(a?.interpretation?.title)??n,url:n,reads:s?.title??"",by:j.names(t.by,e),...t.time?{time:t.time}:{},supposed:[],findings:[],comparisons:[],paths:[]};if(!a)return c;const{recording:o,provenance:u}=W.strip(a),p=e.read(o.description)??e.read(o.summary);p&&(c.description=p),c.supposed=j.valuesOf(u,o,(d,g)=>d.startsWith("interpretation")&&(g==="assumed"||g==="fitted"),e);const l=d=>typeof d=="string"?d:e.read(d)??"";if(c.findings=(o.interpretation?.findings??[]).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!0})),!i)return c;r&&c.findings.push(...r.findingsOf(i,a).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!1})));const m=o.interpretation?.bodies??[];if(m.length>0)try{const d=B.forAccount(i);c.sensitivity=d.of(m,u),c.comparisons=d.comparisons(m),c.paths=j.pathsOf(m,i,c.comparisons.map(g=>g.t))}catch{}return c}static pathsOf(t,n,a){const s=K(n),i={heightAt:()=>0},e=r=>H.eyeOf(s,r,i);return t.filter(r=>(r.explains?.length??0)>0).map(r=>{const c=new H(r,i,e),u=[...new Set([...r.track.map(p=>p.t),...a])].sort((p,l)=>p-l).map(p=>({t:p,state:c.at(p)})).filter(p=>p.state!==void 0).map(({t:p,state:l})=>({t:p,eastM:l.eastM,northM:l.northM}));return{bodyId:r.id,points:u}}).filter(r=>r.points.length>0)}static placeOnMap(t,n){const a=t.find(s=>s.lat!==void 0&&s.lng!==void 0);if(a){for(const s of t){if(s.lat===void 0||s.lng===void 0)continue;const i=Q(s.lat,s.lng,a.lat,a.lng);s.at={eastM:i.x,northM:-i.z}}for(const s of n){const i=t.find(e=>e.title===s.reads)?.at;if(!i){s.paths=[];continue}for(const e of s.paths)for(const r of e.points)r.eastM+=i.eastM,r.northM+=i.northM}}}static valuesOf(t,n,a,s){return t.paths().flatMap(i=>{const e=t.at(i);return a(i,e.basis)?[{path:i,value:i.split(".").reduce((r,c)=>r?.[c],n),basis:e.basis,...e.rationale?{rationale:s.read(e.rationale)??""}:{},...e.source?{source:e.source}:{}}]:[]})}static names(t,n){const a=s=>s.replace(/([a-z])([A-Z])/g,"$1 $2");return(t??[]).map(s=>{if("people"in s){const[e,...r]=a(s.people).split(" ");return[...r,e].join(" ")}if("org"in s)return a(s.org);const i=s;return n.read(i.title)??i.id??""}).filter(s=>s!=="")}}class X{constructor(t,n){this.texts=t,this.language=n,this.decimal=new Intl.NumberFormat(n,{maximumFractionDigits:1}),this.signed=new Intl.NumberFormat(n,{maximumFractionDigits:2,signDisplay:"exceptZero"})}decimal;signed;number(t){return t===void 0||!Number.isFinite(t)?"":this.decimal.format(t)}degrees(t){return t===void 0?"":`${this.number(t)}°`}azimuth(t){return t===void 0?"":this.degrees((t%360+360)%360)}instant(t){return`${this.number(t/1e3)} s`}amount(t,n){switch(t){case"azimuth":case"altitude":return`${this.signed.format(n)}°`;case"time":return`${this.signed.format(n/1e3)} s`;default:return`×${new Intl.NumberFormat(this.language,{maximumFractionDigits:2}).format(n)}`}}rests(t){const n=t.source;return[n?[n.said?`interview ${n.said.interview??""} #${n.said.segment}`.replace(" "," "):void 0,typeof n.document=="string"?n.document:void 0,n.at,n.picture,n.tool,n.url].filter(Boolean).join(", "):"",t.rationale].filter(s=>s&&s!=="").join(" : ")}value(t){const n=t.value;return typeof n=="number"?this.number(n):typeof n=="string"?n:Array.isArray(n)?`[${n.length}]`:n===void 0?"":JSON.stringify(n)}robustness(t){const n=this.texts.robustness;return!t||t.compared===0?{kind:"nothing",text:n.nothing}:B.measurable(t)?t.sufficient===!0?{kind:"sufficient",text:n.sufficient}:t.sufficient===!1?{kind:"fine-tuned",text:n.fineTuned.replace("{knob}",this.texts.knobs[t.margins[0].knob])}:{kind:"unjudged",text:n.unjudged}:{kind:"too-few",text:n.tooFew}}reproduced(t){return t&&t.compared>0?`${Math.round(t.agreement*t.compared)} / ${t.compared}`:""}ends(t){const n=(a,s)=>`${s?"≥ ":""}${this.amount(t.knob,a)}`;return{from:n(t.lower,t.lowerReached),to:n(t.upper,t.upperReached)}}fill(t,n){return t.replace(/\{(\w+)\}/g,(a,s)=>s in n?n[s]:a)}}class T{static FORMAT="ufoathome-case-report";static VERSION=1;static json(t,n){return JSON.stringify({format:T.FORMAT,version:T.VERSION,generator:`UFO@home ${n}`,...t},null,2)}static csv(t,n,a){const s=new X(n,a),i=n.columns,e=c=>c===void 0||!Number.isFinite(c)?"":String(Math.round(c*1e3)/1e3),r={};return r["indications.csv"]=T.table([i.witness,`${i.instant} (s)`,i.phenomenon,`${i.azimuth} (°)`,`${i.altitude} (°)`,`${i.azimuth} min`,`${i.azimuth} max`,`${i.altitude} min`,`${i.altitude} max`,`${i.size} (°)`,i.basis,i.rests],t.witnesses.flatMap(c=>c.indications.map(o=>[c.title,e(o.t/1e3),o.phenomenon??o.sourceId,e(o.aim?.azimuthDeg),e(o.aim?.altitudeDeg),e(o.uncertainty?.azimuthDeg[0]),e(o.uncertainty?.azimuthDeg[1]),e(o.uncertainty?.altitudeDeg[0]),e(o.uncertainty?.altitudeDeg[1]),o.sizeSaid?e(o.angular?.widthDeg):"",o.basis?n.bases[o.basis]:"",s.rests(o)]))),r["values.csv"]=T.table([i.witness,i.reading,i.path,i.value,i.basis,i.rests],[...t.witnesses.flatMap(c=>c.values.map(o=>[c.title,"",o.path,s.value(o),n.bases[o.basis],s.rests(o)])),...t.readings.flatMap(c=>c.supposed.map(o=>[c.reads,c.title,o.path,s.value(o),n.bases[o.basis],s.rests(o)]))]),r["readings.csv"]=T.table([i.reading,i.reads,i.by,i.time,i.reproduced,i.compared,`${i.gap} (°)`,i.robustness,i.supposedCount],t.readings.map(c=>[c.title,c.reads,c.by.join(", "),c.time??"",c.sensitivity&&c.sensitivity.compared>0?String(Math.round(c.sensitivity.agreement*c.sensitivity.compared)):"",c.sensitivity&&c.sensitivity.compared>0?String(c.sensitivity.compared):"",e(c.sensitivity?.medianSeparationDeg),s.robustness(c.sensitivity).text,String(c.supposed.length)])),r["margins.csv"]=T.table([i.reading,i.reads,i.knob,i.from,i.to,`${i.reference} min`,`${i.reference} max`,i.covered],t.readings.flatMap(c=>(c.sensitivity?.margins??[]).map(o=>[c.title,c.reads,n.knobs[o.knob],e(o.lower),e(o.upper),e(o.reference?.lower),e(o.reference?.upper),o.coverage===void 0?"":e(o.coverage)]))),r["comparisons.csv"]=T.table([i.reading,i.reads,`${i.instant} (s)`,i.phenomenon,`${i.said} ${i.azimuth}`,`${i.said} ${i.altitude}`,`${i.read} ${i.azimuth}`,`${i.read} ${i.altitude}`,`${i.separation} (°)`,i.agrees],t.readings.flatMap(c=>c.comparisons.map(o=>[c.title,c.reads,e(o.t/1e3),t.witnesses.find(u=>u.title===c.reads)?.phenomena?.[o.sourceId]??o.sourceId,e(o.said?.azimuthDeg),e(o.said?.altitudeDeg),e(o.predicted.azimuthDeg),e(o.predicted.altitudeDeg),e(o.separationDeg),o.agrees?n.yes:n.no]))),r["findings.csv"]=T.table([i.reading,i.reads,i.finding,i.outcome,i.against,i.origin],t.readings.flatMap(c=>c.findings.map(o=>[c.title,c.reads,o.text,n.outcomes[o.outcome],o.outcome==="fails"?n.grounds[o.against??"established"]:"",n.origins[o.written?"written":"computed"]]))),r}static table(t,n){const a=s=>/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s;return[t,...n].map(s=>s.map(a).join(",")).join(`\r
1
+ import{P as W,j as Y,R as Z,k as K,B as H,m as Q,n as P,_ as B,o as J,a as C,p as F}from"./rr0-sighting-editor.mjs";class j{static of(t,n,a,s,i,e=new Date){const r=t.events??[],c=f=>f.url?new URL(f.url,n).href:void 0,o=r.filter(f=>f.eventType==="sighting"&&c(f)),u=o.filter(f=>f.interpretationOf===void 0),p=u.map(f=>j.witnessOf(f,c(f),a.get(c(f)),s)),l=f=>{const w=[f.interpretationOf].flat().filter(b=>typeof b=="string");return u.find(b=>b.id!==void 0&&w.includes(b.id))??u.find(b=>w.includes(a.get(c(b))?.id??""))},m=o.filter(f=>f.interpretationOf!==void 0).map(f=>{const w=l(f),b=w?p[u.indexOf(w)]:void 0;return j.readingOf(f,c(f),a.get(c(f)),b,w?a.get(c(w)):void 0,s,i)}),d=r.filter(f=>f.eventType==="interview").map(f=>{const w=u.find(b=>b.id!==void 0&&[f.interviewOf].flat().includes(b.id));return{title:s.read(f.title)??f.id??"",...w?{witness:p[u.indexOf(w)].title}:{},...f.time?{time:f.time}:{},by:j.names(f.by,s),...f.medium?{medium:f.medium}:{}}});j.placeOnMap(p,m);const g=s.read(t.summary);return{generatedAt:e.toISOString(),case:{...t.id?{id:t.id}:{},...t.title?{title:t.title}:{},...t.time?{time:t.time}:{},url:n,...g?{summary:g}:{}},witnesses:p,readings:m,interviews:d}}static witnessOf(t,n,a,s){const i=s.read(t.title)??s.read(a?.observer?.title)??t.id??n,e={...t.id?{id:t.id}:{},title:i,url:n,...t.time?{time:t.time}:{},indications:[],values:[],sources:[],moments:[]};if(!a)return e;const{recording:r,provenance:c}=W.strip(a),o=s.read(r.description);o&&(e.description=o);const u=r.place?.name;u&&(e.place=u),!e.time&&r.time&&(e.time=r.time),typeof r.durationSeconds=="number"&&(e.durationSeconds=r.durationSeconds),r.instrument&&(e.instrument=r.instrument),e.sources=(r.sources??[]).map(b=>{const v=b,y=s.read(v.title);return{...y?{title:y}:{},...v.authors?.length?{authors:v.authors}:{},...v.publication?.publisher?{publisher:v.publication.publisher}:{},...v.publication?.time?{time:v.publication.time}:{},...v.url?{url:v.url}:{},...v.index?{index:v.index}:{}}}),e.moments=[...r.milestones??[]].sort((b,v)=>b.t-v.t).map(b=>{const v=s.read(b.note);return{t:b.t,label:s.read(b.label)??"",...v?{note:v}:{}}});const p=r.observerTrack?.keyframes?.[0]?.pose,l=r.place?.locations?.[0],m=p?.lat??l?.lat,d=p?.lng??l?.lng;typeof m=="number"&&typeof d=="number"&&Object.assign(e,{lat:m,lng:d}),e.values=j.valuesOf(c,r,()=>!0,s);const g=Y.MODELS[0],f=r.account?.conditions,w=new Map;for(const b of r.timeline?.keyframes??[])for(const v of b.shapes){const y=s.read(v.shape.title);y&&!w.has(v.sourceId)&&w.set(v.sourceId,y)}return e.phenomena=Object.fromEntries(w),(r.timeline?.keyframes??[]).forEach((b,v)=>b.shapes.forEach((y,h)=>{const M=`timeline.keyframes.${v}.shapes.${h}.shape`,E=Z.traced(c,`${M}.aim`),O=Z.traced(c,`${M}.angular`);if(!E&&!O)return;const $=y.shape,x=c.at(`${M}.aim`)??c.at(`${M}.angular`),I={t:b.t,sourceId:y.sourceId,directionSaid:E,sizeSaid:O,...w.has(y.sourceId)?{phenomenon:w.get(y.sourceId)}:{},...$.aim?{aim:{azimuthDeg:$.aim.azimuthDeg,altitudeDeg:$.aim.altitudeDeg}}:{},...$.angular?{angular:$.angular}:{},...x?{basis:x.basis}:{},...x?.rationale?{rationale:s.read(x.rationale)??""}:{},...x?.source?{source:x.source}:{}};if(E&&$.aim){const L=(G,A,R)=>{const V=c.at(`${M}.aim.${R}`)??c.at(`${M}.aim`),q=g.law({kind:G,value:A,basis:V?.basis,how:V?.how},f);return[q.low??A,q.high??A]};I.uncertainty={azimuthDeg:L("heading",$.aim.azimuthDeg,"azimuthDeg"),altitudeDeg:L("elevation",$.aim.altitudeDeg,"altitudeDeg")}}e.indications.push(I)})),e}static readingOf(t,n,a,s,i,e,r){const c={...t.id?{id:t.id}:{},title:e.read(t.title)??e.read(a?.interpretation?.title)??n,url:n,reads:s?.title??"",by:j.names(t.by,e),...t.time?{time:t.time}:{},supposed:[],findings:[],comparisons:[],paths:[]};if(!a)return c;const{recording:o,provenance:u}=W.strip(a),p=e.read(o.description)??e.read(o.summary);p&&(c.description=p),c.supposed=j.valuesOf(u,o,(d,g)=>d.startsWith("interpretation")&&(g==="assumed"||g==="fitted"),e);const l=d=>typeof d=="string"?d:e.read(d)??"";if(c.findings=(o.interpretation?.findings??[]).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!0})),!i)return c;r&&c.findings.push(...r.findingsOf(i,a).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!1})));const m=o.interpretation?.bodies??[];if(m.length>0)try{const d=Z.forAccount(i);c.sensitivity=d.of(m,u),c.comparisons=d.comparisons(m),c.paths=j.pathsOf(m,i,c.comparisons.map(g=>g.t))}catch{}return c}static pathsOf(t,n,a){const s=K(n),i={heightAt:()=>0},e=r=>H.eyeOf(s,r,i);return t.filter(r=>(r.explains?.length??0)>0).map(r=>{const c=new H(r,i,e),u=[...new Set([...r.track.map(p=>p.t),...a])].sort((p,l)=>p-l).map(p=>({t:p,state:c.at(p)})).filter(p=>p.state!==void 0).map(({t:p,state:l})=>({t:p,eastM:l.eastM,northM:l.northM}));return{bodyId:r.id,points:u}}).filter(r=>r.points.length>0)}static placeOnMap(t,n){const a=t.find(s=>s.lat!==void 0&&s.lng!==void 0);if(a){for(const s of t){if(s.lat===void 0||s.lng===void 0)continue;const i=Q(s.lat,s.lng,a.lat,a.lng);s.at={eastM:i.x,northM:-i.z}}for(const s of n){const i=t.find(e=>e.title===s.reads)?.at;if(!i){s.paths=[];continue}for(const e of s.paths)for(const r of e.points)r.eastM+=i.eastM,r.northM+=i.northM}}}static valuesOf(t,n,a,s){return t.paths().flatMap(i=>{const e=t.at(i);return a(i,e.basis)?[{path:i,value:i.split(".").reduce((r,c)=>r?.[c],n),basis:e.basis,...e.rationale?{rationale:s.read(e.rationale)??""}:{},...e.source?{source:e.source}:{}}]:[]})}static names(t,n){const a=s=>s.replace(/([a-z])([A-Z])/g,"$1 $2");return(t??[]).map(s=>{if("people"in s){const[e,...r]=a(s.people).split(" ");return[...r,e].join(" ")}if("org"in s)return a(s.org);const i=s;return n.read(i.title)??i.id??""}).filter(s=>s!=="")}}class X{constructor(t,n){this.texts=t,this.language=n,this.decimal=new Intl.NumberFormat(n,{maximumFractionDigits:1}),this.signed=new Intl.NumberFormat(n,{maximumFractionDigits:2,signDisplay:"exceptZero"})}decimal;signed;number(t){return t===void 0||!Number.isFinite(t)?"":this.decimal.format(t)}degrees(t){return t===void 0?"":`${this.number(t)}°`}azimuth(t){return t===void 0?"":this.degrees((t%360+360)%360)}instant(t){return`${this.number(t/1e3)} s`}amount(t,n){switch(t){case"azimuth":case"altitude":return`${this.signed.format(n)}°`;case"time":return`${this.signed.format(n/1e3)} s`;default:return`×${new Intl.NumberFormat(this.language,{maximumFractionDigits:2}).format(n)}`}}rests(t){const n=t.source;return[n?[n.said?`interview ${n.said.interview??""} #${n.said.segment}`.replace(" "," "):void 0,typeof n.document=="string"?n.document:void 0,n.at,n.picture,n.tool,n.url].filter(Boolean).join(", "):"",t.rationale].filter(s=>s&&s!=="").join(" : ")}value(t){const n=t.value;return typeof n=="number"?this.number(n):typeof n=="string"?n:Array.isArray(n)?`[${n.length}]`:n===void 0?"":JSON.stringify(n)}robustness(t){const n=this.texts.robustness;return!t||t.compared===0?{kind:"nothing",text:n.nothing}:Z.measurable(t)?t.sufficient===!0?{kind:"sufficient",text:n.sufficient}:t.sufficient===!1?{kind:"fine-tuned",text:n.fineTuned.replace("{knob}",this.texts.knobs[t.margins[0].knob])}:{kind:"unjudged",text:n.unjudged}:{kind:"too-few",text:n.tooFew}}reproduced(t){return t&&t.compared>0?`${Math.round(t.agreement*t.compared)} / ${t.compared}`:""}ends(t){const n=(a,s)=>`${s?"≥ ":""}${this.amount(t.knob,a)}`;return{from:n(t.lower,t.lowerReached),to:n(t.upper,t.upperReached)}}fill(t,n){return t.replace(/\{(\w+)\}/g,(a,s)=>s in n?n[s]:a)}}class T{static FORMAT="ufoathome-case-report";static VERSION=1;static json(t,n){return JSON.stringify({format:T.FORMAT,version:T.VERSION,generator:`UFO@home ${n}`,...t},null,2)}static csv(t,n,a){const s=new X(n,a),i=n.columns,e=c=>c===void 0||!Number.isFinite(c)?"":String(Math.round(c*1e3)/1e3),r={};return r["indications.csv"]=T.table([i.witness,`${i.instant} (s)`,i.phenomenon,`${i.azimuth} (°)`,`${i.altitude} (°)`,`${i.azimuth} min`,`${i.azimuth} max`,`${i.altitude} min`,`${i.altitude} max`,`${i.size} (°)`,i.basis,i.rests],t.witnesses.flatMap(c=>c.indications.map(o=>[c.title,e(o.t/1e3),o.phenomenon??o.sourceId,e(o.aim?.azimuthDeg),e(o.aim?.altitudeDeg),e(o.uncertainty?.azimuthDeg[0]),e(o.uncertainty?.azimuthDeg[1]),e(o.uncertainty?.altitudeDeg[0]),e(o.uncertainty?.altitudeDeg[1]),o.sizeSaid?e(o.angular?.widthDeg):"",o.basis?n.bases[o.basis]:"",s.rests(o)]))),r["values.csv"]=T.table([i.witness,i.reading,i.path,i.value,i.basis,i.rests],[...t.witnesses.flatMap(c=>c.values.map(o=>[c.title,"",o.path,s.value(o),n.bases[o.basis],s.rests(o)])),...t.readings.flatMap(c=>c.supposed.map(o=>[c.reads,c.title,o.path,s.value(o),n.bases[o.basis],s.rests(o)]))]),r["readings.csv"]=T.table([i.reading,i.reads,i.by,i.time,i.reproduced,i.compared,`${i.gap} (°)`,i.robustness,i.supposedCount],t.readings.map(c=>[c.title,c.reads,c.by.join(", "),c.time??"",c.sensitivity&&c.sensitivity.compared>0?String(Math.round(c.sensitivity.agreement*c.sensitivity.compared)):"",c.sensitivity&&c.sensitivity.compared>0?String(c.sensitivity.compared):"",e(c.sensitivity?.medianSeparationDeg),s.robustness(c.sensitivity).text,String(c.supposed.length)])),r["margins.csv"]=T.table([i.reading,i.reads,i.knob,i.from,i.to,`${i.reference} min`,`${i.reference} max`,i.covered],t.readings.flatMap(c=>(c.sensitivity?.margins??[]).map(o=>[c.title,c.reads,n.knobs[o.knob],e(o.lower),e(o.upper),e(o.reference?.lower),e(o.reference?.upper),o.coverage===void 0?"":e(o.coverage)]))),r["comparisons.csv"]=T.table([i.reading,i.reads,`${i.instant} (s)`,i.phenomenon,`${i.said} ${i.azimuth}`,`${i.said} ${i.altitude}`,`${i.read} ${i.azimuth}`,`${i.read} ${i.altitude}`,`${i.separation} (°)`,i.agrees],t.readings.flatMap(c=>c.comparisons.map(o=>[c.title,c.reads,e(o.t/1e3),t.witnesses.find(u=>u.title===c.reads)?.phenomena?.[o.sourceId]??o.sourceId,e(o.said?.azimuthDeg),e(o.said?.altitudeDeg),e(o.predicted.azimuthDeg),e(o.predicted.altitudeDeg),e(o.separationDeg),o.agrees?n.yes:n.no]))),r["findings.csv"]=T.table([i.reading,i.reads,i.finding,i.outcome,i.against,i.origin],t.readings.flatMap(c=>c.findings.map(o=>[c.title,c.reads,o.text,n.outcomes[o.outcome],o.outcome==="fails"?n.grounds[o.against??"established"]:"",n.origins[o.written?"written":"computed"]]))),r}static table(t,n){const a=s=>/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s;return[t,...n].map(s=>s.map(a).join(",")).join(`\r
2
2
  `)+`\r
3
3
  `}}class D{static COLOURS=["#c2410c","#1d4ed8","#15803d","#7e22ce","#b91c1c","#0f766e"];static WIDTH=640;static HEIGHT=320;static MARGIN={left:44,right:12,top:12,bottom:34};static svg(t,n,a){const s=t.indications.filter(h=>h.directionSaid&&h.aim);if(s.length===0)return;const i=D.circularMean(s.map(h=>h.aim.azimuthDeg)),e=h=>i+((h-i)%360+540)%360-180,r=[];for(const h of s){const{azimuthDeg:M,altitudeDeg:E}=h.uncertainty??{azimuthDeg:[h.aim.azimuthDeg,h.aim.azimuthDeg],altitudeDeg:[h.aim.altitudeDeg,h.aim.altitudeDeg]};r.push({x:e(h.aim.azimuthDeg),y:h.aim.altitudeDeg}),r.push({x:e(h.aim.azimuthDeg)+(M[0]-h.aim.azimuthDeg),y:E[0]}),r.push({x:e(h.aim.azimuthDeg)+(M[1]-h.aim.azimuthDeg),y:E[1]})}for(const h of n)for(const M of h.comparisons)r.push({x:e(M.predicted.azimuthDeg),y:M.predicted.altitudeDeg});const c=r.map(h=>h.x),o=r.map(h=>h.y),[u,p]=D.padded(Math.min(...c),Math.max(...c),10),[l,m]=D.padded(Math.max(-10,Math.min(...o)),Math.min(90,Math.max(...o)),5),d=D.MARGIN,g=D.WIDTH-d.left-d.right,f=D.HEIGHT-d.top-d.bottom,w=h=>d.left+(h-u)/(p-u)*g,b=h=>d.top+(1-(h-l)/(m-l))*f,v=h=>Math.round(h*10)/10,y=[];for(const h of D.ticks(u,p))y.push(`<line x1="${v(w(h))}" y1="${d.top}" x2="${v(w(h))}" y2="${d.top+f}" class="grid"/>`),y.push(`<text x="${v(w(h))}" y="${d.top+f+14}" text-anchor="middle" class="tick">${a.number((h%360+360)%360)}°</text>`);for(const h of D.ticks(l,m))y.push(`<line x1="${d.left}" y1="${v(b(h))}" x2="${d.left+g}" y2="${v(b(h))}" class="${h===0?"horizon":"grid"}"/>`),y.push(`<text x="${d.left-6}" y="${v(b(h))+4}" text-anchor="end" class="tick">${a.number(h)}°</text>`);y.push(`<text x="${d.left+g/2}" y="${D.HEIGHT-4}" text-anchor="middle" class="axis">${a.texts.azimuth}</text>`),y.push(`<text x="12" y="${d.top+f/2}" text-anchor="middle" class="axis" transform="rotate(-90 12 ${d.top+f/2})">${a.texts.altitude}</text>`);for(const h of s){const M=h.uncertainty;if(!M)continue;const E=e(h.aim.azimuthDeg),O=w(E+M.azimuthDeg[0]-h.aim.azimuthDeg),$=w(E+M.azimuthDeg[1]-h.aim.azimuthDeg);y.push(`<rect x="${v(Math.min(O,$))}" y="${v(b(M.altitudeDeg[1]))}" width="${v(Math.abs($-O))}" height="${v(Math.max(1,b(M.altitudeDeg[0])-b(M.altitudeDeg[1])))}" class="uncertainty"/>`)}n.forEach((h,M)=>{const E=D.COLOURS[M%D.COLOURS.length];for(const O of h.comparisons){const $=w(e(O.predicted.azimuthDeg)),x=b(O.predicted.altitudeDeg);O.said&&y.push(`<line x1="${v(w(e(O.said.azimuthDeg)))}" y1="${v(b(O.said.altitudeDeg))}" x2="${v($)}" y2="${v(x)}" stroke="${E}" class="gap"/>`),y.push(D.mark(M,$,x,E,O.agrees))}});for(const h of s)y.push(`<circle cx="${v(w(e(h.aim.azimuthDeg)))}" cy="${v(b(h.aim.altitudeDeg))}" r="4" class="said"><title>${a.instant(h.t)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${D.WIDTH} ${D.HEIGHT}" role="img" class="sky">${y.join("")}</svg>`}static mark(t,n,a,s,i){const r=o=>Math.round(o*10)/10,c=i?s:"none";switch(t%3){case 0:return`<path d="M${r(n-5)} ${r(a-5)}L${r(n+5)} ${r(a+5)}M${r(n-5)} ${r(a+5)}L${r(n+5)} ${r(a-5)}" stroke="${s}" stroke-width="${i?2.4:1.2}"/>`;case 1:return`<rect x="${r(n-5)}" y="${r(a-5)}" width="10" height="10" stroke="${s}" fill="${c}" stroke-width="1.4"/>`;default:return`<path d="M${r(n)} ${r(a-5-1)}L${r(n+5+1)} ${r(a+5)}L${r(n-5-1)} ${r(a+5)}Z" stroke="${s}" fill="${c}" stroke-width="1.4"/>`}}static legendMark(t){const n=D.COLOURS[t%D.COLOURS.length];return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="14" height="14" aria-hidden="true">${D.mark(t,7,7,n,!0)}</svg>`}static circularMean(t){const n=Math.PI/180,a=t.reduce((i,e)=>i+Math.cos(e*n),0),s=t.reduce((i,e)=>i+Math.sin(e*n),0);return Math.atan2(s,a)/n}static padded(t,n,a){const s=Math.max(n-t,a),i=(t+n)/2;return[i-s/2-s*.08,i+s/2+s*.08]}static ticks(t,n){const a=n-t,s=[1,2,5,10,15,20,30,45,90].find(e=>a/e<=10)??90,i=[];for(let e=Math.ceil(t/s)*s;e<=n;e+=s)i.push(e);return i}}class k{static SIZE=520;static count=0;static MARGIN=28;static svg(t,n,a){const s=t.filter($=>$.at);if(s.length===0)return;const i=n.filter($=>$.paths.length>0),e=[...s.map($=>$.at),...i.flatMap($=>$.paths.flatMap(x=>x.points))],r=e.map($=>$.eastM),c=e.map($=>$.northM),o=Math.max(200,Math.max(...r)-Math.min(...r),Math.max(...c)-Math.min(...c))*1.25,u=(Math.max(...r)+Math.min(...r))/2,p=(Math.max(...c)+Math.min(...c))/2,l=k.SIZE-2*k.MARGIN,m=$=>k.MARGIN+($-u+o/2)/o*l,d=$=>k.MARGIN+(1-($-p+o/2)/o)*l,g=$=>Math.round($*10)/10,f=o*.75,w=Math.PI/180,b=($,x)=>({eastM:$.eastM+f*Math.sin(x*w),northM:$.northM+f*Math.cos(x*w)}),v=`plan-clip-${k.count++}`,y=[`<defs><clipPath id="${v}"><rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}"/></clipPath></defs>`,`<rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}" class="frame"/>`,`<g clip-path="url(#${v})">`];for(const $ of s)for(const x of $.indications){if(!x.directionSaid||!x.aim)continue;const I=$.at,L=x.uncertainty?.azimuthDeg;if(L&&L[1]-L[0]<180){const A=b(I,L[0]),R=b(I,L[1]);y.push(`<path d="M${g(m(I.eastM))} ${g(d(I.northM))}L${g(m(A.eastM))} ${g(d(A.northM))}L${g(m(R.eastM))} ${g(d(R.northM))}Z" class="fan"/>`)}const G=b(I,x.aim.azimuthDeg);y.push(`<line x1="${g(m(I.eastM))}" y1="${g(d(I.northM))}" x2="${g(m(G.eastM))}" y2="${g(d(G.northM))}" class="sight"><title>${a.instant(x.t)}</title></line>`)}i.forEach($=>{const x=D.COLOURS[n.indexOf($)%D.COLOURS.length];for(const I of $.paths){const L=I.points.map((A,R)=>`${R===0?"M":"L"}${g(m(A.eastM))} ${g(d(A.northM))}`).join("");y.push(`<path d="${L}" stroke="${x}" class="track"/>`);const G=I.points[I.points.length-1];y.push(`<circle cx="${g(m(G.eastM))}" cy="${g(d(G.northM))}" r="2.5" fill="${x}"/>`)}}),y.push("</g>");const h=[];for(const $ of s){const x=h.find(I=>Math.hypot(I.at.eastM-$.at.eastM,I.at.northM-$.at.northM)<o/100);x?x.names.push($.title):h.push({at:$.at,names:[$.title]})}for(const $ of h)y.push(`<circle cx="${g(m($.at.eastM))}" cy="${g(d($.at.northM))}" r="4.5" class="witness"/>`),y.push(`<text x="${g(m($.at.eastM)+7)}" y="${g(d($.at.northM)-7)}" class="name">${k.escape($.names.join(", "))}</text>`);const M=k.round(o/5),E=M/o*l,O=k.SIZE-10;return y.push(`<line x1="${k.MARGIN}" y1="${O}" x2="${g(k.MARGIN+E)}" y2="${O}" class="scale"/>`),y.push(`<text x="${g(k.MARGIN+E+6)}" y="${O+4}" class="tick">${k.escape(a.fill(a.texts.scale,{metres:a.number(M)}))}</text>`),y.push(`<path d="M${k.SIZE-18} 34L${k.SIZE-12} 18L${k.SIZE-6} 34Z" class="north"/><text x="${k.SIZE-12}" y="14" text-anchor="middle" class="tick">N</text>`),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${k.SIZE} ${k.SIZE}" role="img" class="plan">${y.join("")}</svg>`}static round(t){const n=10**Math.floor(Math.log10(t));return[5,2,1].map(a=>a*n).find(a=>a<=t)??n}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class S{static WIDTH=640;static HEIGHT=74;static LEFT=16;static RIGHT=16;static svg(t,n){const a=t.indications.map(l=>l.t),s=t.moments;if(a.length===0&&s.length===0)return;const i=Math.max(1e3,(t.durationSeconds??0)*1e3,...a,...s.map(l=>l.t)),e=S.WIDTH-S.LEFT-S.RIGHT,r=l=>S.LEFT+l/i*e,c=l=>Math.round(l*10)/10,o=40,u=[`<line x1="${S.LEFT}" y1="${o}" x2="${S.LEFT+e}" y2="${o}" class="axis-line"/>`],p=[.5,1,2,5,10,15,30,60,120,300,600].find(l=>i/1e3/l<=10)??600;for(let l=0;l*1e3<=i;l+=p)u.push(`<line x1="${c(r(l*1e3))}" y1="${o-3}" x2="${c(r(l*1e3))}" y2="${o+3}" class="axis-line"/>`),u.push(`<text x="${c(r(l*1e3))}" y="${o+16}" text-anchor="middle" class="tick">${n.instant(l*1e3)}</text>`);for(const l of s)u.push(`<line x1="${c(r(l.t))}" y1="8" x2="${c(r(l.t))}" y2="${o}" class="moment"/>`),u.push(`<text x="${c(r(l.t)+3)}" y="16" class="moment-label">${S.escape(l.label)}${l.note?`<title>${S.escape(l.note)}</title>`:""}</text>`);for(const l of a)u.push(`<circle cx="${c(r(l))}" cy="${o}" r="3.5" class="said"><title>${n.instant(l)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S.WIDTH} ${S.HEIGHT}" role="img" class="timeline">${u.join("")}</svg>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class z{static CSS=`
4
4
  :root { color-scheme: light; --ink: #1b1d22; --dim: #5b6070; --line: #d6d9e0; --ok: #15803d; --warn: #b45309; --error: #b91c1c; }
@@ -62,4 +62,4 @@ ${o.join(`
62
62
  `)}
63
63
  </body>
64
64
  </html>
65
- `}static comparedTable(t,n){const a=n.texts.columns,s=z.escape;return z.table([a.reading,a.reads,a.reproduced,a.gap,a.robustness,a.supposedCount],t.readings.map(i=>{const e=n.robustness(i.sensitivity);return[s(i.title),s(i.reads),`<span class="n">${n.reproduced(i.sensitivity)}</span>`,n.degrees(i.sensitivity?.medianSeparationDeg),`<span class="${e.kind}">${s(e.text)}</span>`,String(i.supposed.length)]}),[2,3,5])}static witness(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h3>${e(a.fill(s.witnessHeading,{witness:t.title}))}</h3>`],o=[[s.columns.time,t.time??""],[s.place,t.place??""],[s.duration,t.durationSeconds!==void 0?a.instant(t.durationSeconds*1e3):""],[s.instrument,t.instrument??""]].filter(([,m])=>m!=="");o.length&&r.push(`<dl class="facts">${o.map(([m,d])=>`<dt>${e(m)}</dt><dd>${e(d)}</dd>`).join("")}</dl>`),t.description&&r.push(`<h4>${e(s.account)}</h4>`,`<blockquote>${e(t.description)}</blockquote>`),t.sources.length&&r.push(`<h4>${e(s.sources)}</h4>`,`<ul class="sources">${t.sources.map(m=>`<li>${[m.authors?.join(", "),m.title?`<em>${e(m.title)}</em>`:"",m.publisher,m.time,m.index].filter(Boolean).map(g=>g.startsWith("<em>")?g:e(g)).join(", ")}${m.url?` <a href="${e(m.url)}">${e(m.url)}</a>`:""}</li>`).join("")}</ul>`);const u=S.svg(t,a);u&&r.push(`<figure>${u}<figcaption>${e(s.timelineCaption)}</figcaption></figure>`),n=n.filter(m=>m.comparisons.length>0);const p=D.svg(t,n,a);if(p){const m=[`<li><svg viewBox="0 0 14 14" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4" fill="#111827"/></svg>${e(s.saidLegend)}</li>`,...n.map((d,g)=>`<li>${D.legendMark(g)}${e(d.title)}</li>`)];r.push(`<figure>${p}<ul class="legend">${m.join("")}</ul><figcaption>${e(s.figureCaption)}</figcaption></figure>`)}if(t.pictures?.length){const m=t.pictures[0].views.map(d=>d.label);r.push(`<h4>${e(s.pictures)}</h4>`,`<div class="scroll"><table class="pictures"><thead><tr><th scope="col">${e(s.columns.instant)}</th>${m.map(d=>`<th scope="col">${e(d)}</th>`).join("")}</tr></thead><tbody>${t.pictures.map(d=>`<tr><td class="n">${a.instant(d.t)}</td>${d.views.map(g=>`<td>${g.image?`<img src="${g.image}" alt="${e(g.label)}, ${a.instant(d.t)}">`:`<span class="nothing">${e(s.noPicture)}</span>`}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`,`<p class="caption">${e(s.picturesCaption)}</p>`)}r.push(`<h4>${e(s.indications)}</h4>`),t.indications.length===0?r.push(`<p>${e(s.noIndication)}</p>`):r.push(z.table([i.instant,i.phenomenon,i.azimuth,i.altitude,i.uncertainty,i.size,i.basis,i.rests],t.indications.map(m=>{const d=m.uncertainty;return[a.instant(m.t),e(m.phenomenon??m.sourceId),m.directionSaid?a.azimuth(m.aim?.azimuthDeg):"",m.directionSaid?a.degrees(m.aim?.altitudeDeg):"",d?`${a.azimuth(d.azimuthDeg[0])} … ${a.azimuth(d.azimuthDeg[1])} ; ${a.degrees(d.altitudeDeg[0])} … ${a.degrees(d.altitudeDeg[1])}`:"",m.sizeSaid?a.degrees(m.angular?.widthDeg):"",m.basis?e(s.bases[m.basis]):"",e(a.rests(m))]}),[0,2,3,5]));const l=t.values.filter(m=>!/^timeline\.keyframes\.\d+\.shapes\.\d+\.shape\.(aim|angular)/.test(m.path));return l.length>0&&r.push(`<h4>${e(s.values)}</h4>`,z.valuesTable(l,a)),r}static reading(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h2>${e(a.fill(s.readingHeading,{title:t.title,witness:t.reads}))}</h2>`],c=[t.by.length?a.fill(s.by,{names:t.by.join(", ")}):"",t.time?a.fill(s.made,{time:t.time}):""].filter(Boolean).join(" ");c&&r.push(`<p class="meta">${e(c)}</p>`),t.description&&r.push(`<blockquote>${e(t.description)}</blockquote>`),r.push(`<h4>${e(s.supposed)}</h4>`,t.supposed.length?z.valuesTable(t.supposed,a):`<p>${e(s.noneSupposed)}</p>`),r.push(`<h4>${e(s.findings)}</h4>`),r.push(t.findings.length?z.table([i.finding,i.outcome,i.against,i.origin],t.findings.map(u=>[e(u.text),`<span class="${u.outcome}">${e(s.outcomes[u.outcome])}</span>`,u.outcome==="fails"?e(s.grounds[u.against??"established"]):"",e(s.origins[u.written?"written":"computed"])])):`<p>${e(s.noFinding)}</p>`);const o=t.sensitivity;if(o){const u=a.robustness(o);if(r.push(`<h4>${e(s.sensitivity)}</h4>`,`<p>${e(i.reproduced)} : ${a.reproduced(o)||"–"} · ${e(i.gap)} : ${a.degrees(o.medianSeparationDeg)||"–"} · <span class="${u.kind}">${e(u.text)}</span></p>`),u.kind!=="too-few"&&u.kind!=="nothing"&&o.margins.length>0&&r.push(z.table([i.knob,i.from,i.to,i.reference,i.covered],o.margins.map(p=>{const l=a.ends(p),m=p.reference?`${a.amount(p.knob,p.reference.lower)} … ${a.amount(p.knob,p.reference.upper)}`:s.noLaw;return[e(s.knobs[p.knob]),l.from,l.to,e(m),p.coverage===void 0?"":`${Math.round(p.coverage*100)} %`]}),[1,2,4])),o.better){const{knob:p,amount:l,agreement:m}=o.better;r.push(`<p class="fine-tuned">${e(a.fill(s.better,{knob:s.knobs[p],amount:a.amount(p,l),agreed:String(Math.round(m*o.compared)),compared:String(o.compared)}))}</p>`)}}return t.comparisons.length>0&&r.push(`<h4>${e(s.comparisons)}</h4>`,z.table([i.instant,i.phenomenon,`${i.said} (${i.azimuth}, ${i.altitude})`,`${i.read} (${i.azimuth}, ${i.altitude})`,i.separation,i.agrees],t.comparisons.map(u=>[a.instant(u.t),e(n?.phenomena?.[u.sourceId]??u.sourceId),u.said?`${a.azimuth(u.said.azimuthDeg)}, ${a.degrees(u.said.altitudeDeg)}`:"",`${a.azimuth(u.predicted.azimuthDeg)}, ${a.degrees(u.predicted.altitudeDeg)}`,a.degrees(u.separationDeg),`<span class="${u.agrees?"holds":"fails"}">${e(u.agrees?s.yes:s.no)}</span>`]),[0,4])),r}static valuesTable(t,n){const a=n.texts,s=a.columns,i=z.escape;return z.table([s.path,s.value,s.basis,s.rests],t.map(e=>[`<code>${i(e.path)}</code>`,i(n.value(e)),i(a.bases[e.basis]),i(n.rests(e))]))}static table(t,n,a=[]){const s=z.escape,i=`<tr>${t.map(r=>`<th scope="col">${s(r)}</th>`).join("")}</tr>`,e=n.map(r=>`<tr>${r.map((c,o)=>`<td${a.includes(o)?' class="n"':""}>${c}</td>`).join("")}</tr>`);return`<div class="scroll"><table><thead>${i}</thead><tbody>${e.join("")}</tbody></table></div>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const _=P.catalog({en:()=>Z(()=>import("./CaseReportTexts_en-DlN7p1pC.js"),[],import.meta.url).then(N=>N.caseReportTexts_en),fr:()=>Z(()=>import("./CaseReportTexts_fr-B5nP6RlP.js"),[],import.meta.url).then(N=>N.caseReportTexts_fr),es:()=>Z(()=>import("./CaseReportTexts_es-CncAEaey.js"),[],import.meta.url).then(N=>N.caseReportTexts_es),it:()=>Z(()=>import("./CaseReportTexts_it-Dc-oPmXB.js"),[],import.meta.url).then(N=>N.caseReportTexts_it)});class U{static async make(t,n,a,s,i=!1,e){const[r,c]=await Promise.all([_.load(a),J.load(a)]),o=j.of(n.caseJson,n.caseUrl,n.recordings,new C([...s]),new F(c));i&&t!=="csv"&&await U.pictures(o,n,r,e);const u=`${n.caseJson.id??"case"}-report`;switch(t){case"html":U.download(new Blob([z.of(o,r,a,"0.194.0")],{type:"text/html"}),`${u}.html`);return;case"print":U.print(z.of(o,r,a,"0.194.0"));return;case"json":U.download(new Blob([T.json(o,"0.194.0")],{type:"application/json"}),`${u}.json`);return;case"csv":{const{zipSync:p,strToU8:l}=await Z(async()=>{const{zipSync:d,strToU8:g}=await import("./browser-CltifEM0.js");return{zipSync:d,strToU8:g}},[],import.meta.url),m=Object.fromEntries(Object.entries(T.csv(o,r,a)).map(([d,g])=>[d,l(`\uFEFF${g}`)]));U.download(new Blob([p(m)],{type:"application/zip"}),`${u}-tables.zip`)}}}static PICTURED_INSTANTS=3;static async pictures(t,n,a,s){const{registerScene:i,SCENE_ELEMENT_NAME:e}=await Z(async()=>{const{registerScene:p,SCENE_ELEMENT_NAME:l}=await import("./rr0-sighting-editor.mjs").then(m=>m.cZ);return{registerScene:p,SCENE_ELEMENT_NAME:l}},[],import.meta.url);i();const r=t.witnesses.map(p=>{const l=p.indications.filter(f=>f.directionSaid).map(f=>f.t),m=l.length<=U.PICTURED_INSTANTS?l:[l[0],l[Math.floor(l.length/2)],l[l.length-1]],d=t.readings.filter(f=>f.reads===p.title&&f.comparisons.length>0),g=[{label:a.accountView,url:p.url,reading:void 0},...d.map(f=>({label:f.title,url:p.url,reading:f.url}))];return{witness:p,instants:[...new Set(m)],recordings:g}}).filter(p=>p.instants.length>0),c=r.reduce((p,l)=>p+l.instants.length*l.recordings.length,0);if(c===0)return;const o=document.createElement(e);o.setAttribute("max-pixel-ratio","1"),o.setAttribute("always-live",""),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:"640px",height:"360px",visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(o);let u=0;s?.(u,c);try{for(const p of r){const l=p.instants.map(d=>({t:d,views:[]})),m=n.recordings.get(p.witness.url);m&&(o.documentUrl=p.witness.url,o.sightingData=m);for(const d of p.recordings){const g=m,f=d.reading?n.recordings.get(d.reading):void 0;for(const w of l){let b;g&&(!d.reading||f)&&(w===l[0]&&(o.interpretation=U.bodiesOf(f??g,d.reading??p.witness.url)),b=await o.pictureAt(w.t,480).catch(()=>{})),w.views.push({label:d.label,...b?{image:b}:{}}),s?.(++u,c)}}p.witness.pictures=l}}finally{o.remove()}}static bodiesOf(t,n){const a=W.strip(t).recording.interpretation;if(a)return{...a,bodies:a.bodies.map(s=>s.model?.url?{...s,model:{...s.model,url:new URL(s.model.url,n).href}}:s)}}static print(t){const n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText="position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0",n.addEventListener("load",()=>{const a=n.contentWindow;a&&(a.addEventListener("afterprint",()=>n.remove()),a.focus(),a.print(),window.setTimeout(()=>n.remove(),6e4))},{once:!0}),n.srcdoc=t,document.body.append(n)}static download(t,n){const a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download=n,s.click(),window.setTimeout(()=>URL.revokeObjectURL(a),1e3)}}export{U as CaseReportExport};
65
+ `}static comparedTable(t,n){const a=n.texts.columns,s=z.escape;return z.table([a.reading,a.reads,a.reproduced,a.gap,a.robustness,a.supposedCount],t.readings.map(i=>{const e=n.robustness(i.sensitivity);return[s(i.title),s(i.reads),`<span class="n">${n.reproduced(i.sensitivity)}</span>`,n.degrees(i.sensitivity?.medianSeparationDeg),`<span class="${e.kind}">${s(e.text)}</span>`,String(i.supposed.length)]}),[2,3,5])}static witness(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h3>${e(a.fill(s.witnessHeading,{witness:t.title}))}</h3>`],o=[[s.columns.time,t.time??""],[s.place,t.place??""],[s.duration,t.durationSeconds!==void 0?a.instant(t.durationSeconds*1e3):""],[s.instrument,t.instrument??""]].filter(([,m])=>m!=="");o.length&&r.push(`<dl class="facts">${o.map(([m,d])=>`<dt>${e(m)}</dt><dd>${e(d)}</dd>`).join("")}</dl>`),t.description&&r.push(`<h4>${e(s.account)}</h4>`,`<blockquote>${e(t.description)}</blockquote>`),t.sources.length&&r.push(`<h4>${e(s.sources)}</h4>`,`<ul class="sources">${t.sources.map(m=>`<li>${[m.authors?.join(", "),m.title?`<em>${e(m.title)}</em>`:"",m.publisher,m.time,m.index].filter(Boolean).map(g=>g.startsWith("<em>")?g:e(g)).join(", ")}${m.url?` <a href="${e(m.url)}">${e(m.url)}</a>`:""}</li>`).join("")}</ul>`);const u=S.svg(t,a);u&&r.push(`<figure>${u}<figcaption>${e(s.timelineCaption)}</figcaption></figure>`),n=n.filter(m=>m.comparisons.length>0);const p=D.svg(t,n,a);if(p){const m=[`<li><svg viewBox="0 0 14 14" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4" fill="#111827"/></svg>${e(s.saidLegend)}</li>`,...n.map((d,g)=>`<li>${D.legendMark(g)}${e(d.title)}</li>`)];r.push(`<figure>${p}<ul class="legend">${m.join("")}</ul><figcaption>${e(s.figureCaption)}</figcaption></figure>`)}if(t.pictures?.length){const m=t.pictures[0].views.map(d=>d.label);r.push(`<h4>${e(s.pictures)}</h4>`,`<div class="scroll"><table class="pictures"><thead><tr><th scope="col">${e(s.columns.instant)}</th>${m.map(d=>`<th scope="col">${e(d)}</th>`).join("")}</tr></thead><tbody>${t.pictures.map(d=>`<tr><td class="n">${a.instant(d.t)}</td>${d.views.map(g=>`<td>${g.image?`<img src="${g.image}" alt="${e(g.label)}, ${a.instant(d.t)}">`:`<span class="nothing">${e(s.noPicture)}</span>`}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`,`<p class="caption">${e(s.picturesCaption)}</p>`)}r.push(`<h4>${e(s.indications)}</h4>`),t.indications.length===0?r.push(`<p>${e(s.noIndication)}</p>`):r.push(z.table([i.instant,i.phenomenon,i.azimuth,i.altitude,i.uncertainty,i.size,i.basis,i.rests],t.indications.map(m=>{const d=m.uncertainty;return[a.instant(m.t),e(m.phenomenon??m.sourceId),m.directionSaid?a.azimuth(m.aim?.azimuthDeg):"",m.directionSaid?a.degrees(m.aim?.altitudeDeg):"",d?`${a.azimuth(d.azimuthDeg[0])} … ${a.azimuth(d.azimuthDeg[1])} ; ${a.degrees(d.altitudeDeg[0])} … ${a.degrees(d.altitudeDeg[1])}`:"",m.sizeSaid?a.degrees(m.angular?.widthDeg):"",m.basis?e(s.bases[m.basis]):"",e(a.rests(m))]}),[0,2,3,5]));const l=t.values.filter(m=>!/^timeline\.keyframes\.\d+\.shapes\.\d+\.shape\.(aim|angular)/.test(m.path));return l.length>0&&r.push(`<h4>${e(s.values)}</h4>`,z.valuesTable(l,a)),r}static reading(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h2>${e(a.fill(s.readingHeading,{title:t.title,witness:t.reads}))}</h2>`],c=[t.by.length?a.fill(s.by,{names:t.by.join(", ")}):"",t.time?a.fill(s.made,{time:t.time}):""].filter(Boolean).join(" ");c&&r.push(`<p class="meta">${e(c)}</p>`),t.description&&r.push(`<blockquote>${e(t.description)}</blockquote>`),r.push(`<h4>${e(s.supposed)}</h4>`,t.supposed.length?z.valuesTable(t.supposed,a):`<p>${e(s.noneSupposed)}</p>`),r.push(`<h4>${e(s.findings)}</h4>`),r.push(t.findings.length?z.table([i.finding,i.outcome,i.against,i.origin],t.findings.map(u=>[e(u.text),`<span class="${u.outcome}">${e(s.outcomes[u.outcome])}</span>`,u.outcome==="fails"?e(s.grounds[u.against??"established"]):"",e(s.origins[u.written?"written":"computed"])])):`<p>${e(s.noFinding)}</p>`);const o=t.sensitivity;if(o){const u=a.robustness(o);if(r.push(`<h4>${e(s.sensitivity)}</h4>`,`<p>${e(i.reproduced)} : ${a.reproduced(o)||"–"} · ${e(i.gap)} : ${a.degrees(o.medianSeparationDeg)||"–"} · <span class="${u.kind}">${e(u.text)}</span></p>`),u.kind!=="too-few"&&u.kind!=="nothing"&&o.margins.length>0&&r.push(z.table([i.knob,i.from,i.to,i.reference,i.covered],o.margins.map(p=>{const l=a.ends(p),m=p.reference?`${a.amount(p.knob,p.reference.lower)} … ${a.amount(p.knob,p.reference.upper)}`:s.noLaw;return[e(s.knobs[p.knob]),l.from,l.to,e(m),p.coverage===void 0?"":`${Math.round(p.coverage*100)} %`]}),[1,2,4])),o.better){const{knob:p,amount:l,agreement:m}=o.better;r.push(`<p class="fine-tuned">${e(a.fill(s.better,{knob:s.knobs[p],amount:a.amount(p,l),agreed:String(Math.round(m*o.compared)),compared:String(o.compared)}))}</p>`)}}return t.comparisons.length>0&&r.push(`<h4>${e(s.comparisons)}</h4>`,z.table([i.instant,i.phenomenon,`${i.said} (${i.azimuth}, ${i.altitude})`,`${i.read} (${i.azimuth}, ${i.altitude})`,i.separation,i.agrees],t.comparisons.map(u=>[a.instant(u.t),e(n?.phenomena?.[u.sourceId]??u.sourceId),u.said?`${a.azimuth(u.said.azimuthDeg)}, ${a.degrees(u.said.altitudeDeg)}`:"",`${a.azimuth(u.predicted.azimuthDeg)}, ${a.degrees(u.predicted.altitudeDeg)}`,a.degrees(u.separationDeg),`<span class="${u.agrees?"holds":"fails"}">${e(u.agrees?s.yes:s.no)}</span>`]),[0,4])),r}static valuesTable(t,n){const a=n.texts,s=a.columns,i=z.escape;return z.table([s.path,s.value,s.basis,s.rests],t.map(e=>[`<code>${i(e.path)}</code>`,i(n.value(e)),i(a.bases[e.basis]),i(n.rests(e))]))}static table(t,n,a=[]){const s=z.escape,i=`<tr>${t.map(r=>`<th scope="col">${s(r)}</th>`).join("")}</tr>`,e=n.map(r=>`<tr>${r.map((c,o)=>`<td${a.includes(o)?' class="n"':""}>${c}</td>`).join("")}</tr>`);return`<div class="scroll"><table><thead>${i}</thead><tbody>${e.join("")}</tbody></table></div>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const _=P.catalog({en:()=>B(()=>import("./CaseReportTexts_en-DlN7p1pC.js"),[],import.meta.url).then(N=>N.caseReportTexts_en),fr:()=>B(()=>import("./CaseReportTexts_fr-B5nP6RlP.js"),[],import.meta.url).then(N=>N.caseReportTexts_fr),es:()=>B(()=>import("./CaseReportTexts_es-CncAEaey.js"),[],import.meta.url).then(N=>N.caseReportTexts_es),it:()=>B(()=>import("./CaseReportTexts_it-Dc-oPmXB.js"),[],import.meta.url).then(N=>N.caseReportTexts_it)});class U{static async make(t,n,a,s,i=!1,e){const[r,c]=await Promise.all([_.load(a),J.load(a)]),o=j.of(n.caseJson,n.caseUrl,n.recordings,new C([...s]),new F(c));i&&t!=="csv"&&await U.pictures(o,n,r,e);const u=`${n.caseJson.id??"case"}-report`;switch(t){case"html":U.download(new Blob([z.of(o,r,a,"0.196.0")],{type:"text/html"}),`${u}.html`);return;case"print":U.print(z.of(o,r,a,"0.196.0"));return;case"json":U.download(new Blob([T.json(o,"0.196.0")],{type:"application/json"}),`${u}.json`);return;case"csv":{const{zipSync:p,strToU8:l}=await B(async()=>{const{zipSync:d,strToU8:g}=await import("./browser-CltifEM0.js");return{zipSync:d,strToU8:g}},[],import.meta.url),m=Object.fromEntries(Object.entries(T.csv(o,r,a)).map(([d,g])=>[d,l(`\uFEFF${g}`)]));U.download(new Blob([p(m)],{type:"application/zip"}),`${u}-tables.zip`)}}}static PICTURED_INSTANTS=3;static async pictures(t,n,a,s){const{registerScene:i,SCENE_ELEMENT_NAME:e}=await B(async()=>{const{registerScene:p,SCENE_ELEMENT_NAME:l}=await import("./rr0-sighting-editor.mjs").then(m=>m.c_);return{registerScene:p,SCENE_ELEMENT_NAME:l}},[],import.meta.url);i();const r=t.witnesses.map(p=>{const l=p.indications.filter(f=>f.directionSaid).map(f=>f.t),m=l.length<=U.PICTURED_INSTANTS?l:[l[0],l[Math.floor(l.length/2)],l[l.length-1]],d=t.readings.filter(f=>f.reads===p.title&&f.comparisons.length>0),g=[{label:a.accountView,url:p.url,reading:void 0},...d.map(f=>({label:f.title,url:p.url,reading:f.url}))];return{witness:p,instants:[...new Set(m)],recordings:g}}).filter(p=>p.instants.length>0),c=r.reduce((p,l)=>p+l.instants.length*l.recordings.length,0);if(c===0)return;const o=document.createElement(e);o.setAttribute("max-pixel-ratio","1"),o.setAttribute("always-live",""),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:"640px",height:"360px",visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(o);let u=0;s?.(u,c);try{for(const p of r){const l=p.instants.map(d=>({t:d,views:[]})),m=n.recordings.get(p.witness.url);m&&(o.documentUrl=p.witness.url,o.sightingData=m);for(const d of p.recordings){const g=m,f=d.reading?n.recordings.get(d.reading):void 0;for(const w of l){let b;g&&(!d.reading||f)&&(w===l[0]&&(o.interpretation=U.bodiesOf(f??g,d.reading??p.witness.url)),b=await o.pictureAt(w.t,480).catch(()=>{})),w.views.push({label:d.label,...b?{image:b}:{}}),s?.(++u,c)}}p.witness.pictures=l}}finally{o.remove()}}static bodiesOf(t,n){const a=W.strip(t).recording.interpretation;if(a)return{...a,bodies:a.bodies.map(s=>s.model?.url?{...s,model:{...s.model,url:new URL(s.model.url,n).href}}:s)}}static print(t){const n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText="position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0",n.addEventListener("load",()=>{const a=n.contentWindow;a&&(a.addEventListener("afterprint",()=>n.remove()),a.focus(),a.print(),window.setTimeout(()=>n.remove(),6e4))},{once:!0}),n.srcdoc=t,document.body.append(n)}static download(t,n){const a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download=n,s.click(),window.setTimeout(()=>URL.revokeObjectURL(a),1e3)}}export{U as CaseReportExport};
@@ -1 +1 @@
1
- import{aU as b,ba as F,bb as I,aX as X,bc as m,bd as U}from"./rr0-sighting-editor.mjs";import{C as x}from"./ContrailGrowth-DwHS8If9.js";class h{static MAX_SEGMENTS=8e3;static MIN_PIXELS=2;static UNRESOLVED_CONTRAST=.5;static STATIONS=[0,.5,1,1.5,2.25];static VERTICES_PER_SEGMENT=12*(h.STATIONS.length-1);static ICE_ASYMMETRY=.75;static phase(t){const s=h.ICE_ASYMMETRY;return(1-s*s)/(1+s*s-2*s*t)**1.5}object;group=new b;trails=[];positions=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*3);colors=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*4);segments=0;constructor(){const t=new F;t.setAttribute("position",new I(this.positions,3)),t.setAttribute("color",new I(this.colors,4)),t.setDrawRange(0,0),this.object=new X(t,new m({vertexColors:!0,transparent:!0,depthWrite:!1,side:U})),this.object.frustumCulled=!1,this.object.name="contrails",this.group.name="contrails",this.group.add(this.object)}get segmentCount(){return this.segments}set(t){this.trails=t}update(t,s,c){let p=0;this.segments=0;for(const o of this.trails){const u=this.samplesOf(o,t,s),i=c(o.id);for(let a=0;a+1<u.length;a++){const n=u[a],M=u[a+1];if(!n.forms||!M.forms)continue;if(this.segments>=h.MAX_SEGMENTS)break;const y=this.pushSegment(p,n,M,o.spanM,i,s);y>p&&this.segments++,p=y}}const d=this.object.geometry;d.setDrawRange(0,p);for(const[o,u]of[["position",3],["color",4]]){const i=d.getAttribute(o);i.clearUpdateRanges(),p>0&&i.addUpdateRange(0,p*u),i.needsUpdate=!0}}samplesOf(t,s,c){const p=s-x.FORMATION_S*1e3,d=[],o=(n,M,y,T,l,N)=>({x:M+n.driftEastMs*l+c.origin.x,y:T,z:-(y+n.driftNorthMs*l)+c.origin.z,age:l,forms:N,point:n});let u=-1;t.points.forEach((n,M)=>{n.tMs>p||(u=M,d.push(o(n,n.eastM,n.northM,n.upM,(s-n.tMs)/1e3,n.forms)))});const i=t.points[u],a=t.points[u+1];if(i&&a){const n=(p-i.tMs)/(a.tMs-i.tMs),M=(y,T)=>y+(T-y)*n;d.push(o(i,M(i.eastM,a.eastM),M(i.northM,a.northM),M(i.upM,a.upM),x.FORMATION_S,i.forms&&a.forms))}return d}pushSegment(t,s,c,p,d,o){const u=e=>({persistent:e.point.persistent,lifetimeS:e.point.lifetimeS,spanM:p,shearPerS:e.point.shearPerS,saturatedForS:e.point.saturatedForS}),i=x.opacity(s.age,u(s)),a=x.opacity(c.age,u(c));if(i<=0&&a<=0)return t;const n={x:c.x-s.x,y:c.y-s.y,z:c.z-s.z};if(Math.hypot(n.x,n.y,n.z)<1e-6)return t;const M={x:(s.x+c.x)/2-o.eye.x,y:(s.y+c.y)/2-o.eye.y,z:(s.z+c.z)/2-o.eye.z},y=this.normalise(this.cross(n,M)),T=e=>{if(!o.sun)return d;const r={x:e.x-o.eye.x,y:e.y-o.eye.y,z:e.z-o.eye.z},E=h.phase((o.sun.x*r.x+o.sun.y*r.y+o.sun.z*r.z)/(Math.hypot(r.x,r.y,r.z)||1));return[d[0]*E,d[1]*E,d[2]*E]},l=(e,r)=>{const E=Math.hypot(e.x-o.eye.x,e.y-o.eye.y,e.z-o.eye.z),A=x.widthM(p,e.age,e.point.shearPerS),g=Math.max(A,h.MIN_PIXELS*o.pixelRad*E),z=r*(A/g)**h.UNRESOLVED_CONTRAST,S=x.profileExponent(e.age),G=h.STATIONS.map((j,P)=>P===h.STATIONS.length-1?0:z*Math.exp(-Math.LN2*j**S));return{half:g/2,profile:G,scattered:T(e)}},N=[{sample:s,...l(s,i)},{sample:c,...l(c,a)}],w=h.STATIONS.length-1,f=(e,r,E)=>{const A=h.STATIONS[r],g=e.half*A*E,z=t*3;this.positions[z]=e.sample.x+y.x*g,this.positions[z+1]=e.sample.y+y.y*g,this.positions[z+2]=e.sample.z+y.z*g;const S=t*4;this.colors[S]=e.scattered[0],this.colors[S+1]=e.scattered[1],this.colors[S+2]=e.scattered[2],this.colors[S+3]=e.profile[r],t++},[R,O]=N;for(const e of[-1,1])for(let r=0;r<w;r++)f(R,r+1,e),f(R,r,e),f(O,r+1,e),f(R,r,e),f(O,r,e),f(O,r+1,e);return t}cross(t,s){return{x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x}}normalise(t){const s=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/s,y:t.y/s,z:t.z/s}}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.group.removeFromParent()}}export{h as ContrailSystem};
1
+ import{aV as b,bb as F,bc as I,aY as m,bd as V,be as X}from"./rr0-sighting-editor.mjs";import{C as x}from"./ContrailGrowth-DwHS8If9.js";class h{static MAX_SEGMENTS=8e3;static MIN_PIXELS=2;static UNRESOLVED_CONTRAST=.5;static STATIONS=[0,.5,1,1.5,2.25];static VERTICES_PER_SEGMENT=12*(h.STATIONS.length-1);static ICE_ASYMMETRY=.75;static phase(t){const s=h.ICE_ASYMMETRY;return(1-s*s)/(1+s*s-2*s*t)**1.5}object;group=new b;trails=[];positions=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*3);colors=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*4);segments=0;constructor(){const t=new F;t.setAttribute("position",new I(this.positions,3)),t.setAttribute("color",new I(this.colors,4)),t.setDrawRange(0,0),this.object=new m(t,new V({vertexColors:!0,transparent:!0,depthWrite:!1,side:X})),this.object.frustumCulled=!1,this.object.name="contrails",this.group.name="contrails",this.group.add(this.object)}get segmentCount(){return this.segments}set(t){this.trails=t}update(t,s,c){let p=0;this.segments=0;for(const o of this.trails){const u=this.samplesOf(o,t,s),i=c(o.id);for(let a=0;a+1<u.length;a++){const n=u[a],M=u[a+1];if(!n.forms||!M.forms)continue;if(this.segments>=h.MAX_SEGMENTS)break;const y=this.pushSegment(p,n,M,o.spanM,i,s);y>p&&this.segments++,p=y}}const d=this.object.geometry;d.setDrawRange(0,p);for(const[o,u]of[["position",3],["color",4]]){const i=d.getAttribute(o);i.clearUpdateRanges(),p>0&&i.addUpdateRange(0,p*u),i.needsUpdate=!0}}samplesOf(t,s,c){const p=s-x.FORMATION_S*1e3,d=[],o=(n,M,y,T,l,N)=>({x:M+n.driftEastMs*l+c.origin.x,y:T,z:-(y+n.driftNorthMs*l)+c.origin.z,age:l,forms:N,point:n});let u=-1;t.points.forEach((n,M)=>{n.tMs>p||(u=M,d.push(o(n,n.eastM,n.northM,n.upM,(s-n.tMs)/1e3,n.forms)))});const i=t.points[u],a=t.points[u+1];if(i&&a){const n=(p-i.tMs)/(a.tMs-i.tMs),M=(y,T)=>y+(T-y)*n;d.push(o(i,M(i.eastM,a.eastM),M(i.northM,a.northM),M(i.upM,a.upM),x.FORMATION_S,i.forms&&a.forms))}return d}pushSegment(t,s,c,p,d,o){const u=e=>({persistent:e.point.persistent,lifetimeS:e.point.lifetimeS,spanM:p,shearPerS:e.point.shearPerS,saturatedForS:e.point.saturatedForS}),i=x.opacity(s.age,u(s)),a=x.opacity(c.age,u(c));if(i<=0&&a<=0)return t;const n={x:c.x-s.x,y:c.y-s.y,z:c.z-s.z};if(Math.hypot(n.x,n.y,n.z)<1e-6)return t;const M={x:(s.x+c.x)/2-o.eye.x,y:(s.y+c.y)/2-o.eye.y,z:(s.z+c.z)/2-o.eye.z},y=this.normalise(this.cross(n,M)),T=e=>{if(!o.sun)return d;const r={x:e.x-o.eye.x,y:e.y-o.eye.y,z:e.z-o.eye.z},E=h.phase((o.sun.x*r.x+o.sun.y*r.y+o.sun.z*r.z)/(Math.hypot(r.x,r.y,r.z)||1));return[d[0]*E,d[1]*E,d[2]*E]},l=(e,r)=>{const E=Math.hypot(e.x-o.eye.x,e.y-o.eye.y,e.z-o.eye.z),A=x.widthM(p,e.age,e.point.shearPerS),g=Math.max(A,h.MIN_PIXELS*o.pixelRad*E),z=r*(A/g)**h.UNRESOLVED_CONTRAST,S=x.profileExponent(e.age),G=h.STATIONS.map((j,P)=>P===h.STATIONS.length-1?0:z*Math.exp(-Math.LN2*j**S));return{half:g/2,profile:G,scattered:T(e)}},N=[{sample:s,...l(s,i)},{sample:c,...l(c,a)}],w=h.STATIONS.length-1,f=(e,r,E)=>{const A=h.STATIONS[r],g=e.half*A*E,z=t*3;this.positions[z]=e.sample.x+y.x*g,this.positions[z+1]=e.sample.y+y.y*g,this.positions[z+2]=e.sample.z+y.z*g;const S=t*4;this.colors[S]=e.scattered[0],this.colors[S+1]=e.scattered[1],this.colors[S+2]=e.scattered[2],this.colors[S+3]=e.profile[r],t++},[R,O]=N;for(const e of[-1,1])for(let r=0;r<w;r++)f(R,r+1,e),f(R,r,e),f(O,r+1,e),f(R,r,e),f(O,r,e),f(O,r+1,e);return t}cross(t,s){return{x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x}}normalise(t){const s=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/s,y:t.y/s,z:t.z/s}}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.group.removeFromParent()}}export{h as ContrailSystem};
@@ -1,4 +1,4 @@
1
- import{b3 as b,bH as A,c3 as D,bJ as F,c4 as M,c5 as R,c6 as E,aX as P,br as S,c7 as U,bS as k}from"./rr0-sighting-editor.mjs";class w{target;wideCamera=new b;materials=new Map;draw(t){const{renderer:s,camera:r,equidistant:a}=t,i=s.getDrawingBufferSize(new A),n=i.x,o=i.y,e=n/o;if(a&&!D.supports(r.fov,e))throw new Error(`A field of ${r.fov}° is drawn through a cube, which the control passes do not follow yet: export through a narrower field.`);const c=this.sourceCamera(r,a?a.sourceFovDeg(r.fov,e):r.fov),d=this.usableTarget(n,o),l=this.drawDistance(t,c,d),u=this.drawPhenomenon(t,c,d),f=Math.tan(c.fov*Math.PI/360),h=new Float32Array(n*o),p=new Uint8Array(n*o);for(let v=0;v<o;v++)for(let g=0;g<n;g++){const m=this.sourcePixel(g,v,n,o,r.fov,e,f,a);if(m<0)continue;const x=v*n+g;h[x]=l[m*4];const y=u[m*4],T=u[m*4+1],C=u[m*4+2],_=u[m*4+3];p[x]=Math.max(y,T,C,_)>w.LIGHT_THRESHOLD?255:0}return{width:n,height:o,distanceM:h,phenomenon:p}}dispose(){this.target?.dispose();for(const t of this.materials.values())t.dispose();this.materials.clear()}static LIGHT_THRESHOLD=1e-6;sourcePixel(t,s,r,a,i,n,o,e){if(!e)return(a-1-s)*r+t;const c=(t+.5)/r*2-1,d=1-(s+.5)/a*2,l=e.directionFor(c,d,i);if(l.z>=0)return-1;const u=l.x/-l.z/(o*n),f=l.y/-l.z/o,h=Math.floor((u+1)/2*r),p=Math.floor((f+1)/2*a);return h<0||h>=r||p<0||p>=a?-1:p*r+h}sourceCamera(t,s){const r=this.wideCamera.copy(t);return r.fov=s,r.clearViewOffset(),r.updateProjectionMatrix(),r.updateMatrixWorld(),r}usableTarget(t,s){return this.target?(this.target.width!==t||this.target.height!==s)&&this.target.setSize(t,s):this.target=new F(t,s,{type:E,format:R,minFilter:M,magFilter:M,depthBuffer:!0}),this.target}drawDistance(t,s,r){const{renderer:a,scene:i}=t,n=[],o=[];for(const e of t.sky)e.visible&&(e.visible=!1,n.push(e));i.traverseVisible(e=>{if(e instanceof P){if(t.isSolid(e)){o.push({mesh:e,material:e.material}),e.material=Array.isArray(e.material)?e.material.map(c=>this.distanceMaterial(c)):this.distanceMaterial(e.material);return}}else if(!e.isPoints&&!e.isLine&&!e.isSprite)return;n.push(e)});for(const e of n)e.visible=!1;try{return this.drawInto(t,r,()=>a.render(i,s))}finally{for(const e of n)e.visible=!0;for(const{mesh:e,material:c}of o)e.material=c}}drawPhenomenon(t,s,r){return this.drawInto(t,r,()=>t.drawPhenomena(s))}drawInto(t,s,r){const{renderer:a,scene:i}=t,n=a.getRenderTarget(),o=a.autoClear,e=a.shadowMap.autoUpdate,c=i.fog,d=i.background,l=a.getClearAlpha(),u=a.getClearColor(new S);i.fog=null,i.background=null,a.shadowMap.autoUpdate=!1,a.setRenderTarget(s),a.setClearColor(0,0),a.clear(!0,!0,!0),a.autoClear=!1;try{r();const f=new Float32Array(s.width*s.height*4);return U.now(a,s,0,0,s.width,s.height,f),f}finally{a.autoClear=o,a.shadowMap.autoUpdate=e,a.setRenderTarget(n),a.setClearColor(u,l),i.fog=c,i.background=d}}distanceMaterial(t){const s=t.alphaTest??0,r=t.map??t.alphaMap??null,a=s>0&&r!==null,i=`${t.side}:${a?`${r.uuid}:${s}`:"-"}`;let n=this.materials.get(i);return n||(n=new k({defines:a?{CUTOUT:"",USE_UV:""}:{},uniforms:{cutoutMap:{value:r},cutoutAlpha:{value:s}},vertexShader:w.VERTEX,fragmentShader:w.FRAGMENT,side:t.side}),this.materials.set(i,n)),n}static VERTEX=`
1
+ import{b4 as b,bI as A,c4 as D,bK as F,c5 as M,c6 as R,c7 as E,aY as P,bs as U,c8 as k,bT as S}from"./rr0-sighting-editor.mjs";class w{target;wideCamera=new b;materials=new Map;draw(t){const{renderer:s,camera:r,equidistant:a}=t,i=s.getDrawingBufferSize(new A),n=i.x,o=i.y,e=n/o;if(a&&!D.supports(r.fov,e))throw new Error(`A field of ${r.fov}° is drawn through a cube, which the control passes do not follow yet: export through a narrower field.`);const c=this.sourceCamera(r,a?a.sourceFovDeg(r.fov,e):r.fov),d=this.usableTarget(n,o),l=this.drawDistance(t,c,d),u=this.drawPhenomenon(t,c,d),f=Math.tan(c.fov*Math.PI/360),h=new Float32Array(n*o),p=new Uint8Array(n*o);for(let v=0;v<o;v++)for(let g=0;g<n;g++){const m=this.sourcePixel(g,v,n,o,r.fov,e,f,a);if(m<0)continue;const x=v*n+g;h[x]=l[m*4];const y=u[m*4],T=u[m*4+1],C=u[m*4+2],_=u[m*4+3];p[x]=Math.max(y,T,C,_)>w.LIGHT_THRESHOLD?255:0}return{width:n,height:o,distanceM:h,phenomenon:p}}dispose(){this.target?.dispose();for(const t of this.materials.values())t.dispose();this.materials.clear()}static LIGHT_THRESHOLD=1e-6;sourcePixel(t,s,r,a,i,n,o,e){if(!e)return(a-1-s)*r+t;const c=(t+.5)/r*2-1,d=1-(s+.5)/a*2,l=e.directionFor(c,d,i);if(l.z>=0)return-1;const u=l.x/-l.z/(o*n),f=l.y/-l.z/o,h=Math.floor((u+1)/2*r),p=Math.floor((f+1)/2*a);return h<0||h>=r||p<0||p>=a?-1:p*r+h}sourceCamera(t,s){const r=this.wideCamera.copy(t);return r.fov=s,r.clearViewOffset(),r.updateProjectionMatrix(),r.updateMatrixWorld(),r}usableTarget(t,s){return this.target?(this.target.width!==t||this.target.height!==s)&&this.target.setSize(t,s):this.target=new F(t,s,{type:E,format:R,minFilter:M,magFilter:M,depthBuffer:!0}),this.target}drawDistance(t,s,r){const{renderer:a,scene:i}=t,n=[],o=[];for(const e of t.sky)e.visible&&(e.visible=!1,n.push(e));i.traverseVisible(e=>{if(e instanceof P){if(t.isSolid(e)){o.push({mesh:e,material:e.material}),e.material=Array.isArray(e.material)?e.material.map(c=>this.distanceMaterial(c)):this.distanceMaterial(e.material);return}}else if(!e.isPoints&&!e.isLine&&!e.isSprite)return;n.push(e)});for(const e of n)e.visible=!1;try{return this.drawInto(t,r,()=>a.render(i,s))}finally{for(const e of n)e.visible=!0;for(const{mesh:e,material:c}of o)e.material=c}}drawPhenomenon(t,s,r){return this.drawInto(t,r,()=>t.drawPhenomena(s))}drawInto(t,s,r){const{renderer:a,scene:i}=t,n=a.getRenderTarget(),o=a.autoClear,e=a.shadowMap.autoUpdate,c=i.fog,d=i.background,l=a.getClearAlpha(),u=a.getClearColor(new U);i.fog=null,i.background=null,a.shadowMap.autoUpdate=!1,a.setRenderTarget(s),a.setClearColor(0,0),a.clear(!0,!0,!0),a.autoClear=!1;try{r();const f=new Float32Array(s.width*s.height*4);return k.now(a,s,0,0,s.width,s.height,f),f}finally{a.autoClear=o,a.shadowMap.autoUpdate=e,a.setRenderTarget(n),a.setClearColor(u,l),i.fog=c,i.background=d}}distanceMaterial(t){const s=t.alphaTest??0,r=t.map??t.alphaMap??null,a=s>0&&r!==null,i=`${t.side}:${a?`${r.uuid}:${s}`:"-"}`;let n=this.materials.get(i);return n||(n=new S({defines:a?{CUTOUT:"",USE_UV:""}:{},uniforms:{cutoutMap:{value:r},cutoutAlpha:{value:s}},vertexShader:w.VERTEX,fragmentShader:w.FRAGMENT,side:t.side}),this.materials.set(i,n)),n}static VERTEX=`
2
2
  #include <common>
3
3
  #include <uv_pars_vertex>
4
4
  #include <batching_pars_vertex>
@@ -1 +1 @@
1
- import{bA as o}from"./rr0-sighting-editor.mjs";const l=[{id:"when",paths:["time"]},{id:"where",paths:["place.locations.*.lat","place.locations.*.lng","observerTrack.keyframes.*.pose.lat","observerTrack.keyframes.*.pose.lng"]},{id:"facing",paths:["observerTrack.keyframes.*.pose.headingDeg"]},{id:"apparent-size",paths:["timeline.keyframes.*.shapes.*.shape.angular.widthDeg","timeline.keyframes.*.shapes.*.shape.angular.heightDeg"]},{id:"sky-position",paths:["timeline.keyframes.*.shapes.*.shape.aim.azimuthDeg","timeline.keyframes.*.shapes.*.shape.aim.altitudeDeg"]},{id:"how-long",paths:["durationSeconds","endTime"]},{id:"appearance",paths:["timeline.keyframes.*.shapes.*.shape.kind","timeline.keyframes.*.shapes.*.shape.title","timeline.keyframes.*.shapes.*.shape.color","timeline.keyframes.*.shapes.*.shape.brightness"]},{id:"movement",paths:["timeline.keyframes.1.t","observerTrack.keyframes.1.t"]},{id:"sound",paths:["soundTrack.keyframes.*.sound.kind"]},{id:"conditions",paths:["weatherTrack.keyframes.*.weather.*","weather.*"]}],d=["fitted","assumed","derived","stated","measured","established"];class p{about="observer";async assess(a){const i=o(a,!0),s=l.map(e=>p.answer(e,i,a));return{score:s.filter(e=>e.basis==="stated").length/s.length,criteria:s}}static answer(a,i,s){const e=a.paths.flatMap(t=>p.resolve(t,i));if(e.length===0)return{id:a.id,paths:[]};const r=e.map(t=>p.basisAt(t,s)??"stated");return{id:a.id,basis:d.find(t=>r.includes(t)),paths:e}}static basisAt(a,i){const s=a.split(".");for(let e=s.length;e>0;e--){const r=i.provenance.at(s.slice(0,e).join("."))?.basis;if(r)return r}}static resolve(a,i){let s=[{path:[],value:i}];for(const e of a.split("."))s=s.flatMap(({path:r,value:t})=>{if(typeof t!="object"||t===null)return[];if(e!=="*"){const n=t[e];return n===void 0?[]:[{path:[...r,e],value:n}]}return Object.entries(t).filter(([,n])=>n!==void 0).map(([n,h])=>({path:[...r,n],value:h}))});return s.filter(({value:e})=>e!==null&&e!==""&&!(Array.isArray(e)&&e.length===0)).map(({path:e})=>e.join("."))}}export{p as CoverageAssessor};
1
+ import{bB as o}from"./rr0-sighting-editor.mjs";const l=[{id:"when",paths:["time"]},{id:"where",paths:["place.locations.*.lat","place.locations.*.lng","observerTrack.keyframes.*.pose.lat","observerTrack.keyframes.*.pose.lng"]},{id:"facing",paths:["observerTrack.keyframes.*.pose.headingDeg"]},{id:"apparent-size",paths:["timeline.keyframes.*.shapes.*.shape.angular.widthDeg","timeline.keyframes.*.shapes.*.shape.angular.heightDeg"]},{id:"sky-position",paths:["timeline.keyframes.*.shapes.*.shape.aim.azimuthDeg","timeline.keyframes.*.shapes.*.shape.aim.altitudeDeg"]},{id:"how-long",paths:["durationSeconds","endTime"]},{id:"appearance",paths:["timeline.keyframes.*.shapes.*.shape.kind","timeline.keyframes.*.shapes.*.shape.title","timeline.keyframes.*.shapes.*.shape.color","timeline.keyframes.*.shapes.*.shape.brightness"]},{id:"movement",paths:["timeline.keyframes.1.t","observerTrack.keyframes.1.t"]},{id:"sound",paths:["soundTrack.keyframes.*.sound.kind"]},{id:"conditions",paths:["weatherTrack.keyframes.*.weather.*","weather.*"]}],d=["fitted","assumed","derived","stated","measured","established"];class p{about="observer";async assess(a){const i=o(a,!0),s=l.map(e=>p.answer(e,i,a));return{score:s.filter(e=>e.basis==="stated").length/s.length,criteria:s}}static answer(a,i,s){const e=a.paths.flatMap(t=>p.resolve(t,i));if(e.length===0)return{id:a.id,paths:[]};const r=e.map(t=>p.basisAt(t,s)??"stated");return{id:a.id,basis:d.find(t=>r.includes(t)),paths:e}}static basisAt(a,i){const s=a.split(".");for(let e=s.length;e>0;e--){const r=i.provenance.at(s.slice(0,e).join("."))?.basis;if(r)return r}}static resolve(a,i){let s=[{path:[],value:i}];for(const e of a.split("."))s=s.flatMap(({path:r,value:t})=>{if(typeof t!="object"||t===null)return[];if(e!=="*"){const n=t[e];return n===void 0?[]:[{path:[...r,e],value:n}]}return Object.entries(t).filter(([,n])=>n!==void 0).map(([n,h])=>({path:[...r,n],value:h}))});return s.filter(({value:e})=>e!==null&&e!==""&&!(Array.isArray(e)&&e.length===0)).map(({path:e})=>e.join("."))}}export{p as CoverageAssessor};
@@ -1,4 +1,4 @@
1
- import{n as v,_ as l,b8 as p,b5 as f,$ as m,a1 as b,a0 as w,I as O,Y as T,Z as I,a2 as M,a3 as k}from"./rr0-sighting-editor.mjs";import{S as L}from"./SkyEventEditorStyle-CvY_AhbI.js";import{D as y,a as c,b as E}from"./DroneFlight-Fr4Vgso3.js";const S=v.catalog({en:()=>l(()=>import("./DroneParameterTexts_en-sL1dR2RG.js"),[],import.meta.url).then(a=>a.droneParameterTexts_en),fr:()=>l(()=>import("./DroneParameterTexts_fr-B8Ym7Yz6.js"),[],import.meta.url).then(a=>a.droneParameterTexts_fr),es:()=>l(()=>import("./DroneParameterTexts_es-Bg8_8XVE.js"),[],import.meta.url).then(a=>a.droneParameterTexts_es),it:()=>l(()=>import("./DroneParameterTexts_it-DfvWjvoc.js"),[],import.meta.url).then(a=>a.droneParameterTexts_it)});class s{static DRONE="drone";static FLIGHT="flight";static LOOK="look";static LIGHT_NAMES=[...new Set(y.ALL.flatMap(t=>Object.keys(t.lights)))];static textKey(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static flightOf(t){return t}static ownLight(t,e){return c.airframeOf(s.flightOf(t)).lights[e]}static formationUnstated(t){return(p.read(t,"count")??1)>1?"cluster":"single"}static formationOf(t){const e=p.read(t,"formation.kind");return typeof e=="string"?e:s.formationUnstated(t)}static hovers(t){return c.airframeOf(s.flightOf(t)).hovers}static light(t){const e=s.textKey(t),i=o=>s.ownLight(o,t)!==void 0,n=o=>{const h=s.flightOf(o).lights?.[t];return h===!1?!0:typeof h?.off=="boolean"?h.off:s.ownLight(o,t)?.off===!0},r=o=>i(o)&&!n(o);return[{type:"boolean",key:`lights.${t}.off`,group:e,label:"switchedOff",visibleWhen:i,effective:o=>s.flightOf(o).lights?.[t]===!1||s.ownLight(o,t)?.off===!0},{type:"colour",key:`lights.${t}.color`,group:e,label:"colour",visibleWhen:r,effective:o=>s.ownLight(o,t)?.color},{type:"number",key:`lights.${t}.candela`,min:0,max:1e5,step:.1,unit:"cd",group:e,label:"intensity",hint:"eachLed",visibleWhen:r,effective:o=>s.ownLight(o,t)?.candela},{type:"number",key:`lights.${t}.hz`,min:0,max:50,step:.05,unit:"Hz",group:e,label:"flashesASecond",hint:"steadyAtNought",visibleWhen:r,effective:o=>s.ownLight(o,t)?.hz??0},{type:"number",key:`lights.${t}.flashS`,min:.001,max:60,step:.001,unit:"s",group:e,label:"eachFlashLasts",visibleWhen:o=>r(o)&&(p.read(o,`lights.${t}.hz`)??s.ownLight(o,t)?.hz??0)>0,effective:o=>{const h=s.ownLight(o,t),d=p.read(o,`lights.${t}.hz`)??h?.hz??0;return h?.flashS??(d>0?Math.round(500/d)/1e3:void 0)}}]}static SET={kind:"drones",title:"drones",parameters:[{type:"said",key:"title",label:"name",group:s.DRONE},{type:"choice",key:"airframe",required:!0,group:s.DRONE,label:"airframe",choices:y.ALL.map(t=>({value:t.id,label:s.textKey(t.id)}))},{type:"number",key:"count",min:1,max:2e3,step:1,group:s.DRONE,effective:()=>1,label:"howMany"},{type:"set",key:"explains",group:s.DRONE,label:"standForTheShapes",hint:"theWholeGroupTakenForOne",visibleWhen:t=>s.flightOf(t).explainsEach===void 0,options:(t,e)=>{const i=e?.shapes??[],n=(s.flightOf(t).explains??[]).filter(r=>!i.some(o=>o.value===r));return[...i,...n.map(r=>({value:r,label:r}))]},empty:"noShape"},{type:"number",key:"seed",min:0,max:4294967295,step:1,group:s.DRONE,effective:()=>1,label:"draw",hint:"whatTheDrawsStartFrom"},{type:"choice",key:"formation.kind",group:s.FLIGHT,label:"pattern",effective:t=>s.formationUnstated(t),choices:[{value:"single",label:"oneDrone"},{value:"cluster",label:"aLooseGroup"},{value:"line",label:"abreast"}],visibleWhen:t=>(p.read(t,"count")??1)>1},{type:"number",key:"formation.spacingM",min:.5,max:1e3,step:.5,unit:"m",group:s.FLIGHT,effective:t=>s.formationOf(t)==="line"?5:10,label:"spacing",hint:"betweenNeighbours",visibleWhen:t=>(p.read(t,"count")??1)>1&&s.formationOf(t)!=="single"},{type:"number",key:"headingDeg",min:0,max:360,step:1,unit:"°",group:s.FLIGHT,label:"noseTowards",hint:"emptyItFacesWhereItGoes",placeholder:"whereItGoes",visibleWhen:s.hovers},{type:"number",key:"wind.fromDeg",min:0,max:360,step:1,unit:"°",group:s.FLIGHT,label:"windFrom",effective:()=>0,hint:"whatItLeansInto"},{type:"number",key:"wind.speedMS",min:0,max:60,step:.1,unit:"m/s",group:s.FLIGHT,label:"windSpeed",effective:()=>0},{type:"boolean",key:"silent",group:s.FLIGHT,label:"silent",hint:"notEvenItsRotors"},{type:"number",key:"quieterDb",min:0,max:60,step:1,unit:"dB",group:s.FLIGHT,label:"quieter",hint:"thanItsClass",effective:()=>0,visibleWhen:t=>p.read(t,"silent")!==!0},{type:"colour",key:"bodyColor",group:s.LOOK,label:"hull",effective:t=>c.airframeOf(s.flightOf(t)).bodyColor},...s.LIGHT_NAMES.flatMap(t=>s.light(t))]};static angular(t){return typeof t.azimuthDeg=="number"}static WAYPOINT={kind:"drones-waypoint",title:"pointOfThePath",parameters:[{type:"number",key:"t",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"time",hint:"secondsOfTheRecording"},{type:"position",key:"eastM",secondKey:"northM",saidKey:"saidPosition",native:"local",step:1,rangeM:1e5,label:"position",visibleWhen:t=>!s.angular(t)},{type:"number",key:"altitudeM",min:-500,max:2e4,step:.1,unit:"m",required:!0,label:"height",hint:"aboveTheGroundOfThePlace",visibleWhen:t=>!s.angular(t)},{type:"number",key:"azimuthDeg",min:0,max:360,step:.1,unit:"°",required:!0,label:"azimuth",visibleWhen:t=>s.angular(t)},{type:"number",key:"altitudeDeg",min:-90,max:90,step:.1,unit:"°",required:!0,label:"elevation",visibleWhen:t=>s.angular(t)},{type:"number",key:"distanceM",min:0,max:1e5,step:1,unit:"m",required:!0,label:"distance",visibleWhen:t=>s.angular(t)},{type:"number",key:"eyeHeightM",min:0,max:1e4,step:.1,unit:"m",effective:()=>1.6,label:"eyeHeight",visibleWhen:t=>s.angular(t)}]};static waypointAt(t,e){const i=c.pathOf(t);if(i.length===0)return{t:Math.round(e),eastM:0,northM:0,altitudeM:0};const n=new E(i,c.airframeOf(t).hovers).at(e),r=o=>Math.round(o*10)/10;return{t:Math.round(e),eastM:r(n.eastM),northM:r(n.northM),altitudeM:r(n.upM)}}static publish(){f.publish(s.SET),f.publish(s.WAYPOINT)}}const A=v.catalog({en:()=>l(()=>import("./DroneEditorMessages_en-BViHK30c.js"),[],import.meta.url).then(a=>a.droneEditorMessages_en),fr:()=>l(()=>import("./DroneEditorMessages_fr-CvV0RyOT.js"),[],import.meta.url).then(a=>a.droneEditorMessages_fr),es:()=>l(()=>import("./DroneEditorMessages_es-D6bhIOAa.js"),[],import.meta.url).then(a=>a.droneEditorMessages_es),it:()=>l(()=>import("./DroneEditorMessages_it-CYi-jmVN.js"),[],import.meta.url).then(a=>a.droneEditorMessages_it)});class u{constructor(t,e,i){this.container=t,this.host=e,L.attach(t,"drone-editor-part",u.STYLE),this.language=i,f.of("drones")||s.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;pointForm;pointIndex=0;language;shown=[];static STYLE='.drone-editor-part { flex-basis: 100%; min-width: 0; } .drone-editor-part #drone-list, .drone-editor-part #drone-timeline { flex-basis: 100%; min-width: 0; } .drone-editor-part #drone-timeline { padding: 4px 0; } .drone-editor-part #drone-path > .icon-btn { align-self: flex-end; } .drone-editor-part .launch-editor, .drone-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .drone-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .drone-editor-part [hidden] { display: none !important; } .drone-editor-part select { min-width: 0; width: 100%; } .drone-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .drone-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .drone-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .drone-editor-part input, .drone-editor-part select { max-width: 100%; box-sizing: border-box; } .drone-editor-part input[type="text"] { width: 12em; } .drone-editor-part label { min-width: 0; max-width: 100%; } .drone-editor-part input.parameter-derived::placeholder { opacity: .65; } .drone-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';static PATH_COLOR="#3b82c4";async setLanguage(t){const e=++this.languageToken;this.language=t;const[i,n]=await Promise.all([A.load(t),S.load(t)]);e===this.languageToken&&(this.messages=i,this.parameterTexts=n,this.render(),this.sync())}sync(){if(!this.messages)return;const t=this.flights;this.shown=[...t],t.some(n=>n.id===this.currentId)||(this.currentId=t[0]?.id),this.list?.setItems(t.map(n=>({id:n.id,label:this.labelOf(n)})),this.currentId),this.syncAddState();const e=this.current;if(this.element("drone-fields").hidden=e===void 0,!e)return;const i=this.element("drone-each");i.hidden=e.explainsEach===void 0,i.textContent=this.messages.explainsEachNote.replace("{n}",String(e.explainsEach?.length??0)),this.form??=new m(this.element("drone-parameters"),this.language,"drones.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(s.SET),new b(()=>this.current,n=>this.editFlight(r=>n(r)),()=>({shapes:this.host.shapes().map(n=>({value:n.id,label:n.label}))}),this.host.positionPlace?.()),()=>this.written()),this.syncPoint(!0)}refresh(){if(!this.messages)return;this.syncAddState();const t=this.flights;if(t.length===this.shown.length&&t.every((e,i)=>e.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(t){this.messages&&this.timeline?.setTime(t)}syncAddState(){const t=this.frontOfObserver()!==void 0;this.list?.setAddState(t,t?void 0:this.messages.addNowhere)}get current(){return this.flights.find(t=>t.id===this.currentId)}resolved(t){return w.resolve(t,this.parameterTexts)}render(){if(!this.messages)return;const t=this.messages;this.form=void 0,this.pointForm=void 0,this.container.innerHTML=`<div class="launch-editor">
1
+ import{n as v,_ as l,b9 as p,b6 as f,$ as m,a1 as b,a0 as w,I as O,Y as T,Z as I,a2 as M,a3 as k}from"./rr0-sighting-editor.mjs";import{S as L}from"./SkyEventEditorStyle-CvY_AhbI.js";import{D as y,a as c,b as E}from"./DroneFlight-BpnBgJ9K.js";const S=v.catalog({en:()=>l(()=>import("./DroneParameterTexts_en-sL1dR2RG.js"),[],import.meta.url).then(a=>a.droneParameterTexts_en),fr:()=>l(()=>import("./DroneParameterTexts_fr-B8Ym7Yz6.js"),[],import.meta.url).then(a=>a.droneParameterTexts_fr),es:()=>l(()=>import("./DroneParameterTexts_es-Bg8_8XVE.js"),[],import.meta.url).then(a=>a.droneParameterTexts_es),it:()=>l(()=>import("./DroneParameterTexts_it-DfvWjvoc.js"),[],import.meta.url).then(a=>a.droneParameterTexts_it)});class s{static DRONE="drone";static FLIGHT="flight";static LOOK="look";static LIGHT_NAMES=[...new Set(y.ALL.flatMap(t=>Object.keys(t.lights)))];static textKey(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static flightOf(t){return t}static ownLight(t,e){return c.airframeOf(s.flightOf(t)).lights[e]}static formationUnstated(t){return(p.read(t,"count")??1)>1?"cluster":"single"}static formationOf(t){const e=p.read(t,"formation.kind");return typeof e=="string"?e:s.formationUnstated(t)}static hovers(t){return c.airframeOf(s.flightOf(t)).hovers}static light(t){const e=s.textKey(t),i=o=>s.ownLight(o,t)!==void 0,n=o=>{const h=s.flightOf(o).lights?.[t];return h===!1?!0:typeof h?.off=="boolean"?h.off:s.ownLight(o,t)?.off===!0},r=o=>i(o)&&!n(o);return[{type:"boolean",key:`lights.${t}.off`,group:e,label:"switchedOff",visibleWhen:i,effective:o=>s.flightOf(o).lights?.[t]===!1||s.ownLight(o,t)?.off===!0},{type:"colour",key:`lights.${t}.color`,group:e,label:"colour",visibleWhen:r,effective:o=>s.ownLight(o,t)?.color},{type:"number",key:`lights.${t}.candela`,min:0,max:1e5,step:.1,unit:"cd",group:e,label:"intensity",hint:"eachLed",visibleWhen:r,effective:o=>s.ownLight(o,t)?.candela},{type:"number",key:`lights.${t}.hz`,min:0,max:50,step:.05,unit:"Hz",group:e,label:"flashesASecond",hint:"steadyAtNought",visibleWhen:r,effective:o=>s.ownLight(o,t)?.hz??0},{type:"number",key:`lights.${t}.flashS`,min:.001,max:60,step:.001,unit:"s",group:e,label:"eachFlashLasts",visibleWhen:o=>r(o)&&(p.read(o,`lights.${t}.hz`)??s.ownLight(o,t)?.hz??0)>0,effective:o=>{const h=s.ownLight(o,t),d=p.read(o,`lights.${t}.hz`)??h?.hz??0;return h?.flashS??(d>0?Math.round(500/d)/1e3:void 0)}}]}static SET={kind:"drones",title:"drones",parameters:[{type:"said",key:"title",label:"name",group:s.DRONE},{type:"choice",key:"airframe",required:!0,group:s.DRONE,label:"airframe",choices:y.ALL.map(t=>({value:t.id,label:s.textKey(t.id)}))},{type:"number",key:"count",min:1,max:2e3,step:1,group:s.DRONE,effective:()=>1,label:"howMany"},{type:"set",key:"explains",group:s.DRONE,label:"standForTheShapes",hint:"theWholeGroupTakenForOne",visibleWhen:t=>s.flightOf(t).explainsEach===void 0,options:(t,e)=>{const i=e?.shapes??[],n=(s.flightOf(t).explains??[]).filter(r=>!i.some(o=>o.value===r));return[...i,...n.map(r=>({value:r,label:r}))]},empty:"noShape"},{type:"number",key:"seed",min:0,max:4294967295,step:1,group:s.DRONE,effective:()=>1,label:"draw",hint:"whatTheDrawsStartFrom"},{type:"choice",key:"formation.kind",group:s.FLIGHT,label:"pattern",effective:t=>s.formationUnstated(t),choices:[{value:"single",label:"oneDrone"},{value:"cluster",label:"aLooseGroup"},{value:"line",label:"abreast"}],visibleWhen:t=>(p.read(t,"count")??1)>1},{type:"number",key:"formation.spacingM",min:.5,max:1e3,step:.5,unit:"m",group:s.FLIGHT,effective:t=>s.formationOf(t)==="line"?5:10,label:"spacing",hint:"betweenNeighbours",visibleWhen:t=>(p.read(t,"count")??1)>1&&s.formationOf(t)!=="single"},{type:"number",key:"headingDeg",min:0,max:360,step:1,unit:"°",group:s.FLIGHT,label:"noseTowards",hint:"emptyItFacesWhereItGoes",placeholder:"whereItGoes",visibleWhen:s.hovers},{type:"number",key:"wind.fromDeg",min:0,max:360,step:1,unit:"°",group:s.FLIGHT,label:"windFrom",effective:()=>0,hint:"whatItLeansInto"},{type:"number",key:"wind.speedMS",min:0,max:60,step:.1,unit:"m/s",group:s.FLIGHT,label:"windSpeed",effective:()=>0},{type:"boolean",key:"silent",group:s.FLIGHT,label:"silent",hint:"notEvenItsRotors"},{type:"number",key:"quieterDb",min:0,max:60,step:1,unit:"dB",group:s.FLIGHT,label:"quieter",hint:"thanItsClass",effective:()=>0,visibleWhen:t=>p.read(t,"silent")!==!0},{type:"colour",key:"bodyColor",group:s.LOOK,label:"hull",effective:t=>c.airframeOf(s.flightOf(t)).bodyColor},...s.LIGHT_NAMES.flatMap(t=>s.light(t))]};static angular(t){return typeof t.azimuthDeg=="number"}static WAYPOINT={kind:"drones-waypoint",title:"pointOfThePath",parameters:[{type:"number",key:"t",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"time",hint:"secondsOfTheRecording"},{type:"position",key:"eastM",secondKey:"northM",saidKey:"saidPosition",native:"local",step:1,rangeM:1e5,label:"position",visibleWhen:t=>!s.angular(t)},{type:"number",key:"altitudeM",min:-500,max:2e4,step:.1,unit:"m",required:!0,label:"height",hint:"aboveTheGroundOfThePlace",visibleWhen:t=>!s.angular(t)},{type:"number",key:"azimuthDeg",min:0,max:360,step:.1,unit:"°",required:!0,label:"azimuth",visibleWhen:t=>s.angular(t)},{type:"number",key:"altitudeDeg",min:-90,max:90,step:.1,unit:"°",required:!0,label:"elevation",visibleWhen:t=>s.angular(t)},{type:"number",key:"distanceM",min:0,max:1e5,step:1,unit:"m",required:!0,label:"distance",visibleWhen:t=>s.angular(t)},{type:"number",key:"eyeHeightM",min:0,max:1e4,step:.1,unit:"m",effective:()=>1.6,label:"eyeHeight",visibleWhen:t=>s.angular(t)}]};static waypointAt(t,e){const i=c.pathOf(t);if(i.length===0)return{t:Math.round(e),eastM:0,northM:0,altitudeM:0};const n=new E(i,c.airframeOf(t).hovers).at(e),r=o=>Math.round(o*10)/10;return{t:Math.round(e),eastM:r(n.eastM),northM:r(n.northM),altitudeM:r(n.upM)}}static publish(){f.publish(s.SET),f.publish(s.WAYPOINT)}}const A=v.catalog({en:()=>l(()=>import("./DroneEditorMessages_en-BViHK30c.js"),[],import.meta.url).then(a=>a.droneEditorMessages_en),fr:()=>l(()=>import("./DroneEditorMessages_fr-CvV0RyOT.js"),[],import.meta.url).then(a=>a.droneEditorMessages_fr),es:()=>l(()=>import("./DroneEditorMessages_es-D6bhIOAa.js"),[],import.meta.url).then(a=>a.droneEditorMessages_es),it:()=>l(()=>import("./DroneEditorMessages_it-CYi-jmVN.js"),[],import.meta.url).then(a=>a.droneEditorMessages_it)});class u{constructor(t,e,i){this.container=t,this.host=e,L.attach(t,"drone-editor-part",u.STYLE),this.language=i,f.of("drones")||s.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;pointForm;pointIndex=0;language;shown=[];static STYLE='.drone-editor-part { flex-basis: 100%; min-width: 0; } .drone-editor-part #drone-list, .drone-editor-part #drone-timeline { flex-basis: 100%; min-width: 0; } .drone-editor-part #drone-timeline { padding: 4px 0; } .drone-editor-part #drone-path > .icon-btn { align-self: flex-end; } .drone-editor-part .launch-editor, .drone-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .drone-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .drone-editor-part [hidden] { display: none !important; } .drone-editor-part select { min-width: 0; width: 100%; } .drone-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .drone-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .drone-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .drone-editor-part input, .drone-editor-part select { max-width: 100%; box-sizing: border-box; } .drone-editor-part input[type="text"] { width: 12em; } .drone-editor-part label { min-width: 0; max-width: 100%; } .drone-editor-part input.parameter-derived::placeholder { opacity: .65; } .drone-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';static PATH_COLOR="#3b82c4";async setLanguage(t){const e=++this.languageToken;this.language=t;const[i,n]=await Promise.all([A.load(t),S.load(t)]);e===this.languageToken&&(this.messages=i,this.parameterTexts=n,this.render(),this.sync())}sync(){if(!this.messages)return;const t=this.flights;this.shown=[...t],t.some(n=>n.id===this.currentId)||(this.currentId=t[0]?.id),this.list?.setItems(t.map(n=>({id:n.id,label:this.labelOf(n)})),this.currentId),this.syncAddState();const e=this.current;if(this.element("drone-fields").hidden=e===void 0,!e)return;const i=this.element("drone-each");i.hidden=e.explainsEach===void 0,i.textContent=this.messages.explainsEachNote.replace("{n}",String(e.explainsEach?.length??0)),this.form??=new m(this.element("drone-parameters"),this.language,"drones.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(s.SET),new b(()=>this.current,n=>this.editFlight(r=>n(r)),()=>({shapes:this.host.shapes().map(n=>({value:n.id,label:n.label}))}),this.host.positionPlace?.()),()=>this.written()),this.syncPoint(!0)}refresh(){if(!this.messages)return;this.syncAddState();const t=this.flights;if(t.length===this.shown.length&&t.every((e,i)=>e.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(t){this.messages&&this.timeline?.setTime(t)}syncAddState(){const t=this.frontOfObserver()!==void 0;this.list?.setAddState(t,t?void 0:this.messages.addNowhere)}get current(){return this.flights.find(t=>t.id===this.currentId)}resolved(t){return w.resolve(t,this.parameterTexts)}render(){if(!this.messages)return;const t=this.messages;this.form=void 0,this.pointForm=void 0,this.container.innerHTML=`<div class="launch-editor">
2
2
  <p class="launch-intro">${t.intro}</p>
3
3
  <div id="drone-list"></div>
4
4
  <div id="drone-fields" class="launch-fields">
@@ -1 +1 @@
1
- import{b9 as T}from"./rr0-sighting-editor.mjs";class O{static G=9.81;static ALL=[{id:"quadcopter",modelId:"ufoathome-drone-quadcopter",sizeM:{widthM:.508,lengthM:.493,heightM:.093},hovers:!0,maxSpeedMS:21,maxTiltDeg:35,holdM:{horizontalM:.5,verticalM:.5},yawRateDegS:120,bodyColor:"#5b5f63",lights:{front:{color:"#ff2a1a",candela:1,leds:[{at:[-.125,-.03,-.14],radiusM:.004},{at:[.125,-.03,-.14],radiusM:.004}]},rear:{color:"#2aff5a",candela:1,hz:.5,leds:[{at:[0,.005,.135],radiusM:.004}]},strobe:{color:"#ffffff",candela:40,hz:1.25,flashS:.06,leds:[{at:[0,-.034,.05],radiusM:.006}]}}},{id:"saucer",modelId:"ufoathome-drone-saucer",sizeM:{widthM:.8,lengthM:.8,heightM:.206},hovers:!0,maxSpeedMS:12,maxTiltDeg:25,holdM:{horizontalM:.5,verticalM:.5},yawRateDegS:90,bodyColor:"#c9ccd0",lights:{rim:{color:"#4fd2ff",candela:1,leds:O.ring(12,.388,0,.012)},under:{color:"#ffffff",candela:3,leds:[{at:[0,-.094,0],radiusM:.02}]},strobe:{color:"#ffffff",candela:40,hz:1.25,flashS:.06,off:!0,leds:[{at:[0,.1,0],radiusM:.006}]}}},{id:"fixed-wing",modelId:"ufoathome-drone-fixed-wing",sizeM:{widthM:3.596,lengthM:1.848,heightM:.53},hovers:!1,maxSpeedMS:33,maxTiltDeg:0,holdM:{horizontalM:1,verticalM:.5},yawRateDegS:0,bodyColor:"#6f7568",lights:{"nav-left":{color:"#ff2a1a",candela:2,leds:[{at:[-1.79,.02,.05],radiusM:.008}]},"nav-right":{color:"#2aff5a",candela:2,leds:[{at:[1.79,.02,.05],radiusM:.008}]},tail:{color:"#ffffff",candela:1,leds:[{at:[0,.05,.94],radiusM:.008}]},strobe:{color:"#ffffff",candela:40,hz:1,flashS:.06,leds:[{at:[0,-.1,.1],radiusM:.008}]}}}];static byId(t){return O.ALL.find(a=>a.id===t)}static materialOf(t,a,e){return e>1?`light-${t}-${a+1}`:`light-${t}`}static colourKeyOf(t){return t.replace(/-([a-z])/g,(a,e)=>e.toUpperCase())+"Color"}static ring(t,a,e,n){return Array.from({length:t},(s,M)=>{const r=M/t*2*Math.PI;return{at:[Math.round(a*Math.sin(r)*1e4)/1e4,e,Math.round(-a*Math.cos(r)*1e4)/1e4],radiusM:n}})}}class i{static SAMPLE_MS=100;static MAX_KEYFRAMES=6e4;static computed=new Map;static bodiesOf(t){const a=JSON.stringify(t);let e=i.computed.get(a);return e||(e=i.compute(t),i.computed.set(a,e),i.computed.size>16&&i.computed.delete(i.computed.keys().next().value)),e}static airframeOf(t){return O.byId(t.airframe)??O.ALL[0]}static lightsOf(t){const a=i.airframeOf(t),e={};for(const[n,s]of Object.entries(a.lights)){const M=t.lights?.[n];if(M===!1)continue;const r={...s,...M??{}};r.off||(e[n]=r)}return e}static compute(t){const a=i.pathOf(t);if(a.length===0)return[];const e=i.airframeOf(t),n=new j(a,e.hovers),s=Math.max(1,Math.floor(t.count??1)),M=i.randomFrom(t.seed??1),r=a[0].t,c=Math.max(a[a.length-1].t,r),d=i.sampleMs(s,c-r),u=i.offsetsOf(t.formation??{kind:s>1?"cluster":"single"},s,M),f=i.lightsOf(t),y={bodyColor:t.bodyColor??e.bodyColor};for(const[m,o]of Object.entries(f))y[O.colourKeyOf(m)]=o.color;const S=t.formation?.kind==="line";return u.map((m,o)=>{const h=i.swayFrom(M,e.holdM),p=Object.fromEntries(Object.entries(f).map(([l,b])=>[l,b.phase??(s>1?M():0)])),g=l=>{const b=n.at(l),[z,I,N]=h((l-r)/1e3);let k=m.eastM,C=m.northM;if(S){const D=n.velocityAt(l),R=Math.hypot(D.east,D.north)>.3?Math.atan2(D.east,D.north):n.headingAtRest(l);k=Math.cos(R)*m.rightM,C=-Math.sin(R)*m.rightM}return{eastM:b.eastM+k+z,northM:b.northM+C+I,upM:b.upM+m.upM+N}},w=[];for(let l=r;l<=c+1e-6;l+=d)w.push(l);w[w.length-1]<c&&w.push(c);const x=i.attitudes(w.map(l=>({t:l,...g(l),headingDeg:0,pitchDeg:0,rollDeg:0})),e,t),P=i.switchesOf(f,p,r,c),E=[...new Set([...w.map(l=>Math.round(l)),...P])].filter(l=>l>=r&&l<=c).sort((l,b)=>l-b);let v=0;const A=E.map((l,b)=>{for(;v<x.length-2&&x[v+1].t<=l;)v++;const z=i.between(x[v],x[Math.min(x.length-1,v+1)],l,g);return{t:l,eastM:i.round(z.eastM),northM:i.round(z.northM),altitudeM:i.round(z.upM-e.sizeM.heightM/2),...b===0?{sizeM:e.sizeM}:{},attitude:{headingDeg:i.round(z.headingDeg,10),pitchDeg:i.round(z.pitchDeg,10),rollDeg:i.round(z.rollDeg,10)},lights:i.luminancesAt(f,p,l,E[b+1]===l+1)}});return{id:s>1?`${t.id}-${o+1}`:t.id,...t.title?{title:t.title}:{},...t.explainsEach?t.explainsEach[o]!==void 0?{explains:[t.explainsEach[o]]}:{}:{...t.explains?{explains:t.explains}:{},...s>1?{ensemble:t.id}:{}},model:{id:e.modelId},modelParameters:y,lamps:i.lampsOf(f,p),...t.silent?{}:{sound:{kind:"unmanned",...t.quieterDb?{quieterDb:t.quieterDb}:{}}},track:A}})}static lampsOf(t,a){return Object.entries(t).flatMap(([e,n])=>n.leds.map((s,M)=>{const r=n.hz>0,c=r?1/n.hz:0;return{id:O.materialOf(e,M,n.leds.length),offsetM:{x:s.at[0],y:s.at[1],z:-s.at[2]},color:n.color,intensity:n.candela/T,pattern:r?{kind:"flash",perMinute:n.hz*60,dutyCycle:Math.min(1,(n.flashS??.5*c)/c),phase:((1-(a[e]??0))%1+1)%1}:{kind:"steady"}}}))}static luminancesAt(t,a,e,n=!1){const s={};for(const[M,r]of Object.entries(t)){const c=i.isOn(r,a[M]??0,n?e-1:e+.5);r.leds.forEach((d,u)=>{s[O.materialOf(M,u,r.leds.length)]=c?i.round(r.candela/(Math.PI*d.radiusM**2),1):0})}return s}static isOn(t,a,e){if(!(t.hz>0))return!0;const n=1e3/t.hz,s=Math.min(n,(t.flashS??.5/t.hz)*1e3);return((e/n-a)%1+1)%1*n<s}static switchesOf(t,a,e,n){const s=[];for(const[M,r]of Object.entries(t)){if(!(r.hz>0))continue;const c=1e3/r.hz,d=Math.min(c,(r.flashS??.5/r.hz)*1e3);if(d>=c)continue;const u=(a[M]??0)*c;for(let f=Math.floor((e-u)/c)*c+u;f<=n;f+=c)for(const y of[f,f+d]){const S=Math.round(y);S>=e&&S<n&&s.push(S,S+1)}}return s}static sampleMs(t,a){const e=t*(a/i.SAMPLE_MS+1);return e<=i.MAX_KEYFRAMES?i.SAMPLE_MS:Math.ceil(i.SAMPLE_MS*e/i.MAX_KEYFRAMES/50)*50}static pathOf(t){return[...t.path].sort((a,e)=>a.t-e.t).map(a=>{if("eastM"in a)return{t:a.t,eastM:a.eastM,northM:a.northM,upM:a.altitudeM};const e=a.azimuthDeg*Math.PI/180,n=a.altitudeDeg*Math.PI/180,s=a.distanceM*Math.cos(n);return{t:a.t,eastM:s*Math.sin(e),northM:s*Math.cos(e),upM:(a.eyeHeightM??1.6)+a.distanceM*Math.sin(n)}})}static offsetsOf(t,a,e){if(t.kind==="single"||a===1)return[{eastM:0,northM:0,upM:0,rightM:0}];if(t.kind==="line"){const c=t.spacingM??5;return Array.from({length:a},(d,u)=>({eastM:0,northM:0,upM:(e()-.5)*c*.2,rightM:(u-(a-1)/2)*c}))}const n=t.spacingM??10,s=Math.cbrt(a*n**3/(4/3*Math.PI*2*2*1)),M=[];let r=0;for(;M.length<a&&r<a*200;){r++;const c=2*e()-1,d=2*e()-1,u=2*e()-1;if(c*c+d*d+u*u>1)continue;const f={eastM:c*2*s,northM:d*2*s,upM:u*s,rightM:0};M.some(y=>(y.eastM-f.eastM)**2+(y.northM-f.northM)**2+(y.upM-f.upM)**2<(n/2)**2)||M.push(f)}for(;M.length<a;)M.push({eastM:(e()-.5)*4*s,northM:(e()-.5)*4*s,upM:0,rightM:0});return M}static swayFrom(t,a){const e=[a.horizontalM,a.horizontalM,a.verticalM].map(n=>[0,1].map(()=>({period:4+t()*10,phase:t()*2*Math.PI,amplitude:n*.5*(.5+.5*t())})));return n=>e.map(s=>s.reduce((M,r)=>M+r.amplitude*Math.sin(2*Math.PI*n/r.period+r.phase),0))}static attitudes(t,a,e){const n=t.length;if(n===0)return t;const s=O.G,M=(e.wind?.fromDeg??0)*Math.PI/180,r=-(e.wind?.speedMS??0)*Math.sin(M),c=-(e.wind?.speedMS??0)*Math.cos(M),d=o=>{const h=t[Math.max(0,o-1)],p=t[Math.min(n-1,o+1)],g=Math.max((p.t-h.t)/1e3,.001);return{e:(p.eastM-h.eastM)/g,n:(p.northM-h.northM)/g,u:(p.upM-h.upM)/g}},u=t.map((o,h)=>d(h)),f=o=>{const h=u[Math.max(0,o-1)],p=u[Math.min(n-1,o+1)],g=Math.max((t[Math.min(n-1,o+1)].t-t[Math.max(0,o-1)].t)/1e3,.001);return{e:(p.e-h.e)/g,n:(p.n-h.n)/g,u:(p.u-h.u)/g}};if(!a.hovers){for(let o=0;o<n;o++){const h=u[o],p=h.e-r,g=h.n-c,w=Math.hypot(h.e,h.n);t[o].headingDeg=Math.hypot(p,g)>.5?(Math.atan2(p,g)*180/Math.PI+360)%360:o>0?t[o-1].headingDeg:0,t[o].pitchDeg=Math.atan2(h.u,Math.max(w,1))*180/Math.PI+2;const x=f(o),P=w>.5?(x.e*h.n-x.n*h.e)/w:0;t[o].rollDeg=Math.max(-45,Math.min(45,Math.atan(P/s)*180/Math.PI))}return t}const y=s*Math.tan(a.maxTiltDeg*Math.PI/180)/a.maxSpeedMS**2,S=a.yawRateDegS*i.SAMPLE_MS/1e3;let m=e.headingDeg;if(m===void 0){const o=u.find(h=>Math.hypot(h.e,h.n)>1);m=o?(Math.atan2(o.e,o.n)*180/Math.PI+360)%360:0}for(let o=0;o<n;o++){const h=u[o];if(e.headingDeg===void 0&&Math.hypot(h.e,h.n)>1){const z=((Math.atan2(h.e,h.n)*180/Math.PI+360)%360-m+540)%360-180,I=o>0?(t[o].t-t[o-1].t)/i.SAMPLE_MS:1;m=(m+Math.max(-S*I,Math.min(S*I,z))+360)%360}const p=f(o),g=h.e-r,w=h.n-c,x=Math.hypot(g,w),P=p.e+y*x*g,E=p.n+y*x*w,v=Math.max(s+p.u,.2*s),A=m*Math.PI/180,L=P*Math.sin(A)+E*Math.cos(A),l=P*Math.cos(A)-E*Math.sin(A);t[o].headingDeg=m,t[o].pitchDeg=-Math.atan(L/v)*180/Math.PI,t[o].rollDeg=Math.atan(l/v)*180/Math.PI}return t}static between(t,a,e,n){if(e===t.t)return t;if(e===a.t)return a;const s=a.t===t.t?0:Math.min(1,Math.max(0,(e-t.t)/(a.t-t.t))),M=(a.headingDeg-t.headingDeg+540)%360-180;return{t:e,...n(e),headingDeg:(t.headingDeg+M*s+360)%360,pitchDeg:t.pitchDeg+(a.pitchDeg-t.pitchDeg)*s,rollDeg:t.rollDeg+(a.rollDeg-t.rollDeg)*s}}static randomFrom(t){let a=t>>>0;return()=>{a=a+1831565813>>>0;let e=a;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}static round(t,a=100){return Math.round(t*a)/a}}class j{constructor(t,a){this.points=t,this.hovers=a;const e=t;this.speeds=e.map((n,s)=>{const M=e[s-1],r=e[s+1],c=(h,p)=>{const g=Math.max((p.t-h.t)/1e3,.001);return{e:(p.eastM-h.eastM)/g,n:(p.northM-h.northM)/g,u:(p.upM-h.upM)/g}};if(!M||!r)return a||e.length<2?{e:0,n:0,u:0}:M?c(M,n):c(n,r);const d=c(M,n),u=c(n,r),f=Math.hypot(d.e,d.n,d.u),y=Math.hypot(u.e,u.n,u.u);if(a&&(f<.05||y<.05||d.e*u.e+d.n*u.n+d.u*u.u<0))return{e:0,n:0,u:0};const S=n.t-M.t,m=r.t-n.t,o=S/Math.max(S+m,1);return{e:d.e*(1-o)+u.e*o,n:d.n*(1-o)+u.n*o,u:d.u*(1-o)+u.u*o}})}speeds;at(t){const a=this.points;if(a.length===1)return{...a[0],t};if(t<=a[0].t)return this.outside(t,0);if(t>=a[a.length-1].t)return this.outside(t,a.length-1);let e=0;for(;e<a.length-2&&t>a[e+1].t;)e++;const n=a[e],s=a[e+1],M=Math.max((s.t-n.t)/1e3,.001),r=(t-n.t)/(s.t-n.t),c=r*r,d=c*r,u=2*d-3*c+1,f=d-2*c+r,y=-2*d+3*c,S=d-c,m=this.speeds[e],o=this.speeds[e+1];return{t,eastM:u*n.eastM+f*m.e*M+y*s.eastM+S*o.e*M,northM:u*n.northM+f*m.n*M+y*s.northM+S*o.n*M,upM:u*n.upM+f*m.u*M+y*s.upM+S*o.u*M}}velocityAt(t){const a=this.at(t-50),e=this.at(t+50);return{east:(e.eastM-a.eastM)/.1,north:(e.northM-a.northM)/.1,up:(e.upM-a.upM)/.1}}headingAtRest(t){const a=this.points;for(let e=a.length-1;e>0;e--){if(a[e].t>t&&e>1)continue;const n=a[e].eastM-a[e-1].eastM,s=a[e].northM-a[e-1].northM;if(Math.hypot(n,s)>.1)return Math.atan2(n,s)}for(let e=1;e<a.length;e++){const n=a[e].eastM-a[e-1].eastM,s=a[e].northM-a[e-1].northM;if(Math.hypot(n,s)>.1)return Math.atan2(n,s)}return 0}outside(t,a){const e=this.points[a];if(this.hovers)return{...e,t};const n=this.speeds[a],s=(t-e.t)/1e3;return{t,eastM:e.eastM+n.e*s,northM:e.northM+n.n*s,upM:e.upM+n.u*s}}}const K=Object.freeze(Object.defineProperty({__proto__:null,DroneFlight:i,DronePath:j},Symbol.toStringTag,{value:"Module"}));export{O as D,i as a,j as b,K as c};
1
+ import{ba as T}from"./rr0-sighting-editor.mjs";class O{static G=9.81;static ALL=[{id:"quadcopter",modelId:"ufoathome-drone-quadcopter",sizeM:{widthM:.508,lengthM:.493,heightM:.093},hovers:!0,maxSpeedMS:21,maxTiltDeg:35,holdM:{horizontalM:.5,verticalM:.5},yawRateDegS:120,bodyColor:"#5b5f63",lights:{front:{color:"#ff2a1a",candela:1,leds:[{at:[-.125,-.03,-.14],radiusM:.004},{at:[.125,-.03,-.14],radiusM:.004}]},rear:{color:"#2aff5a",candela:1,hz:.5,leds:[{at:[0,.005,.135],radiusM:.004}]},strobe:{color:"#ffffff",candela:40,hz:1.25,flashS:.06,leds:[{at:[0,-.034,.05],radiusM:.006}]}}},{id:"saucer",modelId:"ufoathome-drone-saucer",sizeM:{widthM:.8,lengthM:.8,heightM:.206},hovers:!0,maxSpeedMS:12,maxTiltDeg:25,holdM:{horizontalM:.5,verticalM:.5},yawRateDegS:90,bodyColor:"#c9ccd0",lights:{rim:{color:"#4fd2ff",candela:1,leds:O.ring(12,.388,0,.012)},under:{color:"#ffffff",candela:3,leds:[{at:[0,-.094,0],radiusM:.02}]},strobe:{color:"#ffffff",candela:40,hz:1.25,flashS:.06,off:!0,leds:[{at:[0,.1,0],radiusM:.006}]}}},{id:"fixed-wing",modelId:"ufoathome-drone-fixed-wing",sizeM:{widthM:3.596,lengthM:1.848,heightM:.53},hovers:!1,maxSpeedMS:33,maxTiltDeg:0,holdM:{horizontalM:1,verticalM:.5},yawRateDegS:0,bodyColor:"#6f7568",lights:{"nav-left":{color:"#ff2a1a",candela:2,leds:[{at:[-1.79,.02,.05],radiusM:.008}]},"nav-right":{color:"#2aff5a",candela:2,leds:[{at:[1.79,.02,.05],radiusM:.008}]},tail:{color:"#ffffff",candela:1,leds:[{at:[0,.05,.94],radiusM:.008}]},strobe:{color:"#ffffff",candela:40,hz:1,flashS:.06,leds:[{at:[0,-.1,.1],radiusM:.008}]}}}];static byId(t){return O.ALL.find(a=>a.id===t)}static materialOf(t,a,e){return e>1?`light-${t}-${a+1}`:`light-${t}`}static colourKeyOf(t){return t.replace(/-([a-z])/g,(a,e)=>e.toUpperCase())+"Color"}static ring(t,a,e,n){return Array.from({length:t},(s,M)=>{const r=M/t*2*Math.PI;return{at:[Math.round(a*Math.sin(r)*1e4)/1e4,e,Math.round(-a*Math.cos(r)*1e4)/1e4],radiusM:n}})}}class i{static SAMPLE_MS=100;static MAX_KEYFRAMES=6e4;static computed=new Map;static bodiesOf(t){const a=JSON.stringify(t);let e=i.computed.get(a);return e||(e=i.compute(t),i.computed.set(a,e),i.computed.size>16&&i.computed.delete(i.computed.keys().next().value)),e}static airframeOf(t){return O.byId(t.airframe)??O.ALL[0]}static lightsOf(t){const a=i.airframeOf(t),e={};for(const[n,s]of Object.entries(a.lights)){const M=t.lights?.[n];if(M===!1)continue;const r={...s,...M??{}};r.off||(e[n]=r)}return e}static compute(t){const a=i.pathOf(t);if(a.length===0)return[];const e=i.airframeOf(t),n=new j(a,e.hovers),s=Math.max(1,Math.floor(t.count??1)),M=i.randomFrom(t.seed??1),r=a[0].t,c=Math.max(a[a.length-1].t,r),d=i.sampleMs(s,c-r),u=i.offsetsOf(t.formation??{kind:s>1?"cluster":"single"},s,M),f=i.lightsOf(t),y={bodyColor:t.bodyColor??e.bodyColor};for(const[m,o]of Object.entries(f))y[O.colourKeyOf(m)]=o.color;const S=t.formation?.kind==="line";return u.map((m,o)=>{const h=i.swayFrom(M,e.holdM),p=Object.fromEntries(Object.entries(f).map(([l,b])=>[l,b.phase??(s>1?M():0)])),g=l=>{const b=n.at(l),[z,I,N]=h((l-r)/1e3);let k=m.eastM,C=m.northM;if(S){const D=n.velocityAt(l),R=Math.hypot(D.east,D.north)>.3?Math.atan2(D.east,D.north):n.headingAtRest(l);k=Math.cos(R)*m.rightM,C=-Math.sin(R)*m.rightM}return{eastM:b.eastM+k+z,northM:b.northM+C+I,upM:b.upM+m.upM+N}},w=[];for(let l=r;l<=c+1e-6;l+=d)w.push(l);w[w.length-1]<c&&w.push(c);const x=i.attitudes(w.map(l=>({t:l,...g(l),headingDeg:0,pitchDeg:0,rollDeg:0})),e,t),P=i.switchesOf(f,p,r,c),E=[...new Set([...w.map(l=>Math.round(l)),...P])].filter(l=>l>=r&&l<=c).sort((l,b)=>l-b);let v=0;const A=E.map((l,b)=>{for(;v<x.length-2&&x[v+1].t<=l;)v++;const z=i.between(x[v],x[Math.min(x.length-1,v+1)],l,g);return{t:l,eastM:i.round(z.eastM),northM:i.round(z.northM),altitudeM:i.round(z.upM-e.sizeM.heightM/2),...b===0?{sizeM:e.sizeM}:{},attitude:{headingDeg:i.round(z.headingDeg,10),pitchDeg:i.round(z.pitchDeg,10),rollDeg:i.round(z.rollDeg,10)},lights:i.luminancesAt(f,p,l,E[b+1]===l+1)}});return{id:s>1?`${t.id}-${o+1}`:t.id,...t.title?{title:t.title}:{},...t.explainsEach?t.explainsEach[o]!==void 0?{explains:[t.explainsEach[o]]}:{}:{...t.explains?{explains:t.explains}:{},...s>1?{ensemble:t.id}:{}},model:{id:e.modelId},modelParameters:y,lamps:i.lampsOf(f,p),...t.silent?{}:{sound:{kind:"unmanned",...t.quieterDb?{quieterDb:t.quieterDb}:{}}},track:A}})}static lampsOf(t,a){return Object.entries(t).flatMap(([e,n])=>n.leds.map((s,M)=>{const r=n.hz>0,c=r?1/n.hz:0;return{id:O.materialOf(e,M,n.leds.length),offsetM:{x:s.at[0],y:s.at[1],z:-s.at[2]},color:n.color,intensity:n.candela/T,pattern:r?{kind:"flash",perMinute:n.hz*60,dutyCycle:Math.min(1,(n.flashS??.5*c)/c),phase:((1-(a[e]??0))%1+1)%1}:{kind:"steady"}}}))}static luminancesAt(t,a,e,n=!1){const s={};for(const[M,r]of Object.entries(t)){const c=i.isOn(r,a[M]??0,n?e-1:e+.5);r.leds.forEach((d,u)=>{s[O.materialOf(M,u,r.leds.length)]=c?i.round(r.candela/(Math.PI*d.radiusM**2),1):0})}return s}static isOn(t,a,e){if(!(t.hz>0))return!0;const n=1e3/t.hz,s=Math.min(n,(t.flashS??.5/t.hz)*1e3);return((e/n-a)%1+1)%1*n<s}static switchesOf(t,a,e,n){const s=[];for(const[M,r]of Object.entries(t)){if(!(r.hz>0))continue;const c=1e3/r.hz,d=Math.min(c,(r.flashS??.5/r.hz)*1e3);if(d>=c)continue;const u=(a[M]??0)*c;for(let f=Math.floor((e-u)/c)*c+u;f<=n;f+=c)for(const y of[f,f+d]){const S=Math.round(y);S>=e&&S<n&&s.push(S,S+1)}}return s}static sampleMs(t,a){const e=t*(a/i.SAMPLE_MS+1);return e<=i.MAX_KEYFRAMES?i.SAMPLE_MS:Math.ceil(i.SAMPLE_MS*e/i.MAX_KEYFRAMES/50)*50}static pathOf(t){return[...t.path].sort((a,e)=>a.t-e.t).map(a=>{if("eastM"in a)return{t:a.t,eastM:a.eastM,northM:a.northM,upM:a.altitudeM};const e=a.azimuthDeg*Math.PI/180,n=a.altitudeDeg*Math.PI/180,s=a.distanceM*Math.cos(n);return{t:a.t,eastM:s*Math.sin(e),northM:s*Math.cos(e),upM:(a.eyeHeightM??1.6)+a.distanceM*Math.sin(n)}})}static offsetsOf(t,a,e){if(t.kind==="single"||a===1)return[{eastM:0,northM:0,upM:0,rightM:0}];if(t.kind==="line"){const c=t.spacingM??5;return Array.from({length:a},(d,u)=>({eastM:0,northM:0,upM:(e()-.5)*c*.2,rightM:(u-(a-1)/2)*c}))}const n=t.spacingM??10,s=Math.cbrt(a*n**3/(4/3*Math.PI*2*2*1)),M=[];let r=0;for(;M.length<a&&r<a*200;){r++;const c=2*e()-1,d=2*e()-1,u=2*e()-1;if(c*c+d*d+u*u>1)continue;const f={eastM:c*2*s,northM:d*2*s,upM:u*s,rightM:0};M.some(y=>(y.eastM-f.eastM)**2+(y.northM-f.northM)**2+(y.upM-f.upM)**2<(n/2)**2)||M.push(f)}for(;M.length<a;)M.push({eastM:(e()-.5)*4*s,northM:(e()-.5)*4*s,upM:0,rightM:0});return M}static swayFrom(t,a){const e=[a.horizontalM,a.horizontalM,a.verticalM].map(n=>[0,1].map(()=>({period:4+t()*10,phase:t()*2*Math.PI,amplitude:n*.5*(.5+.5*t())})));return n=>e.map(s=>s.reduce((M,r)=>M+r.amplitude*Math.sin(2*Math.PI*n/r.period+r.phase),0))}static attitudes(t,a,e){const n=t.length;if(n===0)return t;const s=O.G,M=(e.wind?.fromDeg??0)*Math.PI/180,r=-(e.wind?.speedMS??0)*Math.sin(M),c=-(e.wind?.speedMS??0)*Math.cos(M),d=o=>{const h=t[Math.max(0,o-1)],p=t[Math.min(n-1,o+1)],g=Math.max((p.t-h.t)/1e3,.001);return{e:(p.eastM-h.eastM)/g,n:(p.northM-h.northM)/g,u:(p.upM-h.upM)/g}},u=t.map((o,h)=>d(h)),f=o=>{const h=u[Math.max(0,o-1)],p=u[Math.min(n-1,o+1)],g=Math.max((t[Math.min(n-1,o+1)].t-t[Math.max(0,o-1)].t)/1e3,.001);return{e:(p.e-h.e)/g,n:(p.n-h.n)/g,u:(p.u-h.u)/g}};if(!a.hovers){for(let o=0;o<n;o++){const h=u[o],p=h.e-r,g=h.n-c,w=Math.hypot(h.e,h.n);t[o].headingDeg=Math.hypot(p,g)>.5?(Math.atan2(p,g)*180/Math.PI+360)%360:o>0?t[o-1].headingDeg:0,t[o].pitchDeg=Math.atan2(h.u,Math.max(w,1))*180/Math.PI+2;const x=f(o),P=w>.5?(x.e*h.n-x.n*h.e)/w:0;t[o].rollDeg=Math.max(-45,Math.min(45,Math.atan(P/s)*180/Math.PI))}return t}const y=s*Math.tan(a.maxTiltDeg*Math.PI/180)/a.maxSpeedMS**2,S=a.yawRateDegS*i.SAMPLE_MS/1e3;let m=e.headingDeg;if(m===void 0){const o=u.find(h=>Math.hypot(h.e,h.n)>1);m=o?(Math.atan2(o.e,o.n)*180/Math.PI+360)%360:0}for(let o=0;o<n;o++){const h=u[o];if(e.headingDeg===void 0&&Math.hypot(h.e,h.n)>1){const z=((Math.atan2(h.e,h.n)*180/Math.PI+360)%360-m+540)%360-180,I=o>0?(t[o].t-t[o-1].t)/i.SAMPLE_MS:1;m=(m+Math.max(-S*I,Math.min(S*I,z))+360)%360}const p=f(o),g=h.e-r,w=h.n-c,x=Math.hypot(g,w),P=p.e+y*x*g,E=p.n+y*x*w,v=Math.max(s+p.u,.2*s),A=m*Math.PI/180,L=P*Math.sin(A)+E*Math.cos(A),l=P*Math.cos(A)-E*Math.sin(A);t[o].headingDeg=m,t[o].pitchDeg=-Math.atan(L/v)*180/Math.PI,t[o].rollDeg=Math.atan(l/v)*180/Math.PI}return t}static between(t,a,e,n){if(e===t.t)return t;if(e===a.t)return a;const s=a.t===t.t?0:Math.min(1,Math.max(0,(e-t.t)/(a.t-t.t))),M=(a.headingDeg-t.headingDeg+540)%360-180;return{t:e,...n(e),headingDeg:(t.headingDeg+M*s+360)%360,pitchDeg:t.pitchDeg+(a.pitchDeg-t.pitchDeg)*s,rollDeg:t.rollDeg+(a.rollDeg-t.rollDeg)*s}}static randomFrom(t){let a=t>>>0;return()=>{a=a+1831565813>>>0;let e=a;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}static round(t,a=100){return Math.round(t*a)/a}}class j{constructor(t,a){this.points=t,this.hovers=a;const e=t;this.speeds=e.map((n,s)=>{const M=e[s-1],r=e[s+1],c=(h,p)=>{const g=Math.max((p.t-h.t)/1e3,.001);return{e:(p.eastM-h.eastM)/g,n:(p.northM-h.northM)/g,u:(p.upM-h.upM)/g}};if(!M||!r)return a||e.length<2?{e:0,n:0,u:0}:M?c(M,n):c(n,r);const d=c(M,n),u=c(n,r),f=Math.hypot(d.e,d.n,d.u),y=Math.hypot(u.e,u.n,u.u);if(a&&(f<.05||y<.05||d.e*u.e+d.n*u.n+d.u*u.u<0))return{e:0,n:0,u:0};const S=n.t-M.t,m=r.t-n.t,o=S/Math.max(S+m,1);return{e:d.e*(1-o)+u.e*o,n:d.n*(1-o)+u.n*o,u:d.u*(1-o)+u.u*o}})}speeds;at(t){const a=this.points;if(a.length===1)return{...a[0],t};if(t<=a[0].t)return this.outside(t,0);if(t>=a[a.length-1].t)return this.outside(t,a.length-1);let e=0;for(;e<a.length-2&&t>a[e+1].t;)e++;const n=a[e],s=a[e+1],M=Math.max((s.t-n.t)/1e3,.001),r=(t-n.t)/(s.t-n.t),c=r*r,d=c*r,u=2*d-3*c+1,f=d-2*c+r,y=-2*d+3*c,S=d-c,m=this.speeds[e],o=this.speeds[e+1];return{t,eastM:u*n.eastM+f*m.e*M+y*s.eastM+S*o.e*M,northM:u*n.northM+f*m.n*M+y*s.northM+S*o.n*M,upM:u*n.upM+f*m.u*M+y*s.upM+S*o.u*M}}velocityAt(t){const a=this.at(t-50),e=this.at(t+50);return{east:(e.eastM-a.eastM)/.1,north:(e.northM-a.northM)/.1,up:(e.upM-a.upM)/.1}}headingAtRest(t){const a=this.points;for(let e=a.length-1;e>0;e--){if(a[e].t>t&&e>1)continue;const n=a[e].eastM-a[e-1].eastM,s=a[e].northM-a[e-1].northM;if(Math.hypot(n,s)>.1)return Math.atan2(n,s)}for(let e=1;e<a.length;e++){const n=a[e].eastM-a[e-1].eastM,s=a[e].northM-a[e-1].northM;if(Math.hypot(n,s)>.1)return Math.atan2(n,s)}return 0}outside(t,a){const e=this.points[a];if(this.hovers)return{...e,t};const n=this.speeds[a],s=(t-e.t)/1e3;return{t,eastM:e.eastM+n.e*s,northM:e.northM+n.n*s,upM:e.upM+n.u*s}}}const K=Object.freeze(Object.defineProperty({__proto__:null,DroneFlight:i,DronePath:j},Symbol.toStringTag,{value:"Module"}));export{O as D,i as a,j as b,K as c};
@@ -1 +1 @@
1
- import{aS as R,aJ as l,aH as I}from"./rr0-sighting-editor.mjs";class S extends Error{constructor(t){super(t),this.problem=t}}class e{citation=R;static FIRST_MS=Date.UTC(2016,4,11);static DEFAULT_RADIUS_KM=100;static RINGS_KM=[25,50];static SNAPSHOT_LIMIT=60;static SMALLEST_PLAN_RESULTS=20;static MAX_TRACED=8;static CREDITS_PER_SNAPSHOT_FLIGHT=8;static CREDITS_PER_TRACK=40;static CREDITS_FOR_NOTHING=1;static MAX_CREDITS_PER_PAGE=5e3;static WORST_CASE_CREDITS=(e.MAX_TRACED-1)*e.RINGS_KM.length*e.CREDITS_PER_SNAPSHOT_FLIGHT+e.SNAPSHOT_LIMIT*e.CREDITS_PER_SNAPSHOT_FLIGHT+e.MAX_TRACED*e.CREDITS_PER_TRACK;static API="https://fr24api.flightradar24.com/api";static IN_THE_AIR_FT="1-60000";static KM_PER_DEG=111.32;token;fetchImpl;settleMs;requestsPerMinute;snapshots=[];tracks=new Map;descriptions=new Map;requestTimes=[];tokenOfMemory;latestQuestion=0;creditsSpent=0;constructor(t){this.token=t.token,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.settleMs=t.settleMs??1500,this.requestsPerMinute=t.requestsPerMinute??10}mayCover(t){return t>=e.FIRST_MS&&t<=Date.now()}async between(t,n,i,o=e.DEFAULT_RADIUS_KM){const u=this.token();if(!u)return{status:"failed",problem:"credential"};u!==this.tokenOfMemory&&this.forgetAnswers(u);try{const c=await this.snapshotFor(u,t,n,i,o);if(!c)return{status:"failed"};const s=c.flights.slice(0,e.MAX_TRACED),h=await Promise.all(s.map(a=>this.trackOf(u,a))),f=[];return s.forEach((a,r)=>{const p=h[r].filter(T=>T.t>=n&&T.t<=i&&l.groundDistanceKm(t,T)<=o);p.length>0&&f.push({...e.addressOf(a),points:p})}),{status:"found",tracks:f,creditsSpent:this.creditsSpent,partial:{traced:s.length,seen:c.flights.length,moreSeen:c.flights.length>=e.SMALLEST_PLAN_RESULTS,withinKm:c.withinKm}}}catch(c){return{status:"failed",problem:c instanceof S?c.problem:"network",creditsSpent:this.creditsSpent}}}async describe(t){return this.descriptions.get(I.keyOf(t))}static addressOf(t){const n=t.hex?Number.parseInt(t.hex,16):Number.NaN;return Number.isFinite(n)?{icao:n,nonIcao:!1}:{icao:Number.parseInt(t.fr24_id,16),nonIcao:!0}}static boundsAround(t,n){const i=n/e.KM_PER_DEG,o=Math.min(90,t.lat+i),u=Math.max(-90,t.lat-i),c=Math.cos(Math.max(Math.abs(o),Math.abs(u))*Math.PI/180),s=c<1e-6?180:n/(e.KM_PER_DEG*c),h=Math.max(-180,t.lng-s),f=Math.min(180,t.lng+s);return[o,u,h,f].map(a=>a.toFixed(3)).join(",")}forgetAnswers(t){this.tokenOfMemory=t,this.snapshots.length=0,this.tracks.clear(),this.descriptions.clear()}async snapshotFor(t,n,i,o,u){const c=`${n.lat.toFixed(3)},${n.lng.toFixed(3)},${u}`;for(const f of this.snapshots){const a=await f.catch(()=>{});if(a&&a.place===c&&a.t>=i&&a.t<=o)return a}const s=++this.latestQuestion;if(this.settleMs>0&&await new Promise(f=>setTimeout(f,this.settleMs)),s!==this.latestQuestion)return;if(this.creditsSpent+e.WORST_CASE_CREDITS>e.MAX_CREDITS_PER_PAGE)throw new S("budget");const h=this.askSnapshot(t,n,Math.round((i+o)/2),u,c);return this.snapshots.push(h),h.catch(()=>this.snapshots.splice(this.snapshots.indexOf(h),1)),h}async askSnapshot(t,n,i,o,u){const c=[...e.RINGS_KM.filter(a=>a<o),o];let s=[],h=o;for(const a of c)if(h=a,s=await this.flightsWithin(t,n,i,a),s.length>=e.MAX_TRACED)break;const f=a=>l.groundDistanceKm(n,{lat:a.lat,lng:a.lon});return{t:i,place:u,withinKm:h,flights:[...s].sort((a,r)=>f(a)-f(r))}}async flightsWithin(t,n,i,o){const u=new URLSearchParams({timestamp:String(Math.floor(i/1e3)),bounds:e.boundsAround(n,o),altitude_ranges:e.IN_THE_AIR_FT,limit:String(e.SNAPSHOT_LIMIT)}),s=(await this.get(t,`/historic/flight-positions/full?${u}`)).data??[];this.creditsSpent+=s.length>0?s.length*e.CREDITS_PER_SNAPSHOT_FLIGHT:e.CREDITS_FOR_NOTHING;for(const h of s){const f={type:h.type||void 0,registration:h.reg||void 0};(f.type||f.registration)&&this.descriptions.set(I.keyOf(e.addressOf(h)),f)}return s}trackOf(t,n){let i=this.tracks.get(n.fr24_id);return i||(i=this.get(t,`/flight-tracks?flight_id=${encodeURIComponent(n.fr24_id)}`).then(o=>{const c=(Array.isArray(o)?o:o.data??[]).flatMap(s=>s.tracks??[]);return this.creditsSpent+=c.length>0?e.CREDITS_PER_TRACK:e.CREDITS_FOR_NOTHING,c.filter(s=>s.source?.toUpperCase()!=="ESTIMATED"&&s.alt>0).map(s=>({t:Date.parse(s.timestamp),lat:s.lat,lng:s.lon,altitudeFt:s.alt,groundSpeedKt:s.gspeed,trackDeg:s.track})).sort((s,h)=>s.t-h.t)}),i.catch(()=>this.tracks.delete(n.fr24_id)),this.tracks.set(n.fr24_id,i)),i}async get(t,n){await this.paced();const i=await this.fetchImpl(`${e.API}${n}`,{headers:{Accept:"application/json","Accept-Version":"v1",Authorization:`Bearer ${t}`}});if(!i.ok)throw new S(e.problemOf(i.status));return await i.json()}static problemOf(t){switch(t){case 401:return"credential";case 402:return"credits";case 429:return"rate";case 400:case 403:case 404:return"refused";default:return"network"}}async paced(){for(;;){const t=Date.now();for(;this.requestTimes.length>0&&t-this.requestTimes[0]>=6e4;)this.requestTimes.shift();if(this.requestTimes.length<this.requestsPerMinute){this.requestTimes.push(t);return}await new Promise(n=>setTimeout(n,6e4-(t-this.requestTimes[0])+50))}}}export{e as Flightradar24Provider};
1
+ import{aT as R,aK as l,aI as I}from"./rr0-sighting-editor.mjs";class p extends Error{constructor(t){super(t),this.problem=t}}class e{citation=R;static FIRST_MS=Date.UTC(2016,4,11);static DEFAULT_RADIUS_KM=100;static RINGS_KM=[25,50];static SNAPSHOT_LIMIT=60;static SMALLEST_PLAN_RESULTS=20;static MAX_TRACED=8;static CREDITS_PER_SNAPSHOT_FLIGHT=8;static CREDITS_PER_TRACK=40;static CREDITS_FOR_NOTHING=1;static MAX_CREDITS_PER_PAGE=5e3;static WORST_CASE_CREDITS=(e.MAX_TRACED-1)*e.RINGS_KM.length*e.CREDITS_PER_SNAPSHOT_FLIGHT+e.SNAPSHOT_LIMIT*e.CREDITS_PER_SNAPSHOT_FLIGHT+e.MAX_TRACED*e.CREDITS_PER_TRACK;static API="https://fr24api.flightradar24.com/api";static IN_THE_AIR_FT="1-60000";static KM_PER_DEG=111.32;token;fetchImpl;settleMs;requestsPerMinute;snapshots=[];tracks=new Map;descriptions=new Map;requestTimes=[];tokenOfMemory;latestQuestion=0;creditsSpent=0;constructor(t){this.token=t.token,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.settleMs=t.settleMs??1500,this.requestsPerMinute=t.requestsPerMinute??10}mayCover(t){return t>=e.FIRST_MS&&t<=Date.now()}async between(t,n,i,o=e.DEFAULT_RADIUS_KM){const u=this.token();if(!u)return{status:"failed",problem:"credential"};u!==this.tokenOfMemory&&this.forgetAnswers(u);try{const c=await this.snapshotFor(u,t,n,i,o);if(!c)return{status:"failed"};const s=c.flights.slice(0,e.MAX_TRACED),h=await Promise.all(s.map(a=>this.trackOf(u,a))),f=[];return s.forEach((a,r)=>{const S=h[r].filter(T=>T.t>=n&&T.t<=i&&l.groundDistanceKm(t,T)<=o);S.length>0&&f.push({...e.addressOf(a),points:S})}),{status:"found",tracks:f,creditsSpent:this.creditsSpent,partial:{traced:s.length,seen:c.flights.length,moreSeen:c.flights.length>=e.SMALLEST_PLAN_RESULTS,withinKm:c.withinKm}}}catch(c){return{status:"failed",problem:c instanceof p?c.problem:"network",creditsSpent:this.creditsSpent}}}async describe(t){return this.descriptions.get(I.keyOf(t))}static addressOf(t){const n=t.hex?Number.parseInt(t.hex,16):Number.NaN;return Number.isFinite(n)?{icao:n,nonIcao:!1}:{icao:Number.parseInt(t.fr24_id,16),nonIcao:!0}}static boundsAround(t,n){const i=n/e.KM_PER_DEG,o=Math.min(90,t.lat+i),u=Math.max(-90,t.lat-i),c=Math.cos(Math.max(Math.abs(o),Math.abs(u))*Math.PI/180),s=c<1e-6?180:n/(e.KM_PER_DEG*c),h=Math.max(-180,t.lng-s),f=Math.min(180,t.lng+s);return[o,u,h,f].map(a=>a.toFixed(3)).join(",")}forgetAnswers(t){this.tokenOfMemory=t,this.snapshots.length=0,this.tracks.clear(),this.descriptions.clear()}async snapshotFor(t,n,i,o,u){const c=`${n.lat.toFixed(3)},${n.lng.toFixed(3)},${u}`;for(const f of this.snapshots){const a=await f.catch(()=>{});if(a&&a.place===c&&a.t>=i&&a.t<=o)return a}const s=++this.latestQuestion;if(this.settleMs>0&&await new Promise(f=>setTimeout(f,this.settleMs)),s!==this.latestQuestion)return;if(this.creditsSpent+e.WORST_CASE_CREDITS>e.MAX_CREDITS_PER_PAGE)throw new p("budget");const h=this.askSnapshot(t,n,Math.round((i+o)/2),u,c);return this.snapshots.push(h),h.catch(()=>this.snapshots.splice(this.snapshots.indexOf(h),1)),h}async askSnapshot(t,n,i,o,u){const c=[...e.RINGS_KM.filter(a=>a<o),o];let s=[],h=o;for(const a of c)if(h=a,s=await this.flightsWithin(t,n,i,a),s.length>=e.MAX_TRACED)break;const f=a=>l.groundDistanceKm(n,{lat:a.lat,lng:a.lon});return{t:i,place:u,withinKm:h,flights:[...s].sort((a,r)=>f(a)-f(r))}}async flightsWithin(t,n,i,o){const u=new URLSearchParams({timestamp:String(Math.floor(i/1e3)),bounds:e.boundsAround(n,o),altitude_ranges:e.IN_THE_AIR_FT,limit:String(e.SNAPSHOT_LIMIT)}),s=(await this.get(t,`/historic/flight-positions/full?${u}`)).data??[];this.creditsSpent+=s.length>0?s.length*e.CREDITS_PER_SNAPSHOT_FLIGHT:e.CREDITS_FOR_NOTHING;for(const h of s){const f={type:h.type||void 0,registration:h.reg||void 0};(f.type||f.registration)&&this.descriptions.set(I.keyOf(e.addressOf(h)),f)}return s}trackOf(t,n){let i=this.tracks.get(n.fr24_id);return i||(i=this.get(t,`/flight-tracks?flight_id=${encodeURIComponent(n.fr24_id)}`).then(o=>{const c=(Array.isArray(o)?o:o.data??[]).flatMap(s=>s.tracks??[]);return this.creditsSpent+=c.length>0?e.CREDITS_PER_TRACK:e.CREDITS_FOR_NOTHING,c.filter(s=>s.source?.toUpperCase()!=="ESTIMATED"&&s.alt>0).map(s=>({t:Date.parse(s.timestamp),lat:s.lat,lng:s.lon,altitudeFt:s.alt,groundSpeedKt:s.gspeed,trackDeg:s.track})).sort((s,h)=>s.t-h.t)}),i.catch(()=>this.tracks.delete(n.fr24_id)),this.tracks.set(n.fr24_id,i)),i}async get(t,n){await this.paced();const i=await this.fetchImpl(`${e.API}${n}`,{headers:{Accept:"application/json","Accept-Version":"v1",Authorization:`Bearer ${t}`}});if(!i.ok)throw new p(e.problemOf(i.status));return await i.json()}static problemOf(t){switch(t){case 401:return"credential";case 402:return"credits";case 429:return"rate";case 400:case 403:case 404:return"refused";default:return"network"}}async paced(){for(;;){const t=Date.now();for(;this.requestTimes.length>0&&t-this.requestTimes[0]>=6e4;)this.requestTimes.shift();if(this.requestTimes.length<this.requestsPerMinute){this.requestTimes.push(t);return}await new Promise(n=>setTimeout(n,6e4-(t-this.requestTimes[0])+50))}}}export{e as Flightradar24Provider};
@@ -1 +1 @@
1
- import{cf as Le,cg as Q,ch as he,ci as Me,cj as v,ck as de,bE as w,bH as pe,br as F,cl as b,ca as U,c1 as Se,cm as ye,b2 as we,G as K,cn as be,V as C,Q as me,co as Ne,D as ge,cp as Ie,cq as Oe,bb as V,cr as Ce,cs as Te,ct as Fe,cu as Pe,cv as He,bK as J,c4 as Re,cw as Z,cx as ke,cy as De,bZ as Ge,cz as X,cA as ve,aZ as Ee,bd as Ue,bc as G,cB as Ke,ba as Be,cC as je,aX as Ve,cD as Xe,cE as ze,cF as qe,bp as We,aU as z,b3 as Ye,bX as Qe,cG as Je,cH as Ze,cI as $e,cJ as en,cK as nn,cL as tn,cM as xe,bQ as sn,cb as ne,cN as te,cO as se,cP as ie,cQ as re,cR as rn,cS as on,a_ as an,a$ as cn}from"./rr0-sighting-editor.mjs";function oe(f,n){if(n===Le)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(n===Q||n===he){let e=f.getIndex();if(e===null){const r=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);f.setIndex(r),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,t=[];if(n===Q)for(let r=1;r<=s;r++)t.push(e.getX(0)),t.push(e.getX(r)),t.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(t.push(e.getX(r)),t.push(e.getX(r+1)),t.push(e.getX(r+2))):(t.push(e.getX(r+2)),t.push(e.getX(r+1)),t.push(e.getX(r)));t.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=f.clone();return i.setIndex(t),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",n),f}class jn extends Me{constructor(n){super(n),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new dn(e)}),this.register(function(e){return new pn(e)}),this.register(function(e){return new Ln(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new gn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new hn(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new mn(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new ln(e)}),this.register(function(e){return new ae(e,g.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new ae(e,g.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new yn(e)})}load(n,e,s,t){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=v.extractUrlBase(n);r=v.resolveURL(c,this.path)}else r=v.extractUrlBase(n);this.manager.itemStart(n);const a=function(c){t?t(c):console.error(c),i.manager.itemError(n),i.manager.itemEnd(n)},o=new de(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(n,function(c){try{i.parse(c,r,function(u){e(u),i.manager.itemEnd(n)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(n){return this.dracoLoader=n,this}setKTX2Loader(n){return this.ktx2Loader=n,this}setMeshoptDecoder(n){return this.meshoptDecoder=n,this}register(n){return this.pluginCallbacks.indexOf(n)===-1&&this.pluginCallbacks.push(n),this}unregister(n){return this.pluginCallbacks.indexOf(n)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n),1),this}parse(n,e,s,t){let i;const r={},a={},o=new TextDecoder;if(typeof n=="string")i=JSON.parse(n);else if(n instanceof ArrayBuffer)if(o.decode(new Uint8Array(n,0,4))===Ae){try{r[g.KHR_BINARY_GLTF]=new wn(n)}catch(l){t&&t(l);return}i=JSON.parse(r[g.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(n));else i=n;if(i.asset===void 0||i.asset.version[0]<2){t&&t(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Un(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,r[l.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const l=i.extensionsUsed[u],h=i.extensionsRequired||[];switch(l){case g.KHR_MATERIALS_UNLIT:r[l]=new fn;break;case g.KHR_DRACO_MESH_COMPRESSION:r[l]=new bn(i,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:r[l]=new Nn;break;case g.KHR_MESH_QUANTIZATION:r[l]=new In;break;default:h.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,t)}parseAsync(n,e){const s=this;return new Promise(function(t,i){s.parse(n,e,t,i)})}}function un(){let f={};return{get:function(n){return f[n]},add:function(n,e){f[n]=e},remove:function(n){delete f[n]},removeAll:function(){f={}}}}function _(f,n,e){const s=f.json.materials[n];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const g={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ln{constructor(n){this.parser=n,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const n=this.parser,e=this.parser.json.nodes||[];for(let s=0,t=e.length;s<t;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&n._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(n){const e=this.parser,s="light:"+n;let t=e.cache.get(s);if(t)return t;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[n];let c;const u=new F(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],b);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new we(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ye(u),c.distance=l;break;case"spot":c=new Se(u),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),y(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+n),t=Promise.resolve(c),e.cache.add(s,t),t}getDependency(n,e){if(n==="light")return this._loadLight(e)}createNodeAttachment(n){const e=this,s=this.parser,i=s.json.nodes[n],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class fn{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return G}extendParams(n,e,s){const t=[];n.color=new F(1,1,1),n.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;n.color.setRGB(r[0],r[1],r[2],b),n.opacity=r[3]}i.baseColorTexture!==void 0&&t.push(s.assignTexture(n,"map",i.baseColorTexture,U))}return Promise.all(t)}}class hn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class dn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(t.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new pe(i,i)}return Promise.all(t)}}class pn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(t)}}class gn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(e.sheenColor=new F(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;e.sheenColor.setRGB(i[0],i[1],i[2],b)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,U)),s.sheenRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(t)}}class Tn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&t.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(t)}}class Rn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return e.attenuationColor=new F().setRGB(i[0],i[1],i[2],b),Promise.all(t)}}class En{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IOR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class xn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return e.specularColor=new F().setRGB(i[0],i[1],i[2],b),s.specularColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,U)),Promise.all(t)}}class An{constructor(n){this.parser=n,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&t.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(t)}}class _n{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&t.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(t)}}class Ln{constructor(n){this.parser=n,this.name=g.KHR_TEXTURE_BASISU}loadTexture(n){const e=this.parser,s=e.json,t=s.textures[n];if(!t.extensions||!t.extensions[this.name])return null;const i=t.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(n,i.source,r)}}class Mn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_WEBP}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class Sn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_AVIF}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class ae{constructor(n,e){this.name=e,this.parser=n}loadBufferView(n){const e=this.parser.json,s=e.bufferViews[n];if(s.extensions&&s.extensions[this.name]){const t=s.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=t.byteOffset||0,c=t.byteLength||0,u=t.count,l=t.byteStride,h=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,l,h,t.mode,t.filter).then(function(d){return d.buffer}):r.ready.then(function(){const d=new ArrayBuffer(u*l);return r.decodeGltfBuffer(new Uint8Array(d),u,l,h,t.mode,t.filter),d})})}else return null}}class yn{constructor(n){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,s=e.nodes[n];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const t=e.meshes[s.mesh];for(const c of t.primitives)if(c.mode!==M.TRIANGLES&&c.mode!==M.TRIANGLE_STRIP&&c.mode!==M.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(n)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],h=c[0].count,d=[];for(const p of l){const R=new K,m=new C,T=new me,A=new C(1,1,1),x=new be(p.geometry,p.material,h);for(let E=0;E<h;E++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,E),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,E),o.SCALE&&A.fromBufferAttribute(o.SCALE,E),x.setMatrixAt(E,R.compose(m,T,A));for(const E in o)if(E==="_COLOR_0"){const L=o[E];x.instanceColor=new Ne(L.array,L.itemSize,L.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&p.geometry.setAttribute(E,o[E]);ge.prototype.copy.call(x,p),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}}const Ae="glTF",D=12,ce={JSON:1313821514,BIN:5130562};class wn{constructor(n){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(n,0,D),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(n.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ae)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const t=this.header.length-D,i=new DataView(n,D);let r=0;for(;r<t;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===ce.JSON){const c=new Uint8Array(n,D+r,a);this.content=s.decode(c)}else if(o===ce.BIN){const c=D+r;this.body=n.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class bn{constructor(n,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=n,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(n,e){const s=this.json,t=this.dracoLoader,i=n.extensions[this.name].bufferView,r=n.extensions[this.name].attributes,a={},o={},c={};for(const u in r){const l=$[u]||u.toLowerCase();a[l]=r[u]}for(const u in n.attributes){const l=$[u]||u.toLowerCase();if(r[u]!==void 0){const h=s.accessors[n.attributes[u]],d=H[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",i).then(function(u){return new Promise(function(l,h){t.decodeDracoFile(u,function(d){for(const p in d.attributes){const R=d.attributes[p],m=o[p];m!==void 0&&(R.normalized=m)}l(d)},a,c,b,h)})})}}class Nn{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(n,e){return(e.texCoord===void 0||e.texCoord===n.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(n=n.clone(),e.texCoord!==void 0&&(n.channel=e.texCoord),e.offset!==void 0&&n.offset.fromArray(e.offset),e.rotation!==void 0&&(n.rotation=e.rotation),e.scale!==void 0&&n.repeat.fromArray(e.scale),n.needsUpdate=!0),n}}class In{constructor(){this.name=g.KHR_MESH_QUANTIZATION}}class _e extends on{constructor(n,e,s,t){super(n,e,s,t)}copySampleValue_(n){const e=this.resultBuffer,s=this.sampleValues,t=this.valueSize,i=n*t*3+t;for(let r=0;r!==t;r++)e[r]=s[i+r];return e}interpolate_(n,e,s,t){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=t-e,l=(s-e)/u,h=l*l,d=h*l,p=n*c,R=p-c,m=-2*d+3*h,T=d-h,A=1-m,x=T-h+l;for(let E=0;E!==a;E++){const L=r[R+E+a],N=r[R+E+o]*u,S=r[p+E+a],k=r[p+E]*u;i[E]=A*L+x*N+m*S+T*k}return i}}const On=new me;class Cn extends _e{interpolate_(n,e,s,t){const i=super.interpolate_(n,e,s,t);return On.fromArray(i).normalize().toArray(i),i}}const M={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},H={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ue={9728:Re,9729:J,9984:He,9985:Pe,9986:Fe,9987:Te},le={33071:De,33648:ke,10497:Z},q={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Fn={CUBICSPLINE:void 0,LINEAR:xe,STEP:tn},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Pn(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),f.DefaultMaterial}function O(f,n,e){for(const s in e.extensions)f[s]===void 0&&(n.userData.gltfExtensions=n.userData.gltfExtensions||{},n.userData.gltfExtensions[s]=e.extensions[s])}function y(f,n){n.extras!==void 0&&(typeof n.extras=="object"?Object.assign(f.userData,n.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+n.extras))}function Hn(f,n,e){let s=!1,t=!1,i=!1;for(let c=0,u=n.length;c<u;c++){const l=n[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(t=!0),l.COLOR_0!==void 0&&(i=!0),s&&t&&i)break}if(!s&&!t&&!i)return Promise.resolve(f);const r=[],a=[],o=[];for(let c=0,u=n.length;c<u;c++){const l=n[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;r.push(h)}if(t){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;a.push(h)}if(i){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const u=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=u),t&&(f.morphAttributes.normal=l),i&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function kn(f,n){if(f.updateMorphTargets(),n.weights!==void 0)for(let e=0,s=n.weights.length;e<s;e++)f.morphTargetInfluences[e]=n.weights[e];if(n.extras&&Array.isArray(n.extras.targetNames)){const e=n.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,t=e.length;s<t;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Dn(f){let n;const e=f.extensions&&f.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(e?n="draco:"+e.bufferView+":"+e.indices+":"+Y(e.attributes):n=f.indices+":"+Y(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,t=f.targets.length;s<t;s++)n+=":"+Y(f.targets[s]);return n}function Y(f){let n="";const e=Object.keys(f).sort();for(let s=0,t=e.length;s<t;s++)n+=e[s]+":"+f[e[s]]+";";return n}function ee(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Gn(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const vn=new K;class Un{constructor(n={},e={}){this.json=n,this.extensions={},this.plugins={},this.options=e,this.cache=new un,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,t=-1,i=!1,r=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);t=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&t<17||i&&r<98?this.textureLoader=new Ie(this.options.manager):this.textureLoader=new Oe(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new de(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(n){this.extensions=n}setPlugins(n){this.plugins=n}parse(n,e){const s=this,t=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][t.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:t.asset,parser:s,userData:{}};return O(i,a,t),y(a,t),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();n(a)})}).catch(e)}_markDefs(){const n=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let t=0,i=e.length;t<i;t++){const r=e[t].joints;for(let a=0,o=r.length;a<o;a++)n[r[a]].isBone=!0}for(let t=0,i=n.length;t<i;t++){const r=n[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(n,e){e!==void 0&&(n.refs[e]===void 0&&(n.refs[e]=n.uses[e]=0),n.refs[e]++)}_getNodeRef(n,e,s){if(n.refs[e]<=1)return s;const t=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,u]of r.children.entries())i(u,a.children[c])};return i(s,t),t.name+="_instance_"+n.uses[e]++,t}_invokeOne(n){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const t=n(e[s]);if(t)return t}return null}_invokeAll(n){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let t=0;t<e.length;t++){const i=n(e[t]);i&&s.push(i)}return s}getDependency(n,e){const s=n+":"+e;let t=this.cache.get(s);if(!t){switch(n){case"scene":t=this.loadScene(e);break;case"node":t=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":t=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":t=this.loadAccessor(e);break;case"bufferView":t=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":t=this.loadBuffer(e);break;case"material":t=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":t=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":t=this.loadSkin(e);break;case"animation":t=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":t=this.loadCamera(e);break;default:if(t=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(n,e)}),!t)throw new Error("Unknown type: "+n);break}this.cache.add(s,t)}return t}getDependencies(n){let e=this.cache.get(n);if(!e){const s=this,t=this.json[n+(n==="mesh"?"es":"s")]||[];e=Promise.all(t.map(function(i,r){return s.getDependency(n,r)})),this.cache.add(n,e)}return e}loadBuffer(n){const e=this.json.buffers[n],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&n===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);const t=this.options;return new Promise(function(i,r){s.load(v.resolveURL(e.uri,t.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(n){const e=this.json.bufferViews[n];return this.getDependency("buffer",e.buffer).then(function(s){const t=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+t)})}loadAccessor(n){const e=this,s=this.json,t=this.json.accessors[n];if(t.bufferView===void 0&&t.sparse===void 0){const r=q[t.type],a=H[t.componentType],o=t.normalized===!0,c=new a(t.count*r);return Promise.resolve(new V(c,r,o))}const i=[];return t.bufferView!==void 0?i.push(this.getDependency("bufferView",t.bufferView)):i.push(null),t.sparse!==void 0&&(i.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=q[t.type],c=H[t.componentType],u=c.BYTES_PER_ELEMENT,l=u*o,h=t.byteOffset||0,d=t.bufferView!==void 0?s.bufferViews[t.bufferView].byteStride:void 0,p=t.normalized===!0;let R,m;if(d&&d!==l){const T=Math.floor(h/d),A="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+T+":"+t.count;let x=e.cache.get(A);x||(R=new c(a,T*d,t.count*d/u),x=new Ce(R,d/u),e.cache.add(A,x)),m=new sn(x,o,h%d/u,p)}else a===null?R=new c(t.count*o):R=new c(a,h,t.count*o),m=new V(R,o,p);if(t.sparse!==void 0){const T=q.SCALAR,A=H[t.sparse.indices.componentType],x=t.sparse.indices.byteOffset||0,E=t.sparse.values.byteOffset||0,L=new A(r[1],x,t.sparse.count*T),N=new c(r[2],E,t.sparse.count*o);a!==null&&(m=new V(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,k=L.length;S<k;S++){const P=L[S];if(m.setX(P,N[S*o]),o>=2&&m.setY(P,N[S*o+1]),o>=3&&m.setZ(P,N[S*o+2]),o>=4&&m.setW(P,N[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(n){const e=this.json,s=this.options,i=e.textures[n].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(n,i,a)}loadTextureImage(n,e,s){const t=this,i=this.json,r=i.textures[n],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(i.samplers||{})[r.sampler]||{};return u.magFilter=ue[h.magFilter]||J,u.minFilter=ue[h.minFilter]||Te,u.wrapS=le[h.wrapS]||Z,u.wrapT=le[h.wrapT]||Z,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Re&&u.minFilter!==J,t.associations.set(u,{textures:n}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(n,e){const s=this,t=this.json,i=this.options;if(this.sourceCache[n]!==void 0)return this.sourceCache[n].then(l=>l.clone());const r=t.images[n],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:r.mimeType});return o=a.createObjectURL(h),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+n+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let p=h;e.isImageBitmapLoader===!0&&(p=function(R){const m=new ne(R);m.needsUpdate=!0,h(m)}),e.load(v.resolveURL(l,i.path),p,void 0,d)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),y(l,r),l.userData.mimeType=r.mimeType||Gn(r.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[n]=u,u}assignTexture(n,e,s,t){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[g.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return t!==void 0&&(r.colorSpace=t),n[e]=r,r})}assignFinalMaterial(n){const e=n.geometry;let s=n.material;const t=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(n.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new Ge,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(n.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new ve,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(t||i||r){let a="ClonedMaterial:"+s.uuid+":";t&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),t&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}n.material=s}getMaterialType(){return Ee}loadMaterial(n){const e=this,s=this.json,t=this.extensions,i=s.materials[n];let r;const a={},o=i.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){const l=t[g.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),c.push(l.extendParams(a,i,e))}else{const l=i.pbrMetallicRoughness||{};if(a.color=new F(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],b),a.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,U)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),r=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(n)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(n,a)})))}i.doubleSided===!0&&(a.side=Ue);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new pe(1,1),i.normalTexture.scale!==void 0)){const l=i.normalTexture.scale;a.normalScale.set(l,l)}if(i.occlusionTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==G){const l=i.emissiveFactor;a.emissive=new F().setRGB(l[0],l[1],l[2],b)}return i.emissiveTexture!==void 0&&r!==G&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,U)),Promise.all(c).then(function(){const l=new r(a);return i.name&&(l.name=i.name),y(l,i),e.associations.set(l,{materials:n}),i.extensions&&O(t,l,i),l})}createUniqueName(n){const e=Ke.sanitizeNodeName(n||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(n){const e=this,s=this.extensions,t=this.primitiveCache;function i(a){return s[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return fe(o,a,e)})}const r=[];for(let a=0,o=n.length;a<o;a++){const c=n[a],u=Dn(c),l=t[u];if(l)r.push(l.promise);else{let h;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?h=i(c):h=fe(new Be,c,e),t[u]={primitive:c,promise:h},r.push(h)}}return Promise.all(r)}loadMesh(n){const e=this,s=this.json,t=this.extensions,i=s.meshes[n],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const u=r[o].material===void 0?Pn(this.cache):this.getDependency("material",r[o].material);a.push(u)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),u=o[o.length-1],l=[];for(let d=0,p=u.length;d<p;d++){const R=u[d],m=r[d];let T;const A=c[d];if(m.mode===M.TRIANGLES||m.mode===M.TRIANGLE_STRIP||m.mode===M.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new je(R,A):new Ve(R,A),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===M.TRIANGLE_STRIP?T.geometry=oe(T.geometry,he):m.mode===M.TRIANGLE_FAN&&(T.geometry=oe(T.geometry,Q));else if(m.mode===M.LINES)T=new Xe(R,A);else if(m.mode===M.LINE_STRIP)T=new ze(R,A);else if(m.mode===M.LINE_LOOP)T=new qe(R,A);else if(m.mode===M.POINTS)T=new We(R,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&kn(T,i),T.name=e.createUniqueName(i.name||"mesh_"+n),y(T,i),m.extensions&&O(t,T,m),e.assignFinalMaterial(T),l.push(T)}for(let d=0,p=l.length;d<p;d++)e.associations.set(l[d],{meshes:n,primitives:d});if(l.length===1)return i.extensions&&O(t,l[0],i),l[0];const h=new z;i.extensions&&O(t,h,i),e.associations.set(h,{meshes:n});for(let d=0,p=l.length;d<p;d++)h.add(l[d]);return h})}loadCamera(n){let e;const s=this.json.cameras[n],t=s[s.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new Ye(Qe.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):s.type==="orthographic"&&(e=new Je(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),y(e,s),Promise.resolve(e)}loadSkin(n){const e=this.json.skins[n],s=[];for(let t=0,i=e.joints.length;t<i;t++)s.push(this._loadNodeShallow(e.joints[t]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const i=t.pop(),r=t,a=[],o=[];for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l){a.push(l);const h=new K;i!==null&&h.fromArray(i.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new Ze(a,o)})}loadAnimation(n){const e=this.json,s=this,t=e.animations[n],i=t.name?t.name:"animation_"+n,r=[],a=[],o=[],c=[],u=[];for(let l=0,h=t.channels.length;l<h;l++){const d=t.channels[l],p=t.samplers[d.sampler],R=d.target,m=R.node,T=t.parameters!==void 0?t.parameters[p.input]:p.input,A=t.parameters!==void 0?t.parameters[p.output]:p.output;R.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",A)),c.push(p),u.push(R))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(l){const h=l[0],d=l[1],p=l[2],R=l[3],m=l[4],T=[];for(let x=0,E=h.length;x<E;x++){const L=h[x],N=d[x],S=p[x],k=R[x],P=m[x];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const B=s._createAnimationTracks(L,N,S,k,P);if(B)for(let j=0;j<B.length;j++)T.push(B[j])}const A=new $e(i,void 0,T);return y(A,t),A})}createNodeMesh(n){const e=this.json,s=this,t=e.nodes[n];return t.mesh===void 0?null:s.getDependency("mesh",t.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,t.mesh,i);return t.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=t.weights.length;o<c;o++)a.morphTargetInfluences[o]=t.weights[o]}),r})}loadNode(n){const e=this.json,s=this,t=e.nodes[n],i=s._loadNodeShallow(n),r=[],a=t.children||[];for(let c=0,u=a.length;c<u;c++)r.push(s.getDependency("node",a[c]));const o=t.skin===void 0?Promise.resolve(null):s.getDependency("skin",t.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const u=c[0],l=c[1],h=c[2];h!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(h,vn)});for(let d=0,p=l.length;d<p;d++)u.add(l[d]);if(u.userData.pivot!==void 0&&l.length>0){const d=u.userData.pivot,p=l[0];u.pivot=new C().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(n){const e=this.json,s=this.extensions,t=this;if(this.nodeCache[n]!==void 0)return this.nodeCache[n];const i=e.nodes[n],r=i.name?t.createUniqueName(i.name):"",a=[],o=t._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(n)});return o&&a.push(o),i.camera!==void 0&&a.push(t.getDependency("camera",i.camera).then(function(c){return t._getNodeRef(t.cameraCache,i.camera,c)})),t._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(n)}).forEach(function(c){a.push(c)}),this.nodeCache[n]=Promise.all(a).then(function(c){let u;if(i.isBone===!0?u=new en:c.length>1?u=new z:c.length===1?u=c[0]:u=new ge,u!==c[0])for(let l=0,h=c.length;l<h;l++)u.add(c[l]);if(i.name&&(u.userData.name=i.name,u.name=r),y(u,i),i.extensions&&O(s,u,i),i.matrix!==void 0){const l=new K;l.fromArray(i.matrix),u.applyMatrix4(l)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!t.associations.has(u))t.associations.set(u,{});else if(i.mesh!==void 0&&t.meshCache.refs[i.mesh]>1){const l=t.associations.get(u);t.associations.set(u,{...l})}return t.associations.get(u).nodes=n,u}),this.nodeCache[n]}loadScene(n){const e=this.extensions,s=this.json.scenes[n],t=this,i=new z;s.name&&(i.name=t.createUniqueName(s.name)),y(i,s),s.extensions&&O(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(t.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let u=0,l=o.length;u<l;u++){const h=o[u];h.parent!==null?i.add(nn(h)):i.add(h)}const c=u=>{const l=new Map;for(const[h,d]of t.associations)(h instanceof X||h instanceof ne)&&l.set(h,d);return u.traverse(h=>{const d=t.associations.get(h);d!=null&&l.set(h,d)}),l};return t.associations=c(i),i})}_createAnimationTracks(n,e,s,t,i){const r=[],a=n.name?n.name:n.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}I[i.path]===I.weights?(c(n),n.isGroup&&n.children.forEach(c)):o.push(a);let u;switch(I[i.path]){case I.weights:u=se;break;case I.rotation:u=ie;break;case I.translation:case I.scale:u=te;break;default:switch(s.itemSize){case 1:u=se;break;case 2:case 3:default:u=te;break}break}const l=t.interpolation!==void 0?Fn[t.interpolation]:xe,h=this._getArrayFromAccessor(s);for(let d=0,p=o.length;d<p;d++){const R=new u(o[d]+"."+I[i.path],e.array,h,l);t.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(R),r.push(R)}return r}_getArrayFromAccessor(n){let e=n.array;if(n.normalized){const s=ee(e.constructor),t=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]=e[i]*s;e=t}return e}_createCubicSplineTrackInterpolant(n){n.createInterpolant=function(s){const t=this instanceof ie?Cn:_e;return new t(this.times,this.values,this.getValueSize()/3,s)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Kn(f,n,e){const s=n.attributes,t=new an;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(t.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){const u=ee(H[a.componentType]);t.min.multiplyScalar(u),t.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=n.targets;if(i!==void 0){const a=new C,o=new C;for(let c=0,u=i.length;c<u;c++){const l=i[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,p=h.max;if(d!==void 0&&p!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(p[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(p[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(p[2]))),h.normalized){const R=ee(H[h.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}t.expandByVector(a)}f.boundingBox=t;const r=new cn;t.getCenter(r.center),r.radius=t.min.distanceTo(t.max)/2,f.boundingSphere=r}function fe(f,n,e){const s=n.attributes,t=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){f.setAttribute(a,o)})}for(const r in s){const a=$[r]||r.toLowerCase();a in f.attributes||t.push(i(s[r],a))}if(n.indices!==void 0&&!f.index){const r=e.getDependency("accessor",n.indices).then(function(a){f.setIndex(a)});t.push(r)}return re.workingColorSpace!==b&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${re.workingColorSpace}" not supported.`),y(f,n),Kn(f,n,e),Promise.all(t).then(function(){return n.targets!==void 0?Hn(f,n.targets,e):f})}export{jn as GLTFLoader};
1
+ import{cg as Le,ch as Q,ci as he,cj as Me,ck as v,cl as de,bF as b,bI as pe,bs as F,cm as w,cb as U,c2 as Se,cn as ye,b3 as be,G as K,co as we,V as C,Q as me,cp as Ne,D as ge,cq as Ie,cr as Oe,bc as V,cs as Ce,ct as Te,cu as Fe,cv as Pe,cw as He,bL as J,c5 as Re,cx as Z,cy as ke,cz as De,b_ as Ge,cA as X,cB as ve,a_ as Ee,be as Ue,bd as G,cC as Ke,bb as Be,cD as je,aY as Ve,cE as Xe,cF as ze,cG as qe,bq as We,aV as z,b4 as Ye,bY as Qe,cH as Je,cI as Ze,cJ as $e,cK as en,cL as nn,cM as tn,cN as xe,bR as sn,cc as ne,cO as te,cP as se,cQ as ie,cR as re,cS as rn,cT as on,a$ as an,b0 as cn}from"./rr0-sighting-editor.mjs";function oe(f,n){if(n===Le)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(n===Q||n===he){let e=f.getIndex();if(e===null){const r=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);f.setIndex(r),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,t=[];if(n===Q)for(let r=1;r<=s;r++)t.push(e.getX(0)),t.push(e.getX(r)),t.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(t.push(e.getX(r)),t.push(e.getX(r+1)),t.push(e.getX(r+2))):(t.push(e.getX(r+2)),t.push(e.getX(r+1)),t.push(e.getX(r)));t.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=f.clone();return i.setIndex(t),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",n),f}class jn extends Me{constructor(n){super(n),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new dn(e)}),this.register(function(e){return new pn(e)}),this.register(function(e){return new Ln(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new gn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new hn(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new mn(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new ln(e)}),this.register(function(e){return new ae(e,g.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new ae(e,g.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new yn(e)})}load(n,e,s,t){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=v.extractUrlBase(n);r=v.resolveURL(c,this.path)}else r=v.extractUrlBase(n);this.manager.itemStart(n);const a=function(c){t?t(c):console.error(c),i.manager.itemError(n),i.manager.itemEnd(n)},o=new de(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(n,function(c){try{i.parse(c,r,function(u){e(u),i.manager.itemEnd(n)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(n){return this.dracoLoader=n,this}setKTX2Loader(n){return this.ktx2Loader=n,this}setMeshoptDecoder(n){return this.meshoptDecoder=n,this}register(n){return this.pluginCallbacks.indexOf(n)===-1&&this.pluginCallbacks.push(n),this}unregister(n){return this.pluginCallbacks.indexOf(n)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n),1),this}parse(n,e,s,t){let i;const r={},a={},o=new TextDecoder;if(typeof n=="string")i=JSON.parse(n);else if(n instanceof ArrayBuffer)if(o.decode(new Uint8Array(n,0,4))===_e){try{r[g.KHR_BINARY_GLTF]=new bn(n)}catch(l){t&&t(l);return}i=JSON.parse(r[g.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(n));else i=n;if(i.asset===void 0||i.asset.version[0]<2){t&&t(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Un(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,r[l.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const l=i.extensionsUsed[u],h=i.extensionsRequired||[];switch(l){case g.KHR_MATERIALS_UNLIT:r[l]=new fn;break;case g.KHR_DRACO_MESH_COMPRESSION:r[l]=new wn(i,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:r[l]=new Nn;break;case g.KHR_MESH_QUANTIZATION:r[l]=new In;break;default:h.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,t)}parseAsync(n,e){const s=this;return new Promise(function(t,i){s.parse(n,e,t,i)})}}function un(){let f={};return{get:function(n){return f[n]},add:function(n,e){f[n]=e},remove:function(n){delete f[n]},removeAll:function(){f={}}}}function A(f,n,e){const s=f.json.materials[n];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const g={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ln{constructor(n){this.parser=n,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const n=this.parser,e=this.parser.json.nodes||[];for(let s=0,t=e.length;s<t;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&n._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(n){const e=this.parser,s="light:"+n;let t=e.cache.get(s);if(t)return t;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[n];let c;const u=new F(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],w);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new be(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ye(u),c.distance=l;break;case"spot":c=new Se(u),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),y(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+n),t=Promise.resolve(c),e.cache.add(s,t),t}getDependency(n,e){if(n==="light")return this._loadLight(e)}createNodeAttachment(n){const e=this,s=this.parser,i=s.json.nodes[n],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class fn{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return G}extendParams(n,e,s){const t=[];n.color=new F(1,1,1),n.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;n.color.setRGB(r[0],r[1],r[2],w),n.opacity=r[3]}i.baseColorTexture!==void 0&&t.push(s.assignTexture(n,"map",i.baseColorTexture,U))}return Promise.all(t)}}class hn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class dn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(t.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new pe(i,i)}return Promise.all(t)}}class pn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(t)}}class gn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(e.sheenColor=new F(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;e.sheenColor.setRGB(i[0],i[1],i[2],w)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,U)),s.sheenRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(t)}}class Tn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&t.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(t)}}class Rn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return e.attenuationColor=new F().setRGB(i[0],i[1],i[2],w),Promise.all(t)}}class En{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IOR}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class xn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return e.specularColor=new F().setRGB(i[0],i[1],i[2],w),s.specularColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,U)),Promise.all(t)}}class _n{constructor(n){this.parser=n,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&t.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(t)}}class An{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){return A(this.parser,n,this.name)!==null?b:null}extendMaterialParams(n,e){const s=A(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&t.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(t)}}class Ln{constructor(n){this.parser=n,this.name=g.KHR_TEXTURE_BASISU}loadTexture(n){const e=this.parser,s=e.json,t=s.textures[n];if(!t.extensions||!t.extensions[this.name])return null;const i=t.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(n,i.source,r)}}class Mn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_WEBP}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class Sn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_AVIF}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class ae{constructor(n,e){this.name=e,this.parser=n}loadBufferView(n){const e=this.parser.json,s=e.bufferViews[n];if(s.extensions&&s.extensions[this.name]){const t=s.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=t.byteOffset||0,c=t.byteLength||0,u=t.count,l=t.byteStride,h=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,l,h,t.mode,t.filter).then(function(d){return d.buffer}):r.ready.then(function(){const d=new ArrayBuffer(u*l);return r.decodeGltfBuffer(new Uint8Array(d),u,l,h,t.mode,t.filter),d})})}else return null}}class yn{constructor(n){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,s=e.nodes[n];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const t=e.meshes[s.mesh];for(const c of t.primitives)if(c.mode!==M.TRIANGLES&&c.mode!==M.TRIANGLE_STRIP&&c.mode!==M.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(n)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],h=c[0].count,d=[];for(const p of l){const R=new K,m=new C,T=new me,_=new C(1,1,1),x=new we(p.geometry,p.material,h);for(let E=0;E<h;E++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,E),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,E),o.SCALE&&_.fromBufferAttribute(o.SCALE,E),x.setMatrixAt(E,R.compose(m,T,_));for(const E in o)if(E==="_COLOR_0"){const L=o[E];x.instanceColor=new Ne(L.array,L.itemSize,L.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&p.geometry.setAttribute(E,o[E]);ge.prototype.copy.call(x,p),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}}const _e="glTF",D=12,ce={JSON:1313821514,BIN:5130562};class bn{constructor(n){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(n,0,D),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(n.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==_e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const t=this.header.length-D,i=new DataView(n,D);let r=0;for(;r<t;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===ce.JSON){const c=new Uint8Array(n,D+r,a);this.content=s.decode(c)}else if(o===ce.BIN){const c=D+r;this.body=n.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class wn{constructor(n,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=n,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(n,e){const s=this.json,t=this.dracoLoader,i=n.extensions[this.name].bufferView,r=n.extensions[this.name].attributes,a={},o={},c={};for(const u in r){const l=$[u]||u.toLowerCase();a[l]=r[u]}for(const u in n.attributes){const l=$[u]||u.toLowerCase();if(r[u]!==void 0){const h=s.accessors[n.attributes[u]],d=H[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",i).then(function(u){return new Promise(function(l,h){t.decodeDracoFile(u,function(d){for(const p in d.attributes){const R=d.attributes[p],m=o[p];m!==void 0&&(R.normalized=m)}l(d)},a,c,w,h)})})}}class Nn{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(n,e){return(e.texCoord===void 0||e.texCoord===n.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(n=n.clone(),e.texCoord!==void 0&&(n.channel=e.texCoord),e.offset!==void 0&&n.offset.fromArray(e.offset),e.rotation!==void 0&&(n.rotation=e.rotation),e.scale!==void 0&&n.repeat.fromArray(e.scale),n.needsUpdate=!0),n}}class In{constructor(){this.name=g.KHR_MESH_QUANTIZATION}}class Ae extends on{constructor(n,e,s,t){super(n,e,s,t)}copySampleValue_(n){const e=this.resultBuffer,s=this.sampleValues,t=this.valueSize,i=n*t*3+t;for(let r=0;r!==t;r++)e[r]=s[i+r];return e}interpolate_(n,e,s,t){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=t-e,l=(s-e)/u,h=l*l,d=h*l,p=n*c,R=p-c,m=-2*d+3*h,T=d-h,_=1-m,x=T-h+l;for(let E=0;E!==a;E++){const L=r[R+E+a],N=r[R+E+o]*u,S=r[p+E+a],k=r[p+E]*u;i[E]=_*L+x*N+m*S+T*k}return i}}const On=new me;class Cn extends Ae{interpolate_(n,e,s,t){const i=super.interpolate_(n,e,s,t);return On.fromArray(i).normalize().toArray(i),i}}const M={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},H={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ue={9728:Re,9729:J,9984:He,9985:Pe,9986:Fe,9987:Te},le={33071:De,33648:ke,10497:Z},q={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Fn={CUBICSPLINE:void 0,LINEAR:xe,STEP:tn},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Pn(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),f.DefaultMaterial}function O(f,n,e){for(const s in e.extensions)f[s]===void 0&&(n.userData.gltfExtensions=n.userData.gltfExtensions||{},n.userData.gltfExtensions[s]=e.extensions[s])}function y(f,n){n.extras!==void 0&&(typeof n.extras=="object"?Object.assign(f.userData,n.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+n.extras))}function Hn(f,n,e){let s=!1,t=!1,i=!1;for(let c=0,u=n.length;c<u;c++){const l=n[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(t=!0),l.COLOR_0!==void 0&&(i=!0),s&&t&&i)break}if(!s&&!t&&!i)return Promise.resolve(f);const r=[],a=[],o=[];for(let c=0,u=n.length;c<u;c++){const l=n[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;r.push(h)}if(t){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;a.push(h)}if(i){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const u=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=u),t&&(f.morphAttributes.normal=l),i&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function kn(f,n){if(f.updateMorphTargets(),n.weights!==void 0)for(let e=0,s=n.weights.length;e<s;e++)f.morphTargetInfluences[e]=n.weights[e];if(n.extras&&Array.isArray(n.extras.targetNames)){const e=n.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,t=e.length;s<t;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Dn(f){let n;const e=f.extensions&&f.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(e?n="draco:"+e.bufferView+":"+e.indices+":"+Y(e.attributes):n=f.indices+":"+Y(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,t=f.targets.length;s<t;s++)n+=":"+Y(f.targets[s]);return n}function Y(f){let n="";const e=Object.keys(f).sort();for(let s=0,t=e.length;s<t;s++)n+=e[s]+":"+f[e[s]]+";";return n}function ee(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Gn(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const vn=new K;class Un{constructor(n={},e={}){this.json=n,this.extensions={},this.plugins={},this.options=e,this.cache=new un,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,t=-1,i=!1,r=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);t=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&t<17||i&&r<98?this.textureLoader=new Ie(this.options.manager):this.textureLoader=new Oe(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new de(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(n){this.extensions=n}setPlugins(n){this.plugins=n}parse(n,e){const s=this,t=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][t.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:t.asset,parser:s,userData:{}};return O(i,a,t),y(a,t),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();n(a)})}).catch(e)}_markDefs(){const n=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let t=0,i=e.length;t<i;t++){const r=e[t].joints;for(let a=0,o=r.length;a<o;a++)n[r[a]].isBone=!0}for(let t=0,i=n.length;t<i;t++){const r=n[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(n,e){e!==void 0&&(n.refs[e]===void 0&&(n.refs[e]=n.uses[e]=0),n.refs[e]++)}_getNodeRef(n,e,s){if(n.refs[e]<=1)return s;const t=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,u]of r.children.entries())i(u,a.children[c])};return i(s,t),t.name+="_instance_"+n.uses[e]++,t}_invokeOne(n){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const t=n(e[s]);if(t)return t}return null}_invokeAll(n){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let t=0;t<e.length;t++){const i=n(e[t]);i&&s.push(i)}return s}getDependency(n,e){const s=n+":"+e;let t=this.cache.get(s);if(!t){switch(n){case"scene":t=this.loadScene(e);break;case"node":t=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":t=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":t=this.loadAccessor(e);break;case"bufferView":t=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":t=this.loadBuffer(e);break;case"material":t=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":t=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":t=this.loadSkin(e);break;case"animation":t=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":t=this.loadCamera(e);break;default:if(t=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(n,e)}),!t)throw new Error("Unknown type: "+n);break}this.cache.add(s,t)}return t}getDependencies(n){let e=this.cache.get(n);if(!e){const s=this,t=this.json[n+(n==="mesh"?"es":"s")]||[];e=Promise.all(t.map(function(i,r){return s.getDependency(n,r)})),this.cache.add(n,e)}return e}loadBuffer(n){const e=this.json.buffers[n],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&n===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);const t=this.options;return new Promise(function(i,r){s.load(v.resolveURL(e.uri,t.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(n){const e=this.json.bufferViews[n];return this.getDependency("buffer",e.buffer).then(function(s){const t=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+t)})}loadAccessor(n){const e=this,s=this.json,t=this.json.accessors[n];if(t.bufferView===void 0&&t.sparse===void 0){const r=q[t.type],a=H[t.componentType],o=t.normalized===!0,c=new a(t.count*r);return Promise.resolve(new V(c,r,o))}const i=[];return t.bufferView!==void 0?i.push(this.getDependency("bufferView",t.bufferView)):i.push(null),t.sparse!==void 0&&(i.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=q[t.type],c=H[t.componentType],u=c.BYTES_PER_ELEMENT,l=u*o,h=t.byteOffset||0,d=t.bufferView!==void 0?s.bufferViews[t.bufferView].byteStride:void 0,p=t.normalized===!0;let R,m;if(d&&d!==l){const T=Math.floor(h/d),_="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+T+":"+t.count;let x=e.cache.get(_);x||(R=new c(a,T*d,t.count*d/u),x=new Ce(R,d/u),e.cache.add(_,x)),m=new sn(x,o,h%d/u,p)}else a===null?R=new c(t.count*o):R=new c(a,h,t.count*o),m=new V(R,o,p);if(t.sparse!==void 0){const T=q.SCALAR,_=H[t.sparse.indices.componentType],x=t.sparse.indices.byteOffset||0,E=t.sparse.values.byteOffset||0,L=new _(r[1],x,t.sparse.count*T),N=new c(r[2],E,t.sparse.count*o);a!==null&&(m=new V(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,k=L.length;S<k;S++){const P=L[S];if(m.setX(P,N[S*o]),o>=2&&m.setY(P,N[S*o+1]),o>=3&&m.setZ(P,N[S*o+2]),o>=4&&m.setW(P,N[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(n){const e=this.json,s=this.options,i=e.textures[n].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(n,i,a)}loadTextureImage(n,e,s){const t=this,i=this.json,r=i.textures[n],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(i.samplers||{})[r.sampler]||{};return u.magFilter=ue[h.magFilter]||J,u.minFilter=ue[h.minFilter]||Te,u.wrapS=le[h.wrapS]||Z,u.wrapT=le[h.wrapT]||Z,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Re&&u.minFilter!==J,t.associations.set(u,{textures:n}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(n,e){const s=this,t=this.json,i=this.options;if(this.sourceCache[n]!==void 0)return this.sourceCache[n].then(l=>l.clone());const r=t.images[n],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:r.mimeType});return o=a.createObjectURL(h),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+n+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let p=h;e.isImageBitmapLoader===!0&&(p=function(R){const m=new ne(R);m.needsUpdate=!0,h(m)}),e.load(v.resolveURL(l,i.path),p,void 0,d)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),y(l,r),l.userData.mimeType=r.mimeType||Gn(r.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[n]=u,u}assignTexture(n,e,s,t){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[g.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return t!==void 0&&(r.colorSpace=t),n[e]=r,r})}assignFinalMaterial(n){const e=n.geometry;let s=n.material;const t=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(n.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new Ge,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(n.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new ve,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(t||i||r){let a="ClonedMaterial:"+s.uuid+":";t&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),t&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}n.material=s}getMaterialType(){return Ee}loadMaterial(n){const e=this,s=this.json,t=this.extensions,i=s.materials[n];let r;const a={},o=i.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){const l=t[g.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),c.push(l.extendParams(a,i,e))}else{const l=i.pbrMetallicRoughness||{};if(a.color=new F(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],w),a.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,U)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),r=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(n)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(n,a)})))}i.doubleSided===!0&&(a.side=Ue);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new pe(1,1),i.normalTexture.scale!==void 0)){const l=i.normalTexture.scale;a.normalScale.set(l,l)}if(i.occlusionTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==G){const l=i.emissiveFactor;a.emissive=new F().setRGB(l[0],l[1],l[2],w)}return i.emissiveTexture!==void 0&&r!==G&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,U)),Promise.all(c).then(function(){const l=new r(a);return i.name&&(l.name=i.name),y(l,i),e.associations.set(l,{materials:n}),i.extensions&&O(t,l,i),l})}createUniqueName(n){const e=Ke.sanitizeNodeName(n||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(n){const e=this,s=this.extensions,t=this.primitiveCache;function i(a){return s[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return fe(o,a,e)})}const r=[];for(let a=0,o=n.length;a<o;a++){const c=n[a],u=Dn(c),l=t[u];if(l)r.push(l.promise);else{let h;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?h=i(c):h=fe(new Be,c,e),t[u]={primitive:c,promise:h},r.push(h)}}return Promise.all(r)}loadMesh(n){const e=this,s=this.json,t=this.extensions,i=s.meshes[n],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const u=r[o].material===void 0?Pn(this.cache):this.getDependency("material",r[o].material);a.push(u)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),u=o[o.length-1],l=[];for(let d=0,p=u.length;d<p;d++){const R=u[d],m=r[d];let T;const _=c[d];if(m.mode===M.TRIANGLES||m.mode===M.TRIANGLE_STRIP||m.mode===M.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new je(R,_):new Ve(R,_),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===M.TRIANGLE_STRIP?T.geometry=oe(T.geometry,he):m.mode===M.TRIANGLE_FAN&&(T.geometry=oe(T.geometry,Q));else if(m.mode===M.LINES)T=new Xe(R,_);else if(m.mode===M.LINE_STRIP)T=new ze(R,_);else if(m.mode===M.LINE_LOOP)T=new qe(R,_);else if(m.mode===M.POINTS)T=new We(R,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&kn(T,i),T.name=e.createUniqueName(i.name||"mesh_"+n),y(T,i),m.extensions&&O(t,T,m),e.assignFinalMaterial(T),l.push(T)}for(let d=0,p=l.length;d<p;d++)e.associations.set(l[d],{meshes:n,primitives:d});if(l.length===1)return i.extensions&&O(t,l[0],i),l[0];const h=new z;i.extensions&&O(t,h,i),e.associations.set(h,{meshes:n});for(let d=0,p=l.length;d<p;d++)h.add(l[d]);return h})}loadCamera(n){let e;const s=this.json.cameras[n],t=s[s.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new Ye(Qe.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):s.type==="orthographic"&&(e=new Je(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),y(e,s),Promise.resolve(e)}loadSkin(n){const e=this.json.skins[n],s=[];for(let t=0,i=e.joints.length;t<i;t++)s.push(this._loadNodeShallow(e.joints[t]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const i=t.pop(),r=t,a=[],o=[];for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l){a.push(l);const h=new K;i!==null&&h.fromArray(i.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new Ze(a,o)})}loadAnimation(n){const e=this.json,s=this,t=e.animations[n],i=t.name?t.name:"animation_"+n,r=[],a=[],o=[],c=[],u=[];for(let l=0,h=t.channels.length;l<h;l++){const d=t.channels[l],p=t.samplers[d.sampler],R=d.target,m=R.node,T=t.parameters!==void 0?t.parameters[p.input]:p.input,_=t.parameters!==void 0?t.parameters[p.output]:p.output;R.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",_)),c.push(p),u.push(R))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(l){const h=l[0],d=l[1],p=l[2],R=l[3],m=l[4],T=[];for(let x=0,E=h.length;x<E;x++){const L=h[x],N=d[x],S=p[x],k=R[x],P=m[x];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const B=s._createAnimationTracks(L,N,S,k,P);if(B)for(let j=0;j<B.length;j++)T.push(B[j])}const _=new $e(i,void 0,T);return y(_,t),_})}createNodeMesh(n){const e=this.json,s=this,t=e.nodes[n];return t.mesh===void 0?null:s.getDependency("mesh",t.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,t.mesh,i);return t.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=t.weights.length;o<c;o++)a.morphTargetInfluences[o]=t.weights[o]}),r})}loadNode(n){const e=this.json,s=this,t=e.nodes[n],i=s._loadNodeShallow(n),r=[],a=t.children||[];for(let c=0,u=a.length;c<u;c++)r.push(s.getDependency("node",a[c]));const o=t.skin===void 0?Promise.resolve(null):s.getDependency("skin",t.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const u=c[0],l=c[1],h=c[2];h!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(h,vn)});for(let d=0,p=l.length;d<p;d++)u.add(l[d]);if(u.userData.pivot!==void 0&&l.length>0){const d=u.userData.pivot,p=l[0];u.pivot=new C().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(n){const e=this.json,s=this.extensions,t=this;if(this.nodeCache[n]!==void 0)return this.nodeCache[n];const i=e.nodes[n],r=i.name?t.createUniqueName(i.name):"",a=[],o=t._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(n)});return o&&a.push(o),i.camera!==void 0&&a.push(t.getDependency("camera",i.camera).then(function(c){return t._getNodeRef(t.cameraCache,i.camera,c)})),t._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(n)}).forEach(function(c){a.push(c)}),this.nodeCache[n]=Promise.all(a).then(function(c){let u;if(i.isBone===!0?u=new en:c.length>1?u=new z:c.length===1?u=c[0]:u=new ge,u!==c[0])for(let l=0,h=c.length;l<h;l++)u.add(c[l]);if(i.name&&(u.userData.name=i.name,u.name=r),y(u,i),i.extensions&&O(s,u,i),i.matrix!==void 0){const l=new K;l.fromArray(i.matrix),u.applyMatrix4(l)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!t.associations.has(u))t.associations.set(u,{});else if(i.mesh!==void 0&&t.meshCache.refs[i.mesh]>1){const l=t.associations.get(u);t.associations.set(u,{...l})}return t.associations.get(u).nodes=n,u}),this.nodeCache[n]}loadScene(n){const e=this.extensions,s=this.json.scenes[n],t=this,i=new z;s.name&&(i.name=t.createUniqueName(s.name)),y(i,s),s.extensions&&O(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(t.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let u=0,l=o.length;u<l;u++){const h=o[u];h.parent!==null?i.add(nn(h)):i.add(h)}const c=u=>{const l=new Map;for(const[h,d]of t.associations)(h instanceof X||h instanceof ne)&&l.set(h,d);return u.traverse(h=>{const d=t.associations.get(h);d!=null&&l.set(h,d)}),l};return t.associations=c(i),i})}_createAnimationTracks(n,e,s,t,i){const r=[],a=n.name?n.name:n.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}I[i.path]===I.weights?(c(n),n.isGroup&&n.children.forEach(c)):o.push(a);let u;switch(I[i.path]){case I.weights:u=se;break;case I.rotation:u=ie;break;case I.translation:case I.scale:u=te;break;default:switch(s.itemSize){case 1:u=se;break;case 2:case 3:default:u=te;break}break}const l=t.interpolation!==void 0?Fn[t.interpolation]:xe,h=this._getArrayFromAccessor(s);for(let d=0,p=o.length;d<p;d++){const R=new u(o[d]+"."+I[i.path],e.array,h,l);t.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(R),r.push(R)}return r}_getArrayFromAccessor(n){let e=n.array;if(n.normalized){const s=ee(e.constructor),t=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]=e[i]*s;e=t}return e}_createCubicSplineTrackInterpolant(n){n.createInterpolant=function(s){const t=this instanceof ie?Cn:Ae;return new t(this.times,this.values,this.getValueSize()/3,s)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Kn(f,n,e){const s=n.attributes,t=new an;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(t.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){const u=ee(H[a.componentType]);t.min.multiplyScalar(u),t.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=n.targets;if(i!==void 0){const a=new C,o=new C;for(let c=0,u=i.length;c<u;c++){const l=i[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,p=h.max;if(d!==void 0&&p!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(p[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(p[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(p[2]))),h.normalized){const R=ee(H[h.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}t.expandByVector(a)}f.boundingBox=t;const r=new cn;t.getCenter(r.center),r.radius=t.min.distanceTo(t.max)/2,f.boundingSphere=r}function fe(f,n,e){const s=n.attributes,t=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){f.setAttribute(a,o)})}for(const r in s){const a=$[r]||r.toLowerCase();a in f.attributes||t.push(i(s[r],a))}if(n.indices!==void 0&&!f.index){const r=e.getDependency("accessor",n.indices).then(function(a){f.setIndex(a)});t.push(r)}return re.workingColorSpace!==w&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${re.workingColorSpace}" not supported.`),y(f,n),Kn(f,n,e),Promise.all(t).then(function(){return n.targets!==void 0?Hn(f,n.targets,e):f})}export{jn as GLTFLoader};