@rr0/ufoathome 0.177.2 → 0.178.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-interview/rr0-interview.mjs +3 -3
- package/dist-embed-scene/{AdsbLolArchiveProvider-BHGe8FVN.js → AdsbLolArchiveProvider-B0Yi081_.js} +1 -1
- package/dist-embed-scene/{BeamEditor-zq64GorX.js → BeamEditor-DFGRzRny.js} +1 -1
- package/dist-embed-scene/{BeamSystem-BXee1GYk.js → BeamSystem-ebEMoYD3.js} +1 -1
- package/dist-embed-scene/{ContrailSystem-BSbI2jUe.js → ContrailSystem-Bn--uCNU.js} +1 -1
- package/dist-embed-scene/ControlPasses-BMma2JRm.js +29 -0
- package/dist-embed-scene/FilmChrome-DYiyzoB_.js +1 -0
- package/dist-embed-scene/{Flightradar24Provider-Dx2Fb8yO.js → Flightradar24Provider-CpwhYfIE.js} +1 -1
- package/dist-embed-scene/GLTFLoader-BxToReDu.js +1 -0
- package/dist-embed-scene/GenerativeKit-DR6C3LMC.js +4 -0
- package/dist-embed-scene/GenerativeKitMessages-Cu7wXgYa.js +1 -0
- package/dist-embed-scene/GenerativeKitMessages_en-Cl3kA96x.js +33 -0
- package/dist-embed-scene/GenerativeKitMessages_es-CEU93Cl3.js +33 -0
- package/dist-embed-scene/GenerativeKitMessages_fr-DmW0OAmF.js +33 -0
- package/dist-embed-scene/GenerativeKitMessages_it-Ba87kumS.js +33 -0
- package/dist-embed-scene/{HeadlightSystem-_BIIKhQ2.js → HeadlightSystem-l2XbBvXf.js} +1 -1
- package/dist-embed-scene/LanternEditor-H8VYYbRn.js +9 -0
- package/dist-embed-scene/{LaserBeam-DmH2JeMa.js → LaserBeam-B48FKTrt.js} +1 -1
- package/dist-embed-scene/LaunchEditor-CIYcS0Y-.js +22 -0
- package/dist-embed-scene/{LaunchPlume-BRnjFVcY.js → LaunchPlume-eEIp7_hM.js} +1 -1
- package/dist-embed-scene/{LaunchSimulation-DL7QBfEl.js → LaunchSimulation-DNNEzmzs.js} +1 -1
- package/dist-embed-scene/{ModuleSession-BvQABNEZ.js → ModuleSession-DLoAutYP.js} +2 -2
- package/dist-embed-scene/ModuleThree-R2LhnY95.js +1 -0
- package/dist-embed-scene/{ParameterForm-BMIW4Gkh.js → ParameterForm-ez-n_0Dw.js} +9 -9
- package/dist-embed-scene/{RailwaySystem-DZQr_rS_.js → RailwaySystem-C3Y0a9aT.js} +1 -1
- package/dist-embed-scene/{ReentryEditor-DJO_M-8-.js → ReentryEditor-CwY4oANp.js} +1 -1
- package/dist-embed-scene/{ReentrySimulation-pWRgNLjt.js → ReentrySimulation-BDgEPekW.js} +1 -1
- package/dist-embed-scene/ReferenceSystem-D9IdSvFM.js +1 -0
- package/dist-embed-scene/{SceneNames_en-CqzjDgS4.js → SceneNames_en-BCTAMSLj.js} +1 -1
- package/dist-embed-scene/{SceneNames_es-DMfxIS0T.js → SceneNames_es-BOWBdXXS.js} +1 -1
- package/dist-embed-scene/{SceneNames_fr-DydzEE4a.js → SceneNames_fr-De6iQ9ff.js} +1 -1
- package/dist-embed-scene/{SceneNames_it-DJAACEvb.js → SceneNames_it-DfBWbCPR.js} +1 -1
- package/dist-embed-scene/{TimelineTracks-B-bXAaF7.js → TimelineTracks-BQXJMJaJ.js} +1 -1
- package/dist-embed-scene/{TraceSystem-gVZk_ffU.js → TraceSystem-BD6YpW6g.js} +2 -2
- package/dist-embed-scene/UfoMessages_en-CXQNZd8v.js +1 -0
- package/dist-embed-scene/UfoMessages_es-CO-v8Jl6.js +1 -0
- package/dist-embed-scene/UfoMessages_fr-CGkQBn5r.js +1 -0
- package/dist-embed-scene/UfoMessages_it-BScqxIaH.js +1 -0
- package/dist-embed-scene/VideoButton-Cy_r767Z.js +1 -0
- package/dist-embed-scene/VideoExport-B8ZhHNnd.js +169 -0
- package/dist-embed-scene/{WaterSystem-DI_NBDfH.js → WaterSystem-DbyWlKho.js} +1 -1
- package/dist-embed-scene/browser-CltifEM0.js +1 -0
- package/dist-embed-scene/logo-h2-w4Mwu.png +0 -0
- package/dist-embed-scene/rr0-scene.mjs +426 -296
- package/dist-embed-scene/{sightingSchema-BfOYR_OD.js → sightingSchema-pBDQNwMz.js} +1 -1
- package/dist-embed-scene/trafficRuntime-CJIPy2oO.js +2 -0
- package/dist-embed-sighting/{AdsbLolArchiveProvider-DK4qEYPv.js → AdsbLolArchiveProvider-BqLvFUVC.js} +1 -1
- package/dist-embed-sighting/{BallesterGuaspAssessor-FGskpWWG.js → BallesterGuaspAssessor-CLQvJKlm.js} +1 -1
- package/dist-embed-sighting/{BeamEditor-BglkfKa6.js → BeamEditor-CcOf6lNz.js} +1 -1
- package/dist-embed-sighting/{BeamSystem-DDtPjozC.js → BeamSystem-B5d0Ymn5.js} +1 -1
- package/dist-embed-sighting/CaseExportMessages_en-jHlu58Y7.js +1 -0
- package/dist-embed-sighting/CaseExportMessages_es-dCQQFgjq.js +1 -0
- package/dist-embed-sighting/CaseExportMessages_fr-sDfEgjWg.js +1 -0
- package/dist-embed-sighting/CaseExportMessages_it-BJaglZtP.js +1 -0
- package/dist-embed-sighting/CaseMessages_en-CBS5QChl.js +1 -0
- package/dist-embed-sighting/CaseMessages_es-DAMl4aTC.js +1 -0
- package/dist-embed-sighting/CaseMessages_fr-C3wQxAk_.js +1 -0
- package/dist-embed-sighting/CaseMessages_it-CyrREg6v.js +1 -0
- package/dist-embed-sighting/CaseReportExport-Uf7Bs2Qz.js +65 -0
- package/dist-embed-sighting/CaseReportTexts_en-DlN7p1pC.js +1 -0
- package/dist-embed-sighting/CaseReportTexts_es-CncAEaey.js +1 -0
- package/dist-embed-sighting/CaseReportTexts_fr-B5nP6RlP.js +1 -0
- package/dist-embed-sighting/CaseReportTexts_it-Dc-oPmXB.js +1 -0
- package/dist-embed-sighting/{ContrailSystem-DXV0DnrQ.js → ContrailSystem-CqpZgLkb.js} +1 -1
- package/dist-embed-sighting/ControlPasses-BxgSO3B9.js +29 -0
- package/dist-embed-sighting/FilmChrome-DYiyzoB_.js +1 -0
- package/dist-embed-sighting/{Flightradar24Provider-Ch4GdVJG.js → Flightradar24Provider-DQtEJ3tX.js} +1 -1
- package/dist-embed-sighting/GLTFLoader-VIIHsteW.js +1 -0
- package/dist-embed-sighting/GenerativeKit-DR6C3LMC.js +4 -0
- package/dist-embed-sighting/GenerativeKitMessages-BudEc93g.js +1 -0
- package/dist-embed-sighting/GenerativeKitMessages_en-Cl3kA96x.js +33 -0
- package/dist-embed-sighting/GenerativeKitMessages_es-CEU93Cl3.js +33 -0
- package/dist-embed-sighting/GenerativeKitMessages_fr-DmW0OAmF.js +33 -0
- package/dist-embed-sighting/GenerativeKitMessages_it-Ba87kumS.js +33 -0
- package/dist-embed-sighting/HeadlightSystem-B4RR270O.js +34 -0
- package/dist-embed-sighting/{HynekAssessor-Cb8mZ9Ib.js → HynekAssessor-CJ9APziM.js} +1 -1
- package/dist-embed-sighting/LanternEditor-D1BA5pRP.js +9 -0
- package/dist-embed-sighting/{LaserBeam-DkKFSSp_.js → LaserBeam-BjjC_CzP.js} +1 -1
- package/dist-embed-sighting/LaunchEditor-TTSgWqbE.js +22 -0
- package/dist-embed-sighting/LaunchPlume-B2Fjd2_C.js +1 -0
- package/dist-embed-sighting/{LaunchSimulation-DUvH6_BB.js → LaunchSimulation-BcmPicEe.js} +1 -1
- package/dist-embed-sighting/{ModuleSession-GzfQ8_LE.js → ModuleSession-CY9_UusZ.js} +2 -2
- package/dist-embed-sighting/ModuleThree-BhryLUjX.js +1 -0
- package/dist-embed-sighting/{NearestApproach-BeKwz4vK.js → NearestApproach-iBLl7o1g.js} +1 -1
- package/dist-embed-sighting/ParameterForm-BaUeWd7v.js +91 -0
- package/dist-embed-sighting/{PoherAssessor-JLqDISRf.js → PoherAssessor-DDRUgnRW.js} +1 -1
- package/dist-embed-sighting/RailwaySystem-C1nfRJfj.js +41 -0
- package/dist-embed-sighting/ReadingSensitivityMessages_en-CF6XauSj.js +1 -0
- package/dist-embed-sighting/ReadingSensitivityMessages_es-Ca-13TTT.js +1 -0
- package/dist-embed-sighting/ReadingSensitivityMessages_fr-Djdd6Hdq.js +1 -0
- package/dist-embed-sighting/ReadingSensitivityMessages_it-CPUXxMqD.js +1 -0
- package/dist-embed-sighting/{ReentryEditor-BHgPXlx3.js → ReentryEditor-CGN3ewTE.js} +1 -1
- package/dist-embed-sighting/ReentrySimulation-C2kIulZ6.js +1 -0
- package/dist-embed-sighting/{ReferenceSystem-B5diz1Lt.js → ReferenceSystem-BRTCOQHk.js} +1 -1
- package/dist-embed-sighting/{RoadMarkings-Dv3xdtFG.js → RoadMarkings-CNLt-BEg.js} +1 -1
- package/dist-embed-sighting/{SceneNames_en-BbQ55UYu.js → SceneNames_en-ChY7v63o.js} +1 -1
- package/dist-embed-sighting/{SceneNames_es-DsJpGSDK.js → SceneNames_es-DH4YgJV5.js} +1 -1
- package/dist-embed-sighting/{SceneNames_fr-CKr5m8QL.js → SceneNames_fr-Ca52lykk.js} +1 -1
- package/dist-embed-sighting/{SceneNames_it-qSw1j95v.js → SceneNames_it-BQe9GLaj.js} +1 -1
- package/dist-embed-sighting/{SightingMessages_en-DuokT218.js → SightingMessages_en-Xm6PILcs.js} +1 -1
- package/dist-embed-sighting/{SightingMessages_es-JO8WQ1_V.js → SightingMessages_es-DMp0MUjJ.js} +1 -1
- package/dist-embed-sighting/{SightingMessages_fr-3C2RZVNA.js → SightingMessages_fr-NvQKGPaf.js} +1 -1
- package/dist-embed-sighting/{SightingMessages_it-BEMBUACg.js → SightingMessages_it-CKIf49Zt.js} +1 -1
- package/dist-embed-sighting/{TimelineTracks-XzShW15O.js → TimelineTracks-Ddv5sZHp.js} +1 -1
- package/{dist-embed-sighting-editor/TraceSystem-CDHG18il.js → dist-embed-sighting/TraceSystem-BkUPo1Xf.js} +2 -2
- package/dist-embed-sighting/UfoMessages_en-cLvtpfIC.js +1 -0
- package/dist-embed-sighting/UfoMessages_es-CO-v8Jl6.js +1 -0
- package/dist-embed-sighting/UfoMessages_fr-CGkQBn5r.js +1 -0
- package/dist-embed-sighting/UfoMessages_it-BScqxIaH.js +1 -0
- package/dist-embed-sighting/VideoButton-C62NkJrH.js +1 -0
- package/dist-embed-sighting/VideoExport-B8ZhHNnd.js +169 -0
- package/dist-embed-sighting/{WaterSystem-CcLIPQfy.js → WaterSystem-DrSAhM5g.js} +1 -1
- package/dist-embed-sighting/browser-CltifEM0.js +1 -0
- package/dist-embed-sighting/logo-h2-w4Mwu.png +0 -0
- package/dist-embed-sighting/rr0-sighting.mjs +531 -337
- package/dist-embed-sighting/{sightingSchema-BfOYR_OD.js → sightingSchema-pBDQNwMz.js} +1 -1
- package/dist-embed-sighting/trafficRuntime-CFgDqQz4.js +2 -0
- package/dist-embed-sighting-editor/{AdsbLolArchiveProvider-CXB-CDQ2.js → AdsbLolArchiveProvider-fZkxLAHp.js} +1 -1
- package/dist-embed-sighting-editor/{BallesterGuaspAssessor-Bb8Kl2FU.js → BallesterGuaspAssessor-DASadJjI.js} +1 -1
- package/dist-embed-sighting-editor/{BeamEditor-DJtZYFp0.js → BeamEditor-B2diaX_e.js} +1 -1
- package/dist-embed-sighting-editor/{BeamSystem-C6Wk_vNQ.js → BeamSystem-BfNJfayv.js} +1 -1
- package/dist-embed-sighting-editor/{BodyEditor-Cj7TgjV-.js → BodyEditor-CCBXFuuL.js} +1 -1
- package/dist-embed-sighting-editor/BodyEditorMessages_en-CckxSS1L.js +1 -0
- package/dist-embed-sighting-editor/BodyEditorMessages_es-B8GlFFBo.js +1 -0
- package/dist-embed-sighting-editor/BodyEditorMessages_fr-638ypdqf.js +1 -0
- package/dist-embed-sighting-editor/BodyEditorMessages_it-SKpMkHFI.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_en-DrJY0M8h.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_es-j8EeOBq6.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_fr-BkwEF9mu.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_it-d3Z0PBEw.js +1 -0
- package/dist-embed-sighting-editor/CaseExportMessages_en-jHlu58Y7.js +1 -0
- package/dist-embed-sighting-editor/CaseExportMessages_es-dCQQFgjq.js +1 -0
- package/dist-embed-sighting-editor/CaseExportMessages_fr-sDfEgjWg.js +1 -0
- package/dist-embed-sighting-editor/CaseExportMessages_it-BJaglZtP.js +1 -0
- package/dist-embed-sighting-editor/CaseReportExport-iCzv1W9B.js +65 -0
- package/dist-embed-sighting-editor/CaseReportTexts_en-DlN7p1pC.js +1 -0
- package/dist-embed-sighting-editor/CaseReportTexts_es-CncAEaey.js +1 -0
- package/dist-embed-sighting-editor/CaseReportTexts_fr-B5nP6RlP.js +1 -0
- package/dist-embed-sighting-editor/CaseReportTexts_it-Dc-oPmXB.js +1 -0
- package/dist-embed-sighting-editor/{ContrailSystem-e-OLIzTk.js → ContrailSystem-BWvO9taK.js} +1 -1
- package/dist-embed-sighting-editor/ControlPasses-BQ_DUxa_.js +29 -0
- package/dist-embed-sighting-editor/{CoverageAssessor-DUDmS-aG.js → CoverageAssessor-CSktyUlP.js} +1 -1
- package/dist-embed-sighting-editor/FilmChrome-DYiyzoB_.js +1 -0
- package/dist-embed-sighting-editor/{Flightradar24Provider-DtcvpdT3.js → Flightradar24Provider-OvRZWZWj.js} +1 -1
- package/dist-embed-sighting-editor/{GLTFLoader-AHdd-c6G.js → GLTFLoader-CM7Uk25s.js} +1 -1
- package/dist-embed-sighting-editor/GenerativeKit-DR6C3LMC.js +4 -0
- package/dist-embed-sighting-editor/GenerativeKitMessages-BNXaLr1m.js +1 -0
- package/dist-embed-sighting-editor/GenerativeKitMessages_en-Cl3kA96x.js +33 -0
- package/dist-embed-sighting-editor/GenerativeKitMessages_es-CEU93Cl3.js +33 -0
- package/dist-embed-sighting-editor/GenerativeKitMessages_fr-DmW0OAmF.js +33 -0
- package/dist-embed-sighting-editor/GenerativeKitMessages_it-Ba87kumS.js +33 -0
- package/dist-embed-sighting-editor/{GeoExportTexts-DAllttgw.js → GeoExportTexts-DBGGdRnP.js} +1 -1
- package/dist-embed-sighting-editor/{GeoJsonExport-3snOe-2J.js → GeoJsonExport-BZ-0v8fM.js} +1 -1
- package/dist-embed-sighting-editor/GeographicFigures-DqhWddS9.js +1 -0
- package/dist-embed-sighting-editor/{HeadlightSystem-CLhqQjbe.js → HeadlightSystem-C-8Gl3vu.js} +1 -1
- package/dist-embed-sighting-editor/{HynekAssessor-DvVp-CLS.js → HynekAssessor-CH2E88xV.js} +1 -1
- package/dist-embed-sighting-editor/{InterviewEditorElement-44XFadV4.js → InterviewEditorElement-Bz3hyZ-m.js} +2 -2
- package/dist-embed-sighting-editor/{KmlExport-B0SKgn4U.js → KmlExport-Bh4eTycx.js} +1 -1
- package/dist-embed-sighting-editor/{KmlImport-B9mAzJwr.js → KmlImport-CKxaATTA.js} +1 -1
- package/dist-embed-sighting-editor/LanternEditor-tTk1vUZm.js +9 -0
- package/dist-embed-sighting-editor/{LaserBeam-QJPhnVO_.js → LaserBeam-CtogDP38.js} +1 -1
- package/dist-embed-sighting-editor/LaunchEditor-CteAalch.js +22 -0
- package/dist-embed-sighting-editor/{LaunchPlume-C_r62XTj.js → LaunchPlume-BtRrJTP9.js} +1 -1
- package/dist-embed-sighting-editor/{LaunchSimulation-BSDTfZTv.js → LaunchSimulation-xKwguVJt.js} +1 -1
- package/dist-embed-sighting-editor/{ModelSource-B85niY1n.js → ModelSource-CnKzaNDn.js} +1 -1
- package/dist-embed-sighting-editor/{ModelThumbnails-uYh2sUIb.js → ModelThumbnails-UE_Er5EW.js} +1 -1
- package/dist-embed-sighting-editor/{ModelViewer-DLZhhuq5.js → ModelViewer-DoCshJc6.js} +1 -1
- package/dist-embed-sighting-editor/{ModuleConformance-CBMdTSVo.js → ModuleConformance-BKvZnuw9.js} +2 -2
- package/dist-embed-sighting-editor/{ModuleSession-rFLStWcj.js → ModuleSession-CJstaNEN.js} +3 -3
- package/dist-embed-sighting-editor/ModuleThree-1hxqvWFa.js +1 -0
- package/dist-embed-sighting-editor/{ModulesPanelElement-CGp6DrpQ.js → ModulesPanelElement-DdGqqdn4.js} +3 -3
- package/dist-embed-sighting-editor/{NearestApproach-Ctw1-XBO.js → NearestApproach-BH3Yw8Qz.js} +1 -1
- package/dist-embed-sighting-editor/{PictureRegistration-ZyvGfReK.js → PictureRegistration-B9C6iY17.js} +1 -1
- package/dist-embed-sighting-editor/{PoherAssessor-CLKwvgUL.js → PoherAssessor-DWcCWUfa.js} +1 -1
- package/dist-embed-sighting-editor/RailwaySystem-D3VBmx1X.js +41 -0
- package/dist-embed-sighting-editor/ReadingSensitivityMessages_en-CF6XauSj.js +1 -0
- package/dist-embed-sighting-editor/ReadingSensitivityMessages_es-Ca-13TTT.js +1 -0
- package/dist-embed-sighting-editor/ReadingSensitivityMessages_fr-Djdd6Hdq.js +1 -0
- package/dist-embed-sighting-editor/ReadingSensitivityMessages_it-CPUXxMqD.js +1 -0
- package/dist-embed-sighting-editor/{ReentryEditor-DXe8wen6.js → ReentryEditor-BDyG-48K.js} +2 -2
- package/dist-embed-sighting-editor/{ReentrySimulation-BxVE5Dsn.js → ReentrySimulation-BQj0wWXW.js} +1 -1
- package/dist-embed-sighting-editor/ReferenceSystem-C9NRL7UY.js +1 -0
- package/dist-embed-sighting-editor/RoadMarkings-ByQL2MTo.js +1 -0
- package/dist-embed-sighting-editor/SceneNames_en-BdRB6cjg.js +1 -0
- package/dist-embed-sighting-editor/SceneNames_es-Dk0UmXHp.js +1 -0
- package/dist-embed-sighting-editor/SceneNames_fr-_z2iZ8Bm.js +1 -0
- package/dist-embed-sighting-editor/SceneNames_it-CE7fanb3.js +1 -0
- package/dist-embed-sighting-editor/{SightingEditorMessages_en-G8-sD56V.js → SightingEditorMessages_en-jinQLW0J.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_es-DEmsmIRU.js → SightingEditorMessages_es-CsrGiJYn.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_fr-D2HXab_N.js → SightingEditorMessages_fr-cQ6KnPU1.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_it-LpFdlGY5.js → SightingEditorMessages_it-D3Rqso5s.js} +1 -1
- package/dist-embed-sighting-editor/{SightingFileEditor-CnKF2ndt.js → SightingFileEditor-BCjntT4l.js} +1 -1
- package/dist-embed-sighting-editor/{TraceImport-CL8lefw6.js → TraceImport-uGVIjCrc.js} +2 -2
- package/{dist-embed-sighting/TraceSystem-XybhI4uJ.js → dist-embed-sighting-editor/TraceSystem-g262KZ3G.js} +2 -2
- package/dist-embed-sighting-editor/UfoMessages_en-JeMK-39o.js +1 -0
- package/dist-embed-sighting-editor/UfoMessages_es-CO-v8Jl6.js +1 -0
- package/dist-embed-sighting-editor/UfoMessages_fr-CGkQBn5r.js +1 -0
- package/dist-embed-sighting-editor/UfoMessages_it-BScqxIaH.js +1 -0
- package/dist-embed-sighting-editor/VideoButton-CqCZ65oK.js +1 -0
- package/dist-embed-sighting-editor/VideoExport-B8ZhHNnd.js +169 -0
- package/dist-embed-sighting-editor/WaterSystem-CIbQPMqE.js +1 -0
- package/dist-embed-sighting-editor/browser-CltifEM0.js +1 -0
- package/dist-embed-sighting-editor/logo-h2-w4Mwu.png +0 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +610 -398
- package/dist-embed-sighting-editor/{sightingSchema-9xw8srxN.js → sightingSchema-RamhmoRU.js} +1 -1
- package/dist-embed-sighting-editor/{surroundingsSources-DXpzMDPy.js → surroundingsSources-BExFsNzP.js} +1 -1
- package/dist-embed-sighting-editor/trafficRuntime-CPRQW0Ho.js +2 -0
- package/package.json +2 -1
- package/dist-embed-scene/GLTFLoader-DDba3PaV.js +0 -1
- package/dist-embed-scene/LanternEditor-2q5seAWj.js +0 -9
- package/dist-embed-scene/LaunchEditor-Cupksu8A.js +0 -22
- package/dist-embed-scene/ModuleThree-12Uq6OyD.js +0 -1
- package/dist-embed-scene/ReferenceSystem-D9agTeWl.js +0 -1
- package/dist-embed-scene/UfoMessages_en-CRIdIMYy.js +0 -1
- package/dist-embed-scene/UfoMessages_es-BoulVpJw.js +0 -1
- package/dist-embed-scene/UfoMessages_fr-8f6FJbk6.js +0 -1
- package/dist-embed-scene/UfoMessages_it-cngzFg3N.js +0 -1
- package/dist-embed-scene/browser-_Ncw3Jhn.js +0 -1
- package/dist-embed-scene/trafficRuntime-BDtw1Kqi.js +0 -2
- package/dist-embed-sighting/CaseMessages_en-DEyvxYxv.js +0 -1
- package/dist-embed-sighting/CaseMessages_es-DDsQ93tK.js +0 -1
- package/dist-embed-sighting/CaseMessages_fr-DoHbDEkG.js +0 -1
- package/dist-embed-sighting/CaseMessages_it-CF8sKknV.js +0 -1
- package/dist-embed-sighting/GLTFLoader-BDyucwJ-.js +0 -1
- package/dist-embed-sighting/HeadlightSystem-DGUfgm2c.js +0 -34
- package/dist-embed-sighting/LanternEditor-CaZ1JhZS.js +0 -9
- package/dist-embed-sighting/LaunchEditor-QRG2uHH8.js +0 -22
- package/dist-embed-sighting/LaunchPlume-DBINBQgQ.js +0 -1
- package/dist-embed-sighting/ModuleThree-tnKi-oul.js +0 -1
- package/dist-embed-sighting/ParameterForm-DW6cQmYI.js +0 -91
- package/dist-embed-sighting/RailwaySystem-BfTJvmf3.js +0 -41
- package/dist-embed-sighting/ReentrySimulation-C3BR2hs3.js +0 -1
- package/dist-embed-sighting/UfoMessages_en-CoSqGYwb.js +0 -1
- package/dist-embed-sighting/UfoMessages_es-BoulVpJw.js +0 -1
- package/dist-embed-sighting/UfoMessages_fr-8f6FJbk6.js +0 -1
- package/dist-embed-sighting/UfoMessages_it-cngzFg3N.js +0 -1
- package/dist-embed-sighting/browser-_Ncw3Jhn.js +0 -1
- package/dist-embed-sighting/trafficRuntime-BAuwwA-Z.js +0 -2
- package/dist-embed-sighting-editor/BodyEditorMessages_en-zfy3BJb5.js +0 -1
- package/dist-embed-sighting-editor/BodyEditorMessages_es-w95anMnI.js +0 -1
- package/dist-embed-sighting-editor/BodyEditorMessages_fr-ixsDgTbt.js +0 -1
- package/dist-embed-sighting-editor/BodyEditorMessages_it-B3oQzqHE.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_en-D47ntA6R.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_es-CyIdBeD_.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_fr-DXaZI1jZ.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_it-Cp1-Jm34.js +0 -1
- package/dist-embed-sighting-editor/GeographicFigures-CLBS2HJ-.js +0 -1
- package/dist-embed-sighting-editor/LanternEditor-ngKN2Zt3.js +0 -9
- package/dist-embed-sighting-editor/LaunchEditor-B8KlP5eo.js +0 -22
- package/dist-embed-sighting-editor/ModuleThree-DrKN6B-3.js +0 -1
- package/dist-embed-sighting-editor/RailwaySystem-C67LdkZv.js +0 -41
- package/dist-embed-sighting-editor/ReferenceSystem-B201fXMC.js +0 -1
- package/dist-embed-sighting-editor/RoadMarkings-DJ2HL-6g.js +0 -1
- package/dist-embed-sighting-editor/SceneNames_en-DggkchR4.js +0 -1
- package/dist-embed-sighting-editor/SceneNames_es-BtXXqtTk.js +0 -1
- package/dist-embed-sighting-editor/SceneNames_fr-I6FOP0oQ.js +0 -1
- package/dist-embed-sighting-editor/SceneNames_it-DrW4eXBX.js +0 -1
- package/dist-embed-sighting-editor/UfoMessages_en-BxhQNf5z.js +0 -1
- package/dist-embed-sighting-editor/UfoMessages_es-BoulVpJw.js +0 -1
- package/dist-embed-sighting-editor/UfoMessages_fr-8f6FJbk6.js +0 -1
- package/dist-embed-sighting-editor/UfoMessages_it-cngzFg3N.js +0 -1
- package/dist-embed-sighting-editor/WaterSystem-B2xlCmn2.js +0 -1
- package/dist-embed-sighting-editor/browser-_Ncw3Jhn.js +0 -1
- package/dist-embed-sighting-editor/trafficRuntime-_7Uw8kC_.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as V,O as tt,h as q,T as j,i as C,j as X,k as et,m as st,n as B}from"./rr0-sighting-editor.mjs";class I{constructor(t){this.survey=t}static CACHE_NAME="rr0-surroundings";static MAX_AGE_MS=720*3600*1e3;static FORMAT=8;static MAX_STORED=400;static asked=new Map;get id(){return this.survey.id}get name(){return this.survey.name}get attribution(){return this.survey.attribution}get creditUrl(){return this.survey.creditUrl}get contemporary(){return this.survey.contemporary}covers(t,e){return this.survey.covers(t,e)}async getSurroundings(t,e){const o=I.key(this.survey.id,t,e);let s=I.asked.get(o);return s===void 0&&(s=this.recalled(o,t,e),I.asked.set(o,s),s.catch(()=>I.asked.delete(o))),structuredClone(await s)}later(t,e){const o=this.survey.later?.(t,e);if(!o)return;const s=I.key(this.survey.id,t,e);return o.then(n=>{const a=I.partial.get(s);if(a){I.partial.delete(s);const{incomplete:r,...i}=a,h=[...a.credits??[],...n.credits??[]].filter((l,f,M)=>M.findIndex(d=>d.url===l.url)===f),c={...i,...n,dates:{...a.dates,...n.dates},...h.length>0?{credits:h}:{}};I.asked.set(s,Promise.resolve(c)),I.openCache().then(l=>l&&I.store(l,I.request(s),c))}return structuredClone(n)})}static partial=new Map;static forget(){I.partial.clear(),I.asked.clear()}static key(t,e,o){return`${t}/v${I.FORMAT}/${e.lat.toFixed(5)}/${e.lng.toFixed(5)}/${Math.round(o)}`}async recalled(t,e,o){const s=await I.openCache(),n=I.request(t);if(s)try{const r=await s.match(n);if(r){const{savedAt:i,surroundings:h}=await r.json();if(Date.now()-i<I.MAX_AGE_MS)return h;await s.delete(n)}}catch{}const a=await this.survey.getSurroundings(e,o);return a.incomplete?(I.asked.delete(t),I.partial.set(t,structuredClone(a)),a):(s&&I.store(s,n,a),a)}static async store(t,e,o){try{const s={savedAt:Date.now(),surroundings:o};await t.put(e,new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const a of n.slice(0,Math.max(0,n.length-I.MAX_STORED)))await t.delete(a)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(I.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__surroundings__/${encodeURIComponent(t)}`)}}class ot{constructor(t){if(this.candidates=t,t.length===0)throw new Error("A survey needs at least one candidate");this.current=t[0]}current;get id(){return this.current.id}get name(){return this.current.name}get attribution(){return this.current.attribution}get creditUrl(){return this.current.creditUrl}get contemporary(){return this.current.contemporary}covers(t,e){return this.candidates.some(o=>o.covers(t,e))}async getSurroundings(t,e){let o;for(const s of this.candidates)if(s.covers(t.lat,t.lng))try{const n=await s.getSurroundings(t,e);return this.current=s,n}catch(n){if(o??=n,!(n instanceof V))throw n}throw o??new V("no-coverage","No survey reaches this place")}later(t,e){return this.current.later?.(t,e)}}class D{constructor(t,e,o,s){this.heights=t,this.building=e,this.width=o,this.height=s}static ROOF_PERCENTILE=.9;static STEP_M=.9;static RECTANGLE_FILL=.72;static MIN_DEPTH_M=2.5;static MAX_PARTS=24;static MAX_CELLS=640;buildings(t){const e=t.metresPerPixel,o=t.minAreaM2??12,s=new Uint8Array(this.width*this.height),n=[];for(let a=0;a<this.building.length;a++){if(!this.building[a]||s[a])continue;const r=this.patchFrom(a,s);if(!(r.length*e*e<o))for(const i of this.buildingsOf(r,e,o))Math.hypot(i.eastM,i.northM)<=t.radiusM&&n.push(i)}return n.sort((a,r)=>Math.hypot(a.eastM,a.northM)-Math.hypot(r.eastM,r.northM)),n.slice(0,t.maxBuildings??60)}patchFrom(t,e){const o=[],s=[t];for(e[t]=1;s.length>0;){const n=s.pop();o.push(n);const a=n%this.width,r=Math.floor(n/this.width);for(const[i,h]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+i,l=r+h;if(c<0||l<0||c>=this.width||l>=this.height)continue;const f=l*this.width+c;this.building[f]&&!e[f]&&Math.abs(this.heights[f]-this.heights[n])<=D.STEP_M&&(e[f]=1,s.push(f))}}return o}buildingsOf(t,e,o){const s=this.width/2,n=this.height/2,a=[],r=[],i=[];for(const h of t){const c=h%this.width,l=Math.floor(h/this.width);a.push((c+.5-s)*e),r.push((n-l-.5)*e),i.push(this.heights[h])}return D.ofPoints(a,r,i,e,o)}static ofPoints(t,e,o,s,n,a=D.RECTANGLE_FILL,r=[]){const i=[];for(let m=0;m<t.length;m++)for(const[E,v]of[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]])i.push([t[m]+E*s,e[m]+v*s]);const h=D.hull(i),{angle:c,rectangle:l}=D.smallestRectangle(h),f=t.length*s*s,M=(l.maxU-l.minU)*(l.maxV-l.minV);if(f/M>=a||f<4*n)return[D.building(l,c,D.roof(o))];const d=h.map((m,E)=>({from:{east:m[0],north:m[1]},to:{east:h[(E+1)%h.length][0],north:h[(E+1)%h.length][1]}})),g=D.dominantAngles([...r,...d]);return D.parts(t,e,o,g.length>0?g:[c],s,n)}static dominantAngles(t,e=3){const o=new Map;for(const s of t){const n=Math.hypot(s.to.east-s.from.east,s.to.north-s.from.north);if(n<1e-6)continue;const a=(Math.atan2(s.to.north-s.from.north,s.to.east-s.from.east)%(Math.PI/2)+Math.PI/2)%(Math.PI/2),r=Math.round(a/(Math.PI/60));o.set(r,(o.get(r)??0)+n)}return[...o.entries()].sort((s,n)=>n[1]-s[1]).slice(0,e).map(([s])=>s*Math.PI/60)}static parts(t,e,o,s,n,a){let r=t.map((h,c)=>c);const i=[];for(let h=0;h<D.MAX_PARTS&&r.length>0;h++){let c;for(const M of s){const d=D.largestIn(t,e,r,M,n);d&&(c===void 0||d.area>c.area)&&(c=d)}if(c===void 0||c.area<a)break;const l=c.covered;Math.min(c.rectangle.maxU-c.rectangle.minU,c.rectangle.maxV-c.rectangle.minV)>=D.MIN_DEPTH_M&&i.push(D.building(c.rectangle,c.angle,D.roof([...l].map(M=>o[M])))),r=r.filter(M=>!l.has(M))}return i}static largestIn(t,e,o,s,n){const a=Math.cos(s),r=Math.sin(s);let i=1/0,h=-1/0,c=1/0,l=-1/0;const f=[],M=[];for(const A of o){const y=t[A]*a+e[A]*r,R=-t[A]*r+e[A]*a;f.push(y),M.push(R),i=Math.min(i,y),h=Math.max(h,y),c=Math.min(c,R),l=Math.max(l,R)}const d=Math.max(n*Math.SQRT2,Math.max(h-i,l-c)/D.MAX_CELLS),g=Math.max(1,Math.ceil((h-i)/d+1e-9)),m=Math.max(1,Math.ceil((l-c)/d+1e-9)),E=new Uint8Array(g*m),v=o.map((A,y)=>{const R=Math.min(g-1,Math.max(0,Math.floor((f[y]-i)/d))),x=Math.min(m-1,Math.max(0,Math.floor((M[y]-c)/d)));return E[x*g+R]=1,x*g+R}),w=D.largestRectangle(E,g,m);if(w===void 0)return;const p=new Set;return o.forEach((A,y)=>{const R=v[y]%g,x=Math.floor(v[y]/g);R>=w.column&&R<w.column+w.columns&&x>=w.row&&x<w.row+w.rows&&p.add(A)}),{area:w.area*d*d,angle:s,covered:p,rectangle:{minU:i+w.column*d,maxU:i+(w.column+w.columns)*d,minV:c+w.row*d,maxV:c+(w.row+w.rows)*d}}}static largestRectangle(t,e,o){const s=new Array(e).fill(0);let n;for(let a=0;a<o;a++){for(let i=0;i<e;i++)s[i]=t[a*e+i]?s[i]+1:0;const r=[];for(let i=0;i<=e;i++){const h=i===e?0:s[i];for(;r.length>0&&s[r[r.length-1]]>=h;){const c=r.pop(),l=r.length===0?i:i-r[r.length-1]-1,f=s[c]*l;(n===void 0||f>n.area)&&(n={column:i-l,row:a-s[c]+1,columns:l,rows:s[c],area:f})}r.push(i)}}return n}static roof(t){const e=[...t].sort((o,s)=>o-s);return Math.max(2,e[Math.min(e.length-1,Math.floor(e.length*D.ROOF_PERCENTILE))])}static building(t,e,o){const s=Math.cos(e),n=Math.sin(e),a=t.maxU-t.minU,r=t.maxV-t.minV,i=(t.minU+t.maxU)/2,h=(t.minV+t.maxV)/2,l=((90-(a<r?e:e+Math.PI/2)*180/Math.PI)%180+180)%180;return{eastM:D.tenth(i*s-h*n),northM:D.tenth(i*n+h*s),widthM:D.tenth(Math.max(a,r)),lengthM:D.tenth(Math.min(a,r)),heightM:D.tenth(o),headingDeg:Math.round(l*10)/10}}static smallestRectangle(t){let e={area:1/0,angle:0,rectangle:{minU:0,maxU:0,minV:0,maxV:0}};for(let o=0;o<Math.max(1,t.length);o++){const[s,n]=t[o]??[0,0],[a,r]=t[(o+1)%t.length]??[1,0],i=Math.atan2(r-n,a-s),h=Math.cos(i),c=Math.sin(i);let l=1/0,f=-1/0,M=1/0,d=-1/0;for(const[m,E]of t){const v=m*h+E*c,w=-m*c+E*h;l=Math.min(l,v),f=Math.max(f,v),M=Math.min(M,w),d=Math.max(d,w)}const g=(f-l)*(d-M);g<e.area&&(e={area:g,angle:i,rectangle:{minU:l,maxU:f,minV:M,maxV:d}})}return e}static hull(t){const e=[...t].sort((r,i)=>r[0]-i[0]||r[1]-i[1]),o=e.filter((r,i)=>i===0||r[0]!==e[i-1][0]||r[1]!==e[i-1][1]);if(o.length<3)return o;const s=(r,i,h)=>(i[0]-r[0])*(h[1]-r[1])-(i[1]-r[1])*(h[0]-r[0]),n=[];for(const r of o){for(;n.length>=2&&s(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}const a=[];for(const r of[...o].reverse()){for(;a.length>=2&&s(a[a.length-2],a[a.length-1],r)<=0;)a.pop();a.push(r)}return[...n.slice(0,-1),...a.slice(0,-1)]}static tenth(t){return Math.round(t*10)/10}}class H{constructor(t,e,o,s){this.heights=t,this.vegetation=e,this.width=o,this.height=s}static SUMMIT_RADIUS_M=2.5;static CROWN_REACH_M=8;static MAX_WIDTH_M=16;static MIN_WIDTH_M=2;static tenth(t){return Math.round(t*10)/10}trees(t){const e=t.metresPerPixel,o=t.minHeightM??4,s=t.eyeM??1.6,n=t.minElevationDeg??2,a=Math.max(1,Math.round(H.SUMMIT_RADIUS_M/e)),r=Math.round(H.CROWN_REACH_M/e),i=this.width/2,h=this.height/2,c=[];for(let l=0;l<this.height;l++)for(let f=0;f<this.width;f++){const M=this.canopy(f,l);if(M<o)continue;const d=(f+.5-i)*e,g=(h-l-.5)*e,m=Math.hypot(d,g);if(m>t.radiusM||!this.isSummit(f,l,M,a))continue;const E=Math.atan2(M-s,Math.max(m,1))*180/Math.PI;E<n||c.push({tree:{eastM:H.tenth(d),northM:H.tenth(g),heightM:H.tenth(M),widthM:H.tenth(this.crownWidth(f,l,M,e,r))},elevation:E})}return c.sort((l,f)=>f.elevation-l.elevation),c.slice(0,t.maxTrees??150).map(l=>l.tree)}canopy(t,e){if(t<0||e<0||t>=this.width||e>=this.height)return 0;const o=e*this.width+t;return this.vegetation[o]?this.heights[o]:0}isSummit(t,e,o,s){for(let n=-s;n<=s;n++)for(let a=-s;a<=s;a++){if(a===0&&n===0)continue;const r=this.canopy(t+a,e+n);if(r>o||r===o&&(n<0||n===0&&a<0))return!1}return!0}crownWidth(t,e,o,s,n){let a=0;for(let i=-n;i<=n;i++)for(let h=-n;h<=n;h++)Math.hypot(h,i)*s<=H.CROWN_REACH_M&&this.canopy(t+h,e+i)>=o*.5&&a++;const r=2*Math.sqrt(a*s*s/Math.PI);return Math.max(H.MIN_WIDTH_M,Math.min(r,H.MAX_WIDTH_M))}}class _{static WALLS={1:"stone",2:"meuliere",3:"concrete",4:"brick",5:"block",6:"wood",9:"other"};static ROOFS={1:"tile",2:"slate",3:"zinc",4:"concrete",9:"other"};static WALL_COLOURS={stone:"#b9ae9b",meuliere:"#b8a78a",concrete:"#b4b2ac",brick:"#a65f48",block:"#d0c6b2",wood:"#7d5c3e",other:"#c9c0ae"};static PLASTER="#d3cab8";static ROOF_COLOURS={tile:"#a0583f",slate:"#4a5059",zinc:"#8d969c",concrete:"#8f8e8a",other:"#7a7872"};static VARIATION=.12;static OLD_ROOF="#7d858c";static OLD_STOREY_M=3.6;static GRAND_STOREY_M=4.5;static MIN_STOREY_M=2.4;static MAX_STOREY_M=6;static of(t,e){const o=String(t??"").trim();if(!/^\d{1,2}$/.test(o))return;const s=Number(o),n=s%10!==0?s%10:Math.floor(s/10);return(e==="wall"?_.WALLS:_.ROOFS)[String(n)]}static roofColor(t){return t?_.ROOF_COLOURS[t]:void 0}static fit(t){return t.map(e=>{const o=e.style,s={...e.facade,color:e.facade?.color??_.wallColor(e)};o==="church"?s.openings="lancet":o==="monument"||o==="works"?s.openings="plain":(o==="old"||o==="grand")&&(s.openings="tall"),e.closedAtNight&&s.openings!=="plain"&&(s.closedAtNight=!0);const n=_.storeyOf(e);n!==void 0&&o!=="church"&&o!=="monument"&&(s.storeyM=n);const a=o==="old"&&e.roof?.color===void 0?{shape:"flat",riseM:0,...e.roof,color:_.OLD_ROOF}:e.roof;return{...e,facade:s,...a?{roof:a}:{}}})}static storeyOf(t){const e=t.heightM-(t.roof?.riseM??0);if(t.floors&&t.floors>0){const o=e/t.floors;if(o>=_.MIN_STOREY_M&&o<=_.MAX_STOREY_M)return Math.round(o*100)/100}return t.style==="old"?_.OLD_STOREY_M:t.style==="grand"?_.GRAND_STOREY_M:void 0}static wallColor(t){const e=t.style==="church"||t.style==="monument"||t.style==="old",o=t.wallMaterial?_.WALL_COLOURS[t.wallMaterial]:e?_.WALL_COLOURS.stone:_.PLASTER,s=Math.sin(t.eastM*12.9898+t.northM*78.233)*43758.5453,n=1+(s-Math.floor(s)-.5)*2*_.VARIATION,a=r=>Math.max(0,Math.min(255,Math.round(parseInt(o.slice(r,r+2),16)*n))).toString(16).padStart(2,"0");return`#${a(1)}${a(3)}${a(5)}`}}class N{static MIN_RISE_M=1.2;static MIN_EAVES_M=2.5;static MIN_SEEN=.35;static NO_DATA=-9999;static BANDS=7;static INSET_M=.9;static LIFT=1.18;static PEAK=.3;static LEVEL=.45;static fit(t,e,o){return!e&&!o&&!t.some(s=>s.roofMaterial)?t:t.map(s=>{const n=e?N.shapeOf(s,e):void 0,a=(o?N.colorOf(s,o):void 0)??_.roofColor(s.roofMaterial);if(!n&&!a)return s;const r={shape:n?.shape??"flat",...n?.ridge==="depth"?{ridge:"depth"}:{},riseM:n?.riseM??0,...a?{color:a}:{}},i=n&&n.shape!=="flat"?n.topM:s.heightM;return{...s,heightM:i,roof:r}})}static world(t,e,o){const s=t.headingDeg*Math.PI/180;return{east:t.eastM+e*Math.cos(s)+o*Math.sin(s),north:t.northM-e*Math.sin(s)+o*Math.cos(s)}}static shapeOf(t,e){const o=N.BANDS,s=Math.max(e.metresPerPixel,.5),n=t.widthM/2-N.INSET_M,a=t.lengthM/2-N.INSET_M;if(n<=0||a<=0)return;const r=[],i=Array.from({length:o},()=>({sum:0,n:0})),h=Array.from({length:o},()=>({sum:0,n:0}));let c=0;for(let y=-n;y<=n;y+=s)for(let R=-a;R<=a;R+=s){c++;const{east:x,north:$}=N.world(t,y,R),z=Math.floor(x/e.metresPerPixel+e.size/2),Y=Math.floor(e.size/2-$/e.metresPerPixel);if(z<0||Y<0||z>=e.size||Y>=e.size)continue;const U=Y*e.size+z,P=e.heights[U];if(e.vegetation[U]||P===N.NO_DATA||!(P>0))continue;r.push(P);const J=i[Math.min(o-1,Math.floor((y+n)/(2*n)*o))],Q=h[Math.min(o-1,Math.floor((R+a)/(2*a)*o))];J.sum+=P,J.n++,Q.sum+=P,Q.n++}if(c===0||r.length/c<N.MIN_SEEN)return;r.sort((y,R)=>y-R);const l=N.percentile(r,.08),f=N.percentile(r,.92),M=f-l;if(l<N.MIN_EAVES_M||M>Math.min(t.widthM,t.lengthM))return;if(M<N.MIN_RISE_M)return{shape:"flat",riseM:0,topM:f};const d=N.profile(i),g=N.profile(h);if(!d||!g)return;const m=N.peak(g)/M,E=N.peak(d)/M,v=N.spread(d)/M,w=N.spread(g)/M,p=m>=N.PEAK&&v<=N.LEVEL,A=E>=N.PEAK&&w<=N.LEVEL;if(p&&(!A||m>=E))return{shape:"gable",ridge:"width",riseM:M,topM:f};if(A)return{shape:"gable",ridge:"depth",riseM:M,topM:f};if(m>=N.PEAK&&E>=N.PEAK/2)return{shape:"hip",ridge:"width",riseM:M,topM:f}}static profile(t){const e=t.map(o=>o.n>0?o.sum/o.n:NaN);return e.filter(Number.isFinite).length>=t.length-1?e.map((o,s)=>Number.isFinite(o)?o:N.neighbour(e,s)):void 0}static neighbour(t,e){return Number.isFinite(t[e-1])?t[e-1]:t[e+1]}static peak(t){const e=Math.max(1,Math.floor(t.length/3)),o=n=>n.reduce((a,r)=>a+r,0)/n.length,s=[...t.slice(0,e),...t.slice(t.length-e)];return o(t.slice(e,t.length-e))-o(s)}static spread(t){return Math.max(...t)-Math.min(...t)}static percentile(t,e){return t[Math.min(t.length-1,Math.floor(t.length*e))]}static colorOf(t,e){const o=Math.max(e.metresPerPixel,.5),s=Math.max(t.widthM/2-N.INSET_M,o),n=Math.max(t.lengthM/2-N.INSET_M,o),a=[],r=[],i=[];for(let l=-s;l<=s;l+=o)for(let f=-n;f<=n;f+=o){const{east:M,north:d}=N.world(t,l,f),g=Math.floor(M/e.metresPerPixel+e.size/2),m=Math.floor(e.size/2-d/e.metresPerPixel);if(g<0||m<0||g>=e.size||m>=e.size)continue;const E=(m*e.size+g)*e.samples,v=e.values[E],w=e.values[E+1],p=e.values[E+2];w>v&&w>p||(a.push(v),r.push(w),i.push(p))}if(a.length===0)return;const h=l=>l.sort((f,M)=>f-M)[Math.floor(l.length/2)],c=l=>Math.min(255,Math.round(l*N.LIFT)).toString(16).padStart(2,"0");return`#${c(h(a))}${c(h(r))}${c(h(i))}`}}class G{static DEFAULT_HEIGHT_M=6;static METRES_PER_DEGREE=111320;static STREET_SPACING_M=35;static KERB_OFFSET_M=1;static DEFAULT_WIDTH_M=5.5;static PATIENCE_MS=15e3;static MAX=150;static lampsFrom(t,e,o){const s=[],n=new Set;for(const r of t.elements??[]){if(r.id!==void 0){const l=`${r.type}/${r.id}`;if(n.has(l))continue;n.add(l)}if(r.type==="way"){r.tags?.lit==="yes"&&G.alongStreet(r,e,s);continue}if(r.tags?.highway!=="street_lamp"||typeof r.lat!="number"||typeof r.lon!="number")continue;const i=(r.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),h=(r.lat-e.lat)*G.METRES_PER_DEGREE;if(Math.hypot(i,h)>o)continue;const c=Number.parseFloat(r.tags?.height??"");s.push({eastM:Math.round(i*10)/10,northM:Math.round(h*10)/10,...Number.isFinite(c)&&c>=2&&c<=20?{heightM:c}:{}})}const a=s.filter(r=>Math.hypot(r.eastM,r.northM)<=o);return s.length=0,s.push(...a),s.sort((r,i)=>Math.hypot(r.eastM,r.northM)-Math.hypot(i.eastM,i.northM)),s.slice(0,G.MAX)}static alongStreet(t,e,o){const s=t.geometry;if(!s||s.length<2)return;const n=d=>[(d.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),(d.lat-e.lat)*G.METRES_PER_DEGREE],a=s.map(n),r=Number.parseFloat(t.tags?.width??""),i=Number.parseInt(t.tags?.lanes??"",10),c=(Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*3.5:G.DEFAULT_WIDTH_M)/2+G.KERB_OFFSET_M;let l=1,f=G.STREET_SPACING_M/2,M=0;for(let d=1;d<a.length;d++){const[g,m]=a[d-1],[E,v]=a[d],w=Math.hypot(E-g,v-m);if(w===0)continue;const p=(E-g)/w,A=(v-m)/w;for(;f<=M+w;f+=G.STREET_SPACING_M){const y=f-M;o.push({eastM:Math.round((g+p*y+A*c*l)*10)/10,northM:Math.round((m+A*y-p*c*l)*10)/10,supposed:!0}),l=-l}M+=w}}}class u{constructor(t={},e=[],o=[]){this.lampSources=e,this.signalSources=o,this.client=new tt(t)}static METRES_PER_DEGREE=111320;static KERB_OFFSET_M=.6;static SETBACK_M=.5;static MIN_CROSSING_M=3;static MAX_CROSSING_M=30;static SAME_CROSSING_M=5;static SAME_HEAD_M=2.5;static SAME_HEAD_DEG=45;static MAX_SIGNALS=160;static MAX_CROSSINGS=150;static MAX_SIGNS=100;static ROADS=new Set([...q.DRIVABLE,"living_street","busway","road"]);static ON_ROAD="^(traffic_signals|crossing|stop|give_way)$";static CREDIT={name:"OpenStreetMap",url:"https://www.openstreetmap.org/copyright",licence:"ODbL"};client;local(t,e){const o=u.boxOf(t,e),s=(r,i)=>{if(!r)return Promise.resolve(void 0);const h=`${r.credit.url} ${o}`;let c=u.localPending.get(h);return c||(c=i().then(l=>({credit:r.credit,found:l}),()=>{u.localPending.delete(h)}),u.localPending.set(h,c)),c},n=this.lampSources.find(r=>r.covers(t.lat,t.lng)),a=this.signalSources.find(r=>r.covers(t.lat,t.lng));return Promise.all([s(n,()=>n.lampsNear(t,e)),s(a,()=>a.signalsNear(t,e))]).then(([r,i])=>({lamps:r,signals:i}))}static localPending=new Map;static withLocal(t,e){const o=e?.lamps?e.lamps.found:t.lamps,s=e?.signals?e.signals.found:t.signals,a=[...u.found({crossings:t.crossings,signs:t.signs,...e?.lamps?{}:{lamps:o},...e?.signals?{}:{signals:s}})?[u.CREDIT]:[],...e?.lamps&&e.lamps.found.length>0?[e.lamps.credit]:[],...e?.signals&&e.signals.found.length>0?[e.signals.credit]:[]],{lamps:r,signals:i,credits:h,...c}=t;return{...c,...o?.length?{lamps:o}:{},...s?.length?{signals:s}:{},...a.length>0?{credits:a}:{}}}static today(){return new Date().toISOString().slice(0,10)}static later(t,e,o){return t?.answered(e,o).then(s=>({...s,...u.found(s)?{dates:{lamps:u.today()}}:{}}))}static found(t){return!!(t?.lamps?.length||t?.signals?.length||t?.crossings?.length||t?.signs?.length)}static query(t){const e=u.ON_ROAD;return`[out:json][timeout:25];(node["highway"="street_lamp"](${t});way["highway"]["lit"="yes"](${t});node["highway"~"${e}"](${t});node["traffic_sign"](${t});way["footway"="crossing"](${t}););out geom;(node._["highway"~"${e}"];node._["traffic_sign"];)->.kerb;way(bn.kerb)["highway"];out geom;`}static pending=new Map;async near(t,e){const o=this.ask(u.boxOf(t,e)),s=this.local(t,e);let n;const a=Symbol("late"),r=new Promise(i=>{n=setTimeout(()=>i(a),G.PATIENCE_MS)});try{const[i,h]=await Promise.all([Promise.race([o,r]),Promise.race([s,r])]),c=h===a?void 0:h;return i===a||i===void 0?{...u.withLocal({},c),incomplete:!0}:u.withLocal(u.from(i,t,e),c)}finally{clearTimeout(n)}}static RETRY_DELAYS_MS=[15e3,6e4,18e4,6e5];async answered(t,e){const o=u.boxOf(t,e);for(let s=0;;s++){const n=await this.ask(o);if(n)return u.withLocal(u.from(n,t,e),await this.local(t,e));if(s>=u.RETRY_DELAYS_MS.length)throw new Error("Overpass did not answer");await new Promise(a=>setTimeout(a,u.RETRY_DELAYS_MS[s]))}}ask(t){let e=u.pending.get(t);return e||(e=this.client.query(u.query(t)).catch(()=>{u.pending.delete(t)}),u.pending.set(t,e)),e}static boxOf(t,e){const o=e/u.METRES_PER_DEGREE,s=e/(u.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180));return[t.lat-o,t.lng-s,t.lat+o,t.lng+s].map(n=>n.toFixed(6)).join(",")}static forget(){u.pending.clear(),u.localPending.clear()}static from(t,e,o){const s=G.lampsFrom(t,e,o),n=Math.cos(e.lat*Math.PI/180),a=(p,A)=>[(A-e.lng)*u.METRES_PER_DEGREE*n,(p-e.lat)*u.METRES_PER_DEGREE],r=(p,A)=>`${p.toFixed(7)},${A.toFixed(7)}`,i=new Map,h=new Set,c=[],l=[];for(const p of t.elements??[]){if(p.type==="node"){typeof p.lat=="number"&&typeof p.lon=="number"&&l.push(p);continue}if(p.type!=="way"||!p.geometry||p.geometry.length<2)continue;if(p.id!==void 0){if(h.has(p.id))continue;h.add(p.id)}const A=p.tags??{};if(A.footway==="crossing"&&c.push(p),!u.ROADS.has(A.highway??""))continue;const y=p.geometry.map(R=>a(R.lat,R.lon));p.geometry.forEach((R,x)=>{const $=r(R.lat,R.lon);i.set($,[...i.get($)??[],{way:p,points:y,index:x}])})}const f=[],M=[],d=[],g=new Set;for(const p of l){if(p.id!==void 0){if(g.has(p.id))continue;g.add(p.id)}const A=p.tags??{},y=a(p.lat,p.lon),R=i.get(r(p.lat,p.lon))??[],x=A.highway;if(x==="traffic_signals")for(const U of u.approaches(R,u.directionOf(A),!1))f.push(u.head(y,U,"vehicles"));if(x==="crossing"||x==="traffic_signals"&&A.crossing!==void 0){const U=R[0];if(U&&u.marked(A)){const P=u.directionAt(U);P&&M.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:u.heading(P),widthM:q.widthOf(U.way.tags??{})}),P&&(A.crossing==="traffic_signals"||A["crossing:signals"]==="yes")&&f.push(...u.pedestrianHeads(y,P,U))}}if(x==="traffic_signals")continue;const $=x==="stop"?{face:"stop"}:x==="give_way"?{face:"give-way"}:u.faceOf(A);if(!$)continue;const z=A.traffic_sign?{code:A.traffic_sign}:{};if(R.length>0){const U=u.approaches(R,u.directionOf(A),!0)[0];if(U){const P=u.head(y,U,"vehicles");d.push({eastM:P.eastM,northM:P.northM,headingDeg:P.headingDeg,...$,...z})}continue}const Y=u.compassOf(A.direction);Y!==void 0&&d.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:(Y+180)%360,...$,...z})}for(const p of c){const A=u.crossingAlong(p,a);A&&!M.some(y=>Math.hypot(y.eastM-A.eastM,y.northM-A.northM)<u.SAME_CROSSING_M)&&M.push(A)}const m=f.filter((p,A)=>!f.slice(0,A).some(y=>y.for===p.for&&Math.hypot(y.eastM-p.eastM,y.northM-p.northM)<u.SAME_HEAD_M&&Math.abs((y.headingDeg-p.headingDeg+540)%360-180)<u.SAME_HEAD_DEG)),E=(p,A)=>p.filter(y=>Math.hypot(y.eastM,y.northM)<=o).sort((y,R)=>Math.hypot(y.eastM,y.northM)-Math.hypot(R.eastM,R.northM)).slice(0,A),v={};s.length>0&&(v.lamps=s);const w={signals:E(m,u.MAX_SIGNALS),crossings:E(M,u.MAX_CROSSINGS),signs:E(d,u.MAX_SIGNS)};return w.signals.length>0&&(v.signals=w.signals),w.crossings.length>0&&(v.crossings=w.crossings),w.signs.length>0&&(v.signs=w.signs),v}static approaches(t,e,o){const s=[];for(const a of t){const r=a.way.tags??{},i=r.oneway==="yes"||r.oneway==="true"||r.oneway==="1"||r.junction==="roundabout"||r.highway==="motorway",h=r.oneway==="-1",{points:c,index:l}=a,f=(d,g)=>{let m=0;for(let E=Math.min(d,g);E<Math.max(d,g);E++)m+=Math.hypot(c[E+1][0]-c[E][0],c[E+1][1]-c[E][1]);return m},M=d=>{const g=c[l][0]-c[d][0],m=c[l][1]-c[d][1],E=Math.hypot(g,m);return E>0?[g/E,m/E]:void 0};if(l>0&&!h){const d=M(l-1);d&&s.push({approach:{unit:d,road:a},toEndM:f(l,c.length-1),forward:!0})}if(l<c.length-1&&!i){const d=M(l+1);d&&s.push({approach:{unit:d,road:a},toEndM:f(0,l),forward:!1})}}const n=e!==void 0&&t.length===1?s.filter(a=>a.forward===(e==="forward")):s;return!o||n.length<=1?n.map(a=>a.approach):[n.reduce((a,r)=>r.toEndM<a.toEndM?r:a).approach]}static head(t,e,o){const[s,n]=e.unit,a=q.widthOf(e.road.way.tags??{})/2+u.KERB_OFFSET_M,r=u.SETBACK_M,i=u.heading(e.unit);return{eastM:u.round(t[0]-s*r+n*a),northM:u.round(t[1]-n*r-s*a),headingDeg:(i+180)%360,for:o,phase:j.phaseOf(i)}}static pedestrianHeads(t,e,o){const s=q.widthOf(o.way.tags??{})/2+u.KERB_OFFSET_M,n=u.heading(e),a=j.phaseOf(n);return[1,-1].map(r=>({eastM:u.round(t[0]+e[1]*s*r),northM:u.round(t[1]-e[0]*s*r),headingDeg:(n+(r===1?270:90))%360,for:"pedestrians",phase:a}))}static crossingAlong(t,e){if(!u.marked(t.tags??{}))return;const o=t.geometry.map(h=>e(h.lat,h.lon)),[s,n]=o[0],[a,r]=o[o.length-1],i=Math.hypot(a-s,r-n);if(!(i<u.MIN_CROSSING_M))return{eastM:u.round((s+a)/2),northM:u.round((n+r)/2),headingDeg:(u.heading([(a-s)/i,(r-n)/i])+90)%360,widthM:Math.round(Math.min(i,u.MAX_CROSSING_M)*10)/10}}static marked(t){const e=t.crossing;return e!=="unmarked"&&e!=="no"&&e!=="informal"&&t["crossing:markings"]!=="no"}static directionAt(t){const{points:e,index:o}=t,[s,n]=o<e.length-1?[e[o],e[o+1]]:[e[o-1],e[o]],a=Math.hypot(n[0]-s[0],n[1]-s[1]);return a>0?[(n[0]-s[0])/a,(n[1]-s[1])/a]:void 0}static directionOf(t){const e=t["traffic_signals:direction"]??t["traffic_sign:direction"]??t.direction;return e==="forward"||e==="backward"?e:void 0}static compassOf(t){if(t===void 0)return;const e=Number.parseFloat(t);if(Number.isFinite(e)&&/^\s*-?\d/.test(t))return(e%360+360)%360;const s=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"].indexOf(t.trim().toUpperCase());return s<0?void 0:s*22.5}static faceOf(t){const e=t.traffic_sign;if(!e||e==="no"||e==="none")return;const o=e.split(/[;,]/).map(s=>s.trim());if(o.some(s=>/stop|:AB4\b|:206\b|:R1-1\b|:B2\b/i.test(s)))return{face:"stop"};if(o.some(s=>/give_way|yield|:AB3a\b|:205\b|:R1-2\b|:B1\b/i.test(s)))return{face:"give-way"};for(const s of o){const n=/maxspeed|:B14\b|:274\b|:C14\b|:R2-1\b/i.test(s)?Number.parseInt(/\[(\d+)\]/.exec(s)?.[1]??t.maxspeed??"",10):Number.NaN;if(Number.isFinite(n)&&n>0)return{face:"speed-limit",value:n}}return{face:"other"}}static heading([t,e]){return Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}static round(t){return Math.round(t*10)/10}}class nt{id="ign-lidar-hd";name="IGN LiDAR HD";attribution="Canopy and roofs © IGN, LiDAR HD (Licence Ouverte 2.0), as surveyed on a day the service does not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The LiDAR HD survey covers France only");const o=C.lidarRadius(e),[s,n,a,r,i]=await Promise.all([this.platform.lidar(t,o),this.platform.photo(t,o).catch(()=>{}),this.furniture?.near(t,e),this.platform.laserDate(t),this.platform.photoDate(t)]);return{trees:new H(s.heights,s.vegetation,s.size,s.size).trees({metresPerPixel:s.metresPerPixel,radiusM:o}),buildings:_.fit(N.fit(new D(s.heights,s.building,s.size,s.size).buildings({metresPerPixel:s.metresPerPixel,radiusM:o,maxBuildings:300}),s,n)),bridges:[],lines:[],...a,dates:{...r?{laser:r}:{},...n&&i?{photo:i}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class O{static MAP_NATURES={Eglise:"church",Chapelle:"church",Monument:"monument","Tour, donjon":"monument","Fort, blockhaus, casemate":"monument","Arc de triomphe":"monument","Arène ou théâtre antique":"monument",Château:"old","Industriel, agricole ou commercial":"works",Serre:"works",Silo:"works"};static MAP_WORKS=new Set(["Industriel","Agricole","Annexe"]);static MAP_CLOSED_AT_NIGHT=new Set(["Commercial et services","Sportif"]);static OSM_CLOSED_AT_NIGHT=new Set(["retail","commercial","office","supermarket","kiosk","sports_hall","sports_centre","stadium","school","university","college","kindergarten","public","civic","government","train_station","transportation"]);static OSM_BUILDINGS={cathedral:"church",church:"church",chapel:"church",basilica:"church",temple:"church",mosque:"church",synagogue:"church",shrine:"church",religious:"church",castle:"old",palace:"old",fortress:"monument",bunker:"monument",triumphal_arch:"monument",industrial:"works",warehouse:"works",barn:"works",farm_auxiliary:"works",shed:"works",hangar:"works",garage:"works",garages:"works",greenhouse:"works",silo:"works",storage_tank:"works",cowshed:"works",stable:"works",sty:"works",manufacture:"works"};static OSM_HISTORIC={church:"church",chapel:"church",monastery:"old",castle:"old",manor:"old",fort:"monument",tower:"monument",monument:"monument",memorial:"monument",city_gate:"monument"};static OLD_BEFORE=1900;static GRAND_FROM_M=15;static GRAND_UP_TO_M=40;static TOWER_SLENDERNESS=2;static CHURCH_PITCH=.7;static CHURCH_ROOF_OF_WALLS=.35;static CHURCH_ROOF_COLOUR="#5a6068";static ofMap(t){const e=O.year(t.date_d_apparition),s=O.MAP_NATURES[String(t.nature??"")]??(t.usage_1==="Religieux"?"church":void 0)??(O.MAP_WORKS.has(String(t.usage_1??""))?"works":void 0)??O.ofYear(e)??O.grand(t),n=O.MAP_CLOSED_AT_NIGHT.has(String(t.usage_1??""));return{...s?{style:s}:{},...e!==void 0?{builtYear:e}:{},...n?{closedAtNight:!0}:{}}}static ofOsm(t){const e=O.year(t.start_date),o=t.historic&&t.historic!=="no"?O.OSM_HISTORIC[t.historic]??"old":void 0,s=t.amenity==="place_of_worship"?"church":void 0,n=O.OSM_BUILDINGS[t.building??""]??o??s??O.ofYear(e),a=O.OSM_CLOSED_AT_NIGHT.has(t.building??"")||t.shop!==void 0&&t.shop!=="no";return{...n?{style:n}:{},...e!==void 0?{builtYear:e}:{},...a?{closedAtNight:!0}:{}}}static year(t){const e=Number(/\b(\d{4})\b/.exec(String(t??""))?.[1]);return Number.isFinite(e)&&e>=1e3&&e<=2100?e:void 0}static fit(t){return t.map(e=>e.style==="church"?O.church(e):e)}static isTower(t){return t.heightM>=O.TOWER_SLENDERNESS*Math.max(t.widthM,t.lengthM)}static church(t){const e=t.roof?.color??O.CHURCH_ROOF_COLOUR;if(O.isTower(t))return{...t,roof:{shape:"flat",riseM:0,color:e}};if(t.roof&&t.roof.shape!=="flat")return t;const o=Math.round(Math.min(O.CHURCH_PITCH*t.lengthM,O.CHURCH_ROOF_OF_WALLS*t.heightM)*10)/10,s={shape:"gable",riseM:o,color:e};return{...t,heightM:Math.round((t.heightM+o)*10)/10,roof:s}}static ofYear(t){return t!==void 0&&t<O.OLD_BEFORE?"old":void 0}static grand(t){const e=Number(t.hauteur),o=Number(t.nombre_d_etages);if(!(Number.isFinite(o)&&o>0)&&!(t.usage_1==="Résidentiel"||t.date_d_apparition))return e>=O.GRAND_FROM_M&&e<=O.GRAND_UP_TO_M?"grand":void 0}}class b{static METRES_PER_DEGREE=111320;static NAMED_NATURES={Silo:"Silo"};static DEFAULT_HEIGHT_M=6;static FLOOR_HEIGHT_M=3;static FINE_M=.5;static COARSE_M=1;static MAX_CELLS=4e4;static RECTANGLE_FILL=.9;static buildings(t,e,o,s=12,n=300,a=[]){const r=[];for(const h of b.reached(t,a,e,o)){const c=h.feature,l=Number(c.properties.nombre_d_etages),f=Number(c.properties.hauteur),M=Number.isFinite(f)&&f>0?f:Number.isFinite(l)&&l>0?l*b.FLOOR_HEIGHT_M:b.DEFAULT_HEIGHT_M,{style:d,builtYear:g,closedAtNight:m}=O.ofMap(c.properties);for(const E of b.rectanglesOf(h.rings,M,s)){const v=_.of(c.properties.materiaux_des_murs,"wall"),w=_.of(c.properties.materiaux_de_la_toiture,"roof"),p=b.NAMED_NATURES[String(c.properties.nature??"")];r.push({...E,...p?{name:p}:{},...Number.isFinite(l)&&l>0?{floors:l}:{},...v?{wallMaterial:v}:{},...w?{roofMaterial:w}:{},...d?{style:d}:{},...g!==void 0?{builtYear:g}:{},...m?{closedAtNight:m}:{}})}}const i=h=>Math.hypot(h.eastM,h.northM);if(r.length>n){const h=c=>(c.heightM+6)*Math.sqrt(c.widthM*c.lengthM)/Math.max(i(c),50);r.sort((c,l)=>h(l)-h(c)),r.length=n}return r.sort((h,c)=>i(h)-i(c)),r}static named(t,e,o){const s=e.map(n=>({name:typeof n.properties.toponyme=="string"?n.properties.toponyme:"",rings:b.rings(n,o)})).filter(n=>n.name.length>0&&n.rings.length>0);return s.length===0?t:t.map(n=>{const a=s.find(r=>b.inside(n.eastM,n.northM,r.rings));return a?{...n,name:a.name}:n})}static reached(t,e,o,s){const n=t.map(i=>({feature:i,rings:b.rings(i,o)})).filter(i=>i.rings.length>0),a=n.map(i=>b.reach(i.rings)<=s),r=e.filter(i=>typeof i.properties.toponyme=="string"&&i.properties.toponyme.length>0).map(i=>b.rings(i,o)).filter(i=>i.length>0);if(r.length>0){const i=n.map(c=>{const l=c.rings[0],f=l.reduce((d,g)=>d+g.east,0)/l.length,M=l.reduce((d,g)=>d+g.north,0)/l.length;return r.findIndex(d=>b.inside(f,M,d))}),h=new Set(i.filter((c,l)=>c>=0&&a[l]));i.forEach((c,l)=>{h.has(c)&&(a[l]=!0)})}return n.filter((i,h)=>a[h])}static reach(t){if(b.inside(0,0,t))return 0;let e=1/0;for(const o of t)for(let s=0;s+1<o.length;s++){const n=o[s],a=o[s+1],r=a.east-n.east,i=a.north-n.north,h=r*r+i*i>0?Math.max(0,Math.min(1,-(n.east*r+n.north*i)/(r*r+i*i))):0;e=Math.min(e,Math.hypot(n.east+h*r,n.north+h*i))}return e}static inside(t,e,o){let s=0;for(const n of o)for(let a=0;a+1<n.length;a++){const r=n[a],i=n[a+1];r.north<=e!=i.north<=e&&r.east+(e-r.north)/(i.north-r.north)*(i.east-r.east)>t&&s++}return s%2===1}static rings(t,e){const o=t.geometry,s=o.type==="Polygon"?[o.coordinates]:o.type==="MultiPolygon"?o.coordinates:[],n=Math.cos(e.lat*Math.PI/180),a=[];for(const r of s)for(const i of r)a.push(i.map(([h,c])=>({east:(h-e.lng)*b.METRES_PER_DEGREE*n,north:(c-e.lat)*b.METRES_PER_DEGREE})));return a}static rectanglesOf(t,e,o){let s=1/0,n=-1/0,a=1/0,r=-1/0;for(const f of t)for(const M of f)s=Math.min(s,M.east),n=Math.max(n,M.east),a=Math.min(a,M.north),r=Math.max(r,M.north);let i=b.FINE_M;(n-s)*(r-a)/(i*i)>b.MAX_CELLS&&(i=b.COARSE_M);const h=[],c=[];for(let f=a+i/2;f<r;f+=i){const M=[];for(const d of t)for(let g=0;g+1<d.length;g++){const m=d[g],E=d[g+1];m.north<=f!=E.north<=f&&M.push(m.east+(f-m.north)/(E.north-m.north)*(E.east-m.east))}M.sort((d,g)=>d-g);for(let d=0;d+1<M.length;d+=2)for(let g=Math.ceil((M[d]-i/2)/i)*i+i/2;g<M[d+1];g+=i)h.push(g),c.push(f)}if(h.length*i*i<o)return[];const l=t.flatMap(f=>f.slice(0,-1).map((M,d)=>({from:M,to:f[d+1]})));return D.ofPoints(h,c,new Array(h.length).fill(e),i,o,b.RECTANGLE_FILL,l)}}class F{id="ign-lidar-topo";name="IGN LiDAR HD + BD TOPO";attribution="Canopy © IGN, LiDAR HD; buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as surveyed on days the services do not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;static BRIDGE_MARGIN_M=30;static MAX_BRIDGE_WINDOWS=8;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The IGN's surveys cover France only");const o=C.radius(e),[s,n,a,r,i,h]=await Promise.allSettled([this.platform.lidar(t,o),this.platform.vectors(t,o,!0),this.platform.photo(t,o),this.furniture?.near(t,e)??Promise.resolve(void 0),this.platform.laserDate(t),this.platform.photoDate(t)]),c=C.lidarRadius(o);if(s.status==="rejected"&&n.status==="rejected")throw s.reason;const l=s.status==="fulfilled"?s.value:void 0,f=n.status==="fulfilled"?n.value:void 0,M=f!==void 0&&f.buildings.length===0&&f.bridges.length===0&&f.lines.length===0;if(s.status==="rejected"&&s.reason instanceof V&&s.reason.reason==="no-coverage"&&M)throw s.reason;return{trees:l?new H(l.heights,l.vegetation,l.size,l.size).trees({metresPerPixel:l.metresPerPixel,radiusM:c}):[],buildings:this.roofed(this.buildings(l,f,t,o),l,a.status==="fulfilled"?a.value:void 0),bridges:f?await this.bridges(f,t,o,l?.structures,c):[],lines:f?X.lines(f,t,o,l?.structures):[],...r.status==="fulfilled"?r.value:{},dates:{...s.status==="fulfilled"&&i.status==="fulfilled"&&i.value?{laser:i.value}:{},...a.status==="fulfilled"&&h.status==="fulfilled"&&h.value?{photo:h.value}:{},...f?.mapDate?{map:f.mapDate}:{},...r.status==="fulfilled"&&u.found(r.value)?{lamps:u.today()}:{}}}}async bridges(t,e,o,s,n){const a=X.bridges(t,e,o,s);let r=0;return Promise.all(a.map(async i=>{if(s!==void 0&&Math.hypot(i.eastM,i.northM)+i.lengthM/2<=n)return i;const h=i.lengthM/2+F.BRIDGE_MARGIN_M;if(r++>=F.MAX_BRIDGE_WINDOWS)return i;const c=et(i.eastM,-i.northM,e.lat,e.lng);try{const l=await this.platform.lidar(c,h),f=X.bridges(t,c,h,l.structures).sort((M,d)=>Math.hypot(M.eastM,M.northM)-Math.hypot(d.eastM,d.northM))[0];return!f||Math.hypot(f.eastM,f.northM)>i.lengthM/2?i:{...f,eastM:X.tenth(f.eastM+i.eastM),northM:X.tenth(f.northM+i.northM)}}catch{return i}}))}roofed(t,e,o){return _.fit(O.fit(N.fit(t,e,o)))}buildings(t,e,o,s){const n=e?b.buildings(e.buildings,o,s,void 0,void 0,e.zones):[],a=n.length>0||t===void 0?n:new D(t.heights,t.building,t.size,t.size).buildings({metresPerPixel:t.metresPerPixel,radiusM:C.lidarRadius(s),maxBuildings:300});return e?b.named(a,e.zones,o):a}}class at{id="ign-bd-topo";name="IGN BD TOPO";attribution="Buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as drawn on a day the service does not give";creditUrl="https://geoservices.ign.fr/bdtopo";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","BD TOPO covers France only");const o=C.radius(e),[s,n,a,r]=await Promise.all([this.platform.vectors(t,o,!0),this.platform.photo(t,o).catch(()=>{}),this.furniture?.near(t,e),this.platform.photoDate(t)]);return{trees:[],buildings:_.fit(O.fit(N.fit(b.named(b.buildings(s.buildings,t,o,void 0,void 0,s.zones),s.zones,t),void 0,n))),bridges:X.bridges(s,t,o,void 0),lines:X.lines(s,t,o,void 0),...a,dates:{...s.mapDate?{map:s.mapDate}:{},...n&&r?{photo:r}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class S{static ROOF_SHAPES={flat:"flat",gabled:"gable",gambrel:"gable",saltbox:"gable","half-hipped":"hip",hipped:"hip",pyramidal:"hip",mansard:"hip",round:"gable",dome:"dome",onion:"dome"};static WALL_MATERIALS={brick:"brick",stone:"stone",granite:"stone",sandstone:"stone",limestone:"stone",concrete:"concrete",cement_block:"block",block:"block",wood:"wood",timber_framing:"wood"};static ROOF_MATERIALS={roof_tiles:"tile",tiles:"tile",tile:"tile",slate:"slate",metal:"zinc",zinc:"zinc",tin:"zinc",copper:"zinc",concrete:"concrete",eternit:"other"};static COLOURS={white:"#e8e6e0",grey:"#8c8c8a",gray:"#8c8c8a",black:"#3a3a3a",red:"#a8483a",brown:"#6e4f38",beige:"#d6c9a8",yellow:"#d8c070",orange:"#c9773a",green:"#5f7a52",blue:"#506a8a",tan:"#c0a37a",cream:"#e6dcc0",pink:"#c99a96",silver:"#b4b6b6"};static height(t){const e=Number.parseFloat((t??"").replace(",","."));return Number.isFinite(e)&&e>=2&&e<=500?e:void 0}static levels(t){const e=Number.parseInt(t??"",10);return Number.isFinite(e)&&e>=1&&e<=150?e:void 0}static roofShape(t){return S.ROOF_SHAPES[(t??"").trim().toLowerCase()]}static wallMaterial(t){return S.WALL_MATERIALS[(t??"").trim().toLowerCase()]}static roofMaterial(t){return S.ROOF_MATERIALS[(t??"").trim().toLowerCase()]}static colour(t){const e=(t??"").trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(e)?e:/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:S.COLOURS[e]}}class W{id="osm-buildings";name="OpenStreetMap buildings";attribution="Buildings © OpenStreetMap contributors (ODbL), as drawn on the day of the data, which a recording is not";creditUrl="https://www.openstreetmap.org/copyright";contemporary=!0;static MAX_RADIUS_M=1500;static MIN_AREA_M2=12;static MAX_BUILDINGS=300;client;furniture;constructor(t={},e){this.client=new tt(t),this.furniture=e}covers(){return!0}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){const o=Math.min(e,W.MAX_RADIUS_M);let s;try{s=await this.client.query(`[out:json][timeout:30];(way["building"](around:${o},${t.lat},${t.lng});relation["building"]["type"="multipolygon"](around:${o},${t.lat},${t.lng}););out geom;`)}catch(r){throw new V("unreachable",r instanceof Error?r.message:String(r))}const n=await this.furniture?.near(t,e),a=(s.osm3s?.timestamp_osm_base??"").slice(0,10);return{trees:[],buildings:_.fit(O.fit(W.buildings(s,t,o))),bridges:[],lines:[],...n,dates:{.../^\d{4}-\d{2}-\d{2}$/.test(a)?{map:a}:{},...u.found(n)?{lamps:u.today()}:{}}}}static buildings(t,e,o){const s=[];for(const n of t.elements??[]){const a=W.ringsOf(n);if(a.length===0)continue;const r=n.tags??{},i=S.levels(r["building:levels"]),h=S.height(r.height),c={geometry:{type:"Polygon",coordinates:a},properties:{...h?{hauteur:h}:{},...i?{nombre_d_etages:i}:{}}};for(const l of b.buildings([c],e,o,W.MIN_AREA_M2,50))s.push(W.described(l,r,h!==void 0))}return s.sort((n,a)=>Math.hypot(n.eastM,n.northM)-Math.hypot(a.eastM,a.northM)),s.slice(0,W.MAX_BUILDINGS)}static ringsOf(t){const e=s=>{if(!s||s.length<4)return;const n=s.map(i=>[i.lon,i.lat]),a=n[0],r=n[n.length-1];return a[0]===r[0]&&a[1]===r[1]?n:void 0};if(t.type==="way"){const s=e(t.geometry);return s?[s]:[]}return(t.members??[]).filter(s=>s.role==="outer").map(s=>e(s.geometry)).filter(s=>s!==void 0).slice(0,1)}static described(t,e,o){const s=S.wallMaterial(e["building:material"]),n=S.roofMaterial(e["roof:material"]),a=S.colour(e["building:colour"]),r=S.colour(e["roof:colour"])??_.roofColor(n),i=S.roofShape(e["roof:shape"]),h=a?{color:a}:void 0;let c,l=t.heightM;if(i==="gable"||i==="hip"||i==="dome"){const g=S.height(e["roof:height"]),m=Math.round((g??Math.min(5,Math.max(1.5,.29*Math.min(t.widthM,t.lengthM))))*10)/10;o||(l=Math.round((t.heightM+m)*10)/10),c={shape:i,riseM:m,...e["roof:orientation"]==="across"?{ridge:"depth"}:{},...r?{color:r}:{}}}else(i==="flat"||r)&&(c={shape:"flat",riseM:0,...r?{color:r}:{}});const{style:f,builtYear:M,closedAtNight:d}=O.ofOsm(e);return{...t,heightM:l,...f?{style:f}:{},...M!==void 0?{builtYear:M}:{},...d?{closedAtNight:d}:{},...e.name?{name:e.name}:{},...s?{wallMaterial:s}:{},...n?{roofMaterial:n}:{},...h?{facade:h}:{},...c?{roof:c}:{}}}}class L{credit={name:"Ville de Paris, Éclairage public",url:"https://opendata.paris.fr/explore/dataset/eclairage-public/",licence:"ODbL",of:"lamps"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/eclairage-public/records";static PAGE=100;static MAX=150;static MAX_PAGES=4;static METRES_PER_DEGREE=111320;static SAME_COLUMN_M=.5;static MIN_HEIGHT_M=2;fetchImpl;constructor(t){this.fetchImpl=t??fetch.bind(globalThis)}covers(t,e){const o=L.BOUNDS;return t>=o.south&&t<=o.north&&e>=o.west&&e<=o.east}async lampsNear(t,e){const o=[];let s=[];for(let n=0;n<L.MAX_PAGES&&s.length<L.MAX;n++){const a=await this.fetchImpl(L.query(t,e,L.PAGE,n*L.PAGE));if(!a.ok)throw new Error(`opendata.paris.fr refused (${a.status})`);const r=(await a.json()).results??[];if(o.push(...r),s=L.lampsFrom(o,t),r.length<L.PAGE)break}return s.slice(0,L.MAX)}static query(t,e,o,s){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_ouvrag,lampe_temperature_couleur,lampe_flux,support_hauteur",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(o),offset:String(s)});return`${L.ENDPOINT}?${a}`}static lampsFrom(t,e){const o=Math.cos(e.lat*Math.PI/180),s=a=>{const r=typeof a=="number"?a:Number.parseFloat(a??"");return Number.isFinite(r)&&r>0?r:void 0},n=[];for(const a of t){const r=a.geo_point_2d;if(!r||a.lib_ouvrag==="Projecteur")continue;const i=Math.round((r.lon-e.lng)*L.METRES_PER_DEGREE*o*10)/10,h=Math.round((r.lat-e.lat)*L.METRES_PER_DEGREE*10)/10,c=s(a.lampe_flux),l=n.find(d=>Math.hypot(d.eastM-i,d.northM-h)<L.SAME_COLUMN_M);if(l){c!==void 0&&(l.lumens=(l.lumens??0)+c);continue}const f=s(a.lampe_temperature_couleur),M=s(a.support_hauteur);n.push({eastM:i,northM:h,...M!==void 0&&M>=L.MIN_HEIGHT_M?{heightM:M}:{},...f!==void 0?{colorTemperatureK:f}:{},...c!==void 0?{lumens:c}:{},...a.lib_ouvrag==="Console"?{mount:"wall"}:{}})}return n}}class T{constructor(t,e){this.roads=t,this.fetchImpl=e??fetch.bind(globalThis)}credit={name:"Ville de Paris, Signalisation lumineuse tricolore",url:"https://opendata.paris.fr/explore/dataset/signalisation-tricolore/",licence:"ODbL",of:"signals"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/signalisation-tricolore/records";static PAGE=100;static MAX_PAGES=5;static MAX=160;static METRES_PER_DEGREE=111320;static SAME_POST_M=.8;static SEARCH_M=15;static PEDESTRIAN_ALONG_M=.4;fetchImpl;covers(t,e){const o=T.BOUNDS;return t>=o.south&&t<=o.north&&e>=o.west&&e<=o.east}async signalsNear(t,e){const o=(e+T.SEARCH_M)/T.METRES_PER_DEGREE,s=o/Math.cos(t.lat*Math.PI/180),[n,a]=await Promise.all([this.lenses(t,e),this.roads.getRoads({south:t.lat-o,north:t.lat+o,west:t.lng-s,east:t.lng+s})]);return T.signalsFrom(n,a,t)}async lenses(t,e){const o=[];for(let s=0;s<T.MAX_PAGES;s++){const n=await this.fetchImpl(T.query(t,e,T.PAGE,s*T.PAGE));if(!n.ok)throw new Error(`opendata.paris.fr refused (${n.status})`);const a=(await n.json()).results??[];if(o.push(...a),a.length<T.PAGE)break}return o}static query(t,e,o,s){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_regime",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(o),offset:String(s)});return`${T.ENDPOINT}?${a}`}static signalsFrom(t,e,o){const s=Math.cos(o.lat*Math.PI/180),n=(h,c)=>[(c-o.lng)*T.METRES_PER_DEGREE*s,(h-o.lat)*T.METRES_PER_DEGREE],a=[];for(const h of t){if(!h.geo_point_2d)continue;const c=n(h.geo_point_2d.lat,h.geo_point_2d.lon),l=(h.lib_regime??"").toUpperCase(),f=/ROUGE|JAUNE|VERT/.test(l),M=/PASSEZ|ATTENDEZ/.test(l);if(!f&&!M)continue;let d=a.find(g=>Math.hypot(g.at[0]-c[0],g.at[1]-c[1])<T.SAME_POST_M);d||a.push(d={at:c,vehicles:0,pedestrians:0}),f&&d.vehicles++,M&&d.pedestrians++}const r=e.map(h=>({way:h,points:h.points.map(c=>n(c.lat,c.lng))})),i=[];for(const h of a){const c=T.nearestRoad(h.at,r);if(!c)continue;const[l,f]=c.unit,M=T.heading(c.unit),d=(h.at[0]-c.foot[0])*f-(h.at[1]-c.foot[1])*l>=0,g=c.way.direction,m=g==="forward"?M:g==="backward"?(M+180)%360:d?M:(M+180)%360,E=w=>Math.round(w*10)/10,v=w=>E((w%360+360)%360);if(h.vehicles>0&&i.push({eastM:E(h.at[0]),northM:E(h.at[1]),headingDeg:v(m+180),for:"vehicles",phase:j.phaseOf(m)}),h.pedestrians>0){const w=T.heading([c.foot[0]-h.at[0],c.foot[1]-h.at[1]]),p=h.vehicles>0?T.PEDESTRIAN_ALONG_M:0;i.push({eastM:E(h.at[0]+l*p),northM:E(h.at[1]+f*p),headingDeg:v(Number.isNaN(w)?M+90:w),for:"pedestrians",phase:j.phaseOf(M)})}}return i.sort((h,c)=>Math.hypot(h.eastM,h.northM)-Math.hypot(c.eastM,c.northM)).slice(0,T.MAX)}static nearestRoad(t,e){let o;for(const{way:s,points:n}of e)for(let a=1;a<n.length;a++){const[r,i]=n[a-1],[h,c]=n[a],l=Math.hypot(h-r,c-i);if(l===0)continue;const f=[(h-r)/l,(c-i)/l],M=Math.max(0,Math.min(l,(t[0]-r)*f[0]+(t[1]-i)*f[1])),d=[r+f[0]*M,i+f[1]*M],g=Math.hypot(t[0]-d[0],t[1]-d[1]);g<=T.SEARCH_M&&(!o||g<o.distance)&&(o={way:s,unit:f,foot:d,distance:g})}return o}static heading([t,e]){return t===0&&e===0?Number.NaN:Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}}const K=B.point("surroundings").provide(B.BUILT_IN,[{id:"ign-lidar-topo",name:"IGN LiDAR HD + BD TOPO",credit:"© IGN, LiDAR HD and BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new F({},new u({},k.TOWN_LAMPS,k.TOWN_SIGNALS)))},{id:"ign-lidar-hd",name:"IGN LiDAR HD",credit:"© IGN, LiDAR HD, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new nt({},new u({},k.TOWN_LAMPS,k.TOWN_SIGNALS)))},{id:"ign-bd-topo",name:"IGN BD TOPO",credit:"© IGN, BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/bdtopo",create:()=>new I(new at({},new u({},k.TOWN_LAMPS,k.TOWN_SIGNALS)))},{id:"osm-buildings",name:"OpenStreetMap buildings",credit:"Buildings and street lamps © OpenStreetMap contributors (ODbL)",creditUrl:"https://www.openstreetmap.org/copyright",create:()=>new I(new W({},new u({},k.TOWN_LAMPS,k.TOWN_SIGNALS)))}]);class k{static DEFAULT_ID=K[0].id;static WORLD_ID="osm-buildings";static TOWN_LAMPS=[new L];static TOWN_SIGNALS=[new T(new st)];static NONE="none";static byId(t){return t===k.NONE?void 0:K.find(e=>e.id===t)??K[0]}static providerFor(t,e,o){const s=k.byId(t)?.create();if(t!==void 0&&t!==k.DEFAULT_ID)return s?.covers(e,o)?s:void 0;const n=K.find(r=>r.id===k.WORLD_ID).create(),a=[s,n].filter(r=>r!==void 0&&r.covers(e,o));return a.length>1?new ot(a):a[0]}}export{K as SURROUNDINGS_SOURCES,k as SurroundingsSources};
|
|
1
|
+
import{o as V,O as tt,p as q,T as j,q as C,t as X,u as et,v as st,w as B}from"./rr0-sighting-editor.mjs";class I{constructor(t){this.survey=t}static CACHE_NAME="rr0-surroundings";static MAX_AGE_MS=720*3600*1e3;static FORMAT=8;static MAX_STORED=400;static asked=new Map;get id(){return this.survey.id}get name(){return this.survey.name}get attribution(){return this.survey.attribution}get creditUrl(){return this.survey.creditUrl}get contemporary(){return this.survey.contemporary}covers(t,e){return this.survey.covers(t,e)}async getSurroundings(t,e){const o=I.key(this.survey.id,t,e);let s=I.asked.get(o);return s===void 0&&(s=this.recalled(o,t,e),I.asked.set(o,s),s.catch(()=>I.asked.delete(o))),structuredClone(await s)}later(t,e){const o=this.survey.later?.(t,e);if(!o)return;const s=I.key(this.survey.id,t,e);return o.then(n=>{const a=I.partial.get(s);if(a){I.partial.delete(s);const{incomplete:r,...i}=a,h=[...a.credits??[],...n.credits??[]].filter((l,f,M)=>M.findIndex(d=>d.url===l.url)===f),c={...i,...n,dates:{...a.dates,...n.dates},...h.length>0?{credits:h}:{}};I.asked.set(s,Promise.resolve(c)),I.openCache().then(l=>l&&I.store(l,I.request(s),c))}return structuredClone(n)})}static partial=new Map;static forget(){I.partial.clear(),I.asked.clear()}static key(t,e,o){return`${t}/v${I.FORMAT}/${e.lat.toFixed(5)}/${e.lng.toFixed(5)}/${Math.round(o)}`}async recalled(t,e,o){const s=await I.openCache(),n=I.request(t);if(s)try{const r=await s.match(n);if(r){const{savedAt:i,surroundings:h}=await r.json();if(Date.now()-i<I.MAX_AGE_MS)return h;await s.delete(n)}}catch{}const a=await this.survey.getSurroundings(e,o);return a.incomplete?(I.asked.delete(t),I.partial.set(t,structuredClone(a)),a):(s&&I.store(s,n,a),a)}static async store(t,e,o){try{const s={savedAt:Date.now(),surroundings:o};await t.put(e,new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const a of n.slice(0,Math.max(0,n.length-I.MAX_STORED)))await t.delete(a)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(I.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__surroundings__/${encodeURIComponent(t)}`)}}class ot{constructor(t){if(this.candidates=t,t.length===0)throw new Error("A survey needs at least one candidate");this.current=t[0]}current;get id(){return this.current.id}get name(){return this.current.name}get attribution(){return this.current.attribution}get creditUrl(){return this.current.creditUrl}get contemporary(){return this.current.contemporary}covers(t,e){return this.candidates.some(o=>o.covers(t,e))}async getSurroundings(t,e){let o;for(const s of this.candidates)if(s.covers(t.lat,t.lng))try{const n=await s.getSurroundings(t,e);return this.current=s,n}catch(n){if(o??=n,!(n instanceof V))throw n}throw o??new V("no-coverage","No survey reaches this place")}later(t,e){return this.current.later?.(t,e)}}class D{constructor(t,e,o,s){this.heights=t,this.building=e,this.width=o,this.height=s}static ROOF_PERCENTILE=.9;static STEP_M=.9;static RECTANGLE_FILL=.72;static MIN_DEPTH_M=2.5;static MAX_PARTS=24;static MAX_CELLS=640;buildings(t){const e=t.metresPerPixel,o=t.minAreaM2??12,s=new Uint8Array(this.width*this.height),n=[];for(let a=0;a<this.building.length;a++){if(!this.building[a]||s[a])continue;const r=this.patchFrom(a,s);if(!(r.length*e*e<o))for(const i of this.buildingsOf(r,e,o))Math.hypot(i.eastM,i.northM)<=t.radiusM&&n.push(i)}return n.sort((a,r)=>Math.hypot(a.eastM,a.northM)-Math.hypot(r.eastM,r.northM)),n.slice(0,t.maxBuildings??60)}patchFrom(t,e){const o=[],s=[t];for(e[t]=1;s.length>0;){const n=s.pop();o.push(n);const a=n%this.width,r=Math.floor(n/this.width);for(const[i,h]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+i,l=r+h;if(c<0||l<0||c>=this.width||l>=this.height)continue;const f=l*this.width+c;this.building[f]&&!e[f]&&Math.abs(this.heights[f]-this.heights[n])<=D.STEP_M&&(e[f]=1,s.push(f))}}return o}buildingsOf(t,e,o){const s=this.width/2,n=this.height/2,a=[],r=[],i=[];for(const h of t){const c=h%this.width,l=Math.floor(h/this.width);a.push((c+.5-s)*e),r.push((n-l-.5)*e),i.push(this.heights[h])}return D.ofPoints(a,r,i,e,o)}static ofPoints(t,e,o,s,n,a=D.RECTANGLE_FILL,r=[]){const i=[];for(let m=0;m<t.length;m++)for(const[E,v]of[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]])i.push([t[m]+E*s,e[m]+v*s]);const h=D.hull(i),{angle:c,rectangle:l}=D.smallestRectangle(h),f=t.length*s*s,M=(l.maxU-l.minU)*(l.maxV-l.minV);if(f/M>=a||f<4*n)return[D.building(l,c,D.roof(o))];const d=h.map((m,E)=>({from:{east:m[0],north:m[1]},to:{east:h[(E+1)%h.length][0],north:h[(E+1)%h.length][1]}})),g=D.dominantAngles([...r,...d]);return D.parts(t,e,o,g.length>0?g:[c],s,n)}static dominantAngles(t,e=3){const o=new Map;for(const s of t){const n=Math.hypot(s.to.east-s.from.east,s.to.north-s.from.north);if(n<1e-6)continue;const a=(Math.atan2(s.to.north-s.from.north,s.to.east-s.from.east)%(Math.PI/2)+Math.PI/2)%(Math.PI/2),r=Math.round(a/(Math.PI/60));o.set(r,(o.get(r)??0)+n)}return[...o.entries()].sort((s,n)=>n[1]-s[1]).slice(0,e).map(([s])=>s*Math.PI/60)}static parts(t,e,o,s,n,a){let r=t.map((h,c)=>c);const i=[];for(let h=0;h<D.MAX_PARTS&&r.length>0;h++){let c;for(const M of s){const d=D.largestIn(t,e,r,M,n);d&&(c===void 0||d.area>c.area)&&(c=d)}if(c===void 0||c.area<a)break;const l=c.covered;Math.min(c.rectangle.maxU-c.rectangle.minU,c.rectangle.maxV-c.rectangle.minV)>=D.MIN_DEPTH_M&&i.push(D.building(c.rectangle,c.angle,D.roof([...l].map(M=>o[M])))),r=r.filter(M=>!l.has(M))}return i}static largestIn(t,e,o,s,n){const a=Math.cos(s),r=Math.sin(s);let i=1/0,h=-1/0,c=1/0,l=-1/0;const f=[],M=[];for(const A of o){const y=t[A]*a+e[A]*r,R=-t[A]*r+e[A]*a;f.push(y),M.push(R),i=Math.min(i,y),h=Math.max(h,y),c=Math.min(c,R),l=Math.max(l,R)}const d=Math.max(n*Math.SQRT2,Math.max(h-i,l-c)/D.MAX_CELLS),g=Math.max(1,Math.ceil((h-i)/d+1e-9)),m=Math.max(1,Math.ceil((l-c)/d+1e-9)),E=new Uint8Array(g*m),v=o.map((A,y)=>{const R=Math.min(g-1,Math.max(0,Math.floor((f[y]-i)/d))),x=Math.min(m-1,Math.max(0,Math.floor((M[y]-c)/d)));return E[x*g+R]=1,x*g+R}),w=D.largestRectangle(E,g,m);if(w===void 0)return;const p=new Set;return o.forEach((A,y)=>{const R=v[y]%g,x=Math.floor(v[y]/g);R>=w.column&&R<w.column+w.columns&&x>=w.row&&x<w.row+w.rows&&p.add(A)}),{area:w.area*d*d,angle:s,covered:p,rectangle:{minU:i+w.column*d,maxU:i+(w.column+w.columns)*d,minV:c+w.row*d,maxV:c+(w.row+w.rows)*d}}}static largestRectangle(t,e,o){const s=new Array(e).fill(0);let n;for(let a=0;a<o;a++){for(let i=0;i<e;i++)s[i]=t[a*e+i]?s[i]+1:0;const r=[];for(let i=0;i<=e;i++){const h=i===e?0:s[i];for(;r.length>0&&s[r[r.length-1]]>=h;){const c=r.pop(),l=r.length===0?i:i-r[r.length-1]-1,f=s[c]*l;(n===void 0||f>n.area)&&(n={column:i-l,row:a-s[c]+1,columns:l,rows:s[c],area:f})}r.push(i)}}return n}static roof(t){const e=[...t].sort((o,s)=>o-s);return Math.max(2,e[Math.min(e.length-1,Math.floor(e.length*D.ROOF_PERCENTILE))])}static building(t,e,o){const s=Math.cos(e),n=Math.sin(e),a=t.maxU-t.minU,r=t.maxV-t.minV,i=(t.minU+t.maxU)/2,h=(t.minV+t.maxV)/2,l=((90-(a<r?e:e+Math.PI/2)*180/Math.PI)%180+180)%180;return{eastM:D.tenth(i*s-h*n),northM:D.tenth(i*n+h*s),widthM:D.tenth(Math.max(a,r)),lengthM:D.tenth(Math.min(a,r)),heightM:D.tenth(o),headingDeg:Math.round(l*10)/10}}static smallestRectangle(t){let e={area:1/0,angle:0,rectangle:{minU:0,maxU:0,minV:0,maxV:0}};for(let o=0;o<Math.max(1,t.length);o++){const[s,n]=t[o]??[0,0],[a,r]=t[(o+1)%t.length]??[1,0],i=Math.atan2(r-n,a-s),h=Math.cos(i),c=Math.sin(i);let l=1/0,f=-1/0,M=1/0,d=-1/0;for(const[m,E]of t){const v=m*h+E*c,w=-m*c+E*h;l=Math.min(l,v),f=Math.max(f,v),M=Math.min(M,w),d=Math.max(d,w)}const g=(f-l)*(d-M);g<e.area&&(e={area:g,angle:i,rectangle:{minU:l,maxU:f,minV:M,maxV:d}})}return e}static hull(t){const e=[...t].sort((r,i)=>r[0]-i[0]||r[1]-i[1]),o=e.filter((r,i)=>i===0||r[0]!==e[i-1][0]||r[1]!==e[i-1][1]);if(o.length<3)return o;const s=(r,i,h)=>(i[0]-r[0])*(h[1]-r[1])-(i[1]-r[1])*(h[0]-r[0]),n=[];for(const r of o){for(;n.length>=2&&s(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}const a=[];for(const r of[...o].reverse()){for(;a.length>=2&&s(a[a.length-2],a[a.length-1],r)<=0;)a.pop();a.push(r)}return[...n.slice(0,-1),...a.slice(0,-1)]}static tenth(t){return Math.round(t*10)/10}}class H{constructor(t,e,o,s){this.heights=t,this.vegetation=e,this.width=o,this.height=s}static SUMMIT_RADIUS_M=2.5;static CROWN_REACH_M=8;static MAX_WIDTH_M=16;static MIN_WIDTH_M=2;static tenth(t){return Math.round(t*10)/10}trees(t){const e=t.metresPerPixel,o=t.minHeightM??4,s=t.eyeM??1.6,n=t.minElevationDeg??2,a=Math.max(1,Math.round(H.SUMMIT_RADIUS_M/e)),r=Math.round(H.CROWN_REACH_M/e),i=this.width/2,h=this.height/2,c=[];for(let l=0;l<this.height;l++)for(let f=0;f<this.width;f++){const M=this.canopy(f,l);if(M<o)continue;const d=(f+.5-i)*e,g=(h-l-.5)*e,m=Math.hypot(d,g);if(m>t.radiusM||!this.isSummit(f,l,M,a))continue;const E=Math.atan2(M-s,Math.max(m,1))*180/Math.PI;E<n||c.push({tree:{eastM:H.tenth(d),northM:H.tenth(g),heightM:H.tenth(M),widthM:H.tenth(this.crownWidth(f,l,M,e,r))},elevation:E})}return c.sort((l,f)=>f.elevation-l.elevation),c.slice(0,t.maxTrees??150).map(l=>l.tree)}canopy(t,e){if(t<0||e<0||t>=this.width||e>=this.height)return 0;const o=e*this.width+t;return this.vegetation[o]?this.heights[o]:0}isSummit(t,e,o,s){for(let n=-s;n<=s;n++)for(let a=-s;a<=s;a++){if(a===0&&n===0)continue;const r=this.canopy(t+a,e+n);if(r>o||r===o&&(n<0||n===0&&a<0))return!1}return!0}crownWidth(t,e,o,s,n){let a=0;for(let i=-n;i<=n;i++)for(let h=-n;h<=n;h++)Math.hypot(h,i)*s<=H.CROWN_REACH_M&&this.canopy(t+h,e+i)>=o*.5&&a++;const r=2*Math.sqrt(a*s*s/Math.PI);return Math.max(H.MIN_WIDTH_M,Math.min(r,H.MAX_WIDTH_M))}}class _{static WALLS={1:"stone",2:"meuliere",3:"concrete",4:"brick",5:"block",6:"wood",9:"other"};static ROOFS={1:"tile",2:"slate",3:"zinc",4:"concrete",9:"other"};static WALL_COLOURS={stone:"#b9ae9b",meuliere:"#b8a78a",concrete:"#b4b2ac",brick:"#a65f48",block:"#d0c6b2",wood:"#7d5c3e",other:"#c9c0ae"};static PLASTER="#d3cab8";static ROOF_COLOURS={tile:"#a0583f",slate:"#4a5059",zinc:"#8d969c",concrete:"#8f8e8a",other:"#7a7872"};static VARIATION=.12;static OLD_ROOF="#7d858c";static OLD_STOREY_M=3.6;static GRAND_STOREY_M=4.5;static MIN_STOREY_M=2.4;static MAX_STOREY_M=6;static of(t,e){const o=String(t??"").trim();if(!/^\d{1,2}$/.test(o))return;const s=Number(o),n=s%10!==0?s%10:Math.floor(s/10);return(e==="wall"?_.WALLS:_.ROOFS)[String(n)]}static roofColor(t){return t?_.ROOF_COLOURS[t]:void 0}static fit(t){return t.map(e=>{const o=e.style,s={...e.facade,color:e.facade?.color??_.wallColor(e)};o==="church"?s.openings="lancet":o==="monument"||o==="works"?s.openings="plain":(o==="old"||o==="grand")&&(s.openings="tall"),e.closedAtNight&&s.openings!=="plain"&&(s.closedAtNight=!0);const n=_.storeyOf(e);n!==void 0&&o!=="church"&&o!=="monument"&&(s.storeyM=n);const a=o==="old"&&e.roof?.color===void 0?{shape:"flat",riseM:0,...e.roof,color:_.OLD_ROOF}:e.roof;return{...e,facade:s,...a?{roof:a}:{}}})}static storeyOf(t){const e=t.heightM-(t.roof?.riseM??0);if(t.floors&&t.floors>0){const o=e/t.floors;if(o>=_.MIN_STOREY_M&&o<=_.MAX_STOREY_M)return Math.round(o*100)/100}return t.style==="old"?_.OLD_STOREY_M:t.style==="grand"?_.GRAND_STOREY_M:void 0}static wallColor(t){const e=t.style==="church"||t.style==="monument"||t.style==="old",o=t.wallMaterial?_.WALL_COLOURS[t.wallMaterial]:e?_.WALL_COLOURS.stone:_.PLASTER,s=Math.sin(t.eastM*12.9898+t.northM*78.233)*43758.5453,n=1+(s-Math.floor(s)-.5)*2*_.VARIATION,a=r=>Math.max(0,Math.min(255,Math.round(parseInt(o.slice(r,r+2),16)*n))).toString(16).padStart(2,"0");return`#${a(1)}${a(3)}${a(5)}`}}class N{static MIN_RISE_M=1.2;static MIN_EAVES_M=2.5;static MIN_SEEN=.35;static NO_DATA=-9999;static BANDS=7;static INSET_M=.9;static LIFT=1.18;static PEAK=.3;static LEVEL=.45;static fit(t,e,o){return!e&&!o&&!t.some(s=>s.roofMaterial)?t:t.map(s=>{const n=e?N.shapeOf(s,e):void 0,a=(o?N.colorOf(s,o):void 0)??_.roofColor(s.roofMaterial);if(!n&&!a)return s;const r={shape:n?.shape??"flat",...n?.ridge==="depth"?{ridge:"depth"}:{},riseM:n?.riseM??0,...a?{color:a}:{}},i=n&&n.shape!=="flat"?n.topM:s.heightM;return{...s,heightM:i,roof:r}})}static world(t,e,o){const s=t.headingDeg*Math.PI/180;return{east:t.eastM+e*Math.cos(s)+o*Math.sin(s),north:t.northM-e*Math.sin(s)+o*Math.cos(s)}}static shapeOf(t,e){const o=N.BANDS,s=Math.max(e.metresPerPixel,.5),n=t.widthM/2-N.INSET_M,a=t.lengthM/2-N.INSET_M;if(n<=0||a<=0)return;const r=[],i=Array.from({length:o},()=>({sum:0,n:0})),h=Array.from({length:o},()=>({sum:0,n:0}));let c=0;for(let y=-n;y<=n;y+=s)for(let R=-a;R<=a;R+=s){c++;const{east:x,north:$}=N.world(t,y,R),z=Math.floor(x/e.metresPerPixel+e.size/2),Y=Math.floor(e.size/2-$/e.metresPerPixel);if(z<0||Y<0||z>=e.size||Y>=e.size)continue;const k=Y*e.size+z,P=e.heights[k];if(e.vegetation[k]||P===N.NO_DATA||!(P>0))continue;r.push(P);const J=i[Math.min(o-1,Math.floor((y+n)/(2*n)*o))],Q=h[Math.min(o-1,Math.floor((R+a)/(2*a)*o))];J.sum+=P,J.n++,Q.sum+=P,Q.n++}if(c===0||r.length/c<N.MIN_SEEN)return;r.sort((y,R)=>y-R);const l=N.percentile(r,.08),f=N.percentile(r,.92),M=f-l;if(l<N.MIN_EAVES_M||M>Math.min(t.widthM,t.lengthM))return;if(M<N.MIN_RISE_M)return{shape:"flat",riseM:0,topM:f};const d=N.profile(i),g=N.profile(h);if(!d||!g)return;const m=N.peak(g)/M,E=N.peak(d)/M,v=N.spread(d)/M,w=N.spread(g)/M,p=m>=N.PEAK&&v<=N.LEVEL,A=E>=N.PEAK&&w<=N.LEVEL;if(p&&(!A||m>=E))return{shape:"gable",ridge:"width",riseM:M,topM:f};if(A)return{shape:"gable",ridge:"depth",riseM:M,topM:f};if(m>=N.PEAK&&E>=N.PEAK/2)return{shape:"hip",ridge:"width",riseM:M,topM:f}}static profile(t){const e=t.map(o=>o.n>0?o.sum/o.n:NaN);return e.filter(Number.isFinite).length>=t.length-1?e.map((o,s)=>Number.isFinite(o)?o:N.neighbour(e,s)):void 0}static neighbour(t,e){return Number.isFinite(t[e-1])?t[e-1]:t[e+1]}static peak(t){const e=Math.max(1,Math.floor(t.length/3)),o=n=>n.reduce((a,r)=>a+r,0)/n.length,s=[...t.slice(0,e),...t.slice(t.length-e)];return o(t.slice(e,t.length-e))-o(s)}static spread(t){return Math.max(...t)-Math.min(...t)}static percentile(t,e){return t[Math.min(t.length-1,Math.floor(t.length*e))]}static colorOf(t,e){const o=Math.max(e.metresPerPixel,.5),s=Math.max(t.widthM/2-N.INSET_M,o),n=Math.max(t.lengthM/2-N.INSET_M,o),a=[],r=[],i=[];for(let l=-s;l<=s;l+=o)for(let f=-n;f<=n;f+=o){const{east:M,north:d}=N.world(t,l,f),g=Math.floor(M/e.metresPerPixel+e.size/2),m=Math.floor(e.size/2-d/e.metresPerPixel);if(g<0||m<0||g>=e.size||m>=e.size)continue;const E=(m*e.size+g)*e.samples,v=e.values[E],w=e.values[E+1],p=e.values[E+2];w>v&&w>p||(a.push(v),r.push(w),i.push(p))}if(a.length===0)return;const h=l=>l.sort((f,M)=>f-M)[Math.floor(l.length/2)],c=l=>Math.min(255,Math.round(l*N.LIFT)).toString(16).padStart(2,"0");return`#${c(h(a))}${c(h(r))}${c(h(i))}`}}class G{static DEFAULT_HEIGHT_M=6;static METRES_PER_DEGREE=111320;static STREET_SPACING_M=35;static KERB_OFFSET_M=1;static DEFAULT_WIDTH_M=5.5;static PATIENCE_MS=15e3;static MAX=150;static lampsFrom(t,e,o){const s=[],n=new Set;for(const r of t.elements??[]){if(r.id!==void 0){const l=`${r.type}/${r.id}`;if(n.has(l))continue;n.add(l)}if(r.type==="way"){r.tags?.lit==="yes"&&G.alongStreet(r,e,s);continue}if(r.tags?.highway!=="street_lamp"||typeof r.lat!="number"||typeof r.lon!="number")continue;const i=(r.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),h=(r.lat-e.lat)*G.METRES_PER_DEGREE;if(Math.hypot(i,h)>o)continue;const c=Number.parseFloat(r.tags?.height??"");s.push({eastM:Math.round(i*10)/10,northM:Math.round(h*10)/10,...Number.isFinite(c)&&c>=2&&c<=20?{heightM:c}:{}})}const a=s.filter(r=>Math.hypot(r.eastM,r.northM)<=o);return s.length=0,s.push(...a),s.sort((r,i)=>Math.hypot(r.eastM,r.northM)-Math.hypot(i.eastM,i.northM)),s.slice(0,G.MAX)}static alongStreet(t,e,o){const s=t.geometry;if(!s||s.length<2)return;const n=d=>[(d.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),(d.lat-e.lat)*G.METRES_PER_DEGREE],a=s.map(n),r=Number.parseFloat(t.tags?.width??""),i=Number.parseInt(t.tags?.lanes??"",10),c=(Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*3.5:G.DEFAULT_WIDTH_M)/2+G.KERB_OFFSET_M;let l=1,f=G.STREET_SPACING_M/2,M=0;for(let d=1;d<a.length;d++){const[g,m]=a[d-1],[E,v]=a[d],w=Math.hypot(E-g,v-m);if(w===0)continue;const p=(E-g)/w,A=(v-m)/w;for(;f<=M+w;f+=G.STREET_SPACING_M){const y=f-M;o.push({eastM:Math.round((g+p*y+A*c*l)*10)/10,northM:Math.round((m+A*y-p*c*l)*10)/10,supposed:!0}),l=-l}M+=w}}}class u{constructor(t={},e=[],o=[]){this.lampSources=e,this.signalSources=o,this.client=new tt(t)}static METRES_PER_DEGREE=111320;static KERB_OFFSET_M=.6;static SETBACK_M=.5;static MIN_CROSSING_M=3;static MAX_CROSSING_M=30;static SAME_CROSSING_M=5;static SAME_HEAD_M=2.5;static SAME_HEAD_DEG=45;static MAX_SIGNALS=160;static MAX_CROSSINGS=150;static MAX_SIGNS=100;static ROADS=new Set([...q.DRIVABLE,"living_street","busway","road"]);static ON_ROAD="^(traffic_signals|crossing|stop|give_way)$";static CREDIT={name:"OpenStreetMap",url:"https://www.openstreetmap.org/copyright",licence:"ODbL"};client;local(t,e){const o=u.boxOf(t,e),s=(r,i)=>{if(!r)return Promise.resolve(void 0);const h=`${r.credit.url} ${o}`;let c=u.localPending.get(h);return c||(c=i().then(l=>({credit:r.credit,found:l}),()=>{u.localPending.delete(h)}),u.localPending.set(h,c)),c},n=this.lampSources.find(r=>r.covers(t.lat,t.lng)),a=this.signalSources.find(r=>r.covers(t.lat,t.lng));return Promise.all([s(n,()=>n.lampsNear(t,e)),s(a,()=>a.signalsNear(t,e))]).then(([r,i])=>({lamps:r,signals:i}))}static localPending=new Map;static withLocal(t,e){const o=e?.lamps?e.lamps.found:t.lamps,s=e?.signals?e.signals.found:t.signals,a=[...u.found({crossings:t.crossings,signs:t.signs,...e?.lamps?{}:{lamps:o},...e?.signals?{}:{signals:s}})?[u.CREDIT]:[],...e?.lamps&&e.lamps.found.length>0?[e.lamps.credit]:[],...e?.signals&&e.signals.found.length>0?[e.signals.credit]:[]],{lamps:r,signals:i,credits:h,...c}=t;return{...c,...o?.length?{lamps:o}:{},...s?.length?{signals:s}:{},...a.length>0?{credits:a}:{}}}static today(){return new Date().toISOString().slice(0,10)}static later(t,e,o){return t?.answered(e,o).then(s=>({...s,...u.found(s)?{dates:{lamps:u.today()}}:{}}))}static found(t){return!!(t?.lamps?.length||t?.signals?.length||t?.crossings?.length||t?.signs?.length)}static query(t){const e=u.ON_ROAD;return`[out:json][timeout:25];(node["highway"="street_lamp"](${t});way["highway"]["lit"="yes"](${t});node["highway"~"${e}"](${t});node["traffic_sign"](${t});way["footway"="crossing"](${t}););out geom;(node._["highway"~"${e}"];node._["traffic_sign"];)->.kerb;way(bn.kerb)["highway"];out geom;`}static pending=new Map;async near(t,e){const o=this.ask(u.boxOf(t,e)),s=this.local(t,e);let n;const a=Symbol("late"),r=new Promise(i=>{n=setTimeout(()=>i(a),G.PATIENCE_MS)});try{const[i,h]=await Promise.all([Promise.race([o,r]),Promise.race([s,r])]),c=h===a?void 0:h;return i===a||i===void 0?{...u.withLocal({},c),incomplete:!0}:u.withLocal(u.from(i,t,e),c)}finally{clearTimeout(n)}}static RETRY_DELAYS_MS=[15e3,6e4,18e4,6e5];async answered(t,e){const o=u.boxOf(t,e);for(let s=0;;s++){const n=await this.ask(o);if(n)return u.withLocal(u.from(n,t,e),await this.local(t,e));if(s>=u.RETRY_DELAYS_MS.length)throw new Error("Overpass did not answer");await new Promise(a=>setTimeout(a,u.RETRY_DELAYS_MS[s]))}}ask(t){let e=u.pending.get(t);return e||(e=this.client.query(u.query(t)).catch(()=>{u.pending.delete(t)}),u.pending.set(t,e)),e}static boxOf(t,e){const o=e/u.METRES_PER_DEGREE,s=e/(u.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180));return[t.lat-o,t.lng-s,t.lat+o,t.lng+s].map(n=>n.toFixed(6)).join(",")}static forget(){u.pending.clear(),u.localPending.clear()}static from(t,e,o){const s=G.lampsFrom(t,e,o),n=Math.cos(e.lat*Math.PI/180),a=(p,A)=>[(A-e.lng)*u.METRES_PER_DEGREE*n,(p-e.lat)*u.METRES_PER_DEGREE],r=(p,A)=>`${p.toFixed(7)},${A.toFixed(7)}`,i=new Map,h=new Set,c=[],l=[];for(const p of t.elements??[]){if(p.type==="node"){typeof p.lat=="number"&&typeof p.lon=="number"&&l.push(p);continue}if(p.type!=="way"||!p.geometry||p.geometry.length<2)continue;if(p.id!==void 0){if(h.has(p.id))continue;h.add(p.id)}const A=p.tags??{};if(A.footway==="crossing"&&c.push(p),!u.ROADS.has(A.highway??""))continue;const y=p.geometry.map(R=>a(R.lat,R.lon));p.geometry.forEach((R,x)=>{const $=r(R.lat,R.lon);i.set($,[...i.get($)??[],{way:p,points:y,index:x}])})}const f=[],M=[],d=[],g=new Set;for(const p of l){if(p.id!==void 0){if(g.has(p.id))continue;g.add(p.id)}const A=p.tags??{},y=a(p.lat,p.lon),R=i.get(r(p.lat,p.lon))??[],x=A.highway;if(x==="traffic_signals")for(const k of u.approaches(R,u.directionOf(A),!1))f.push(u.head(y,k,"vehicles"));if(x==="crossing"||x==="traffic_signals"&&A.crossing!==void 0){const k=R[0];if(k&&u.marked(A)){const P=u.directionAt(k);P&&M.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:u.heading(P),widthM:q.widthOf(k.way.tags??{})}),P&&(A.crossing==="traffic_signals"||A["crossing:signals"]==="yes")&&f.push(...u.pedestrianHeads(y,P,k))}}if(x==="traffic_signals")continue;const $=x==="stop"?{face:"stop"}:x==="give_way"?{face:"give-way"}:u.faceOf(A);if(!$)continue;const z=A.traffic_sign?{code:A.traffic_sign}:{};if(R.length>0){const k=u.approaches(R,u.directionOf(A),!0)[0];if(k){const P=u.head(y,k,"vehicles");d.push({eastM:P.eastM,northM:P.northM,headingDeg:P.headingDeg,...$,...z})}continue}const Y=u.compassOf(A.direction);Y!==void 0&&d.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:(Y+180)%360,...$,...z})}for(const p of c){const A=u.crossingAlong(p,a);A&&!M.some(y=>Math.hypot(y.eastM-A.eastM,y.northM-A.northM)<u.SAME_CROSSING_M)&&M.push(A)}const m=f.filter((p,A)=>!f.slice(0,A).some(y=>y.for===p.for&&Math.hypot(y.eastM-p.eastM,y.northM-p.northM)<u.SAME_HEAD_M&&Math.abs((y.headingDeg-p.headingDeg+540)%360-180)<u.SAME_HEAD_DEG)),E=(p,A)=>p.filter(y=>Math.hypot(y.eastM,y.northM)<=o).sort((y,R)=>Math.hypot(y.eastM,y.northM)-Math.hypot(R.eastM,R.northM)).slice(0,A),v={};s.length>0&&(v.lamps=s);const w={signals:E(m,u.MAX_SIGNALS),crossings:E(M,u.MAX_CROSSINGS),signs:E(d,u.MAX_SIGNS)};return w.signals.length>0&&(v.signals=w.signals),w.crossings.length>0&&(v.crossings=w.crossings),w.signs.length>0&&(v.signs=w.signs),v}static approaches(t,e,o){const s=[];for(const a of t){const r=a.way.tags??{},i=r.oneway==="yes"||r.oneway==="true"||r.oneway==="1"||r.junction==="roundabout"||r.highway==="motorway",h=r.oneway==="-1",{points:c,index:l}=a,f=(d,g)=>{let m=0;for(let E=Math.min(d,g);E<Math.max(d,g);E++)m+=Math.hypot(c[E+1][0]-c[E][0],c[E+1][1]-c[E][1]);return m},M=d=>{const g=c[l][0]-c[d][0],m=c[l][1]-c[d][1],E=Math.hypot(g,m);return E>0?[g/E,m/E]:void 0};if(l>0&&!h){const d=M(l-1);d&&s.push({approach:{unit:d,road:a},toEndM:f(l,c.length-1),forward:!0})}if(l<c.length-1&&!i){const d=M(l+1);d&&s.push({approach:{unit:d,road:a},toEndM:f(0,l),forward:!1})}}const n=e!==void 0&&t.length===1?s.filter(a=>a.forward===(e==="forward")):s;return!o||n.length<=1?n.map(a=>a.approach):[n.reduce((a,r)=>r.toEndM<a.toEndM?r:a).approach]}static head(t,e,o){const[s,n]=e.unit,a=q.widthOf(e.road.way.tags??{})/2+u.KERB_OFFSET_M,r=u.SETBACK_M,i=u.heading(e.unit);return{eastM:u.round(t[0]-s*r+n*a),northM:u.round(t[1]-n*r-s*a),headingDeg:(i+180)%360,for:o,phase:j.phaseOf(i)}}static pedestrianHeads(t,e,o){const s=q.widthOf(o.way.tags??{})/2+u.KERB_OFFSET_M,n=u.heading(e),a=j.phaseOf(n);return[1,-1].map(r=>({eastM:u.round(t[0]+e[1]*s*r),northM:u.round(t[1]-e[0]*s*r),headingDeg:(n+(r===1?270:90))%360,for:"pedestrians",phase:a}))}static crossingAlong(t,e){if(!u.marked(t.tags??{}))return;const o=t.geometry.map(h=>e(h.lat,h.lon)),[s,n]=o[0],[a,r]=o[o.length-1],i=Math.hypot(a-s,r-n);if(!(i<u.MIN_CROSSING_M))return{eastM:u.round((s+a)/2),northM:u.round((n+r)/2),headingDeg:(u.heading([(a-s)/i,(r-n)/i])+90)%360,widthM:Math.round(Math.min(i,u.MAX_CROSSING_M)*10)/10}}static marked(t){const e=t.crossing;return e!=="unmarked"&&e!=="no"&&e!=="informal"&&t["crossing:markings"]!=="no"}static directionAt(t){const{points:e,index:o}=t,[s,n]=o<e.length-1?[e[o],e[o+1]]:[e[o-1],e[o]],a=Math.hypot(n[0]-s[0],n[1]-s[1]);return a>0?[(n[0]-s[0])/a,(n[1]-s[1])/a]:void 0}static directionOf(t){const e=t["traffic_signals:direction"]??t["traffic_sign:direction"]??t.direction;return e==="forward"||e==="backward"?e:void 0}static compassOf(t){if(t===void 0)return;const e=Number.parseFloat(t);if(Number.isFinite(e)&&/^\s*-?\d/.test(t))return(e%360+360)%360;const s=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"].indexOf(t.trim().toUpperCase());return s<0?void 0:s*22.5}static faceOf(t){const e=t.traffic_sign;if(!e||e==="no"||e==="none")return;const o=e.split(/[;,]/).map(s=>s.trim());if(o.some(s=>/stop|:AB4\b|:206\b|:R1-1\b|:B2\b/i.test(s)))return{face:"stop"};if(o.some(s=>/give_way|yield|:AB3a\b|:205\b|:R1-2\b|:B1\b/i.test(s)))return{face:"give-way"};for(const s of o){const n=/maxspeed|:B14\b|:274\b|:C14\b|:R2-1\b/i.test(s)?Number.parseInt(/\[(\d+)\]/.exec(s)?.[1]??t.maxspeed??"",10):Number.NaN;if(Number.isFinite(n)&&n>0)return{face:"speed-limit",value:n}}return{face:"other"}}static heading([t,e]){return Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}static round(t){return Math.round(t*10)/10}}class nt{id="ign-lidar-hd";name="IGN LiDAR HD";attribution="Canopy and roofs © IGN, LiDAR HD (Licence Ouverte 2.0), as surveyed on a day the service does not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The LiDAR HD survey covers France only");const o=C.lidarRadius(e),[s,n,a,r,i]=await Promise.all([this.platform.lidar(t,o),this.platform.photo(t,o).catch(()=>{}),this.furniture?.near(t,e),this.platform.laserDate(t),this.platform.photoDate(t)]);return{trees:new H(s.heights,s.vegetation,s.size,s.size).trees({metresPerPixel:s.metresPerPixel,radiusM:o}),buildings:_.fit(N.fit(new D(s.heights,s.building,s.size,s.size).buildings({metresPerPixel:s.metresPerPixel,radiusM:o,maxBuildings:300}),s,n)),bridges:[],lines:[],...a,dates:{...r?{laser:r}:{},...n&&i?{photo:i}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class O{static MAP_NATURES={Eglise:"church",Chapelle:"church",Monument:"monument","Tour, donjon":"monument","Fort, blockhaus, casemate":"monument","Arc de triomphe":"monument","Arène ou théâtre antique":"monument",Château:"old","Industriel, agricole ou commercial":"works",Serre:"works",Silo:"works"};static MAP_WORKS=new Set(["Industriel","Agricole","Annexe"]);static MAP_CLOSED_AT_NIGHT=new Set(["Commercial et services","Sportif"]);static OSM_CLOSED_AT_NIGHT=new Set(["retail","commercial","office","supermarket","kiosk","sports_hall","sports_centre","stadium","school","university","college","kindergarten","public","civic","government","train_station","transportation"]);static OSM_BUILDINGS={cathedral:"church",church:"church",chapel:"church",basilica:"church",temple:"church",mosque:"church",synagogue:"church",shrine:"church",religious:"church",castle:"old",palace:"old",fortress:"monument",bunker:"monument",triumphal_arch:"monument",industrial:"works",warehouse:"works",barn:"works",farm_auxiliary:"works",shed:"works",hangar:"works",garage:"works",garages:"works",greenhouse:"works",silo:"works",storage_tank:"works",cowshed:"works",stable:"works",sty:"works",manufacture:"works"};static OSM_HISTORIC={church:"church",chapel:"church",monastery:"old",castle:"old",manor:"old",fort:"monument",tower:"monument",monument:"monument",memorial:"monument",city_gate:"monument"};static OLD_BEFORE=1900;static GRAND_FROM_M=15;static GRAND_UP_TO_M=40;static TOWER_SLENDERNESS=2;static CHURCH_PITCH=.7;static CHURCH_ROOF_OF_WALLS=.35;static CHURCH_ROOF_COLOUR="#5a6068";static ofMap(t){const e=O.year(t.date_d_apparition),s=O.MAP_NATURES[String(t.nature??"")]??(t.usage_1==="Religieux"?"church":void 0)??(O.MAP_WORKS.has(String(t.usage_1??""))?"works":void 0)??O.ofYear(e)??O.grand(t),n=O.MAP_CLOSED_AT_NIGHT.has(String(t.usage_1??""));return{...s?{style:s}:{},...e!==void 0?{builtYear:e}:{},...n?{closedAtNight:!0}:{}}}static ofOsm(t){const e=O.year(t.start_date),o=t.historic&&t.historic!=="no"?O.OSM_HISTORIC[t.historic]??"old":void 0,s=t.amenity==="place_of_worship"?"church":void 0,n=O.OSM_BUILDINGS[t.building??""]??o??s??O.ofYear(e),a=O.OSM_CLOSED_AT_NIGHT.has(t.building??"")||t.shop!==void 0&&t.shop!=="no";return{...n?{style:n}:{},...e!==void 0?{builtYear:e}:{},...a?{closedAtNight:!0}:{}}}static year(t){const e=Number(/\b(\d{4})\b/.exec(String(t??""))?.[1]);return Number.isFinite(e)&&e>=1e3&&e<=2100?e:void 0}static fit(t){return t.map(e=>e.style==="church"?O.church(e):e)}static isTower(t){return t.heightM>=O.TOWER_SLENDERNESS*Math.max(t.widthM,t.lengthM)}static church(t){const e=t.roof?.color??O.CHURCH_ROOF_COLOUR;if(O.isTower(t))return{...t,roof:{shape:"flat",riseM:0,color:e}};if(t.roof&&t.roof.shape!=="flat")return t;const o=Math.round(Math.min(O.CHURCH_PITCH*t.lengthM,O.CHURCH_ROOF_OF_WALLS*t.heightM)*10)/10,s={shape:"gable",riseM:o,color:e};return{...t,heightM:Math.round((t.heightM+o)*10)/10,roof:s}}static ofYear(t){return t!==void 0&&t<O.OLD_BEFORE?"old":void 0}static grand(t){const e=Number(t.hauteur),o=Number(t.nombre_d_etages);if(!(Number.isFinite(o)&&o>0)&&!(t.usage_1==="Résidentiel"||t.date_d_apparition))return e>=O.GRAND_FROM_M&&e<=O.GRAND_UP_TO_M?"grand":void 0}}class b{static METRES_PER_DEGREE=111320;static NAMED_NATURES={Silo:"Silo"};static DEFAULT_HEIGHT_M=6;static FLOOR_HEIGHT_M=3;static FINE_M=.5;static COARSE_M=1;static MAX_CELLS=4e4;static RECTANGLE_FILL=.9;static buildings(t,e,o,s=12,n=300,a=[]){const r=[];for(const h of b.reached(t,a,e,o)){const c=h.feature,l=Number(c.properties.nombre_d_etages),f=Number(c.properties.hauteur),M=Number.isFinite(f)&&f>0?f:Number.isFinite(l)&&l>0?l*b.FLOOR_HEIGHT_M:b.DEFAULT_HEIGHT_M,{style:d,builtYear:g,closedAtNight:m}=O.ofMap(c.properties);for(const E of b.rectanglesOf(h.rings,M,s)){const v=_.of(c.properties.materiaux_des_murs,"wall"),w=_.of(c.properties.materiaux_de_la_toiture,"roof"),p=b.NAMED_NATURES[String(c.properties.nature??"")];r.push({...E,...p?{name:p}:{},...Number.isFinite(l)&&l>0?{floors:l}:{},...v?{wallMaterial:v}:{},...w?{roofMaterial:w}:{},...d?{style:d}:{},...g!==void 0?{builtYear:g}:{},...m?{closedAtNight:m}:{}})}}const i=h=>Math.hypot(h.eastM,h.northM);if(r.length>n){const h=c=>(c.heightM+6)*Math.sqrt(c.widthM*c.lengthM)/Math.max(i(c),50);r.sort((c,l)=>h(l)-h(c)),r.length=n}return r.sort((h,c)=>i(h)-i(c)),r}static named(t,e,o){const s=e.map(n=>({name:typeof n.properties.toponyme=="string"?n.properties.toponyme:"",rings:b.rings(n,o)})).filter(n=>n.name.length>0&&n.rings.length>0);return s.length===0?t:t.map(n=>{const a=s.find(r=>b.inside(n.eastM,n.northM,r.rings));return a?{...n,name:a.name}:n})}static reached(t,e,o,s){const n=t.map(i=>({feature:i,rings:b.rings(i,o)})).filter(i=>i.rings.length>0),a=n.map(i=>b.reach(i.rings)<=s),r=e.filter(i=>typeof i.properties.toponyme=="string"&&i.properties.toponyme.length>0).map(i=>b.rings(i,o)).filter(i=>i.length>0);if(r.length>0){const i=n.map(c=>{const l=c.rings[0],f=l.reduce((d,g)=>d+g.east,0)/l.length,M=l.reduce((d,g)=>d+g.north,0)/l.length;return r.findIndex(d=>b.inside(f,M,d))}),h=new Set(i.filter((c,l)=>c>=0&&a[l]));i.forEach((c,l)=>{h.has(c)&&(a[l]=!0)})}return n.filter((i,h)=>a[h])}static reach(t){if(b.inside(0,0,t))return 0;let e=1/0;for(const o of t)for(let s=0;s+1<o.length;s++){const n=o[s],a=o[s+1],r=a.east-n.east,i=a.north-n.north,h=r*r+i*i>0?Math.max(0,Math.min(1,-(n.east*r+n.north*i)/(r*r+i*i))):0;e=Math.min(e,Math.hypot(n.east+h*r,n.north+h*i))}return e}static inside(t,e,o){let s=0;for(const n of o)for(let a=0;a+1<n.length;a++){const r=n[a],i=n[a+1];r.north<=e!=i.north<=e&&r.east+(e-r.north)/(i.north-r.north)*(i.east-r.east)>t&&s++}return s%2===1}static rings(t,e){const o=t.geometry,s=o.type==="Polygon"?[o.coordinates]:o.type==="MultiPolygon"?o.coordinates:[],n=Math.cos(e.lat*Math.PI/180),a=[];for(const r of s)for(const i of r)a.push(i.map(([h,c])=>({east:(h-e.lng)*b.METRES_PER_DEGREE*n,north:(c-e.lat)*b.METRES_PER_DEGREE})));return a}static rectanglesOf(t,e,o){let s=1/0,n=-1/0,a=1/0,r=-1/0;for(const f of t)for(const M of f)s=Math.min(s,M.east),n=Math.max(n,M.east),a=Math.min(a,M.north),r=Math.max(r,M.north);let i=b.FINE_M;(n-s)*(r-a)/(i*i)>b.MAX_CELLS&&(i=b.COARSE_M);const h=[],c=[];for(let f=a+i/2;f<r;f+=i){const M=[];for(const d of t)for(let g=0;g+1<d.length;g++){const m=d[g],E=d[g+1];m.north<=f!=E.north<=f&&M.push(m.east+(f-m.north)/(E.north-m.north)*(E.east-m.east))}M.sort((d,g)=>d-g);for(let d=0;d+1<M.length;d+=2)for(let g=Math.ceil((M[d]-i/2)/i)*i+i/2;g<M[d+1];g+=i)h.push(g),c.push(f)}if(h.length*i*i<o)return[];const l=t.flatMap(f=>f.slice(0,-1).map((M,d)=>({from:M,to:f[d+1]})));return D.ofPoints(h,c,new Array(h.length).fill(e),i,o,b.RECTANGLE_FILL,l)}}class F{id="ign-lidar-topo";name="IGN LiDAR HD + BD TOPO";attribution="Canopy © IGN, LiDAR HD; buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as surveyed on days the services do not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;static BRIDGE_MARGIN_M=30;static MAX_BRIDGE_WINDOWS=8;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The IGN's surveys cover France only");const o=C.radius(e),[s,n,a,r,i,h]=await Promise.allSettled([this.platform.lidar(t,o),this.platform.vectors(t,o,!0),this.platform.photo(t,o),this.furniture?.near(t,e)??Promise.resolve(void 0),this.platform.laserDate(t),this.platform.photoDate(t)]),c=C.lidarRadius(o);if(s.status==="rejected"&&n.status==="rejected")throw s.reason;const l=s.status==="fulfilled"?s.value:void 0,f=n.status==="fulfilled"?n.value:void 0,M=f!==void 0&&f.buildings.length===0&&f.bridges.length===0&&f.lines.length===0;if(s.status==="rejected"&&s.reason instanceof V&&s.reason.reason==="no-coverage"&&M)throw s.reason;return{trees:l?new H(l.heights,l.vegetation,l.size,l.size).trees({metresPerPixel:l.metresPerPixel,radiusM:c}):[],buildings:this.roofed(this.buildings(l,f,t,o),l,a.status==="fulfilled"?a.value:void 0),bridges:f?await this.bridges(f,t,o,l?.structures,c):[],lines:f?X.lines(f,t,o,l?.structures):[],...r.status==="fulfilled"?r.value:{},dates:{...s.status==="fulfilled"&&i.status==="fulfilled"&&i.value?{laser:i.value}:{},...a.status==="fulfilled"&&h.status==="fulfilled"&&h.value?{photo:h.value}:{},...f?.mapDate?{map:f.mapDate}:{},...r.status==="fulfilled"&&u.found(r.value)?{lamps:u.today()}:{}}}}async bridges(t,e,o,s,n){const a=X.bridges(t,e,o,s);let r=0;return Promise.all(a.map(async i=>{if(s!==void 0&&Math.hypot(i.eastM,i.northM)+i.lengthM/2<=n)return i;const h=i.lengthM/2+F.BRIDGE_MARGIN_M;if(r++>=F.MAX_BRIDGE_WINDOWS)return i;const c=et(i.eastM,-i.northM,e.lat,e.lng);try{const l=await this.platform.lidar(c,h),f=X.bridges(t,c,h,l.structures).sort((M,d)=>Math.hypot(M.eastM,M.northM)-Math.hypot(d.eastM,d.northM))[0];return!f||Math.hypot(f.eastM,f.northM)>i.lengthM/2?i:{...f,eastM:X.tenth(f.eastM+i.eastM),northM:X.tenth(f.northM+i.northM)}}catch{return i}}))}roofed(t,e,o){return _.fit(O.fit(N.fit(t,e,o)))}buildings(t,e,o,s){const n=e?b.buildings(e.buildings,o,s,void 0,void 0,e.zones):[],a=n.length>0||t===void 0?n:new D(t.heights,t.building,t.size,t.size).buildings({metresPerPixel:t.metresPerPixel,radiusM:C.lidarRadius(s),maxBuildings:300});return e?b.named(a,e.zones,o):a}}class at{id="ign-bd-topo";name="IGN BD TOPO";attribution="Buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as drawn on a day the service does not give";creditUrl="https://geoservices.ign.fr/bdtopo";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","BD TOPO covers France only");const o=C.radius(e),[s,n,a,r]=await Promise.all([this.platform.vectors(t,o,!0),this.platform.photo(t,o).catch(()=>{}),this.furniture?.near(t,e),this.platform.photoDate(t)]);return{trees:[],buildings:_.fit(O.fit(N.fit(b.named(b.buildings(s.buildings,t,o,void 0,void 0,s.zones),s.zones,t),void 0,n))),bridges:X.bridges(s,t,o,void 0),lines:X.lines(s,t,o,void 0),...a,dates:{...s.mapDate?{map:s.mapDate}:{},...n&&r?{photo:r}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class S{static ROOF_SHAPES={flat:"flat",gabled:"gable",gambrel:"gable",saltbox:"gable","half-hipped":"hip",hipped:"hip",pyramidal:"hip",mansard:"hip",round:"gable",dome:"dome",onion:"dome"};static WALL_MATERIALS={brick:"brick",stone:"stone",granite:"stone",sandstone:"stone",limestone:"stone",concrete:"concrete",cement_block:"block",block:"block",wood:"wood",timber_framing:"wood"};static ROOF_MATERIALS={roof_tiles:"tile",tiles:"tile",tile:"tile",slate:"slate",metal:"zinc",zinc:"zinc",tin:"zinc",copper:"zinc",concrete:"concrete",eternit:"other"};static COLOURS={white:"#e8e6e0",grey:"#8c8c8a",gray:"#8c8c8a",black:"#3a3a3a",red:"#a8483a",brown:"#6e4f38",beige:"#d6c9a8",yellow:"#d8c070",orange:"#c9773a",green:"#5f7a52",blue:"#506a8a",tan:"#c0a37a",cream:"#e6dcc0",pink:"#c99a96",silver:"#b4b6b6"};static height(t){const e=Number.parseFloat((t??"").replace(",","."));return Number.isFinite(e)&&e>=2&&e<=500?e:void 0}static levels(t){const e=Number.parseInt(t??"",10);return Number.isFinite(e)&&e>=1&&e<=150?e:void 0}static roofShape(t){return S.ROOF_SHAPES[(t??"").trim().toLowerCase()]}static wallMaterial(t){return S.WALL_MATERIALS[(t??"").trim().toLowerCase()]}static roofMaterial(t){return S.ROOF_MATERIALS[(t??"").trim().toLowerCase()]}static colour(t){const e=(t??"").trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(e)?e:/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:S.COLOURS[e]}}class W{id="osm-buildings";name="OpenStreetMap buildings";attribution="Buildings © OpenStreetMap contributors (ODbL), as drawn on the day of the data, which a recording is not";creditUrl="https://www.openstreetmap.org/copyright";contemporary=!0;static MAX_RADIUS_M=1500;static MIN_AREA_M2=12;static MAX_BUILDINGS=300;client;furniture;constructor(t={},e){this.client=new tt(t),this.furniture=e}covers(){return!0}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){const o=Math.min(e,W.MAX_RADIUS_M);let s;try{s=await this.client.query(`[out:json][timeout:30];(way["building"](around:${o},${t.lat},${t.lng});relation["building"]["type"="multipolygon"](around:${o},${t.lat},${t.lng}););out geom;`)}catch(r){throw new V("unreachable",r instanceof Error?r.message:String(r))}const n=await this.furniture?.near(t,e),a=(s.osm3s?.timestamp_osm_base??"").slice(0,10);return{trees:[],buildings:_.fit(O.fit(W.buildings(s,t,o))),bridges:[],lines:[],...n,dates:{.../^\d{4}-\d{2}-\d{2}$/.test(a)?{map:a}:{},...u.found(n)?{lamps:u.today()}:{}}}}static buildings(t,e,o){const s=[];for(const n of t.elements??[]){const a=W.ringsOf(n);if(a.length===0)continue;const r=n.tags??{},i=S.levels(r["building:levels"]),h=S.height(r.height),c={geometry:{type:"Polygon",coordinates:a},properties:{...h?{hauteur:h}:{},...i?{nombre_d_etages:i}:{}}};for(const l of b.buildings([c],e,o,W.MIN_AREA_M2,50))s.push(W.described(l,r,h!==void 0))}return s.sort((n,a)=>Math.hypot(n.eastM,n.northM)-Math.hypot(a.eastM,a.northM)),s.slice(0,W.MAX_BUILDINGS)}static ringsOf(t){const e=s=>{if(!s||s.length<4)return;const n=s.map(i=>[i.lon,i.lat]),a=n[0],r=n[n.length-1];return a[0]===r[0]&&a[1]===r[1]?n:void 0};if(t.type==="way"){const s=e(t.geometry);return s?[s]:[]}return(t.members??[]).filter(s=>s.role==="outer").map(s=>e(s.geometry)).filter(s=>s!==void 0).slice(0,1)}static described(t,e,o){const s=S.wallMaterial(e["building:material"]),n=S.roofMaterial(e["roof:material"]),a=S.colour(e["building:colour"]),r=S.colour(e["roof:colour"])??_.roofColor(n),i=S.roofShape(e["roof:shape"]),h=a?{color:a}:void 0;let c,l=t.heightM;if(i==="gable"||i==="hip"||i==="dome"){const g=S.height(e["roof:height"]),m=Math.round((g??Math.min(5,Math.max(1.5,.29*Math.min(t.widthM,t.lengthM))))*10)/10;o||(l=Math.round((t.heightM+m)*10)/10),c={shape:i,riseM:m,...e["roof:orientation"]==="across"?{ridge:"depth"}:{},...r?{color:r}:{}}}else(i==="flat"||r)&&(c={shape:"flat",riseM:0,...r?{color:r}:{}});const{style:f,builtYear:M,closedAtNight:d}=O.ofOsm(e);return{...t,heightM:l,...f?{style:f}:{},...M!==void 0?{builtYear:M}:{},...d?{closedAtNight:d}:{},...e.name?{name:e.name}:{},...s?{wallMaterial:s}:{},...n?{roofMaterial:n}:{},...h?{facade:h}:{},...c?{roof:c}:{}}}}class L{credit={name:"Ville de Paris, Éclairage public",url:"https://opendata.paris.fr/explore/dataset/eclairage-public/",licence:"ODbL",of:"lamps"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/eclairage-public/records";static PAGE=100;static MAX=150;static MAX_PAGES=4;static METRES_PER_DEGREE=111320;static SAME_COLUMN_M=.5;static MIN_HEIGHT_M=2;fetchImpl;constructor(t){this.fetchImpl=t??fetch.bind(globalThis)}covers(t,e){const o=L.BOUNDS;return t>=o.south&&t<=o.north&&e>=o.west&&e<=o.east}async lampsNear(t,e){const o=[];let s=[];for(let n=0;n<L.MAX_PAGES&&s.length<L.MAX;n++){const a=await this.fetchImpl(L.query(t,e,L.PAGE,n*L.PAGE));if(!a.ok)throw new Error(`opendata.paris.fr refused (${a.status})`);const r=(await a.json()).results??[];if(o.push(...r),s=L.lampsFrom(o,t),r.length<L.PAGE)break}return s.slice(0,L.MAX)}static query(t,e,o,s){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_ouvrag,lampe_temperature_couleur,lampe_flux,support_hauteur",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(o),offset:String(s)});return`${L.ENDPOINT}?${a}`}static lampsFrom(t,e){const o=Math.cos(e.lat*Math.PI/180),s=a=>{const r=typeof a=="number"?a:Number.parseFloat(a??"");return Number.isFinite(r)&&r>0?r:void 0},n=[];for(const a of t){const r=a.geo_point_2d;if(!r||a.lib_ouvrag==="Projecteur")continue;const i=Math.round((r.lon-e.lng)*L.METRES_PER_DEGREE*o*10)/10,h=Math.round((r.lat-e.lat)*L.METRES_PER_DEGREE*10)/10,c=s(a.lampe_flux),l=n.find(d=>Math.hypot(d.eastM-i,d.northM-h)<L.SAME_COLUMN_M);if(l){c!==void 0&&(l.lumens=(l.lumens??0)+c);continue}const f=s(a.lampe_temperature_couleur),M=s(a.support_hauteur);n.push({eastM:i,northM:h,...M!==void 0&&M>=L.MIN_HEIGHT_M?{heightM:M}:{},...f!==void 0?{colorTemperatureK:f}:{},...c!==void 0?{lumens:c}:{},...a.lib_ouvrag==="Console"?{mount:"wall"}:{}})}return n}}class T{constructor(t,e){this.roads=t,this.fetchImpl=e??fetch.bind(globalThis)}credit={name:"Ville de Paris, Signalisation lumineuse tricolore",url:"https://opendata.paris.fr/explore/dataset/signalisation-tricolore/",licence:"ODbL",of:"signals"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/signalisation-tricolore/records";static PAGE=100;static MAX_PAGES=5;static MAX=160;static METRES_PER_DEGREE=111320;static SAME_POST_M=.8;static SEARCH_M=15;static PEDESTRIAN_ALONG_M=.4;fetchImpl;covers(t,e){const o=T.BOUNDS;return t>=o.south&&t<=o.north&&e>=o.west&&e<=o.east}async signalsNear(t,e){const o=(e+T.SEARCH_M)/T.METRES_PER_DEGREE,s=o/Math.cos(t.lat*Math.PI/180),[n,a]=await Promise.all([this.lenses(t,e),this.roads.getRoads({south:t.lat-o,north:t.lat+o,west:t.lng-s,east:t.lng+s})]);return T.signalsFrom(n,a,t)}async lenses(t,e){const o=[];for(let s=0;s<T.MAX_PAGES;s++){const n=await this.fetchImpl(T.query(t,e,T.PAGE,s*T.PAGE));if(!n.ok)throw new Error(`opendata.paris.fr refused (${n.status})`);const a=(await n.json()).results??[];if(o.push(...a),a.length<T.PAGE)break}return o}static query(t,e,o,s){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_regime",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(o),offset:String(s)});return`${T.ENDPOINT}?${a}`}static signalsFrom(t,e,o){const s=Math.cos(o.lat*Math.PI/180),n=(h,c)=>[(c-o.lng)*T.METRES_PER_DEGREE*s,(h-o.lat)*T.METRES_PER_DEGREE],a=[];for(const h of t){if(!h.geo_point_2d)continue;const c=n(h.geo_point_2d.lat,h.geo_point_2d.lon),l=(h.lib_regime??"").toUpperCase(),f=/ROUGE|JAUNE|VERT/.test(l),M=/PASSEZ|ATTENDEZ/.test(l);if(!f&&!M)continue;let d=a.find(g=>Math.hypot(g.at[0]-c[0],g.at[1]-c[1])<T.SAME_POST_M);d||a.push(d={at:c,vehicles:0,pedestrians:0}),f&&d.vehicles++,M&&d.pedestrians++}const r=e.map(h=>({way:h,points:h.points.map(c=>n(c.lat,c.lng))})),i=[];for(const h of a){const c=T.nearestRoad(h.at,r);if(!c)continue;const[l,f]=c.unit,M=T.heading(c.unit),d=(h.at[0]-c.foot[0])*f-(h.at[1]-c.foot[1])*l>=0,g=c.way.direction,m=g==="forward"?M:g==="backward"?(M+180)%360:d?M:(M+180)%360,E=w=>Math.round(w*10)/10,v=w=>E((w%360+360)%360);if(h.vehicles>0&&i.push({eastM:E(h.at[0]),northM:E(h.at[1]),headingDeg:v(m+180),for:"vehicles",phase:j.phaseOf(m)}),h.pedestrians>0){const w=T.heading([c.foot[0]-h.at[0],c.foot[1]-h.at[1]]),p=h.vehicles>0?T.PEDESTRIAN_ALONG_M:0;i.push({eastM:E(h.at[0]+l*p),northM:E(h.at[1]+f*p),headingDeg:v(Number.isNaN(w)?M+90:w),for:"pedestrians",phase:j.phaseOf(M)})}}return i.sort((h,c)=>Math.hypot(h.eastM,h.northM)-Math.hypot(c.eastM,c.northM)).slice(0,T.MAX)}static nearestRoad(t,e){let o;for(const{way:s,points:n}of e)for(let a=1;a<n.length;a++){const[r,i]=n[a-1],[h,c]=n[a],l=Math.hypot(h-r,c-i);if(l===0)continue;const f=[(h-r)/l,(c-i)/l],M=Math.max(0,Math.min(l,(t[0]-r)*f[0]+(t[1]-i)*f[1])),d=[r+f[0]*M,i+f[1]*M],g=Math.hypot(t[0]-d[0],t[1]-d[1]);g<=T.SEARCH_M&&(!o||g<o.distance)&&(o={way:s,unit:f,foot:d,distance:g})}return o}static heading([t,e]){return t===0&&e===0?Number.NaN:Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}}const K=B.point("surroundings").provide(B.BUILT_IN,[{id:"ign-lidar-topo",name:"IGN LiDAR HD + BD TOPO",credit:"© IGN, LiDAR HD and BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new F({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-lidar-hd",name:"IGN LiDAR HD",credit:"© IGN, LiDAR HD, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new nt({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-bd-topo",name:"IGN BD TOPO",credit:"© IGN, BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/bdtopo",create:()=>new I(new at({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"osm-buildings",name:"OpenStreetMap buildings",credit:"Buildings and street lamps © OpenStreetMap contributors (ODbL)",creditUrl:"https://www.openstreetmap.org/copyright",create:()=>new I(new W({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))}]);class U{static DEFAULT_ID=K[0].id;static WORLD_ID="osm-buildings";static TOWN_LAMPS=[new L];static TOWN_SIGNALS=[new T(new st)];static NONE="none";static byId(t){return t===U.NONE?void 0:K.find(e=>e.id===t)??K[0]}static providerFor(t,e,o){const s=U.byId(t)?.create();if(t!==void 0&&t!==U.DEFAULT_ID)return s?.covers(e,o)?s:void 0;const n=K.find(r=>r.id===U.WORLD_ID).create(),a=[s,n].filter(r=>r!==void 0&&r.covers(e,o));return a.length>1?new ot(a):a[0]}}export{K as SURROUNDINGS_SOURCES,U as SurroundingsSources};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a7 as J,a8 as pt,a9 as W,aa as L,ab as F,ac as U,ad as At,u as $,ae as tt}from"./rr0-sighting-editor.mjs";import{af as Gt}from"./rr0-sighting-editor.mjs";import{C as et}from"./ContrailGrowth-DwHS8If9.js";class m{static OCTAVES=[63,125,250,500,1e3,2e3,4e3,8e3];static STANDARD={temperatureC:15,relativeHumidity:.7,pressureKPa:101.325};static REFERENCE_PRESSURE_KPA=101.325;static REFERENCE_TEMPERATURE_K=293.15;static TRIPLE_POINT_K=273.16;static speedOfSound(t){return 20.0468*Math.sqrt(t+273.15)}static absorptionDbPerKm(t,e=m.STANDARD){const a=e.temperatureC+273.15,n=m.REFERENCE_TEMPERATURE_K,i=e.pressureKPa/m.REFERENCE_PRESSURE_KPA,o=10**(-6.8346*(m.TRIPLE_POINT_K/a)**1.261+4.6151),r=e.relativeHumidity*100*o/i,c=i*(24+40400*r*(.02+r)/(.391+r)),h=i*(a/n)**-.5*(9+280*r*Math.exp(-4.17*((a/n)**(-1/3)-1))),s=t*t;return 8.686*s*(184e-13*(1/i)*Math.sqrt(a/n)+(a/n)**-2.5*(.01275*Math.exp(-2239.1/a)/(c+s/c)+.1068*Math.exp(-3352/a)/(h+s/h)))*1e3}static aWeightingDb(t){const e=t*t,a=12194**2*e*e/((e+20.6**2)*Math.sqrt((e+107.7**2)*(e+737.9**2))*(e+12194**2));return 20*Math.log10(a)+2}static sumDb(t){return 10*Math.log10(t.reduce((e,a)=>e+10**(a/10),0))}}const gt=.25,at=.4,nt=6,z=12,mt=3,it=.2,Et=.2,Mt=24,bt=3,ft=12,st=1,Dt=.7,St=1.5,Rt=.8,It=1.3,rt=.9,ot=5,Ot=25,Bt=.5,Tt=.12,ct=[.13,.31],Nt=.16,vt=1.6,_t=3.6,lt=1.1,Ct=.3,kt=1e3,ut=.7;class x{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}J.isLive(this.context)&&J.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);J.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const i=this.voices.get(n.id)??this.build(t,n);this.retarget(t,i,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const i=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(i)):a.connect(i);const o=t.createGain(),r=e.character?.modulationDepth??0;o.gain.value=1-r/2;const c=t.createOscillator();c.type="sine";const h=t.createGain();h.gain.value=r/2,c.connect(h).connect(o.gain),o.connect(a);const s=t.createBufferSource();s.buffer=this.noise(t),s.loop=!0,s.loopStart=Math.random()*nt*.5;const d=[],l=[],u=[];for(const B of m.OCTAVES){const T=t.createBiquadFilter();T.type="bandpass",T.frequency.value=B,T.Q.value=st;const _=t.createBiquadFilter();_.type="bandpass",_.frequency.value=B,_.Q.value=st;const P=t.createGain();P.gain.value=0,s.connect(T).connect(_).connect(P).connect(o),d.push(T),l.push(_),u.push(P)}const p=[];for(const[B,T]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(B!==void 0)for(let _=1;_<=bt;_++){const P=t.createOscillator();P.type="sine",P.frequency.value=B*_;const Y=t.createGain();Y.gain.value=0,P.connect(Y).connect(a),p.push({oscillator:P,gain:Y,harmonic:_,baseHz:B,share:T??0})}const A=t.createGain();A.gain.value=0,A.connect(a.gain);const M=ct.map(B=>{const T=t.createOscillator();return T.type="sine",T.frequency.value=B,T.connect(A),T}),f=t.createGain();f.gain.value=e.character?.roughness??it;const I=t.createBufferSource();I.buffer=this.roughTable(t,mt),I.loop=!0,I.loopStart=Math.random()*z*.5,I.connect(f).connect(o.gain);const S=t.createGain();S.gain.value=(e.character?.roughness??it)*Et;const b=t.createBufferSource();b.buffer=this.roughTable(t,Mt),b.loop=!0,b.loopStart=Math.random()*z*.5,b.connect(S).connect(o.gain);let N;const K=this.busOf(t)&&this.reverb;K&&(N=t.createGain(),N.gain.value=0,a.connect(N).connect(K));const q=[s,I,b,c,...p.map(B=>B.oscillator),...M];for(const B of q)B.start();const Q={nodes:[a,o,h,f,S,A,...p.map(B=>B.gain),...d,...l,...u,...N?[N]:[],...n?[n]:[],...q],sources:q,filters:d,seconds:l,gains:u,tones:p,lfo:c,lfoDepth:h,wander:M,wanderDepth:A,roughDepth:f,crackleDepth:S,beat:o,output:a,panner:n,send:N};return this.voices.set(e.id,Q),Q}retarget(t,e,a){const n=t.currentTime,i=(p,A)=>p.setTargetAtTime(A,n,gt),o=Math.min(St,Math.max(Dt,a.dopplerRatio)),r=Math.min(It,Math.max(Rt,Math.sqrt(a.dopplerRatio))),c=t.sampleRate*.45,h=a.bandAmplitudes.map((p,A)=>p*x.unweighting(m.OCTAVES[A])),s=Math.sqrt(h.reduce((p,A)=>p+A*A,0)),d=Math.min(1,Math.max(0,(a.distanceKm-ot)/(Ot-ot)));m.OCTAVES.forEach((p,A)=>{i(e.filters[A].frequency,Math.min(c,p*r)),i(e.seconds[A].frequency,Math.min(c,p*r)),i(e.gains[A].gain,h[A]*Math.sqrt(kt/p))});const l=a.character;for(const{oscillator:p,gain:A,harmonic:M,baseHz:f,share:I}of e.tones){const S=f*M;i(p.frequency,S*o);const b=S*o;i(A.gain,b<c?I*Nt*h[x.bandOf(b)]/M:0)}l?.modulationHz!==void 0&&i(e.lfo.frequency,l.modulationHz*o);const u=s>0?ut*(1-Math.exp(-s/ut))/s:1;if(i(e.output.gain,u*(1-Ct*d)),i(e.wanderDepth.gain,u*Tt*d/ct.length),e.send&&i(e.send.gain,vt*d),e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,A=a.inside?0:Math.max(-rt,Math.min(rt,Math.sin(p)))*(1-Bt*d);i(e.panner.pan,A)}}static unweighting(t){return 10**(Math.min(ft,Math.max(0,-m.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return m.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/m.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*z),i=t.createBuffer(1,n,t.sampleRate),o=i.getChannelData(0),r=Array.from({length:z*e},()=>(Math.random()*2-1)**3),c=t.sampleRate/e;for(let h=0;h<o.length;h++){const s=h/c,d=Math.floor(s),l=s-d,u=l*l*(3-2*l);o[h]=r[d%r.length]*(1-u)+r[(d+1)%r.length]*u}return this.roughBuffers.set(e,i),i}roomImpulse(t){const e=Math.floor(t.sampleRate*_t),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const i=a.getChannelData(n);let o=0;for(let r=0;r<e;r++){const c=r/t.sampleRate,h=.6*Math.exp(-c/(lt*2))+.04;o+=h*(Math.random()*2-1-o),i[r]=o*Math.exp(-c/lt)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,at/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},at*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*nt,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class v{static BASE_DB_A=30;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(t){const e=[v.BASE_DB_A,v.along(v.WIND_DB_A,t.windSpeed)];return(t.precipitationType==="rain"||t.precipitationType==="hail")&&e.push(v.along(v.RAIN_DB_A,t.precipitationIntensity)),10*Math.log10(e.filter(a=>a>0).reduce((a,n)=>a+10**(n/10),0))}static bedVolume(t){const e=t.windSpeed>v.WIND_BED_MIN_MS?Math.min(t.windSpeed/v.WIND_BED_FULL_MS,1):0,a=t.precipitationType==="hail"?Math.min(1,t.precipitationIntensity*1.3+.2):t.precipitationType==="rain"?t.precipitationIntensity:0;return Math.hypot(e,a)}static referenceAmplitude(t){return Math.max(v.BED_RMS*v.bedVolume(t),v.MINIMUM_REFERENCE)}static along(t,e){if(e<=t[0][0])return t[0][1];for(let a=1;a<t.length;a++)if(e<=t[a][0]){const[n,i]=t[a-1],[o,r]=t[a];return i+(r-i)*(e-n)/(o-n)}return t[t.length-1][1]}}class y{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?y.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?y.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...y.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class O{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(O.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(O.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<O.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=O.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),i=pt.find(u=>u.id===(n?"helicopter":"airliner")).create(),[o,r]=n?[5,7]:[17,18],c=t.spanM/2/o,h=t.lengthM/2/r,[s,d,l]=O.BRIGHTNESS[t.kind]??[1,1,1];return i.filter(u=>u.id.startsWith("nav")?a.navigation:u.id.startsWith("strobe")?a.strobes:u.id.startsWith("beacon")?a.beacon:!0).filter(u=>!(u.id.startsWith("beacon")&&!a.beacon)).map(u=>{const p=u.id.startsWith("nav")?s:u.id.startsWith("strobe")?d:l;return{...u,offsetM:{x:u.offsetM.x*c,y:u.offsetM.y,z:u.offsetM.z*h},intensity:(u.intensity??1)*p}}).filter(u=>(u.intensity??1)>0)}static landingLights(t,e,a){const n=O.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!O.lampsOn(t.kind,e).navigation)return[];const i=s=>s<O.LANDING_LIGHTS_BELOW_FT;if(!a.some(s=>i(s.altitudeFt)))return[];const o=O.LANDING_INTENSITY*n,r=a.flatMap((s,d)=>d>0&&i(s.altitudeFt)!==i(a[d-1].altitudeFt)?[{t:s.t,intensity:i(s.altitudeFt)?o:0}]:[]),c=t.spanM/34,h=t.lengthM/36;return[-1,1].map(s=>({id:s<0?"landing-left":"landing-right",offsetM:{x:s*5*c,y:-1,z:3*h},color:O.LANDING_COLOR,intensity:i(a[0].altitudeFt)?o:0,pattern:{kind:"steady"},beamDeg:O.LANDING_BEAM_DEG,keyframes:r}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class j{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(j.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?j.BY_TYPE.get(t.toUpperCase()):void 0}}class R{static ID_PREFIX=W.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=R.MAX_OBJECTS,i={}){return new yt(t,e,a,n,i).build()}static idOf(t,e){return W.idOf(t,e)}static keyOf(t){return W.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*R.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=L.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*R.FT_TO_M}),n=a.distanceKm*1e3,i=n*Math.cos(a.altitudeDeg*R.DEG);return{eastM:i*Math.sin(a.azimuthDeg*R.DEG),northM:i*Math.cos(a.azimuthDeg*R.DEG),upM:n*Math.sin(a.altitudeDeg*R.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const i=a[a.length-1];i&&n.t-i.t>F.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/R.DEG+360)%360}}class yt{constructor(t,e,a,n,i){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=i}build(){const t=[];for(const a of this.tracks){const n=R.keyOf(a),i=this.options.models?.get(n)??y.of(void 0);R.segments(a).forEach((o,r)=>{const c=o.map(u=>({point:u,at:R.offsetOf(this.observer,u)}));if(!c.some(u=>u.at.altitudeDeg>=0))return;const h=c.map((u,p)=>({t:u.point.t-this.startMs,eastM:u.at.eastM,northM:u.at.northM,altitudeM:u.at.upM,headingDeg:u.point.trackDeg??(p+1<c.length?R.bearingDeg(u.at,c[p+1].at):R.bearingDeg(c[p-1].at,u.at))})),s=R.idOf(a,r),d=c[Math.floor(c.length/2)].point,l=this.options.sunElevationAt?.(d)??90;t.push({object:{id:s,kind:"aircraft",eastM:h[0].eastM,northM:h[0].northM,headingDeg:h[0].headingDeg,sizeM:R.sizeOf(i),model:j.idOf(i.code)?{id:j.idOf(i.code)}:void 0,color:O.bodyColor(i),lights:[...O.lights(i,l),...O.landingLights(i,l,o.map(u=>({t:u.t-this.startMs,altitudeFt:u.altitudeFt})))],track:h},presence:{fromMs:h[0].t,untilMs:h[h.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:o},closestKm:Math.min(...c.map(u=>u.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const dt=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7}},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7}},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7}},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7}},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-18,-9,-5,-4,-8,-14,-22,-30],character:{toneHz:80,toneShare:.4}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ht=dt.map(w=>({id:w.id,name:w.name,soundPowerA:w.shapeDb.map(t=>t+w.totalDbA-m.sumDb(w.shapeDb)),character:w.character}));class g{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static noiseOfKind(t){const e=dt.find(a=>a.kinds.includes(t));return ht.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=m.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return m.OCTAVES.map((i,o)=>t.soundPowerA[o]-n-m.absorptionDbPerKm(i,a)*e)}static couldBeHeard(t,e,a=g.DEFAULT_AMBIENT_DB_A,n=m.STANDARD){const i=g.ambientBands(a);return g.bandsAt(t,e,n).some((o,r)=>o>=Math.max(i[r]+g.DETECTION_MARGIN_DB,g.HEARING_FLOOR_DB_A))}static ambientBands(t){const e=g.AMBIENT_SHAPE_DB,a=m.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const i=n.air??m.STANDARD,o=m.speedOfSound(i.temperatureC),r=t.points[t.points.length-1]?.t;if(r===void 0)return;let c=Math.min(a,r),h=F.positionAt(t,c);if(!h)return;let s=L.seenFrom(e,h.geo);for(let b=0;b<g.ITERATIONS;b++){const N=a-s.distanceKm*1e3*1e3/o,K=Math.abs(N-c);if(c=N,h=F.positionAt(t,c),!h)return;if(s=L.seenFrom(e,h.geo),K<g.CONVERGED_MS)break}const d=F.positionAt(t,a),l=d?L.seenFrom(e,d.geo):s,u=n.noise??ht[0],p=n.ambientDbA??g.DEFAULT_AMBIENT_DB_A,A=g.ambientBands(p),M=g.bandsAt(u,s.distanceKm,i),f=M.map((b,N)=>b>=Math.max(A[N]+g.DETECTION_MARGIN_DB,g.HEARING_FLOOR_DB_A)),I=M.indexOf(Math.max(...M)),S=f.lastIndexOf(!0);return{track:t,audible:f.some(Boolean),levelDbA:m.sumDb(M),bandsDbA:M,ambientDbA:p,delayS:(a-c)/1e3,emittedAtMs:c,sound:s,seen:l,lagDeg:g.angleBetween(s,l),dopplerRatio:g.doppler(t,e,c,o),dominantHz:m.OCTAVES[I],cutoffHz:S<0?void 0:m.OCTAVES[S]}}static profile(t,e,a,n,i=2e3,o={}){const r=[];let c,h,s=a;for(let d=a;d<=n;d+=i){const l=g.heardAt(t,e,d,o);l&&(!h||l.levelDbA>h.levelDbA)&&(h=l,s=d),l?.audible?c?c.untilMs=d:r.push(c={fromMs:d,untilMs:d}):c=void 0}return{track:t,audible:r,peakDbA:h?.levelDbA??-1/0,peakAtMs:s,peakDelayS:h?.delayS??0}}static angleBetween(t,e){const a=s=>{const d=s.altitudeDeg*Math.PI/180,l=s.azimuthDeg*Math.PI/180;return[Math.cos(d)*Math.sin(l),Math.cos(d)*Math.cos(l),Math.sin(d)]},[n,i,o]=a(t),[r,c,h]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*r+i*c+o*h)))*180/Math.PI}static doppler(t,e,a,n){const i=g.VELOCITY_STEP_MS,o=F.positionAt(t,a-i),r=F.positionAt(t,a+i);if(!o||!r)return 1;const c=L.seenFrom(e,o.geo).distanceKm*1e3,h=L.seenFrom(e,r.geo).distanceKm*1e3;return 1/(1-(c-h)/(2*i/1e3)/n)}}class Ht{static at(t,e,a,n,i={}){const o=F.seenFrom(t,a,n);if(!o)return;const r=y.of(e),c=g.heardAt(t,a,n,{noise:g.noiseOfKind(r.kind),...i});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:r.code??e?.type,name:r.basis==="nothing"?void 0:r.name,kind:r.kind,basis:r.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:o.altitudeFt,groundSpeedKt:o.groundSpeedKt,trackDeg:o.trackDeg,sky:o.sky,angularRateDegPerS:o.angularRateDegPerS,hearing:c&&{audible:c.audible,levelDbA:c.levelDbA,ambientDbA:c.ambientDbA,delayS:c.delayS,lagDeg:c.lagDeg,dopplerRatio:c.dopplerRatio,cutoffHz:c.cutoffHz,dominantHz:c.dominantHz}}}}class D{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1.5;static EXPANSION_RATIO=1.8;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,i={}){const o=new Set;for(const[r,c]of t){const h=g.noiseOfKind(y.of(e.get(a(c))).kind);let s=1/0;for(const d of c.points)s=Math.min(s,L.seenFrom(n,{lat:d.lat,lng:d.lng,heightM:d.altitudeFt*.3048}).distanceKm);g.couldBeHeard(h,s,i.ambientDbA,i.air)&&o.add(r)}return o}static voices(t,e,a,n,i,o,r={}){const c=[];for(const h of t){const s=e.get(h);if(!s||r.only?.(h)===!1)continue;const d=r.kindOf?.(h)??y.of(a.get(n(s))).kind,l=r.noiseOf?.(h)??g.noiseOfKind(d),u=g.heardAt(s,i,o,{...r,noise:l});if(!u?.audible)continue;const p=r.throughDb,A=p?u.bandsDbA.map((M,f)=>M-(p[f]??0)):u.bandsDbA;p&&!D.noticed(A,u.ambientDbA)||c.push({id:h,kind:d,bandAmplitudes:D.bandAmplitudes(A,u.ambientDbA,r.referenceAmplitude),levelDbA:p?m.sumDb(A):u.levelDbA,distanceKm:u.sound.distanceKm,dopplerRatio:u.dopplerRatio,azimuthDeg:u.sound.azimuthDeg,elevationDeg:u.sound.altitudeDeg,character:l.character})}return c.sort((h,s)=>s.levelDbA-h.levelDbA).slice(0,r.maxVoices??D.DEFAULT_MAX_VOICES)}static noticed(t,e){const a=g.ambientBands(e);return t.some((n,i)=>n>=a[i]+g.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=D.REFERENCE_AMPLITUDE){const n=g.ambientBands(e),i=g.DETECTION_MARGIN_DB,o=m.sumDb(t),r=o-e,c=r>=D.KNEE_DB?D.KNEE_DB+(r-D.KNEE_DB)/D.COMPRESSION_RATIO:D.KNEE_DB-(D.KNEE_DB-r)*D.EXPANSION_RATIO,h=a*10**(c/20);return t.map((s,d)=>{const l=Math.min(1,Math.max(0,(s-n[d]-i+D.MASKING_RANGE_DB)/(2*D.MASKING_RANGE_DB)));return l*l*(3-2*l)*h*10**((s-o)/20)})}static BANDS_HZ=m.OCTAVES}class V{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const i=(l,u=0)=>l.toLocaleString(n,{maximumFractionDigits:u}),o=(l,u)=>l.replace(/\{(\w+)\}/g,(p,A)=>u[A]??`{${A}}`),r=[],c=[t.registration,t.name].filter(Boolean).join(" · ");r.push(c||o(e.unnamed,{hex:t.hex}));const h=[o(e.altitude,{value:i(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:o(e.speed,{value:i(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:o(e.heading,{value:i(Math.round(t.trackDeg))})].filter(Boolean);r.push(h.join(" · ")),r.push(o(e.position,{distance:i(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:i(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const s=t.hearing;if(!s)r.push(e.soundUnknown);else if(!s.audible)r.push(o(e.inaudible,{level:i(Math.round(s.levelDbA)),ambient:i(Math.round(s.ambientDbA))}));else{const l=s.cutoffHz??0,u=l<=V.RUMBLE_BELOW_HZ?e.rumble:l<=V.DULL_BELOW_HZ?e.muffled:e.broad,p=s.dopplerRatio-1,A=Math.abs(p)<V.PITCH_NOTICED?"":o(p>0?e.pitchHigher:e.pitchLower,{percent:i(Math.round(Math.abs(p)*100))});r.push(o(e.heard,{level:i(Math.round(s.levelDbA)),delay:i(Math.round(s.delayS)),lag:i(Math.round(s.lagDeg)),character:o(u,{cutoff:i(l)}),pitch:A}))}t.contrail&&r.push(o(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:i(Math.round(t.contrail.iceRelativeHumidity*100))}));const d=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return d.length>0&&r.push(d.join(" · ")),r.push(e.candidate),r.join(`
|
|
2
|
+
`)}}class Z{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return Z.EFFICIENCY[t]}}class E{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*E.FT_TO_M;return e<=E.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:E.TROPOPAUSE_HPA*Math.exp(-(e-E.TROPOPAUSE_M)/E.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*E.saturationOverWaterPa(t)/E.saturationOverIcePa(t)}static mixingSlope(t,e){return E.EMISSION_INDEX_WATER*E.AIR_HEAT_CAPACITY*t*100/(E.MOLAR_MASS_RATIO*E.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(E.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=E.criticalTemperatureC(t,e);return(E.mixingSlope(t,e)*(a-n)+E.saturationOverWaterPa(n))/E.saturationOverWaterPa(a)}static evaluate(t,e){const a=E.criticalTemperatureC(t.pressureHpa,e),n=E.requiredHumidity(t.pressureHpa,e,t.temperatureC),i=E.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),o=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:o,persistent:o&&i>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:i}}}class k{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],i=t[t.length-1];if(e<n.t-k.HOLD_MS||e>i.t+k.HOLD_MS)return;const o=t.findIndex(u=>u.t>e),r=o===0?t[0]:t[(o===-1?t.length:o)-1],c=o===-1||o===0?r:t[o],h=k.atLevel(r,a),s=k.atLevel(c,a);if(!h||!s)return;const d=c.t>r.t?Math.min(1,Math.max(0,(e-r.t)/(c.t-r.t))):0,l=(u,p)=>u+(p-u)*d;return{pressureHpa:a,temperatureC:l(h.temperatureC,s.temperatureC),relativeHumidity:l(h.relativeHumidity,s.relativeHumidity),driftEastMs:l(h.driftEastMs,s.driftEastMs),driftNorthMs:l(h.driftNorthMs,s.driftNorthMs),shearPerS:l(h.shearPerS,s.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const i=a[n],o=a[n+1];if(e>i.pressureHpa||e<o.pressureHpa)continue;const r=(Math.log(i.pressureHpa)-Math.log(e))/(Math.log(i.pressureHpa)-Math.log(o.pressureHpa)),c=(u,p)=>u+(p-u)*r,h=u=>{const p=u.windFromDeg*k.DEG;return{east:-u.windSpeedMs*Math.sin(p),north:-u.windSpeedMs*Math.cos(p)}},s=h(i),d=h(o),l=k.GAS_CONSTANT_OVER_GRAVITY*((i.temperatureC+o.temperatureC)/2+273.15)*Math.log(i.pressureHpa/o.pressureHpa);return{pressureHpa:e,temperatureC:c(i.temperatureC,o.temperatureC),relativeHumidity:c(i.relativeHumidity,o.relativeHumidity),driftEastMs:c(s.east,d.east),driftNorthMs:c(s.north,d.north),shearPerS:Math.hypot(d.east-s.east,d.north-s.north)/l}}}}class H{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const i=[],o=new Map,r=(c,h,s)=>{const d=Math.round(h/H.PRESSURE_STEP_HPA)*H.PRESSURE_STEP_HPA,l=H.SATURATION_STEP_MS,u=Math.floor(c/l)*l,p=`${d}|${u}`,A=o.get(p);if(A!==void 0)return A+(u-c)/1e3;let M=1/0;for(let f=l;f<=H.SATURATION_HORIZON_MS;f+=l){const I=k.at(a,u+f,d);if(!I)break;if(E.evaluate(I,s).iceRelativeHumidity<1){M=f/1e3;break}}return o.set(p,M),M+(u-c)/1e3};for(const c of t.objects){const h=t.flights.get(c.id),s=c.track;if(!h||!s||s.length!==h.points.length)continue;const d=e?.get(W.keyOf(h))??y.of(void 0),l=Z.efficiencyOf(d.kind);if(l===void 0)continue;const u=[];let p=-1/0;s.forEach((A,M)=>{if(A.t<-H.DENSE_MS&&M+1<s.length&&A.t-p<H.SPARSE_STEP_MS)return;p=A.t;const f=h.points[M],I=E.pressureAtAltitudeFt(f.altitudeFt),S=k.at(a,n+A.t,I),b=S&&E.evaluate(S,l);u.push({tMs:A.t,eastM:A.eastM,northM:A.northM,upM:A.altitudeM??0,forms:b?.forms??!1,persistent:b?.persistent??!1,lifetimeS:b?et.lifetimeS(b.iceRelativeHumidity):0,driftEastMs:S?.driftEastMs??0,driftNorthMs:S?.driftNorthMs??0,shearPerS:S?.shearPerS??et.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:b?.iceRelativeHumidity??0,saturatedForS:b?.persistent?r(n+A.t,I,l):0})}),u.some((A,M)=>A.forms&&u[M+1]?.forms)&&i.push({id:c.id,spanM:d.spanM,points:u})}return i}}class C{static DEFAULT_KIND=U.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return U.kindOf(t,e)}static flies(t){return U.flies(t)}voices(t,e,a,n={},i=()=>{}){const o=t.event.place?.[0];if(!o)return[];const r=new Map,c=new Map,h=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3);for(const s of t.decor){const d=U.kindOf(s,i(s));if(!d)continue;const l=`${C.ID_PREFIX}${s.id}`;r.set(l,this.trackOf(s,l,o,h)),c.set(l,d)}for(const s of this.tracks.keys())r.has(s)||this.tracks.delete(s);return r.size===0?[]:D.voices(new Set(r.keys()),r,new Map,s=>String(s.icao),a,e,{...n,kindOf:s=>c.get(s)})}trackOf(t,e,a,n){const i=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),o=this.tracks.get(e);if(o?.key===i)return o.track;const r=[];for(let l=0;l<=n;l+=C.STEP_MS)r.push(C.pointAt(t,l,a));(r.length===0||r[r.length-1].t<n)&&r.push(C.pointAt(t,n,a));const c=r[0],h=r[1]??c,s=l=>(h[l]-c[l])/(h.t-c.t||1);for(let l=C.STEP_MS*10;l<=C.LEAD_MS;l+=C.STEP_MS*10)r.unshift({t:-l,lat:c.lat-s("lat")*l,lng:c.lng-s("lng")*l,altitudeFt:Math.max(0,c.altitudeFt-s("altitudeFt")*l)});const d={icao:C.hash(e),nonIcao:!0,points:r};return this.tracks.set(e,{key:i,track:d}),d}static pointAt(t,e,a){const n=At(t,e),i=$(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:i.lat,lng:i.lng,altitudeFt:n.altitudeM*C.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class X{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static DEFAULT_DB_A=78;static voice(t,e={}){const a=tt.aircraftOf(t);if(!a)return;const n=g.noiseOfKind(a),i=tt.insulationDb(t),o=n.soundPowerA.map((s,d)=>s-i[d]),r=m.sumDb(o),c=X.levelDbA(a,t?.noise),h=o.map(s=>s-r+c);return{id:"observer:cabin",kind:a,bandAmplitudes:D.bandAmplitudes(h,e.ambientDbA??0,e.referenceAmplitude),levelDbA:c,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(X.CABIN_DB_A[t]??X.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class G{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=g.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,i,o,r={}){const c=new Map,h=new Map,s=new Map;for(const l of t){if(!l.sound)continue;const u=`${G.ID_PREFIX}${l.id}`,p=this.trackOf(l,u,e,n,o);p&&(c.set(u,p),h.set(u,l.sound.kind),s.set(u,G.noiseOf(l.sound)))}for(const l of this.tracks.keys())c.has(l)||this.tracks.delete(l);if(c.size===0)return[];const d=$(a.eastM,-a.northM,n.lat,n.lng);return D.voices(new Set(c.keys()),c,new Map,l=>String(l.icao),{lat:d.lat,lng:d.lng,heightM:a.upM},i,{...r,kindOf:l=>h.get(l),noiseOf:l=>s.get(l)})}trackOf(t,e,a,n,i){const o=`${n.lat},${n.lng},${i}`,r=this.tracks.get(e);if(r&&r.body===t&&r.origin===o)return r.track;const c=[];for(let s=-12e4;s<=i;s+=G.STEP_MS){const d=a(t,s);if(!d)continue;const l=$(d.eastM,-d.northM,n.lat,n.lng);c.push({t:s,lat:l.lat,lng:l.lng,altitudeFt:d.upM*G.FT_PER_M})}if(c.length<2)return;const h={icao:G.hash(e),nonIcao:!0,points:c};return this.tracks.set(e,{body:t,origin:o,track:h}),h}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{x as AircraftAudio,H as AircraftContrails,y as AircraftModels,v as AmbientNoise,G as BodyHearing,X as CabinHearing,C as DecorAircraftHearing,R as TrafficDecor,Ht as TrafficInfos,D as TrafficSound,V as TrafficTooltip,Gt as UPPER_AIR_SOURCES};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rr0/ufoathome",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.178.0",
|
|
5
5
|
"description": "UFO@home — record and replay a UFO sighting's shape, movement and appearance",
|
|
6
6
|
"author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@rr0/place": "^0.5.5",
|
|
72
72
|
"@rr0/time": "^2.2.0",
|
|
73
73
|
"astronomy-engine": "^2.1.19",
|
|
74
|
+
"mediabunny": "1.62.1",
|
|
74
75
|
"satellite.js": "6.0.1",
|
|
75
76
|
"three": "^0.185.1",
|
|
76
77
|
"three-mesh-bvh": "0.9.16"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ac as Le,ad as Q,ae as he,af as Me,ag as v,ah as de,c as w,V as pe,C as F,ai as N,$ as U,N as Se,aj as ye,ak as we,v as K,al as Ne,o as C,Y as me,am as be,a5 as ge,an as Ie,ao as Oe,h as V,ap as Ce,aq as Te,ar as Fe,as as Pe,at as He,a0 as J,au as Re,av as Z,aw as ke,ax as De,P as Ge,ay as X,az as ve,e as Ee,K as Ue,J as G,aA as Ke,B as Be,aB as je,d as Ve,aC as Xe,aD as ze,aE as qe,y as We,G as z,aF as Ye,w as Qe,aG as Je,aH as Ze,aI as $e,aJ as en,aK as nn,aL as tn,aM as xe,k as sn,a1 as ne,aN as te,aO as se,aP as ie,aQ as re,aR as rn,aS as on,m as an,n as cn}from"./rr0-scene.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 Nn(i,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:r[l]=new bn;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],N);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],N),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],N)}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],N),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],N),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 Ne(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 be(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 Nn{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,N,h)})})}}class bn{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],b=r[R+E+o]*u,S=r[p+E+a],k=r[p+E]*u;i[E]=A*L+x*b+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),b=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,b[S*o]),o>=2&&m.setY(P,b[S*o+1]),o>=3&&m.setZ(P,b[S*o+2]),o>=4&&m.setW(P,b[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],N),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],N)}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],b=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,b,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!==N&&"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,9 +0,0 @@
|
|
|
1
|
-
import{aT as d,_ as l,b6 as o,b7 as m,b8 as g,b9 as f}from"./rr0-scene.mjs";import{P as u,S as b,a as y,c as T,b as A,E}from"./ParameterForm-BMIW4Gkh.js";const w=d.catalog({en:()=>l(()=>import("./LanternParameterTexts_en-CcnGd8UH.js"),[],import.meta.url).then(a=>a.lanternParameterTexts_en),fr:()=>l(()=>import("./LanternParameterTexts_fr-P2JwYOUy.js"),[],import.meta.url).then(a=>a.lanternParameterTexts_fr),es:()=>l(()=>import("./LanternParameterTexts_es-CUTgNutZ.js"),[],import.meta.url).then(a=>a.lanternParameterTexts_es),it:()=>l(()=>import("./LanternParameterTexts_it-CzNnIUrX.js"),[],import.meta.url).then(a=>a.lanternParameterTexts_it)});class i{static RELEASE="letGo";static LANTERNS="lanterns";static AIR="air";static LANTERN="eachLantern";static instant(e,t,n){return{type:"number",key:e,min:-36e3,max:36e3,step:1,unit:"s",scale:.001,required:!0,label:t,hint:n,group:i.LANTERNS}}static wind(e,t,n,s){return[{type:"number",key:`${e}.towardDeg`,min:0,max:360,step:1,unit:"°",group:i.AIR,hint:s,label:t},{type:"number",key:`${e}.speedMS`,min:0,max:60,step:.1,unit:"m/s",group:i.AIR,label:n}]}static SET={kind:"lantern",title:"skyLanterns",parameters:[{type:"said",key:"title",label:"name",group:i.RELEASE},{type:"position",key:"site.eastM",secondKey:"site.northM",saidKey:"site.saidPosition",native:"local",step:1,rangeM:1e5,group:i.RELEASE,label:"whereTheyAreLetGo",hint:"whereTheyAreLetGoFrom"},{type:"number",key:"site.altitudeM",min:-1e3,max:5e3,step:.1,unit:"m",group:i.RELEASE,effective:()=>0,label:"heightAboveThePlaceSGround",hint:"aGardenOnAHillAbove"},{type:"number",key:"site.originElevationM",min:-500,max:6e3,step:1,unit:"m",group:i.RELEASE,effective:()=>0,label:"thePlaceSGroundAboveThe",hint:"whatSetsHowThinTheAir"},{type:"number",key:"group.count",min:1,max:200,step:1,required:!0,group:i.LANTERNS,label:"howMany"},i.instant("group.fromT","firstLetGoAt","secondsOfTheRecordingBeforeIts"),i.instant("group.untilT","lastLetGoAt","secondsOfTheRecordingTheOthers"),{type:"number",key:"group.radiusM",min:0,max:5e3,step:1,unit:"m",group:i.LANTERNS,effective:()=>20,label:"letGoWithin",hint:"aCrowdLetsThemGoA"},{type:"number",key:"group.burnS.min",min:10,max:3600,step:1,unit:"s",group:i.LANTERNS,effective:()=>480,label:"burnsAtLeast",hint:"howLongEachBurnsFromWhen"},{type:"number",key:"group.burnS.max",min:10,max:3600,step:1,unit:"s",group:i.LANTERNS,effective:()=>900,label:"burnsAtMost"},{type:"number",key:"group.insideExcessK.min",min:10,max:400,step:1,unit:"K",group:i.LANTERNS,effective:()=>125,label:"hotterThanTheAirAtLeast",hint:"howMuchHotterThanTheAir"},{type:"number",key:"group.insideExcessK.max",min:10,max:400,step:1,unit:"K",group:i.LANTERNS,effective:()=>175,label:"hotterThanTheAirAtMost"},{type:"number",key:"group.burnedS",min:0,max:3600,step:1,unit:"s",group:i.LANTERNS,effective:()=>0,label:"alreadyBurntWhenLetGo",hint:"forLanternsTheAccountOnlyHas"},{type:"number",key:"group.seed",min:0,max:4294967295,step:1,group:i.LANTERNS,effective:()=>1,label:"draw",hint:"whatTheDrawsStartFromAnother"},{type:"set",key:"group.explains",group:i.LANTERNS,label:"standForTheShapes",options:(e,t)=>{const n=t?.shapes??[],s=(e.group?.explains??[]).filter(r=>!n.some(h=>h.value===r));return[...n,...s.map(r=>({value:r,label:r}))]},empty:"noShape"},...i.wind("wind","windAtTheGroundTowards","windAtTheGroundSpeed","whereItBlowsTowardsWhichIs"),...i.wind("windAloft","windAloftTowards","windAloftSpeed","theWindHigherUpBlendedWith"),{type:"number",key:"windAloft.atM",min:10,max:1e4,step:10,unit:"m",group:i.AIR,label:"windAloftAt",hint:"metresAboveWhereTheyAreLet"},{type:"number",key:"airTemperatureC",min:-60,max:50,step:.5,unit:"°C",group:i.AIR,effective:()=>10,label:"airTemperature",hint:"atTheGroundFallingBy6"},{type:"number",key:"turbulence.horizontalMS",min:0,max:10,step:.1,unit:"m/s",group:i.AIR,effective:()=>o.TURBULENCE.horizontalMS,label:"gustsAcross",hint:"howFarTheAirSSpeed"},{type:"number",key:"turbulence.verticalMS",min:0,max:10,step:.1,unit:"m/s",group:i.AIR,effective:()=>o.TURBULENCE.verticalMS,label:"gustsUpAndDown"},{type:"number",key:"turbulence.timescaleS",min:1,max:600,step:1,unit:"s",group:i.AIR,effective:()=>o.TURBULENCE.timescaleS,label:"aGustLasts"},{type:"number",key:"lantern.luminousIntensityCd",min:.1,max:1e3,step:.1,unit:"cd",group:i.LANTERN,effective:()=>o.COMMON.luminousIntensityCd,label:"light",hint:"itsFlameSLightThroughThe"},{type:"choice",key:"lantern.shape",group:i.LANTERN,effective:()=>o.COMMON.shape,label:"shape",choices:[{value:"classic",label:"roundAtTheMouthSquareAt"},{value:"balloon",label:"balloonLobedTop"}]},{type:"colour",key:"lantern.paperColor",group:i.LANTERN,fallback:o.COMMON.paperColor,label:"paperColour",hint:"whatItLooksLikeByDay"},{type:"colour",key:"lantern.color",group:i.LANTERN,fallback:o.COMMON.color,label:"flameLight",hint:"itsFlameSLightThroughWhite"},{type:"number",key:"lantern.envelopeVolumeM3",min:.01,max:10,step:.01,unit:"m³",group:i.LANTERN,effective:()=>o.COMMON.envelopeVolumeM3,label:"airItHolds"},{type:"number",key:"lantern.massKg",min:.005,max:5,step:.001,unit:"kg",group:i.LANTERN,effective:()=>o.COMMON.massKg,label:"weightWhenLetGo"}]};static publish(){u.publish(i.SET)}}const v=d.catalog({en:()=>l(()=>import("./LanternEditorMessages_en-DaT3UNfD.js"),[],import.meta.url).then(a=>a.lanternEditorMessages_en),fr:()=>l(()=>import("./LanternEditorMessages_fr-9mByTFMG.js"),[],import.meta.url).then(a=>a.lanternEditorMessages_fr),es:()=>l(()=>import("./LanternEditorMessages_es-TDV5lKeJ.js"),[],import.meta.url).then(a=>a.lanternEditorMessages_es),it:()=>l(()=>import("./LanternEditorMessages_it-MRkJnDQp.js"),[],import.meta.url).then(a=>a.lanternEditorMessages_it)});class p{constructor(e,t,n){this.container=e,this.host=t,b.attach(e,"lantern-editor-part",p.STYLE),this.language=n,u.of("lantern")||i.publish(),this.ready=this.setLanguage(n)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;language;shown=[];static STYLE='.lantern-editor-part { flex-basis: 100%; min-width: 0; } .lantern-editor-part #lantern-list { flex-basis: 100%; min-width: 0; } .lantern-editor-part .launch-editor, .lantern-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .lantern-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .lantern-editor-part [hidden] { display: none !important; } .lantern-editor-part select { min-width: 0; width: 100%; } .lantern-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .lantern-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .lantern-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; } .lantern-editor-part input, .lantern-editor-part select { max-width: 100%; box-sizing: border-box; } .lantern-editor-part input[type="text"] { width: 12em; } .lantern-editor-part label { min-width: 0; max-width: 100%; } .lantern-editor-part input.parameter-derived::placeholder { opacity: .65; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[n,s]=await Promise.all([v.load(e),w.load(e)]);t===this.languageToken&&(this.messages=n,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.launches;this.shown=[...e],e.some(r=>r.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(r=>({id:r.id,label:this.labelOf(r)})),this.currentId),this.syncAddState();const t=this.current;if(this.element("lantern-fields").hidden=t===void 0,!t)return;const n=t.releases?.length??0,s=this.element("lantern-releases");s.hidden=n===0,s.textContent=this.messages.releasesNote.replace("{n}",String(n)),this.form??=new y(this.element("lantern-parameters"),this.language,"lantern.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(i.SET),new T(()=>this.current,r=>this.editLaunch(h=>r(h)),()=>({shapes:this.host.shapes().map(r=>({value:r.id,label:r.label}))}),this.host.positionPlace?.()),()=>this.written())}refresh(){if(!this.messages)return;this.syncAddState();const e=this.launches;e.length===this.shown.length&&e.every((t,n)=>t.id===this.shown[n].id)||this.sync()}syncAddState(){const e=this.siteOfNew()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addLaunchNowhere)}get current(){return this.launches.find(e=>e.id===this.currentId)}resolved(e){return A.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
|
|
2
|
-
<p class="launch-intro">${e.intro}</p>
|
|
3
|
-
<div id="lantern-list"></div>
|
|
4
|
-
<div id="lantern-fields" class="launch-fields">
|
|
5
|
-
<div id="lantern-parameters" class="launch-parameters"></div>
|
|
6
|
-
<p id="lantern-releases" class="launch-intro" hidden></p>
|
|
7
|
-
<p class="launch-intro">${e.derivedNote}</p>
|
|
8
|
-
</div>
|
|
9
|
-
</div>`,this.list=new E({header:this.element("lantern-list"),body:this.element("lantern-fields"),ids:{list:"lantern-select",remove:"lantern-delete",add:"lantern-add"},onSelect:t=>{this.currentId=t,this.sync()},onAdd:()=>this.addLaunch(),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.launch,remove:e.deleteLaunch,add:e.addLaunch,empty:e.none})}written(){const e=this.current;e&&this.list?.rename(e.id,this.labelOf(e))}editLaunch(e){const t=this.current;if(!t)return;const n=structuredClone(t);e(n),this.writeLaunches(this.launches.map(s=>s===t?n:s)),this.host.changed()}siteOfNew(){const e=this.host.sighting(),t=e.event?.place?.[0];if(t?.lat===void 0||t.lng===void 0)return;const n=e.observerTrack?.getInterpolatedPoseAt(0),s=(n?.headingDeg??0)*Math.PI/180,r=111320,h=n?.lng!==void 0?(n.lng-t.lng)*r*Math.cos(t.lat*Math.PI/180):0,c=n?.lat!==void 0?(n.lat-t.lat)*r:0;return{eastM:Math.round(h+1500*Math.sin(s)),northM:Math.round(c+1500*Math.cos(s))}}addLaunch(){const e=this.siteOfNew();if(!e)return;let t=this.launches.length+1;for(;this.launches.some(r=>r.id===`lanterns-${t}`);)t++;const n=m(this.host.sighting(),0),s={id:`lanterns-${t}`,site:e,group:{count:12,fromT:0,untilT:12e4,seed:t},wind:{towardDeg:Math.round((n.windDirectionDeg+180)%360),speedMS:Math.round(n.windSpeed*10)/10}};this.writeLaunches([...this.launches,s]),this.currentId=s.id,this.host.changed(),this.sync()}deleteCurrent(){const e=this.current;e&&(this.currentId=void 0,this.writeLaunches(this.launches.filter(t=>t!==e)),this.host.changed(),this.sync())}writeLaunches(e){const t=this.host.sighting(),n={...t.interpretation??{bodies:[]},lanterns:e.length>0?e:void 0};n.lanterns===void 0&&delete n.lanterns;const s=g.saysNothing(n,f.kinds());t.interpretation=s?void 0:n}labelOf(e){const t=this.host.said().read(e.title);return t?`${t} (${e.id})`:e.id}get launches(){return this.host.sighting().interpretation?.lanterns??[]}element(e){return this.container.querySelector(`#${e}`)}}export{p as LanternEditor};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{aT as y,_ as d,aU as E}from"./rr0-scene.mjs";import{P as b,S as w,a as x,b as j,I as g,E as k,c as v}from"./ParameterForm-BMIW4Gkh.js";import{L as T}from"./LaunchPlume-BRnjFVcY.js";import{T as I}from"./TimelineTracks-B-bXAaF7.js";const S=y.catalog({en:()=>d(()=>import("./LaunchParameterTexts_en-DvrCwbDM.js"),[],import.meta.url).then(r=>r.launchParameterTexts_en),fr:()=>d(()=>import("./LaunchParameterTexts_fr-Bh_1zVzy.js"),[],import.meta.url).then(r=>r.launchParameterTexts_fr),es:()=>d(()=>import("./LaunchParameterTexts_es--RUAegVp.js"),[],import.meta.url).then(r=>r.launchParameterTexts_es),it:()=>d(()=>import("./LaunchParameterTexts_it-CWDx9nJy.js"),[],import.meta.url).then(r=>r.launchParameterTexts_it)});class n{static plumeValue(e){return t=>T.plumeOf(t)[e]}static plume(e,t){return{type:"number",key:`plume.${e}`,effective:n.plumeValue(e),...t}}static burn(e,t){return{type:"number",key:e,min:-3600,max:36e3,step:.1,unit:"s",scale:.001,label:t.label,hint:t.hint,group:"engine",effective:i=>t.ends(i.track??[])?.t}}static placeAt(e,t){if(e.length===0)return{t,lat:0,lng:0,altitudeKm:0};if(e.length===1)return{t,lat:e[0].lat,lng:e[0].lng,altitudeKm:e[0].altitudeKm};let i=0;for(;i<e.length-2&&e[i+1].t<t;)i++;const s=e[i],a=e[i+1],l=a.t===s.t?0:(t-s.t)/(a.t-s.t),o=(m,h)=>m+(h-m)*l;return{t,lat:o(s.lat,a.lat),lng:o(s.lng,a.lng),altitudeKm:Math.max(0,o(s.altitudeKm,a.altitudeKm))}}static instantsOf(e){return[...e.track.map(t=>t.t),...[e.burnFromT,e.burnUntilT].filter(t=>t!==void 0),...(e.jets??[]).flatMap(t=>[t.fromT,t.untilT])]}static SET={kind:"launch",title:"launch",parameters:[{type:"said",key:"title",label:"name",group:"vehicle"},{type:"text",key:"vehicle.mission",label:"mission",placeholder:"Starlink Group 10-49",group:"vehicle"},{type:"number",key:"vehicle.engine.thrustKN",min:1,max:1e5,step:1,unit:"kN",label:"thrustVacuum",hint:"merlinVacuum934Rl10110A",group:"engine"},{type:"number",key:"vehicle.engine.specificImpulseS",min:100,max:500,step:1,unit:"s",label:"specificImpulseVacuum",hint:"times981MSIt",group:"engine"},{type:"choice",key:"vehicle.engine.propellant",label:"propellant",hint:"whatTheExhaustIsMadeOf",choices:[{value:"rp1-lox",label:"keroseneAndOxygen"},{value:"methane-lox",label:"methaneAndOxygen"},{value:"hydrogen-lox",label:"hydrogenAndOxygen"},{value:"hypergolic",label:"hypergolic"},{value:"solid",label:"solid"}],group:"engine"},n.burn("burnFromT",{label:"engineStart",hint:"whenTheEngineStartedInSeconds",ends:e=>e[0]}),n.burn("burnUntilT",{label:"engineCutOff",hint:"whenTheEngineStoppedInSeconds",ends:e=>e[e.length-1]}),n.plume("exhaustKgPerS",{min:.1,max:1e5,step:.1,unit:"kg/s",label:"exhaustFlow",hint:"howMuchExhaustLeavesTheEngine",group:"plume"}),n.plume("condensedShare",{min:0,max:1,step:.01,label:"shareThatScatters",hint:"theShareOfTheExhaustThat",group:"plume"}),n.plume("particleRadiusUm",{min:.05,max:5,step:.05,unit:"µm",label:"particleRadius",group:"plume"}),n.plume("lifetimeS",{min:10,max:3600,step:10,unit:"s",label:"trailLifetime",hint:"howLongTheNarrowTrailLasts",group:"plume"}),n.plume("expansionKmPerS",{min:0,max:5,step:.01,unit:"km/s",label:"trailSpreading",group:"plume"}),n.plume("initialRadiusKm",{min:0,max:50,step:.1,unit:"km",label:"radiusAtRelease",group:"plume"}),n.plume("collarShare",{min:0,max:1,step:.01,label:"shareInTheCollar",hint:"theCollarIsTheExhaustJust",group:"collar"}),n.plume("collarExpansionKmPerS",{min:0,max:10,step:.05,unit:"km/s",label:"collarSpreading",hint:"howFastTheCollarWidensThree",group:"collar"}),n.plume("collarLifetimeS",{min:1,max:300,step:1,unit:"s",label:"collarLifetime",group:"collar"})]};static PLACE={kind:"launch-place",title:"placeOfThePath",parameters:[{type:"number",key:"t",min:-3600,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"time",hint:"secondsOfTheRecordingNegativeBefore"},{type:"position",key:"lat",secondKey:"lng",saidKey:"saidPosition",native:"geo",step:1,label:"position"},{type:"number",key:"altitudeKm",min:0,max:2e3,step:.1,unit:"km",required:!0,label:"altitude"}]};static jetContext(e,t){return{launch:e,index:t}}static jetValue(e){return(t,i)=>{const{launch:s,index:a}=i??{};return s?e(T.releaseOf(s,t,a)):void 0}}static JET_GROUP="jet";static JET={kind:"launch-jet",title:"jet",parameters:[{type:"choice",key:"kind",required:!0,label:"what",choices:[{value:"burn",label:"engineBurn"},{value:"vent",label:"propellantVented"}],group:n.JET_GROUP},{type:"number",key:"fromT",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"from",hint:"secondsOfTheRecordingNegativeBefore2",group:n.JET_GROUP},{type:"number",key:"untilT",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"until",group:n.JET_GROUP},{type:"number",key:"angleDeg",min:0,max:180,step:1,unit:"°",effective:()=>0,label:"directionFromAft",hint:"t0StraightBackAlongTheStage",group:n.JET_GROUP},{type:"number",key:"azimuthDeg",min:-360,max:360,step:1,unit:"°",effective:()=>0,label:"side",hint:"roundTheLineOfMotionWhich",group:n.JET_GROUP},{type:"number",key:"spinPeriodS",min:-3600,max:3600,step:.1,unit:"s",label:"spinPeriod",hint:"howLongTheStageTakesTo",group:n.JET_GROUP},{type:"number",key:"speedKmPerS",min:0,max:10,step:.01,unit:"km/s",effective:n.jetValue(e=>e.speedKmPerS),label:"speed",hint:"howFastItLeavesTheStage",group:n.JET_GROUP},{type:"number",key:"massKgPerS",min:0,max:1e5,step:.1,unit:"kg/s",effective:n.jetValue(e=>e.massKgPerS),label:"flow",group:n.JET_GROUP},{type:"number",key:"condensedShare",min:0,max:1,step:.01,effective:n.jetValue(e=>e.condensedShare),label:"shareThatScatters",group:n.JET_GROUP},{type:"number",key:"particleRadiusUm",min:.05,max:5,step:.05,unit:"µm",effective:n.jetValue(e=>e.particleRadiusUm),label:"particleRadius",group:n.JET_GROUP},{type:"number",key:"expansionKmPerS",min:0,max:5,step:.01,unit:"km/s",effective:n.jetValue(e=>e.populations[0].expansionKmPerS),label:"spreading",hint:"howFastEachPuffOfIt",group:n.JET_GROUP},{type:"number",key:"initialRadiusKm",min:0,max:50,step:.1,unit:"km",effective:n.jetValue(e=>e.initialRadiusKm),label:"radiusAtRelease",group:n.JET_GROUP},{type:"number",key:"lifetimeS",min:1,max:7200,step:1,unit:"s",effective:n.jetValue(e=>e.populations[0].lifetimeS),label:"lifetime",group:n.JET_GROUP}]};static publish(){b.publish(n.SET)}}const O=y.catalog({en:()=>d(()=>import("./LaunchEditorMessages_en-BnzNAYW9.js"),[],import.meta.url).then(r=>r.launchEditorMessages_en),fr:()=>d(()=>import("./LaunchEditorMessages_fr-Ds_VOB8c.js"),[],import.meta.url).then(r=>r.launchEditorMessages_fr),es:()=>d(()=>import("./LaunchEditorMessages_es-BE0dEl7I.js"),[],import.meta.url).then(r=>r.launchEditorMessages_es),it:()=>d(()=>import("./LaunchEditorMessages_it-DPQaR8HY.js"),[],import.meta.url).then(r=>r.launchEditorMessages_it)});class u{constructor(e,t,i){this.container=e,this.host=t,w.attach(e,"launch-editor-part",u.STYLE),this.language=i,b.of("launch")||n.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;row="path";placeForm;placeIndex=0;jetForm;jetIndex=0;language;shown=[];static STYLE='.launch-editor-part { flex-basis: 100%; min-width: 0; } .launch-editor-part #launch-timeline { flex-basis: 100%; min-width: 0; padding: 4px 0; } .launch-editor-part .launch-path > .icon-btn { align-self: flex-end; } .launch-editor-part #launch-list, .launch-editor-part #launch-places { flex-basis: 100%; min-width: 0; } .launch-editor-part .launch-editor, .launch-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .launch-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .launch-editor-part [hidden] { display: none !important; } .launch-editor-part select { min-width: 0; width: 100%; } .launch-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .launch-editor-part .launch-track { flex-basis: 100%; margin: 0; } .launch-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .launch-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; } .launch-editor-part input, .launch-editor-part select { max-width: 100%; box-sizing: border-box; } .launch-editor-part input[type="text"] { width: 12em; } .launch-editor-part #launch-title { width: 18em; } .launch-editor-part label { min-width: 0; max-width: 100%; } .launch-editor-part input.parameter-derived::placeholder { opacity: .65; } .launch-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; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[i,s]=await Promise.all([O.load(e),S.load(e)]);t===this.languageToken&&(this.messages=i,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.launches;this.shown=[...e],e.some(s=>s.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(s=>({id:s.id,label:this.labelOf(s)})),this.currentId),this.syncAddState();const t=this.current;if(this.element("launch-fields").hidden=t===void 0,!t)return;this.syncPlace(!0),this.syncJet(!0);const i=this.resolved(b.of("launch"));this.form??=new x(this.element("launch-parameters"),this.language,"",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(i,t,()=>this.written())}refresh(){if(!this.messages)return;this.syncAddState();const e=this.launches;if(e.length===this.shown.length&&e.every((t,i)=>t===this.shown[i])){this.syncTimeline();return}this.sync()}setTime(e){this.messages&&this.timeline?.setTime(e)}syncAddState(){const e=this.startOfNew()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addLaunchNowhere)}get current(){return this.launches.find(e=>e.id===this.currentId)}show(e){this.messages&&(this.currentId=e,this.row="path",this.placeIndex=0,this.jetIndex=0,this.sync())}resolved(e){return j.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
|
|
2
|
-
<p class="launch-intro">${e.intro}</p>
|
|
3
|
-
<div id="launch-list"></div>
|
|
4
|
-
<div id="launch-fields" class="launch-fields">
|
|
5
|
-
<div id="launch-parameters" class="launch-parameters"></div>
|
|
6
|
-
<div id="launch-timeline" class="launch-timeline"></div>
|
|
7
|
-
<button id="launch-jet-add-burn" type="button" title="${e.addJet}">${g.PLUS} ${e.jetBurn}</button>
|
|
8
|
-
<button id="launch-jet-add-vent" type="button" title="${e.addJet}">${g.PLUS} ${e.jetVent}</button>
|
|
9
|
-
<p class="launch-intro">${e.timelineNote}</p>
|
|
10
|
-
<fieldset id="launch-path" class="launch-path">
|
|
11
|
-
<legend>${e.path}</legend>
|
|
12
|
-
<div id="launch-place-parameters" class="launch-parameters"></div>
|
|
13
|
-
<button id="launch-place-delete" class="icon-btn" type="button" title="${e.deletePlace}" aria-label="${e.deletePlace}">${g.TRASH}</button>
|
|
14
|
-
</fieldset>
|
|
15
|
-
<fieldset id="launch-jets" class="launch-path">
|
|
16
|
-
<legend id="launch-jet-legend">${e.jet}</legend>
|
|
17
|
-
<div id="launch-jet-parameters" class="launch-parameters"></div>
|
|
18
|
-
<button id="launch-jet-delete" class="icon-btn" type="button" title="${e.deleteJet}" aria-label="${e.deleteJet}">${g.TRASH}</button>
|
|
19
|
-
</fieldset>
|
|
20
|
-
<p class="launch-intro">${e.derivedNote}</p>
|
|
21
|
-
</div>
|
|
22
|
-
</div>`;const t=this.element("launch-list");this.list=new k({header:t,body:this.element("launch-fields"),ids:{list:"launch-select",remove:"launch-delete",add:"launch-add",kinds:"launch-add-kind",kind:i=>`launch-add-${i}`},onSelect:i=>this.show(i),onAdd:i=>this.addLaunch(i??u.VEHICLES[0].id),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.launch,remove:e.deleteLaunch,add:e.addLaunch,empty:e.none}),this.list.setKinds(u.VEHICLES.map(i=>({value:i.id,label:i.vehicle.name??i.id}))),this.timeline=new I(this.element("launch-timeline"),i=>this.host.seekTo(i),{addKeyframeHere:e.addHere,keyframeHere:e.here,zoomHint:e.zoomHint}),this.element("launch-jet-add-burn").addEventListener("click",()=>this.addJet("burn",this.host.currentTime())),this.element("launch-jet-add-vent").addEventListener("click",()=>this.addJet("vent",this.host.currentTime())),this.element("launch-place-delete").addEventListener("click",()=>this.removePlace()),this.element("launch-jet-delete").addEventListener("click",()=>this.removeJet()),this.placeForm=void 0,this.jetForm=void 0}written(){this.host.changed();const e=this.current;e&&(this.list?.rename(e.id,this.labelOf(e)),this.syncTimeline())}static PATH_COLOR="#e08a1e";static JET_COLOR="#4f8fd6";jetLabel(e,t){return`${e.kind==="vent"?this.messages.jetVent:this.messages.jetBurn} ${t+1}`}syncTimeline(){const e=this.current;if(!this.timeline||!e)return;const i={id:"path",label:this.messages.path,color:u.PATH_COLOR,times:e.track.map(h=>h.t),active:this.row==="path",selectedTime:this.row==="path"?e.track[this.placeIndex]?.t:void 0,open:()=>this.selectPlace(this.placeIndex),pressed:(h,c)=>{const p=c===void 0?-1:(this.current?.track??[]).findIndex(f=>f.t===c);this.selectPlace(p>=0?p:this.placeIndex)},move:(h,c)=>this.movePlace(h,c),add:()=>this.addPlaceAt(this.host.currentTime())},s=(e.jets??[]).map((h,c)=>({id:`jet-${c}`,label:this.jetLabel(h,c),color:u.JET_COLOR,times:[h.fromT,h.untilT],spans:[{t:h.fromT,until:h.untilT,label:""}],active:this.row==="jet"&&c===this.jetIndex,open:()=>this.selectJet(c),pressed:()=>this.selectJet(c),move:(p,f)=>this.moveJetEnd(c,p,f),add:()=>this.addJet(h.kind??"burn",this.host.currentTime())})),a=n.instantsOf(e),l=Math.min(...a),o=Math.max(...a),m=Math.max(500,(o-l)/10);this.timeline.show([i,...s],this.host.duration(),this.host.currentTime(),{from:l-m,to:o+m})}syncDetail(){const t=this.current?.jets?.[this.jetIndex];this.row==="jet"&&!t&&(this.row="path"),this.element("launch-path").hidden=this.row!=="path",this.element("launch-jets").hidden=this.row!=="jet",this.element("launch-jet-legend").textContent=t?this.jetLabel(t,this.jetIndex):this.messages.jet}static MIN_PLACES=2;syncPlace(e=!1){const t=this.current?.track??[];this.placeIndex=Math.max(0,Math.min(this.placeIndex,t.length-1)),this.element("launch-place-delete").disabled=t.length<=u.MIN_PLACES,this.placeForm?this.placeForm.sync(e):(this.placeForm=new x(this.element("launch-place-parameters"),this.language,"launchPlace."),this.placeForm.show(this.resolved(n.PLACE),new v(()=>this.current?.track[this.placeIndex],i=>this.editPlace(this.placeIndex,i),void 0,this.host.positionPlace?.()),()=>{})),this.syncDetail(),this.syncTimeline()}selectPlace(e){this.row="path",this.placeIndex=e,this.syncPlace(!0)}editPlace(e,t){const i=this.current;if(!i)return;const s={...i.track[e]};t(s),i.track=i.track.map((a,l)=>l===e?s:a).sort((a,l)=>a.t-l.t),this.placeIndex=i.track.indexOf(s),this.syncPlace(),this.written()}movePlace(e,t){const i=this.current?.track.findIndex(s=>s.t===e)??-1;i<0||(this.editPlace(i,s=>{s.t=t}),this.syncPlace(!0))}addPlaceAt(e){const t=this.current;if(!t)return;const i=t.track.findIndex(s=>Math.abs(s.t-e)<1);if(i<0){const s=n.placeAt(t.track,Math.round(e));t.track=[...t.track,s].sort((a,l)=>a.t-l.t),this.host.changed(),this.selectPlace(t.track.indexOf(s));return}this.selectPlace(i)}removePlace(){const e=this.current;!e||e.track.length<=u.MIN_PLACES||(e.track=e.track.filter((t,i)=>i!==this.placeIndex),this.syncPlace(!0),this.host.changed())}syncJet(e=!1){const t=this.current?.jets??[];this.jetIndex=Math.max(0,Math.min(this.jetIndex,t.length-1)),this.jetForm?this.jetForm.sync(e):(this.jetForm=new x(this.element("launch-jet-parameters"),this.language,"launchJet."),this.jetForm.show(this.resolved(n.JET),new v(()=>this.current?.jets?.[this.jetIndex],i=>this.editJet(this.jetIndex,i),()=>this.current?n.jetContext(this.current,this.jetIndex):void 0),()=>{})),this.syncDetail(),this.syncTimeline()}selectJet(e){this.row="jet",this.jetIndex=e,this.syncJet(!0)}editJet(e,t){const i=this.current;if(!i?.jets)return;const s={...i.jets[e]};t(s),i.jets=i.jets.map((a,l)=>l===e?s:a),this.written()}moveJetEnd(e,t,i){const s=this.current?.jets?.[e];s&&(this.editJet(e,a=>{const l=t===s.fromT?[i,s.untilT]:[s.fromT,i];a.fromT=Math.min(l[0],l[1]),a.untilT=Math.max(l[0],l[1])}),this.selectJet(e))}addJet(e,t){const i=this.current;if(!i)return;const s=i.track,a=Math.round(t),l=e==="vent"?{kind:e,fromT:a,untilT:a+3e4,angleDeg:90}:{kind:e,fromT:a,untilT:a+3e4};!i.jets?.length&&i.burnFromT===void 0&&i.burnUntilT===void 0&&(i.burnFromT=s[0].t,i.burnUntilT=s[s.length-1].t),i.jets=[...i.jets??[],l],this.form?.sync(!0),this.host.changed(),this.selectJet(i.jets.length-1)}removeJet(){const e=this.current;if(!e?.jets?.length)return;const t=e.jets.filter((i,s)=>s!==this.jetIndex);t.length?e.jets=t:delete e.jets,this.host.changed(),t.length?this.selectJet(Math.min(this.jetIndex,t.length-1)):this.selectPlace(this.placeIndex)}startOfNew(){const e=this.host.sighting(),t=e.event?.place?.[0];if(t?.lat===void 0||t.lng===void 0)return;const i=(e.observerTrack?.getInterpolatedPoseAt(0)?.headingDeg??0)*Math.PI/180,s=a=>({lat:t.lat+a*Math.cos(i)/111.32,lng:t.lng+a*Math.sin(i)/(111.32*Math.max(.05,Math.cos(t.lat*Math.PI/180)))});return[{t:0,...s(300),altitudeKm:80},{t:6e4,...s(450),altitudeKm:160}]}static VEHICLES=[{id:"falcon-9",vehicle:{name:"Falcon 9"}}];addLaunch(e){const t=this.startOfNew();if(!t)return;const i=u.VEHICLES.find(o=>o.id===e)??u.VEHICLES[0];let s=this.launches.length+1;for(;this.launches.some(o=>o.id===`launch-${s}`);)s++;const a={id:`launch-${s}`,vehicle:{...i.vehicle},track:t},l=this.host.sighting();l.skyEvents={...l.skyEvents,launches:[...this.launches,a]},this.currentId=a.id,this.row="path",this.placeIndex=0,this.host.changed(),this.sync()}deleteCurrent(){const e=this.current;if(!e)return;this.currentId=void 0;const t=this.host.sighting();t.skyEvents=E.written({...t.skyEvents,launches:this.launches.filter(i=>i!==e)}),this.host.changed(),this.sync()}labelOf(e){const t=this.host.said().read(e.title)??e.vehicle?.mission??e.vehicle?.name;return t?`${t} (${e.id})`:e.id}get launches(){return this.host.sighting().skyEvents?.launches??[]}element(e){return this.container.querySelector(`#${e}`)}}export{u as LaunchEditor};
|