signalk-siparu 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,6 +43,17 @@ generator tab. The same gauges are also served over the API (`GET /live`,
43
43
  Pi to a Victron Cerbo GX (Venus OS Large). Nothing here needs node-gyp.
44
44
  - **Compatibility floor:** Node 20 + signalk-server 2.18.
45
45
 
46
+ ## Not a safety system
47
+
48
+ Siparu is not a navigation, safety or alarm system, and it is not a substitute for
49
+ seamanship, a watchkeeper, or going aboard to look. It reads instruments that
50
+ drift, break and lie, and it carries what they say over networks that fail,
51
+ starting with the boat's own uplink: a screen with nothing wrong on it is not the
52
+ same thing as a boat that is fine, and the plugin raises no alarm to tell you
53
+ otherwise. The chart is for looking, not for navigating, and a depth reading is
54
+ whichever plane the boat's own sounder reports, which is not always the water
55
+ under the keel. Do not rely on this software to protect life or property.
56
+
46
57
  ## Before you pair: turn on Signal K security
47
58
 
48
59
  Signal K ships with security switched off, and nothing in the setup makes you turn
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-siparu",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Kept aboard, proven ashore. An impartial, timestamped record of every voyage: position, wind, depth and logbook, written on the boat and readable from anywhere. A read-only Signal K plugin with a built-in dashboard.",
5
5
  "keywords": [
6
6
  "signalk-node-server-plugin",
@@ -254,7 +254,7 @@ module.exports = (app) => {
254
254
  const plugin = {
255
255
  id: PLUGIN_ID,
256
256
  name: 'Siparu',
257
- description: 'Kept aboard, proven ashore: records position, wind, depth and voyage history on the boat and serves a read-only dashboard. Never writes to the boat. Turn Signal K security on (add an admin user) before pairing: with it off these endpoints answer anyone on your network, and someone else can link this vessel to their account.',
257
+ description: 'Kept aboard, proven ashore: records position, wind, depth and voyage history on the boat and serves a read-only dashboard. Never writes to the boat. Not a navigation, safety or alarm system: it raises no alarm, and a screen with nothing wrong on it is not the same thing as a boat that is fine. Turn Signal K security on (add an admin user) before pairing: with it off these endpoints answer anyone on your network, and someone else can link this vessel to their account.',
258
258
  schema: config_1.CONFIG_SCHEMA,
259
259
  start(config, restart) {
260
260
  const gen = ++startGen;
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,c as n,g as r,i,l as a,n as o,o as s,p as c,s as l,t as u,u as d,y as f}from"./index-5gz9-vQd.js";import{t as p}from"./visibleInterval-CFxPzgzx.js";var m=e(f(),1),h={"1m":1,"1h":60,"6h":360,"1d":1440},g={"1m":60,"1h":48,"6h":40,"1d":30},_=15e3;function v(){let[e,t]=(0,m.useState)(`1h`),[n,i]=(0,m.useState)(0),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)([]),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),v=h[e],y=g[e]+n*g[e],b=(0,m.useCallback)(e=>{t(e),i(0),c([]),o(!1)},[]),x=(0,m.useCallback)(async()=>{f(!0),u(null);try{let e=y+1,t=await r.logbook.snapshots({bucket:v,limit:e,order:`desc`});o(t.length>y),c(t.slice(0,y))}catch(e){u(e.message)}finally{f(!1)}},[v,y]);return(0,m.useEffect)(()=>{x();let e=p(x,_);return()=>e()},[x]),{granularity:e,changeGran:b,snaps:s,err:l,busy:d,hasMore:a,loadMore:(0,m.useCallback)(()=>i(e=>e+1),[])}}function y(){let[e,t]=(0,m.useState)(o()),[n,i]=(0,m.useState)([]),[a,s]=(0,m.useState)(null),[l,d]=(0,m.useState)(!1),f=(0,m.useRef)(!0),h=c(6e4),g=o(new Date(h)),v=(0,m.useMemo)(()=>u(e),[e]),y=v+24*36e5,b=e===g;(0,m.useEffect)(()=>{f.current&&e!==g&&t(g)},[g,e]);let x=(0,m.useCallback)(e=>{f.current=e===o(),t(e)},[]),S=(0,m.useCallback)(async()=>{d(!0),s(null);try{let e=await r.logbook.snapshots({from:v,to:y,limit:5e3,order:`desc`,bucket:60});i(e)}catch(e){s(e.message)}finally{d(!1)}},[v,y]);return(0,m.useEffect)(()=>{if(S(),!b)return;let e=p(S,_);return()=>e()},[S,b]),{dateStr:e,setDateStr:x,dayStart:v,isToday:b,snaps:n,err:a,busy:l,prevDay:(0,m.useCallback)(()=>x(o(new Date(v-864e5))),[v,x]),nextDay:(0,m.useCallback)(()=>x(o(new Date(v+864e5))),[v,x]),goToday:(0,m.useCallback)(()=>x(o()),[x])}}var b=t(),x=[`1m`,`1h`,`6h`,`1d`],S={"1m":`Last hour`,"1h":`Last 2 days`,"6h":`Last 10 days`,"1d":`Last month`};function C(){let[e,t]=(0,m.useState)(`live`),[n,r]=(0,m.useState)(()=>localStorage.getItem(`lb:windUnit`)||`kn`),i={mode:e,setMode:t,windUnit:n,toggleWind:()=>r(e=>{let t=e===`kn`?`bft`:`kn`;return localStorage.setItem(`lb:windUnit`,t),t})};return(0,b.jsx)(`div`,{className:`lb`,children:e===`live`?(0,b.jsx)(E,{...i}):(0,b.jsx)(D,{...i})})}function w({mode:e,setMode:t}){return(0,b.jsxs)(`div`,{className:`seg`,children:[(0,b.jsx)(`button`,{className:e===`live`?`on`:``,onClick:()=>t(`live`),children:`Live`}),(0,b.jsx)(`button`,{className:e===`day`?`on`:``,onClick:()=>t(`day`),children:`Day`})]})}function T({windUnit:e,toggleWind:t}){return(0,b.jsxs)(`div`,{className:`lb-cols`,children:[(0,b.jsx)(`span`,{children:`UTC`}),(0,b.jsx)(`span`,{children:`SOG`}),(0,b.jsx)(`span`,{children:`HDG`}),(0,b.jsx)(`span`,{className:`tap`,onClick:t,title:`Tap: knots ⇄ Beaufort`,children:e===`kn`?`TWS`:`BFT`}),(0,b.jsx)(`span`,{children:`BARO`}),(0,b.jsx)(`span`,{children:`DEP`})]})}function E({mode:e,setMode:t,windUnit:n,toggleWind:r}){let{granularity:i,changeGran:a,snaps:o,err:s,busy:c,hasMore:l,loadMore:u}=v();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`lb-ctrl`,children:[(0,b.jsx)(w,{mode:e,setMode:t}),(0,b.jsx)(`div`,{className:`seg`,children:x.map(e=>(0,b.jsx)(`button`,{className:i===e?`on`:``,onClick:()=>a(e),children:e},e))}),(0,b.jsx)(`span`,{className:`lb-count`,children:o.length})]}),(0,b.jsx)(T,{windUnit:n,toggleWind:r}),(0,b.jsxs)(`div`,{className:`lb-day`,children:[(0,b.jsx)(`span`,{children:S[i]}),(0,b.jsx)(`b`,{children:o.length})]}),s&&(0,b.jsx)(`div`,{className:`lb-err`,children:s}),(0,b.jsx)(O,{snaps:o,windUnit:n,footer:l?(0,b.jsx)(`button`,{className:`lb-more`,onClick:u,disabled:c,children:c?`Loading…`:`Load ${g[i]} more`}):null})]})}function D({mode:e,setMode:t,windUnit:n,toggleWind:r}){let{dateStr:i,setDateStr:a,isToday:s,snaps:c,err:l,busy:u,prevDay:d,nextDay:f,goToday:p}=y(),m=s?`Today · ${new Date(i).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,timeZone:`UTC`})}`:new Date(i).toLocaleDateString(`en-GB`,{weekday:`short`,day:`2-digit`,month:`short`,timeZone:`UTC`}).replace(/,/g,``);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`lb-ctrl`,children:[(0,b.jsx)(w,{mode:e,setMode:t}),(0,b.jsxs)(`div`,{className:`lb-date`,children:[(0,b.jsx)(`button`,{onClick:d,"aria-label":`Previous day`,children:`‹`}),(0,b.jsx)(`input`,{type:`date`,className:`dt`,value:i,max:o(),onChange:e=>a(e.target.value),style:{border:`1.5px solid var(--rule)`,background:`var(--cell)`,color:`var(--text)`,fontFamily:`var(--sp-font)`,fontSize:12,padding:`5px 7px`}}),(0,b.jsx)(`button`,{onClick:f,disabled:s,"aria-label":`Next day`,children:`›`}),(0,b.jsx)(`button`,{onClick:p,disabled:s,children:`Now`})]})]}),(0,b.jsx)(T,{windUnit:n,toggleWind:r}),(0,b.jsxs)(`div`,{className:`lb-day`,children:[(0,b.jsx)(`span`,{children:m}),(0,b.jsx)(`b`,{children:c.length})]}),l&&(0,b.jsx)(`div`,{className:`lb-err`,children:l}),!u&&c.length===0?(0,b.jsxs)(`div`,{className:`sp-empty`,children:[(0,b.jsx)(`div`,{className:`em-t`,children:`No snapshots`}),(0,b.jsx)(`div`,{className:`em-s`,children:`No telemetry was logged for this day.`})]}):(0,b.jsx)(O,{snaps:c,windUnit:n,footer:null})]})}function O({snaps:e,footer:t,windUnit:n}){return(0,b.jsxs)(`div`,{className:`lb-rows`,children:[e.map(e=>(0,b.jsx)(k,{s:e,windUnit:n},e.ts)),t]})}function k({s:e,windUnit:t}){let r=new Date(e.ts),o=e=>String(e).padStart(2,`0`),c=d(e.sog),u=a(e.heading_true??e.heading_mag),f=l(e.wind_speed_true),p=f===null?`·`:String(t===`kn`?Math.round(f):s(f)??`·`),m=n(e.air_pressure_pa);return(0,b.jsxs)(`div`,{className:`lb-row`,children:[(0,b.jsxs)(`span`,{className:`tm`,children:[o(r.getUTCHours()),`:`,o(r.getUTCMinutes())]}),(0,b.jsx)(`span`,{className:`v`,children:i(c,1)}),(0,b.jsx)(`span`,{className:`v`,children:u===null?`·`:Math.round(u)+`°`}),(0,b.jsx)(`span`,{className:`v`,children:p}),(0,b.jsx)(`span`,{className:`v dim`,children:m===null?`·`:Math.round(m)}),(0,b.jsx)(`span`,{className:`v`,children:e.depth===null?`·`:e.depth.toFixed(1)})]})}function A(){return(0,b.jsx)(C,{})}export{A as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,c as n,g as r,i,l as a,n as o,o as s,p as c,s as l,t as u,u as d,y as f}from"./index-RgGUQ86M.js";import{t as p}from"./visibleInterval-CFxPzgzx.js";var m=e(f(),1),h={"1m":1,"1h":60,"6h":360,"1d":1440},g={"1m":60,"1h":48,"6h":40,"1d":30},_=15e3;function v(){let[e,t]=(0,m.useState)(`1h`),[n,i]=(0,m.useState)(0),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)([]),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),v=h[e],y=g[e]+n*g[e],b=(0,m.useCallback)(e=>{t(e),i(0),c([]),o(!1)},[]),x=(0,m.useCallback)(async()=>{f(!0),u(null);try{let e=y+1,t=await r.logbook.snapshots({bucket:v,limit:e,order:`desc`});o(t.length>y),c(t.slice(0,y))}catch(e){u(e.message)}finally{f(!1)}},[v,y]);return(0,m.useEffect)(()=>{x();let e=p(x,_);return()=>e()},[x]),{granularity:e,changeGran:b,snaps:s,err:l,busy:d,hasMore:a,loadMore:(0,m.useCallback)(()=>i(e=>e+1),[])}}function y(){let[e,t]=(0,m.useState)(o()),[n,i]=(0,m.useState)([]),[a,s]=(0,m.useState)(null),[l,d]=(0,m.useState)(!1),f=(0,m.useRef)(!0),h=c(6e4),g=o(new Date(h)),v=(0,m.useMemo)(()=>u(e),[e]),y=v+24*36e5,b=e===g;(0,m.useEffect)(()=>{f.current&&e!==g&&t(g)},[g,e]);let x=(0,m.useCallback)(e=>{f.current=e===o(),t(e)},[]),S=(0,m.useCallback)(async()=>{d(!0),s(null);try{let e=await r.logbook.snapshots({from:v,to:y,limit:5e3,order:`desc`,bucket:60});i(e)}catch(e){s(e.message)}finally{d(!1)}},[v,y]);return(0,m.useEffect)(()=>{if(S(),!b)return;let e=p(S,_);return()=>e()},[S,b]),{dateStr:e,setDateStr:x,dayStart:v,isToday:b,snaps:n,err:a,busy:l,prevDay:(0,m.useCallback)(()=>x(o(new Date(v-864e5))),[v,x]),nextDay:(0,m.useCallback)(()=>x(o(new Date(v+864e5))),[v,x]),goToday:(0,m.useCallback)(()=>x(o()),[x])}}var b=t(),x=[`1m`,`1h`,`6h`,`1d`],S={"1m":`Last hour`,"1h":`Last 2 days`,"6h":`Last 10 days`,"1d":`Last month`};function C(){let[e,t]=(0,m.useState)(`live`),[n,r]=(0,m.useState)(()=>localStorage.getItem(`lb:windUnit`)||`kn`),i={mode:e,setMode:t,windUnit:n,toggleWind:()=>r(e=>{let t=e===`kn`?`bft`:`kn`;return localStorage.setItem(`lb:windUnit`,t),t})};return(0,b.jsx)(`div`,{className:`lb`,children:e===`live`?(0,b.jsx)(E,{...i}):(0,b.jsx)(D,{...i})})}function w({mode:e,setMode:t}){return(0,b.jsxs)(`div`,{className:`seg`,children:[(0,b.jsx)(`button`,{className:e===`live`?`on`:``,onClick:()=>t(`live`),children:`Live`}),(0,b.jsx)(`button`,{className:e===`day`?`on`:``,onClick:()=>t(`day`),children:`Day`})]})}function T({windUnit:e,toggleWind:t}){return(0,b.jsxs)(`div`,{className:`lb-cols`,children:[(0,b.jsx)(`span`,{children:`UTC`}),(0,b.jsx)(`span`,{children:`SOG`}),(0,b.jsx)(`span`,{children:`HDG`}),(0,b.jsx)(`span`,{className:`tap`,onClick:t,title:`Tap: knots ⇄ Beaufort`,children:e===`kn`?`TWS`:`BFT`}),(0,b.jsx)(`span`,{children:`BARO`}),(0,b.jsx)(`span`,{children:`DEP`})]})}function E({mode:e,setMode:t,windUnit:n,toggleWind:r}){let{granularity:i,changeGran:a,snaps:o,err:s,busy:c,hasMore:l,loadMore:u}=v();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`lb-ctrl`,children:[(0,b.jsx)(w,{mode:e,setMode:t}),(0,b.jsx)(`div`,{className:`seg`,children:x.map(e=>(0,b.jsx)(`button`,{className:i===e?`on`:``,onClick:()=>a(e),children:e},e))}),(0,b.jsx)(`span`,{className:`lb-count`,children:o.length})]}),(0,b.jsx)(T,{windUnit:n,toggleWind:r}),(0,b.jsxs)(`div`,{className:`lb-day`,children:[(0,b.jsx)(`span`,{children:S[i]}),(0,b.jsx)(`b`,{children:o.length})]}),s&&(0,b.jsx)(`div`,{className:`lb-err`,children:s}),(0,b.jsx)(O,{snaps:o,windUnit:n,footer:l?(0,b.jsx)(`button`,{className:`lb-more`,onClick:u,disabled:c,children:c?`Loading…`:`Load ${g[i]} more`}):null})]})}function D({mode:e,setMode:t,windUnit:n,toggleWind:r}){let{dateStr:i,setDateStr:a,isToday:s,snaps:c,err:l,busy:u,prevDay:d,nextDay:f,goToday:p}=y(),m=s?`Today · ${new Date(i).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,timeZone:`UTC`})}`:new Date(i).toLocaleDateString(`en-GB`,{weekday:`short`,day:`2-digit`,month:`short`,timeZone:`UTC`}).replace(/,/g,``);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`lb-ctrl`,children:[(0,b.jsx)(w,{mode:e,setMode:t}),(0,b.jsxs)(`div`,{className:`lb-date`,children:[(0,b.jsx)(`button`,{onClick:d,"aria-label":`Previous day`,children:`‹`}),(0,b.jsx)(`input`,{type:`date`,className:`dt`,value:i,max:o(),onChange:e=>a(e.target.value),style:{border:`1.5px solid var(--rule)`,background:`var(--cell)`,color:`var(--text)`,fontFamily:`var(--sp-font)`,fontSize:12,padding:`5px 7px`}}),(0,b.jsx)(`button`,{onClick:f,disabled:s,"aria-label":`Next day`,children:`›`}),(0,b.jsx)(`button`,{onClick:p,disabled:s,children:`Now`})]})]}),(0,b.jsx)(T,{windUnit:n,toggleWind:r}),(0,b.jsxs)(`div`,{className:`lb-day`,children:[(0,b.jsx)(`span`,{children:m}),(0,b.jsx)(`b`,{children:c.length})]}),l&&(0,b.jsx)(`div`,{className:`lb-err`,children:l}),!u&&c.length===0?(0,b.jsxs)(`div`,{className:`sp-empty`,children:[(0,b.jsx)(`div`,{className:`em-t`,children:`No snapshots`}),(0,b.jsx)(`div`,{className:`em-s`,children:`No telemetry was logged for this day.`})]}):(0,b.jsx)(O,{snaps:c,windUnit:n,footer:null})]})}function O({snaps:e,footer:t,windUnit:n}){return(0,b.jsxs)(`div`,{className:`lb-rows`,children:[e.map(e=>(0,b.jsx)(k,{s:e,windUnit:n},e.ts)),t]})}function k({s:e,windUnit:t}){let r=new Date(e.ts),o=e=>String(e).padStart(2,`0`),c=d(e.sog),u=a(e.heading_true??e.heading_mag),f=l(e.wind_speed_true),p=f===null?`·`:String(t===`kn`?Math.round(f):s(f)??`·`),m=n(e.air_pressure_pa);return(0,b.jsxs)(`div`,{className:`lb-row`,children:[(0,b.jsxs)(`span`,{className:`tm`,children:[o(r.getUTCHours()),`:`,o(r.getUTCMinutes())]}),(0,b.jsx)(`span`,{className:`v`,children:i(c,1)}),(0,b.jsx)(`span`,{className:`v`,children:u===null?`·`:Math.round(u)+`°`}),(0,b.jsx)(`span`,{className:`v`,children:p}),(0,b.jsx)(`span`,{className:`v dim`,children:m===null?`·`:Math.round(m)}),(0,b.jsx)(`span`,{className:`v`,children:e.depth===null?`·`:e.depth.toFixed(1)})]})}function A(){return(0,b.jsx)(C,{})}export{A as default};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,a as n,d as r,g as i,i as a,l as o,r as s,u as c,y as l}from"./index-5gz9-vQd.js";import{t as u}from"./visibleInterval-CFxPzgzx.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./style-CSszoHyM.js";var v=e(l(),1),y={fill:`#ffb938`,stroke:`#b38326`,glow:`rgba(255,185,56,0.65)`,dot:`#050706`};function b(e,t=y){let n=t.fill,r=t.stroke;return e===null||Number.isNaN(e)?`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,a as n,d as r,g as i,i as a,l as o,r as s,u as c,y as l}from"./index-RgGUQ86M.js";import{t as u}from"./visibleInterval-CFxPzgzx.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./style-Bk78SX0A.js";var v=e(l(),1),y={fill:`#ffb938`,stroke:`#b38326`,glow:`rgba(255,185,56,0.65)`,dot:`#050706`};function b(e,t=y){let n=t.fill,r=t.stroke;return e===null||Number.isNaN(e)?`
2
2
  <div style="
3
3
  width: 14px; height: 14px;
4
4
  background: ${n};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,f as n,g as r,h as i,i as a,m as o,r as s,v as c,y as l}from"./index-5gz9-vQd.js";import{a as u,i as d,n as f,o as p,s as m,t as h}from"./style-CSszoHyM.js";var g=e(l(),1),_=[{mode:`total_l`,label:`Litres`},{mode:`total_usgal`,label:`US gallons`},{mode:`total_impgal`,label:`Imp gallons`},{mode:`per_nm`,label:`Litres / nm`},{mode:`nm_per_l`,label:`nm / L`},{mode:`per_hour`,label:`Litres / hour`}],v=.26417205,y=.21996923,b=1e-6;function x(e,t,n){return`${e.toFixed(n)} ${t}`}function S(e,t,n,r){if(e===null||!Number.isFinite(e))return null;switch(r){case`total_l`:return x(e,`L`,+(e<100));case`total_usgal`:return x(e*v,`US gal`,1);case`total_impgal`:return x(e*y,`Imp gal`,1);case`per_nm`:return t>b?x(e/t,`L/nm`,2):null;case`nm_per_l`:return e>b?x(t/e,`nm/L`,2):null;case`per_hour`:return n>b?x(e/n,`L/h`,1):null}}function C(e){if(e===null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function w(e){if(!(e>0))return``;let t=Math.round(e*60),n=Math.floor(t/60),r=t%60;return n>0?`${n}h ${r}m`:`${r}m`}var T=e=>e===null?null:new Date(e).toISOString(),E=[`id`,`start_utc`,`end_utc`,`duration`,`from`,`to`,`distance_nm`,`hours_underway`,`avg_sog_kn`,`max_sog_kn`,`fuel_used_l`,`start_lat`,`start_lon`,`end_lat`,`end_lon`];function D(e){let t=[...e].sort((e,t)=>e.start_ts-t.start_ts),n=[E.join(`,`)];for(let e of t)n.push([e.id,T(e.start_ts),T(e.end_ts),w(e.hours_underway),e.start_port,e.end_port,e.distance_nm,e.hours_underway,e.avg_sog_kn,e.max_sog_kn,e.fuel_used_l,e.start_lat,e.start_lon,e.end_lat,e.end_lon].map(C).join(`,`));return n.join(`\r
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{_ as t,f as n,g as r,h as i,i as a,m as o,r as s,v as c,y as l}from"./index-RgGUQ86M.js";import{a as u,i as d,n as f,o as p,s as m,t as h}from"./style-Bk78SX0A.js";var g=e(l(),1),_=[{mode:`total_l`,label:`Litres`},{mode:`total_usgal`,label:`US gallons`},{mode:`total_impgal`,label:`Imp gallons`},{mode:`per_nm`,label:`Litres / nm`},{mode:`nm_per_l`,label:`nm / L`},{mode:`per_hour`,label:`Litres / hour`}],v=.26417205,y=.21996923,b=1e-6;function x(e,t,n){return`${e.toFixed(n)} ${t}`}function S(e,t,n,r){if(e===null||!Number.isFinite(e))return null;switch(r){case`total_l`:return x(e,`L`,+(e<100));case`total_usgal`:return x(e*v,`US gal`,1);case`total_impgal`:return x(e*y,`Imp gal`,1);case`per_nm`:return t>b?x(e/t,`L/nm`,2):null;case`nm_per_l`:return e>b?x(t/e,`nm/L`,2):null;case`per_hour`:return n>b?x(e/n,`L/h`,1):null}}function C(e){if(e===null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function w(e){if(!(e>0))return``;let t=Math.round(e*60),n=Math.floor(t/60),r=t%60;return n>0?`${n}h ${r}m`:`${r}m`}var T=e=>e===null?null:new Date(e).toISOString(),E=[`id`,`start_utc`,`end_utc`,`duration`,`from`,`to`,`distance_nm`,`hours_underway`,`avg_sog_kn`,`max_sog_kn`,`fuel_used_l`,`start_lat`,`start_lon`,`end_lat`,`end_lon`];function D(e){let t=[...e].sort((e,t)=>e.start_ts-t.start_ts),n=[E.join(`,`)];for(let e of t)n.push([e.id,T(e.start_ts),T(e.end_ts),w(e.hours_underway),e.start_port,e.end_port,e.distance_nm,e.hours_underway,e.avg_sog_kn,e.max_sog_kn,e.fuel_used_l,e.start_lat,e.start_lon,e.end_lat,e.end_lon].map(C).join(`,`));return n.join(`\r
2
2
  `)+`\r
3
3
  `}function O(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function k(e){let t=new Date(e.start_ts).toISOString().slice(0,10);return!e.start_port&&!e.end_port?`Voyage ${e.id} ${t}`:`${t} ${e.start_port??`?`} to ${e.end_port??`?`}`}function A(e,t){let n=O(k(e)),r=t.map(e=>` <trkpt lat="${e.lat}" lon="${e.lon}"><time>${new Date(e.ts).toISOString()}</time></trkpt>`).join(`
4
4
  `);return[`<?xml version="1.0" encoding="UTF-8"?>`,`<gpx version="1.1" creator="Siparu" xmlns="http://www.topografix.com/GPX/1/1">`,` <metadata>`,` <name>${n}</name>`,` <time>${new Date(e.start_ts).toISOString()}</time>`,` </metadata>`,` <trk>`,` <name>${n}</name>`,` <trkseg>`,r,` </trkseg>`,` </trk>`,`</gpx>`,``].join(`
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./tz-DxphYhHy.js","./rolldown-runtime-CNC7AqOf.js","./Logbook-CZb9OaA4.js","./visibleInterval-CFxPzgzx.js","./Voyage-CzIqnUBA.js","./style-CSszoHyM.js","./style-B2k4QVOw.css","./Map-CN4rx5A-.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./tz-DxphYhHy.js","./rolldown-runtime-CNC7AqOf.js","./Logbook-CpMK73wj.js","./visibleInterval-CFxPzgzx.js","./Voyage-DqTyveli.js","./style-Bk78SX0A.js","./style-B2k4QVOw.css","./Map-BmL-Ri3l.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-CNC7AqOf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var a=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ee(e,t){return E(e.type,t,e.props)}function te(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ne(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var re=/\/+/g;function D(e,t){return typeof e==`object`&&e&&e.key!=null?ne(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+D(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(re,`$&/`)+`/`),ae(o,r,i,``,function(e){return e})):o!=null&&(te(o)&&(o=ee(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(re,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+D(a,u),c+=ae(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+D(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(ie(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function oe(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function se(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var O=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},k={map:oe,forEach:function(e,t,n){oe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return oe(e,function(){t++}),t},toArray:function(e){return oe(e,function(e){return e})||[]},only:function(e){if(!te(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=k,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=te,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:se}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,O)}catch(e){O(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),o=i(((e,t)=>{t.exports=a()})),s=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&D(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&D(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(ee)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=ee,te=function(){re.postMessage(null)}}else te=function(){_(ee,0)};function D(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,D(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),c=i(((e,t)=>{t.exports=s()})),l=i((e=>{var t=o();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=i.p;try{if(c.T=null,i.p=2,e)return e()}finally{c.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),u=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=l()})),d=i((e=>{var t=c(),n=o(),r=u();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(s(e)!==e)throw Error(i(188))}function p(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return f(a),e;if(o===r)return f(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),te=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),D=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=D&&e[D]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case te:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},le=[],ue=-1;function de(e){return{current:e}}function fe(e){0>ue||(e.current=le[ue],le[ue]=null,ue--)}function A(e,t){ue++,le[ue]=e.current,e.current=t}var pe=de(null),me=de(null),he=de(null),ge=de(null);function _e(e,t){switch(A(he,t),A(me,e),A(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}fe(pe),A(pe,e)}function ve(){fe(pe),fe(me),fe(he)}function ye(e){e.memoizedState!==null&&A(ge,e);var t=pe.current,n=Hd(t,e.type);t!==n&&(A(me,e),A(pe,n))}function be(e){me.current===e&&(fe(pe),fe(me)),ge.current===e&&(fe(ge),Qf._currentValue=ce)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -17,5 +17,5 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
17
17
  ${_}px !important;
18
18
  ${v}px !important;
19
19
  }
20
- `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,j.jsx)(Bd,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:p.cloneElement(e,{ref:u})})}var Hd=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=yr(Ud),d=(0,p.useId)(),f=(0,p.useRef)(n),m=(0,p.useRef)(r);br(()=>{f.current=n,m.current=r});let h=!0,g=(0,p.useMemo)(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&m.current?.()})}),[n,u,r]);return a&&h&&(g={...g}),(0,p.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),p.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,j.jsx)(Vd,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,j.jsx)(xr.Provider,{value:g,children:e})};function Ud(){return new Map}function Wd(e=!0){let t=(0,p.useContext)(xr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,p.useId)();(0,p.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,p.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Gd=e=>e.key||``;function Kd(e){let t=[];return p.Children.forEach(e,e=>{(0,p.isValidElement)(e)&&t.push(e)}),t}var qd=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=Wd(o),f=(0,p.useMemo)(()=>Kd(e),[e]),m=o&&!u?[]:f.map(Gd),h=(0,p.useRef)(!0),g=(0,p.useRef)(f),_=yr(()=>new Map),v=(0,p.useRef)(new Set),[y,b]=(0,p.useState)(f),[x,S]=(0,p.useState)(f);br(()=>{h.current=!1,g.current=f;for(let e=0;e<x.length;e++){let t=Gd(x[e]);m.includes(t)?(_.delete(t),v.current.delete(t)):_.get(t)!==!0&&_.set(t,!1)}},[x,m.length,m.join(`-`)]);let C=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=Gd(n);m.includes(r)||(e.splice(t,0,n),C.push(n))}return a===`wait`&&C.length&&(e=C),S(Kd(e)),b(f),null}let{forceRender:w}=(0,p.useContext)(vr);return(0,j.jsx)(j.Fragment,{children:x.map(e=>{let p=Gd(e),y=o&&!u?!1:f===x||m.includes(p);return(0,j.jsx)(Hd,{isPresent:y,initial:!h.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(v.current.has(p))return;if(_.has(p))v.current.add(p),_.set(p,!0);else return;let e=!0;_.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(g.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},p)})})},Jd=(0,p.createContext)({strict:!1}),Yd={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Xd=!1;function Zd(){if(Xd)return;let e={};for(let t in Yd)e[t]={isEnabled:e=>Yd[t].some(t=>!!e[t])};ul(e),Xd=!0}function Qd(){return Zd(),dl()}function $d(e){let t=Qd();for(let n in e)t[n]={...t[n],...e[n]};ul(t)}var ef=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function tf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||ef.has(e)}var nf=r({default:()=>rf}),rf,af=n((()=>{throw rf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),of=e=>!tf(e);function sf(e){typeof e==`function`&&(of=t=>t.startsWith(`on`)?!tf(t):e(t))}try{sf((af(),t(nf)).default)}catch{}function cf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Cs(e[i])||(of(i)||n===!0&&tf(i)||!t&&!tf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var lf=(0,p.createContext)({});function uf(e,t){if(tl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Qc(t)?t:void 0,animate:Qc(n)?n:void 0}}return e.inherit===!1?{}:t}function df(e){let{initial:t,animate:n}=uf(e,(0,p.useContext)(lf));return(0,p.useMemo)(()=>({initial:t,animate:n}),[ff(t),ff(n)])}function ff(e){return Array.isArray(e)?e.join(` `):e}var pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function mf(e,t,n){for(let r in t)!Cs(t[r])&&!Bl(r,n)&&(e[r]=t[r])}function hf({transformTemplate:e},t){return(0,p.useMemo)(()=>{let n=pf();return K(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gf(e,t){let n=e.style||{},r={};return mf(r,n,e),Object.assign(r,hf(e,t)),r}function _f(e,t){let n={},r=gf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var vf=()=>({...pf(),attrs:{}});function yf(e,t,n,r){let i=(0,p.useMemo)(()=>{let n=vf();return Jl(n,t,Xl(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};mf(t,e.style,e),i.style={...t,...i.style}}return i}var bf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function xf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(bf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??xf(e)?yf:_f)(t,r,i,e),c=cf(t,typeof e==`string`,a),l=e===p.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,p.useMemo)(()=>Cs(u)?u.get():u,[u]);return(0,p.createElement)(e,{...l,children:d})}function Cf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wf(n,r,i,e),renderState:t()}}function wf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=$u(a[e]);let{initial:o,animate:s}=e,c=tl(e),l=nl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Zc(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=gs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Tf=e=>(t,n)=>{let r=(0,p.useContext)(lf),i=(0,p.useContext)(xr),a=()=>Cf(e,t,r,i);return n?a():yr(a)},Ef=Tf({scrapeMotionValuesFromProps:Vl,createRenderState:pf}),Df=Tf({scrapeMotionValuesFromProps:Ql,createRenderState:vf}),Of=Symbol.for(`motionComponentSymbol`);function kf(e,t,n){let r=(0,p.useRef)(n);(0,p.useInsertionEffect)(()=>{r.current=n});let i=(0,p.useRef)(null);return(0,p.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var Af=(0,p.createContext)({});function jf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Mf(e,t,n,r,i,a){let{visualElement:o}=(0,p.useContext)(lf),s=(0,p.useContext)(Jd),c=(0,p.useContext)(xr),l=(0,p.useContext)(Id),u=l.reducedMotion,d=l.skipAnimations,f=(0,p.useRef)(null),m=(0,p.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),m.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let h=f.current,g=(0,p.useContext)(Af);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&Nf(f.current,n,i,g);let _=(0,p.useRef)(!1);(0,p.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[Ds],y=(0,p.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return br(()=>{m.current=!0,h&&(_.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState&&h.animationState.animateChanges())}),(0,p.useEffect)(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function Nf(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Pf(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&jf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Pf(e){if(e)return e.options.allowProjection===!1?Pf(e.parent):e.projection}function Ff(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&$d(r);let a=n?n===`svg`:xf(e),o=a?Df:Ef;function s(n,s){let c,l={...(0,p.useContext)(Id),...n,layoutId:If(n)},{isStatic:u}=l,d=df(n),f=o(n,u);if(!u&&typeof window<`u`){Lf(l,r);let t=Rf(l);c=t.MeasureLayout,d.visualElement=Mf(e,f,l,i,t.ProjectionNode,a)}return(0,j.jsxs)(lf.Provider,{value:d,children:[c&&d.visualElement?(0,j.jsx)(c,{visualElement:d.visualElement,...l}):null,Sf(e,n,kf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,p.forwardRef)(s);return c[Of]=e,c}function If({layoutId:e}){let t=(0,p.useContext)(vr).id;return t&&e!==void 0?t+`-`+e:e}function Lf(e,t){(0,p.useContext)(Jd).strict}function Rf(e){let{drag:t,layout:n}=Qd();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function zf(e,t){if(typeof Proxy>`u`)return Ff;let n=new Map,r=(n,r)=>Ff(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Ff(a,void 0,e,t)),n.get(a))})}var Bf=(e,t)=>t.isSVG??xf(e)?new $l(t):new Ul(t,{allowProjection:e!==p.Fragment}),Vf=class extends ml{constructor(e){super(e),e.animationState||=ou(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Zc(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Hf=0,Uf={animation:{Feature:Vf},exit:{Feature:class extends ml{constructor(){super(...arguments),this.id=Hf++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=_s(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Wf(e){return{point:{x:e.pageX,y:e.pageY}}}var Gf=e=>t=>fc(t)&&e(t,Wf(t));function Kf(e,t,n,r){return Yu(e,t,Gf(n),r)}var qf=({current:e})=>e?e.ownerDocument.defaultView:null,Jf=(e,t)=>Math.abs(e-t);function Yf(e,t){let n=Jf(e.x,t.x),r=Jf(e.y,t.y);return Math.sqrt(n**2+r**2)}var Xf=new Set([`auto`,`scroll`]),Zf=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Qf(this.lastRawMoveEventInfo,this.transformPagePoint));let e=ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Yf(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=ui;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Qf(t,this.transformPagePoint),M.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=ep(e.type===`pointercancel`?this.lastMoveEventInfo:Qf(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!fc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Qf(Wf(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=ui;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,ep(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=jr(Kf(this.contextWindow,`pointermove`,this.handlePointerMove,d),Kf(this.contextWindow,`pointerup`,this.handlePointerUp,d),Kf(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Xf.has(e.overflowX)||Xf.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),M.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),li(this.updatePoint)}};function Qf(e,t){return t?{point:t(e.point)}:e}function $f(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ep({point:e},t){return{point:e,delta:$f(e,np(t)),offset:$f(e,tp(t)),velocity:rp(t,.1)}}function tp(e){return e[0]}function np(e){return e[e.length-1]}function rp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=np(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Pr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Pr(t)*2&&(r=e[1]);let a=Fr(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ip(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?R(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?R(n,e,r.max):Math.min(e,n)),e}function ap(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function op(e,{top:t,left:n,bottom:r,right:i}){return{x:ap(e.x,n,i),y:ap(e.y,t,r)}}function sp(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function cp(e,t){return{x:sp(e.x,t.x),y:sp(e.y,t.y)}}function lp(e,t){let n=.5,r=_u(e),i=_u(t);return i>r?n=Mr(t.min,t.max-r,e.min):r>i&&(n=Mr(e.min,e.max-i,t.min)),wr(0,1,n)}function up(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var dp=.35;function fp(e=dp){return e===!1?e=0:e===!0&&(e=dp),{x:pp(e,`left`,`right`),y:pp(e,`top`,`bottom`)}}function pp(e,t,n){return{min:mp(e,t),max:mp(e,n)}}function mp(e,t){return typeof e==`number`?e:e[t]||0}var hp=new WeakMap,gp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yc(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Wf(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),zu(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Ii.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=_u(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&M.update(()=>i(e,t),!1,!0),Ts(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=bp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&M.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Zf(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:qf(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&M.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!yp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=ip(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&jf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=op(n.layoutBox,e):this.constraints=!1,this.elastic=fp(t),r!==this.constraints&&!jf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&zu(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=up(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=Fl(n,r.root,this.visualElement.getTransformPagePoint()),a=cp(r.layout.layoutBox,i);if(t){let e=t(gl(a));this.hasMutatedConstraints=!!e,e&&(a=hl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=zu(o=>{if(!yp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Ts(this.visualElement,e),n.start(ds(e,n,0,t,this.visualElement,!1))}stopAnimation(){zu(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){zu(t=>{let{drag:n}=this.getProps();if(!yp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-R(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!jf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};zu(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=lp({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),zu(t=>{if(!yp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(R(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;hp.set(this.visualElement,this);let e=this.visualElement.current,t=Kf(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();jf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=vp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),M.read(r);let o=Yu(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(zu(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=dp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function _p(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function vp(e,t,n){let r=Lc(e,_p(n)),i=Lc(t,_p(n));return()=>{r(),i()}}function yp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function bp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var xp=class extends ml{constructor(e){super(e),this.removeGroupControls=Ar,this.removeListeners=Ar,this.controls=new gp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ar}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Sp=e=>(t,n)=>{e&&M.update(()=>e(t,n),!1,!0)},Cp=class extends ml{constructor(){super(...arguments),this.removePointerDownListener=Ar}onPointerDown(e){this.session=new Zf(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qf(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Sp(e),onStart:Sp(t),onMove:Sp(n),onEnd:(e,t)=>{delete this.session,r&&M.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Kf(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},wp=!1,Tp=class extends p.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),wp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),td.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),wp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||M.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),rc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Ep(e){let[t,n]=Wd(),r=(0,p.useContext)(vr);return(0,j.jsx)(Tp,{...e,layoutGroup:r,switchLayoutGroup:(0,p.useContext)(Af),isPresent:t,safeToRemove:n})}var Dp={pan:{Feature:Cp},drag:{Feature:xp,ProjectionNode:Fd,MeasureLayout:Ep}};function Op(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&M.postRender(()=>i(t,Wf(t)))}var kp=class extends ml{mount(){let{current:e}=this.node;e&&(this.unmount=uc(e,(e,t)=>(Op(this.node,t,`Start`),e=>Op(this.node,e,`End`))))}unmount(){}},Ap=class extends ml{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=jr(Yu(this.node.current,`focus`,()=>this.onFocus()),Yu(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function jp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&M.postRender(()=>i(t,Wf(t)))}var Mp=class extends ml{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Cc(e,(e,t)=>(jp(this.node,t,`Start`),(e,{success:t})=>jp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Np=new WeakMap,Pp=new WeakMap,Fp=e=>{let t=Np.get(e.target);t&&t(e)},Ip=e=>{e.forEach(Fp)};function Lp({root:e,...t}){let n=e||document;Pp.has(n)||Pp.set(n,{});let r=Pp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Ip,{root:e,...t})),r[i]}function Rp(e,t,n){let r=Lp(t);return Np.set(e,n),r.observe(e),()=>{Np.delete(e),r.unobserve(e)}}var zp={some:0,all:1},Bp=class extends ml{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:zp[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Rp(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Vp(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Vp({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Hp={inView:{Feature:Bp},tap:{Feature:Mp},focus:{Feature:Ap},hover:{Feature:kp}},Up={layout:{ProjectionNode:Fd,MeasureLayout:Ep}},Wp=zf({...Uf,...Hp,...Dp,...Up},Bf);function Gp(e,t,n){(0,p.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}function Kp(e){let t=yr(()=>ts(e)),{isStatic:n}=(0,p.useContext)(Id);if(n){let[,n]=(0,p.useState)(e);(0,p.useEffect)(()=>t.on(`change`,n),[])}return t}function qp(e,t){let n=Kp(t()),r=()=>n.set(t());return r(),br(()=>{let t=()=>M.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),li(r)}}),n}function Jp(e){$o.current=[],e();let t=qp($o.current,e);return $o.current=void 0,t}function Yp(e,t,n,r){if(typeof e==`function`)return Jp(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Zp(e,t,n,r);let i=typeof t==`function`?t:Bc(t,n,r),a=Array.isArray(e)?Xp(e,i):Xp([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function Xp(e,t){let n=yr(()=>[]);return qp(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Zp(e,t,n,r){let i=yr(()=>Object.keys(n)),a=yr(()=>({}));for(let o of i)a[o]=Yp(e,t,n[o],r);return a}function Qp(e,t={}){let{isStatic:n}=(0,p.useContext)(Id),r=()=>Cs(e)?e.get():e;if(n)return Yp(r);let i=Kp(r());return(0,p.useInsertionEffect)(()=>Vc(i,e,t),[i,JSON.stringify(t)]),i}function $p(e,t={}){return Qp(e,{type:`spring`,...t})}var em=Wp,tm={out:[.16,1,.3,1],in:[.4,0,1,1],exit:[.3,0,.8,.15],sheet:[.32,.72,0,1],snap:[.12,0,.08,1]},nm={micro:.14,exit:.14,base:.22,lg:.36,sheet:.5};function rm({size:e=22,children:t,...n}){return(0,j.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,...n,children:t})}var im=e=>(0,j.jsx)(rm,{...e,children:(0,j.jsx)(`path`,{d:`M15 6l-6 6 6 6`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})}),am=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M4 17a8 8 0 0 1 16 0`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`}),(0,j.jsx)(`path`,{d:`M12 17l4.5-5`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`}),(0,j.jsx)(`circle`,{cx:12,cy:17,r:1.6,fill:`currentColor`})]}),om=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`circle`,{cx:5,cy:7,r:1.3,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:5,cy:12,r:1.3,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:5,cy:17,r:1.3,fill:`currentColor`}),(0,j.jsx)(`path`,{d:`M9 7h11M9 12h11M9 17h7`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`})]}),sm=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M12 21s6.5-6 6.5-11A6.5 6.5 0 1 0 5.5 10c0 5 6.5 11 6.5 11Z`,stroke:`currentColor`,strokeWidth:1.7,strokeLinejoin:`round`}),(0,j.jsx)(`circle`,{cx:12,cy:9.5,r:2.4,stroke:`currentColor`,strokeWidth:1.7})]}),cm=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M6.5 18C12 18 11 7.5 18 7`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeDasharray:`0.2 3.4`}),(0,j.jsx)(`circle`,{cx:6,cy:18,r:2.1,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:18,cy:7,r:2.1,fill:`none`,stroke:`currentColor`,strokeWidth:1.7})]}),lm=e=>(0,j.jsx)(rm,{...e,children:(0,j.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`})}),um=({className:e})=>(0,j.jsxs)(`svg`,{className:e,viewBox:`0 0 22 7`,"aria-hidden":`true`,focusable:`false`,children:[(0,j.jsx)(`rect`,{x:`0`,y:`0`,width:`7`,height:`7`,fill:`#e5484d`}),(0,j.jsx)(`line`,{x1:`8.4`,y1:`3.5`,x2:`13.6`,y2:`3.5`,stroke:`currentColor`,strokeWidth:1.3,strokeDasharray:`2 1.2`,opacity:.85}),(0,j.jsx)(`rect`,{x:`15.8`,y:`0.8`,width:`5.4`,height:`5.4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6})]}),dm=({size:e=15})=>(0,j.jsx)(rm,{size:e,children:(0,j.jsx)(`path`,{d:`M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5Z`,stroke:`currentColor`,strokeWidth:1.8,strokeLinejoin:`round`})}),fm=({size:e=15})=>(0,j.jsxs)(rm,{size:e,children:[(0,j.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4.2`,stroke:`currentColor`,strokeWidth:1.8}),(0,j.jsx)(`path`,{d:`M12 2.8v2.4M12 18.8v2.4M2.8 12h2.4M18.8 12h2.4M5.5 5.5l1.7 1.7M16.8 16.8l1.7 1.7M18.5 5.5l-1.7 1.7M7.2 16.8l-1.7 1.7`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`})]});function pm({title:e,eyebrow:t,onClose:n,children:r,tabs:i,footer:a,padded:o=!0,closeRef:s}){let[c,l]=(0,p.useState)(!0);(0,p.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let u=()=>l(!1);return(0,p.useEffect)(()=>{if(s)return s.current=u,()=>{s.current=null}},[s]),(0,j.jsx)(qd,{onExitComplete:n,children:c&&(0,j.jsx)(em.div,{className:`scrim`,onClick:u,initial:{opacity:0},animate:{opacity:1,transition:{duration:.18}},exit:{opacity:0,transition:{duration:nm.exit}},children:(0,j.jsxs)(em.div,{className:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":e,onClick:e=>e.stopPropagation(),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:nm.base,ease:tm.out}},exit:{opacity:0,scale:.97,transition:{duration:nm.exit,ease:tm.exit}},children:[(0,j.jsxs)(`div`,{className:`sheet-head`,children:[(0,j.jsxs)(`div`,{children:[t&&(0,j.jsx)(`div`,{className:`sheet-eyebrow`,children:t}),(0,j.jsx)(`span`,{className:`sheet-title`,children:e})]}),(0,j.jsx)(`button`,{type:`button`,className:`sheet-x`,onClick:u,"aria-label":`Close`,children:(0,j.jsx)(lm,{size:16})})]}),i,o?(0,j.jsx)(`div`,{className:`sheet-body`,children:r}):r,a&&(0,j.jsx)(`div`,{className:`sheet-foot`,children:a})]})},`scrim`)})}var mm=150,hm=3;function gm(e){if(e.length===0)return``;let t=`M ${e[0][0]},${e[0][1]}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]||e[n],i=e[n],a=e[n+1],o=e[n+2]||a;t+=` C ${i[0]+(a[0]-r[0])/6},${i[1]+(a[1]-r[1])/6} ${a[0]-(o[0]-i[0])/6},${a[1]-(o[1]-i[1])/6} ${a[0]},${a[1]}`}return t}function _m({data:e,color:t,fill:n,peak:r,height:i=40,top:a=5,className:o}){if(!e||e.length<2)return(0,j.jsx)(`svg`,{className:o,viewBox:`0 0 ${mm} ${i}`,preserveAspectRatio:`none`,"aria-hidden":`true`});let s=i,c=Math.max(...e),l=Math.min(...e),u=c*1.04,d=l*.96,f=u-d||1,p=t=>hm+t*((mm-hm*2)/(e.length-1)),m=e=>a+(s-a-hm)*(1-(e-d)/f),h=gm(e.map((e,t)=>[p(t),m(e)])),g=r?e.indexOf(c):-1;return(0,j.jsxs)(`svg`,{className:o,viewBox:`0 0 ${mm} ${s}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,j.jsx)(`line`,{x1:hm,y1:s-hm,x2:mm-hm,y2:s-hm,stroke:t,strokeOpacity:.18}),n&&(0,j.jsx)(`path`,{d:`${h} L ${p(e.length-1)},${s} L ${p(0)},${s} Z`,fill:t,fillOpacity:.12}),(0,j.jsx)(`path`,{d:h,fill:`none`,stroke:t,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`}),g>=0&&(0,j.jsx)(`circle`,{cx:p(g),cy:m(e[g]),r:2.6,fill:t})]})}var vm=3e3;function ym(){return(0,p.useEffect)(()=>{let e=!1,t=setInterval(async()=>{if(!(e||document.hidden)){e=!0;try{await _r.live(),window.location.reload()}catch{e=!1}}},vm);return()=>clearInterval(t)},[]),(0,j.jsxs)(`div`,{className:`sp-auth`,role:`alert`,children:[(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(`span`,{className:`sp-auth-mk`,children:`Siparu`})]}),(0,j.jsxs)(`div`,{className:`sp-auth-card`,children:[(0,j.jsx)(`span`,{className:`sp-auth-kick`,children:`Sign-in required`}),(0,j.jsx)(`p`,{className:`sp-auth-body`,children:`This Signal K server only shares boat data with signed-in users. Siparu reads everything through Signal K, so sign in there and come back - the dashboard picks up on its own.`}),(0,j.jsx)(`a`,{className:`sp-auth-cta`,href:`/admin/#/login`,target:`_blank`,rel:`noopener`,children:`Open Signal K sign-in`}),(0,j.jsx)(`p`,{className:`sp-auth-foot`,children:`Signed in but still locked out? Your account may not have enough access - ask whoever runs this Signal K server.`})]}),(0,j.jsxs)(`span`,{className:`sp-auth-wait`,children:[(0,j.jsx)(`span`,{className:`sp-auth-pulse`,"aria-hidden":`true`}),`Waiting for sign-in`]})]})}function bm({full:e=!1}){return(0,j.jsx)(`div`,{className:`sp-bload${e?` full`:``}`,role:`status`,"aria-label":`Loading`,children:(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(`span`,{className:`sp-bload-mk`,children:`Siparu`})]})})}function xm(e=3e4){let[t,n]=(0,p.useState)(()=>Date.now());return(0,p.useEffect)(()=>{let t=null,r=()=>{t===null&&(t=setInterval(()=>n(Date.now()),e))},i=()=>{t!==null&&(clearInterval(t),t=null)},a=()=>{document.hidden?i():(n(Date.now()),r())};return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[e]),t}var Sm=new Map;function Cm(e,t=6e4){let n=Sm.get(e);return!n||Date.now()-n.ts>t?null:n.value}function wm(e,t){Sm.set(e,{value:t,ts:Date.now()})}function Tm(e){return Sm.get(e)?.ts??null}var Em=3e4;function Dm(e,t=Em,n=[],r){let[i,a]=(0,p.useState)(()=>r?Cm(r):null),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(()=>!(r&&Cm(r)!==null)),[u,d]=(0,p.useState)(0),f=(0,p.useRef)(e),m=(0,p.useRef)(0),h=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{f.current=e},[e]),(0,p.useEffect)(()=>{let e=!1,n=null,i=async()=>{if(h.current)return;h.current=!0;let t=++m.current;try{let n=await f.current();if(e||t!==m.current)return;a(n),r&&wm(r,n),s(null)}catch(n){if(e||t!==m.current)return;s(n)}finally{h.current=!1,!e&&t===m.current&&l(!1)}},o=()=>{n===null&&(n=setInterval(i,t))},c=()=>{n!==null&&(clearInterval(n),n=null)},u=()=>{document.hidden?c():(i(),o())};return i(),document.hidden||o(),document.addEventListener(`visibilitychange`,u),()=>{e=!0,h.current=!1,c(),document.removeEventListener(`visibilitychange`,u)}},[t,u,...n]),{data:i,error:o,loading:c,refresh:()=>d(e=>e+1)}}var Om=`night`,km=`sp_theme`;function Am(e){return e===`night`||e===`day`}function jm(e){document.documentElement.dataset.theme=e}function Mm(){let e=localStorage.getItem(km);return Am(e)?e:Om}function Nm(e){localStorage.setItem(km,e),jm(e)}function Pm(){let e=Mm()===`night`?`day`:`night`;return Nm(e),e}function Fm(){jm(Mm())}function Im(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}:${n(t.getUTCSeconds())} UTC`}function Lm(){let t=xm(1e3),{data:n}=Dm(_r.live,6e4,[],`bridge:live`),[r,i]=(0,p.useState)(null),a=n?.lat??null,o=n?.lon??null;(0,p.useEffect)(()=>{if(a===null||o===null)return;let t=!0;return v(()=>import(`./tz-DxphYhHy.js`).then(t=>e(t.default,1)).then(e=>{t&&i(e.default(a,o))}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{}),()=>{t=!1}},[a===null?null:Math.round(a*10),o===null?null:Math.round(o*10)]);let s=Im(t);if(r)try{s=new Intl.DateTimeFormat(`en-GB`,{timeZone:r,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1,timeZoneName:`short`}).format(t)}catch{}return(0,j.jsx)(`span`,{className:`clk`,children:s})}function Rm({back:e,context:t,live:n,stale:r,clock:i}){let a=pt(),[o,s]=(0,p.useState)(()=>Mm());return(0,j.jsxs)(`header`,{className:`head`,children:[(0,j.jsxs)(`div`,{className:`mkwrap`,children:[e!=null&&e!==!1&&(0,j.jsx)(`button`,{type:`button`,className:`back`,onClick:()=>{a(typeof e==`string`?e:-1)},"aria-label":`Back`,children:(0,j.jsx)(im,{size:15})}),(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(Fn,{to:`/`,className:`mk`,"aria-label":`Siparu home`,children:`Siparu`})]}),t&&(0,j.jsx)(`span`,{className:`ctx`,children:t})]}),(0,j.jsxs)(`div`,{className:`r`,children:[n&&(0,j.jsxs)(`span`,{className:`live${r?` is-stale`:``}`,children:[(0,j.jsx)(`span`,{className:`dot`}),r?`STALE`:`LIVE`]}),i&&(0,j.jsx)(Lm,{}),(0,j.jsx)(`button`,{type:`button`,className:`umenu-btn`,onClick:()=>s(Pm()),"aria-label":o===`night`?`Switch to day theme`:`Switch to night theme`,title:o===`night`?`Day theme`:`Night theme`,children:o===`night`?(0,j.jsx)(fm,{size:15}):(0,j.jsx)(dm,{size:15})})]})]})}var zm=[{to:`/`,end:!0,label:`Instruments`,Icon:am},{to:`/logbook`,end:!1,label:`Logbook`,Icon:om},{to:`/voyage`,end:!1,label:`Voyage`,Icon:cm},{to:`/map`,end:!1,label:`Map`,Icon:sm}];function Bm(){return(0,j.jsx)(`nav`,{className:`tabbar`,"aria-label":`Bridge tabs`,children:zm.map(({to:e,end:t,label:n,Icon:r})=>(0,j.jsx)(In,{to:e,end:t,replace:!0,className:({isActive:e})=>`tab${e?` on`:``}`,children:({isActive:e})=>(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(em.span,{className:`tind`,layoutId:`sp-tabind`,transition:{duration:.2,ease:tm.snap}}),(0,j.jsx)(r,{size:21}),(0,j.jsx)(`span`,{className:`tl`,children:n})]})},e))})}function Vm({live:e,stale:t}){let[n,r]=(0,p.useState)(()=>Mm());return(0,j.jsxs)(`nav`,{className:`sp-rail`,"aria-label":`Bridge navigation`,children:[(0,j.jsxs)(`span`,{className:`sp-lockup sp-brand`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(Fn,{to:`/`,className:`mk`,"aria-label":`Siparu home`,children:`Siparu`})]}),(0,j.jsx)(`div`,{className:`rnav-list`,children:zm.map(({to:e,end:t,label:n,Icon:r})=>(0,j.jsxs)(In,{to:e,end:t,replace:!0,className:({isActive:e})=>`rnav${e?` on`:``}`,children:[(0,j.jsx)(r,{size:20}),(0,j.jsx)(`span`,{className:`rl`,children:n})]},e))}),(0,j.jsxs)(`div`,{className:`rfoot`,children:[e&&(0,j.jsxs)(`span`,{className:`live${t?` is-stale`:``}`,children:[(0,j.jsx)(`span`,{className:`dot`}),t?`STALE`:`LIVE`]}),(0,j.jsx)(Lm,{}),(0,j.jsx)(`button`,{type:`button`,className:`umenu-btn`,onClick:()=>r(Pm()),"aria-label":n===`night`?`Switch to day theme`:`Switch to night theme`,title:n===`night`?`Day theme`:`Night theme`,children:n===`night`?(0,j.jsx)(fm,{size:15}):(0,j.jsx)(dm,{size:15})})]})]})}function Hm(e){let[t,n]=(0,p.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,p.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return r({matches:t.matches}),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Um=`(min-width: 1000px)`,Wm=[`/`,`/logbook`,`/voyage`,`/map`],Gm=3,Km={enter:e=>({opacity:0,x:e}),center:e=>({opacity:1,x:0,transition:{duration:e===0?.16:nm.base,ease:tm.out}}),exit:e=>({opacity:0,x:-e,transition:{duration:nm.exit,ease:tm.exit}})};function qm(){let e=ut(),t=gt(),n=e.pathname===`/`||e.pathname===`/map`;(0,p.useEffect)(()=>{let e=setTimeout(()=>{v(()=>import(`./Logbook-CZb9OaA4.js`),__vite__mapDeps([2,1,3]),import.meta.url).catch(()=>{}),v(()=>import(`./Voyage-CzIqnUBA.js`),__vite__mapDeps([4,1,5,6]),import.meta.url).catch(()=>{}),v(()=>import(`./Map-CN4rx5A-.js`),__vite__mapDeps([7,1,3,5,6]),import.meta.url).catch(()=>{})},250);return()=>clearTimeout(e)},[]);let r=Wm.indexOf(e.pathname),[i,a]=(0,p.useState)({prev:r,curr:r});i.curr!==r&&a({prev:i.curr,curr:r});let o=i.curr===r?i.prev:i.curr,s=r===Gm||o===Gm?0:(r===o?0:r>o?1:-1)*10,c=xm(2e3),l=Tm(`bridge:live`),u=e.pathname===`/`&&l!==null&&c-l>1e4,d=Hm(Um);return(0,j.jsxs)(`div`,{className:`swiss sp-screen${d?` sp-wide`:``}`,children:[d?(0,j.jsx)(Vm,{live:n,stale:u}):(0,j.jsx)(Rm,{clock:!0,live:n,stale:u}),(0,j.jsx)(`main`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col`,children:(0,j.jsx)(p.Suspense,{fallback:(0,j.jsx)(bm,{}),children:(0,j.jsx)(qd,{mode:`wait`,initial:!1,custom:s,children:(0,j.jsx)(em.div,{className:`h-full min-h-0 flex flex-col`,custom:s,variants:Km,initial:`enter`,animate:`center`,exit:`exit`,children:t},e.pathname)})})}),!d&&(0,j.jsx)(Bm,{})]})}function Jm(e,t){return Number.isNaN(e)?`·`:t>0?e.toFixed(t):String(Math.round(e))}function Ym({value:e,digits:t=0,className:n,style:r}){let i=$p(e??0,{stiffness:140,damping:22,mass:.6}),[a,o]=(0,p.useState)(e===null?`·`:Jm(e,t));return(0,p.useEffect)(()=>{e!==null&&i.set(e)},[e,i]),Gp(i,`change`,n=>{e!==null&&o(Jm(n,t))}),(0,j.jsx)(`span`,{className:n,style:r,children:e===null?`·`:a})}var Xm=1.94384;function Zm(e){return e<1?0:e<=3?1:e<=6?2:e<=10?3:e<=16?4:e<=21?5:e<=27?6:e<=33?7:e<=40?8:e<=47?9:e<=55?10:e<=63?11:12}function Qm(e){return typeof e!=`number`||Number.isNaN(e)?null:Zm(e)}var $m=[`engine`,`generator`,`tanks`],eh={engine:`Engine`,generator:`Generator`,tanks:`Tanks`};function th(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var nh=36e5,rh=1e3,ih=1852*rh,ah=()=>({sub:!0,fmt:e=>`${(e-273.15).toFixed(1)} °C`,scale:e=>e-273.15,unit:`°C`}),oh=()=>({sub:!0,fmt:e=>`${(e/1e5).toFixed(1)} bar`,scale:e=>e/1e5,unit:`bar`}),sh=()=>({sub:!0,fmt:e=>`${Math.round(e*rh)} L`,scale:e=>e*rh,unit:`L`}),ch=e=>({sub:e,fmt:e=>`${Math.round(e*100)}%`,scale:e=>e*100,unit:`%`}),lh={revolutions:{sub:!0,fmt:e=>`${Math.round(e*60)} rpm`,scale:e=>e*60,unit:`rpm`},runTime:{sub:!0,fmt:e=>`${Math.round(e/3600)} h`,scale:e=>e/3600,unit:`h`},temperature:ah(),oilTemperature:ah(),coolantTemperature:ah(),intakeManifoldTemperature:ah(),exhaustTemperature:ah(),oilPressure:oh(),coolantPressure:oh(),boostPressure:oh(),currentLevel:ch(!1),"tanks.capacity":sh(),"tanks.currentVolume":sh(),"tanks.pressure":oh(),engineLoad:ch(!0),engineTorque:ch(!0),trimState:ch(!0),"fuel.rate":{sub:!0,fmt:e=>`${(e*nh).toFixed(1)} L/h`,scale:e=>e*nh,unit:`L/h`},"fuel.averageRate":{sub:!0,fmt:e=>`${(e*nh).toFixed(1)} L/h`,scale:e=>e*nh,unit:`L/h`},"fuel.used":{sub:!0,fmt:e=>`${Math.round(e*rh)} L`,scale:e=>e*rh,unit:`L`},"fuel.pressure":{sub:!0,fmt:e=>`${(e/1e5).toFixed(1)} bar`,scale:e=>e/1e5,unit:`bar`},"fuel.economy":{sub:!0,fmt:e=>e>0?`${(ih/e).toFixed(2)} L/nm`:`·`,scale:e=>e>0?ih/e:NaN,unit:`L/nm`}},uh={"fuel.rate":`Fuel rate`,"fuel.averageRate":`Fuel rate (average)`,"fuel.economy":`Fuel per mile`,"fuel.used":`Fuel used (since reset)`,"fuel.pressure":`Fuel pressure`,"fuel.type":`Fuel type`,"drive.type":`Drive type`,"transmission.oilTemperature":`Gearbox oil temperature`,"transmission.oilPressure":`Gearbox oil pressure`},dh={"fuel.economyRate":!0};function fh(e,t){let n=t.split(`.`),r=n[n.length-1];return e[n.slice(-2).join(`.`)]??e[`${n[0]}.${r}`]??e[r]}var ph={wasteWater:`Grey water`};function mh(e){return th(e).toLowerCase()}function hh(e){if(fh(dh,e))return null;let t=e.split(`.`),n=t[t.length-1],r=fh(lh,e),i=r&&!r.sub?null:fh(uh,e)??th(n);return e.startsWith(`propulsion.`)&&t.length>=3?{tab:`engine`,label:th(t[1]),sub:i}:e.startsWith(`electrical.generators.`)&&t.length>=4?{tab:`generator`,label:`Generator ${mh(t[2])}`,sub:i}:e.startsWith(`tanks.`)&&t.length>=4?{tab:`tanks`,label:`${ph[t[1]]??th(t[1])} ${mh(t[2])}`,sub:i}:null}function gh(e,t){if(typeof t==`string`)return t;if(!Number.isFinite(t))return`·`;let n=fh(lh,e);return n?n.fmt(t):Number.isInteger(t)?String(t):t.toFixed(1)}function _h(e){let t=[],n=[],r={};for(let i of e){let e=i.sub??i.label;t.includes(i.label)||t.push(i.label),e in r||(r[e]={},n.push(e)),r[e][i.label]=i}return{cols:t,rows:n.map(e=>({sub:e,cells:r[e]}))}}function vh(e){let t={engine:[],generator:[],tanks:[]};for(let[n,r]of Object.entries(e?.paths??{})){let i=hh(n);if(!i)continue;let a=e?.path_ages?.[n];t[i.tab].push({path:n,label:i.label,sub:i.sub,value:gh(n,r),ageS:typeof a==`number`?a:null})}return $m.filter(e=>t[e].length>0).map(e=>({key:e,name:eh[e],gauges:t[e]}))}function yh(e){let t=Math.max(0,Math.floor(e));return t<60?{value:t,unit:`s`}:t<3600?{value:Math.floor(t/60),unit:`min`}:t<86400?{value:Math.floor(t/3600),unit:`h`}:{value:Math.floor(t/86400),unit:`d`}}var bh=90;function xh(e){let{value:t,unit:n}=yh(e);return`${t} ${n.toUpperCase()} AGO`}function Sh(e){let t=e.toLowerCase();return t===`port`?`port`:t===`starboard`||t===`stbd`?`stbd`:t===`center`||t===`centre`?`center`:``}function Ch(e){return/^starboard$/i.test(e)?`Stbd`:e.replace(/^Generator /i,`Gen `)}function wh({g:e}){if(!e)return(0,j.jsx)(`div`,{className:`sm-cell sm-empty`,"aria-hidden":`true`});let t=e.ageS!==null&&e.ageS>=bh;return(0,j.jsxs)(`div`,{className:`sm-cell${t?` quiet`:``}`,children:[(0,j.jsx)(`span`,{className:`sm-v`,children:e.value}),t&&(0,j.jsx)(`span`,{className:`sm-age`,children:xh(e.ageS)})]})}function Th({m:e}){return(0,j.jsxs)(`div`,{className:`sm-matrix`,style:{"--sm-cols":e.cols.length},children:[(0,j.jsx)(`div`,{className:`sm-corner`,"aria-hidden":`true`}),e.cols.map(e=>{let t=Sh(e);return(0,j.jsx)(`div`,{className:`sm-head${t?` sm-${t}`:``}`,children:Ch(e)},e)}),e.rows.map(t=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(`div`,{className:`sm-rl`,children:t.sub}),e.cols.map(e=>(0,j.jsx)(wh,{g:t.cells[e]},e))]},t.sub))]})}function Eh({g:e}){let t=parseFloat(e.value),n=Number.isFinite(t),r=n?Math.max(0,Math.min(100,t)):0,i=n&&e.path.includes(`.fuel.`)&&r<20;return(0,j.jsxs)(`div`,{className:`tk${e.ageS!==null&&e.ageS>=bh?` quiet`:``}${i?` low`:``}`,children:[(0,j.jsx)(`div`,{className:`tk-l`,children:e.label}),(0,j.jsx)(`div`,{className:`tk-bar`,children:(0,j.jsx)(`i`,{style:{width:`${r}%`}})}),(0,j.jsx)(`div`,{className:`tk-pct`,children:e.value})]})}function Dh({g:e}){let t=e.ageS!==null&&e.ageS>=bh;return(0,j.jsxs)(`div`,{className:`c sy-c${t?` quiet`:``}`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[e.label,e.sub!==null&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsx)(`span`,{className:`sub`,children:e.sub})]})]}),(0,j.jsx)(`div`,{className:`n sy-n`,children:e.value}),t&&(0,j.jsx)(`div`,{className:`sy-age`,children:xh(e.ageS)})]})}function Oh({snap:e,tab:t}){let n=vh(e).find(e=>e.key===t);if(!n)return(0,j.jsx)(`div`,{className:`sy-wrap`,children:(0,j.jsx)(`div`,{className:`sy-none`,children:`No readings from this system right now.`})});if(n.key===`tanks`){let e=n.gauges.filter(e=>e.sub===null),t=n.gauges.filter(e=>e.sub!==null);return(0,j.jsxs)(`div`,{className:`sy-wrap`,children:[e.length>0&&(0,j.jsx)(`div`,{className:`tk-list`,children:e.map(e=>(0,j.jsx)(Eh,{g:e},e.path))}),t.length>0&&(0,j.jsx)(`div`,{className:`sy-grid`,children:t.map(e=>(0,j.jsx)(Dh,{g:e},e.path))})]})}return(0,j.jsx)(`div`,{className:`sy-wrap`,children:(0,j.jsx)(Th,{m:_h(n.gauges)})})}var kh=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`},Ah=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}`},jh=e=>e==null?null:(e*180/Math.PI+360)%360,Mh=e=>e==null?null:e*Xm,Nh=e=>{let t=Mh(e);return t===null?null:t>=.4?t:0},Ph=e=>e==null?null:e-273.15,Fh=e=>e==null?null:e/100,Ih=(e,t=1,n=``)=>e==null?`·`:`${e.toFixed(t)}${n}`,Lh=Qm,Rh=(e,t,n)=>{if(e==null||Number.isNaN(e))return`·`;let r=e<0?t[1]:t[0],i=Math.abs(e),a=Math.floor(i),o=(i-a)*60;return`${String(a).padStart(n,`0`)}°${o.toFixed(3).padStart(6,`0`)}' ${r}`},zh=e=>{let[t,n,r]=e.split(`-`).map(Number);return Date.UTC(t,n-1,r,0,0,0,0)},Bh=(e=new Date)=>{let t=e=>String(e).padStart(2,`0`);return`${e.getUTCFullYear()}-${t(e.getUTCMonth()+1)}-${t(e.getUTCDate())}`},Vh=[`environment.depth.belowTransducer`,`environment.depth.belowKeel`,`environment.depth.belowSurface`];function Hh(e,t){if(e!==null||!t)return{kind:`none`};let n=0;for(let e of Vh){let r=t[e];r&&r.last_seen_ts>n&&(n=r.last_seen_ts)}return n===0?{kind:`no-sensor`}:{kind:`quiet`,lastTs:n}}var Uh=864e5;function Wh(e){switch(e){case`belowTransducer`:return`BELOW TRANSDUCER`;case`belowKeel`:return`BELOW KEEL`;case`belowSurface`:return`BELOW SURFACE`;default:return`DATUM UNKNOWN`}}function Gh(e,t){switch(e.kind){case`none`:return null;case`no-sensor`:return`NO SENSOR
21
- NORMAL`;case`quiet`:{let n=t-e.lastTs;return n>=Uh?`QUIET · ${Math.floor(n/Uh)}d`:`QUIET · ${Ah(e.lastTs)}`}}}var Kh=2e3,qh=6e4;function Jh(e){return e.sogKn!==null||(e.snap?.nav_state??null)!==null||(e.snap?.lat??null)!==null||(e.snap?.lon??null)!==null||e.cogDeg!==null||e.hdgTrue!==null||e.twsKn!==null||e.twdDeg!==null||e.awaDeg!==null||e.baroHPa!==null||e.airC!==null||e.waterC!==null||e.depth!==null}function Yh(e,t){if(e.length<=t)return e;let n=e.length/t,r=[];for(let i=0;i<t;i++)r.push(e[Math.floor(i*n)]);return r}function Xh(){let{data:e}=Dm(_r.live,Kh,[],`bridge:live`),{data:t}=Dm(()=>_r.tools.baroTrend(3),qh,[],`bridge:baro`),{data:n}=Dm(_r.health,qh,[],`bridge:health`),r=xm(1e3),[i,a]=(0,p.useState)(6),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)([]);(0,p.useEffect)(()=>{let e=!1,t=async()=>{try{let t=Date.now()-i*36e5,n=await _r.logbook.snapshots({from:t,limit:5e3,order:`asc`}),r=null,a=[];for(let e of n){let t=Mh(e.wind_gust??e.wind_speed_true);t!==null&&(a.push(t),(r===null||t>r.kn)&&(r={kn:t,ts:e.ts}))}e||(s(r),l(Yh(a,28)))}catch{}},n=null,r=()=>{n===null&&(n=setInterval(t,5*6e4))},a=()=>{n!==null&&(clearInterval(n),n=null)},o=()=>{document.hidden?a():(t(),r())};return t(),document.hidden||r(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[i]);let u=e?.ts?Math.max(0,Math.round((r-e.ts)/1e3)):null,d=e?.field_ages?.lat,f=u===null?null:d===void 0?u:u+d,m=e?.lat!=null&&e?.lon!=null,h=m&&f!==null&&f<30,g=jh(e?.heading_true),_=Nh(e?.sog),v=_===null?null:jh(e?.cog),y=Mh(e?.wind_speed_true),b=jh(e?.wind_direction_true),x=jh(e?.wind_angle_apparent),S=Lh(y);(0,p.useEffect)(()=>{if(y===null||!e?.ts)return;let t=Date.now()-i*36e5;e.ts<t||s(t=>!t||y>t.kn?{kn:y,ts:e.ts}:t)},[y,e?.ts,i]);let C=Fh(e?.air_pressure_pa)??t?.current_hpa??null,w=t?.delta_3h_hpa??null,T=Yh((t?.series??[]).map(e=>e.value).filter(e=>e!==null).map(e=>e>2e3?e/100:e),28),E=Ph(e?.air_temp_k),ee=Ph(e?.water_temp_k),te=e?.depth??null,ne=Hh(te,n?.paths),re=e?.nav_state?.toUpperCase()||`·`,D=o&&r-o.ts<=i*36e5?o:null,ie=(()=>{let e=new Date(r),t=e=>String(e).padStart(2,`0`);return`${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`})();return{snap:e??null,now:r,ageSec:f,live:h,hasFix:m,hdgTrue:g,sogKn:_,cogDeg:v,twsKn:y,twdDeg:b,awaDeg:x,bft:S,baroHPa:C,baroDelta:w,airC:E,waterC:ee,depth:te,depthDiag:ne,sealing:n?.sealing??null,navState:re,utcClock:ie,gustMax:D,gustHours:i,setGustHours:a,gustSeries:c,baroSeries:T}}var Zh=e(u(),1),Qh=36e5,$h=864e5,eg=[{key:`24h`,label:`24h`,span:24*Qh,buffer:3*$h},{key:`7d`,label:`7d`,span:7*$h,buffer:21*$h},{key:`30d`,label:`30d`,span:30*$h,buffer:90*$h}];function tg(e){if(e.length===0)return``;let t=`M ${e[0][0]},${e[0][1]}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]||e[n],i=e[n],a=e[n+1],o=e[n+2]||a;t+=` C ${i[0]+(a[0]-r[0])/6},${i[1]+(a[1]-r[1])/6} ${a[0]-(o[0]-i[0])/6},${a[1]-(o[1]-i[1])/6} ${a[0]},${a[1]}`}return t}var ng=340,rg=190,ig=34,ag=10,og=12,sg=22,cg=ng-ig-ag,lg=rg-og-sg;function ug(e,t){let n=new Date(e);return t<=2*$h?n.toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`})}function dg({onClose:e,current:t,delta:n}){let[r,i]=(0,p.useState)(`24h`),[a,o]=(0,p.useState)([]),[s,c]=(0,p.useState)(!0),[l,u]=(0,p.useState)(null),[d,f]=(0,p.useState)(()=>Date.now()),[m,h]=(0,p.useState)(!1),g=(0,p.useRef)({from:0,to:0}),_=eg.find(e=>e.key===r);(0,p.useEffect)(()=>{let e=!1;c(!0),u(null);let t=Date.now(),n=t-_.buffer;return g.current={from:n,to:t},(async()=>{try{let r=await _r.tools.baroSeries({from:n,to:t,points:160});if(e)return;o(r),f(t)}catch(t){e||u(t.message||`Load failed`)}finally{e||c(!1)}})(),()=>{e=!0}},[r,_.buffer]);let v=(0,p.useMemo)(()=>{let e=a.length?a[0].ts:g.current.from,t=g.current.to;return{minEnd:Math.min(t,e+_.span),maxEnd:t}},[a,_.span]),y=d-_.span,b=(0,p.useMemo)(()=>{let e=a.filter(e=>e.ts>=y&&e.ts<=d),t=a.findIndex(e=>e.ts>=y),n=t>0?t-1:0,r=a.length-1;for(let e=a.length-1;e>=0;e--)if(a[e].ts<=d){r=Math.min(a.length-1,e+1);break}return e.length?a.slice(n,r+1):[]},[a,y,d]),x=(0,p.useMemo)(()=>{if(!b.length)return{lo:1e3,hi:1020};let e=Math.min(...b.map(e=>e.hpa)),t=Math.max(...b.map(e=>e.hpa)),n=(e+t)/2,r=Math.max((t-e)/2+1,3);return{lo:Math.floor(n-r),hi:Math.ceil(n+r)}},[b]),S=(0,p.useRef)(x),C=m?S.current:x,w=e=>ig+(e-y)/_.span*cg,T=e=>og+lg*(1-(e-C.lo)/(C.hi-C.lo||1)),E=tg(b.map(e=>[w(e.ts),T(e.hpa)])),ee=E?`${E} L ${w(b[b.length-1].ts)},168 L ${w(b[0].ts)},168 Z`:``,te=[0,.5,1].map(e=>Math.round(C.hi-e*(C.hi-C.lo))),ne=[0,.5,1].map(e=>y+e*_.span),re=(0,p.useRef)(null),D=(0,p.useRef)(null),ie=(0,p.useRef)(null),ae=(0,p.useRef)(0),oe=()=>{if(ie.current=null,!D.current)return;let e=-((ae.current-D.current.x)/D.current.w)*_.span;f(Math.max(v.minEnd,Math.min(v.maxEnd,D.current.end+e)))},se=e=>{let t=re.current?.clientWidth??ng;D.current={x:e.clientX,end:d,w:t},ae.current=e.clientX,S.current=x,h(!0),re.current?.setPointerCapture(e.pointerId)},O=e=>{D.current&&(ae.current=e.clientX,ie.current??=requestAnimationFrame(oe))},k=e=>{ie.current!=null&&cancelAnimationFrame(ie.current),oe(),D.current=null,h(!1),re.current?.releasePointerCapture(e.pointerId)};(0,p.useEffect)(()=>()=>{ie.current!=null&&cancelAnimationFrame(ie.current)},[]);let ce=n===null?``:n<-.1?`▼`:n>.1?`▲`:`▬`,le=d>=v.maxEnd-6e4,ue=document.querySelector(`.swiss.sp-screen`)??document.body;return(0,Zh.createPortal)((0,j.jsx)(pm,{title:`Barometer`,eyebrow:`hPa · pressure`,onClose:e,children:(0,j.jsxs)(`div`,{className:`baro-pop`,children:[(0,j.jsxs)(`div`,{className:`bp-head`,children:[(0,j.jsxs)(`div`,{className:`bp-now`,children:[t===null?`·`:Math.round(t),(0,j.jsx)(`span`,{className:`bp-u`,children:`hPa`})]}),n!==null&&(0,j.jsxs)(`div`,{className:`bp-delta`,children:[ce,` `,Math.abs(n).toFixed(1),` / 3h`]}),(0,j.jsx)(`div`,{className:`seg bp-seg`,children:eg.map(e=>(0,j.jsx)(`button`,{type:`button`,className:r===e.key?`on`:``,onClick:()=>i(e.key),children:e.label},e.key))})]}),l?(0,j.jsx)(`div`,{className:`lb-err`,children:l}):s?(0,j.jsx)(`div`,{className:`bp-msg`,children:`Loading…`}):b.length<2?(0,j.jsx)(`div`,{className:`bp-msg`,children:`No barometric data for this range.`}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`svg`,{ref:re,className:`bp-chart`,viewBox:`0 0 ${ng} ${rg}`,onPointerDown:se,onPointerMove:O,onPointerUp:k,onPointerCancel:k,children:[(0,j.jsx)(`defs`,{children:(0,j.jsxs)(`linearGradient`,{id:`bp-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,j.jsx)(`stop`,{offset:`0%`,style:{stopColor:`var(--accent)`,stopOpacity:.3}}),(0,j.jsx)(`stop`,{offset:`100%`,style:{stopColor:`var(--accent)`,stopOpacity:0}})]})}),te.map(e=>(0,j.jsxs)(`g`,{children:[(0,j.jsx)(`line`,{x1:ig,x2:ng-ag,y1:T(e),y2:T(e),className:`bp-grid`}),(0,j.jsx)(`text`,{x:ig-6,y:T(e)+3,className:`bp-ylab`,children:e})]},e)),(0,j.jsx)(`path`,{d:ee,className:`bp-area`,fill:`url(#bp-grad)`}),(0,j.jsx)(`path`,{d:E,className:`bp-line`,vectorEffect:`non-scaling-stroke`}),le&&b.length>0&&(0,j.jsx)(`circle`,{cx:w(b[b.length-1].ts),cy:T(b[b.length-1].hpa),r:3,className:`bp-dot`}),ne.map((e,t)=>(0,j.jsx)(`text`,{x:t===0?ig:t===2?ng-ag:182,y:rg-6,className:`bp-xlab`,textAnchor:t===0?`start`:t===2?`end`:`middle`,children:ug(e,_.span)},e))]})})]})}),ue)}function fg(e){return!e||e.mode!==`blocked`?null:{title:`Nothing is going ashore`,detail:`She is still recording her own history, but no report is leaving this boat: ${e.reason??`she could not seal this report to anybody`}.`}}var pg=`siparu.app/app`;function mg(e){return Math.max(0,Math.round((new Date(e).getTime()-Date.now())/6e4))}function hg(e){let{value:t,unit:n}=yh((Date.now()-e)/1e3);return`${t}${n===`s`?`s`:` ${n}`} ago`}function gg(e){return e?e.rejected||e.failures>0?e.lastError??`Not reaching Siparu.`:e.lastSentTs?`Sending · last frame ${hg(e.lastSentTs)}`:`Waiting to send the first frame.`:`Checking the link…`}function _g({sealing:e}){let[t,n]=(0,p.useState)(!1),[r,i]=(0,p.useState)(!1),[a,o]=(0,p.useState)(!1),{data:s,refresh:c}=Dm(()=>_r.pair.status(),t?5e3:3e4,[]);(0,p.useEffect)(()=>{let e=s?.state;n(e===`showing_code`||e===`awaiting_approval`)},[s?.state]);async function l(e){i(!0);try{await e()}catch{}finally{i(!1),o(!1),c()}}let u=fg(e),d=u?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:u.title}),(0,j.jsx)(`div`,{className:`s`,children:u.detail})]})}):null,f=e?.screens??[],m=f.length>0?(0,j.jsx)(`div`,{className:`pair`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Screens she seals to`}),(0,j.jsx)(`div`,{className:`fps`,children:f.map((e,t)=>(0,j.jsx)(`span`,{className:`fp`,children:e},`${e}-${t}`))}),(0,j.jsx)(`div`,{className:`s`,children:`Every screen that can open her reports has a line here. If the line on your phone is missing, she is not sealing to it; if a line here is not one of yours, it can read her.`})]})}):null;if(!s)return(0,j.jsxs)(j.Fragment,{children:[d,m]});let h=(e,t,n)=>(0,j.jsx)(`button`,{className:`pbtn${n?` ${n}`:``}`,disabled:r,onClick:t,children:e}),g=s.pairing_locked===!0;return(0,j.jsxs)(j.Fragment,{children:[d,s.security_off?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:g?`Signal K security is off · pairing is locked`:`Signal K security is off`}),(0,j.jsx)(`div`,{className:`s`,children:g?`Anyone on this network could link this boat to another account or cut her loose, so pairing, unpairing and log edits stay locked. Add an admin user in Signal K - or, on a network you trust, accept the risk in the plugin settings.`:`Anyone who can reach this network can link this boat to their account, and the only sign here would be a linked account you do not recognise. Add an admin user in Signal K.`})]})}):null,s.revoke_pending?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Still revoking the old key`}),(0,j.jsx)(`div`,{className:`s`,children:`Remote viewing is off on this boat, but Siparu could not be reached to revoke its copy of the key. It will keep trying whenever the boat is online.`})]})}):null,(()=>{switch(s.state){case`idle`:case`expired`:return(0,j.jsxs)(`div`,{className:`pair`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing`}),(0,j.jsx)(`div`,{className:`s`,children:s.state===`expired`?`The code expired. Nothing was linked.`:`Off - this boat is not linked to an account.`})]}),!g&&h(s.state===`expired`?`New code`:`Turn on`,()=>l(_r.pair.start))]});case`showing_code`:return(0,j.jsxs)(`div`,{className:`pair`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · waiting`}),(0,j.jsx)(`div`,{className:`code`,children:s.userCode}),(0,j.jsxs)(`div`,{className:`s`,children:[`Enter this at `,(0,j.jsx)(`b`,{children:pg}),` · `,mg(s.expiresAt),` min left`]})]}),h(`Cancel`,()=>l(_r.pair.deny),`ghost`)]});case`awaiting_approval`:return(0,j.jsxs)(`div`,{className:`pair asking`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Someone wants to pair`}),(0,j.jsx)(`div`,{className:`who`,children:s.email??`an account we cannot name`}),s.device?(0,j.jsx)(`div`,{className:`fps`,children:(0,j.jsx)(`span`,{className:`fp`,children:s.device.fingerprint})}):null,(0,j.jsx)(`div`,{className:`s`,children:s.device?`Approve only if this is you, and only if that line matches the one on your phone. They will see where this boat is.`:`Approve only if this is you. They will see where this boat is.`})]}),(0,j.jsxs)(`div`,{className:`acts`,children:[h(`Deny`,()=>l(_r.pair.deny),`ghost`),!g&&h(`Approve`,()=>l(_r.pair.approve),`accent`)]})]});case`paired`:return(0,j.jsxs)(`div`,{className:`pair${s.uplink?.rejected?` err`:``}`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · on`}),(0,j.jsx)(`div`,{className:`who`,children:s.email??`linked account`}),!a&&!u&&(0,j.jsx)(`div`,{className:`s`,children:gg(s.uplink)})]}),g?null:a?(0,j.jsxs)(`div`,{className:`acts`,children:[h(`Keep`,()=>o(!1),`ghost`),h(`Unlink`,()=>l(_r.pair.reset),`accent`)]}):(0,j.jsxs)(`div`,{className:`acts`,children:[h(`Pair again`,()=>l(_r.pair.start),`ghost`),h(`Turn off`,()=>o(!0),`ghost`)]})]});case`error`:return(0,j.jsxs)(`div`,{className:`pair err`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · error`}),(0,j.jsx)(`div`,{className:`s`,children:s.message})]}),!g&&(0,j.jsxs)(`div`,{className:`acts`,children:[h(`Dismiss`,()=>l(_r.pair.reset),`ghost`),h(`Retry`,()=>l(_r.pair.start))]})]})}})(),m]})}var vg=1e-6;function yg(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function bg(e,t){let n=[],r=(e,t,r,i)=>n.push({key:e,label:t,sub:r,value:i}),i=(e.end_ts??t)-e.start_ts;i>=0&&r(`duration`,`Duration`,e.end_ts===null?`So far`:`Total`,yg(i)),e.hours_underway>vg&&r(`underway`,`Under way`,`Moving`,yg(e.hours_underway*36e5)),r(`distance`,`Distance`,`nm`,e.distance_nm.toFixed(1)),e.avg_sog_kn!==null&&r(`avgSpeed`,`Average speed`,`kn`,e.avg_sog_kn.toFixed(1)),e.max_sog_kn!==null&&r(`maxSpeed`,`Max speed`,`kn`,e.max_sog_kn.toFixed(1));let a=e.fuel_used_l;return a!==null&&Number.isFinite(a)&&(r(`fuelUsed`,`Fuel used`,`L`,a.toFixed(1)),e.hours_underway>vg&&r(`fuelPerHour`,`Fuel per hour`,`L/h`,(a/e.hours_underway).toFixed(1)),e.distance_nm>vg&&r(`fuelPerMile`,`Fuel per mile`,`L/nm`,(a/e.distance_nm).toFixed(2))),n}function xg({voyage:e,now:t}){if(e===null)return null;let n=bg(e,t);return n.length===0?null:(0,j.jsx)(`div`,{className:`grid`,children:(0,j.jsx)(`div`,{className:`matrix`,children:n.map(e=>(0,j.jsxs)(`div`,{className:`c`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[e.label,` · `,(0,j.jsx)(`span`,{className:`sub`,children:e.sub})]}),(0,j.jsx)(`div`,{className:`n`,children:e.value})]},e.key))})})}var Sg=[1,6,12,24],Cg=`(min-width: 1000px)`,wg=6e4;function Tg(e){return e===null?`·`:String(Math.round(e))}function Eg(e){return e===null?`·`:`${Math.round(Math.abs(e))}°${e<0?`P`:`S`}`}function Dg(e){if(e===null)return{txt:`·`,tone:``};let t=e<-.1?`▼`:e>.1?`▲`:`▬`,n=e<=-4?`alarm`:e<=-1.6?`warn`:e>=1?`ok`:``;return{txt:`${t} ${Math.abs(e).toFixed(1)} / 3h`,tone:n}}function Og(e){return e.charAt(0)+e.slice(1).toLowerCase()}var kg={UNDERWAY:`Under­way`,ANCHORED:`An­chored`,MOORED:`Moored`};function Ag(e){return e===`·`?`·`:kg[e]??Og(e)}function jg({d:e,onBaro:t}){let n=e.snap===null,r=Dg(e.baroDelta),i=e.snap?.lat??null,a=e.snap?.lon??null,o=e=>n||e!==null,s=[];o(e.sogKn)&&s.push((0,j.jsxs)(`div`,{className:`c c-sog`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`SOG · `,(0,j.jsx)(`span`,{className:`sub`,children:`Knots`})]}),n?(0,j.jsx)(`div`,{className:`n skel`,children:`8.4`}):(0,j.jsx)(Ym,{className:`n`,value:e.sogKn,digits:1})]},`sog`)),(o(e.snap?.nav_state??null)||o(i))&&s.push((0,j.jsxs)(`div`,{className:`c c-state`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Nav state`}),(0,j.jsx)(`div`,{className:`s`,children:Ag(e.navState)}),(0,j.jsx)(`div`,{className:`meta`,children:e.snap===null||!e.hasFix?`AWAITING FIX`:e.live?`FIX ${e.ageSec}s · WGS84`:`STALE ${e.ageSec}s`})]},`state`)),o(i)&&o(a)&&s.push((0,j.jsxs)(`div`,{className:`c c-pos`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Position · `,(0,j.jsx)(`span`,{className:`sub`,children:`WGS84`})]}),(0,j.jsxs)(`div`,{className:`coords`,children:[Rh(i,[`N`,`S`],2),(0,j.jsx)(`br`,{}),Rh(a,[`E`,`W`],3)]})]},`pos`));let c=[];return o(e.cogDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-cog`,children:[(0,j.jsx)(`div`,{className:`t`,children:`COG`}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Tg(e.cogDeg),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`cog`)),o(e.hdgTrue)&&c.push((0,j.jsxs)(`div`,{className:`c c-hdg`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`HDG · `,(0,j.jsx)(`span`,{className:`sub`,children:`True`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Tg(e.hdgTrue),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`hdg`)),o(e.twsKn)&&c.push((0,j.jsxs)(`div`,{className:`c c-windtrue`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Wind true`,e.bft!==null&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsxs)(`span`,{className:`sub`,children:[`Bft `,e.bft]})]})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.twsKn===null?`·`:e.twsKn.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`kn`})]})]},`windtrue`)),o(e.twdDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-windfrom`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Wind from · `,(0,j.jsx)(`span`,{className:`sub`,children:`True`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Tg(e.twdDeg),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`windfrom`)),o(e.twsKn)&&c.push((0,j.jsxs)(`div`,{className:`c c-gust`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Gust`}),(0,j.jsx)(_m,{className:`spark`,data:e.gustSeries,color:`var(--spark-gust)`,fill:!0,peak:!0,height:42}),(0,j.jsx)(`div`,{className:`lab`,children:e.gustMax?(0,j.jsxs)(j.Fragment,{children:[`GUST `,(0,j.jsxs)(`b`,{children:[e.gustMax.kn.toFixed(1),` kn`]}),` · `,Ah(e.gustMax.ts)]}):`GUST -`}),(0,j.jsx)(`div`,{className:`gustseg`,role:`group`,"aria-label":`Gust window`,children:Sg.map(t=>(0,j.jsxs)(`button`,{className:e.gustHours===t?`on`:``,onClick:()=>e.setGustHours(t),children:[t,`h`]},t))})]},`gust`)),o(e.awaDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-awa`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`AWA · `,(0,j.jsx)(`span`,{className:`sub`,children:`Apparent`})]}),(0,j.jsx)(`div`,{className:`n${n?` skel`:``}`,children:Eg(e.awaDeg)})]},`awa`)),o(e.baroHPa)&&c.push((0,j.jsxs)(`div`,{className:`c c-baro tap`,onClick:t,role:`button`,"aria-label":`Barometer detail`,children:[(0,j.jsxs)(`div`,{className:`left`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Baro · `,(0,j.jsx)(`span`,{className:`sub`,children:`hPa`})]}),(0,j.jsx)(`div`,{className:`n${n?` skel`:``}`,children:e.baroHPa===null?`·`:Math.round(e.baroHPa)}),(0,j.jsx)(`div`,{className:`trend ${r.tone}`,children:r.txt})]}),(0,j.jsxs)(`div`,{className:`sparkwrap`,children:[(0,j.jsx)(_m,{className:`spark-b`,data:e.baroSeries,color:`var(--spark-baro)`,height:38,top:4}),(0,j.jsx)(`div`,{className:`lab`,children:`3-hour trend · tap ⤢`})]})]},`baro`)),o(e.airC)&&c.push((0,j.jsxs)(`div`,{className:`c c-air`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Air · `,(0,j.jsx)(`span`,{className:`sub`,children:`Outside`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.airC===null?`·`:e.airC.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`°C`})]})]},`air`)),o(e.waterC)&&c.push((0,j.jsxs)(`div`,{className:`c c-sea`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Sea · `,(0,j.jsx)(`span`,{className:`sub`,children:`Water`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.waterC===null?`·`:e.waterC.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`°C`})]})]},`sea`)),o(e.depth)&&c.push((0,j.jsxs)(`div`,{className:`c c-depth`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Depth · `,(0,j.jsx)(`span`,{className:`sub`,children:`m`})]}),n?(0,j.jsx)(`div`,{className:`n skel`,children:`32.4`}):(0,j.jsx)(Ym,{className:`n`,value:e.depth,digits:1}),!n&&Gh(e.depthDiag,e.now)&&(0,j.jsx)(`div`,{className:`meta`,children:Gh(e.depthDiag,e.now)}),!n&&e.depth!==null&&(0,j.jsx)(`div`,{className:`meta`,children:Wh(e.snap?.depth_datum)})]},`depth`)),(0,j.jsxs)(`div`,{className:`grid`,children:[s.length>0&&(0,j.jsx)(`div`,{className:`band`,children:s}),c.length>0&&(0,j.jsx)(`div`,{className:`matrix`,children:c}),!n&&s.length===0&&c.length===0&&(0,j.jsxs)(`div`,{className:`c c-quiet`,children:[(0,j.jsx)(`div`,{className:`t`,children:`No instruments reporting`}),(0,j.jsx)(`div`,{className:`meta`,children:`Signal K is connected and carries no position, speed, wind or depth for this vessel. Alongside with the instruments switched off, this is the expected reading.`})]})]})}function Mg({tab:e,tabs:t,d:n,voyage:r,onTab:i,onBaro:a}){return(0,j.jsxs)(`div`,{className:`sp-pane`,children:[t.length>1&&(0,j.jsx)(`nav`,{className:`sy-tabs`,"aria-label":`Instrument panels`,children:t.map(t=>(0,j.jsx)(`button`,{type:`button`,className:`sy-tab${e===t.key?` on`:``}`,"aria-current":e===t.key?`page`:void 0,onClick:()=>i(t.key),children:t.name},t.key))}),e===`bridge`?(0,j.jsx)(jg,{d:n,onBaro:a}):e===`trip`?(0,j.jsx)(xg,{voyage:r,now:n.now}):(0,j.jsx)(Oh,{snap:n.snap,tab:e})]})}function Ng(){let e=Xh(),[t,n]=(0,p.useState)(!1),[r,i]=Un(),a=Hm(Cg),o=()=>n(!0),s=vh(e.snap),c=e.snap===null||Jh(e)||s.length===0,{data:l}=Dm(_r.voyage.current,wg),u=l!=null;if(a)return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`sp-dash sp-board`,children:[c&&(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-bridge`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:`Bridge`}),(0,j.jsx)(jg,{d:e,onBaro:o})]}),(s.length>0||u)&&(0,j.jsxs)(`div`,{className:`sp-systems`,children:[s.map(t=>(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-${t.key}`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:t.name}),(0,j.jsx)(Oh,{snap:e.snap,tab:t.key})]},t.key)),u&&(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-trip`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:`Trip computer`}),(0,j.jsx)(xg,{voyage:l,now:e.now})]},`trip`)]})]}),(0,j.jsx)(_g,{sealing:e.sealing}),t&&(0,j.jsx)(dg,{onClose:()=>n(!1),current:e.baroHPa,delta:e.baroDelta})]});let d=[...c?[{key:`bridge`,name:`Bridge`}]:[],...s.map(e=>({key:e.key,name:e.name})),...u?[{key:`trip`,name:`Trip`}]:[]],f=(e=>e&&d.some(t=>t.key===e)?e:null)(r.get(`a`))??d[0]?.key??`bridge`;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`sp-dash`,children:(0,j.jsx)(Mg,{tab:f,tabs:d,d:e,voyage:l,onTab:e=>{let t=new URLSearchParams(r);t.set(`a`,e),i(t,{replace:!0})},onBaro:o})}),(0,j.jsx)(_g,{sealing:e.sealing}),t&&(0,j.jsx)(dg,{onClose:()=>n(!1),current:e.baroHPa,delta:e.baroDelta})]})}function Pg(){return(0,j.jsx)(Ng,{})}var Fg=(0,p.lazy)(()=>v(()=>import(`./Logbook-CZb9OaA4.js`),__vite__mapDeps([2,1,3]),import.meta.url)),Ig=(0,p.lazy)(()=>v(()=>import(`./Voyage-CzIqnUBA.js`),__vite__mapDeps([4,1,5,6]),import.meta.url)),Lg=(0,p.lazy)(()=>v(()=>import(`./Map-CN4rx5A-.js`),__vite__mapDeps([7,1,3,5,6]),import.meta.url));function Rg(){let[e,t]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(ar,e),()=>window.removeEventListener(ar,e)},[]),e?(0,j.jsx)(ym,{}):(0,j.jsx)(nr,{children:(0,j.jsx)(p.Suspense,{fallback:(0,j.jsx)(bm,{full:!0}),children:(0,j.jsxs)(Ut,{children:[(0,j.jsxs)(Vt,{element:(0,j.jsx)(qm,{}),children:[(0,j.jsx)(Vt,{path:`/`,element:(0,j.jsx)(Pg,{})}),(0,j.jsx)(Vt,{path:`/logbook`,element:(0,j.jsx)(Fg,{})}),(0,j.jsx)(Vt,{path:`/voyage`,element:(0,j.jsx)(Ig,{})}),(0,j.jsx)(Vt,{path:`/map`,element:(0,j.jsx)(Lg,{})})]}),(0,j.jsx)(Vt,{path:`*`,element:(0,j.jsx)(Bt,{to:`/`,replace:!0})})]})})})}Fm(),(0,m.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(p.StrictMode,{children:(0,j.jsx)(Nn,{children:(0,j.jsx)(Rg,{})})}));export{tr as _,kh as a,Fh as c,yh as d,Dm as f,_r as g,rr as h,Ih as i,jh as l,pm as m,Bh as n,Lh as o,xm as p,Rh as r,Mh as s,zh as t,Nh as u,u as v,o as y};
20
+ `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,j.jsx)(Bd,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:p.cloneElement(e,{ref:u})})}var Hd=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=yr(Ud),d=(0,p.useId)(),f=(0,p.useRef)(n),m=(0,p.useRef)(r);br(()=>{f.current=n,m.current=r});let h=!0,g=(0,p.useMemo)(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&m.current?.()})}),[n,u,r]);return a&&h&&(g={...g}),(0,p.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),p.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,j.jsx)(Vd,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,j.jsx)(xr.Provider,{value:g,children:e})};function Ud(){return new Map}function Wd(e=!0){let t=(0,p.useContext)(xr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,p.useId)();(0,p.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,p.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Gd=e=>e.key||``;function Kd(e){let t=[];return p.Children.forEach(e,e=>{(0,p.isValidElement)(e)&&t.push(e)}),t}var qd=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=Wd(o),f=(0,p.useMemo)(()=>Kd(e),[e]),m=o&&!u?[]:f.map(Gd),h=(0,p.useRef)(!0),g=(0,p.useRef)(f),_=yr(()=>new Map),v=(0,p.useRef)(new Set),[y,b]=(0,p.useState)(f),[x,S]=(0,p.useState)(f);br(()=>{h.current=!1,g.current=f;for(let e=0;e<x.length;e++){let t=Gd(x[e]);m.includes(t)?(_.delete(t),v.current.delete(t)):_.get(t)!==!0&&_.set(t,!1)}},[x,m.length,m.join(`-`)]);let C=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=Gd(n);m.includes(r)||(e.splice(t,0,n),C.push(n))}return a===`wait`&&C.length&&(e=C),S(Kd(e)),b(f),null}let{forceRender:w}=(0,p.useContext)(vr);return(0,j.jsx)(j.Fragment,{children:x.map(e=>{let p=Gd(e),y=o&&!u?!1:f===x||m.includes(p);return(0,j.jsx)(Hd,{isPresent:y,initial:!h.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(v.current.has(p))return;if(_.has(p))v.current.add(p),_.set(p,!0);else return;let e=!0;_.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(g.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},p)})})},Jd=(0,p.createContext)({strict:!1}),Yd={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Xd=!1;function Zd(){if(Xd)return;let e={};for(let t in Yd)e[t]={isEnabled:e=>Yd[t].some(t=>!!e[t])};ul(e),Xd=!0}function Qd(){return Zd(),dl()}function $d(e){let t=Qd();for(let n in e)t[n]={...t[n],...e[n]};ul(t)}var ef=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function tf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||ef.has(e)}var nf=r({default:()=>rf}),rf,af=n((()=>{throw rf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),of=e=>!tf(e);function sf(e){typeof e==`function`&&(of=t=>t.startsWith(`on`)?!tf(t):e(t))}try{sf((af(),t(nf)).default)}catch{}function cf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Cs(e[i])||(of(i)||n===!0&&tf(i)||!t&&!tf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var lf=(0,p.createContext)({});function uf(e,t){if(tl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Qc(t)?t:void 0,animate:Qc(n)?n:void 0}}return e.inherit===!1?{}:t}function df(e){let{initial:t,animate:n}=uf(e,(0,p.useContext)(lf));return(0,p.useMemo)(()=>({initial:t,animate:n}),[ff(t),ff(n)])}function ff(e){return Array.isArray(e)?e.join(` `):e}var pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function mf(e,t,n){for(let r in t)!Cs(t[r])&&!Bl(r,n)&&(e[r]=t[r])}function hf({transformTemplate:e},t){return(0,p.useMemo)(()=>{let n=pf();return K(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gf(e,t){let n=e.style||{},r={};return mf(r,n,e),Object.assign(r,hf(e,t)),r}function _f(e,t){let n={},r=gf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var vf=()=>({...pf(),attrs:{}});function yf(e,t,n,r){let i=(0,p.useMemo)(()=>{let n=vf();return Jl(n,t,Xl(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};mf(t,e.style,e),i.style={...t,...i.style}}return i}var bf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function xf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(bf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??xf(e)?yf:_f)(t,r,i,e),c=cf(t,typeof e==`string`,a),l=e===p.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,p.useMemo)(()=>Cs(u)?u.get():u,[u]);return(0,p.createElement)(e,{...l,children:d})}function Cf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wf(n,r,i,e),renderState:t()}}function wf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=$u(a[e]);let{initial:o,animate:s}=e,c=tl(e),l=nl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Zc(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=gs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Tf=e=>(t,n)=>{let r=(0,p.useContext)(lf),i=(0,p.useContext)(xr),a=()=>Cf(e,t,r,i);return n?a():yr(a)},Ef=Tf({scrapeMotionValuesFromProps:Vl,createRenderState:pf}),Df=Tf({scrapeMotionValuesFromProps:Ql,createRenderState:vf}),Of=Symbol.for(`motionComponentSymbol`);function kf(e,t,n){let r=(0,p.useRef)(n);(0,p.useInsertionEffect)(()=>{r.current=n});let i=(0,p.useRef)(null);return(0,p.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var Af=(0,p.createContext)({});function jf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Mf(e,t,n,r,i,a){let{visualElement:o}=(0,p.useContext)(lf),s=(0,p.useContext)(Jd),c=(0,p.useContext)(xr),l=(0,p.useContext)(Id),u=l.reducedMotion,d=l.skipAnimations,f=(0,p.useRef)(null),m=(0,p.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),m.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let h=f.current,g=(0,p.useContext)(Af);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&Nf(f.current,n,i,g);let _=(0,p.useRef)(!1);(0,p.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[Ds],y=(0,p.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return br(()=>{m.current=!0,h&&(_.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState&&h.animationState.animateChanges())}),(0,p.useEffect)(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function Nf(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Pf(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&jf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Pf(e){if(e)return e.options.allowProjection===!1?Pf(e.parent):e.projection}function Ff(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&$d(r);let a=n?n===`svg`:xf(e),o=a?Df:Ef;function s(n,s){let c,l={...(0,p.useContext)(Id),...n,layoutId:If(n)},{isStatic:u}=l,d=df(n),f=o(n,u);if(!u&&typeof window<`u`){Lf(l,r);let t=Rf(l);c=t.MeasureLayout,d.visualElement=Mf(e,f,l,i,t.ProjectionNode,a)}return(0,j.jsxs)(lf.Provider,{value:d,children:[c&&d.visualElement?(0,j.jsx)(c,{visualElement:d.visualElement,...l}):null,Sf(e,n,kf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,p.forwardRef)(s);return c[Of]=e,c}function If({layoutId:e}){let t=(0,p.useContext)(vr).id;return t&&e!==void 0?t+`-`+e:e}function Lf(e,t){(0,p.useContext)(Jd).strict}function Rf(e){let{drag:t,layout:n}=Qd();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function zf(e,t){if(typeof Proxy>`u`)return Ff;let n=new Map,r=(n,r)=>Ff(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Ff(a,void 0,e,t)),n.get(a))})}var Bf=(e,t)=>t.isSVG??xf(e)?new $l(t):new Ul(t,{allowProjection:e!==p.Fragment}),Vf=class extends ml{constructor(e){super(e),e.animationState||=ou(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Zc(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Hf=0,Uf={animation:{Feature:Vf},exit:{Feature:class extends ml{constructor(){super(...arguments),this.id=Hf++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=_s(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Wf(e){return{point:{x:e.pageX,y:e.pageY}}}var Gf=e=>t=>fc(t)&&e(t,Wf(t));function Kf(e,t,n,r){return Yu(e,t,Gf(n),r)}var qf=({current:e})=>e?e.ownerDocument.defaultView:null,Jf=(e,t)=>Math.abs(e-t);function Yf(e,t){let n=Jf(e.x,t.x),r=Jf(e.y,t.y);return Math.sqrt(n**2+r**2)}var Xf=new Set([`auto`,`scroll`]),Zf=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Qf(this.lastRawMoveEventInfo,this.transformPagePoint));let e=ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Yf(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=ui;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Qf(t,this.transformPagePoint),M.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=ep(e.type===`pointercancel`?this.lastMoveEventInfo:Qf(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!fc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Qf(Wf(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=ui;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,ep(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=jr(Kf(this.contextWindow,`pointermove`,this.handlePointerMove,d),Kf(this.contextWindow,`pointerup`,this.handlePointerUp,d),Kf(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Xf.has(e.overflowX)||Xf.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),M.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),li(this.updatePoint)}};function Qf(e,t){return t?{point:t(e.point)}:e}function $f(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ep({point:e},t){return{point:e,delta:$f(e,np(t)),offset:$f(e,tp(t)),velocity:rp(t,.1)}}function tp(e){return e[0]}function np(e){return e[e.length-1]}function rp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=np(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Pr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Pr(t)*2&&(r=e[1]);let a=Fr(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ip(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?R(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?R(n,e,r.max):Math.min(e,n)),e}function ap(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function op(e,{top:t,left:n,bottom:r,right:i}){return{x:ap(e.x,n,i),y:ap(e.y,t,r)}}function sp(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function cp(e,t){return{x:sp(e.x,t.x),y:sp(e.y,t.y)}}function lp(e,t){let n=.5,r=_u(e),i=_u(t);return i>r?n=Mr(t.min,t.max-r,e.min):r>i&&(n=Mr(e.min,e.max-i,t.min)),wr(0,1,n)}function up(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var dp=.35;function fp(e=dp){return e===!1?e=0:e===!0&&(e=dp),{x:pp(e,`left`,`right`),y:pp(e,`top`,`bottom`)}}function pp(e,t,n){return{min:mp(e,t),max:mp(e,n)}}function mp(e,t){return typeof e==`number`?e:e[t]||0}var hp=new WeakMap,gp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yc(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Wf(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),zu(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Ii.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=_u(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&M.update(()=>i(e,t),!1,!0),Ts(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=bp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&M.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Zf(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:qf(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&M.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!yp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=ip(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&jf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=op(n.layoutBox,e):this.constraints=!1,this.elastic=fp(t),r!==this.constraints&&!jf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&zu(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=up(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=Fl(n,r.root,this.visualElement.getTransformPagePoint()),a=cp(r.layout.layoutBox,i);if(t){let e=t(gl(a));this.hasMutatedConstraints=!!e,e&&(a=hl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=zu(o=>{if(!yp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Ts(this.visualElement,e),n.start(ds(e,n,0,t,this.visualElement,!1))}stopAnimation(){zu(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){zu(t=>{let{drag:n}=this.getProps();if(!yp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-R(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!jf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};zu(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=lp({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),zu(t=>{if(!yp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(R(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;hp.set(this.visualElement,this);let e=this.visualElement.current,t=Kf(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();jf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=vp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),M.read(r);let o=Yu(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(zu(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=dp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function _p(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function vp(e,t,n){let r=Lc(e,_p(n)),i=Lc(t,_p(n));return()=>{r(),i()}}function yp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function bp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var xp=class extends ml{constructor(e){super(e),this.removeGroupControls=Ar,this.removeListeners=Ar,this.controls=new gp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ar}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Sp=e=>(t,n)=>{e&&M.update(()=>e(t,n),!1,!0)},Cp=class extends ml{constructor(){super(...arguments),this.removePointerDownListener=Ar}onPointerDown(e){this.session=new Zf(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qf(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Sp(e),onStart:Sp(t),onMove:Sp(n),onEnd:(e,t)=>{delete this.session,r&&M.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Kf(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},wp=!1,Tp=class extends p.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),wp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),td.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),wp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||M.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),rc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Ep(e){let[t,n]=Wd(),r=(0,p.useContext)(vr);return(0,j.jsx)(Tp,{...e,layoutGroup:r,switchLayoutGroup:(0,p.useContext)(Af),isPresent:t,safeToRemove:n})}var Dp={pan:{Feature:Cp},drag:{Feature:xp,ProjectionNode:Fd,MeasureLayout:Ep}};function Op(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&M.postRender(()=>i(t,Wf(t)))}var kp=class extends ml{mount(){let{current:e}=this.node;e&&(this.unmount=uc(e,(e,t)=>(Op(this.node,t,`Start`),e=>Op(this.node,e,`End`))))}unmount(){}},Ap=class extends ml{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=jr(Yu(this.node.current,`focus`,()=>this.onFocus()),Yu(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function jp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&M.postRender(()=>i(t,Wf(t)))}var Mp=class extends ml{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Cc(e,(e,t)=>(jp(this.node,t,`Start`),(e,{success:t})=>jp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Np=new WeakMap,Pp=new WeakMap,Fp=e=>{let t=Np.get(e.target);t&&t(e)},Ip=e=>{e.forEach(Fp)};function Lp({root:e,...t}){let n=e||document;Pp.has(n)||Pp.set(n,{});let r=Pp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Ip,{root:e,...t})),r[i]}function Rp(e,t,n){let r=Lp(t);return Np.set(e,n),r.observe(e),()=>{Np.delete(e),r.unobserve(e)}}var zp={some:0,all:1},Bp=class extends ml{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:zp[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Rp(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Vp(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Vp({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Hp={inView:{Feature:Bp},tap:{Feature:Mp},focus:{Feature:Ap},hover:{Feature:kp}},Up={layout:{ProjectionNode:Fd,MeasureLayout:Ep}},Wp=zf({...Uf,...Hp,...Dp,...Up},Bf);function Gp(e,t,n){(0,p.useInsertionEffect)(()=>e.on(t,n),[e,t,n])}function Kp(e){let t=yr(()=>ts(e)),{isStatic:n}=(0,p.useContext)(Id);if(n){let[,n]=(0,p.useState)(e);(0,p.useEffect)(()=>t.on(`change`,n),[])}return t}function qp(e,t){let n=Kp(t()),r=()=>n.set(t());return r(),br(()=>{let t=()=>M.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),li(r)}}),n}function Jp(e){$o.current=[],e();let t=qp($o.current,e);return $o.current=void 0,t}function Yp(e,t,n,r){if(typeof e==`function`)return Jp(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Zp(e,t,n,r);let i=typeof t==`function`?t:Bc(t,n,r),a=Array.isArray(e)?Xp(e,i):Xp([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function Xp(e,t){let n=yr(()=>[]);return qp(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Zp(e,t,n,r){let i=yr(()=>Object.keys(n)),a=yr(()=>({}));for(let o of i)a[o]=Yp(e,t,n[o],r);return a}function Qp(e,t={}){let{isStatic:n}=(0,p.useContext)(Id),r=()=>Cs(e)?e.get():e;if(n)return Yp(r);let i=Kp(r());return(0,p.useInsertionEffect)(()=>Vc(i,e,t),[i,JSON.stringify(t)]),i}function $p(e,t={}){return Qp(e,{type:`spring`,...t})}var em=Wp,tm={out:[.16,1,.3,1],in:[.4,0,1,1],exit:[.3,0,.8,.15],sheet:[.32,.72,0,1],snap:[.12,0,.08,1]},nm={micro:.14,exit:.14,base:.22,lg:.36,sheet:.5};function rm({size:e=22,children:t,...n}){return(0,j.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,...n,children:t})}var im=e=>(0,j.jsx)(rm,{...e,children:(0,j.jsx)(`path`,{d:`M15 6l-6 6 6 6`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})}),am=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M4 17a8 8 0 0 1 16 0`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`}),(0,j.jsx)(`path`,{d:`M12 17l4.5-5`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`}),(0,j.jsx)(`circle`,{cx:12,cy:17,r:1.6,fill:`currentColor`})]}),om=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`circle`,{cx:5,cy:7,r:1.3,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:5,cy:12,r:1.3,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:5,cy:17,r:1.3,fill:`currentColor`}),(0,j.jsx)(`path`,{d:`M9 7h11M9 12h11M9 17h7`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`})]}),sm=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M12 21s6.5-6 6.5-11A6.5 6.5 0 1 0 5.5 10c0 5 6.5 11 6.5 11Z`,stroke:`currentColor`,strokeWidth:1.7,strokeLinejoin:`round`}),(0,j.jsx)(`circle`,{cx:12,cy:9.5,r:2.4,stroke:`currentColor`,strokeWidth:1.7})]}),cm=e=>(0,j.jsxs)(rm,{...e,children:[(0,j.jsx)(`path`,{d:`M6.5 18C12 18 11 7.5 18 7`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeDasharray:`0.2 3.4`}),(0,j.jsx)(`circle`,{cx:6,cy:18,r:2.1,fill:`currentColor`}),(0,j.jsx)(`circle`,{cx:18,cy:7,r:2.1,fill:`none`,stroke:`currentColor`,strokeWidth:1.7})]}),lm=e=>(0,j.jsx)(rm,{...e,children:(0,j.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`})}),um=({className:e})=>(0,j.jsxs)(`svg`,{className:e,viewBox:`0 0 22 7`,"aria-hidden":`true`,focusable:`false`,children:[(0,j.jsx)(`rect`,{x:`0`,y:`0`,width:`7`,height:`7`,fill:`#e5484d`}),(0,j.jsx)(`line`,{x1:`8.4`,y1:`3.5`,x2:`13.6`,y2:`3.5`,stroke:`currentColor`,strokeWidth:1.3,strokeDasharray:`2 1.2`,opacity:.85}),(0,j.jsx)(`rect`,{x:`15.8`,y:`0.8`,width:`5.4`,height:`5.4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6})]}),dm=({size:e=15})=>(0,j.jsx)(rm,{size:e,children:(0,j.jsx)(`path`,{d:`M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5Z`,stroke:`currentColor`,strokeWidth:1.8,strokeLinejoin:`round`})}),fm=({size:e=15})=>(0,j.jsxs)(rm,{size:e,children:[(0,j.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4.2`,stroke:`currentColor`,strokeWidth:1.8}),(0,j.jsx)(`path`,{d:`M12 2.8v2.4M12 18.8v2.4M2.8 12h2.4M18.8 12h2.4M5.5 5.5l1.7 1.7M16.8 16.8l1.7 1.7M18.5 5.5l-1.7 1.7M7.2 16.8l-1.7 1.7`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`})]});function pm({title:e,eyebrow:t,onClose:n,children:r,tabs:i,footer:a,padded:o=!0,closeRef:s}){let[c,l]=(0,p.useState)(!0);(0,p.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let u=()=>l(!1);return(0,p.useEffect)(()=>{if(s)return s.current=u,()=>{s.current=null}},[s]),(0,j.jsx)(qd,{onExitComplete:n,children:c&&(0,j.jsx)(em.div,{className:`scrim`,onClick:u,initial:{opacity:0},animate:{opacity:1,transition:{duration:.18}},exit:{opacity:0,transition:{duration:nm.exit}},children:(0,j.jsxs)(em.div,{className:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":e,onClick:e=>e.stopPropagation(),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:nm.base,ease:tm.out}},exit:{opacity:0,scale:.97,transition:{duration:nm.exit,ease:tm.exit}},children:[(0,j.jsxs)(`div`,{className:`sheet-head`,children:[(0,j.jsxs)(`div`,{children:[t&&(0,j.jsx)(`div`,{className:`sheet-eyebrow`,children:t}),(0,j.jsx)(`span`,{className:`sheet-title`,children:e})]}),(0,j.jsx)(`button`,{type:`button`,className:`sheet-x`,onClick:u,"aria-label":`Close`,children:(0,j.jsx)(lm,{size:16})})]}),i,o?(0,j.jsx)(`div`,{className:`sheet-body`,children:r}):r,a&&(0,j.jsx)(`div`,{className:`sheet-foot`,children:a})]})},`scrim`)})}var mm=150,hm=3;function gm(e){if(e.length===0)return``;let t=`M ${e[0][0]},${e[0][1]}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]||e[n],i=e[n],a=e[n+1],o=e[n+2]||a;t+=` C ${i[0]+(a[0]-r[0])/6},${i[1]+(a[1]-r[1])/6} ${a[0]-(o[0]-i[0])/6},${a[1]-(o[1]-i[1])/6} ${a[0]},${a[1]}`}return t}function _m({data:e,color:t,fill:n,peak:r,height:i=40,top:a=5,className:o}){if(!e||e.length<2)return(0,j.jsx)(`svg`,{className:o,viewBox:`0 0 ${mm} ${i}`,preserveAspectRatio:`none`,"aria-hidden":`true`});let s=i,c=Math.max(...e),l=Math.min(...e),u=c*1.04,d=l*.96,f=u-d||1,p=t=>hm+t*((mm-hm*2)/(e.length-1)),m=e=>a+(s-a-hm)*(1-(e-d)/f),h=gm(e.map((e,t)=>[p(t),m(e)])),g=r?e.indexOf(c):-1;return(0,j.jsxs)(`svg`,{className:o,viewBox:`0 0 ${mm} ${s}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,j.jsx)(`line`,{x1:hm,y1:s-hm,x2:mm-hm,y2:s-hm,stroke:t,strokeOpacity:.18}),n&&(0,j.jsx)(`path`,{d:`${h} L ${p(e.length-1)},${s} L ${p(0)},${s} Z`,fill:t,fillOpacity:.12}),(0,j.jsx)(`path`,{d:h,fill:`none`,stroke:t,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`}),g>=0&&(0,j.jsx)(`circle`,{cx:p(g),cy:m(e[g]),r:2.6,fill:t})]})}var vm=3e3;function ym(){return(0,p.useEffect)(()=>{let e=!1,t=setInterval(async()=>{if(!(e||document.hidden)){e=!0;try{await _r.live(),window.location.reload()}catch{e=!1}}},vm);return()=>clearInterval(t)},[]),(0,j.jsxs)(`div`,{className:`sp-auth`,role:`alert`,children:[(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(`span`,{className:`sp-auth-mk`,children:`Siparu`})]}),(0,j.jsxs)(`div`,{className:`sp-auth-card`,children:[(0,j.jsx)(`span`,{className:`sp-auth-kick`,children:`Sign-in required`}),(0,j.jsx)(`p`,{className:`sp-auth-body`,children:`This Signal K server only shares boat data with signed-in users. Siparu reads everything through Signal K, so sign in there and come back - the dashboard picks up on its own.`}),(0,j.jsx)(`a`,{className:`sp-auth-cta`,href:`/admin/#/login`,target:`_blank`,rel:`noopener`,children:`Open Signal K sign-in`}),(0,j.jsx)(`p`,{className:`sp-auth-foot`,children:`Signed in but still locked out? Your account may not have enough access - ask whoever runs this Signal K server.`})]}),(0,j.jsxs)(`span`,{className:`sp-auth-wait`,children:[(0,j.jsx)(`span`,{className:`sp-auth-pulse`,"aria-hidden":`true`}),`Waiting for sign-in`]})]})}function bm({full:e=!1}){return(0,j.jsx)(`div`,{className:`sp-bload${e?` full`:``}`,role:`status`,"aria-label":`Loading`,children:(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(`span`,{className:`sp-bload-mk`,children:`Siparu`})]})})}function xm(e=3e4){let[t,n]=(0,p.useState)(()=>Date.now());return(0,p.useEffect)(()=>{let t=null,r=()=>{t===null&&(t=setInterval(()=>n(Date.now()),e))},i=()=>{t!==null&&(clearInterval(t),t=null)},a=()=>{document.hidden?i():(n(Date.now()),r())};return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[e]),t}var Sm=new Map;function Cm(e,t=6e4){let n=Sm.get(e);return!n||Date.now()-n.ts>t?null:n.value}function wm(e,t){Sm.set(e,{value:t,ts:Date.now()})}function Tm(e){return Sm.get(e)?.ts??null}var Em=3e4;function Dm(e,t=Em,n=[],r){let[i,a]=(0,p.useState)(()=>r?Cm(r):null),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(()=>!(r&&Cm(r)!==null)),[u,d]=(0,p.useState)(0),f=(0,p.useRef)(e),m=(0,p.useRef)(0),h=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{f.current=e},[e]),(0,p.useEffect)(()=>{let e=!1,n=null,i=async()=>{if(h.current)return;h.current=!0;let t=++m.current;try{let n=await f.current();if(e||t!==m.current)return;a(n),r&&wm(r,n),s(null)}catch(n){if(e||t!==m.current)return;s(n)}finally{h.current=!1,!e&&t===m.current&&l(!1)}},o=()=>{n===null&&(n=setInterval(i,t))},c=()=>{n!==null&&(clearInterval(n),n=null)},u=()=>{document.hidden?c():(i(),o())};return i(),document.hidden||o(),document.addEventListener(`visibilitychange`,u),()=>{e=!0,h.current=!1,c(),document.removeEventListener(`visibilitychange`,u)}},[t,u,...n]),{data:i,error:o,loading:c,refresh:()=>d(e=>e+1)}}var Om=`night`,km=`sp_theme`;function Am(e){return e===`night`||e===`day`}function jm(e){document.documentElement.dataset.theme=e}function Mm(){let e=localStorage.getItem(km);return Am(e)?e:Om}function Nm(e){localStorage.setItem(km,e),jm(e)}function Pm(){let e=Mm()===`night`?`day`:`night`;return Nm(e),e}function Fm(){jm(Mm())}function Im(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}:${n(t.getUTCSeconds())} UTC`}function Lm(){let t=xm(1e3),{data:n}=Dm(_r.live,6e4,[],`bridge:live`),[r,i]=(0,p.useState)(null),a=n?.lat??null,o=n?.lon??null;(0,p.useEffect)(()=>{if(a===null||o===null)return;let t=!0;return v(()=>import(`./tz-DxphYhHy.js`).then(t=>e(t.default,1)).then(e=>{t&&i(e.default(a,o))}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{}),()=>{t=!1}},[a===null?null:Math.round(a*10),o===null?null:Math.round(o*10)]);let s=Im(t);if(r)try{s=new Intl.DateTimeFormat(`en-GB`,{timeZone:r,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1,timeZoneName:`short`}).format(t)}catch{}return(0,j.jsx)(`span`,{className:`clk`,children:s})}function Rm({back:e,context:t,live:n,stale:r,clock:i}){let a=pt(),[o,s]=(0,p.useState)(()=>Mm());return(0,j.jsxs)(`header`,{className:`head`,children:[(0,j.jsxs)(`div`,{className:`mkwrap`,children:[e!=null&&e!==!1&&(0,j.jsx)(`button`,{type:`button`,className:`back`,onClick:()=>{a(typeof e==`string`?e:-1)},"aria-label":`Back`,children:(0,j.jsx)(im,{size:15})}),(0,j.jsxs)(`span`,{className:`sp-lockup`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(Fn,{to:`/`,className:`mk`,"aria-label":`Siparu home`,children:`Siparu`})]}),t&&(0,j.jsx)(`span`,{className:`ctx`,children:t})]}),(0,j.jsxs)(`div`,{className:`r`,children:[n&&(0,j.jsxs)(`span`,{className:`live${r?` is-stale`:``}`,children:[(0,j.jsx)(`span`,{className:`dot`}),r?`STALE`:`LIVE`]}),i&&(0,j.jsx)(Lm,{}),(0,j.jsx)(`button`,{type:`button`,className:`umenu-btn`,onClick:()=>s(Pm()),"aria-label":o===`night`?`Switch to day theme`:`Switch to night theme`,title:o===`night`?`Day theme`:`Night theme`,children:o===`night`?(0,j.jsx)(fm,{size:15}):(0,j.jsx)(dm,{size:15})})]})]})}var zm=[{to:`/`,end:!0,label:`Instruments`,Icon:am},{to:`/logbook`,end:!1,label:`Logbook`,Icon:om},{to:`/voyage`,end:!1,label:`Voyage`,Icon:cm},{to:`/map`,end:!1,label:`Map`,Icon:sm}];function Bm(){return(0,j.jsx)(`nav`,{className:`tabbar`,"aria-label":`Bridge tabs`,children:zm.map(({to:e,end:t,label:n,Icon:r})=>(0,j.jsx)(In,{to:e,end:t,replace:!0,className:({isActive:e})=>`tab${e?` on`:``}`,children:({isActive:e})=>(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(em.span,{className:`tind`,layoutId:`sp-tabind`,transition:{duration:.2,ease:tm.snap}}),(0,j.jsx)(r,{size:21}),(0,j.jsx)(`span`,{className:`tl`,children:n})]})},e))})}function Vm({live:e,stale:t}){let[n,r]=(0,p.useState)(()=>Mm());return(0,j.jsxs)(`nav`,{className:`sp-rail`,"aria-label":`Bridge navigation`,children:[(0,j.jsxs)(`span`,{className:`sp-lockup sp-brand`,children:[(0,j.jsx)(um,{className:`sp-glyph`}),(0,j.jsx)(Fn,{to:`/`,className:`mk`,"aria-label":`Siparu home`,children:`Siparu`})]}),(0,j.jsx)(`div`,{className:`rnav-list`,children:zm.map(({to:e,end:t,label:n,Icon:r})=>(0,j.jsxs)(In,{to:e,end:t,replace:!0,className:({isActive:e})=>`rnav${e?` on`:``}`,children:[(0,j.jsx)(r,{size:20}),(0,j.jsx)(`span`,{className:`rl`,children:n})]},e))}),(0,j.jsxs)(`div`,{className:`rfoot`,children:[e&&(0,j.jsxs)(`span`,{className:`live${t?` is-stale`:``}`,children:[(0,j.jsx)(`span`,{className:`dot`}),t?`STALE`:`LIVE`]}),(0,j.jsx)(Lm,{}),(0,j.jsx)(`button`,{type:`button`,className:`umenu-btn`,onClick:()=>r(Pm()),"aria-label":n===`night`?`Switch to day theme`:`Switch to night theme`,title:n===`night`?`Day theme`:`Night theme`,children:n===`night`?(0,j.jsx)(fm,{size:15}):(0,j.jsx)(dm,{size:15})})]})]})}function Hm(e){let[t,n]=(0,p.useState)(()=>typeof window<`u`&&window.matchMedia(e).matches);return(0,p.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return r({matches:t.matches}),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Um=`(min-width: 1000px)`,Wm=[`/`,`/logbook`,`/voyage`,`/map`],Gm=3,Km={enter:e=>({opacity:0,x:e}),center:e=>({opacity:1,x:0,transition:{duration:e===0?.16:nm.base,ease:tm.out}}),exit:e=>({opacity:0,x:-e,transition:{duration:nm.exit,ease:tm.exit}})};function qm(){let e=ut(),t=gt(),n=e.pathname===`/`||e.pathname===`/map`;(0,p.useEffect)(()=>{let e=setTimeout(()=>{v(()=>import(`./Logbook-CpMK73wj.js`),__vite__mapDeps([2,1,3]),import.meta.url).catch(()=>{}),v(()=>import(`./Voyage-DqTyveli.js`),__vite__mapDeps([4,1,5,6]),import.meta.url).catch(()=>{}),v(()=>import(`./Map-BmL-Ri3l.js`),__vite__mapDeps([7,1,3,5,6]),import.meta.url).catch(()=>{})},250);return()=>clearTimeout(e)},[]);let r=Wm.indexOf(e.pathname),[i,a]=(0,p.useState)({prev:r,curr:r});i.curr!==r&&a({prev:i.curr,curr:r});let o=i.curr===r?i.prev:i.curr,s=r===Gm||o===Gm?0:(r===o?0:r>o?1:-1)*10,c=xm(2e3),l=Tm(`bridge:live`),u=e.pathname===`/`&&l!==null&&c-l>1e4,d=Hm(Um);return(0,j.jsxs)(`div`,{className:`swiss sp-screen${d?` sp-wide`:``}`,children:[d?(0,j.jsx)(Vm,{live:n,stale:u}):(0,j.jsx)(Rm,{clock:!0,live:n,stale:u}),(0,j.jsx)(`main`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col`,children:(0,j.jsx)(p.Suspense,{fallback:(0,j.jsx)(bm,{}),children:(0,j.jsx)(qd,{mode:`wait`,initial:!1,custom:s,children:(0,j.jsx)(em.div,{className:`h-full min-h-0 flex flex-col`,custom:s,variants:Km,initial:`enter`,animate:`center`,exit:`exit`,children:t},e.pathname)})})}),!d&&(0,j.jsx)(Bm,{})]})}function Jm(e,t){return Number.isNaN(e)?`·`:t>0?e.toFixed(t):String(Math.round(e))}function Ym({value:e,digits:t=0,className:n,style:r}){let i=$p(e??0,{stiffness:140,damping:22,mass:.6}),[a,o]=(0,p.useState)(e===null?`·`:Jm(e,t));return(0,p.useEffect)(()=>{e!==null&&i.set(e)},[e,i]),Gp(i,`change`,n=>{e!==null&&o(Jm(n,t))}),(0,j.jsx)(`span`,{className:n,style:r,children:e===null?`·`:a})}var Xm=1.94384;function Zm(e){return e<1?0:e<=3?1:e<=6?2:e<=10?3:e<=16?4:e<=21?5:e<=27?6:e<=33?7:e<=40?8:e<=47?9:e<=55?10:e<=63?11:12}function Qm(e){return typeof e!=`number`||Number.isNaN(e)?null:Zm(e)}var $m=[`engine`,`generator`,`tanks`],eh={engine:`Engine`,generator:`Generator`,tanks:`Tanks`};function th(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var nh=36e5,rh=1e3,ih=1852*rh,ah=()=>({sub:!0,fmt:e=>`${(e-273.15).toFixed(1)} °C`,scale:e=>e-273.15,unit:`°C`}),oh=()=>({sub:!0,fmt:e=>`${(e/1e5).toFixed(1)} bar`,scale:e=>e/1e5,unit:`bar`}),sh=()=>({sub:!0,fmt:e=>`${Math.round(e*rh)} L`,scale:e=>e*rh,unit:`L`}),ch=e=>({sub:e,fmt:e=>`${Math.round(e*100)}%`,scale:e=>e*100,unit:`%`}),lh={revolutions:{sub:!0,fmt:e=>`${Math.round(e*60)} rpm`,scale:e=>e*60,unit:`rpm`},runTime:{sub:!0,fmt:e=>`${Math.round(e/3600)} h`,scale:e=>e/3600,unit:`h`},temperature:ah(),oilTemperature:ah(),coolantTemperature:ah(),intakeManifoldTemperature:ah(),exhaustTemperature:ah(),oilPressure:oh(),coolantPressure:oh(),boostPressure:oh(),currentLevel:ch(!1),"tanks.capacity":sh(),"tanks.currentVolume":sh(),"tanks.pressure":oh(),engineLoad:ch(!0),engineTorque:ch(!0),trimState:ch(!0),"fuel.rate":{sub:!0,fmt:e=>`${(e*nh).toFixed(1)} L/h`,scale:e=>e*nh,unit:`L/h`},"fuel.averageRate":{sub:!0,fmt:e=>`${(e*nh).toFixed(1)} L/h`,scale:e=>e*nh,unit:`L/h`},"fuel.used":{sub:!0,fmt:e=>`${Math.round(e*rh)} L`,scale:e=>e*rh,unit:`L`},"fuel.pressure":{sub:!0,fmt:e=>`${(e/1e5).toFixed(1)} bar`,scale:e=>e/1e5,unit:`bar`},"fuel.economy":{sub:!0,fmt:e=>e>0?`${(ih/e).toFixed(2)} L/nm`:`·`,scale:e=>e>0?ih/e:NaN,unit:`L/nm`}},uh={"fuel.rate":`Fuel rate`,"fuel.averageRate":`Fuel rate (average)`,"fuel.economy":`Fuel per mile`,"fuel.used":`Fuel used (since reset)`,"fuel.pressure":`Fuel pressure`,"fuel.type":`Fuel type`,"drive.type":`Drive type`,"transmission.oilTemperature":`Gearbox oil temperature`,"transmission.oilPressure":`Gearbox oil pressure`},dh={"fuel.economyRate":!0};function fh(e,t){let n=t.split(`.`),r=n[n.length-1];return e[n.slice(-2).join(`.`)]??e[`${n[0]}.${r}`]??e[r]}var ph={wasteWater:`Grey water`};function mh(e){return th(e).toLowerCase()}function hh(e){if(fh(dh,e))return null;let t=e.split(`.`),n=t[t.length-1],r=fh(lh,e),i=r&&!r.sub?null:fh(uh,e)??th(n);return e.startsWith(`propulsion.`)&&t.length>=3?{tab:`engine`,label:th(t[1]),sub:i}:e.startsWith(`electrical.generators.`)&&t.length>=4?{tab:`generator`,label:`Generator ${mh(t[2])}`,sub:i}:e.startsWith(`tanks.`)&&t.length>=4?{tab:`tanks`,label:`${ph[t[1]]??th(t[1])} ${mh(t[2])}`,sub:i}:null}function gh(e,t){if(typeof t==`string`)return t;if(!Number.isFinite(t))return`·`;let n=fh(lh,e);return n?n.fmt(t):Number.isInteger(t)?String(t):t.toFixed(1)}function _h(e){let t=[],n=[],r={};for(let i of e){let e=i.sub??i.label;t.includes(i.label)||t.push(i.label),e in r||(r[e]={},n.push(e)),r[e][i.label]=i}return{cols:t,rows:n.map(e=>({sub:e,cells:r[e]}))}}function vh(e){let t={engine:[],generator:[],tanks:[]};for(let[n,r]of Object.entries(e?.paths??{})){let i=hh(n);if(!i)continue;let a=e?.path_ages?.[n];t[i.tab].push({path:n,label:i.label,sub:i.sub,value:gh(n,r),ageS:typeof a==`number`?a:null})}return $m.filter(e=>t[e].length>0).map(e=>({key:e,name:eh[e],gauges:t[e]}))}function yh(e){let t=Math.max(0,Math.floor(e));return t<60?{value:t,unit:`s`}:t<3600?{value:Math.floor(t/60),unit:`min`}:t<86400?{value:Math.floor(t/3600),unit:`h`}:{value:Math.floor(t/86400),unit:`d`}}var bh=90;function xh(e){let{value:t,unit:n}=yh(e);return`${t} ${n.toUpperCase()} AGO`}function Sh(e){let t=e.toLowerCase();return t===`port`?`port`:t===`starboard`||t===`stbd`?`stbd`:t===`center`||t===`centre`?`center`:``}function Ch(e){return/^starboard$/i.test(e)?`Stbd`:e.replace(/^Generator /i,`Gen `)}function wh({g:e}){if(!e)return(0,j.jsx)(`div`,{className:`sm-cell sm-empty`,"aria-hidden":`true`});let t=e.ageS!==null&&e.ageS>=bh;return(0,j.jsxs)(`div`,{className:`sm-cell${t?` quiet`:``}`,children:[(0,j.jsx)(`span`,{className:`sm-v`,children:e.value}),t&&(0,j.jsx)(`span`,{className:`sm-age`,children:xh(e.ageS)})]})}function Th({m:e}){return(0,j.jsxs)(`div`,{className:`sm-matrix`,style:{"--sm-cols":e.cols.length},children:[(0,j.jsx)(`div`,{className:`sm-corner`,"aria-hidden":`true`}),e.cols.map(e=>{let t=Sh(e);return(0,j.jsx)(`div`,{className:`sm-head${t?` sm-${t}`:``}`,children:Ch(e)},e)}),e.rows.map(t=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(`div`,{className:`sm-rl`,children:t.sub}),e.cols.map(e=>(0,j.jsx)(wh,{g:t.cells[e]},e))]},t.sub))]})}function Eh({g:e}){let t=parseFloat(e.value),n=Number.isFinite(t),r=n?Math.max(0,Math.min(100,t)):0,i=n&&e.path.includes(`.fuel.`)&&r<20;return(0,j.jsxs)(`div`,{className:`tk${e.ageS!==null&&e.ageS>=bh?` quiet`:``}${i?` low`:``}`,children:[(0,j.jsx)(`div`,{className:`tk-l`,children:e.label}),(0,j.jsx)(`div`,{className:`tk-bar`,children:(0,j.jsx)(`i`,{style:{width:`${r}%`}})}),(0,j.jsx)(`div`,{className:`tk-pct`,children:e.value})]})}function Dh({g:e}){let t=e.ageS!==null&&e.ageS>=bh;return(0,j.jsxs)(`div`,{className:`c sy-c${t?` quiet`:``}`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[e.label,e.sub!==null&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsx)(`span`,{className:`sub`,children:e.sub})]})]}),(0,j.jsx)(`div`,{className:`n sy-n`,children:e.value}),t&&(0,j.jsx)(`div`,{className:`sy-age`,children:xh(e.ageS)})]})}function Oh({snap:e,tab:t}){let n=vh(e).find(e=>e.key===t);if(!n)return(0,j.jsx)(`div`,{className:`sy-wrap`,children:(0,j.jsx)(`div`,{className:`sy-none`,children:`No readings from this system right now.`})});if(n.key===`tanks`){let e=n.gauges.filter(e=>e.sub===null),t=n.gauges.filter(e=>e.sub!==null);return(0,j.jsxs)(`div`,{className:`sy-wrap`,children:[e.length>0&&(0,j.jsx)(`div`,{className:`tk-list`,children:e.map(e=>(0,j.jsx)(Eh,{g:e},e.path))}),t.length>0&&(0,j.jsx)(`div`,{className:`sy-grid`,children:t.map(e=>(0,j.jsx)(Dh,{g:e},e.path))})]})}return(0,j.jsx)(`div`,{className:`sy-wrap`,children:(0,j.jsx)(Th,{m:_h(n.gauges)})})}var kh=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`},Ah=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}`},jh=e=>e==null?null:(e*180/Math.PI+360)%360,Mh=e=>e==null?null:e*Xm,Nh=e=>{let t=Mh(e);return t===null?null:t>=.4?t:0},Ph=e=>e==null?null:e-273.15,Fh=e=>e==null?null:e/100,Ih=(e,t=1,n=``)=>e==null?`·`:`${e.toFixed(t)}${n}`,Lh=Qm,Rh=(e,t,n)=>{if(e==null||Number.isNaN(e))return`·`;let r=e<0?t[1]:t[0],i=Math.abs(e),a=Math.floor(i),o=(i-a)*60;return`${String(a).padStart(n,`0`)}°${o.toFixed(3).padStart(6,`0`)}' ${r}`},zh=e=>{let[t,n,r]=e.split(`-`).map(Number);return Date.UTC(t,n-1,r,0,0,0,0)},Bh=(e=new Date)=>{let t=e=>String(e).padStart(2,`0`);return`${e.getUTCFullYear()}-${t(e.getUTCMonth()+1)}-${t(e.getUTCDate())}`},Vh=[`environment.depth.belowTransducer`,`environment.depth.belowKeel`,`environment.depth.belowSurface`];function Hh(e,t){if(e!==null||!t)return{kind:`none`};let n=0;for(let e of Vh){let r=t[e];r&&r.last_seen_ts>n&&(n=r.last_seen_ts)}return n===0?{kind:`no-sensor`}:{kind:`quiet`,lastTs:n}}var Uh=864e5;function Wh(e){switch(e){case`belowTransducer`:return`BELOW TRANSDUCER`;case`belowKeel`:return`BELOW KEEL`;case`belowSurface`:return`BELOW SURFACE`;default:return`DATUM UNKNOWN`}}function Gh(e,t){switch(e.kind){case`none`:return null;case`no-sensor`:return`NO SENSOR
21
+ NORMAL`;case`quiet`:{let n=t-e.lastTs;return n>=Uh?`QUIET · ${Math.floor(n/Uh)}d`:`QUIET · ${Ah(e.lastTs)}`}}}var Kh=2e3,qh=6e4;function Jh(e){return e.sogKn!==null||(e.snap?.nav_state??null)!==null||(e.snap?.lat??null)!==null||(e.snap?.lon??null)!==null||e.cogDeg!==null||e.hdgTrue!==null||e.twsKn!==null||e.twdDeg!==null||e.awaDeg!==null||e.baroHPa!==null||e.airC!==null||e.waterC!==null||e.depth!==null}function Yh(e,t){if(e.length<=t)return e;let n=e.length/t,r=[];for(let i=0;i<t;i++)r.push(e[Math.floor(i*n)]);return r}function Xh(){let{data:e}=Dm(_r.live,Kh,[],`bridge:live`),{data:t}=Dm(()=>_r.tools.baroTrend(3),qh,[],`bridge:baro`),{data:n}=Dm(_r.health,qh,[],`bridge:health`),r=xm(1e3),[i,a]=(0,p.useState)(6),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)([]);(0,p.useEffect)(()=>{let e=!1,t=async()=>{try{let t=Date.now()-i*36e5,n=await _r.logbook.snapshots({from:t,limit:5e3,order:`asc`}),r=null,a=[];for(let e of n){let t=Mh(e.wind_gust??e.wind_speed_true);t!==null&&(a.push(t),(r===null||t>r.kn)&&(r={kn:t,ts:e.ts}))}e||(s(r),l(Yh(a,28)))}catch{}},n=null,r=()=>{n===null&&(n=setInterval(t,5*6e4))},a=()=>{n!==null&&(clearInterval(n),n=null)},o=()=>{document.hidden?a():(t(),r())};return t(),document.hidden||r(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[i]);let u=e?.ts?Math.max(0,Math.round((r-e.ts)/1e3)):null,d=e?.field_ages?.lat,f=u===null?null:d===void 0?u:u+d,m=e?.lat!=null&&e?.lon!=null,h=m&&f!==null&&f<30,g=jh(e?.heading_true),_=Nh(e?.sog),v=_===null?null:jh(e?.cog),y=Mh(e?.wind_speed_true),b=jh(e?.wind_direction_true),x=jh(e?.wind_angle_apparent),S=Lh(y);(0,p.useEffect)(()=>{if(y===null||!e?.ts)return;let t=Date.now()-i*36e5;e.ts<t||s(t=>!t||y>t.kn?{kn:y,ts:e.ts}:t)},[y,e?.ts,i]);let C=Fh(e?.air_pressure_pa)??t?.current_hpa??null,w=t?.delta_3h_hpa??null,T=Yh((t?.series??[]).map(e=>e.value).filter(e=>e!==null).map(e=>e>2e3?e/100:e),28),E=Ph(e?.air_temp_k),ee=Ph(e?.water_temp_k),te=e?.depth??null,ne=Hh(te,n?.paths),re=e?.nav_state?.toUpperCase()||`·`,D=o&&r-o.ts<=i*36e5?o:null,ie=(()=>{let e=new Date(r),t=e=>String(e).padStart(2,`0`);return`${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`})();return{snap:e??null,now:r,ageSec:f,live:h,hasFix:m,hdgTrue:g,sogKn:_,cogDeg:v,twsKn:y,twdDeg:b,awaDeg:x,bft:S,baroHPa:C,baroDelta:w,airC:E,waterC:ee,depth:te,depthDiag:ne,sealing:n?.sealing??null,navState:re,utcClock:ie,gustMax:D,gustHours:i,setGustHours:a,gustSeries:c,baroSeries:T}}var Zh=e(u(),1),Qh=36e5,$h=864e5,eg=[{key:`24h`,label:`24h`,span:24*Qh,buffer:3*$h},{key:`7d`,label:`7d`,span:7*$h,buffer:21*$h},{key:`30d`,label:`30d`,span:30*$h,buffer:90*$h}];function tg(e){if(e.length===0)return``;let t=`M ${e[0][0]},${e[0][1]}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]||e[n],i=e[n],a=e[n+1],o=e[n+2]||a;t+=` C ${i[0]+(a[0]-r[0])/6},${i[1]+(a[1]-r[1])/6} ${a[0]-(o[0]-i[0])/6},${a[1]-(o[1]-i[1])/6} ${a[0]},${a[1]}`}return t}var ng=340,rg=190,ig=34,ag=10,og=12,sg=22,cg=ng-ig-ag,lg=rg-og-sg;function ug(e,t){let n=new Date(e);return t<=2*$h?n.toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`})}function dg({onClose:e,current:t,delta:n}){let[r,i]=(0,p.useState)(`24h`),[a,o]=(0,p.useState)([]),[s,c]=(0,p.useState)(!0),[l,u]=(0,p.useState)(null),[d,f]=(0,p.useState)(()=>Date.now()),[m,h]=(0,p.useState)(!1),g=(0,p.useRef)({from:0,to:0}),_=eg.find(e=>e.key===r);(0,p.useEffect)(()=>{let e=!1;c(!0),u(null);let t=Date.now(),n=t-_.buffer;return g.current={from:n,to:t},(async()=>{try{let r=await _r.tools.baroSeries({from:n,to:t,points:160});if(e)return;o(r),f(t)}catch(t){e||u(t.message||`Load failed`)}finally{e||c(!1)}})(),()=>{e=!0}},[r,_.buffer]);let v=(0,p.useMemo)(()=>{let e=a.length?a[0].ts:g.current.from,t=g.current.to;return{minEnd:Math.min(t,e+_.span),maxEnd:t}},[a,_.span]),y=d-_.span,b=(0,p.useMemo)(()=>{let e=a.filter(e=>e.ts>=y&&e.ts<=d),t=a.findIndex(e=>e.ts>=y),n=t>0?t-1:0,r=a.length-1;for(let e=a.length-1;e>=0;e--)if(a[e].ts<=d){r=Math.min(a.length-1,e+1);break}return e.length?a.slice(n,r+1):[]},[a,y,d]),x=(0,p.useMemo)(()=>{if(!b.length)return{lo:1e3,hi:1020};let e=Math.min(...b.map(e=>e.hpa)),t=Math.max(...b.map(e=>e.hpa)),n=(e+t)/2,r=Math.max((t-e)/2+1,3);return{lo:Math.floor(n-r),hi:Math.ceil(n+r)}},[b]),S=(0,p.useRef)(x),C=m?S.current:x,w=e=>ig+(e-y)/_.span*cg,T=e=>og+lg*(1-(e-C.lo)/(C.hi-C.lo||1)),E=tg(b.map(e=>[w(e.ts),T(e.hpa)])),ee=E?`${E} L ${w(b[b.length-1].ts)},168 L ${w(b[0].ts)},168 Z`:``,te=[0,.5,1].map(e=>Math.round(C.hi-e*(C.hi-C.lo))),ne=[0,.5,1].map(e=>y+e*_.span),re=(0,p.useRef)(null),D=(0,p.useRef)(null),ie=(0,p.useRef)(null),ae=(0,p.useRef)(0),oe=()=>{if(ie.current=null,!D.current)return;let e=-((ae.current-D.current.x)/D.current.w)*_.span;f(Math.max(v.minEnd,Math.min(v.maxEnd,D.current.end+e)))},se=e=>{let t=re.current?.clientWidth??ng;D.current={x:e.clientX,end:d,w:t},ae.current=e.clientX,S.current=x,h(!0),re.current?.setPointerCapture(e.pointerId)},O=e=>{D.current&&(ae.current=e.clientX,ie.current??=requestAnimationFrame(oe))},k=e=>{ie.current!=null&&cancelAnimationFrame(ie.current),oe(),D.current=null,h(!1),re.current?.releasePointerCapture(e.pointerId)};(0,p.useEffect)(()=>()=>{ie.current!=null&&cancelAnimationFrame(ie.current)},[]);let ce=n===null?``:n<-.1?`▼`:n>.1?`▲`:`▬`,le=d>=v.maxEnd-6e4,ue=document.querySelector(`.swiss.sp-screen`)??document.body;return(0,Zh.createPortal)((0,j.jsx)(pm,{title:`Barometer`,eyebrow:`hPa · pressure`,onClose:e,children:(0,j.jsxs)(`div`,{className:`baro-pop`,children:[(0,j.jsxs)(`div`,{className:`bp-head`,children:[(0,j.jsxs)(`div`,{className:`bp-now`,children:[t===null?`·`:Math.round(t),(0,j.jsx)(`span`,{className:`bp-u`,children:`hPa`})]}),n!==null&&(0,j.jsxs)(`div`,{className:`bp-delta`,children:[ce,` `,Math.abs(n).toFixed(1),` / 3h`]}),(0,j.jsx)(`div`,{className:`seg bp-seg`,children:eg.map(e=>(0,j.jsx)(`button`,{type:`button`,className:r===e.key?`on`:``,onClick:()=>i(e.key),children:e.label},e.key))})]}),l?(0,j.jsx)(`div`,{className:`lb-err`,children:l}):s?(0,j.jsx)(`div`,{className:`bp-msg`,children:`Loading…`}):b.length<2?(0,j.jsx)(`div`,{className:`bp-msg`,children:`No barometric data for this range.`}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`svg`,{ref:re,className:`bp-chart`,viewBox:`0 0 ${ng} ${rg}`,onPointerDown:se,onPointerMove:O,onPointerUp:k,onPointerCancel:k,children:[(0,j.jsx)(`defs`,{children:(0,j.jsxs)(`linearGradient`,{id:`bp-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,j.jsx)(`stop`,{offset:`0%`,style:{stopColor:`var(--accent)`,stopOpacity:.3}}),(0,j.jsx)(`stop`,{offset:`100%`,style:{stopColor:`var(--accent)`,stopOpacity:0}})]})}),te.map(e=>(0,j.jsxs)(`g`,{children:[(0,j.jsx)(`line`,{x1:ig,x2:ng-ag,y1:T(e),y2:T(e),className:`bp-grid`}),(0,j.jsx)(`text`,{x:ig-6,y:T(e)+3,className:`bp-ylab`,children:e})]},e)),(0,j.jsx)(`path`,{d:ee,className:`bp-area`,fill:`url(#bp-grad)`}),(0,j.jsx)(`path`,{d:E,className:`bp-line`,vectorEffect:`non-scaling-stroke`}),le&&b.length>0&&(0,j.jsx)(`circle`,{cx:w(b[b.length-1].ts),cy:T(b[b.length-1].hpa),r:3,className:`bp-dot`}),ne.map((e,t)=>(0,j.jsx)(`text`,{x:t===0?ig:t===2?ng-ag:182,y:rg-6,className:`bp-xlab`,textAnchor:t===0?`start`:t===2?`end`:`middle`,children:ug(e,_.span)},e))]})})]})}),ue)}function fg(e){return!e||e.mode!==`blocked`?null:{title:`Nothing is going ashore`,detail:`She is still recording her own history, but no report is leaving this boat: ${e.reason??`she could not seal this report to anybody`}.`}}function pg(e){if(!e||e.mode!==`sealed`)return null;let t=e.screens_skipped??[],n=e.screens_rejected??[],r=e.screens_pinned===!1;return!r&&t.length===0&&n.length===0?null:{unapproved:t,unwrapped:n,unpinned:r}}var mg=`siparu.app/app`;function hg(e){return Math.max(0,Math.round((new Date(e).getTime()-Date.now())/6e4))}function gg(e){let{value:t,unit:n}=yh((Date.now()-e)/1e3);return`${t}${n===`s`?`s`:` ${n}`} ago`}function _g(e){return e?e.rejected||e.failures>0?e.lastError??`Not reaching Siparu.`:e.lastSentTs?`Sending · last frame ${gg(e.lastSentTs)}`:`Waiting to send the first frame.`:`Checking the link…`}function vg({sealing:e}){let[t,n]=(0,p.useState)(!1),[r,i]=(0,p.useState)(!1),[a,o]=(0,p.useState)(!1),{data:s,refresh:c}=Dm(()=>_r.pair.status(),t?5e3:3e4,[]);(0,p.useEffect)(()=>{let e=s?.state;n(e===`showing_code`||e===`awaiting_approval`)},[s?.state]);async function l(e){i(!0);try{await e()}catch{}finally{i(!1),o(!1),c()}}let u=fg(e),d=u?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:u.title}),(0,j.jsx)(`div`,{className:`s`,children:u.detail})]})}):null,f=e?.screens??[],m=f.length>0?(0,j.jsx)(`div`,{className:`pair`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Screens she seals to`}),(0,j.jsx)(`div`,{className:`fps`,children:f.map((e,t)=>(0,j.jsx)(`span`,{className:`fp`,children:e},`${e}-${t}`))}),(0,j.jsx)(`div`,{className:`s`,children:`Every screen that can open her reports has a line here. If the line on your phone is missing, she is not sealing to it; if a line here is not one of yours, it can read her.`})]})}):null,h=pg(e),g=h?(0,j.jsxs)(j.Fragment,{children:[h.unapproved.length>0?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`She will not seal to these screens`}),(0,j.jsx)(`div`,{className:`s`,children:`Nothing she trusts has vouched for them, so they receive nothing at all. A line here you did not add is somebody else's key on your list: remove it from the boat's page ashore, and if you cannot account for it, pair her again from this screen.`}),(0,j.jsx)(`div`,{className:`fps`,children:h.unapproved.map(e=>(0,j.jsxs)(`span`,{className:`fp`,children:[e.kid,` · `,e.reason]},e.kid))})]})}):null,h.unwrapped.length>0?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Authorised, and still receiving nothing`}),(0,j.jsx)(`div`,{className:`s`,children:`These screens are on her list and she could not wrap her last report to them. From ashore that looks exactly like a boat gone quiet, which is why it is named here.`}),(0,j.jsx)(`div`,{className:`fps`,children:h.unwrapped.map(e=>(0,j.jsxs)(`span`,{className:`fp`,children:[e.kid,` · `,e.reason]},e.kid))})]})}):null,h.unpinned?(0,j.jsx)(`div`,{className:`pair`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Her screens are not pinned`}),(0,j.jsx)(`div`,{className:`s`,children:`She was paired before screens could vouch for one another, so she checks that a key is well formed and nothing about who put it on her list. She still seals every report. Pair her again from this screen to pin the first one, and every later screen will have to chain to it.`})]})}):null]}):null;if(!s)return(0,j.jsxs)(j.Fragment,{children:[d,m,g]});let _=(e,t,n)=>(0,j.jsx)(`button`,{className:`pbtn${n?` ${n}`:``}`,disabled:r,onClick:t,children:e}),v=s.pairing_locked===!0;return(0,j.jsxs)(j.Fragment,{children:[d,s.security_off?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:v?`Signal K security is off · pairing is locked`:`Signal K security is off`}),(0,j.jsx)(`div`,{className:`s`,children:v?`Anyone on this network could link this boat to another account or cut her loose, so pairing, unpairing and log edits stay locked. Add an admin user in Signal K - or, on a network you trust, accept the risk in the plugin settings.`:`Anyone who can reach this network can link this boat to their account, and the only sign here would be a linked account you do not recognise. Add an admin user in Signal K.`})]})}):null,s.revoke_pending?(0,j.jsx)(`div`,{className:`pair warn`,children:(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Still revoking the old key`}),(0,j.jsx)(`div`,{className:`s`,children:`Remote viewing is off on this boat, but Siparu could not be reached to revoke its copy of the key. It will keep trying whenever the boat is online.`})]})}):null,(()=>{switch(s.state){case`idle`:case`expired`:return(0,j.jsxs)(`div`,{className:`pair`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing`}),(0,j.jsx)(`div`,{className:`s`,children:s.state===`expired`?`The code expired. Nothing was linked.`:`Off - this boat is not linked to an account.`})]}),!v&&_(s.state===`expired`?`New code`:`Turn on`,()=>l(_r.pair.start))]});case`showing_code`:return(0,j.jsxs)(`div`,{className:`pair`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · waiting`}),(0,j.jsx)(`div`,{className:`code`,children:s.userCode}),(0,j.jsxs)(`div`,{className:`s`,children:[`Enter this at `,(0,j.jsx)(`b`,{children:mg}),` · `,hg(s.expiresAt),` min left`]})]}),_(`Cancel`,()=>l(_r.pair.deny),`ghost`)]});case`awaiting_approval`:return(0,j.jsxs)(`div`,{className:`pair asking`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Someone wants to pair`}),(0,j.jsx)(`div`,{className:`who`,children:s.email??`an account we cannot name`}),s.device?(0,j.jsx)(`div`,{className:`fps`,children:(0,j.jsx)(`span`,{className:`fp`,children:s.device.fingerprint})}):null,(0,j.jsx)(`div`,{className:`s`,children:s.device?`Approve only if this is you, and only if that line matches the one on your phone. They will see where this boat is.`:`Approve only if this is you. They will see where this boat is.`})]}),(0,j.jsxs)(`div`,{className:`acts`,children:[_(`Deny`,()=>l(_r.pair.deny),`ghost`),!v&&_(`Approve`,()=>l(_r.pair.approve),`accent`)]})]});case`paired`:return(0,j.jsxs)(`div`,{className:`pair${s.uplink?.rejected?` err`:``}`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · on`}),(0,j.jsx)(`div`,{className:`who`,children:s.email??`linked account`}),!a&&!u&&(0,j.jsx)(`div`,{className:`s`,children:_g(s.uplink)})]}),v?null:a?(0,j.jsxs)(`div`,{className:`acts`,children:[_(`Keep`,()=>o(!1),`ghost`),_(`Unlink`,()=>l(_r.pair.reset),`accent`)]}):(0,j.jsxs)(`div`,{className:`acts`,children:[_(`Pair again`,()=>l(_r.pair.start),`ghost`),_(`Turn off`,()=>o(!0),`ghost`)]})]});case`error`:return(0,j.jsxs)(`div`,{className:`pair err`,children:[(0,j.jsxs)(`div`,{className:`pl`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Remote viewing · error`}),(0,j.jsx)(`div`,{className:`s`,children:s.message})]}),!v&&(0,j.jsxs)(`div`,{className:`acts`,children:[_(`Dismiss`,()=>l(_r.pair.reset),`ghost`),_(`Retry`,()=>l(_r.pair.start))]})]})}})(),m,g]})}var yg=1e-6;function bg(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function xg(e,t){let n=[],r=(e,t,r,i)=>n.push({key:e,label:t,sub:r,value:i}),i=(e.end_ts??t)-e.start_ts;i>=0&&r(`duration`,`Duration`,e.end_ts===null?`So far`:`Total`,bg(i)),e.hours_underway>yg&&r(`underway`,`Under way`,`Moving`,bg(e.hours_underway*36e5)),r(`distance`,`Distance`,`nm`,e.distance_nm.toFixed(1)),e.avg_sog_kn!==null&&r(`avgSpeed`,`Average speed`,`kn`,e.avg_sog_kn.toFixed(1)),e.max_sog_kn!==null&&r(`maxSpeed`,`Max speed`,`kn`,e.max_sog_kn.toFixed(1));let a=e.fuel_used_l;return a!==null&&Number.isFinite(a)&&(r(`fuelUsed`,`Fuel used`,`L`,a.toFixed(1)),e.hours_underway>yg&&r(`fuelPerHour`,`Fuel per hour`,`L/h`,(a/e.hours_underway).toFixed(1)),e.distance_nm>yg&&r(`fuelPerMile`,`Fuel per mile`,`L/nm`,(a/e.distance_nm).toFixed(2))),n}function Sg({voyage:e,now:t}){if(e===null)return null;let n=xg(e,t);return n.length===0?null:(0,j.jsx)(`div`,{className:`grid`,children:(0,j.jsx)(`div`,{className:`matrix`,children:n.map(e=>(0,j.jsxs)(`div`,{className:`c`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[e.label,` · `,(0,j.jsx)(`span`,{className:`sub`,children:e.sub})]}),(0,j.jsx)(`div`,{className:`n`,children:e.value})]},e.key))})})}var Cg=[1,6,12,24],wg=`(min-width: 1000px)`,Tg=6e4;function Eg(e){return e===null?`·`:String(Math.round(e))}function Dg(e){return e===null?`·`:`${Math.round(Math.abs(e))}°${e<0?`P`:`S`}`}function Og(e){if(e===null)return{txt:`·`,tone:``};let t=e<-.1?`▼`:e>.1?`▲`:`▬`,n=e<=-4?`alarm`:e<=-1.6?`warn`:e>=1?`ok`:``;return{txt:`${t} ${Math.abs(e).toFixed(1)} / 3h`,tone:n}}function kg(e){return e.charAt(0)+e.slice(1).toLowerCase()}var Ag={UNDERWAY:`Under­way`,ANCHORED:`An­chored`,MOORED:`Moored`};function jg(e){return e===`·`?`·`:Ag[e]??kg(e)}function Mg({d:e,onBaro:t}){let n=e.snap===null,r=Og(e.baroDelta),i=e.snap?.lat??null,a=e.snap?.lon??null,o=e=>n||e!==null,s=[];o(e.sogKn)&&s.push((0,j.jsxs)(`div`,{className:`c c-sog`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`SOG · `,(0,j.jsx)(`span`,{className:`sub`,children:`Knots`})]}),n?(0,j.jsx)(`div`,{className:`n skel`,children:`8.4`}):(0,j.jsx)(Ym,{className:`n`,value:e.sogKn,digits:1})]},`sog`)),(o(e.snap?.nav_state??null)||o(i))&&s.push((0,j.jsxs)(`div`,{className:`c c-state`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Nav state`}),(0,j.jsx)(`div`,{className:`s`,children:jg(e.navState)}),(0,j.jsx)(`div`,{className:`meta`,children:e.snap===null||!e.hasFix?`AWAITING FIX`:e.live?`FIX ${e.ageSec}s · WGS84`:`STALE ${e.ageSec}s`})]},`state`)),o(i)&&o(a)&&s.push((0,j.jsxs)(`div`,{className:`c c-pos`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Position · `,(0,j.jsx)(`span`,{className:`sub`,children:`WGS84`})]}),(0,j.jsxs)(`div`,{className:`coords`,children:[Rh(i,[`N`,`S`],2),(0,j.jsx)(`br`,{}),Rh(a,[`E`,`W`],3)]})]},`pos`));let c=[];return o(e.cogDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-cog`,children:[(0,j.jsx)(`div`,{className:`t`,children:`COG`}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Eg(e.cogDeg),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`cog`)),o(e.hdgTrue)&&c.push((0,j.jsxs)(`div`,{className:`c c-hdg`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`HDG · `,(0,j.jsx)(`span`,{className:`sub`,children:`True`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Eg(e.hdgTrue),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`hdg`)),o(e.twsKn)&&c.push((0,j.jsxs)(`div`,{className:`c c-windtrue`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Wind true`,e.bft!==null&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsxs)(`span`,{className:`sub`,children:[`Bft `,e.bft]})]})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.twsKn===null?`·`:e.twsKn.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`kn`})]})]},`windtrue`)),o(e.twdDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-windfrom`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Wind from · `,(0,j.jsx)(`span`,{className:`sub`,children:`True`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[Eg(e.twdDeg),(0,j.jsx)(`span`,{className:`u`,children:`°`})]})]},`windfrom`)),o(e.twsKn)&&c.push((0,j.jsxs)(`div`,{className:`c c-gust`,children:[(0,j.jsx)(`div`,{className:`t`,children:`Gust`}),(0,j.jsx)(_m,{className:`spark`,data:e.gustSeries,color:`var(--spark-gust)`,fill:!0,peak:!0,height:42}),(0,j.jsx)(`div`,{className:`lab`,children:e.gustMax?(0,j.jsxs)(j.Fragment,{children:[`GUST `,(0,j.jsxs)(`b`,{children:[e.gustMax.kn.toFixed(1),` kn`]}),` · `,Ah(e.gustMax.ts)]}):`GUST -`}),(0,j.jsx)(`div`,{className:`gustseg`,role:`group`,"aria-label":`Gust window`,children:Cg.map(t=>(0,j.jsxs)(`button`,{className:e.gustHours===t?`on`:``,onClick:()=>e.setGustHours(t),children:[t,`h`]},t))})]},`gust`)),o(e.awaDeg)&&c.push((0,j.jsxs)(`div`,{className:`c c-awa`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`AWA · `,(0,j.jsx)(`span`,{className:`sub`,children:`Apparent`})]}),(0,j.jsx)(`div`,{className:`n${n?` skel`:``}`,children:Dg(e.awaDeg)})]},`awa`)),o(e.baroHPa)&&c.push((0,j.jsxs)(`div`,{className:`c c-baro tap`,onClick:t,role:`button`,"aria-label":`Barometer detail`,children:[(0,j.jsxs)(`div`,{className:`left`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Baro · `,(0,j.jsx)(`span`,{className:`sub`,children:`hPa`})]}),(0,j.jsx)(`div`,{className:`n${n?` skel`:``}`,children:e.baroHPa===null?`·`:Math.round(e.baroHPa)}),(0,j.jsx)(`div`,{className:`trend ${r.tone}`,children:r.txt})]}),(0,j.jsxs)(`div`,{className:`sparkwrap`,children:[(0,j.jsx)(_m,{className:`spark-b`,data:e.baroSeries,color:`var(--spark-baro)`,height:38,top:4}),(0,j.jsx)(`div`,{className:`lab`,children:`3-hour trend · tap ⤢`})]})]},`baro`)),o(e.airC)&&c.push((0,j.jsxs)(`div`,{className:`c c-air`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Air · `,(0,j.jsx)(`span`,{className:`sub`,children:`Outside`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.airC===null?`·`:e.airC.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`°C`})]})]},`air`)),o(e.waterC)&&c.push((0,j.jsxs)(`div`,{className:`c c-sea`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Sea · `,(0,j.jsx)(`span`,{className:`sub`,children:`Water`})]}),(0,j.jsxs)(`div`,{className:`n${n?` skel`:``}`,children:[e.waterC===null?`·`:e.waterC.toFixed(1),(0,j.jsx)(`span`,{className:`u`,children:`°C`})]})]},`sea`)),o(e.depth)&&c.push((0,j.jsxs)(`div`,{className:`c c-depth`,children:[(0,j.jsxs)(`div`,{className:`t`,children:[`Depth · `,(0,j.jsx)(`span`,{className:`sub`,children:`m`})]}),n?(0,j.jsx)(`div`,{className:`n skel`,children:`32.4`}):(0,j.jsx)(Ym,{className:`n`,value:e.depth,digits:1}),!n&&Gh(e.depthDiag,e.now)&&(0,j.jsx)(`div`,{className:`meta`,children:Gh(e.depthDiag,e.now)}),!n&&e.depth!==null&&(0,j.jsx)(`div`,{className:`meta`,children:Wh(e.snap?.depth_datum)})]},`depth`)),(0,j.jsxs)(`div`,{className:`grid`,children:[s.length>0&&(0,j.jsx)(`div`,{className:`band`,children:s}),c.length>0&&(0,j.jsx)(`div`,{className:`matrix`,children:c}),!n&&s.length===0&&c.length===0&&(0,j.jsxs)(`div`,{className:`c c-quiet`,children:[(0,j.jsx)(`div`,{className:`t`,children:`No instruments reporting`}),(0,j.jsx)(`div`,{className:`meta`,children:`Signal K is connected and carries no position, speed, wind or depth for this vessel. Alongside with the instruments switched off, this is the expected reading.`})]})]})}function Ng({tab:e,tabs:t,d:n,voyage:r,onTab:i,onBaro:a}){return(0,j.jsxs)(`div`,{className:`sp-pane`,children:[t.length>1&&(0,j.jsx)(`nav`,{className:`sy-tabs`,"aria-label":`Instrument panels`,children:t.map(t=>(0,j.jsx)(`button`,{type:`button`,className:`sy-tab${e===t.key?` on`:``}`,"aria-current":e===t.key?`page`:void 0,onClick:()=>i(t.key),children:t.name},t.key))}),e===`bridge`?(0,j.jsx)(Mg,{d:n,onBaro:a}):e===`trip`?(0,j.jsx)(Sg,{voyage:r,now:n.now}):(0,j.jsx)(Oh,{snap:n.snap,tab:e})]})}function Pg(){let e=Xh(),[t,n]=(0,p.useState)(!1),[r,i]=Un(),a=Hm(wg),o=()=>n(!0),s=vh(e.snap),c=e.snap===null||Jh(e)||s.length===0,{data:l}=Dm(_r.voyage.current,Tg),u=l!=null;if(a)return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`sp-dash sp-board`,children:[c&&(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-bridge`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:`Bridge`}),(0,j.jsx)(Mg,{d:e,onBaro:o})]}),(s.length>0||u)&&(0,j.jsxs)(`div`,{className:`sp-systems`,children:[s.map(t=>(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-${t.key}`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:t.name}),(0,j.jsx)(Oh,{snap:e.snap,tab:t.key})]},t.key)),u&&(0,j.jsxs)(`section`,{className:`sp-sec sp-sec-trip`,children:[(0,j.jsx)(`h2`,{className:`sp-sec-h`,children:`Trip computer`}),(0,j.jsx)(Sg,{voyage:l,now:e.now})]},`trip`)]})]}),(0,j.jsx)(vg,{sealing:e.sealing}),t&&(0,j.jsx)(dg,{onClose:()=>n(!1),current:e.baroHPa,delta:e.baroDelta})]});let d=[...c?[{key:`bridge`,name:`Bridge`}]:[],...s.map(e=>({key:e.key,name:e.name})),...u?[{key:`trip`,name:`Trip`}]:[]],f=(e=>e&&d.some(t=>t.key===e)?e:null)(r.get(`a`))??d[0]?.key??`bridge`;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`sp-dash`,children:(0,j.jsx)(Ng,{tab:f,tabs:d,d:e,voyage:l,onTab:e=>{let t=new URLSearchParams(r);t.set(`a`,e),i(t,{replace:!0})},onBaro:o})}),(0,j.jsx)(vg,{sealing:e.sealing}),t&&(0,j.jsx)(dg,{onClose:()=>n(!1),current:e.baroHPa,delta:e.baroDelta})]})}function Fg(){return(0,j.jsx)(Pg,{})}var Ig=(0,p.lazy)(()=>v(()=>import(`./Logbook-CpMK73wj.js`),__vite__mapDeps([2,1,3]),import.meta.url)),Lg=(0,p.lazy)(()=>v(()=>import(`./Voyage-DqTyveli.js`),__vite__mapDeps([4,1,5,6]),import.meta.url)),Rg=(0,p.lazy)(()=>v(()=>import(`./Map-BmL-Ri3l.js`),__vite__mapDeps([7,1,3,5,6]),import.meta.url));function zg(){let[e,t]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(ar,e),()=>window.removeEventListener(ar,e)},[]),e?(0,j.jsx)(ym,{}):(0,j.jsx)(nr,{children:(0,j.jsx)(p.Suspense,{fallback:(0,j.jsx)(bm,{full:!0}),children:(0,j.jsxs)(Ut,{children:[(0,j.jsxs)(Vt,{element:(0,j.jsx)(qm,{}),children:[(0,j.jsx)(Vt,{path:`/`,element:(0,j.jsx)(Fg,{})}),(0,j.jsx)(Vt,{path:`/logbook`,element:(0,j.jsx)(Ig,{})}),(0,j.jsx)(Vt,{path:`/voyage`,element:(0,j.jsx)(Lg,{})}),(0,j.jsx)(Vt,{path:`/map`,element:(0,j.jsx)(Rg,{})})]}),(0,j.jsx)(Vt,{path:`*`,element:(0,j.jsx)(Bt,{to:`/`,replace:!0})})]})})})}Fm(),(0,m.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(p.StrictMode,{children:(0,j.jsx)(Nn,{children:(0,j.jsx)(zg,{})})}));export{tr as _,kh as a,Fh as c,yh as d,Dm as f,_r as g,rr as h,Ih as i,jh as l,pm as m,Bh as n,Lh as o,xm as p,Rh as r,Mh as s,zh as t,Nh as u,u as v,o as y};