1import{r as p,j as e}from"./vendor-react-BWQKYwBR.js";import{aj as P,an as K,al as g,ao as A,ak as ne,am as oe,w as Se,c as Te}from"./index-C-C3bWXR.js";import{A as J,R as Q}from"./Area-Cw5iHR4y.js";import"./vendor-leaflet-D9lupU1w.js";import"./vendor-tz-1-Tm3DMS.js";function B(a,i){return i==="imperial"?Math.round(a*9/5+32):Math.round(a*10)/10}function V(a,i){return Math.round(i==="imperial"?a/1.60934:a)}function De(a,i){try{return new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:i}).format(new Date(a))}catch{return a.slice(11,16)}}function Le(a,i){try{const n=new Date(a),r=new Intl.DateTimeFormat("en-US",{weekday:"short",timeZone:i}).format(n),s=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:i}).format(n),l=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:i}).format(n).replace(":00","").replace(" AM","a").replace(" PM","p");return`${r} ${s}, ${l}`}catch{return a.slice(0,16).replace("T"," ")}}function Fe(a,i){if(a.length<2)return[];const n=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",timeZone:i}),r=new Intl.DateTimeFormat("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:i}),s=[];let l=n.format(new Date(a[0].ms));for(let m=1;m<a.length;m++){const d=n.format(new Date(a[m].ms));d!==l&&(s.push({ms:a[m].ms,label:r.format(new Date(a[m].ms))}),l=d)}return s}function $e(a){var i;try{return((i=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"short"}).formatToParts(new Date).find(n=>n.type==="timeZoneName"))==null?void 0:i.value)??""}catch{return""}}const N={tick:{fill:"#94a3b8",fontSize:10},axisLine:{stroke:"#334155"},tickLine:{stroke:"#334155"}};function O(a,i,n,r,s){return a.filter(({ms:l})=>l>i&&l<n).map(({ms:l,label:m})=>e.jsx(Q,{x:l,stroke:"#334155",strokeWidth:1.5,yAxisId:r,label:s?{value:m,position:"insideTopRight",fill:"#475569",fontSize:9,dy:2}:void 0},`day-${l}`))}function U(a,i,n,r){return a.map(s=>new Date(s).getTime()).filter(s=>s>i&&s<n).map(s=>e.jsx(Q,{x:s,stroke:"#475569",strokeDasharray:"4 3",strokeWidth:1,yAxisId:r},s))}function We(a,i,n,r){return a.filter(s=>s.ms>i&&s.ms<n).map(s=>e.jsx(Q,{x:s.ms,stroke:s.type==="sunrise"?"#fbbf24":"#f97316",strokeWidth:1,strokeDasharray:"3 3",yAxisId:r,label:{value:s.type==="sunrise"?"sun":"dusk",position:"insideTopLeft",fill:s.type==="sunrise"?"#fbbf24":"#f97316",fontSize:10,dy:2}},`${s.type}-${s.ms}`))}function Z({xDomainMin:a,xDomainMax:i,xTicks:n,courseTz:r,isBottom:s,tzAbbr:l}){return s?e.jsx(ne,{dataKey:"ms",type:"number",domain:[a,i],scale:"time",ticks:n,tickFormatter:m=>De(new Date(m).toISOString(),r),...N,label:l?{value:l,position:"insideBottomRight",offset:-4,style:{fill:"#64748b",fontSize:9,fontStyle:"italic"}}:void 0}):e.jsx(ne,{dataKey:"ms",type:"number",domain:[a,i],scale:"time",tick:!1,axisLine:{stroke:"#334155"},tickLine:!1,height:4})}function Re({active:a,payload:i,courseTz:n,unitSystem:r,showTempChart:s,showFeelsLike:l,showWindChart:m,showGusts:d,showPrecipChart:k,showPrecipProb:_,hasPrecip:M,showCoverChart:I,showHumidity:v}){if(!a||!(i!=null&&i.length))return null;const C=i[0].payload,o=C.raw.weather,S=r==="imperial"?"F":"C",b=r==="imperial"?"mph":"km/h",E=Se(o.weatherCode,o.isDay);return e.jsxs("div",{className:"temp-chart-tooltip",children:[e.jsxs("div",{className:"temp-chart-tooltip-time",children:[E," ",Le(C.raw.timeIso,n)]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Temp"}),e.jsxs("span",{children:[B(o.temperature,r),"°",S]})]}),l&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Feels like"}),e.jsxs("span",{children:[B(o.apparentTemperature,r),"°",S]})]})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Wind"}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",transform:`rotate(${(o.windDirection+180)%360}deg)`,lineHeight:1},children:e.jsx("i",{className:"fa-solid fa-arrow-up"})})," ",V(o.windSpeed,r)," ",b," ",Te(o.windDirection)]})]}),d&&o.windGusts>o.windSpeed&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Gusts"}),e.jsxs("span",{children:[V(o.windGusts,r)," ",b]})]})]}),k&&M&&_&&o.precipitationProbabilityAvailable&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Prob"}),e.jsxs("span",{children:[Math.round(o.precipitationProbability),"%"]})]}),k&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Rain"}),e.jsxs("span",{children:[o.rain.toFixed(2)," mm"]})]}),o.precipitation>o.rain&&o.precipitation>0&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Total"}),e.jsxs("span",{children:[o.precipitation.toFixed(2)," mm"]})]})]}),I&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Cloud"}),e.jsxs("span",{children:[Math.round(o.cloudCover),"%"]})]}),I&&v&&e.jsxs("div",{className:"temp-chart-tooltip-row",children:[e.jsx("span",{className:"temp-chart-tooltip-label",children:"Humidity"}),e.jsxs("span",{children:[Math.round(o.humidity),"%"]})]})]})}const Be=p.memo(function({hourlyWeather:i,courseTz:n,unitSystem:r,segmentBoundaryTimes:s=[],onHoverPoint:l,sunriseSunset:m=[],zoomDomain:d}){const[k,_]=p.useState(!0),[M,I]=p.useState(!1),[v,C]=p.useState(!1),[o,S]=p.useState(!1),[b,E]=p.useState(!0),[T,le]=p.useState(!0),[y,ce]=p.useState(!0),[X,de]=p.useState(!0),me=r==="imperial"?"F":"C",he=r==="imperial"?"mph":"km/h",u=p.useMemo(()=>i.map(t=>({ms:new Date(t.timeIso).getTime(),temp:B(t.weather.temperature,r),feelsLike:B(t.weather.apparentTemperature,r),windSpeed:V(t.weather.windSpeed,r),windGusts:V(t.weather.windGusts,r),precip:t.weather.precipitationProbabilityAvailable?t.weather.precipitationProbability:null,rain:t.weather.rain,cloudCover:t.weather.cloudCover,humidity:t.weather.humidity,raw:t})),[i,r]);if(u.length<2)return null;const f=(d==null?void 0:d[0])??u[0].ms,x=(d==null?void 0:d[1])??u[u.length-1].ms,c=d?u.filter(t=>t.ms>=d[0]&&t.ms<=d[1]):u;if(c.length===0)return null;const H=c.length/4,pe=H<=24?8:H<=72?24:H<=168?48:96,fe=c.filter((t,w)=>w%pe===0).map(t=>t.ms),xe=$e(n),D=p.useMemo(()=>Fe(u,n),[u,n]),j=c.some(t=>t.precip!==null),Y=c.some(t=>t.rain>0),z=j||Y,h={temp:k,wind:M,precip:v&&z,cover:o}
1,ue=Object.values(h).filter(Boolean).length,L=t=>!t||ue>1,ee=[...["temp","wind","precip","cover"]].reverse().find(t=>h[t])??"temp",te=[...c.map(t=>t.temp),...b?c.map(t=>t.feelsLike):[]],se=Math.min(...te),ae=Math.max(...te),ie=Math.max((ae-se)*.15,2),we=Math.floor(se-ie),ge=Math.ceil(ae+ie),be=Math.max(...c.map(t=>T?Math.max(t.windSpeed,t.windGusts):t.windSpeed)),je=Math.max(Math.ceil(be*1.2),1),ve=Y?Math.max(...c.map(t=>t.rain)):0,ye=Math.max(Math.ceil(ve*1.3),1),ke={top:6,right:8,left:2,bottom:4},Ae={top:6,right:8,left:2,bottom:16},F=t=>ee===t?Ae:ke,$=t=>{if(!l)return;const w=t.activeTooltipIndex;w!=null&&w>=0&&w<c.length&&l(c[w].raw)},W=()=>l==null?void 0:l(null),R=t=>({xDomainMin:f,xDomainMax:x,xTicks:fe,courseTz:n,isBottom:ee===t,tzAbbr:xe}),Ne=["temp","wind","precip","cover"].find(t=>h[t])??"temp",G=t=>Ne===t?e.jsx(oe,{content:e.jsx(Re,{unitSystem:r,courseTz:n,showTempChart:h.temp,showFeelsLike:b,showWindChart:h.wind,showGusts:T,showPrecipChart:h.precip,showPrecipProb:y,hasPrecip:j,showCoverChart:h.cover,showHumidity:X}),isAnimationActive:!1}):e.jsx(oe,{content:()=>null,cursor:{stroke:"#334155",strokeWidth:1,strokeDasharray:"4 2"},isAnimationActive:!1});return e.jsxs("div",{className:"temp-chart-container",children:[e.jsx("div",{className:"temp-chart-header",children:e.jsxs("div",{className:"temp-chart-toggles",children:[[{id:"temp",label:"Temp",color:"#60a5fa",shown:k,set:_},{id:"wind",label:"Wind",color:"#34d399",shown:M,set:I},{id:"cover",label:"Cover",color:"#94a3b8",shown:o,set:S}].map(({id:t,label:w,color:Me,shown:re,set:Ie})=>{const q=!L(re);return e.jsx("button",{type:"button",className:`temp-chart-toggle-btn${re?" temp-chart-toggle-btn--active":""}${q?" temp-chart-toggle-btn--locked":""}`,style:{"--toggle-color":Me},onClick:()=>!q&&Ie(Ce=>!Ce),title:q?"At least one chart must be visible":void 0,children:w},t)}),z&&e.jsx("button",{type:"button",className:`temp-chart-toggle-btn${h.precip?" temp-chart-toggle-btn--active":""}${L(v)?"":" temp-chart-toggle-btn--locked"}`,style:{"--toggle-color":"#38bdf8"},onClick:()=>L(v)&&C(t=>!t),title:L(v)?void 0:"At least one chart must be visible",children:"Precip"})]})}),h.temp&&e.jsxs("div",{className:"temp-chart-subrow",children:[e.jsxs("div",{className:"temp-chart-subrow-header",children:[e.jsxs("span",{style:{color:"#60a5fa"},children:[e.jsx("i",{className:"fa-solid fa-temperature-half"})," Temperature (°",me,")"]}),e.jsxs("button",{type:"button",className:`temp-chart-toggle-btn temp-chart-toggle-btn--mini${b?" temp-chart-toggle-btn--active":""}`,style:{"--toggle-color":"#fb923c"},onClick:()=>E(t=>!t),children:[e.jsx("span",{className:"temp-chart-toggle-swatch temp-chart-toggle-swatch--line"}),"Feels like"]})]}),e.jsx(P,{width:"100%",height:120,children:e.jsxs(K,{data:c,margin:F("temp"),syncId:"wx-forecast",onMouseMove:$,onMouseLeave:W,children:[We(m,f,x,"temp"),O(D,f,x,"temp",!0),U(s,f,x,"temp"),Z(R("temp")),e.jsx(g,{yAxisId:"temp",orientation:"left",domain:[we,ge],...N,width:36,tickFormatter:t=>`${t}`}),e.jsx(g,{yAxisId:"right-pad",orientation:"right",width:36,tick:!1,axisLine:!1,tickLine:!1}),G("temp"),b&&e.jsx(A,{yAxisId:"temp",type:"monotone",dataKey:"feelsLike",stroke:"#fb923c",strokeWidth:1.5,strokeDasharray:"5 3",dot:!1,activeDot:{r:3,fill:"#fb923c",stroke:"#1e293b"},isAnimationActive:!1}),e.jsx(A,{yAxisId:"temp",type:"monotone",dataKey:"temp",stroke:"#60a5fa",strokeWidth:2,dot:!1,activeDot:{r:4,fill:"#93c5fd",stroke:"#1e293b"},isAnimationActive:!1})]})})]}),h.wind&&e.jsxs("div",{className:"temp-chart-subrow",children:[e.jsxs("div",{className:"temp-chart-subrow-header",children:[e.jsxs("span",{style:{color:"#34d399"},children:[e.jsx("i",{className:"fa-solid fa-wind"})," Wind (",he,")"]}),e.jsxs("button",{type:"button",className:`temp-chart-toggle-btn temp-chart-toggle-btn--mini${T?" temp-chart-toggle-btn--active":""}`,style:{"--toggle-color":"#a7f3d0"},onClick:()=>le(t=>!t),children:[e.jsx("span",{className:"temp-chart-toggle-swatch temp-chart-toggle-swatch--line"}),"Gusts"]})]}),e.jsx(P,{width:"100%",height:100,children:e.jsxs(K,{data:c,margin:F("wind"),syncId:"wx-forecast",onMouseMove:$,onMouseLeave:W,children:[O(D,f,x,"wind",!1),U(s,f,x,"wind"),Z(R("wind")),e.jsx(g,{yAxisId:"wind",orientation:"left",domain:[0,je],...N,width:36,tickFormatter:t=>`${t}`}),e.jsx(g,{yAxisId:"right-pad",orientation:"right",width:36,tick:!1,axisLine
1:!1,tickLine:!1}),G("wind"),T&&e.jsx(A,{yAxisId:"wind",type:"monotone",dataKey:"windGusts",stroke:"#a7f3d0",strokeWidth:1.5,strokeDasharray:"5 3",dot:!1,activeDot:{r:3,fill:"#a7f3d0",stroke:"#1e293b"},isAnimationActive:!1}),e.jsx(A,{yAxisId:"wind",type:"monotone",dataKey:"windSpeed",stroke:"#34d399",strokeWidth:1.5,dot:!1,activeDot:{r:3,fill:"#34d399",stroke:"#1e293b"},isAnimationActive:!1})]})})]}),h.precip&&e.jsxs("div",{className:"temp-chart-subrow",children:[e.jsxs("div",{className:"temp-chart-subrow-header",children:[e.jsxs("span",{style:{color:"#38bdf8"},children:[e.jsx("i",{className:"fa-solid fa-cloud-rain"})," Precipitation"]}),e.jsxs("div",{style:{display:"flex",gap:"0.3rem",alignItems:"center"},children:[Y&&e.jsxs("span",{className:"temp-chart-subrow-legend-item",style:{color:"#38bdf8"},children:[e.jsx("span",{className:"temp-chart-legend-area",style:{background:"#38bdf8"}}),"Rain (mm)"]}),j&&e.jsxs("button",{type:"button",className:`temp-chart-toggle-btn temp-chart-toggle-btn--mini${y?" temp-chart-toggle-btn--active":""}`,style:{"--toggle-color":"#7dd3fc"},onClick:()=>ce(t=>!t),children:[e.jsx("span",{className:"temp-chart-toggle-swatch temp-chart-toggle-swatch--area"}),"Prob %"]})]})]}),e.jsx(P,{width:"100%",height:100,children:e.jsxs(K,{data:c,margin:F("precip"),syncId:"wx-forecast",onMouseMove:$,onMouseLeave:W,children:[O(D,f,x,"rain",!1),U(s,f,x,"rain"),Z(R("precip")),e.jsx(g,{yAxisId:"rain",orientation:"left",domain:[0,ye],...N,width:36,tickFormatter:t=>`${t}mm`}),e.jsx(g,{yAxisId:"pct",orientation:"right",domain:[0,100],width:36,tick:j&&y?{fill:"#94a3b8",fontSize:10}:!1,axisLine:j&&y?{stroke:"#334155"}:!1,tickLine:j&&y?{stroke:"#334155"}:!1,tickFormatter:t=>`${t}%`}),G("precip"),j&&y&&e.jsx(J,{yAxisId:"pct",type:"monotone",dataKey:"precip",fill:"#1e3a5f",stroke:"#7dd3fc",strokeWidth:1,fillOpacity:.45,dot:!1,activeDot:!1,isAnimationActive:!1,connectNulls:!1}),e.jsx(J,{yAxisId:"rain",type:"monotone",dataKey:"rain",fill:"#0c4a6e",stroke:"#38bdf8",strokeWidth:1.5,fillOpacity:.6,dot:!1,activeDot:!1,isAnimationActive:!1})]})})]}),h.cover&&e.jsxs("div",{className:"temp-chart-subrow",children:[e.jsxs("div",{className:"temp-chart-subrow-header",children:[e.jsxs("span",{style:{color:"#94a3b8"},children:[e.jsx("i",{className:"fa-solid fa-cloud"})," Cloud & Humidity (%)"]}),e.jsxs("button",{type:"button",className:`temp-chart-toggle-btn temp-chart-toggle-btn--mini${X?" temp-chart-toggle-btn--active":""}`,style:{"--toggle-color":"#67e8f9"},onClick:()=>de(t=>!t),children:[e.jsx("span",{className:"temp-chart-toggle-swatch temp-chart-toggle-swatch--line"}),"Humidity"]})]}),e.jsx(P,{width:"100%",height:100,children:e.jsxs(K,{data:c,margin:F("cover"),syncId:"wx-forecast",onMouseMove:$,onMouseLeave:W,children:[O(D,f,x,"cover",!1),U(s,f,x,"cover"),Z(R("cover")),e.jsx(g,{yAxisId:"cover",orientation:"left",domain:[0,100],...N,width:36,tickFormatter:t=>`${t}%`}),e.jsx(g,{yAxisId:"right-pad",orientation:"right",width:36,tick:!1,axisLine:!1,tickLine:!1}),G("cover"),e.jsx(J,{yAxisId:"cover",type:"monotone",dataKey:"cloudCover",fill:"#1e293b",stroke:"#94a3b8",strokeWidth:1,fillOpacity:.4,dot:!1,activeDot:!1,isAnimationActive:!1}),X&&e.jsx(A,{yAxisId:"cover",type:"monotone",dataKey:"humidity",stroke:"#67e8f9",strokeWidth:1.5,dot:!1,activeDot:{r:3,fill:"#67e8f9",stroke:"#1e293b"},isAnimationActive:!1})]})})]})]})});export{Be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.