@rr0/ufoathome 0.178.3 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist-embed-interview/InterviewMessages_en-ru7GkZlQ.js +1 -0
  2. package/dist-embed-interview/InterviewMessages_es-DkJurNrG.js +1 -0
  3. package/dist-embed-interview/InterviewMessages_fr-DAYgf8Ms.js +1 -0
  4. package/dist-embed-interview/InterviewMessages_it-6lenkmSg.js +1 -0
  5. package/dist-embed-interview/rr0-interview.mjs +2 -2
  6. package/dist-embed-scene/{BeamEditor-DFGRzRny.js → BeamEditor-DXIKipID.js} +1 -1
  7. package/dist-embed-scene/{LanternEditor-H8VYYbRn.js → LanternEditor-JvQQ8GOQ.js} +1 -1
  8. package/dist-embed-scene/LaunchEditor-DIxYPs4d.js +22 -0
  9. package/dist-embed-scene/{LaunchPlume-eEIp7_hM.js → LaunchPlume-FP3Yk-8B.js} +1 -1
  10. package/dist-embed-scene/{LaunchSimulation-DNNEzmzs.js → LaunchSimulation-v4khqz4r.js} +1 -1
  11. package/dist-embed-scene/{ModuleSession-DLoAutYP.js → ModuleSession-CLUE46BO.js} +2 -2
  12. package/dist-embed-scene/{ModuleThree-R2LhnY95.js → ModuleThree-DQfMGMDy.js} +1 -1
  13. package/dist-embed-scene/{ParameterForm-ez-n_0Dw.js → ParameterForm-BFp5BoHL.js} +9 -12
  14. package/dist-embed-scene/{ReentryEditor-CwY4oANp.js → ReentryEditor-ByVtt--5.js} +6 -6
  15. package/dist-embed-scene/{ReentrySimulation-BDgEPekW.js → ReentrySimulation-nzg5V3kJ.js} +1 -1
  16. package/dist-embed-scene/{TimelineTracks-BQXJMJaJ.js → TimelineTracks-BOjTfdGu.js} +2 -2
  17. package/dist-embed-scene/rr0-scene.mjs +333 -322
  18. package/dist-embed-sighting/{CaseReportExport-ByLXCo0I.js → CaseReportExport-C30Foqx0.js} +1 -1
  19. package/dist-embed-sighting/{InterviewElement-Byb_sxbO.js → InterviewElement-BduwyUn5.js} +2 -2
  20. package/dist-embed-sighting/InterviewMessages_en-ru7GkZlQ.js +1 -0
  21. package/dist-embed-sighting/InterviewMessages_es-DkJurNrG.js +1 -0
  22. package/dist-embed-sighting/InterviewMessages_fr-DAYgf8Ms.js +1 -0
  23. package/dist-embed-sighting/InterviewMessages_it-6lenkmSg.js +1 -0
  24. package/dist-embed-sighting/rr0-sighting.mjs +36 -28
  25. package/dist-embed-sighting-editor/{AdsbLolArchiveProvider-fZkxLAHp.js → AdsbLolArchiveProvider-DEqEth50.js} +1 -1
  26. package/dist-embed-sighting-editor/AssemblyAiTranscriptionProvider-o2kkPD5o.js +1 -0
  27. package/dist-embed-sighting-editor/{BallesterGuaspAssessor-DASadJjI.js → BallesterGuaspAssessor-ClwhCo4B.js} +1 -1
  28. package/dist-embed-sighting-editor/{BeamEditor-B2diaX_e.js → BeamEditor-vxinYAhV.js} +1 -1
  29. package/dist-embed-sighting-editor/{BeamSystem-BfNJfayv.js → BeamSystem-BMyP16H9.js} +1 -1
  30. package/dist-embed-sighting-editor/{BodyEditor-CCBXFuuL.js → BodyEditor-Dn5HrH2t.js} +1 -1
  31. package/dist-embed-sighting-editor/BrowserWhisperProvider-Dn44ZE45.js +1 -0
  32. package/dist-embed-sighting-editor/{CaseReportExport-DBSSDC9F.js → CaseReportExport-Ct_2DUSO.js} +2 -2
  33. package/dist-embed-sighting-editor/{ContrailSystem-BWvO9taK.js → ContrailSystem-Y75rFfLJ.js} +1 -1
  34. package/dist-embed-sighting-editor/{ControlPasses-BQ_DUxa_.js → ControlPasses-oqSnNDq6.js} +1 -1
  35. package/dist-embed-sighting-editor/{CoverageAssessor-CSktyUlP.js → CoverageAssessor-CN-3cMS9.js} +1 -1
  36. package/dist-embed-sighting-editor/{Flightradar24Provider-OvRZWZWj.js → Flightradar24Provider-D3bM2ckV.js} +1 -1
  37. package/dist-embed-sighting-editor/GLTFLoader-CJy8wjmO.js +1 -0
  38. package/dist-embed-sighting-editor/{GenerativeKitMessages-BtNG1usJ.js → GenerativeKitMessages-I8xH2ec9.js} +1 -1
  39. package/dist-embed-sighting-editor/{GeoExportTexts-DBGGdRnP.js → GeoExportTexts-DAllttgw.js} +1 -1
  40. package/dist-embed-sighting-editor/{GeoJsonExport-BZ-0v8fM.js → GeoJsonExport-_yjIEd4F.js} +1 -1
  41. package/dist-embed-sighting-editor/GeographicFigures-DC6Tw3ja.js +1 -0
  42. package/dist-embed-sighting-editor/{HeadlightSystem-C-8Gl3vu.js → HeadlightSystem-DZN_EX7x.js} +1 -1
  43. package/dist-embed-sighting-editor/{HynekAssessor-CH2E88xV.js → HynekAssessor-CKjvYcVe.js} +1 -1
  44. package/dist-embed-sighting-editor/InterviewEditorElement-C7eNBUfn.js +270 -0
  45. package/dist-embed-sighting-editor/InterviewMessages_en-ru7GkZlQ.js +1 -0
  46. package/dist-embed-sighting-editor/InterviewMessages_es-DkJurNrG.js +1 -0
  47. package/dist-embed-sighting-editor/InterviewMessages_fr-DAYgf8Ms.js +1 -0
  48. package/dist-embed-sighting-editor/InterviewMessages_it-6lenkmSg.js +1 -0
  49. package/dist-embed-sighting-editor/{KmlExport-Bh4eTycx.js → KmlExport-dpml2tIJ.js} +1 -1
  50. package/dist-embed-sighting-editor/LanternEditor-CKKUIplQ.js +9 -0
  51. package/dist-embed-sighting-editor/{LaserBeam-CtogDP38.js → LaserBeam-Ct6opxMs.js} +1 -1
  52. package/dist-embed-sighting-editor/LaunchEditor-BfggZKq5.js +22 -0
  53. package/dist-embed-sighting-editor/{LaunchPlume-BtRrJTP9.js → LaunchPlume-CT777Ivp.js} +1 -1
  54. package/dist-embed-sighting-editor/{LaunchSimulation-xKwguVJt.js → LaunchSimulation-BSlF3Uq4.js} +1 -1
  55. package/dist-embed-sighting-editor/{ModelSource-CnKzaNDn.js → ModelSource-BQm0eN7H.js} +1 -1
  56. package/dist-embed-sighting-editor/{ModelThumbnails-UE_Er5EW.js → ModelThumbnails-Bwh2px6A.js} +1 -1
  57. package/dist-embed-sighting-editor/{ModelViewer-DoCshJc6.js → ModelViewer-Dl5ichWV.js} +1 -1
  58. package/dist-embed-sighting-editor/ModuleConformance-B8OYKQop.js +2 -0
  59. package/dist-embed-sighting-editor/{ModuleSession-CJstaNEN.js → ModuleSession-BQSTCqob.js} +3 -3
  60. package/dist-embed-sighting-editor/ModuleThree-DwGM2nF4.js +1 -0
  61. package/dist-embed-sighting-editor/{ModulesPanelElement-DdGqqdn4.js → ModulesPanelElement-CZcbo6lq.js} +3 -3
  62. package/dist-embed-sighting-editor/{NearestApproach-BH3Yw8Qz.js → NearestApproach-DkpM-8sl.js} +1 -1
  63. package/dist-embed-sighting-editor/OpenAiTranscriptionProvider-DDW446tK.js +1 -0
  64. package/dist-embed-sighting-editor/{PictureRegistration-B9C6iY17.js → PictureRegistration-CbfytwCX.js} +1 -1
  65. package/dist-embed-sighting-editor/{PoherAssessor-DWcCWUfa.js → PoherAssessor-C5-F9VMn.js} +1 -1
  66. package/dist-embed-sighting-editor/{RailwaySystem-D3VBmx1X.js → RailwaySystem-BxHS7Jka.js} +1 -1
  67. package/dist-embed-sighting-editor/{ReentryEditor-BDyG-48K.js → ReentryEditor-BgpCftyc.js} +2 -2
  68. package/dist-embed-sighting-editor/{ReentrySimulation-BQj0wWXW.js → ReentrySimulation-BHjJYTL1.js} +1 -1
  69. package/dist-embed-sighting-editor/{ReferenceSystem-C9NRL7UY.js → ReferenceSystem-BxKEbMVI.js} +1 -1
  70. package/dist-embed-sighting-editor/{RoadMarkings-ByQL2MTo.js → RoadMarkings-D9-6Cy9S.js} +1 -1
  71. package/dist-embed-sighting-editor/{SceneNames_en-BdRB6cjg.js → SceneNames_en-09L_ZfER.js} +1 -1
  72. package/dist-embed-sighting-editor/{SceneNames_es-Dk0UmXHp.js → SceneNames_es-C4PEieol.js} +1 -1
  73. package/dist-embed-sighting-editor/{SceneNames_fr-_z2iZ8Bm.js → SceneNames_fr-BGTFI_pF.js} +1 -1
  74. package/dist-embed-sighting-editor/{SceneNames_it-CE7fanb3.js → SceneNames_it-DHk5C-uS.js} +1 -1
  75. package/dist-embed-sighting-editor/{TraceSystem-g262KZ3G.js → TraceSystem-DAa5Lzof.js} +2 -2
  76. package/dist-embed-sighting-editor/TranscriptionAudio-C_xvRUv2.js +5 -0
  77. package/dist-embed-sighting-editor/TranscriptionError-D_TCbYbt.js +1 -0
  78. package/dist-embed-sighting-editor/{UfoMessages_en-JeMK-39o.js → UfoMessages_en-FAvzKxmR.js} +1 -1
  79. package/dist-embed-sighting-editor/{WaterSystem-CIbQPMqE.js → WaterSystem-C7hE-tnY.js} +1 -1
  80. package/dist-embed-sighting-editor/interviewImport-CgWyTdKb.js +4 -0
  81. package/dist-embed-sighting-editor/{interviewJson-DXD8FSBX.js → interviewJson-iURHP4Zk.js} +1 -1
  82. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +30 -22
  83. package/dist-embed-sighting-editor/{surroundingsSources-BExFsNzP.js → surroundingsSources-YIawBCws.js} +1 -1
  84. package/dist-embed-sighting-editor/{trafficRuntime-CPRQW0Ho.js → trafficRuntime-j8tnHTec.js} +1 -1
  85. package/package.json +1 -1
  86. package/dist-embed-interview/InterviewMessages_en-BNau2xU8.js +0 -1
  87. package/dist-embed-interview/InterviewMessages_es-ypa0EDh9.js +0 -1
  88. package/dist-embed-interview/InterviewMessages_fr-OCQdwn9j.js +0 -1
  89. package/dist-embed-interview/InterviewMessages_it-awuOqf5v.js +0 -1
  90. package/dist-embed-scene/LaunchEditor-CIYcS0Y-.js +0 -22
  91. package/dist-embed-sighting/InterviewMessages_en-BNau2xU8.js +0 -1
  92. package/dist-embed-sighting/InterviewMessages_es-ypa0EDh9.js +0 -1
  93. package/dist-embed-sighting/InterviewMessages_fr-OCQdwn9j.js +0 -1
  94. package/dist-embed-sighting/InterviewMessages_it-awuOqf5v.js +0 -1
  95. package/dist-embed-sighting-editor/GLTFLoader-CM7Uk25s.js +0 -1
  96. package/dist-embed-sighting-editor/GeographicFigures-DqhWddS9.js +0 -1
  97. package/dist-embed-sighting-editor/InterviewEditorElement-Bz3hyZ-m.js +0 -234
  98. package/dist-embed-sighting-editor/InterviewMessages_en-BNau2xU8.js +0 -1
  99. package/dist-embed-sighting-editor/InterviewMessages_es-ypa0EDh9.js +0 -1
  100. package/dist-embed-sighting-editor/InterviewMessages_fr-OCQdwn9j.js +0 -1
  101. package/dist-embed-sighting-editor/InterviewMessages_it-awuOqf5v.js +0 -1
  102. package/dist-embed-sighting-editor/LanternEditor-tTk1vUZm.js +0 -9
  103. package/dist-embed-sighting-editor/LaunchEditor-CteAalch.js +0 -22
  104. package/dist-embed-sighting-editor/ModuleConformance-BKvZnuw9.js +0 -2
  105. package/dist-embed-sighting-editor/ModuleThree-1hxqvWFa.js +0 -1
  106. package/dist-embed-sighting-editor/interviewImport-C-TiARLK.js +0 -4
@@ -0,0 +1,22 @@
1
+ import{c as y,_ as d,a$ as g,b0 as E}from"./rr0-scene.mjs";import{P as b,S as w,a as x,b as j,E as k,c as v}from"./ParameterForm-BFp5BoHL.js";import{L as T}from"./LaunchPlume-FP3Yk-8B.js";import{T as I}from"./TimelineTracks-BOjTfdGu.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};
@@ -1 +1 @@
1
- import{b8 as w,b9 as F,ba as v,bb as Y,R as H}from"./rr0-scene.mjs";class K{static MU=398600.4418;static OMEGA=72921159e-12;static EARTH_RADIUS_KM=6371;static STEP_S=1;static DENSITY=[[0,1.225],[20,.0889],[40,.004],[60,31e-5],[80,185e-7],[100,56e-8],[120,222e-10],[150,208e-11],[200,254e-12],[250,607e-13],[300,192e-13],[400,28e-13],[500,522e-15],[600,114e-15],[700,307e-16],[800,114e-16],[900,576e-17],[1e3,356e-17]];static FREE_PATH_TIMES_DENSITY=68e-9;static ICE_DENSITY=917;static airDensity(s){const t=K.DENSITY;if(s<=t[0][0])return t[0][1];let e=0;for(;e<t.length-2&&t[e+1][0]<s;)e++;const[a,i]=t[e],[o,n]=t[e+1];return i*Math.exp(Math.log(n/i)*(s-a)/(o-a))}static dragPerKm(s,t,e,a=.5){const i=K.airDensity(s),o=K.FREE_PATH_TIMES_DENSITY/i/1e3,n=Math.exp(-o/t),p=i*1e9*Math.PI*t*t/Math.max(e,1e-9),d=3*i/(4*a*1e-6*K.ICE_DENSITY)*1e3;return n*p+(1-n)*d}static step(s,t,e,a,i){const[o,n,p,d,R,h]=s,m=Math.hypot(o,n,p),T=K.OMEGA,M=-398600.4418/(m*m*m),y=M*o+2*T*R+T*T*o,U=M*n-2*T*d+T*T*n,I=M*p,E=Math.hypot(d,R,h),c=1/(1+K.dragPerKm(m-K.EARTH_RADIUS_KM,e,a,i)*E*t);s[3]=(d+y*t)*c,s[4]=(R+U*t)*c,s[5]=(h+I*t)*c,s[0]=o+s[3]*t,s[1]=n+s[4]*t,s[2]=p+s[5]*t;const f=Math.hypot(s[0],s[1],s[2]);if(f<K.EARTH_RADIUS_KM){const A=K.EARTH_RADIUS_KM/f;s[0]*=A,s[1]*=A,s[2]*=A,s[3]=s[4]=s[5]=0}}}class _{constructor(s,t,e,a,i=.5){this.massKg=e,this.radiusAt=a,this.particleRadiusUm=i,this.state=Float64Array.of(...s,...t),this.positions=new Float64Array(192),this.positions.set(s,0)}positions;steps=0;state;at(s){const t=K.STEP_S,e=Math.max(0,s/t),a=Math.ceil(e);for(;this.steps<a;){if(K.step(this.state,t,this.radiusAt(this.steps*t),this.massKg,this.particleRadiusUm),this.steps++,3*(this.steps+1)>this.positions.length){const p=new Float64Array(this.positions.length*2);p.set(this.positions),this.positions=p}this.positions.set(this.state.subarray(0,3),3*this.steps)}const i=Math.floor(e),o=e-i,n=this.positions;return o===0||i>=this.steps?[n[3*i],n[3*i+1],n[3*i+2]]:[0,1,2].map(p=>n[3*i+p]+(n[3*i+3+p]-n[3*i+p])*o)}}class r{static EARTH_RADIUS_KM=6371;static SHADOW_RADIUS_KM=r.EARTH_RADIUS_KM+15;static PENUMBRA_KM=10;static SUN_ILLUMINANCE_LUX=127e3;static RAYLEIGH_PER_M=[58e-7,135e-7,331e-7];static SCALE_HEIGHT_M=8e3;static OZONE_GRAZING_DEPTH=[2.4,1.8,.24];static ANISOTROPY=.7;static ALBEDO=.99;static WAVELENGTHS_UM=[.61,.55,.465];static ICE_INDEX=1.31;static DEFAULTS={exhaustKgPerS:273,condensedShare:.065,particleRadiusUm:.5,expansionKmPerS:.15,initialRadiusKm:.5,lifetimeS:420,collarShare:.85,collarExpansionKmPerS:2.5,collarLifetimeS:20};static PROPELLANTS={"rp1-lox":{condensedShare:.065,particleRadiusUm:.5},"methane-lox":{condensedShare:.09,particleRadiusUm:.5},"hydrogen-lox":{condensedShare:.13,particleRadiusUm:.5},hypergolic:{condensedShare:.079,particleRadiusUm:.4},solid:{condensedShare:.27,particleRadiusUm:.8}};static G0=9.80665;static COLLAR_SPREAD_OF_EXHAUST_VELOCITY=.735;static plumeOf(s){const t={},e=s.vehicle?.engine;if(e){const a=e.specificImpulseS===void 0?void 0:e.specificImpulseS*r.G0;e.thrustKN!==void 0&&a&&(t.exhaustKgPerS=e.thrustKN*1e3/a),a&&(t.collarExpansionKmPerS=a/1e3*r.COLLAR_SPREAD_OF_EXHAUST_VELOCITY),e.propellant&&Object.assign(t,r.PROPELLANTS[e.propellant])}return{...r.DEFAULTS,...t,...s.plume}}static PUFF_EVERY_S=.5;static SIGMA_OF_RADIUS=.5;static MAX_PUFFS=320;static DEG=Math.PI/180;static EARTH_ROTATION=72921159e-12;static VENT_DEFAULTS={speedKmPerS:.7,massKgPerS:20,condensedShare:.5,particleRadiusUm:.5,expansionKmPerS:.1,initialRadiusKm:.2,lifetimeS:600};static paths=new WeakMap;static exhaustVelocityKmPerS(s){return(s.vehicle?.engine?.specificImpulseS??348)*r.G0/1e3}static releasesOf(s){const t=[],e=s.jets??[];if(e.length===0||s.burnFromT!==void 0||s.burnUntilT!==void 0){const a=s.track[0]?.t??0,i=s.track[s.track.length-1]?.t??0;t.push(r.engineRelease(s,"burn",{fromT:s.burnFromT??a,untilT:s.burnUntilT??i}))}return e.forEach((a,i)=>t.push(r.releaseOf(s,a,i))),t}static releaseOf(s,t,e){const a=`jet:${t.id??e}`;if((t.kind??"burn")==="burn")return r.engineRelease(s,a,t);const i=r.VENT_DEFAULTS;return{key:a,fromT:t.fromT,untilT:t.untilT,angleDeg:t.angleDeg??0,azimuthDeg:t.azimuthDeg??0,spinPeriodS:t.spinPeriodS,speedKmPerS:t.speedKmPerS??i.speedKmPerS,massKgPerS:t.massKgPerS??i.massKgPerS,condensedShare:t.condensedShare??i.condensedShare,particleRadiusUm:t.particleRadiusUm??i.particleRadiusUm,initialRadiusKm:t.initialRadiusKm??i.initialRadiusKm,populations:[{share:1,expansionKmPerS:t.expansionKmPerS??i.expansionKmPerS,lifetimeS:t.lifetimeS??i.lifetimeS}]}}static engineRelease(s,t,e){const a=r.plumeOf(s);return{key:t,fromT:e.fromT,untilT:e.untilT,angleDeg:e.angleDeg??0,azimuthDeg:e.azimuthDeg??0,spinPeriodS:e.spinPeriodS,speedKmPerS:e.speedKmPerS??r.exhaustVelocityKmPerS(s),massKgPerS:e.massKgPerS??a.exhaustKgPerS,condensedShare:e.condensedShare??a.condensedShare,particleRadiusUm:e.particleRadiusUm??a.particleRadiusUm,initialRadiusKm:e.initialRadiusKm??a.initialRadiusKm,populations:[{share:1-a.collarShare,expansionKmPerS:e.expansionKmPerS??a.expansionKmPerS,lifetimeS:e.lifetimeS??a.lifetimeS},{share:a.collarShare,expansionKmPerS:a.collarExpansionKmPerS,lifetimeS:a.collarLifetimeS}]}}static extinctionEfficiency(s,t){const e=2*Math.PI*s/t,a=r.ICE_INDEX**2,i=8/3*e**4*((a-1)/(a+2))**2,o=2*e*(r.ICE_INDEX-1),n=o<.001?o*o/2:2-4/o*Math.sin(o)+4/(o*o)*(1-Math.cos(o));return Math.min(i,n)}static scatteringColour(s){const t=r.extinctionEfficiency(s,r.WAVELENGTHS_UM[1]);return r.WAVELENGTHS_UM.map(e=>r.extinctionEfficiency(s,e)/t)}static sunDirectionAt(s){const t=new w(0,0,-6378137),e=F(v.Sun,s,t,!0,!0),a=(e.ra-Y(s))*15*r.DEG,i=e.dec*r.DEG;return[Math.cos(i)*Math.cos(a),Math.cos(i)*Math.sin(a),Math.sin(i)]}static puffsAt(s,t){const e=[];for(const a of s){let i=r.paths.get(a);i||r.paths.set(a,i=new Map);for(const o of r.releasesOf(a)){const n=Math.min(o.untilT,t);if(n<=o.fromT)continue;const p=Math.max(r.PUFF_EVERY_S*1e3,(o.untilT-o.fromT)/r.MAX_PUFFS),d=[];for(let M=o.fromT;M<n;M+=p)d.push(M);d.push(n);const R=o.massKgPerS*(p/1e3),m=3*r.extinctionEfficiency(o.particleRadiusUm,r.WAVELENGTHS_UM[1])/(4*917*o.particleRadiusUm*1e-6),T=r.scatteringColour(o.particleRadiusUm);o.populations.forEach((M,y)=>{if(M.share<=0)return;const U=E=>o.initialRadiusKm+M.expansionKmPerS*E,I=[];for(const E of d){const D=(t-E)/1e3;if(D>M.lifetimeS)continue;const c=E!==n||n===o.untilT,f=`${o.key}|${y}|${E}`;let A=c?i.get(f):void 0;if(!A){if(A=r.launchPuff(a,o,E,R*M.share,U),!A)continue;c&&i.set(f,A)}I.push({ageS:D,position:A.at(D)})}for(let E=I.length-1;E>=0;E--){const{ageS:D,position:c}=I[E],f=I[E-1]??I[E+1],A=f?Math.hypot(c[0]-f.position[0],c[1]-f.position[1],c[2]-f.position[2]):0,l=U(D)+A/2,O=r.SIGMA_OF_RADIUS*l*1e3,N=R*o.condensedShare*M.share*m/(2*Math.PI*O*O),x=Math.max(0,1-(D/M.lifetimeS)**2);N*x<=0||e.push({launchId:a.id,release:o.key,at:r.geoPoint(c),radiusKm:l,opticalDepth:N*x,colour:T,ageS:D})}})}}return e}static viewsAt(s,t,e,a){const i=[];for(const o of r.puffsAt(s,t)){const n=H.seenFrom(e,o.at);if(n.altitudeDeg<0)continue;const p=r.sunlightAt(o.at,a);if(p.lit<=0)continue;const d=r.scatteringPhase(e,o.at,a),R=r.SUN_ILLUMINANCE_LUX*r.ALBEDO*d*o.opticalDepth*p.lit;R<=0||i.push({launchId:o.launchId,release:o.release,heightKm:o.at.heightM/1e3,centre:n,radiusDeg:Math.atan2(o.radiusKm,n.distanceKm)/r.DEG,luminanceCdM2:R,sunTransmittance:p.transmittance,colour:o.colour,lit:p.lit,ageS:o.ageS})}return i}static launchPuff(s,t,e,a,i){const o={id:s.id,track:s.track,fragments:[]},n=H.leadAt(o,e);if(!n)return;const p=s.track[0].t,d=s.track[s.track.length-1].t,R=Math.max(p,e-500),h=Math.min(d,e+500),m=r.earthCentred(n),T=r.earthCentred(H.leadAt(o,R)),M=r.earthCentred(H.leadAt(o,h)),y=Math.max(.001,(h-R)/1e3),U=[0,1,2].map(S=>(M[S]-T[S])/y),I=r.EARTH_ROTATION,E=[U[0]-I*m[1],U[1]+I*m[0],U[2]],D=S=>{const b=Math.hypot(S[0],S[1],S[2])||1;return S.map(k=>k/b)},c=D(E),f=D(m),A=f[0]*c[0]+f[1]*c[1]+f[2]*c[2];let l=[f[0]-A*c[0],f[1]-A*c[1],f[2]-A*c[2]];Math.hypot(l[0],l[1],l[2])<1e-6&&(l=[-c[2]*c[0],-c[2]*c[1],1-c[2]*c[2]]),l=D(l);const O=[c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0]],N=t.spinPeriodS?360*((e-t.fromT)/1e3)/t.spinPeriodS:0,x=(t.azimuthDeg+N)*r.DEG,G=t.angleDeg*r.DEG,C=[0,1,2].map(S=>-c[S]*Math.cos(G)+Math.sin(G)*(Math.cos(x)*l[S]+Math.sin(x)*O[S])),P=[0,1,2].map(S=>U[S]+t.speedKmPerS*C[S]);return new _(m,P,a,i,t.particleRadiusUm)}static geoPoint(s){const t=Math.hypot(s[0],s[1],s[2]);return{lat:Math.asin(s[2]/t)/r.DEG,lng:Math.atan2(s[1],s[0])/r.DEG,heightM:(t-K.EARTH_RADIUS_KM)*1e3}}static sunlightAt(s,t){const e=r.earthCentred(s),a=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];if(a>=0)return{lit:1,transmittance:[1,1,1]};const i=Math.hypot(e[0]-a*t[0],e[1]-a*t[1],e[2]-a*t[2]),o=r.PENUMBRA_KM,n=Math.min(1,Math.max(0,(i-(r.SHADOW_RADIUS_KM-o/2))/o));if(n<=0)return{lit:0,transmittance:[0,0,0]};const p=Math.max(0,(i-r.EARTH_RADIUS_KM)*1e3),d=Math.exp(-p/r.SCALE_HEIGHT_M),R=Math.sqrt(2*Math.PI*r.EARTH_RADIUS_KM*1e3*r.SCALE_HEIGHT_M),h=Math.exp(-(((p/1e3-25)/15)**2)),m=[0,1,2].map(T=>Math.exp(-r.RAYLEIGH_PER_M[T]*d*R-r.OZONE_GRAZING_DEPTH[T]*h));return{lit:n,transmittance:m}}static scatteringPhase(s,t,e){const a=r.earthCentred(s),i=r.earthCentred(t),o=[a[0]-i[0],a[1]-i[1],a[2]-i[2]],n=Math.hypot(o[0],o[1],o[2])||1,p=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2])/n,d=r.ANISOTROPY;return(1-d*d)/(4*Math.PI*(1+d*d-2*d*p)**1.5)}static earthCentred(s){const t=s.lat*r.DEG,e=s.lng*r.DEG,a=r.EARTH_RADIUS_KM+s.heightM/1e3;return[a*Math.cos(t)*Math.cos(e),a*Math.cos(t)*Math.sin(e),a*Math.sin(t)]}}export{r as L};
1
+ import{b9 as w,ba as F,bb as v,bc as Y,R as H}from"./rr0-scene.mjs";class K{static MU=398600.4418;static OMEGA=72921159e-12;static EARTH_RADIUS_KM=6371;static STEP_S=1;static DENSITY=[[0,1.225],[20,.0889],[40,.004],[60,31e-5],[80,185e-7],[100,56e-8],[120,222e-10],[150,208e-11],[200,254e-12],[250,607e-13],[300,192e-13],[400,28e-13],[500,522e-15],[600,114e-15],[700,307e-16],[800,114e-16],[900,576e-17],[1e3,356e-17]];static FREE_PATH_TIMES_DENSITY=68e-9;static ICE_DENSITY=917;static airDensity(s){const t=K.DENSITY;if(s<=t[0][0])return t[0][1];let e=0;for(;e<t.length-2&&t[e+1][0]<s;)e++;const[a,i]=t[e],[o,n]=t[e+1];return i*Math.exp(Math.log(n/i)*(s-a)/(o-a))}static dragPerKm(s,t,e,a=.5){const i=K.airDensity(s),o=K.FREE_PATH_TIMES_DENSITY/i/1e3,n=Math.exp(-o/t),p=i*1e9*Math.PI*t*t/Math.max(e,1e-9),d=3*i/(4*a*1e-6*K.ICE_DENSITY)*1e3;return n*p+(1-n)*d}static step(s,t,e,a,i){const[o,n,p,d,R,h]=s,m=Math.hypot(o,n,p),T=K.OMEGA,M=-398600.4418/(m*m*m),y=M*o+2*T*R+T*T*o,U=M*n-2*T*d+T*T*n,I=M*p,E=Math.hypot(d,R,h),c=1/(1+K.dragPerKm(m-K.EARTH_RADIUS_KM,e,a,i)*E*t);s[3]=(d+y*t)*c,s[4]=(R+U*t)*c,s[5]=(h+I*t)*c,s[0]=o+s[3]*t,s[1]=n+s[4]*t,s[2]=p+s[5]*t;const f=Math.hypot(s[0],s[1],s[2]);if(f<K.EARTH_RADIUS_KM){const A=K.EARTH_RADIUS_KM/f;s[0]*=A,s[1]*=A,s[2]*=A,s[3]=s[4]=s[5]=0}}}class _{constructor(s,t,e,a,i=.5){this.massKg=e,this.radiusAt=a,this.particleRadiusUm=i,this.state=Float64Array.of(...s,...t),this.positions=new Float64Array(192),this.positions.set(s,0)}positions;steps=0;state;at(s){const t=K.STEP_S,e=Math.max(0,s/t),a=Math.ceil(e);for(;this.steps<a;){if(K.step(this.state,t,this.radiusAt(this.steps*t),this.massKg,this.particleRadiusUm),this.steps++,3*(this.steps+1)>this.positions.length){const p=new Float64Array(this.positions.length*2);p.set(this.positions),this.positions=p}this.positions.set(this.state.subarray(0,3),3*this.steps)}const i=Math.floor(e),o=e-i,n=this.positions;return o===0||i>=this.steps?[n[3*i],n[3*i+1],n[3*i+2]]:[0,1,2].map(p=>n[3*i+p]+(n[3*i+3+p]-n[3*i+p])*o)}}class r{static EARTH_RADIUS_KM=6371;static SHADOW_RADIUS_KM=r.EARTH_RADIUS_KM+15;static PENUMBRA_KM=10;static SUN_ILLUMINANCE_LUX=127e3;static RAYLEIGH_PER_M=[58e-7,135e-7,331e-7];static SCALE_HEIGHT_M=8e3;static OZONE_GRAZING_DEPTH=[2.4,1.8,.24];static ANISOTROPY=.7;static ALBEDO=.99;static WAVELENGTHS_UM=[.61,.55,.465];static ICE_INDEX=1.31;static DEFAULTS={exhaustKgPerS:273,condensedShare:.065,particleRadiusUm:.5,expansionKmPerS:.15,initialRadiusKm:.5,lifetimeS:420,collarShare:.85,collarExpansionKmPerS:2.5,collarLifetimeS:20};static PROPELLANTS={"rp1-lox":{condensedShare:.065,particleRadiusUm:.5},"methane-lox":{condensedShare:.09,particleRadiusUm:.5},"hydrogen-lox":{condensedShare:.13,particleRadiusUm:.5},hypergolic:{condensedShare:.079,particleRadiusUm:.4},solid:{condensedShare:.27,particleRadiusUm:.8}};static G0=9.80665;static COLLAR_SPREAD_OF_EXHAUST_VELOCITY=.735;static plumeOf(s){const t={},e=s.vehicle?.engine;if(e){const a=e.specificImpulseS===void 0?void 0:e.specificImpulseS*r.G0;e.thrustKN!==void 0&&a&&(t.exhaustKgPerS=e.thrustKN*1e3/a),a&&(t.collarExpansionKmPerS=a/1e3*r.COLLAR_SPREAD_OF_EXHAUST_VELOCITY),e.propellant&&Object.assign(t,r.PROPELLANTS[e.propellant])}return{...r.DEFAULTS,...t,...s.plume}}static PUFF_EVERY_S=.5;static SIGMA_OF_RADIUS=.5;static MAX_PUFFS=320;static DEG=Math.PI/180;static EARTH_ROTATION=72921159e-12;static VENT_DEFAULTS={speedKmPerS:.7,massKgPerS:20,condensedShare:.5,particleRadiusUm:.5,expansionKmPerS:.1,initialRadiusKm:.2,lifetimeS:600};static paths=new WeakMap;static exhaustVelocityKmPerS(s){return(s.vehicle?.engine?.specificImpulseS??348)*r.G0/1e3}static releasesOf(s){const t=[],e=s.jets??[];if(e.length===0||s.burnFromT!==void 0||s.burnUntilT!==void 0){const a=s.track[0]?.t??0,i=s.track[s.track.length-1]?.t??0;t.push(r.engineRelease(s,"burn",{fromT:s.burnFromT??a,untilT:s.burnUntilT??i}))}return e.forEach((a,i)=>t.push(r.releaseOf(s,a,i))),t}static releaseOf(s,t,e){const a=`jet:${t.id??e}`;if((t.kind??"burn")==="burn")return r.engineRelease(s,a,t);const i=r.VENT_DEFAULTS;return{key:a,fromT:t.fromT,untilT:t.untilT,angleDeg:t.angleDeg??0,azimuthDeg:t.azimuthDeg??0,spinPeriodS:t.spinPeriodS,speedKmPerS:t.speedKmPerS??i.speedKmPerS,massKgPerS:t.massKgPerS??i.massKgPerS,condensedShare:t.condensedShare??i.condensedShare,particleRadiusUm:t.particleRadiusUm??i.particleRadiusUm,initialRadiusKm:t.initialRadiusKm??i.initialRadiusKm,populations:[{share:1,expansionKmPerS:t.expansionKmPerS??i.expansionKmPerS,lifetimeS:t.lifetimeS??i.lifetimeS}]}}static engineRelease(s,t,e){const a=r.plumeOf(s);return{key:t,fromT:e.fromT,untilT:e.untilT,angleDeg:e.angleDeg??0,azimuthDeg:e.azimuthDeg??0,spinPeriodS:e.spinPeriodS,speedKmPerS:e.speedKmPerS??r.exhaustVelocityKmPerS(s),massKgPerS:e.massKgPerS??a.exhaustKgPerS,condensedShare:e.condensedShare??a.condensedShare,particleRadiusUm:e.particleRadiusUm??a.particleRadiusUm,initialRadiusKm:e.initialRadiusKm??a.initialRadiusKm,populations:[{share:1-a.collarShare,expansionKmPerS:e.expansionKmPerS??a.expansionKmPerS,lifetimeS:e.lifetimeS??a.lifetimeS},{share:a.collarShare,expansionKmPerS:a.collarExpansionKmPerS,lifetimeS:a.collarLifetimeS}]}}static extinctionEfficiency(s,t){const e=2*Math.PI*s/t,a=r.ICE_INDEX**2,i=8/3*e**4*((a-1)/(a+2))**2,o=2*e*(r.ICE_INDEX-1),n=o<.001?o*o/2:2-4/o*Math.sin(o)+4/(o*o)*(1-Math.cos(o));return Math.min(i,n)}static scatteringColour(s){const t=r.extinctionEfficiency(s,r.WAVELENGTHS_UM[1]);return r.WAVELENGTHS_UM.map(e=>r.extinctionEfficiency(s,e)/t)}static sunDirectionAt(s){const t=new w(0,0,-6378137),e=F(v.Sun,s,t,!0,!0),a=(e.ra-Y(s))*15*r.DEG,i=e.dec*r.DEG;return[Math.cos(i)*Math.cos(a),Math.cos(i)*Math.sin(a),Math.sin(i)]}static puffsAt(s,t){const e=[];for(const a of s){let i=r.paths.get(a);i||r.paths.set(a,i=new Map);for(const o of r.releasesOf(a)){const n=Math.min(o.untilT,t);if(n<=o.fromT)continue;const p=Math.max(r.PUFF_EVERY_S*1e3,(o.untilT-o.fromT)/r.MAX_PUFFS),d=[];for(let M=o.fromT;M<n;M+=p)d.push(M);d.push(n);const R=o.massKgPerS*(p/1e3),m=3*r.extinctionEfficiency(o.particleRadiusUm,r.WAVELENGTHS_UM[1])/(4*917*o.particleRadiusUm*1e-6),T=r.scatteringColour(o.particleRadiusUm);o.populations.forEach((M,y)=>{if(M.share<=0)return;const U=E=>o.initialRadiusKm+M.expansionKmPerS*E,I=[];for(const E of d){const D=(t-E)/1e3;if(D>M.lifetimeS)continue;const c=E!==n||n===o.untilT,f=`${o.key}|${y}|${E}`;let A=c?i.get(f):void 0;if(!A){if(A=r.launchPuff(a,o,E,R*M.share,U),!A)continue;c&&i.set(f,A)}I.push({ageS:D,position:A.at(D)})}for(let E=I.length-1;E>=0;E--){const{ageS:D,position:c}=I[E],f=I[E-1]??I[E+1],A=f?Math.hypot(c[0]-f.position[0],c[1]-f.position[1],c[2]-f.position[2]):0,l=U(D)+A/2,O=r.SIGMA_OF_RADIUS*l*1e3,N=R*o.condensedShare*M.share*m/(2*Math.PI*O*O),x=Math.max(0,1-(D/M.lifetimeS)**2);N*x<=0||e.push({launchId:a.id,release:o.key,at:r.geoPoint(c),radiusKm:l,opticalDepth:N*x,colour:T,ageS:D})}})}}return e}static viewsAt(s,t,e,a){const i=[];for(const o of r.puffsAt(s,t)){const n=H.seenFrom(e,o.at);if(n.altitudeDeg<0)continue;const p=r.sunlightAt(o.at,a);if(p.lit<=0)continue;const d=r.scatteringPhase(e,o.at,a),R=r.SUN_ILLUMINANCE_LUX*r.ALBEDO*d*o.opticalDepth*p.lit;R<=0||i.push({launchId:o.launchId,release:o.release,heightKm:o.at.heightM/1e3,centre:n,radiusDeg:Math.atan2(o.radiusKm,n.distanceKm)/r.DEG,luminanceCdM2:R,sunTransmittance:p.transmittance,colour:o.colour,lit:p.lit,ageS:o.ageS})}return i}static launchPuff(s,t,e,a,i){const o={id:s.id,track:s.track,fragments:[]},n=H.leadAt(o,e);if(!n)return;const p=s.track[0].t,d=s.track[s.track.length-1].t,R=Math.max(p,e-500),h=Math.min(d,e+500),m=r.earthCentred(n),T=r.earthCentred(H.leadAt(o,R)),M=r.earthCentred(H.leadAt(o,h)),y=Math.max(.001,(h-R)/1e3),U=[0,1,2].map(S=>(M[S]-T[S])/y),I=r.EARTH_ROTATION,E=[U[0]-I*m[1],U[1]+I*m[0],U[2]],D=S=>{const b=Math.hypot(S[0],S[1],S[2])||1;return S.map(k=>k/b)},c=D(E),f=D(m),A=f[0]*c[0]+f[1]*c[1]+f[2]*c[2];let l=[f[0]-A*c[0],f[1]-A*c[1],f[2]-A*c[2]];Math.hypot(l[0],l[1],l[2])<1e-6&&(l=[-c[2]*c[0],-c[2]*c[1],1-c[2]*c[2]]),l=D(l);const O=[c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0]],N=t.spinPeriodS?360*((e-t.fromT)/1e3)/t.spinPeriodS:0,x=(t.azimuthDeg+N)*r.DEG,G=t.angleDeg*r.DEG,C=[0,1,2].map(S=>-c[S]*Math.cos(G)+Math.sin(G)*(Math.cos(x)*l[S]+Math.sin(x)*O[S])),P=[0,1,2].map(S=>U[S]+t.speedKmPerS*C[S]);return new _(m,P,a,i,t.particleRadiusUm)}static geoPoint(s){const t=Math.hypot(s[0],s[1],s[2]);return{lat:Math.asin(s[2]/t)/r.DEG,lng:Math.atan2(s[1],s[0])/r.DEG,heightM:(t-K.EARTH_RADIUS_KM)*1e3}}static sunlightAt(s,t){const e=r.earthCentred(s),a=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];if(a>=0)return{lit:1,transmittance:[1,1,1]};const i=Math.hypot(e[0]-a*t[0],e[1]-a*t[1],e[2]-a*t[2]),o=r.PENUMBRA_KM,n=Math.min(1,Math.max(0,(i-(r.SHADOW_RADIUS_KM-o/2))/o));if(n<=0)return{lit:0,transmittance:[0,0,0]};const p=Math.max(0,(i-r.EARTH_RADIUS_KM)*1e3),d=Math.exp(-p/r.SCALE_HEIGHT_M),R=Math.sqrt(2*Math.PI*r.EARTH_RADIUS_KM*1e3*r.SCALE_HEIGHT_M),h=Math.exp(-(((p/1e3-25)/15)**2)),m=[0,1,2].map(T=>Math.exp(-r.RAYLEIGH_PER_M[T]*d*R-r.OZONE_GRAZING_DEPTH[T]*h));return{lit:n,transmittance:m}}static scatteringPhase(s,t,e){const a=r.earthCentred(s),i=r.earthCentred(t),o=[a[0]-i[0],a[1]-i[1],a[2]-i[2]],n=Math.hypot(o[0],o[1],o[2])||1,p=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2])/n,d=r.ANISOTROPY;return(1-d*d)/(4*Math.PI*(1+d*d-2*d*p)**1.5)}static earthCentred(s){const t=s.lat*r.DEG,e=s.lng*r.DEG,a=r.EARTH_RADIUS_KM+s.heightM/1e3;return[a*Math.cos(t)*Math.cos(e),a*Math.cos(t)*Math.sin(e),a*Math.sin(t)]}}export{r as L};
@@ -1 +1 @@
1
- import{L as M}from"./LaunchPlume-eEIp7_hM.js";import{G as T,B as z,i as f,e as C,b6 as w,b7 as A}from"./rr0-scene.mjs";class n{static RADIUS=840;static MAX_PUFFS=1e3;static RINGS=[0,.25,.5,.75,1,1.25];static COLUMN=n.RINGS.map(t=>{const i=o=>Math.exp(-((o/M.SIGMA_OF_RADIUS)**2)/2),s=i(n.RINGS[n.RINGS.length-1]);return Math.max(0,(i(t)-s)/(1-s))});static SECTORS=12;static VERTICES_PER_PUFF=n.SECTORS*(3+6*(n.RINGS.length-2));static BRIGHTEST_RELATIVE=6e4;object=new T;mesh;positions=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);colors=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);shown=0;drawn=[];static VISIBLE_CONTRAST=.1;constructor(){this.object.name="plumes";const t=new z;t.setAttribute("position",new f(this.positions,3)),t.setAttribute("color",new f(this.colors,3)),t.setDrawRange(0,0),this.mesh=new C(t,w.material()),this.mesh.frustumCulled=!1,w.track(this.mesh),this.object.add(this.mesh)}get count(){return this.shown}set(t,i,s,o){let h=0,c=0;this.drawn=[];for(const p of t){if(c>=n.MAX_PUFFS)break;const d=o(p.centre);if(d<=0)continue;const a=s(p.centre),r=[0,1,2].map(g=>Math.min(n.BRIGHTEST_RELATIVE,p.luminanceCdM2*(p.colour?.[g]??1)*i*p.sunTransmittance[g]*a[g]*d));Math.max(...r)<=0||(h=this.pushPuff(h,p,r),this.drawn.push({view:p,direction:this.normalise(A(p.centre.altitudeDeg,p.centre.azimuthDeg,1)),radiusRad:p.radiusDeg*Math.PI/180,luminance:.2126*r[0]+.7152*r[1]+.0722*r[2]}),c++)}this.shown=c;const u=this.mesh.geometry;u.setDrawRange(0,h),u.getAttribute("position").needsUpdate=!0,u.getAttribute("color").needsUpdate=!0}pushPuff(t,i,s){const o=A(i.centre.altitudeDeg,i.centre.azimuthDeg,n.RADIUS),h=this.normalise(o),c=this.normalise(this.cross({x:0,y:1,z:0},h)),u=this.cross(h,c),p=n.RADIUS*Math.tan(i.radiusDeg*Math.PI/180),d=(r,g)=>{const e=g/n.SECTORS*2*Math.PI,I=n.RINGS[r]*p,R=Math.cos(e)*I,l=Math.sin(e)*I;return{x:o.x+c.x*R+u.x*l,y:o.y+c.y*R+u.y*l,z:o.z+c.z*R+u.z*l}},a=r=>n.COLUMN[r];for(let r=0;r<n.SECTORS;r++){const g=(r+1)%n.SECTORS;t=this.push(t,o,s,a(0)),t=this.push(t,d(1,r),s,a(1)),t=this.push(t,d(1,g),s,a(1));for(let e=1;e<n.RINGS.length-1;e++){const I=d(e,r),R=d(e,g),l=d(e+1,r),E=d(e+1,g);t=this.push(t,I,s,a(e)),t=this.push(t,R,s,a(e)),t=this.push(t,l,s,a(e+1)),t=this.push(t,R,s,a(e)),t=this.push(t,E,s,a(e+1)),t=this.push(t,l,s,a(e+1))}}return t}pickAt(t,i,s=0){const o=this.normalise(t);let h=0,c;for(const u of this.drawn){const p=Math.max(-1,Math.min(1,o.x*u.direction.x+o.y*u.direction.y+o.z*u.direction.z)),d=Math.max(0,Math.acos(p)-i)/Math.max(u.radiusRad,1e-9),a=u.luminance*n.profile(d);a<=0||(h+=a,(!c||a>c.light)&&(c={view:u.view,light:a}))}return c&&h>=n.VISIBLE_CONTRAST*s?c.view:void 0}static profile(t){const i=n.RINGS;if(t>=i[i.length-1])return 0;let s=0;for(;t>i[s+1];)s++;const o=(t-i[s])/(i[s+1]-i[s]);return n.COLUMN[s]+(n.COLUMN[s+1]-n.COLUMN[s])*o}push(t,i,s,o){const h=t*3;return this.positions[h]=i.x,this.positions[h+1]=i.y,this.positions[h+2]=i.z,this.colors[h]=s[0]*o,this.colors[h+1]=s[1]*o,this.colors[h+2]=s[2]*o,t+1}cross(t,i){return this.normalise({x:t.y*i.z-t.z*i.y,y:t.z*i.x-t.x*i.z,z:t.x*i.y-t.y*i.x})}normalise(t){const i=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/i,y:t.y/i,z:t.z/i}}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.object.removeFromParent()}}class b{inSky=!0;plumes=new n;get object(){return this.plumes.object}get drawnCount(){return this.plumes.count}update(t,i,s){const o=t.length===0||!s.date?[]:M.viewsAt(t,i,s.observer,M.sunDirectionAt(s.date));o.length===0&&this.plumes.count===0||this.plumes.set(o,s.relativeScale,h=>s.transmittanceFromSpace(h),h=>s.cloudTransmission(h))}pick(t,i,s){const o=this.plumes.pickAt(i,s.toleranceRad,s.skyLightTowards(i));return o&&{id:o.launchId,detail:o}}dispose(){this.plumes.dispose()}}export{b as LaunchSimulation};
1
+ import{L as M}from"./LaunchPlume-FP3Yk-8B.js";import{G as T,B as z,i as f,e as C,b7 as w,b8 as A}from"./rr0-scene.mjs";class n{static RADIUS=840;static MAX_PUFFS=1e3;static RINGS=[0,.25,.5,.75,1,1.25];static COLUMN=n.RINGS.map(t=>{const i=o=>Math.exp(-((o/M.SIGMA_OF_RADIUS)**2)/2),s=i(n.RINGS[n.RINGS.length-1]);return Math.max(0,(i(t)-s)/(1-s))});static SECTORS=12;static VERTICES_PER_PUFF=n.SECTORS*(3+6*(n.RINGS.length-2));static BRIGHTEST_RELATIVE=6e4;object=new T;mesh;positions=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);colors=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);shown=0;drawn=[];static VISIBLE_CONTRAST=.1;constructor(){this.object.name="plumes";const t=new z;t.setAttribute("position",new f(this.positions,3)),t.setAttribute("color",new f(this.colors,3)),t.setDrawRange(0,0),this.mesh=new C(t,w.material()),this.mesh.frustumCulled=!1,w.track(this.mesh),this.object.add(this.mesh)}get count(){return this.shown}set(t,i,s,o){let h=0,c=0;this.drawn=[];for(const p of t){if(c>=n.MAX_PUFFS)break;const d=o(p.centre);if(d<=0)continue;const a=s(p.centre),r=[0,1,2].map(g=>Math.min(n.BRIGHTEST_RELATIVE,p.luminanceCdM2*(p.colour?.[g]??1)*i*p.sunTransmittance[g]*a[g]*d));Math.max(...r)<=0||(h=this.pushPuff(h,p,r),this.drawn.push({view:p,direction:this.normalise(A(p.centre.altitudeDeg,p.centre.azimuthDeg,1)),radiusRad:p.radiusDeg*Math.PI/180,luminance:.2126*r[0]+.7152*r[1]+.0722*r[2]}),c++)}this.shown=c;const u=this.mesh.geometry;u.setDrawRange(0,h),u.getAttribute("position").needsUpdate=!0,u.getAttribute("color").needsUpdate=!0}pushPuff(t,i,s){const o=A(i.centre.altitudeDeg,i.centre.azimuthDeg,n.RADIUS),h=this.normalise(o),c=this.normalise(this.cross({x:0,y:1,z:0},h)),u=this.cross(h,c),p=n.RADIUS*Math.tan(i.radiusDeg*Math.PI/180),d=(r,g)=>{const e=g/n.SECTORS*2*Math.PI,I=n.RINGS[r]*p,R=Math.cos(e)*I,l=Math.sin(e)*I;return{x:o.x+c.x*R+u.x*l,y:o.y+c.y*R+u.y*l,z:o.z+c.z*R+u.z*l}},a=r=>n.COLUMN[r];for(let r=0;r<n.SECTORS;r++){const g=(r+1)%n.SECTORS;t=this.push(t,o,s,a(0)),t=this.push(t,d(1,r),s,a(1)),t=this.push(t,d(1,g),s,a(1));for(let e=1;e<n.RINGS.length-1;e++){const I=d(e,r),R=d(e,g),l=d(e+1,r),E=d(e+1,g);t=this.push(t,I,s,a(e)),t=this.push(t,R,s,a(e)),t=this.push(t,l,s,a(e+1)),t=this.push(t,R,s,a(e)),t=this.push(t,E,s,a(e+1)),t=this.push(t,l,s,a(e+1))}}return t}pickAt(t,i,s=0){const o=this.normalise(t);let h=0,c;for(const u of this.drawn){const p=Math.max(-1,Math.min(1,o.x*u.direction.x+o.y*u.direction.y+o.z*u.direction.z)),d=Math.max(0,Math.acos(p)-i)/Math.max(u.radiusRad,1e-9),a=u.luminance*n.profile(d);a<=0||(h+=a,(!c||a>c.light)&&(c={view:u.view,light:a}))}return c&&h>=n.VISIBLE_CONTRAST*s?c.view:void 0}static profile(t){const i=n.RINGS;if(t>=i[i.length-1])return 0;let s=0;for(;t>i[s+1];)s++;const o=(t-i[s])/(i[s+1]-i[s]);return n.COLUMN[s]+(n.COLUMN[s+1]-n.COLUMN[s])*o}push(t,i,s,o){const h=t*3;return this.positions[h]=i.x,this.positions[h+1]=i.y,this.positions[h+2]=i.z,this.colors[h]=s[0]*o,this.colors[h+1]=s[1]*o,this.colors[h+2]=s[2]*o,t+1}cross(t,i){return this.normalise({x:t.y*i.z-t.z*i.y,y:t.z*i.x-t.x*i.z,z:t.x*i.y-t.y*i.x})}normalise(t){const i=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/i,y:t.y/i,z:t.z/i}}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.object.removeFromParent()}}class b{inSky=!0;plumes=new n;get object(){return this.plumes.object}get drawnCount(){return this.plumes.count}update(t,i,s){const o=t.length===0||!s.date?[]:M.viewsAt(t,i,s.observer,M.sunDirectionAt(s.date));o.length===0&&this.plumes.count===0||this.plumes.set(o,s.relativeScale,h=>s.transmittanceFromSpace(h),h=>s.cloudTransmission(h))}pick(t,i,s){const o=this.plumes.pickAt(i,s.toleranceRad,s.skyLightTowards(i));return o&&{id:o.launchId,detail:o}}dispose(){this.plumes.dispose()}}export{b as LaunchSimulation};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModuleThree-R2LhnY95.js","./rr0-scene.mjs"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModuleThree-DQfMGMDy.js","./rr0-scene.mjs"])))=>i.map(i=>d[i]);
2
2
  import{f as g,b as w,_ as b,M as p}from"./rr0-scene.mjs";class n{static STORAGE_KEY="ufoathome.modules";static FORMAT=1;static empty(){return{format:1,modules:[]}}static read(t=n.storage()){try{const e=t?.getItem(n.STORAGE_KEY);return e?n.parse(e):n.empty()}catch{return n.empty()}}static write(t,e=n.storage()){try{return e?(t.modules.length===0?e.removeItem(n.STORAGE_KEY):e.setItem(n.STORAGE_KEY,n.text(t)),!0):!1}catch{return!1}}static parse(t){const e=JSON.parse(t);if(e===null||typeof e!="object"||!Array.isArray(e.modules))throw new Error("not a UFO@home module list");if(typeof e.format=="number"&&e.format>n.FORMAT)throw new Error(`format ${e.format} is newer than ${n.FORMAT}`);const r=new Set,s=[];for(const i of e.modules)typeof i?.url!="string"||r.has(i.url)||(r.add(i.url),s.push({url:i.url,enabled:i.enabled!==!1}));return{format:1,modules:s}}static text(t){return JSON.stringify({format:n.FORMAT,modules:t.modules},null,2)+`
3
- `}static storage(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}}class E{constructor(t,e){this.attribution=t,this.models=e}async entries(t){return t?this.models.filter(e=>[e.kind].flat().includes(t)):[...this.models]}async entry(t){return this.models.find(e=>e.id===t)}}class f{attribution;fetchImpl;tileUrlTemplate;constructor(t){this.attribution=t.attribution,this.tileUrlTemplate=t.tileUrlTemplate,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis)}getImageryTexture(t,e){return g(t,e,r=>f.tileUrl(this.tileUrlTemplate,r),this.fetchImpl)}static tileUrl(t,e){return t.replaceAll("{z}",String(e.z)).replaceAll("{x}",String(e.x)).replaceAll("{y}",String(e.y))}}class v extends Error{constructor(t,e){super(`${t}: ${e}`),this.url=t,this.reason=e,this.name="ModuleManifestError"}}class d{static FORMAT=1;static check(t,e){const r=o=>{throw new v(e,o)};(t===null||typeof t!="object"||Array.isArray(t))&&r("not a JSON object");const s=t;typeof s.format!="number"&&r('no "format"'),s.format>d.FORMAT&&r(`format ${s.format} is newer than ${d.FORMAT}, which this version reads`),(typeof s.id!="string"||!/^[a-z0-9][a-z0-9._-]*$/.test(s.id))&&r(`"id" must be lowercase letters, digits, '.', '_' or '-'`),(typeof s.name!="string"||s.name.trim()==="")&&r('no "name"'),s.script!==void 0&&typeof s.script!="string"&&r('"script" must be an address');const i=s.contributes??{};for(const o of["imagery","elevation"]){const c=i[o];c!==void 0&&(Array.isArray(c)||r(`"contributes.${o}" must be a list`),c.forEach((l,h)=>{for(const m of["id","name","credit","creditUrl","tiles"])(typeof l?.[m]!="string"||l[m]==="")&&r(`"contributes.${o}[${h}].${m}" is missing`);["{z}","{x}","{y}"].every(m=>l.tiles.includes(m))||r(`"contributes.${o}[${h}].tiles" must hold {z}, {x} and {y}`)}))}const a=i.models;return a!==void 0&&(Array.isArray(a)||r('"contributes.models" must be a list'),a.forEach((o,c)=>{for(const l of["id","name","file"])(typeof o?.[l]!="string"||o[l]==="")&&r(`"contributes.models[${c}].${l}" is missing`);o.kind===void 0&&r(`"contributes.models[${c}].kind" is missing`),(!o.credit||typeof o.credit!="object")&&r(`"contributes.models[${c}].credit" is missing: a model is shown with its author and licence`)})),s}static contributions(t,e){const r=t.contributes??{},s={};if(r.imagery?.length&&(s.imagery=r.imagery.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new f({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),attribution:i.credit,fetchImpl:a})}))),r.elevation?.length&&(s.elevation=r.elevation.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new w({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),fetchImpl:a})}))),r.models?.length){const i=r.models.map(({file:o,...c})=>({...c,url:new URL(o,e).href})),a=t.credit??t.name;s.decorModels=[{id:`${t.id}-models`,name:t.name,credit:a,creditUrl:t.creditUrl??e,create:()=>new E(a,i)}]}return s}static module(t,e,r={}){const s=d.contributions(t,e);for(const[i,a]of Object.entries(r))Array.isArray(a)&&(s[i]=[...s[i]??[],...a]);return{id:t.id,name:t.name,credit:t.credit,creditUrl:t.creditUrl,url:e,contributes:s}}static absoluteTemplate(t,e){const r=t.replaceAll("{z}","__Z__").replaceAll("{x}","__X__").replaceAll("{y}","__Y__");return new URL(r,e).href.replaceAll("__Z__","{z}").replaceAll("__X__","{x}").replaceAll("__Y__","{y}")}}class T{fetchImpl;importImpl;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.importImpl=t.importImpl??(e=>import(e))}async load(t,e){const r=await this.fetchImpl(t);if(!r.ok)throw new Error(`${t}: HTTP ${r.status}`);const s=d.check(await r.json(),t),i=s.script!==void 0;let a={};if(i&&e.runScript){const o=new URL(s.script,t).href,c=await this.importImpl(o);if(typeof c.default!="function")throw new Error(`${o}: its default export is not a function`);const{MODULE_THREE:l}=await b(async()=>{const{MODULE_THREE:h}=await import("./ModuleThree-R2LhnY95.js");return{MODULE_THREE:h}},__vite__mapDeps([0,1]),import.meta.url);a=await c.default({manifestUrl:t,three:l})??{}}return{url:t,manifest:s,module:d.module(s,t,a),hasScript:i,scriptRun:i&&e.runScript}}}class y{constructor(t=new T,e){this.loader=t,this.storage=e}static shared=new y;changes=new EventTarget;states=new Map;config=n.empty();started;list(){const t=[...this.states.values()];return[...t.filter(e=>e.addedByPerson),...t.filter(e=>!e.addedByPerson)]}state(t){return this.states.get(t)}start(){return this.started??=this.applyConfig(n.read(this.storage)),this.started}async add(t){await this.start();const e=new URL(t,typeof location>"u"?void 0:location.href).href;return this.config.modules.some(r=>r.url===e)||(this.config={...this.config,modules:[...this.config.modules,{url:e,enabled:!0}]},this.save()),this.reload(e)}async remove(t){this.config={...this.config,modules:this.config.modules.filter(e=>e.url!==t)},this.save(),await this.reload(t)}async setEnabled(t,e){this.config={...this.config,modules:this.config.modules.map(r=>r.url===t?{...r,enabled:e}:r)},this.save(),await this.reload(t)}exportText(){return n.text(this.config)}async importText(t){const e=n.parse(t);await this.start();const r=this.config.modules.map(s=>s.url);this.config=e,this.save(),await Promise.all([...new Set([...r,...e.modules.map(s=>s.url)])].map(s=>this.reload(s)))}async require(t,e){t?.length&&(await this.start(),await Promise.all(t.map(async r=>{let s;try{s=new URL(r,e??(typeof location>"u"?void 0:location.href)).href}catch{return}const i=this.states.get(s);if(i&&i.status!=="off")return i.status==="loading"?this.pending.get(s):void 0;this.named.add(s),await this.reload(s)})))}named=new Set;pending=new Map;async applyConfig(t){this.config=t,await Promise.all(t.modules.map(e=>this.reload(e.url)))}reload(t){const e=this.reloadNow(t);return this.pending.set(t,e),e}async reloadNow(t){const e=this.config.modules.find(a=>a.url===t),r=this.states.get(t);r?.loaded&&p.uninstall(r.loaded.module.id);const s=e!==void 0,i=e?.enabled??!0;if(!s&&!this.named.has(t))return this.states.delete(t),this.announce(),{url:t,addedByPerson:s,enabled:i,status:"off"};if(s&&!i&&!this.named.has(t))return this.set({url:t,addedByPerson:s,enabled:i,status:"off"});this.set({url:t,addedByPerson:s,enabled:i,status:"loading"});try{const a=await this.loader.load(t,{runScript:s&&i});return p.install(a.module),this.set({url:t,addedByPerson:s,enabled:i,status:"installed",loaded:a})}catch(a){return this.set({url:t,addedByPerson:s,enabled:i,status:"failed",error:a instanceof Error?a.message:String(a)})}}set(t){return this.states.set(t.url,t),this.announce(),t}save(){n.write(this.config,this.storage)}announce(){this.changes.dispatchEvent(new Event("change"))}}export{y as ModuleSession};
3
+ `}static storage(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}}class E{constructor(t,e){this.attribution=t,this.models=e}async entries(t){return t?this.models.filter(e=>[e.kind].flat().includes(t)):[...this.models]}async entry(t){return this.models.find(e=>e.id===t)}}class f{attribution;fetchImpl;tileUrlTemplate;constructor(t){this.attribution=t.attribution,this.tileUrlTemplate=t.tileUrlTemplate,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis)}getImageryTexture(t,e){return g(t,e,r=>f.tileUrl(this.tileUrlTemplate,r),this.fetchImpl)}static tileUrl(t,e){return t.replaceAll("{z}",String(e.z)).replaceAll("{x}",String(e.x)).replaceAll("{y}",String(e.y))}}class v extends Error{constructor(t,e){super(`${t}: ${e}`),this.url=t,this.reason=e,this.name="ModuleManifestError"}}class d{static FORMAT=1;static check(t,e){const r=o=>{throw new v(e,o)};(t===null||typeof t!="object"||Array.isArray(t))&&r("not a JSON object");const s=t;typeof s.format!="number"&&r('no "format"'),s.format>d.FORMAT&&r(`format ${s.format} is newer than ${d.FORMAT}, which this version reads`),(typeof s.id!="string"||!/^[a-z0-9][a-z0-9._-]*$/.test(s.id))&&r(`"id" must be lowercase letters, digits, '.', '_' or '-'`),(typeof s.name!="string"||s.name.trim()==="")&&r('no "name"'),s.script!==void 0&&typeof s.script!="string"&&r('"script" must be an address');const i=s.contributes??{};for(const o of["imagery","elevation"]){const c=i[o];c!==void 0&&(Array.isArray(c)||r(`"contributes.${o}" must be a list`),c.forEach((l,h)=>{for(const m of["id","name","credit","creditUrl","tiles"])(typeof l?.[m]!="string"||l[m]==="")&&r(`"contributes.${o}[${h}].${m}" is missing`);["{z}","{x}","{y}"].every(m=>l.tiles.includes(m))||r(`"contributes.${o}[${h}].tiles" must hold {z}, {x} and {y}`)}))}const a=i.models;return a!==void 0&&(Array.isArray(a)||r('"contributes.models" must be a list'),a.forEach((o,c)=>{for(const l of["id","name","file"])(typeof o?.[l]!="string"||o[l]==="")&&r(`"contributes.models[${c}].${l}" is missing`);o.kind===void 0&&r(`"contributes.models[${c}].kind" is missing`),(!o.credit||typeof o.credit!="object")&&r(`"contributes.models[${c}].credit" is missing: a model is shown with its author and licence`)})),s}static contributions(t,e){const r=t.contributes??{},s={};if(r.imagery?.length&&(s.imagery=r.imagery.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new f({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),attribution:i.credit,fetchImpl:a})}))),r.elevation?.length&&(s.elevation=r.elevation.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new w({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),fetchImpl:a})}))),r.models?.length){const i=r.models.map(({file:o,...c})=>({...c,url:new URL(o,e).href})),a=t.credit??t.name;s.decorModels=[{id:`${t.id}-models`,name:t.name,credit:a,creditUrl:t.creditUrl??e,create:()=>new E(a,i)}]}return s}static module(t,e,r={}){const s=d.contributions(t,e);for(const[i,a]of Object.entries(r))Array.isArray(a)&&(s[i]=[...s[i]??[],...a]);return{id:t.id,name:t.name,credit:t.credit,creditUrl:t.creditUrl,url:e,contributes:s}}static absoluteTemplate(t,e){const r=t.replaceAll("{z}","__Z__").replaceAll("{x}","__X__").replaceAll("{y}","__Y__");return new URL(r,e).href.replaceAll("__Z__","{z}").replaceAll("__X__","{x}").replaceAll("__Y__","{y}")}}class T{fetchImpl;importImpl;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.importImpl=t.importImpl??(e=>import(e))}async load(t,e){const r=await this.fetchImpl(t);if(!r.ok)throw new Error(`${t}: HTTP ${r.status}`);const s=d.check(await r.json(),t),i=s.script!==void 0;let a={};if(i&&e.runScript){const o=new URL(s.script,t).href,c=await this.importImpl(o);if(typeof c.default!="function")throw new Error(`${o}: its default export is not a function`);const{MODULE_THREE:l}=await b(async()=>{const{MODULE_THREE:h}=await import("./ModuleThree-DQfMGMDy.js");return{MODULE_THREE:h}},__vite__mapDeps([0,1]),import.meta.url);a=await c.default({manifestUrl:t,three:l})??{}}return{url:t,manifest:s,module:d.module(s,t,a),hasScript:i,scriptRun:i&&e.runScript}}}class y{constructor(t=new T,e){this.loader=t,this.storage=e}static shared=new y;changes=new EventTarget;states=new Map;config=n.empty();started;list(){const t=[...this.states.values()];return[...t.filter(e=>e.addedByPerson),...t.filter(e=>!e.addedByPerson)]}state(t){return this.states.get(t)}start(){return this.started??=this.applyConfig(n.read(this.storage)),this.started}async add(t){await this.start();const e=new URL(t,typeof location>"u"?void 0:location.href).href;return this.config.modules.some(r=>r.url===e)||(this.config={...this.config,modules:[...this.config.modules,{url:e,enabled:!0}]},this.save()),this.reload(e)}async remove(t){this.config={...this.config,modules:this.config.modules.filter(e=>e.url!==t)},this.save(),await this.reload(t)}async setEnabled(t,e){this.config={...this.config,modules:this.config.modules.map(r=>r.url===t?{...r,enabled:e}:r)},this.save(),await this.reload(t)}exportText(){return n.text(this.config)}async importText(t){const e=n.parse(t);await this.start();const r=this.config.modules.map(s=>s.url);this.config=e,this.save(),await Promise.all([...new Set([...r,...e.modules.map(s=>s.url)])].map(s=>this.reload(s)))}async require(t,e){t?.length&&(await this.start(),await Promise.all(t.map(async r=>{let s;try{s=new URL(r,e??(typeof location>"u"?void 0:location.href)).href}catch{return}const i=this.states.get(s);if(i&&i.status!=="off")return i.status==="loading"?this.pending.get(s):void 0;this.named.add(s),await this.reload(s)})))}named=new Set;pending=new Map;async applyConfig(t){this.config=t,await Promise.all(t.modules.map(e=>this.reload(e.url)))}reload(t){const e=this.reloadNow(t);return this.pending.set(t,e),e}async reloadNow(t){const e=this.config.modules.find(a=>a.url===t),r=this.states.get(t);r?.loaded&&p.uninstall(r.loaded.module.id);const s=e!==void 0,i=e?.enabled??!0;if(!s&&!this.named.has(t))return this.states.delete(t),this.announce(),{url:t,addedByPerson:s,enabled:i,status:"off"};if(s&&!i&&!this.named.has(t))return this.set({url:t,addedByPerson:s,enabled:i,status:"off"});this.set({url:t,addedByPerson:s,enabled:i,status:"loading"});try{const a=await this.loader.load(t,{runScript:s&&i});return p.install(a.module),this.set({url:t,addedByPerson:s,enabled:i,status:"installed",loaded:a})}catch(a){return this.set({url:t,addedByPerson:s,enabled:i,status:"failed",error:a instanceof Error?a.message:String(a)})}}set(t){return this.states.set(t.url,t),this.announce(),t}save(){n.write(this.config,this.storage)}announce(){this.changes.dispatchEvent(new Event("change"))}}export{y as ModuleSession};
@@ -1 +1 @@
1
- import{p as a,V as e,bl as s,H as r,K as t,ab as i,q as o,a5 as n,z as l,E as b,ar as d,ac as m,ad as u,bm as M,h as B,N as G,e as S,w as c,aJ as p,aG as y,aK as f,G as h,aX as x,F as C,bn as E,Q as L,bo as g,bp as D,bq as P,C as T,J as A,B as F,i as V,br as q,aa as v,Z as H}from"./rr0-scene.mjs";const K={AdditiveBlending:H,BackSide:v,BoxGeometry:q,BufferAttribute:V,BufferGeometry:F,CanvasTexture:A,Color:T,ConeGeometry:P,CylinderGeometry:D,DataTexture:g,DoubleSide:L,Euler:E,Float32BufferAttribute:C,FrontSide:x,Group:h,Line:f,LineBasicMaterial:y,LineSegments:p,Matrix4:c,Mesh:S,MeshBasicMaterial:G,MeshStandardMaterial:B,NormalBlending:M,Object3D:u,PlaneGeometry:m,PointLight:d,Points:b,PointsMaterial:l,Quaternion:n,ShaderMaterial:o,SphereGeometry:i,Sprite:t,SpriteMaterial:r,TorusGeometry:s,Vector2:e,Vector3:a};export{K as MODULE_THREE};
1
+ import{p as a,V as e,bm as s,H as r,K as t,ab as i,q as o,a5 as n,z as l,E as b,ar as d,ac as m,ad as u,bn as M,h as B,N as G,e as S,w as c,aJ as p,aG as y,aK as f,G as h,aX as x,F as C,bo as E,Q as L,bp as g,bq as D,br as P,C as T,J as A,B as F,i as V,bs as q,aa as v,Z as H}from"./rr0-scene.mjs";const K={AdditiveBlending:H,BackSide:v,BoxGeometry:q,BufferAttribute:V,BufferGeometry:F,CanvasTexture:A,Color:T,ConeGeometry:P,CylinderGeometry:D,DataTexture:g,DoubleSide:L,Euler:E,Float32BufferAttribute:C,FrontSide:x,Group:h,Line:f,LineBasicMaterial:y,LineSegments:p,Matrix4:c,Mesh:S,MeshBasicMaterial:G,MeshStandardMaterial:B,NormalBlending:M,Object3D:u,PlaneGeometry:m,PointLight:d,Points:b,PointsMaterial:l,Quaternion:n,ShaderMaterial:o,SphereGeometry:i,Sprite:t,SpriteMaterial:r,TorusGeometry:s,Vector2:e,Vector3:a};export{K as MODULE_THREE};
@@ -1,4 +1,4 @@
1
- import{b0 as T,b1 as K,b2 as z,b3 as H,b4 as W,b5 as w}from"./rr0-scene.mjs";class v{static read(t,e){let i=t;for(const n of e.split(".")){if(i=v.bare(i),i===null||typeof i!="object")return;i=i[n]}return v.bare(i)}static write(t,e,i){const n=e.split("."),s=[];let o=t;for(let r=0;r<n.length-1;r++){let a=v.bare(o[n[r]]);if(a===null||typeof a!="object"||Array.isArray(a)){if(i===void 0)return;a={}}o[n[r]]=a,s.push({owner:o,part:n[r]}),o=a}const d=n[n.length-1];i===void 0?delete o[d]:o[d]=i;for(let r=s.length-1;r>=0;r--){const a=s[r].owner[s[r].part];if(Object.keys(a).length>0)break;delete s[r].owner[s[r].part]}}static stated(t,e){return v.read(t,e)!==void 0}static bare(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&"value"in t&&"basis"in t?t.value:t}}class F{static sets=new Map;static publish(t){F.sets.set(t.kind,t)}static of(t){return F.sets.get(t)}static kinds(){return[...F.sets.keys()]}}class ${static resolved=new WeakMap;static resolve(t,e){let i=$.resolved.get(t);i||$.resolved.set(t,i=new WeakMap);let n=i.get(e);if(!n){const s=e,o=r=>{if(typeof r!="string")return r;if(typeof s[r]=="string")return s[r];const a=r.split(" ");return a.length>1&&a.every(c=>typeof s[c]=="string")?a.map(c=>s[c]).join(" "):r},d=r=>r.map(a=>({...a,label:o(a.label)}));n={...t,title:o(t.title),parameters:t.parameters.map(r=>{const a={...r,label:o(r.label),hint:o(r.hint),summary:o(r.summary),group:o(r.group),..."placeholder"in r?{placeholder:o(r.placeholder)}:{},..."empty"in r?{empty:o(r.empty)}:{}};if(a.type==="choice"){const c=a.optionsOf;return{...a,choices:d(a.choices),...c?{optionsOf:(l,h)=>d(c(l,h))}:{}}}if(a.type==="set"){const c=a.options;return{...a,options:(l,h)=>d(c(l,h))}}return a})},i.set(e,n)}return n}static missing(t,e){const i=e,n=new Set,s=o=>{if(typeof o=="string")for(const d of o.split(" "))/^[a-z][A-Za-z0-9]*$/.test(d)&&i[d]===void 0&&n.add(d)};s(t.title);for(const o of t.parameters)if(s(o.label),s(o.hint),s(o.summary),s(o.group),"placeholder"in o&&s(o.placeholder),"empty"in o&&s(o.empty),o.type==="choice")for(const d of o.choices)s(d.label);return[...n]}}class I{static attach(t,e,i){t.classList.add(e);const n=`${e}-style`;if(t.parentElement?.querySelector(`:scope > style.${n}`))return;const s=t.ownerDocument.createElement("style");s.className=n,s.textContent=i,t.before(s)}}class j{constructor(t,e,i,n){this.button=t,this.onPick=i,this.idOf=n;const s=this.panel=t.ownerDocument.createElement("div");s.id=e,s.className="add-menu",s.setAttribute("popover",""),s.setAttribute("role","menu");const o=`--add-menu-${e}`;t.style.setProperty("anchor-name",o),s.style.setProperty("position-anchor",o),t.setAttribute("popovertarget",e),t.setAttribute("aria-haspopup","menu"),t.after(s)}static CSS=`
1
+ import{a$ as K,b1 as $,b2 as j,b3 as U,b4 as W,b5 as z,b6 as f}from"./rr0-scene.mjs";class v{static read(t,e){let i=t;for(const n of e.split(".")){if(i=v.bare(i),i===null||typeof i!="object")return;i=i[n]}return v.bare(i)}static write(t,e,i){const n=e.split("."),s=[];let o=t;for(let r=0;r<n.length-1;r++){let a=v.bare(o[n[r]]);if(a===null||typeof a!="object"||Array.isArray(a)){if(i===void 0)return;a={}}o[n[r]]=a,s.push({owner:o,part:n[r]}),o=a}const d=n[n.length-1];i===void 0?delete o[d]:o[d]=i;for(let r=s.length-1;r>=0;r--){const a=s[r].owner[s[r].part];if(Object.keys(a).length>0)break;delete s[r].owner[s[r].part]}}static stated(t,e){return v.read(t,e)!==void 0}static bare(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&"value"in t&&"basis"in t?t.value:t}}class M{static sets=new Map;static publish(t){M.sets.set(t.kind,t)}static of(t){return M.sets.get(t)}static kinds(){return[...M.sets.keys()]}}class N{static resolved=new WeakMap;static resolve(t,e){let i=N.resolved.get(t);i||N.resolved.set(t,i=new WeakMap);let n=i.get(e);if(!n){const s=e,o=r=>{if(typeof r!="string")return r;if(typeof s[r]=="string")return s[r];const a=r.split(" ");return a.length>1&&a.every(c=>typeof s[c]=="string")?a.map(c=>s[c]).join(" "):r},d=r=>r.map(a=>({...a,label:o(a.label)}));n={...t,title:o(t.title),parameters:t.parameters.map(r=>{const a={...r,label:o(r.label),hint:o(r.hint),summary:o(r.summary),group:o(r.group),..."placeholder"in r?{placeholder:o(r.placeholder)}:{},..."empty"in r?{empty:o(r.empty)}:{}};if(a.type==="choice"){const c=a.optionsOf;return{...a,choices:d(a.choices),...c?{optionsOf:(l,h)=>d(c(l,h))}:{}}}if(a.type==="set"){const c=a.options;return{...a,options:(l,h)=>d(c(l,h))}}return a})},i.set(e,n)}return n}static missing(t,e){const i=e,n=new Set,s=o=>{if(typeof o=="string")for(const d of o.split(" "))/^[a-z][A-Za-z0-9]*$/.test(d)&&i[d]===void 0&&n.add(d)};s(t.title);for(const o of t.parameters)if(s(o.label),s(o.hint),s(o.summary),s(o.group),"placeholder"in o&&s(o.placeholder),"empty"in o&&s(o.empty),o.type==="choice")for(const d of o.choices)s(d.label);return[...n]}}class Q{static attach(t,e,i){t.classList.add(e);const n=`${e}-style`;if(t.parentElement?.querySelector(`:scope > style.${n}`))return;const s=t.ownerDocument.createElement("style");s.className=n,s.textContent=i,t.before(s)}}class G{constructor(t,e,i,n){this.button=t,this.onPick=i,this.idOf=n;const s=this.panel=t.ownerDocument.createElement("div");s.id=e,s.className="add-menu",s.setAttribute("popover",""),s.setAttribute("role","menu");const o=`--add-menu-${e}`;t.style.setProperty("anchor-name",o),s.style.setProperty("position-anchor",o),t.setAttribute("popovertarget",e),t.setAttribute("aria-haspopup","menu"),t.after(s)}static CSS=`
2
2
  .add-menu { padding: .3em 0; border: 1px solid color-mix(in srgb, CanvasText 30%, transparent); border-radius: 4px; background: Canvas; color: CanvasText;
3
3
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); max-height: 60vh; overflow-y: auto; font-size: .9em; }
4
4
  @supports (position-area: bottom span-left) {
@@ -9,10 +9,7 @@ import{b0 as T,b1 as K,b2 as z,b3 as H,b4 as W,b5 as w}from"./rr0-scene.mjs";cla
9
9
  .add-menu-choice:hover, .add-menu-choice:focus-visible { background: color-mix(in srgb, CanvasText 12%, transparent); }
10
10
  .add-menu-choice[aria-disabled="true"] { opacity: .45; cursor: not-allowed; background: none; }
11
11
  .add-menu-choice[hidden] { display: none; }
12
- `;panel;kinds=[];last;setKinds(t){this.kinds=t;const e=this.button.ownerDocument;this.panel.replaceChildren(...t.map(i=>{const n=e.createElement("button");return n.type="button",n.className="add-menu-choice",n.setAttribute("role","menuitem"),this.idOf&&(n.id=this.idOf(i.value)),n.dataset.value=i.value,n.textContent=i.label,n.hidden=i.hidden===!0,i.disabledReason&&(n.setAttribute("aria-disabled","true"),n.title=i.disabledReason),n.addEventListener("click",()=>{n.getAttribute("aria-disabled")!=="true"&&(this.close(),this.last=i.value,this.onPick(i.value))}),n}))}setDisabled(t,e){this.kinds=this.kinds.map(n=>n.value===t?{...n,disabledReason:e}:n);const i=[...this.panel.children].find(n=>n.dataset.value===t);i&&(e?(i.setAttribute("aria-disabled","true"),i.title=e):(i.removeAttribute("aria-disabled"),i.title=""))}labelOf(t){return this.kinds.find(e=>e.value===t)?.label??t}get lastPicked(){return this.last}close(){if(typeof this.panel.hidePopover=="function")try{this.panel.matches(":popover-open")&&this.panel.hidePopover()}catch{}}}class u{static draw(t,e="none"){return`<svg class="icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="${e}" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}static TRASH=u.draw('<path d="M2.5 4.5h11"/><path d="M6 4.5V3h4v1.5"/><path d="M4 4.5l.7 9h6.6l.7-9"/><path d="M6.8 7v4.5M9.2 7v4.5"/>');static TARGET=u.draw('<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="1.6"/><path d="M8 1v2.2M8 12.8V15M1 8h2.2M12.8 8H15"/>');static PLAY=u.draw('<path d="M5 3.2v9.6L12.6 8z"/>',"currentColor");static PAUSE=u.draw('<path d="M5.5 3.5v9M10.5 3.5v9"/>');static RECORD=u.draw('<circle cx="8" cy="8" r="4.2" fill="var(--error, #d93025)" stroke="none"/>');static STOP=u.draw('<rect x="4" y="4" width="8" height="8" rx="1.2"/>',"currentColor");static PREVIOUS_MARK=u.draw('<path d="M6.5 4 2.5 8l4 4"/><path d="M11 5.2 13.8 8 11 10.8 8.2 8z"/>');static NEXT_MARK=u.draw('<path d="M9.5 4l4 4-4 4"/><path d="M5 5.2 7.8 8 5 10.8 2.2 8z"/>');static CLOSE=u.draw('<path d="M4 4l8 8M12 4l-8 8"/>');static PLUS=u.draw('<path d="M8 3v10M3 8h10"/>');static COPY=u.draw('<rect x="5.5" y="5.5" width="8" height="8" rx="1.3"/><path d="M10.5 3.2h-7a1.3 1.3 0 0 0-1.3 1.3v7"/>');static CLOCK=u.draw('<circle cx="8" cy="8" r="6"/><path d="M8 4.6V8l2.4 1.6"/>');static INTERVIEW=u.draw('<path d="M13.3 9.2a1.6 1.6 0 0 1-1.6 1.6H6.2L3 13.4V4.4a1.6 1.6 0 0 1 1.6-1.6h7.1a1.6 1.6 0 0 1 1.6 1.6z"/><path d="M5.8 6.1h5.1M5.8 8.4h3.2"/>');static LOCK=u.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8"/>');static LOCK_OPEN=u.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.6-.7"/>');static METEOR=u.draw('<path d="M2.5 2.5l7 7"/><path d="M5.5 2.5l5 5"/><circle cx="11.5" cy="11.5" r="2"/>');static COMET=u.draw('<circle cx="11" cy="11" r="2.4"/><path d="M9.3 9.3 2.5 2.5M9 11.2 3 7M11.2 9 7 3"/>');static STAR=u.draw('<path d="M8 2.2l1.7 3.6 3.9.5-2.9 2.7.8 3.9L8 11l-3.5 1.9.8-3.9-2.9-2.7 3.9-.5z"/>');static SATELLITE=u.draw('<rect x="6.3" y="6.3" width="3.4" height="3.4" transform="rotate(45 8 8)"/><path d="M5.4 5.4 3 3M10.6 10.6 13 13"/><path d="M1.8 4.2 4.2 1.8M11.8 14.2l2.4-2.4"/><path d="M10.5 3.5a3 3 0 0 1 2 2"/>');static FIREBALL=u.draw('<circle cx="10.5" cy="10.5" r="2.6"/><path d="M8.6 8.6 3 3M8 10.6 4.5 8.5M10.6 8 8.5 4.5"/>');static SUMMARY=u.draw('<rect x="3" y="2" width="10" height="12" rx="1.5"/><path d="M5.5 5.5h5M5.5 8h5M5.5 10.5h3"/>');static WITNESS=u.draw('<circle cx="8" cy="5" r="2.6"/><path d="M2.8 14c.6-3 2.6-4.6 5.2-4.6s4.6 1.6 5.2 4.6"/>');static LOCATION=u.draw('<path d="M8 14.3s4.5-4.3 4.5-7.8a4.5 4.5 0 0 0-9 0c0 3.5 4.5 7.8 4.5 7.8z"/><circle cx="8" cy="6.5" r="1.6"/>');static DATE=u.draw('<rect x="2.3" y="3.3" width="11.4" height="10.4" rx="1.5"/><path d="M2.3 6.6h11.4M5.3 1.8v2.8M10.7 1.8v2.8"/>');static ENVIRONMENT=u.draw('<path d="M1.5 14h13"/><path d="M2.8 14V8.3L6.3 5.5l3.5 2.8V14"/><path d="M12.2 14V9.4"/><circle cx="12.2" cy="7.4" r="2.1"/>');static SKY=u.draw('<path d="M4.6 12.5h7a2.6 2.6 0 0 0 .3-5.2 3.8 3.8 0 0 0-7.3-.6 2.9 2.9 0 0 0 0 5.8z"/>');static PHENOMENON=u.draw('<ellipse cx="8" cy="9" rx="6.3" ry="2.1"/><path d="M4.6 7.8a3.4 3.4 0 0 1 6.8 0"/><path d="M5 13.4l.6-1.4M11 13.4l-.6-1.4M8 14v-1.4"/>');static SOUND=u.draw('<path d="M2.5 6.2h2.3L8 3.5v9L4.8 9.8H2.5z"/><path d="M10.5 6a2.8 2.8 0 0 1 0 4M12.3 4.2a5.4 5.4 0 0 1 0 7.6"/>');static PICTURES=u.draw('<rect x="2" y="3" width="12" height="10" rx="1.5"/><circle cx="5.8" cy="6.4" r="1.2"/><path d="M2.5 12l3.8-3.6 2.4 2.2 2.2-1.8 2.6 2.5"/>');static FILES=u.draw('<path d="M4 1.8h5.2L12.5 5v9.2H4z"/><path d="M9 1.8V5.2h3.5"/>');static BY_GLYPH={"🗑":u.TRASH,"🎯":u.TARGET,"+":u.PLUS,"✕":u.CLOSE,"▶":u.PLAY,"⏸":u.PAUSE,"⏺":u.RECORD,"⏹":u.STOP};static show(t,e){if(t.dataset.icon===e&&t.firstChild)return;const i=u.BY_GLYPH[e];i?t.innerHTML=i:t.textContent=e,t.dataset.icon=e}static CSS=`
13
- .icon { display: block; flex: none; }
14
- button:has(> .icon:only-child) { display: inline-flex; align-items: center; justify-content: center; }
15
- `}class O{constructor(t){this.options=t,this.row=document.createElement("div"),this.row.className="element-list-row",this.pickerRow=document.createElement("label"),this.pickerRow.className="element-list-picker",this.select=document.createElement("select"),this.select.id=t.ids.list,this.select.addEventListener("change",()=>t.onSelect(this.select.value)),this.pickerRow.append(this.select),t.header.append(this.row),this.row.append(this.pickerRow);const e=t.navigation;e&&(this.previousButton=this.iconButton(`${t.ids.list}-previous`,"▲"),this.nextButton=this.iconButton(`${t.ids.list}-next`,"▼"),this.previousButton.addEventListener("click",()=>e.onStep(-1)),this.nextButton.addEventListener("click",()=>e.onStep(1)),this.row.append(this.previousButton,this.nextButton),e.scope.addEventListener("keydown",i=>{if(!i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||i.key!=="ArrowUp"&&i.key!=="ArrowDown"||this.pickerRow.closest("[hidden]")||!this.pickerRow.isConnected)return;i.preventDefault(),i.stopPropagation();const n=i.key==="ArrowUp"?this.previousButton:this.nextButton;n&&!n.disabled&&e.onStep(i.key==="ArrowUp"?-1:1)}));for(const i of t.actions??[]){const n=this.iconButton(i.id,i.glyph);n.addEventListener("click",()=>i.onClick()),this.actionButtons.set(i.id,n),this.row.append(n)}this.removeButton=this.iconButton(t.ids.remove,"🗑"),this.removeButton.addEventListener("click",()=>t.onRemove()),this.emptyText=document.createElement("span"),this.emptyText.className="element-list-empty",this.addButton=this.iconButton(t.ids.add,"+"),this.addButton.classList.add("element-list-add"),this.row.append(this.removeButton,this.emptyText,this.addButton),t.ids.kinds?this.kindMenu=new j(this.addButton,t.ids.kinds,i=>t.onAdd(i),t.ids.kind):this.addButton.addEventListener("click",()=>t.onAdd(void 0)),t.body&&t.body.classList.add("element-list-body")}static CSS=`
12
+ `;panel;kinds=[];last;setKinds(t){this.kinds=t;const e=this.button.ownerDocument;this.panel.replaceChildren(...t.map(i=>{const n=e.createElement("button");return n.type="button",n.className="add-menu-choice",n.setAttribute("role","menuitem"),this.idOf&&(n.id=this.idOf(i.value)),n.dataset.value=i.value,n.textContent=i.label,n.hidden=i.hidden===!0,i.disabledReason&&(n.setAttribute("aria-disabled","true"),n.title=i.disabledReason),n.addEventListener("click",()=>{n.getAttribute("aria-disabled")!=="true"&&(this.close(),this.last=i.value,this.onPick(i.value))}),n}))}setDisabled(t,e){this.kinds=this.kinds.map(n=>n.value===t?{...n,disabledReason:e}:n);const i=[...this.panel.children].find(n=>n.dataset.value===t);i&&(e?(i.setAttribute("aria-disabled","true"),i.title=e):(i.removeAttribute("aria-disabled"),i.title=""))}labelOf(t){return this.kinds.find(e=>e.value===t)?.label??t}get lastPicked(){return this.last}close(){if(typeof this.panel.hidePopover=="function")try{this.panel.matches(":popover-open")&&this.panel.hidePopover()}catch{}}}class A{constructor(t){this.options=t,this.row=document.createElement("div"),this.row.className="element-list-row",this.pickerRow=document.createElement("label"),this.pickerRow.className="element-list-picker",this.select=document.createElement("select"),this.select.id=t.ids.list,this.select.addEventListener("change",()=>t.onSelect(this.select.value)),this.pickerRow.append(this.select),t.header.append(this.row),this.row.append(this.pickerRow);const e=t.navigation;e&&(this.previousButton=this.iconButton(`${t.ids.list}-previous`,"▲"),this.nextButton=this.iconButton(`${t.ids.list}-next`,"▼"),this.previousButton.addEventListener("click",()=>e.onStep(-1)),this.nextButton.addEventListener("click",()=>e.onStep(1)),this.row.append(this.previousButton,this.nextButton),e.scope.addEventListener("keydown",i=>{if(!i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||i.key!=="ArrowUp"&&i.key!=="ArrowDown"||this.pickerRow.closest("[hidden]")||!this.pickerRow.isConnected)return;i.preventDefault(),i.stopPropagation();const n=i.key==="ArrowUp"?this.previousButton:this.nextButton;n&&!n.disabled&&e.onStep(i.key==="ArrowUp"?-1:1)}));for(const i of t.actions??[]){const n=this.iconButton(i.id,i.glyph);n.addEventListener("click",()=>i.onClick()),this.actionButtons.set(i.id,n),this.row.append(n)}this.removeButton=this.iconButton(t.ids.remove,"🗑"),this.removeButton.addEventListener("click",()=>t.onRemove()),this.emptyText=document.createElement("span"),this.emptyText.className="element-list-empty",this.addButton=this.iconButton(t.ids.add,"+"),this.addButton.classList.add("element-list-add"),this.row.append(this.removeButton,this.emptyText,this.addButton),t.ids.kinds?this.kindMenu=new G(this.addButton,t.ids.kinds,i=>t.onAdd(i),t.ids.kind):this.addButton.addEventListener("click",()=>t.onAdd(void 0)),t.body&&t.body.classList.add("element-list-body")}static CSS=`
16
13
  .element-list-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .4em; flex: 1 1 100%; min-width: 0; }
17
14
  .element-list-picker { flex: 1 1 10em; min-width: 0; display: flex; }
18
15
  .element-list-picker select { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
@@ -25,7 +22,7 @@ button:has(> .icon:only-child) { display: inline-flex; align-items: center; just
25
22
  align-items: center; gap: .5em; }
26
23
  .element-list-picker select { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
27
24
  .element-list-row [hidden], .element-list-body[hidden] { display: none !important; }
28
- ${j.CSS}`;static showPresence(t,e,i,n=!1){for(const s of t.children)if(!s.matches(".element-list-add, .add-menu, .add-reason")){if(s.matches(".element-list-empty")){s.hidden=i||n;continue}if(s.matches(".element-list-picker")){s.hidden=!i&&!n;continue}s.hidden=!i&&!n,s instanceof HTMLButtonElement&&!i&&(s.disabled=!0)}e&&(e.hidden=!i,i&&!O.glued.has(e)&&O.glue(e))}static glued=new WeakSet;static glue(t){const e=t.parentElement,i=t.ownerDocument.defaultView;if(!e||!i)return;const n=i.getComputedStyle(e),s=/flex|grid/.test(n.display)&&parseFloat(n.rowGap)||0;t.style.marginTop=`${-s}px`,n.display!=="none"&&O.glued.add(t)}select;row;pickerRow;emptyText;removeButton;addButton;addReason;kindMenu;previousButton;nextButton;actionButtons=new Map;items=[];noneLabel="—";addLabel="";removeEnabled=!0;actionEnabled=new Map;iconButton(t,e){const i=document.createElement("button");return i.type="button",i.className="icon-btn",i.id=t,u.show(i,e),i}setLabels(t){if(this.previousButton&&this.nextButton)for(const[e,i,n]of[[this.previousButton,t.previous??"","Alt+↑"],[this.nextButton,t.next??"","Alt+↓"]]){const s=i===""?n:`${i} (${n})`;e.title=s,e.setAttribute("aria-label",i||s),e.setAttribute("aria-keyshortcuts",n.replace("↑","ArrowUp").replace("↓","ArrowDown"))}this.select.setAttribute("aria-label",t.list),this.emptyText.textContent=t.empty??"",this.noneLabel=t.none??this.noneLabel,this.addLabel=t.add,this.kindMenu?.panel.setAttribute("aria-label",t.add),this.options.optional&&this.listed(this.items,this.select.value);for(const[e,i]of[[this.removeButton,t.remove],[this.addButton,t.add],...[...this.actionButtons].map(([n,s])=>[s,t.actions?.[n]??""])])e.title=i,e.setAttribute("aria-label",i)}setKinds(t){this.kindMenu?.setKinds(t)}kindLabel(t){return this.kindMenu?.labelOf(t)??t}get pickedKind(){return this.kindMenu?.lastPicked}setItems(t,e){this.items=t,this.listed(t,e)}listed(t,e){this.select.replaceChildren(...this.options.optional?[new Option(this.noneLabel,"")]:[],...t.map(i=>new Option(i.label,i.id))),e!==void 0&&(this.select.value=e),this.select.selectedIndex<0&&(this.select.selectedIndex=0),this.setPresent(this.options.optional?this.select.value!=="":t.length>0)}setStepState(t,e){this.previousButton&&(this.previousButton.disabled=!t),this.nextButton&&(this.nextButton.disabled=!e)}setActionEnabled(t,e){const i=this.actionButtons.get(t);i&&(i.disabled=!e||this.select.disabled),this.actionEnabled.set(t,e)}setRemoveEnabled(t){this.removeEnabled=t,this.removeButton.disabled=!t||this.select.value===""&&this.options.optional===!0}get value(){return this.select.value}setAddState(t,e){this.addButton.disabled=!t;const i=e??this.addLabel;this.addButton.title=i,this.addButton.setAttribute("aria-label",i),this.addReason||(this.addReason=this.addButton.ownerDocument.createElement("span"),this.addReason.className="add-reason",this.addReason.style.cssText="font-size: .85em; opacity: .8; align-self: center;",this.row.append(this.addReason)),this.addReason.textContent=!t&&e?e:"",this.addReason.hidden=t||!e}rename(t,e){const i=[...this.select.options].find(n=>n.value===t);i&&(i.textContent=e)}show(t){this.select.value=t,this.options.optional&&this.setPresent(this.select.value!=="")}setPresent(t){const e=this.options.optional===!0;if(O.showPresence(this.row,this.options.body,t,e),this.select.disabled=!t&&!e,!!t){this.removeButton.disabled=!this.removeEnabled;for(const[i,n]of this.actionButtons)n.disabled=this.actionEnabled.get(i)===!1}}focus(){this.select.focus()}}class g{static CHROME="2.6em";static UNBOUNDED=9999;static fit(t){const e=[...t.querySelectorAll('input[type="number"]')];for(const i of e)i.style.width=`calc(${g.charsFor(i)}ch + ${g.CHROME})`,g.hold(i,!g.isFocused(i)),i.dataset.held!==""&&(i.dataset.held="",i.addEventListener("input",()=>g.hold(i)),i.addEventListener("change",()=>g.hold(i,!0)));return e.length}static hold(t,e=!1){const i=g.heldValue(t.value,t,e);i!==t.value&&(t.value=i,t.dispatchEvent(new Event("input",{bubbles:!0})))}static isFocused(t){return t.getRootNode().activeElement===t}static heldValue(t,e,i=!1){if(t===""||!/^-?\d+(\.\d+)?$/.test(t))return t;const n=g.wholeOnly(e.step)?0:g.decimalsOf(e.step),s=t.indexOf("."),o=s>=0&&t.length-s-1>n?n===0?t.slice(0,s):t.slice(0,s+n+1):t,d=Number(o),r=e.min===""?void 0:Number(e.min),a=e.max===""?void 0:Number(e.max);return a!==void 0&&d>a?String(a):i&&r!==void 0&&d<r?String(r):o}static charsFor(t){const e=d=>d===""?void 0:Math.abs(Number(d)),i=Math.max(e(t.max)??g.UNBOUNDED,e(t.min)??0),n=String(Math.floor(Number.isFinite(i)?i:g.UNBOUNDED)).length,s=t.min!==""&&Number(t.min)<0?1:0,o=g.wholeOnly(t.step)?0:g.decimalsOf(t.step);return n+s+(o>0?o+1:0)}static decimalsOf(t){if(t===""||t==="any")return 2;const e=t.indexOf(".");return Math.max(2,e<0?0:t.length-e-1)}static wholeOnly(t){return t!==""&&t!=="any"&&!t.includes(".")}}class S{static CSS=`
25
+ ${G.CSS}`;static showPresence(t,e,i,n=!1){for(const s of t.children)if(!s.matches(".element-list-add, .add-menu, .add-reason")){if(s.matches(".element-list-empty")){s.hidden=i||n;continue}if(s.matches(".element-list-picker")){s.hidden=!i&&!n;continue}s.hidden=!i&&!n,s instanceof HTMLButtonElement&&!i&&(s.disabled=!0)}e&&(e.hidden=!i,i&&!A.glued.has(e)&&A.glue(e))}static glued=new WeakSet;static glue(t){const e=t.parentElement,i=t.ownerDocument.defaultView;if(!e||!i)return;const n=i.getComputedStyle(e),s=/flex|grid/.test(n.display)&&parseFloat(n.rowGap)||0;t.style.marginTop=`${-s}px`,n.display!=="none"&&A.glued.add(t)}select;row;pickerRow;emptyText;removeButton;addButton;addReason;kindMenu;previousButton;nextButton;actionButtons=new Map;items=[];noneLabel="—";addLabel="";removeEnabled=!0;actionEnabled=new Map;iconButton(t,e){const i=document.createElement("button");return i.type="button",i.className="icon-btn",i.id=t,K.show(i,e),i}setLabels(t){if(this.previousButton&&this.nextButton)for(const[e,i,n]of[[this.previousButton,t.previous??"","Alt+↑"],[this.nextButton,t.next??"","Alt+↓"]]){const s=i===""?n:`${i} (${n})`;e.title=s,e.setAttribute("aria-label",i||s),e.setAttribute("aria-keyshortcuts",n.replace("↑","ArrowUp").replace("↓","ArrowDown"))}this.select.setAttribute("aria-label",t.list),this.emptyText.textContent=t.empty??"",this.noneLabel=t.none??this.noneLabel,this.addLabel=t.add,this.kindMenu?.panel.setAttribute("aria-label",t.add),this.options.optional&&this.listed(this.items,this.select.value);for(const[e,i]of[[this.removeButton,t.remove],[this.addButton,t.add],...[...this.actionButtons].map(([n,s])=>[s,t.actions?.[n]??""])])e.title=i,e.setAttribute("aria-label",i)}setKinds(t){this.kindMenu?.setKinds(t)}kindLabel(t){return this.kindMenu?.labelOf(t)??t}get pickedKind(){return this.kindMenu?.lastPicked}setItems(t,e){this.items=t,this.listed(t,e)}listed(t,e){this.select.replaceChildren(...this.options.optional?[new Option(this.noneLabel,"")]:[],...t.map(i=>new Option(i.label,i.id))),e!==void 0&&(this.select.value=e),this.select.selectedIndex<0&&(this.select.selectedIndex=0),this.setPresent(this.options.optional?this.select.value!=="":t.length>0)}setStepState(t,e){this.previousButton&&(this.previousButton.disabled=!t),this.nextButton&&(this.nextButton.disabled=!e)}setActionEnabled(t,e){const i=this.actionButtons.get(t);i&&(i.disabled=!e||this.select.disabled),this.actionEnabled.set(t,e)}setRemoveEnabled(t){this.removeEnabled=t,this.removeButton.disabled=!t||this.select.value===""&&this.options.optional===!0}get value(){return this.select.value}setAddState(t,e){this.addButton.disabled=!t;const i=e??this.addLabel;this.addButton.title=i,this.addButton.setAttribute("aria-label",i),this.addReason||(this.addReason=this.addButton.ownerDocument.createElement("span"),this.addReason.className="add-reason",this.addReason.style.cssText="font-size: .85em; opacity: .8; align-self: center;",this.row.append(this.addReason)),this.addReason.textContent=!t&&e?e:"",this.addReason.hidden=t||!e}rename(t,e){const i=[...this.select.options].find(n=>n.value===t);i&&(i.textContent=e)}show(t){this.select.value=t,this.options.optional&&this.setPresent(this.select.value!=="")}setPresent(t){const e=this.options.optional===!0;if(A.showPresence(this.row,this.options.body,t,e),this.select.disabled=!t&&!e,!!t){this.removeButton.disabled=!this.removeEnabled;for(const[i,n]of this.actionButtons)n.disabled=this.actionEnabled.get(i)===!1}}focus(){this.select.focus()}}class b{static CHROME="2.6em";static UNBOUNDED=9999;static fit(t){const e=[...t.querySelectorAll('input[type="number"]')];for(const i of e)i.style.width=`calc(${b.charsFor(i)}ch + ${b.CHROME})`,b.hold(i,!b.isFocused(i)),i.dataset.held!==""&&(i.dataset.held="",i.addEventListener("input",()=>b.hold(i)),i.addEventListener("change",()=>b.hold(i,!0)));return e.length}static hold(t,e=!1){const i=b.heldValue(t.value,t,e);i!==t.value&&(t.value=i,t.dispatchEvent(new Event("input",{bubbles:!0})))}static isFocused(t){return t.getRootNode().activeElement===t}static heldValue(t,e,i=!1){if(t===""||!/^-?\d+(\.\d+)?$/.test(t))return t;const n=b.wholeOnly(e.step)?0:b.decimalsOf(e.step),s=t.indexOf("."),o=s>=0&&t.length-s-1>n?n===0?t.slice(0,s):t.slice(0,s+n+1):t,d=Number(o),r=e.min===""?void 0:Number(e.min),a=e.max===""?void 0:Number(e.max);return a!==void 0&&d>a?String(a):i&&r!==void 0&&d<r?String(r):o}static charsFor(t){const e=d=>d===""?void 0:Math.abs(Number(d)),i=Math.max(e(t.max)??b.UNBOUNDED,e(t.min)??0),n=String(Math.floor(Number.isFinite(i)?i:b.UNBOUNDED)).length,s=t.min!==""&&Number(t.min)<0?1:0,o=b.wholeOnly(t.step)?0:b.decimalsOf(t.step);return n+s+(o>0?o+1:0)}static decimalsOf(t){if(t===""||t==="any")return 2;const e=t.indexOf(".");return Math.max(2,e<0?0:t.length-e-1)}static wholeOnly(t){return t!==""&&t!=="any"&&!t.includes(".")}}class E{static CSS=`
29
26
  .window-close {
30
27
  position: absolute; top: 8px; right: 8px; z-index: 1;
31
28
  display: inline-flex; align-items: center; justify-content: center;
@@ -35,7 +32,7 @@ ${j.CSS}`;static showPresence(t,e,i,n=!1){for(const s of t.children)if(!s.matche
35
32
  .window-close:hover, .window-close:focus-visible { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
36
33
  :is(dialog, [popover], .context-menu):has(> .window-close) { position: relative; padding-right: 44px; }
37
34
  .context-menu:has(> .window-close) { position: fixed; }
38
- `;static button(t,e,i){const n=t.querySelector(":scope > .window-close");if(n)return S.label(n,e),n;const s=document.createElement("button");return s.type="button",s.className="window-close",s.innerHTML=u.CLOSE,S.label(s,e),s.addEventListener("click",o=>{o.stopPropagation(),i()}),t.prepend(s),s}static popover(t,e){return S.button(t,e,()=>{typeof t.hidePopover=="function"&&t.matches(":popover-open")&&t.hidePopover()})}static dialog(t,e,i){if(!t.dataset.closesBeside){t.dataset.closesBeside="true";let n=!1;t.addEventListener("pointerdown",s=>n=s.target===t),t.addEventListener("click",s=>{s.target===t&&n&&S.outside(t,s)&&i()})}return S.button(t,e,i)}static outside(t,e){const i=t.getBoundingClientRect();return e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom}static label(t,e){t.title=e,t.setAttribute("aria-label",e)}}class y extends HTMLElement{static TAG="rr0-input-basis";static CSS=`
35
+ `;static button(t,e,i){const n=t.querySelector(":scope > .window-close");if(n)return E.label(n,e),n;const s=document.createElement("button");return s.type="button",s.className="window-close",s.innerHTML=K.CLOSE,E.label(s,e),s.addEventListener("click",o=>{o.stopPropagation(),i()}),t.prepend(s),s}static popover(t,e){return E.button(t,e,()=>{typeof t.hidePopover=="function"&&t.matches(":popover-open")&&t.hidePopover()})}static dialog(t,e,i){if(!t.dataset.closesBeside){t.dataset.closesBeside="true";let n=!1;t.addEventListener("pointerdown",s=>n=s.target===t),t.addEventListener("click",s=>{s.target===t&&n&&E.outside(t,s)&&i()})}return E.button(t,e,i)}static outside(t,e){const i=t.getBoundingClientRect();return e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom}static label(t,e){t.title=e,t.setAttribute("aria-label",e)}}class w extends HTMLElement{static TAG="rr0-input-basis";static CSS=`
39
36
  rr0-input-basis { display: inline-block; }
40
37
  rr0-input-basis[hidden] { display: none; }
41
38
  .basis-mark {
@@ -65,7 +62,7 @@ rr0-input-basis[hidden] { display: none; }
65
62
  .basis-source h4 { margin: 0 0 10px; font: 600 13px/1.3 var(--sans); color: var(--ink-dim); }
66
63
  .basis-source-free { margin: 0; font: 400 13px/1.45 var(--sans); color: var(--ink-dim); }
67
64
  .basis-window input { box-sizing: border-box; width: 100%; font-weight: 400; }
68
- `;hows=[];rationaleKept=!0;sourceKept=!0;choices={};wording;sourceWording;shown;mark;window;static count=0;anchor=`--rr0-basis-${++y.count}`;set anchorKey(t){this.anchor=`--rr0-basis-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,this.mark?.style.setProperty("anchor-name",this.anchor)}build(){if(this.mark)return;const t=document.createElement("span");t.className="basis-mark",t.setAttribute("role","button"),t.tabIndex=0,t.style.setProperty("anchor-name",this.anchor);const e=i=>{i.preventDefault(),i.stopPropagation(),this.open()};t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&e(i)}),this.append(t),this.mark=t,this.say()}connectedCallback(){this.build()}set messages(t){this.wording=t,this.say()}set sourceMessages(t){this.sourceWording=t}get entry(){return this.shown}set entry(t){this.shown=t&&(t.basis!=="stated"||t.how!==void 0||t.rationale!==void 0||t.source!==void 0)?{...t}:void 0,this.say()}get pill(){return this.build(),this.mark}say(){const t=this.mark,e=this.wording;if(!t||!e)return;const i=this.shown?.basis??"stated";t.dataset.basis=i,this.dataset.basis=i,t.textContent!==e.basis[i]&&(t.textContent=e.basis[i]),this.shown?.source?t.dataset.sourced="yes":delete t.dataset.sourced;const n=this.rationaleRead();t.title=n?`${e.title} : ${n}`:e.title,t.setAttribute("aria-label",`${e.title} : ${e.basis[i]}`)}rationaleRead(){return new T(K.preferencesFor(this)).read(this.shown?.rationale)}rationaleLanguage(){return z(K.preferencesFor(this),W)}static rationaleWritten(t,e,i){if(t===void 0||typeof t=="string")return e?{rationale:e}:{};const n=Object.fromEntries(Object.entries(t).filter(([o])=>o!==i)),s=e?{...n,[i]:e}:n;return Object.keys(s).length>0?{rationale:s}:{}}open(){const t=this.wording;if(!t)return;const e=Object.assign(document.createElement("h3"),{textContent:t.title}),i=document.createElement("select");for(const p of["established","measured","stated","derived","assumed","fitted"])i.append(new Option(t.basis[p],p));i.value=this.shown?.basis??"stated";const n=document.createElement("select");n.append(new Option("—",""));for(const p of this.hows)n.append(new Option(p.label,p.value));n.value=this.shown?.how??"";const s=document.createElement("textarea");s.value=this.rationaleRead()??"";const o=(p,m)=>{const f=document.createElement("label");return f.append(Object.assign(document.createElement("span"),{textContent:p}),m),f};let d=()=>this.shown?.source;const r=()=>{const p=i.value,m=d();this.entry={basis:p,...n.value?{how:n.value}:{},...y.rationaleWritten(this.shown?.rationale,s.value.trim(),this.rationaleLanguage()),...m?{source:m}:{}},this.dispatchEvent(new CustomEvent("basischange",{detail:{entry:this.shown},bubbles:!0,composed:!0}))};n.addEventListener("change",r),s.addEventListener("change",r);const a=document.createElement("div");a.className="basis-source";const c=()=>{d=this.drawSource(a,i.value,o,()=>r())};i.addEventListener("change",()=>{c(),r()});const l=this.windowElement(),h=this.sourceKept&&this.sourceWording!==void 0;h&&c(),l.replaceChildren(e,o(t.basisField,i),...this.hows.length>0?[o(t.howField,n)]:[],...this.rationaleKept?[o(t.rationaleField,s)]:[],...h?[a]:[]),S.popover(l,t.title),typeof l.showPopover=="function"&&l.isConnected?l.showPopover():l.hidden=!1}static kindOf(t){return t?.said?"said":t?.picture?"picture":t?.document!==void 0||t?.at||t?.url?"document":t?.tool?"tool":"none"}drawSource(t,e,i,n){const s=this.sourceWording;if(!s)return t.replaceChildren(),()=>{};if(H.free({basis:e}))return t.replaceChildren(Object.assign(document.createElement("p"),{className:"basis-source-free",textContent:s.free})),()=>{};const o=this.choices.interviews??[],d=this.choices.pictures??[],r=["none",...o.length>0?["said"]:[],"document",...d.length>0?["picture"]:[],"tool"],a=document.createElement("select");for(const f of r)a.append(new Option(s.kinds[f],f));const c=this.shown?.source,l=y.kindOf(c);a.value=r.includes(l)?l:"none";const h=document.createElement("div");let p=()=>{};const m=()=>{p=this.drawSourceFields(h,a.value,c,i,n)};return a.addEventListener("change",()=>{m(),n()}),m(),t.replaceChildren(i(s.field,a),h),()=>p()}drawSourceFields(t,e,i,n,s){const o=this.sourceWording,d=(e===y.kindOf(i)?i:void 0)??{},r=c=>{const l=document.createElement("input");return l.type="text",l.value=c??"",l.addEventListener("change",s),l},a=c=>c.value.trim()||void 0;if(e==="said"){const c=this.choices.interviews??[],l=document.createElement("select");for(const m of c)l.append(new Option(m.id===void 0?o.interviewOnly:m.label,m.id??""));l.value=d.said?.interview??c[0]?.id??"",l.selectedIndex<0&&c.length===1&&(l.selectedIndex=0);const h=document.createElement("select"),p=()=>{const m=c.find(f=>(f.id??"")===l.value)??c[0];h.replaceChildren(...(m?.segments??[]).map(f=>new Option(f.label||o.segmentUnnamed.replace("{n}",String(f.index+1)),String(f.index)))),d.said&&h.querySelector(`option[value="${d.said.segment}"]`)&&(h.value=String(d.said.segment))};return p(),l.addEventListener("change",()=>{p(),s()}),h.addEventListener("change",s),t.replaceChildren(n(o.interviewField,l),n(o.segmentField,h)),()=>{if(h.value==="")return;const m=c.find(f=>(f.id??"")===l.value);return{said:{...m?.id!==void 0?{interview:m.id}:{},segment:Number(h.value),...d.said?.range?{range:d.said.range}:{}}}}}if(e==="picture"){const c=this.choices.pictures??[],l=document.createElement("select");l.append(new Option("—",""));for(const h of c)l.append(new Option(h.label,h.id));return l.value=d.picture??"",l.addEventListener("change",s),t.replaceChildren(n(o.pictureField,l)),()=>l.value?{picture:l.value}:void 0}if(e==="tool"){const c=r(d.tool);return t.replaceChildren(n(o.toolField,c)),()=>a(c)?{tool:a(c)}:void 0}if(e==="document"){const c=r(typeof d.document=="string"?d.document:void 0),l=r(d.at),h=r(d.url);return t.replaceChildren(n(o.documentField,c),n(o.atField,l),n(o.urlField,h)),()=>{const p={...a(c)?{document:a(c)}:{},...a(l)?{at:a(l)}:{},...a(h)?{url:a(h)}:{}};return typeof d.document=="object"&&d.document!==null&&a(c)===void 0?Object.keys(p).length>0||d.document?{...p,document:d.document}:void 0:Object.keys(p).length>0?p:void 0}}return t.replaceChildren(),()=>{}}windowElement(){if(this.window)return this.window;const t=document.createElement("div");t.className="basis-window",t.setAttribute("popover",""),t.setAttribute("role","dialog"),t.style.setProperty("position-anchor",this.anchor),t.addEventListener("toggle",i=>{i.newState==="closed"&&(t.remove(),this.window=void 0)});const e=this.getRootNode();return e instanceof ShadowRoot?e.append(t):(e instanceof Document?e.body:this).append(t),this.window=t,t}get openWindow(){return this.window}}function Y(){customElements.get(y.TAG)||customElements.define(y.TAG,y)}const q="rr0-input-position",X={positionRelative:"relative",positionAbsolute:"absolute",positionModeHint:"Click to say it the other way: from something else, or as a latitude and a longitude",positionNoPlace:"The recording has no place yet: give the observer a latitude and a longitude first",positionFrom:"from",positionObserver:"the observer",positionEast:"East",positionNorth:"North",positionLatitude:"Latitude",positionLongitude:"Longitude",positionLabel:"Position",positionBasisHint:"Where this position comes from",positionBasisStated:"stated",positionBasisEstablished:"established",positionBasisMeasured:"measured",positionBasisDerived:"derived",positionBasisAssumed:"assumed",positionBasisFitted:"fitted",positionBasisField:"Basis"},J=`${y.CSS}
65
+ `;hows=[];rationaleKept=!0;sourceKept=!0;choices={};wording;sourceWording;shown;mark;window;static count=0;anchor=`--rr0-basis-${++w.count}`;set anchorKey(t){this.anchor=`--rr0-basis-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,this.mark?.style.setProperty("anchor-name",this.anchor)}build(){if(this.mark)return;const t=document.createElement("span");t.className="basis-mark",t.setAttribute("role","button"),t.tabIndex=0,t.style.setProperty("anchor-name",this.anchor);const e=i=>{i.preventDefault(),i.stopPropagation(),this.open()};t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&e(i)}),this.append(t),this.mark=t,this.say()}connectedCallback(){this.build()}set messages(t){this.wording=t,this.say()}set sourceMessages(t){this.sourceWording=t}get entry(){return this.shown}set entry(t){this.shown=t&&(t.basis!=="stated"||t.how!==void 0||t.rationale!==void 0||t.source!==void 0)?{...t}:void 0,this.say()}get pill(){return this.build(),this.mark}say(){const t=this.mark,e=this.wording;if(!t||!e)return;const i=this.shown?.basis??"stated";t.dataset.basis=i,this.dataset.basis=i,t.textContent!==e.basis[i]&&(t.textContent=e.basis[i]),this.shown?.source?t.dataset.sourced="yes":delete t.dataset.sourced;const n=this.rationaleRead();t.title=n?`${e.title} : ${n}`:e.title,t.setAttribute("aria-label",`${e.title} : ${e.basis[i]}`)}rationaleRead(){return new $(j.preferencesFor(this)).read(this.shown?.rationale)}rationaleLanguage(){return U(j.preferencesFor(this),z)}static rationaleWritten(t,e,i){if(t===void 0||typeof t=="string")return e?{rationale:e}:{};const n=Object.fromEntries(Object.entries(t).filter(([o])=>o!==i)),s=e?{...n,[i]:e}:n;return Object.keys(s).length>0?{rationale:s}:{}}open(){const t=this.wording;if(!t)return;const e=Object.assign(document.createElement("h3"),{textContent:t.title}),i=document.createElement("select");for(const u of["established","measured","stated","derived","assumed","fitted"])i.append(new Option(t.basis[u],u));i.value=this.shown?.basis??"stated";const n=document.createElement("select");n.append(new Option("—",""));for(const u of this.hows)n.append(new Option(u.label,u.value));n.value=this.shown?.how??"";const s=document.createElement("textarea");s.value=this.rationaleRead()??"";const o=(u,p)=>{const m=document.createElement("label");return m.append(Object.assign(document.createElement("span"),{textContent:u}),p),m};let d=()=>this.shown?.source;const r=()=>{const u=i.value,p=d();this.entry={basis:u,...n.value?{how:n.value}:{},...w.rationaleWritten(this.shown?.rationale,s.value.trim(),this.rationaleLanguage()),...p?{source:p}:{}},this.dispatchEvent(new CustomEvent("basischange",{detail:{entry:this.shown},bubbles:!0,composed:!0}))};n.addEventListener("change",r),s.addEventListener("change",r);const a=document.createElement("div");a.className="basis-source";const c=()=>{d=this.drawSource(a,i.value,o,()=>r())};i.addEventListener("change",()=>{c(),r()});const l=this.windowElement(),h=this.sourceKept&&this.sourceWording!==void 0;h&&c(),l.replaceChildren(e,o(t.basisField,i),...this.hows.length>0?[o(t.howField,n)]:[],...this.rationaleKept?[o(t.rationaleField,s)]:[],...h?[a]:[]),E.popover(l,t.title),typeof l.showPopover=="function"&&l.isConnected?l.showPopover():l.hidden=!1}static kindOf(t){return t?.said?"said":t?.picture?"picture":t?.document!==void 0||t?.at||t?.url?"document":t?.tool?"tool":"none"}drawSource(t,e,i,n){const s=this.sourceWording;if(!s)return t.replaceChildren(),()=>{};if(W.free({basis:e}))return t.replaceChildren(Object.assign(document.createElement("p"),{className:"basis-source-free",textContent:s.free})),()=>{};const o=this.choices.interviews??[],d=this.choices.pictures??[],r=["none",...o.length>0?["said"]:[],"document",...d.length>0?["picture"]:[],"tool"],a=document.createElement("select");for(const m of r)a.append(new Option(s.kinds[m],m));const c=this.shown?.source,l=w.kindOf(c);a.value=r.includes(l)?l:"none";const h=document.createElement("div");let u=()=>{};const p=()=>{u=this.drawSourceFields(h,a.value,c,i,n)};return a.addEventListener("change",()=>{p(),n()}),p(),t.replaceChildren(i(s.field,a),h),()=>u()}drawSourceFields(t,e,i,n,s){const o=this.sourceWording,d=(e===w.kindOf(i)?i:void 0)??{},r=c=>{const l=document.createElement("input");return l.type="text",l.value=c??"",l.addEventListener("change",s),l},a=c=>c.value.trim()||void 0;if(e==="said"){const c=this.choices.interviews??[],l=document.createElement("select");for(const p of c)l.append(new Option(p.id===void 0?o.interviewOnly:p.label,p.id??""));l.value=d.said?.interview??c[0]?.id??"",l.selectedIndex<0&&c.length===1&&(l.selectedIndex=0);const h=document.createElement("select"),u=()=>{const p=c.find(m=>(m.id??"")===l.value)??c[0];h.replaceChildren(...(p?.segments??[]).map(m=>new Option(m.label||o.segmentUnnamed.replace("{n}",String(m.index+1)),String(m.index)))),d.said&&h.querySelector(`option[value="${d.said.segment}"]`)&&(h.value=String(d.said.segment))};return u(),l.addEventListener("change",()=>{u(),s()}),h.addEventListener("change",s),t.replaceChildren(n(o.interviewField,l),n(o.segmentField,h)),()=>{if(h.value==="")return;const p=c.find(m=>(m.id??"")===l.value);return{said:{...p?.id!==void 0?{interview:p.id}:{},segment:Number(h.value),...d.said?.range?{range:d.said.range}:{}}}}}if(e==="picture"){const c=this.choices.pictures??[],l=document.createElement("select");l.append(new Option("—",""));for(const h of c)l.append(new Option(h.label,h.id));return l.value=d.picture??"",l.addEventListener("change",s),t.replaceChildren(n(o.pictureField,l)),()=>l.value?{picture:l.value}:void 0}if(e==="tool"){const c=r(d.tool);return t.replaceChildren(n(o.toolField,c)),()=>a(c)?{tool:a(c)}:void 0}if(e==="document"){const c=r(typeof d.document=="string"?d.document:void 0),l=r(d.at),h=r(d.url);return t.replaceChildren(n(o.documentField,c),n(o.atField,l),n(o.urlField,h)),()=>{const u={...a(c)?{document:a(c)}:{},...a(l)?{at:a(l)}:{},...a(h)?{url:a(h)}:{}};return typeof d.document=="object"&&d.document!==null&&a(c)===void 0?Object.keys(u).length>0||d.document?{...u,document:d.document}:void 0:Object.keys(u).length>0?u:void 0}}return t.replaceChildren(),()=>{}}windowElement(){if(this.window)return this.window;const t=document.createElement("div");t.className="basis-window",t.setAttribute("popover",""),t.setAttribute("role","dialog"),t.style.setProperty("position-anchor",this.anchor),t.addEventListener("toggle",i=>{i.newState==="closed"&&(t.remove(),this.window=void 0)});const e=this.getRootNode();return e instanceof ShadowRoot?e.append(t):(e instanceof Document?e.body:this).append(t),this.window=t,t}get openWindow(){return this.window}}function H(){customElements.get(w.TAG)||customElements.define(w.TAG,w)}const q="rr0-input-position",Y={positionRelative:"relative",positionAbsolute:"absolute",positionModeHint:"Click to say it the other way: from something else, or as a latitude and a longitude",positionNoPlace:"The recording has no place yet: give the observer a latitude and a longitude first",positionFrom:"from",positionObserver:"the observer",positionEast:"East",positionNorth:"North",positionLatitude:"Latitude",positionLongitude:"Longitude",positionLabel:"Position",positionBasisHint:"Where this position comes from",positionBasisStated:"stated",positionBasisEstablished:"established",positionBasisMeasured:"measured",positionBasisDerived:"derived",positionBasisAssumed:"assumed",positionBasisFitted:"fitted",positionBasisField:"Basis"},J=`${w.CSS}
69
66
  rr0-input-position { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3em .5em; }
70
67
  /* As the date's own switch (see DateInputElement): it reads as part of the label, before the fields. */
71
68
  rr0-input-position .position-mode { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-decoration: underline; text-underline-offset: .15em; }
@@ -83,12 +80,12 @@ rr0-input-position .position-geo input[type="number"] { width: 9.5em; }
83
80
  rr0-input-position .position-basis { order: -2; }
84
81
  rr0-input-position .position-mode { order: -1; }
85
82
  rr0-input-position [hidden] { display: none !important; }
86
- `;class E extends HTMLElement{modeButton;fromRow;fromSelect;localRow;geoRow;eastField;northField;latField;lngField;basisSelect;eastLabel;northLabel;latLabel;lngLabel;wording=X;shownFrame={references:[]};shownValue;shownBasis;relativeShown=!0;referenceId;build(){if(this.modeButton)return;const t=this.getAttribute("name")??"position",e=this.ownerDocument,i=e.createElement("style");i.textContent=J;const n=e.createElement("button");n.type="button",n.className="position-mode",n.addEventListener("click",()=>this.setRelative(!this.relativeShown));const s=e.createElement("span");s.className="position-from";const o=e.createElement("span");o.className="position-from-text";const d=e.createElement("select");d.id=`${t}-from`,d.addEventListener("input",()=>this.pickReference(d.value)),s.append(o,d);const r=this.getAttribute("step")??"0.1",a=(b,M,A,R)=>{const k=e.createElement("input");return k.type="number",k.id=b,k.min=String(M),k.max=String(A),k.step=R,k.autocomplete="off",k},c=(b,M)=>{const A=e.createElement("label");A.className="position-axis";const R=e.createElement("span");return A.append(R,b,M),{row:A,label:R}},l=Number(this.getAttribute("range")??3e4),h=a(this.getAttribute("east-id")??`${t}-east`,-l,l,r),p=a(this.getAttribute("north-id")??`${t}-north`,-l,l,r),m=a(this.getAttribute("lat-id")??`${t}-lat`,-90,90,"0.000001"),f=a(this.getAttribute("lng-id")??`${t}-lng`,-180,180,"0.000001"),B=e.createElement("span");B.className="position-local";const P=c(h,"m"),V=c(p,"m");B.append(P.row,V.row);const C=e.createElement("span");C.className="position-geo";const D=c(m,"°"),G=c(f,"°");C.append(D.row,G.row);for(const b of[h,p])b.addEventListener("input",()=>this.typedLocal());for(const b of[m,f])b.addEventListener("input",()=>this.typedGeo());Y();const x=e.createElement(y.TAG);x.id=`${t}-basis`,x.className="position-basis",x.rationaleKept=!1,x.sourceKept=!1,x.anchorKey=`${t}-basis`,x.addEventListener("basischange",b=>{b.stopPropagation();const M=b.detail.entry;this.shownBasis=M?.basis==="stated"?void 0:M?.basis,this.dispatchEvent(new CustomEvent("basischange",{detail:{basis:this.shownBasis},bubbles:!0,composed:!0}))}),this.append(i,n,s,B,C,x),this.modeButton=n,this.fromRow=s,this.fromSelect=d,this.localRow=B,this.geoRow=C,this.eastField=h,this.northField=p,this.latField=m,this.lngField=f,this.basisSelect=x,this.eastLabel=P.label,this.northLabel=V.label,this.latLabel=D.label,this.lngLabel=G.label,this.relativeShown=!this.isGeo,this.word(),this.show()}connectedCallback(){this.build()}get isGeo(){return this.getAttribute("native")==="geo"}get eastInput(){return this.build(),this.eastField}get northInput(){return this.build(),this.northField}get latInput(){return this.build(),this.latField}get lngInput(){return this.build(),this.lngField}get frame(){return this.shownFrame}set frame(t){this.shownFrame=t,this.build(),this.pullDegrees(),this.show()}get value(){return this.shownValue}set value(t){if(this.shownValue=t,this.build(),this.isGeo){const e=t;this.latField.value=e?String(w.degrees(e.lat)):"",this.lngField.value=e?String(w.degrees(e.lng)):""}this.show()}set said(t){this.build(),this.pullDegrees(),w.isRelative(t)?(this.relativeShown=!0,this.referenceId=t.relativeTo):w.isAbsolute(t)?this.relativeShown=!1:(this.relativeShown=!this.isGeo,this.referenceId=void 0),this.show()}get said(){const t=this.localValue();if(t)return w.restated(this.relativeShown?w.relative(0,0,this.referenceId):{lat:0,lng:0},t,this.shownFrame)}get relative(){return this.relativeShown}get basis(){return this.shownBasis}set basis(t){this.shownBasis=t==="stated"?void 0:t,this.build(),this.markBasis()}set basisShown(t){this.build(),this.basisSelect.hidden=!t}set messages(t){this.wording=t,this.modeButton&&(this.word(),this.show())}setRelative(t){!this.shownFrame.origin||this.references().length===0||(this.pullDegrees(),this.relativeShown=t,this.show())}pullDegrees(){if(!this.isGeo||!this.latField)return;const t=E.typed(this.latField),e=E.typed(this.lngField);this.shownValue=t!==void 0&&e!==void 0?{lat:t,lng:e}:this.latField.value===""&&this.lngField.value===""?void 0:this.shownValue}word(){const t=this.wording;this.eastLabel.textContent=t.positionEast,this.northLabel.textContent=t.positionNorth,this.latLabel.textContent=t.positionLatitude,this.lngLabel.textContent=t.positionLongitude,this.fromRow.querySelector(".position-from-text").textContent=t.positionFrom,this.basisSelect.messages={title:t.positionBasisHint,basisField:t.positionBasisField,howField:"",rationaleField:"",basis:{established:t.positionBasisEstablished,stated:t.positionBasisStated,measured:t.positionBasisMeasured,derived:t.positionBasisDerived,assumed:t.positionBasisAssumed,fitted:t.positionBasisFitted}},this.markBasis()}markBasis(){this.basisSelect&&(this.basisSelect.entry=this.shownBasis?{basis:this.shownBasis}:void 0)}references(){const t=this.shownFrame.references;return t.length>0||this.isGeo?t:[{label:this.wording.positionObserver,eastM:0,northM:0}]}reference(){const t=this.references();return t.find(e=>e.id===this.referenceId)??t[0]??{label:"",eastM:0,northM:0}}localValue(){const t=this.shownValue;if(!t)return;if(!this.isGeo)return t;const e=this.shownFrame.origin;return e?w.toLocal(t,e):void 0}geoValue(){const t=this.shownValue;if(!t)return;if(this.isGeo)return t;const e=this.shownFrame.origin;return e?w.toGeo(t,e):void 0}show(){if(!this.modeButton)return;const t=this.wording,e=this.shownFrame.origin!==void 0&&this.references().length>0;e||(this.relativeShown=!this.isGeo);const i=this.modeButton;i.textContent=this.relativeShown?t.positionRelative:t.positionAbsolute,i.disabled=!e,i.title=e?t.positionModeHint:t.positionNoPlace;const n=this.references(),s=this.fromSelect,o=n.map(h=>h.id??"");([...s.options].map(h=>h.value).join(`
83
+ `;class x extends HTMLElement{modeButton;fromRow;fromSelect;localRow;geoRow;eastField;northField;latField;lngField;basisSelect;eastLabel;northLabel;latLabel;lngLabel;wording=Y;shownFrame={references:[]};shownValue;shownBasis;relativeShown=!0;referenceId;build(){if(this.modeButton)return;const t=this.getAttribute("name")??"position",e=this.ownerDocument,i=e.createElement("style");i.textContent=J;const n=e.createElement("button");n.type="button",n.className="position-mode",n.addEventListener("click",()=>this.setRelative(!this.relativeShown));const s=e.createElement("span");s.className="position-from";const o=e.createElement("span");o.className="position-from-text";const d=e.createElement("select");d.id=`${t}-from`,d.addEventListener("input",()=>this.pickReference(d.value)),s.append(o,d);const r=this.getAttribute("step")??"0.1",a=(g,S,B,F)=>{const k=e.createElement("input");return k.type="number",k.id=g,k.min=String(S),k.max=String(B),k.step=F,k.autocomplete="off",k},c=(g,S)=>{const B=e.createElement("label");B.className="position-axis";const F=e.createElement("span");return B.append(F,g,S),{row:B,label:F}},l=Number(this.getAttribute("range")??3e4),h=a(this.getAttribute("east-id")??`${t}-east`,-l,l,r),u=a(this.getAttribute("north-id")??`${t}-north`,-l,l,r),p=a(this.getAttribute("lat-id")??`${t}-lat`,-90,90,"0.000001"),m=a(this.getAttribute("lng-id")??`${t}-lng`,-180,180,"0.000001"),O=e.createElement("span");O.className="position-local";const P=c(h,"m"),T=c(u,"m");O.append(P.row,T.row);const C=e.createElement("span");C.className="position-geo";const D=c(p,"°"),I=c(m,"°");C.append(D.row,I.row);for(const g of[h,u])g.addEventListener("input",()=>this.typedLocal());for(const g of[p,m])g.addEventListener("input",()=>this.typedGeo());H();const y=e.createElement(w.TAG);y.id=`${t}-basis`,y.className="position-basis",y.rationaleKept=!1,y.sourceKept=!1,y.anchorKey=`${t}-basis`,y.addEventListener("basischange",g=>{g.stopPropagation();const S=g.detail.entry;this.shownBasis=S?.basis==="stated"?void 0:S?.basis,this.dispatchEvent(new CustomEvent("basischange",{detail:{basis:this.shownBasis},bubbles:!0,composed:!0}))}),this.append(i,n,s,O,C,y),this.modeButton=n,this.fromRow=s,this.fromSelect=d,this.localRow=O,this.geoRow=C,this.eastField=h,this.northField=u,this.latField=p,this.lngField=m,this.basisSelect=y,this.eastLabel=P.label,this.northLabel=T.label,this.latLabel=D.label,this.lngLabel=I.label,this.relativeShown=!this.isGeo,this.word(),this.show()}connectedCallback(){this.build()}get isGeo(){return this.getAttribute("native")==="geo"}get eastInput(){return this.build(),this.eastField}get northInput(){return this.build(),this.northField}get latInput(){return this.build(),this.latField}get lngInput(){return this.build(),this.lngField}get frame(){return this.shownFrame}set frame(t){this.shownFrame=t,this.build(),this.pullDegrees(),this.show()}get value(){return this.shownValue}set value(t){if(this.shownValue=t,this.build(),this.isGeo){const e=t;this.latField.value=e?String(f.degrees(e.lat)):"",this.lngField.value=e?String(f.degrees(e.lng)):""}this.show()}set said(t){this.build(),this.pullDegrees(),f.isRelative(t)?(this.relativeShown=!0,this.referenceId=t.relativeTo):f.isAbsolute(t)?this.relativeShown=!1:(this.relativeShown=!this.isGeo,this.referenceId=void 0),this.show()}get said(){const t=this.localValue();if(t)return f.restated(this.relativeShown?f.relative(0,0,this.referenceId):{lat:0,lng:0},t,this.shownFrame)}get relative(){return this.relativeShown}get basis(){return this.shownBasis}set basis(t){this.shownBasis=t==="stated"?void 0:t,this.build(),this.markBasis()}set basisShown(t){this.build(),this.basisSelect.hidden=!t}set messages(t){this.wording=t,this.modeButton&&(this.word(),this.show())}setRelative(t){!this.shownFrame.origin||this.references().length===0||(this.pullDegrees(),this.relativeShown=t,this.show())}pullDegrees(){if(!this.isGeo||!this.latField)return;const t=x.typed(this.latField),e=x.typed(this.lngField);this.shownValue=t!==void 0&&e!==void 0?{lat:t,lng:e}:this.latField.value===""&&this.lngField.value===""?void 0:this.shownValue}word(){const t=this.wording;this.eastLabel.textContent=t.positionEast,this.northLabel.textContent=t.positionNorth,this.latLabel.textContent=t.positionLatitude,this.lngLabel.textContent=t.positionLongitude,this.fromRow.querySelector(".position-from-text").textContent=t.positionFrom,this.basisSelect.messages={title:t.positionBasisHint,basisField:t.positionBasisField,howField:"",rationaleField:"",basis:{established:t.positionBasisEstablished,stated:t.positionBasisStated,measured:t.positionBasisMeasured,derived:t.positionBasisDerived,assumed:t.positionBasisAssumed,fitted:t.positionBasisFitted}},this.markBasis()}markBasis(){this.basisSelect&&(this.basisSelect.entry=this.shownBasis?{basis:this.shownBasis}:void 0)}references(){const t=this.shownFrame.references;return t.length>0||this.isGeo?t:[{label:this.wording.positionObserver,eastM:0,northM:0}]}reference(){const t=this.references();return t.find(e=>e.id===this.referenceId)??t[0]??{label:"",eastM:0,northM:0}}localValue(){const t=this.shownValue;if(!t)return;if(!this.isGeo)return t;const e=this.shownFrame.origin;return e?f.toLocal(t,e):void 0}geoValue(){const t=this.shownValue;if(!t)return;if(this.isGeo)return t;const e=this.shownFrame.origin;return e?f.toGeo(t,e):void 0}show(){if(!this.modeButton)return;const t=this.wording,e=this.shownFrame.origin!==void 0&&this.references().length>0;e||(this.relativeShown=!this.isGeo);const i=this.modeButton;i.textContent=this.relativeShown?t.positionRelative:t.positionAbsolute,i.disabled=!e,i.title=e?t.positionModeHint:t.positionNoPlace;const n=this.references(),s=this.fromSelect,o=n.map(h=>h.id??"");([...s.options].map(h=>h.value).join(`
87
84
  `)!==o.join(`
88
85
  `)||[...s.options].map(h=>h.text).join(`
89
86
  `)!==n.map(h=>h.label).join(`
90
- `))&&s.replaceChildren(...n.map(h=>new Option(h.label,h.id??""))),this.referenceId!==void 0&&!n.some(h=>h.id===this.referenceId)&&(this.referenceId=void 0),s.value=this.referenceId??o[0]??"",this.fromRow.hidden=!this.relativeShown,this.localRow.hidden=!this.relativeShown,this.geoRow.hidden=this.relativeShown;const d=this.getRootNode().activeElement,r=(h,p)=>{h!==d&&(h.value=p===void 0?"":String(p))},a=this.localValue(),c=this.reference();if(r(this.eastField,a?w.metres(a.eastM-c.eastM):void 0),r(this.northField,a?w.metres(a.northM-c.northM):void 0),this.isGeo&&!this.relativeShown)return;const l=this.geoValue();r(this.latField,l?w.degrees(l.lat):void 0),r(this.lngField,l?w.degrees(l.lng):void 0)}pickReference(t){this.pullDegrees(),this.referenceId=t===""?void 0:t,this.show();const e=this.said;e&&this.shownValue&&this.tell(this.shownValue,e)}static typed(t){const e=t.value.trim(),i=e===""?NaN:Number(e);return Number.isFinite(i)?i:void 0}typedLocal(){const t=E.typed(this.eastField),e=E.typed(this.northField);if(t===void 0||e===void 0)return;const i=this.reference(),n={eastM:i.eastM+t,northM:i.northM+e};let s=n;if(this.isGeo){const o=this.shownFrame.origin;if(!o)return;s=w.toGeo(n,o)}this.shownValue=s,this.tell(s,w.relative(t,e,this.referenceId))}typedGeo(){const t=E.typed(this.latField),e=E.typed(this.lngField);if(t===void 0||e===void 0)return;let i={lat:t,lng:e};if(!this.isGeo){const n=this.shownFrame.origin;if(!n)return;i=w.toLocal({lat:t,lng:e},n)}this.shownValue=i,this.tell(i,{lat:t,lng:e})}tell(t,e){this.show();const i=this.isGeo?w.isAbsolute(e):w.isRelative(e)&&e.relativeTo===void 0;this.dispatchEvent(new CustomEvent("positionchange",{detail:{value:t,said:i?void 0:e},bubbles:!0,composed:!0}))}}function Z(){customElements.get(q)||customElements.define(q,E)}class N{constructor(t,e,i=()=>{},n){this.read=t,this.edit=e,this.context=i,this.place=n}static inPlace(t){return new N(()=>t,e=>e(t))}}class L{constructor(t,e,i="",n,s){this.container=t,this.idPrefix=i,this.values=n,this.enhance=s,this.said=new T([e,"en"])}set;target;changed=()=>{};said;setLanguage(t){this.said=new T([t,"en"]),this.set&&this.target&&this.show(this.set,this.target,this.changed)}show(t,e,i){this.set=t,this.target=e instanceof N?e:N.inPlace(e),this.changed=i,this.container.replaceChildren();const n=new Map;for(const s of t.parameters){const o=this.read(s.group)??"";let d=n.get(o);if(!d){if(d=document.createElement("fieldset"),d.className="parameter-group",o!==""){const r=document.createElement("legend");r.textContent=o,d.append(r)}else d.classList.add("parameter-group-untitled"),d.style.border="0",d.style.padding="0",d.style.marginInline="0";n.set(o,d),this.container.append(d)}d.append(this.fieldOf(s))}g.fit(this.container),this.sync()}clear(){this.set=void 0,this.target=void 0,this.container.replaceChildren()}field(t){return this.container.querySelector(`[data-key="${t}"]`)??void 0}sync(t=!1){const e=this.target?.read();if(!this.set||!e)return;const i=this.target.context(),n=t?null:this.container.getRootNode().activeElement;for(const s of this.set.parameters){const o=s.type==="position"?this.positionOf(s):this.field(s.key);if(!o)continue;const d=o.closest("label, .parameter-row")??o;d.hidden=s.visibleWhen!==void 0&&!s.visibleWhen(e,i);const r=v.read(e,s.key);if(s.type==="number"){const a=o;a!==n&&(a.value=typeof r=="number"?L.shown(r,s):"");const c=L.boundsOf(s,e,i);a.min=String(c.min),a.max=String(c.max);const l=s.effective?.(e,i);a.placeholder=l!==void 0?L.shown(l,s):this.read(s.placeholder)??"",a.classList.toggle("parameter-derived",r===void 0)}else if(s.type==="choice"){const a=o,c=s.optionsOf?.(e,i)??s.choices;if([...a.options].filter(l=>l.value!=="").map(l=>l.value).join(`
87
+ `))&&s.replaceChildren(...n.map(h=>new Option(h.label,h.id??""))),this.referenceId!==void 0&&!n.some(h=>h.id===this.referenceId)&&(this.referenceId=void 0),s.value=this.referenceId??o[0]??"",this.fromRow.hidden=!this.relativeShown,this.localRow.hidden=!this.relativeShown,this.geoRow.hidden=this.relativeShown;const d=this.getRootNode().activeElement,r=(h,u)=>{h!==d&&(h.value=u===void 0?"":String(u))},a=this.localValue(),c=this.reference();if(r(this.eastField,a?f.metres(a.eastM-c.eastM):void 0),r(this.northField,a?f.metres(a.northM-c.northM):void 0),this.isGeo&&!this.relativeShown)return;const l=this.geoValue();r(this.latField,l?f.degrees(l.lat):void 0),r(this.lngField,l?f.degrees(l.lng):void 0)}pickReference(t){this.pullDegrees(),this.referenceId=t===""?void 0:t,this.show();const e=this.said;e&&this.shownValue&&this.tell(this.shownValue,e)}static typed(t){const e=t.value.trim(),i=e===""?NaN:Number(e);return Number.isFinite(i)?i:void 0}typedLocal(){const t=x.typed(this.eastField),e=x.typed(this.northField);if(t===void 0||e===void 0)return;const i=this.reference(),n={eastM:i.eastM+t,northM:i.northM+e};let s=n;if(this.isGeo){const o=this.shownFrame.origin;if(!o)return;s=f.toGeo(n,o)}this.shownValue=s,this.tell(s,f.relative(t,e,this.referenceId))}typedGeo(){const t=x.typed(this.latField),e=x.typed(this.lngField);if(t===void 0||e===void 0)return;let i={lat:t,lng:e};if(!this.isGeo){const n=this.shownFrame.origin;if(!n)return;i=f.toLocal({lat:t,lng:e},n)}this.shownValue=i,this.tell(i,{lat:t,lng:e})}tell(t,e){this.show();const i=this.isGeo?f.isAbsolute(e):f.isRelative(e)&&e.relativeTo===void 0;this.dispatchEvent(new CustomEvent("positionchange",{detail:{value:t,said:i?void 0:e},bubbles:!0,composed:!0}))}}function X(){customElements.get(q)||customElements.define(q,x)}class R{constructor(t,e,i=()=>{},n){this.read=t,this.edit=e,this.context=i,this.place=n}static inPlace(t){return new R(()=>t,e=>e(t))}}class L{constructor(t,e,i="",n,s){this.container=t,this.idPrefix=i,this.values=n,this.enhance=s,this.said=new $([e,"en"])}set;target;changed=()=>{};said;setLanguage(t){this.said=new $([t,"en"]),this.set&&this.target&&this.show(this.set,this.target,this.changed)}show(t,e,i){this.set=t,this.target=e instanceof R?e:R.inPlace(e),this.changed=i,this.container.replaceChildren();const n=new Map;for(const s of t.parameters){const o=this.read(s.group)??"";let d=n.get(o);if(!d){if(d=document.createElement("fieldset"),d.className="parameter-group",o!==""){const r=document.createElement("legend");r.textContent=o,d.append(r)}else d.classList.add("parameter-group-untitled"),d.style.border="0",d.style.padding="0",d.style.marginInline="0";n.set(o,d),this.container.append(d)}d.append(this.fieldOf(s))}b.fit(this.container),this.sync()}clear(){this.set=void 0,this.target=void 0,this.container.replaceChildren()}field(t){return this.container.querySelector(`[data-key="${t}"]`)??void 0}sync(t=!1){const e=this.target?.read();if(!this.set||!e)return;const i=this.target.context(),n=t?null:this.container.getRootNode().activeElement;for(const s of this.set.parameters){const o=s.type==="position"?this.positionOf(s):this.field(s.key);if(!o)continue;const d=o.closest("label, .parameter-row")??o;d.hidden=s.visibleWhen!==void 0&&!s.visibleWhen(e,i);const r=v.read(e,s.key);if(s.type==="number"){const a=o;a!==n&&(a.value=typeof r=="number"?L.shown(r,s):"");const c=L.boundsOf(s,e,i);a.min=String(c.min),a.max=String(c.max);const l=s.effective?.(e,i);a.placeholder=l!==void 0?L.shown(l,s):this.read(s.placeholder)??"",a.classList.toggle("parameter-derived",r===void 0)}else if(s.type==="choice"){const a=o,c=s.optionsOf?.(e,i)??s.choices;if([...a.options].filter(l=>l.value!=="").map(l=>l.value).join(`
91
88
  `)!==c.map(l=>l.value).join(`
92
- `)&&a.replaceChildren(...s.required?[]:[new Option("—","")],...c.map(l=>new Option(this.read(l.label)??l.value,l.value))),a!==n&&(a.value=typeof r=="string"&&c.some(l=>l.value===r)?r:s.required?a.options[0]?.value??"":""),!s.required){const l=s.effective?.(e,i),h=c.find(p=>p.value===l);a.options[0].textContent=h?this.read(h.label)??h.value:this.read(s.empty)??"—"}}else if(s.type==="boolean"){const a=o;a.checked=r===!0}else if(s.type==="colour"){const a=o;a!==n&&(a.value=L.swatchOf(r,s.fallback??"#808080"))}else if(s.type==="set")this.syncSet(s,o,e,i);else if(s.type==="position")this.syncPosition(s,o,e);else if(s.type==="said"){const a=o;a!==n&&(a.value=this.values?.said().read(v.read(e,s.key))??""),this.markMissing(s,a)}else{const a=o;a!==n&&(a.value=typeof r=="string"?r:"",a.classList.remove("invalid"),a.removeAttribute("aria-invalid"))}}for(const s of this.container.querySelectorAll("fieldset.parameter-group"))s.hidden=[...s.querySelectorAll("label, .parameter-row")].filter(o=>o.parentElement===s).every(o=>o.hidden)}fieldOf(t){const e=document.createElement("label"),i=this.read(t.hint);i&&(e.title=i);const n=document.createElement("span");n.textContent=this.read(t.label)??t.key,e.append(n," ");let s;if(t.type==="choice"){const o=document.createElement("select");this.identify(o,t),t.required||o.append(new Option("—","")),o.append(...t.choices.map(d=>new Option(this.read(d.label)??d.value,d.value))),o.addEventListener("input",()=>this.write(t,o.value===""?void 0:o.value)),e.append(o),this.enhance?.(t,o)}else{if(t.type==="position")return this.setRow(t,this.positionFieldOf(t));if(t.type==="set"){const o=document.createElement("div");return this.identify(o,t),o.className="parameter-set",o.addEventListener("input",()=>{const d=[...o.querySelectorAll("input:checked")].map(r=>r.value);this.write(t,d.length>0?d:void 0)}),this.setRow(t,o)}else if(t.type==="boolean"){const o=document.createElement("input");o.type="checkbox",this.identify(o,t),o.addEventListener("input",()=>this.write(t,o.checked?!0:t.required?!1:void 0)),e.prepend(o),e.append(" ")}else{const o=document.createElement("input");this.identify(o,t),o.autocomplete="off",t.type==="number"?(o.type="number",o.min=String(t.min),o.max=String(t.max),o.step=String(t.step),s=t.unit,o.addEventListener("input",()=>{const d=o.value.trim();if(d==="")return t.required?void 0:this.write(t,void 0);const r=Number(d);Number.isFinite(r)&&this.write(t,r)})):t.type==="colour"?(o.type="color",o.addEventListener("input",()=>this.write(t,o.value))):t.type==="said"?(o.type="text",o.placeholder=this.read(t.placeholder)??"",o.style.setProperty("field-sizing","content"),o.style.minWidth="10em",o.style.maxWidth="100%",o.addEventListener("input",()=>{const d=this.target?.read(),r=this.values;!d||!r||(this.write(t,r.said().write(v.read(d,t.key),o.value,r.writingLanguage())),this.markMissing(t,o))})):(o.type="text",o.placeholder=this.read(t.placeholder)??"",o.addEventListener("input",()=>{const d=t.required||t.validate?o.value.trim():o.value,r=this.target?.read(),a=r!==void 0&&(t.required===!0&&d===""||d!==""&&t.validate?.(d,r,this.target.context())===!1);o.classList.toggle("invalid",a),a?o.setAttribute("aria-invalid","true"):o.removeAttribute("aria-invalid"),!a&&this.write(t,d===""?void 0:d)}),o.addEventListener("change",()=>{if(!o.classList.contains("invalid"))return;o.classList.remove("invalid"),o.removeAttribute("aria-invalid");const d=this.target?.read(),r=d===void 0?void 0:v.read(d,t.key);o.value=typeof r=="string"?r:""})),e.append(o)}}return s&&e.append(` ${s}`),e}markMissing(t,e){t.type!=="said"||!t.required||(e.classList.toggle("invalid",e.value===""),e.setAttribute("aria-invalid",String(e.value==="")))}positionFieldOf(t){Z();const e=document.createElement("rr0-input-position"),i=`${this.idPrefix}${t.key}`;e.setAttribute("name",i),t.native==="geo"&&e.setAttribute("native","geo"),t.step!==void 0&&e.setAttribute("step",String(t.step)),t.rangeM!==void 0&&e.setAttribute("range",String(t.rangeM));const n=t.native==="geo"?["lat-id","lng-id"]:["east-id","north-id"];this.idPrefix!==""&&(e.setAttribute(n[0],`${this.idPrefix}${t.key}`),e.setAttribute(n[1],`${this.idPrefix}${t.secondKey}`)),e.dataset.position=t.key,e.build();const[s,o]=t.native==="geo"?[e.latInput,e.lngInput]:[e.eastInput,e.northInput];s.dataset.key=t.key,o.dataset.key=t.secondKey;const d=this.target?.place;return d&&(e.messages=d.messages()),e.basisShown=d?.basis!==void 0,e.addEventListener("positionchange",r=>{const{value:a,said:c}=r.detail;this.writePosition(t,a,c)}),e.addEventListener("basischange",r=>this.target?.place?.basis?.write(t,r.detail.basis)),e}positionOf(t){return this.container.querySelector(`rr0-input-position[data-position="${t.key}"]`)??void 0}syncPosition(t,e,i){const n=this.target?.place;n&&(e.messages=n.messages(),e.frame=n.frame());const s=v.read(i,t.key),o=v.read(i,t.secondKey),d=typeof s=="number"&&typeof o=="number";e.value=d?t.native==="geo"?{lat:s,lng:o}:{eastM:s,northM:o}:void 0;const r=v.read(i,t.saidKey),a=JSON.stringify(r??null);e.dataset.said!==a&&(e.dataset.said=a,e.said=r),e.basis=n?.basis?.read(t)}writePosition(t,e,i){const n=this.target;if(!n)return;const[s,o]="lat"in e?[e.lat,e.lng]:[e.eastM,e.northM],d=t.native==="geo"?r=>Math.round(r*1e7)/1e7:r=>Math.round(r*1e3)/1e3;this.positionOf(t)?.setAttribute("data-said",JSON.stringify(i??null)),n.edit(r=>{v.write(r,t.key,d(s)),v.write(r,t.secondKey,d(o)),v.write(r,t.saidKey,i)},t),this.changed(),this.sync()}setRow(t,e){const i=document.createElement("div");i.className="parameter-row";const n=this.read(t.hint);n&&(i.title=n);const s=document.createElement("span");return s.textContent=this.read(t.label)??t.key,i.append(s," ",e),i}syncSet(t,e,i,n){if(t.type!=="set")return;const s=v.read(i,t.key),o=new Set(Array.isArray(s)?s:[]),d=t.options(i,n);if(d.length===0){e.textContent=this.read(t.empty)??"";return}[...e.querySelectorAll("input")].map(a=>a.value).join(`
89
+ `)&&a.replaceChildren(...s.required?[]:[new Option("—","")],...c.map(l=>new Option(this.read(l.label)??l.value,l.value))),a!==n&&(a.value=typeof r=="string"&&c.some(l=>l.value===r)?r:s.required?a.options[0]?.value??"":""),!s.required){const l=s.effective?.(e,i),h=c.find(u=>u.value===l);a.options[0].textContent=h?this.read(h.label)??h.value:this.read(s.empty)??"—"}}else if(s.type==="boolean"){const a=o;a.checked=r===!0}else if(s.type==="colour"){const a=o;a!==n&&(a.value=L.swatchOf(r,s.fallback??"#808080"))}else if(s.type==="set")this.syncSet(s,o,e,i);else if(s.type==="position")this.syncPosition(s,o,e);else if(s.type==="said"){const a=o;a!==n&&(a.value=this.values?.said().read(v.read(e,s.key))??""),this.markMissing(s,a)}else{const a=o;a!==n&&(a.value=typeof r=="string"?r:"",a.classList.remove("invalid"),a.removeAttribute("aria-invalid"))}}for(const s of this.container.querySelectorAll("fieldset.parameter-group"))s.hidden=[...s.querySelectorAll("label, .parameter-row")].filter(o=>o.parentElement===s).every(o=>o.hidden)}fieldOf(t){const e=document.createElement("label"),i=this.read(t.hint);i&&(e.title=i);const n=document.createElement("span");n.textContent=this.read(t.label)??t.key,e.append(n," ");let s;if(t.type==="choice"){const o=document.createElement("select");this.identify(o,t),t.required||o.append(new Option("—","")),o.append(...t.choices.map(d=>new Option(this.read(d.label)??d.value,d.value))),o.addEventListener("input",()=>this.write(t,o.value===""?void 0:o.value)),e.append(o),this.enhance?.(t,o)}else{if(t.type==="position")return this.setRow(t,this.positionFieldOf(t));if(t.type==="set"){const o=document.createElement("div");return this.identify(o,t),o.className="parameter-set",o.addEventListener("input",()=>{const d=[...o.querySelectorAll("input:checked")].map(r=>r.value);this.write(t,d.length>0?d:void 0)}),this.setRow(t,o)}else if(t.type==="boolean"){const o=document.createElement("input");o.type="checkbox",this.identify(o,t),o.addEventListener("input",()=>this.write(t,o.checked?!0:t.required?!1:void 0)),e.prepend(o),e.append(" ")}else{const o=document.createElement("input");this.identify(o,t),o.autocomplete="off",t.type==="number"?(o.type="number",o.min=String(t.min),o.max=String(t.max),o.step=String(t.step),s=t.unit,o.addEventListener("input",()=>{const d=o.value.trim();if(d==="")return t.required?void 0:this.write(t,void 0);const r=Number(d);Number.isFinite(r)&&this.write(t,r)})):t.type==="colour"?(o.type="color",o.addEventListener("input",()=>this.write(t,o.value))):t.type==="said"?(o.type="text",o.placeholder=this.read(t.placeholder)??"",o.style.setProperty("field-sizing","content"),o.style.minWidth="10em",o.style.maxWidth="100%",o.addEventListener("input",()=>{const d=this.target?.read(),r=this.values;!d||!r||(this.write(t,r.said().write(v.read(d,t.key),o.value,r.writingLanguage())),this.markMissing(t,o))})):(o.type="text",o.placeholder=this.read(t.placeholder)??"",o.addEventListener("input",()=>{const d=t.required||t.validate?o.value.trim():o.value,r=this.target?.read(),a=r!==void 0&&(t.required===!0&&d===""||d!==""&&t.validate?.(d,r,this.target.context())===!1);o.classList.toggle("invalid",a),a?o.setAttribute("aria-invalid","true"):o.removeAttribute("aria-invalid"),!a&&this.write(t,d===""?void 0:d)}),o.addEventListener("change",()=>{if(!o.classList.contains("invalid"))return;o.classList.remove("invalid"),o.removeAttribute("aria-invalid");const d=this.target?.read(),r=d===void 0?void 0:v.read(d,t.key);o.value=typeof r=="string"?r:""})),e.append(o)}}return s&&e.append(` ${s}`),e}markMissing(t,e){t.type!=="said"||!t.required||(e.classList.toggle("invalid",e.value===""),e.setAttribute("aria-invalid",String(e.value==="")))}positionFieldOf(t){X();const e=document.createElement("rr0-input-position"),i=`${this.idPrefix}${t.key}`;e.setAttribute("name",i),t.native==="geo"&&e.setAttribute("native","geo"),t.step!==void 0&&e.setAttribute("step",String(t.step)),t.rangeM!==void 0&&e.setAttribute("range",String(t.rangeM));const n=t.native==="geo"?["lat-id","lng-id"]:["east-id","north-id"];this.idPrefix!==""&&(e.setAttribute(n[0],`${this.idPrefix}${t.key}`),e.setAttribute(n[1],`${this.idPrefix}${t.secondKey}`)),e.dataset.position=t.key,e.build();const[s,o]=t.native==="geo"?[e.latInput,e.lngInput]:[e.eastInput,e.northInput];s.dataset.key=t.key,o.dataset.key=t.secondKey;const d=this.target?.place;return d&&(e.messages=d.messages()),e.basisShown=d?.basis!==void 0,e.addEventListener("positionchange",r=>{const{value:a,said:c}=r.detail;this.writePosition(t,a,c)}),e.addEventListener("basischange",r=>this.target?.place?.basis?.write(t,r.detail.basis)),e}positionOf(t){return this.container.querySelector(`rr0-input-position[data-position="${t.key}"]`)??void 0}syncPosition(t,e,i){const n=this.target?.place;n&&(e.messages=n.messages(),e.frame=n.frame());const s=v.read(i,t.key),o=v.read(i,t.secondKey),d=typeof s=="number"&&typeof o=="number";e.value=d?t.native==="geo"?{lat:s,lng:o}:{eastM:s,northM:o}:void 0;const r=v.read(i,t.saidKey),a=JSON.stringify(r??null);e.dataset.said!==a&&(e.dataset.said=a,e.said=r),e.basis=n?.basis?.read(t)}writePosition(t,e,i){const n=this.target;if(!n)return;const[s,o]="lat"in e?[e.lat,e.lng]:[e.eastM,e.northM],d=t.native==="geo"?r=>Math.round(r*1e7)/1e7:r=>Math.round(r*1e3)/1e3;this.positionOf(t)?.setAttribute("data-said",JSON.stringify(i??null)),n.edit(r=>{v.write(r,t.key,d(s)),v.write(r,t.secondKey,d(o)),v.write(r,t.saidKey,i)},t),this.changed(),this.sync()}setRow(t,e){const i=document.createElement("div");i.className="parameter-row";const n=this.read(t.hint);n&&(i.title=n);const s=document.createElement("span");return s.textContent=this.read(t.label)??t.key,i.append(s," ",e),i}syncSet(t,e,i,n){if(t.type!=="set")return;const s=v.read(i,t.key),o=new Set(Array.isArray(s)?s:[]),d=t.options(i,n);if(d.length===0){e.textContent=this.read(t.empty)??"";return}[...e.querySelectorAll("input")].map(a=>a.value).join(`
93
90
  `)===d.map(a=>a.value).join(`
94
- `)||e.replaceChildren(...d.map(a=>{const c=document.createElement("label"),l=document.createElement("input");return l.type="checkbox",l.value=a.value,c.append(l," ",a.label),c}));for(const a of e.querySelectorAll("input"))a.checked=o.has(a.value)}identify(t,e){t.dataset.key=e.key,this.idPrefix!==""&&(t.id=`${this.idPrefix}${e.key}`)}write(t,e){const i=this.target;if(!i)return;let n=e;if(t.type==="number"&&typeof e=="number"){const s=i.read();if(s){const o=L.boundsOf(t,s,i.context());n=Math.max(o.min,Math.min(o.max,e))/(t.scale??1)}}i.edit(s=>v.write(s,t.key,n),t),this.changed(),this.sync()}read(t){return this.said.read(t)}static boundsOf(t,e,i){const n=t.bounds?.(e,i);return{min:n?.min??t.min,max:n?.max??t.max}}static swatchOf(t,e){if(typeof t!="string")return e;const i=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(t);return i?`#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(t)?t.toLowerCase():e}static shown(t,e){const i=Math.max(2,Math.min(6,(String(e.step).split(".")[1]??"").length));return String(Number((t*(e.scale??1)).toFixed(i)))}static choicesOf(t){return t.choices.map(e=>e.value)}}export{O as E,u as I,F as P,I as S,L as a,$ as b,N as c};
91
+ `)||e.replaceChildren(...d.map(a=>{const c=document.createElement("label"),l=document.createElement("input");return l.type="checkbox",l.value=a.value,c.append(l," ",a.label),c}));for(const a of e.querySelectorAll("input"))a.checked=o.has(a.value)}identify(t,e){t.dataset.key=e.key,this.idPrefix!==""&&(t.id=`${this.idPrefix}${e.key}`)}write(t,e){const i=this.target;if(!i)return;let n=e;if(t.type==="number"&&typeof e=="number"){const s=i.read();if(s){const o=L.boundsOf(t,s,i.context());n=Math.max(o.min,Math.min(o.max,e))/(t.scale??1)}}i.edit(s=>v.write(s,t.key,n),t),this.changed(),this.sync()}read(t){return this.said.read(t)}static boundsOf(t,e,i){const n=t.bounds?.(e,i);return{min:n?.min??t.min,max:n?.max??t.max}}static swatchOf(t,e){if(typeof t!="string")return e;const i=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(t);return i?`#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(t)?t.toLowerCase():e}static shown(t,e){const i=Math.max(2,Math.min(6,(String(e.step).split(".")[1]??"").length));return String(Number((t*(e.scale??1)).toFixed(i)))}static choicesOf(t){return t.choices.map(e=>e.value)}}export{A as E,M as P,Q as S,L as a,N as b,R as c};