https://www.asturmet.com/_next/static/chunks/app/pronostico/%5Bmunicipio%5D/page-a5b16fff79d53b62.js
1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8373],{8764:(e,t,s)=>{"use strict";s.d(t,{C6:()=>p,d1:()=>g,eZ:()=>h,lS:()=>x,tL:()=>f,v7:()=>c,vm:()=>u,zt:()=>j});var a=s(62950);let r=/^\d{8}T\d{6}Z$/,i=/^\/v1\/radar\/aemet\/frames\/(\d{8}T\d{6}Z)\.png$/,n=/^[a-f0-9]{64}$/,l=new Set(["fresh","delayed","stale"]);function d(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function o(e){return"number"==typeof e&&Number.isFinite(e)}function m(e){return"string"==typeof e&&Number.isFinite(Date.parse(e))}function c(e){if(!d(e)||"string"!=typeof e.frameId||!r.test(e.frameId)||!m(e.observedAt)||!m(e.fetchedAt)||!m(e.publishedAt)||"string"!=typeof e.freshness||!l.has(e.freshness)||"AEMET radar composition"!==e.source||"compo"!==e.product||"Fuente: AEMET"!==e.attribution||!0!==e.provisional||"EPSG:4326"!==e.crs||!d(e.bounds)||!o(e.bounds.west)||!o(e.bounds.south)||!o(e.bounds.east)||!o(e.bounds.north)||e.bounds.west<-180||e.bounds.east>180||e.bounds.south<-90||e.bounds.north>90||e.bounds.west>=e.bounds.east||e.bounds.south>=e.bounds.north||!d(e.dimensions)||!Number.isInteger(e.dimensions.width)||!Number.isInteger(e.dimensions.height)||!o(e.dimensions.width)||!o(e.dimensions.height)||e.dimensions.width<1||e.dimensions.height<1||e.dimensions.width>1e4||e.dimensions.height>1e4||!d(e.legend)||!Array.isArray(e.legend.colors)||11!==e.legend.colors.length||!e.legend.colors.every(e=>"string"==typeof e&&e.length>0&&e.length<=32)||"string"!=typeof e.legend.highLabel||"string"!=typeof e.legend.label||"string"!=typeof e.legend.lowLabel||!d(e.image)||"string"!=typeof e.image.url||!i.test(e.image.url)||e.image.url!=="/v1/radar/aemet/frames/"+e.frameId+".png"||"image/png"!==e.image.mimeType||!Number.isInteger(e.image.bytes)||!o(e.image.bytes)||e.image.bytes<1||"string"!=typeof e.image.checksum||!n.test(e.image.checksum))throw Error("Invalid AEMET radar payload");return e}function x(){return new URL("/v1/radar/aemet/latest",(0,a.D8)()).toString()}function u(e){if(!i.test(e))throw Error("Invalid AEMET radar frame path");return new URL(e,(0,a.D8)()).toString()}function p(e){return"fresh"===e?"Actualizado":"delayed"===e?"Con retraso":"Antiguo"}function h(e){return"fresh"===e?"border-emerald-300 bg-emerald-50 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"delayed"===e?"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100":"border-rose-300 bg-rose-50 text-rose-900 dark:border-rose-800 dark:bg-rose-950/40 dark:text-rose-100"}function f(e){let t=new Date(e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat("es-ES",{timeZone:"Europe/Madrid",day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}).format(t):"Hora no disponible"}function b(e){return o(e.lat)&&e.lat>=40.5&&e.lat<=44.5&&o(e.lng)&&e.lng>=-10.5&&e.lng<=-1&&Number.isInteger(e.zoom)&&e.zoom>=7&&e.zoom<=11&&"string"==typeof e.locationName&&e.locationName.trim().length>=1&&e.locationName.trim().length<=120&&!/[\u0000-\u001f\u007f]/.test(e.locationName)}function g(e){if(!b(e))throw Error("Invalid local radar view");let t=new URLSearchParams;return t.set("layer","radar"),t.set("lat",String(e.lat)),t.set("lng",String(e.lng)),t.set("zoom",String(e.zoom)),t.set("location",e.locationName.trim()),"/mapas?"+t.toString()}function j(e){if("radar"!==e.layer||"string"!=typeof e.lat||"string"!=typeof e.lng||"string"!=typeof e.zoom||"string"!=typeof e.location||""===e.lat.trim()||""===e.lng.trim()||""===e.zoom.trim())return null;let t={lat:Number(e.lat),lng:Number(e.lng),zoom:Number(e.zoom),locationName:e.location.trim()};return b(t)?t:null}},11145:(e,t,s)=>{"use strict";s.d(t,{XL:()=>n,Z7:()=>l,cb:()=>r,en:()=>m,iU:()=>o,lu:()=>a,xi:()=>d});let a="asturmet:read-news:v1",r="asturmet:news-read";function i(e,t){let s=t-Date.parse(e);return Number.isFinite(s)&&s>=0&&s<864e5}function n(e,t){let s;try{s=JSON.parse(e.getItem(a)??"{}")}catch{return e.removeItem(a),{}}if(!s||"object"!=typeof s||Array.isArray(s))return e.removeItem(a),{};let r=Object.entries(s).filter(([,e])=>"string"==typeof e&&i(e,t)),n=Object.fromEntries(r);return 0===r.length?e.removeItem(a):e.setItem(a,JSON.stringify(n)),n}function l(e,t,s){let r=n(e,s);if(!i(t.publishedAt,s))return r;let l={...r,[t.id]:t.publishedAt};return e.setItem(a,JSON.stringify(l)),l}function d(e,t){let s=e.filter(e=>i(e,t)).map(e=>Date.parse(e)+864e5-t+1);return s.length>0?Math.min(...s):null}function o(e){return e?"Noticias, hay noticias nuevas":"Noticias"}function m(e,t,s){return e.filter(e=>i(e.publishedAt,s)&&t[e.id]!==e.publishedAt).map(e=>e.id)}},11239:(e,t,s)=>{"use strict";s.d(t,{O:()=>i});var a=s(95155),r=s(40980);function i({className:e,visible:t}){return t?(0,a.jsx)("span",{"aria-hidden":"true",className:(0,r.cn)("absolute size-2.5 rounded-full bg-red-500 ring-2 ring-background",e)}):null}},17052:(e,t,s)=>{"use strict";s.d(t,{ForecastModelProvider:()=>n,g:()=>l});var a=s(95155),r=s(12115);let i=(0,r.createContext)(null);function n({children:e}){let[t,s]=(0,r.useState)("asturmet");return(0,a.jsx)(i.Provider,{value:{model:t,setModel:s},children:e})}function l(){let e=(0,r.useContext)(i);if(!e)throw Error("ForecastModelProvider missing");return e}},22254:(e,t,s)=>{"use strict";s.d(t,{PredictionModelView:()=>e2});var a=s(95155),r=s(12115),i=s(17052),n=s(75262),l=s(74635),d=s(20200),o=s(90161),m=s(22100),c=s(45374),x=s(1407),u=s(58120),p=s(51900);let h=e=>{let t=(e||"").toLowerCase();return t.includes("rain")||t.includes("llov")||t.includes("lluv")?d.A:t.includes("snow")||t.includes("niev")?o.A:t.includes("storm")||t.includes("tormenta")?m.A:t.includes("fog")||t.includes("niebla")?c.A:t.includes("cloud")||t.includes("nub")?x.A:t.includes("partly")||t.includes("parcial")?u.A:p.A};var f=s(39092),b=s.n(f),g=s(40980),j=s(28063),N=s(50061),v=s(74526),y=s(7484),w=s(48144),k=s(59320),M=s(78694),A=s(56301);let S=e=>{let t=[[-10,30,58,138],[0,59,130,246],[15,13,148,136],[25,202,138,4],[35,234,88,12],[45,185,28,28]],s=t[0],a=t[t.length-1];for(let r=0;r<t.length-1;r++)if(e>=t[r][0]&&e<=t[r+1][0]){s=t[r],a=t[r+1];break}e<t[0][0]&&(a=t[0]),e>t[t.length-1][0]&&(s=t[t.length-1]);let r=a[0]-s[0],i=0===r?0:(e-s[0])/r,n=Math.round(s[1]+(a[1]-s[1])*i),l=Math.round(s[2]+(a[2]-s[2])*i),d=Math.round(s[3]+(a[3]-s[3])*i);return{backgroundColor:`rgb(${n},${l},${d})`,color:"white"}},E=e=>e>75?"bg-red-500 text-white":e>50?"bg-orange-500 text-white":e>25?"bg-yellow-400 text-black":"",C=(e,t)=>{if(t){if(e>2)return"bg-orange-500 text-white"}else if(e>20)return"bg-orange-500 text-white";return""};function T({hourlyData:e,scrollTargetHour:t}){let s=(0,r.useRef)(null),i=(0,r.useRef)(new Map);if((0,r.useEffect)(()=>
1{if(t&&s.current&&i.current.has(t)){let e=i.current.get(t);if(e){let t=s.current,a=e.offsetLeft;t.scrollTo({left:a-150,behavior:"smooth"})}}},[t,e]),!e||0===e.length)return(0,a.jsx)("div",{className:"p-4 text-center text-muted-foreground",children:"No data available"});let n=Math.max(e.reduce((e,t)=>Math.max(e,(t.rain||0)+10*(t.snow||0)),0),5),l=({icon:e,label:t,unit:s,className:r})=>(0,a.jsxs)("div",{className:(0,g.cn)("sticky left-0 z-50 flex items-center justify-center sm:justify-start gap-2 p-2 bg-background/95 backdrop-blur border-r border-border min-w-[50px] sm:min-w-[140px] shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]",r),children:[(0,a.jsx)("div",{className:"p-1.5 rounded-md bg-muted/50",children:(0,a.jsx)(e,{className:"w-4 h-4 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"hidden sm:flex flex-col",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground leading-none",children:t}),s&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground/50 leading-none mt-0.5 lowercase",children:s})]})]}),o=({children:e,className:s,isSnapPoint:r,time:n})=>{let l=n===t;return(0,a.jsx)("div",{ref:n?e=>{e?i.current.set(n,e):n&&i.current.delete(n)}:void 0,className:(0,g.cn)("flex items-center justify-center p-2 min-w-[var(--cell-min)] border-r border-border/30 last:border-r-0 transition-colors duration-500",r?"snap-start":"",l?"bg-blue-500/10 dark:bg-blue-500/20":"",s),children:e})};return(0,a.jsxs)("div",{ref:s,style:{scrollPaddingLeft:"var(--scroll-padding, 50px)"},className:"jsx-92837e1e53d1925 w-full overflow-x-auto pb-2 scrollbar-hide snap-x snap-mandatory scroll-smooth",children:[(0,a.jsx)(b(),{id:"92837e1e53d1925",children:"div.jsx-92837e1e53d1925{--cell-min:56px}@media(min-width:640px){div.jsx-92837e1e53d1925{--scroll-padding:140px}div.jsx-92837e1e53d1925{--cell-min:70px}}"}),(0,a.jsxs)("div",{style:{gridTemplateColumns:`auto repeat(${e.length}, minmax(var(--cell-min), 1fr))`},className:"jsx-92837e1e53d1925 inline-grid",children:[(0,a.jsx)(l,{icon:j.A,label:"Hora",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{className:"font-semibold text-sm",isSnapPoint:!0,time:e.time,children:e.time},t)),(0,a.jsx)(l,{icon:d.A,label:"Cielo",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>{let s=h(e.condition);return(0,a.jsx)(o,{time:e.time,children:e.icon?(0,a.jsx)("img",{src:e.icon,className:"jsx-92837e1e53d1925 w-8 h-8 object-contain"}):(0,a.jsx)(s,{className:"jsx-92837e1e53d1925 w-6 h-6 text-muted-foreground"})},t)}),(0,a.jsx)(l,{icon:N.A,label:"Lluvia",unit:"mm",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>{let s;e.snow||e.rain;let r=e.rain&&e.rain>0;return(0,a.jsxs)(o,{className:"flex-col justify-end h-[80px] pb-0 relative group",time:e.time,children:[(0,a.jsx)("div",{className:"jsx-92837e1e53d1925 text-[10px] font-medium mb-1 z-10",children:r?e.rain.toFixed(1):""}),r&&(0,a.jsx)("div",{style:{height:(s=Math.min(e.rain/n*100,100),`${Math.max(s,0)}%`)},className:"jsx-92837e1e53d1925 "+((0,g.cn)("w-4 rounded-t-sm transition-all group-hover:bg-blue-500/70",(e.rain||0)>20?"bg-orange-500":"bg-blue-500/50")||"")}),(0,a.jsx)("div",{className:"jsx-92837e1e53d1925 absolute bottom-0 w-full h-[1px] bg-border/50"})]},t)}),(0,a.jsx)(l,{icon:v.A,label:"Temp.",unit:"\xb0C",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{className:"",time:e.time,children:(0,a.jsxs)("div",{style:S(e.temp),className:"jsx-92837e1e53d1925 px-2 py-1 rounded-md text-sm font-bold shadow-sm",children:[Math.round(e.temp),"\xb0"]})},t)),(0,a.jsx)(l,{icon:y.A,label:"Viento",unit:"km/h",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{className:"flex-col gap-1",time:e.time,children:(0,a.jsxs)("div",{className:"jsx-92837e1e53d1925 "+((0,g.cn)("flex flex-col items-center justify-center w-full h-full rounded-md p-1",E(e.windSpeed))||""),children:[(0,a.jsx)(w.A,{className:"w-4 h-4 mb-0.5",style:{transform:`rotate(${e.windDeg||0}deg)`}}),(0,a.jsx)("span",{className:"jsx-92837e1e53d1925 text-xs font-bold",children:Math.round(e.windSpeed)})]})},t)),(0,a.jsx)(l,{icon:k.A,label:"R\xe1fagas",unit:"km/h",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("div",{className:"jsx-92837e1e53d1925 "+((0,g.cn)("px-1.5 py-0.5 rounded text-xs",Number.isFinite(e.gusts)?E(e.gusts):"text-muted-foreground")||""),children:Number.isFinite(e.gusts)?Math.round(e.gusts):"â"})},t)),(0,a.jsx)(l,{icon:v.A,label:"Sensaci\xf3n",unit:"\xb0C",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("span",{className:"jsx-92837e1e53d1925 text-sm text-muted-foreground",children:Number.isFinite(e.feelsLike)?`${Math.round(e.feelsLike)}\xb0`:"â"})},t)),(0,a.jsx)(l,{icon:N.A,label:"Humedad",unit:"%",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("span",{className:"jsx-92837e1e53d1925 text-sm text-blue-400",children:Number.isFinite(e.humidity)?`${Math.round(e.humidity)}%`:"â"})},t)),(0,a.jsx)(l,{icon:M.A,label:"Nieve",unit:"cm",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>{let s=e.snow||0,r=s>0,i=s>2;return(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("span",{className:"jsx-92837e1e53d1925 "+((0,g.cn)("text-xs font-medium",r?i?"text-orange-600 font-bold":"text-blue-400":"text-muted-foreground
1/30")||""),children:Number.isFinite(e.snow)?r?s.toFixed(2):"0":"â"})},t)}),(0,a.jsx)(l,{icon:A.A,label:"Cota Nieve",unit:"m",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("span",{className:"jsx-92837e1e53d1925 text-xs text-muted-foreground",children:Number.isFinite(e.snowLine)?Math.round(e.snowLine):"â"})},t)),(0,a.jsx)(l,{icon:v.A,label:"T. 850mb",unit:"\xb0C",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("div",{style:Number.isFinite(e.temp850)?S(e.temp850):void 0,className:"jsx-92837e1e53d1925 px-1.5 py-0.5 rounded text-xs font-medium",children:Number.isFinite(e.temp850)?Math.round(e.temp850)+"\xb0":"â"})},t)),(0,a.jsx)(l,{icon:v.A,label:"T. 500mb",unit:"\xb0C",className:"jsx-92837e1e53d1925"}),e.map((e,t)=>(0,a.jsx)(o,{time:e.time,children:(0,a.jsx)("div",{style:Number.isFinite(e.temp500)?S(e.temp500):void 0,className:"jsx-92837e1e53d1925 px-1.5 py-0.5 rounded text-xs font-medium",children:Number.isFinite(e.temp500)?Math.round(e.temp500)+"\xb0":"â"})},t))]})]})}var L=s(1728),F=s(68444),P=s(28408),D=s(32539),I=s(59656),z=s(67869),K=s(75319),$=s(58021),W=s(67389),R=s(81477);function O({data:e}){let t="var(--color-weather-rain)",s="var(--color-weather-snow)",i=e=>Math.round(10*e)/10,n=e.map(e=>({time:e.time,formattedTime:parseInt(e.time.includes("T")?e.time.split("T")[1].substring(0,5):e.time,10)+"h",temp:Math.round(e.temp),feelsLike:Math.round(e.feelsLike??e.temp),rainMm:i(e.rain??0),snowCm:i(e.snow??0),precipProb:e.precipProb??0})),[l,o]=r.useState(!0);r.useEffect(()=>{let e=window.matchMedia("(min-width: 640px)"),t=()=>o(e.matches);return(t(),"function"==typeof e.addEventListener)?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[]);let m=l?26:30,c=l&&1?Math.max(520,n.length*m):n.length*m;return(0,a.jsx)(R.Zp,{className:"w-full border-0 bg-transparent shadow-none overflow-hidden py-1 sm:py-2",children:(0,a.jsxs)(R.Wu,{className:"px-1 sm:px-2",children:[(0,a.jsxs)("div",{className:"relative w-full mt-4 sm:mt-6 h-[350px] sm:h-[400px]",children:[(0,a.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-[60]",children:[(0,a.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[32px] bg-background z-[-1]"}),(0,a.jsx)("div",{className:`absolute right-0 top-0 bottom-0 bg-background z-[-1] ${l?"w-[45px]":"w-[30px]"}`}),(0,a.jsx)(L.u,{width:"100%",height:"100%",children:(0,a.jsxs)(F.X,{data:n,margin:{top:10,right:0,left:0,bottom:0},children:[(0,a.jsx)(P.d,{strokeDasharray:"3 3",vertical:!1,stroke:"var(--color-border)",opacity:.5}),(0,a.jsx)(D.W,{dataKey:"time",tick:{fill:"transparent"},axisLine:!1,tickLine:!1}),(0,a.jsx)(I.h,{yAxisId:"left",width:32,axisLine:!1,tickLine:!1,tick:{fill:"var(--color-muted-foreground)",fontSize:10},tickFormatter:e=>String(Math.round(Number(e))),unit:"\xb0",domain:["dataMin - 2","dataMax + 2"]}),(0,a.jsx)(I.h,{yAxisId:"right",width:l?45:30,orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"var(--color-muted-foreground)",fontSize:10},tickFormatter:e=>Number(e).toFixed(1),label:{value:"mm/cm",angle:-90,position:"insideRight",fill:"var(--color-muted-foreground)",fontSize:10,className:"hidden sm:block"},hide:!1}),(0,a.jsx)(z.yP,{yAxisId:"right",dataKey:e=>e?.snowCm>0?e.snowCm:e.rainMm,opacity:0,isAnimationActive:!1}),(0,a.jsx)(K.N1,{yAxisId:"left",type:"monotone",dataKey:"temp",opacity:0,isAnimationActive:!1}),(0,a.jsx)(K.N1,{yAxisId:"left",type:"monotone",dataKey:"feelsLike",opacity:0,isAnimationActive:!1})]})})]}),(0,a.jsx)("div",{className:"chart-scroll-x w-full h-full",children:(0,a.jsx)("div",{className:"h-full",style:{minWidth:c},children:(0,a.jsx)(L.u,{width:"100%",height:"100%",children:(0,a.jsxs)(F.X,{data:n,margin:{top:10,right:0,left:0,bottom:0},children:[(0,a.jsx)(D.W,{dataKey:"time",tick:e=>{let{x:t,y:s,payload:r}=e,i=r.value,l=n.find(e=>e.time===i);if(!l)return null;let d=l.formattedTime;return(0,a.jsx)("g",{transform:`translate(${t},${s})`,children:(0,a.jsx)("text",{x:0,y:0,dy:16,textAnchor:"middle",fill:"var(--color-foreground)",fontSize:12,className:"font-medium",children:d})})}
1,interval:0,minTickGap:0,axisLine:!1,tickLine:!1}),(0,a.jsx)(I.h,{yAxisId:"left",width:32,axisLine:!1,tickLine:!1,tick:{fill:"transparent",fontSize:10},tickFormatter:e=>String(Math.round(Number(e))),unit:"\xb0",domain:["dataMin - 2","dataMax + 2"]}),(0,a.jsx)(I.h,{yAxisId:"right",width:l?45:30,orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"transparent",fontSize:10},tickFormatter:e=>Number(e).toFixed(1),label:{value:"",angle:-90,position:"insideRight"},hide:!1}),(0,a.jsx)($.m,{content:(0,a.jsx)(({active:e,payload:r,label:i})=>{if(e&&r&&r.length){let e=n.find(e=>e.time===i)||r[0].payload,l=Number(e?.rainMm??0),o=Number(e?.snowCm??0),m=Math.round(Number(r.find(e=>"temp"===e.dataKey)?.value??0)),c=Math.round(Number(r.find(e=>"feelsLike"===e.dataKey)?.value??0));return(0,a.jsxs)("div",{className:"bg-card border border-border p-1.5 sm:p-3 rounded-md sm:rounded-lg shadow-lg text-[10px] sm:text-sm z-[100] flex flex-col sm:gap-1",children:[(0,a.jsx)("p",{className:"hidden sm:block font-semibold mb-2 capitalize",children:e.formattedTime}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 sm:space-y-1",children:[(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-full bg-red-500 shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Temp:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[m,"\xb0",(0,a.jsx)("span",{className:"hidden sm:inline",children:"C"})]})]}),(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-full bg-blue-500 shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Sensaci\xf3n:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[c,"\xb0",(0,a.jsx)("span",{className:"hidden sm:inline",children:"C"})]})]}),l>0&&(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-sm opacity-70 shrink-0",style:{backgroundColor:t}}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Lluvia:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[l.toFixed(1),(0,a.jsx)("span",{className:"hidden sm:inline",children:" mm"})]})]}),o>0&&(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-sm opacity-70 shrink-0",style:{backgroundColor:s}}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Nieve:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[o.toFixed(1),(0,a.jsx)("span",{className:"hidden sm:inline",children:" cm"})]})]}),(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[(0,a.jsx)(d.A,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline text-muted-foreground",children:"Prob:"})]}),(0,a.jsxs)("span",{className:"text-muted-foreground font-medium",children:[e?.precipProb??0,"%"]})]})]})]})}return null},{}),cursor:{stroke:"var(--color-border)",strokeWidth:1},isAnimationActive:!1,wrapperStyle:{pointerEvents:"none",zIndex:100}}),(0,a.jsx)(z.yP,{isAnimationActive:!1,yAxisId:"right",dataKey:e=>e?.snowCm>0?e.snowCm:e.rainMm,fill:t,radius:[4,4,0,0],barSize:l?14:18,opacity:.6,children:n.map((e,r)=>(0,a.jsx)(W.f,{fill:e.snowCm>0?s:t,opacity:e.snowCm>0?.65:.6},`cell-${r}`))}),(0,a.jsx)(K.N1,{isAnimationActive:!1,yAxisId:"left",type:"monotone",dataKey:"feelsLike",stroke:"#3b82f6",strokeWidth:3,dot:{r:l?4:2.5,fill:"#3b82f6",strokeWidth:0},activeDot:{r:l?6:4,strokeWidth:0},name:"Sensaci\xf3n T\xe9rmica"}),(0,a.jsx)(K.N1,{isAnimationActive:!1,yAxisId:"left",type:"monotone",dataKey:"temp",stroke:"#ef4444",strokeWidth:3,dot:{r:l?4:2.5,fill:"#ef4444",strokeWidth:0},activeDot:{r:l?6:4,strokeWidth:0},name:"Temperatura"})]})})})})]}),(0,a.jsxs)("div",{className:"flex justify-center flex-wrap gap-x-3 gap-y-2 sm:gap-6 mt-3 sm:mt-4 mb-1 sm:mb-2 text-[10px] sm:text-xs text-muted-foreground px-2",children:[(0,a.jsxs)("div",{className:"flex w-full sm:hidden items-center justify-between px-6 pb-2 border-b border-border/50 mb-2",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"\xb0C"}),(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"mm/cm"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-1 bg-red-500 rounded-full"}),(0,a.jsx)("span",{children:"Temperatura"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-1 bg-blue-500 rounded-full"}),(0,a.jsx)("span",{children:"Sensaci\xf3n T\xe9rmica"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-3 rounded-sm opacity-70",style:{backgroundColor:t}}),(0,a.jsx)("span",{children:"Lluvia (mm)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-3 rounded-sm opacity-70",style:{backgroundColor:s}}),(0,a.jsx)("span",{children:"Nieve (cm)"})]})]})]})})}var G=s(72055),H=s(79328),U=s(26179),_=s(66088),Z=s(5692),V=s(75458),X=s(27055),q=s(19820);let B=q.bL,Q=q.R6,J=q.Ke;function Y({dayData:e,hourlyData:t,defaultOpen:s=!1}){let[i,n]=(0,r.useState)(s),[l,d]=(0,r.useState)("table"),[o,m]=(0,r.useState)(!1);(0,r.useEffect)(()=>{m(!0)},[]);let c=h(e.condition),x=new Date(e.date),u=(0,Z.GP)(x,"EEE d",{locale:X.es}),p=(0,Z.GP)(x,"dd MMMM yyyy",{locale:X.es}),f=e.date===(0,V.S)(),b=o?(0,V.Dq)():-1,j=o&&f?`${b.toString().padStart(2,"0")}:00`:void 0;return(0,a.jsxs)(B,{open:i,onOpenChange:n,className:"w-full bg-card/95 backdrop-blur-sm border border-border/50 rounded-xl overflow-hidden shadow-sm transition-all duration-300 hover:border-primary/20 hover:shadow-md",children:[(0,a.jsx)(Q,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex flex-row items-center justify-between p-3 sm:p-4 cursor-pointer hover:bg-muted/30 transition-colors group gap-2 sm:gap-4 scroll-mt-24",children:[(0,a.jsx)("div",{className:"contents md:flex md:items-center md:gap-4 md:min-w-[140px]",children:(0,a.jsxs)("div",{className:"contents md:flex md:flex-row md:items-center md:gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col shrink-0 items-start",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center md:hidden",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase font-bold text-muted-foreground leading-none mb-0.5",children:(0,Z.GP)(x,"EEE",{locale:X.es}).replace(".","")}),(0,a.jsx)("span",{className:"text-base font-bold leading-none",children:(0,Z.GP)(x,"dd/MM",{locale:X.es})})]}),(0,a.jsx)("span",{className:"hidden md:block text-lg font-medium capitalize leading-tight",children:u}),(0,a.jsx)("span",{className:"hidden md:block text-xs text-muted-foreground capitalize",children:p})]}),(0,a.jsx)("div",{className:"flex flex-col items-center justify-center w-12 md:w-12 text-center shrink-0",children:e.icon?(0,a.jsx)("img",{src:e.icon,alt:e.condition,className:"w-12 h-12 md:w-10 md:h-10 object-contain mb-0 sm:mb-1 group-hover:scale-110 transition-transform"}):(0,a.jsx)(c,{className:"w-10 h-10 md:w-8 md:h-8 text-primary mb-0 sm:mb-1 group-hover:scale-110 transition-transform",strokeWidth:1.5})})]})}),(0,a.jsxs)("div",{className:"contents md:flex md:flex-1 md:items-center md:justify-evenly md:gap-0",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("span",{className:"hidden md:block text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:"Min/M\xe1x"}),(0,a.jsxs)("div",{className:"flex flex-col md:flex-row items-center gap-1 md:gap-2",children:[(0,a.jsxs)("span",{className:"text-white font-bold text-sm md:text-base px-2 py-0.5 rounded shadow-sm w-11 text-center",style:S(e.maxTemp),children:[Math.round(e.maxTemp),"\xb0"]}),(0,a.jsx)("span",{className:"hidden md:inline text-muted-foreground
1/40",children:"/"}),(0,a.jsxs)("span",{className:"text-white font-bold text-sm md:text-base px-2 py-0.5 rounded shadow-sm w-11 text-center",style:S(e.minTemp),children:[Math.round(e.minTemp),"\xb0"]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col md:flex-row items-center gap-2 md:gap-8 min-w-[70px] md:min-w-0 md:flex-grow-0 justify-center",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("span",{className:"hidden md:block text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:"Viento km/h"}),(0,a.jsxs)("div",{className:(0,g.cn)("flex items-center gap-1.5 px-1.5 py-0.5 rounded-md transition-colors",E(e.maxWindSpeed||0)),children:[(0,a.jsx)(y.A,{className:"w-4 h-4 md:w-3.5 md:h-3.5 text-current opacity-80"}),(0,a.jsx)("span",{className:"font-bold text-sm md:text-base",children:Math.round(e.maxWindSpeed||0)}),(0,a.jsx)(G.A,{className:"w-3 h-3 text-current opacity-60 hidden md:block",style:{transform:`rotate(${e.windDegMean||0}deg)`}})]})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("span",{className:"hidden md:block text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:e.snowTotal&&e.snowTotal>0?"Nieve":"Lluvia"}),(0,a.jsx)("div",{className:(0,g.cn)("flex items-center gap-1.5 px-1.5 py-0.5 rounded-md transition-colors",C(e.snowTotal&&e.snowTotal>0?e.snowTotal:e.totalPrecip||0,!!(e.snowTotal&&e.snowTotal>0))),children:e.snowTotal&&e.snowTotal>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(M.A,{className:(0,g.cn)("w-4 h-4 md:w-3.5 md:h-3.5",C(e.snowTotal,!0)?"text-current":"text-blue-300")}),(0,a.jsx)("span",{className:"font-bold text-sm md:text-base",children:e.snowTotal.toFixed(1)})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.A,{className:(0,g.cn)("w-4 h-4 md:w-3.5 md:h-3.5",C(e.totalPrecip||0,!1)?"text-current":"text-blue-500")}),(0,a.jsx)("span",{className:"font-bold text-sm md:text-base",children:(e.totalPrecip||0).toFixed(1)})]})})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[i&&(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-center bg-muted/50 rounded-lg p-0.5 border border-border/30 mr-1 sm:mr-2",onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,a.jsx)("button",{className:(0,g.cn)("p-1.5 rounded-md transition-all","table"===l?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:e=>{e.preventDefault(),e.stopPropagation(),d("table")},title:"Vista de tabla",children:(0,a.jsx)(H.A,{className:"w-4 h-4"})}),(0,a.jsx)("button",{className:(0,g.cn)("p-1.5 rounded-md transition-all","chart"===l?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:e=>{e.preventDefault(),e.stopPropagation(),d("chart")},title:"Vista de gr\xe1fica",children:(0,a.jsx)(U.A,{className:"w-4 h-4"})})]}),(0,a.jsx)("div",{className:(0,g.cn)("p-2 rounded-full hover:bg-muted transition-transform duration-300",i?"rotate-180 bg-muted":""),children:(0,a.jsx)(_.A,{className:"w-4 h-4 text-muted-foreground"})})]})]})}),(0,a.jsx)(J,{children:(0,a.jsx)("div",{className:"border-t border-border/30 bg-muted/10",children:"table"===l?(0,a.jsx)(T,{hourlyData:t,scrollTargetHour:j}):(0,a.jsx)("div",{className:"p-2 sm:p-4",children:(0,a.jsx)(O,{data:t})})})})]})}function ee({daily:e,hourly:t}){let s=(0,V.S)(),r=e.filter(e=>(e.date||"").slice(0,10)>=s);return 0===r.length?(0,a.jsx)("div",{className:"p-8 text-center border rounded-lg bg-muted/20",children:(0,a.jsx)("p",{className:"text-muted-foreground animate-pulse",children:"Actualizando datos meteorol\xf3gicos..."})}):(0,a.jsx)("div",{className:"space-y-3",children:r.map((e,s)=>{let r,i=(r=e.date,t.filter(e=>e.datetime.startsWith(r)));return(0,a.jsx)(Y,{dayData:e,hourlyData:i,defaultOpen:0===s},e.date)})})}var et=s(49804);function es({data:e,hourly:t}){let[s,i]=r.useState("daily"),n="var(--color-weather-rain)",l="var(--color-weather-snow)",o=e=>Math.round(10*e)/10,m=r.useMemo(()=>{if("hourly"===s&&t&&t.length>0){let s=new Map,a=new Date,r=-1;
1t.forEach(e=>{let t=new Date(e.datetime);if(isNaN(t.getTime())&&(t=new Date(e.time)),isNaN(t.getTime())&&e.time){let s=e.time.match(/^(\d{1,2}):(\d{2})$/);if(s){let e=parseInt(s[1],10);-1!==r&&e<r&&a.setDate(a.getDate()+1),r=e,(t=new Date(a)).setHours(e,0,0,0)}}if(isNaN(t.getTime()))return;let i=Math.floor(t.getHours()/6);t.setHours(6*i+3,0,0,0);let n=t.toISOString();s.has(n)||s.set(n,[]),s.get(n).push(e)});let i=new Set(e.map(e=>e.date));return Array.from(s.entries()).filter(([e,t])=>{let s=e.substring(0,10);return i.has(s)}).map(([e,t])=>{let s=t.reduce((e,t)=>e+t.temp,0)/t.length,a=t.reduce((e,t)=>e+(t.feelsLike??t.temp),0)/t.length,r=t.reduce((e,t)=>e+(t.rain??0),0),i=t.reduce((e,t)=>e+(t.snow??0),0),n=Math.max(...t.map(e=>e.precipProb??0));return{date:e,formattedDate:(0,Z.GP)(new Date(e),"EEE d HH:mm",{locale:X.es}),isHourly:!0,maxTemp:Math.round(s),minTemp:Math.round(a),rainMm:o(r),snowCm:o(i),precipProb:Math.round(n)}})}return e.map(e=>({date:e.date,formattedDate:(0,Z.GP)(new Date(e.date),"EEE d",{locale:X.es}),isHourly:!1,maxTemp:Math.round(e.maxTemp),minTemp:Math.round(e.minTemp),rainMm:o(e.totalPrecip??0),snowCm:o(e.snowTotal??0),precipProb:e.precipProb}))},[e,t,s]),[c,x]=r.useState(!0);r.useEffect(()=>{let e=window.matchMedia("(min-width: 640px)"),t=()=>x(e.matches);return(t(),"function"==typeof e.addEventListener)?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[]);let u=c?26:"hourly"===s?14:30,p=c&&1?Math.max(520,m.length*u):m.length*u,h=c?14:"hourly"===s?10:18;return(0,a.jsxs)(R.Zp,{className:"w-full border-0 bg-transparent shadow-none relative overflow-hidden py-1 sm:py-2",children:[t&&t.length>0&&(0,a.jsxs)("div",{className:"absolute top-1 right-2 sm:top-2 sm:right-4 z-[50] bg-background/80 backdrop-blur rounded-lg border border-border shadow-sm flex items-center p-1",children:[(0,a.jsx)("button",{onClick:()=>i("daily"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${"daily"===s?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:"Diario"}),(0,a.jsx)("button",{onClick:()=>i("hourly"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${"hourly"===s?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:"6h"})]}),(0,a.jsxs)(R.Wu,{className:"px-1 sm:px-2",children:[(0,a.jsxs)("div",{className:"relative w-full mt-12 sm:mt-12 h-[350px] sm:h-[400px]",children:[(0,a.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-[60]",children:[(0,a.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[32px] bg-background z-[-1]"}),(0,a.jsx)("div",{className:`absolute right-0 top-0 bottom-0 bg-background z-[-1] ${c?"w-[45px]":"w-[30px]"}`}),(0,a.jsx)(L.u,{width:"100%",height:"100%",children:(0,a.jsxs)(F.X,{data:m,margin:{top:10,right:0,left:0,bottom:0},children:[(0,a.jsx)(P.d,{strokeDasharray:"3 3",vertical:!1,stroke:"var(--color-border)",opacity:.5}),(0,a.jsx)(D.W,{dataKey:"date",tick:{fill:"transparent"},axisLine:!1,tickLine:!1,dy:10,height:50}),(0,a.jsx)(I.h,{yAxisId:"left",width:32,axisLine:!1,tickLine:!1,tick:{fill:"var(--color-muted-foreground)",fontSize:10},tickFormatter:e=>String(Math.round(Number(e))),unit:"\xb0"}),(0,a.jsx)(I.h,{yAxisId:"right",width:c?45:30,orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"var(--color-muted-foreground)",fontSize:10},tickFormatter:e=>Number(e).toFixed(1),label:{value:"mm/cm",angle:-90,position:"insideRight",fill:"var(--color-muted-foreground)",fontSize:10,className:"hidden sm:block"},hide:!1}),(0,a.jsx)(z.yP,{yAxisId:"right",dataKey:"snowCm",stackId:"precip",opacity:0,isAnimationActive:!1}),(0,a.jsx)(z.yP,{yAxisId:"right",dataKey:"rainMm",stackId:"precip",opacity:0,isAnimationActive:!1}),(0,a.jsx)(K.N1,{yAxisId:"left",type:"monotone",dataKey:"maxTemp",stroke:"transparent",dot:!1,activeDot:!1,isAnimationActive:!1}),(0,a.jsx)(K.N1,{yAxisId:"left",type:"monotone",dataKey:"minTemp",stroke:"transparent",dot:!1,activeDot:!1,isAnimationActive:!1})]})})]}),(0,a.jsx)("div",{className:"chart-scroll-x w-full h-full",children:(0,a.jsx)("div",{className:"h-full",style:{minWidth:p},children:(0,a.jsx)(L.u,{width:"100%",height:"100%",children:(0,a.jsxs)(F.X,{data:m,barCategoryGap:c?"10%":"5%",margin:{top:10,right:0,left:0,bottom:10},children:[(0,a.jsx)("defs",{children:(0,a.jsxs)("linearGradient",{id:"colorTempMax",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",
1stopColor:"var(--color-weather-alert)",stopOpacity:.8}),(0,a.jsx)("stop",{offset:"95%",stopColor:"var(--color-weather-alert)",stopOpacity:0})]})}),(0,a.jsx)(D.W,{dataKey:"date",tick:e=>{let t,{x:r,y:i,payload:n}=e,l=n.value,d=!0;if("hourly"===s?(isNaN((t=new Date(l)).getTime())||15!==t.getHours())&&(d=!1):isNaN((t=new Date(l)).getTime())&&(d=!1),!d)return null;let o=(0,Z.GP)(t,"dd",{locale:X.es}),m=(0,Z.GP)(t,"EEE",{locale:X.es}).toUpperCase();return(0,a.jsxs)("g",{transform:`translate(${r},${i})`,children:[(0,a.jsx)("text",{x:0,y:0,dy:16,textAnchor:"middle",fill:"var(--color-foreground)",fontSize:13,className:"font-semibold",children:o}),(0,a.jsx)("text",{x:0,y:0,dy:32,textAnchor:"middle",fill:"var(--color-muted-foreground)",fontSize:11,className:"font-medium",children:m})]})},interval:0,minTickGap:0,axisLine:!1,tickLine:!1,height:50}),(0,a.jsx)(I.h,{yAxisId:"left",width:32,axisLine:!1,tickLine:!1,tick:{fill:"transparent",fontSize:12},tickFormatter:e=>String(Math.round(Number(e))),unit:"\xb0"}),(0,a.jsx)(I.h,{yAxisId:"right",width:c?45:30,orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"transparent",fontSize:12},tickFormatter:e=>Number(e).toFixed(1),label:{value:"mm/cm",angle:-90,position:"insideRight",fill:"transparent",fontSize:12},hide:!1}),(0,a.jsx)($.m,{content:(0,a.jsx)(({active:e,payload:t,label:s})=>{if(e&&t&&t.length){let e=t?.[0]?.payload,r=e?.isHourly,i="";i=r&&s.includes("T")?(0,Z.GP)(new Date(s),"EEEE d 'de' MMMM, HH:mm",{locale:X.es}):r?s:(0,Z.GP)(new Date(s),"EEEE d 'de' MMMM",{locale:X.es});let o=Number(e?.rainMm??0),m=Number(e?.snowCm??0),c=Math.round(Number(t.find(e=>"maxTemp"===e.dataKey)?.value??0)),x=Math.round(Number(t.find(e=>"minTemp"===e.dataKey)?.value??0));return(0,a.jsxs)("div",{className:"bg-card border border-border p-1.5 sm:p-3 rounded-md sm:rounded-lg shadow-lg text-[10px] sm:text-sm z-[100] flex flex-col sm:gap-1",children:[(0,a.jsx)("p",{className:"hidden sm:block font-semibold mb-2 capitalize",children:i}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 sm:space-y-1",children:[(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-full bg-red-500 shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:r?"Temp:":"M\xe1x:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[c,"\xb0",(0,a.jsx)("span",{className:"hidden sm:inline",children:"C"})]})]}),(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-full bg-blue-500 shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:r?"Sensaci\xf3n:":"M\xedn:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[x,"\xb0",(0,a.jsx)("span",{className:"hidden sm:inline",children:"C"})]})]}),o>0&&(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-sm opacity-70 shrink-0",style:{backgroundColor:n}}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Lluvia:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[o.toFixed(1),(0,a.jsx)("span",{className:"hidden sm:inline",children:" mm"})]})]}),m>0&&(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-2 h-2 sm:w-3 sm:h-3 rounded-sm opacity-70 shrink-0",style:{backgroundColor:l}}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Nieve:"})]}),(0,a.jsxs)("span",{className:"font-medium",children:[m.toFixed(1),(0,a.jsx)("span",{className:"hidden sm:inline",children:" cm"})]})]}),(0,a.jsxs)("p",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[(0,a.jsx)(d.A,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"hidden sm:inline text-muted-foreground",children:"Prob:"})]}),(0,a.jsxs)("span",{className:"text-muted-foreground font-medium",children:[e?.precipProb??0,"%"]})]})]})]})}return null},{}),cursor:{stroke:"var(--color-border)",strokeWidth:1},isAnimationActive:!1,wrapperStyle:{pointerEvents:"none",zIndex:100}}),(0,a.jsx)(z.yP,{isAnimationActive:!1,yAxisId:"right",dataKey:"snowCm",stackId:"precip",fill:l,barSize:h,opacity:.65,shape:e=>{let{x:t,y:s,width:r,height:i,payload:n,fill:l,opacity:d}=e;return!i||i<=0?null:(n.rainMm,(0,a.jsx)(et.M,{x:t,y:s,width:r,height:i,fill:l,opacity:d,radius:[4,4,0,0]}))}}),(0,a.jsx)(z.yP,{isAnimationActive:!1,yAxisId:"right",dataKey:"rainMm",stackId:"precip",fill:n,barSize:h,opacity:.6,shape:e=>{let{x:t,y:s,width:r,height:i,payload:n,fill:l,opacity:d}=e;if(!i||i<=0)return null;let o=n.rainMm>0&&n.snowCm>0;return(0,a.jsx)(et.M,{x:t,y:s,width:r,height:Math.max(0,i-2*!!o),fill:l,opacity:d,radius:o?[4,4,4,4]:[4,4,0,0]})}}),(0,a.jsx)(K.N1,{isAnimationActive:!1,yAxisId:"left",type:"monotone",dataKey:"maxTemp",stroke:"#ef4444",strokeWidth:3,dot:{r:4,fill:"#ef4444",strokeWidth:0},activeDot:{r:6,strokeWidth:0},name:"hourly"===s?"Temperatura":"M\xe1xima"}),(0,a.jsx)(K.N1,{isAnimationActive:!1,yAxisId:"left",type:"monotone",dataKey:"minTemp",stroke:"#3b82f6",strokeWidth:3,dot:{r:4,fill:"#3b82f6",strokeWidth:0},activeDot:{r:6,strokeWidth:0},name:"hourly"===s?"Sensaci\xf3n T\xe9rmica":"M\xednima"})]})})})})]}),(0,a.jsxs)("div",{className:"flex justify-center flex-wrap gap-x-3 gap-y-2 sm:gap-6 mt-3 sm:mt-4 mb-1 sm:mb-2 text-[10px] sm:text-xs text-muted-foreground px-2",children:[(0,a.jsxs)("div",{className:"flex w-full sm:hidden items-center justify-between px-6 pb-2 border-b border-border/50 mb-2",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"\xb0C"}),(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"mm/cm"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-1 bg-red-500 rounded-full"}),(0,a.jsx)("span",{children:"hourly"===s?"Temperatura":"Temp. M\xe1xima"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-1 bg-blue-500 rounded-full"}),(0,a.jsx)("span",{children:"hourly"===s?"Sensaci\xf3n T\xe9rmica":"Temp. M\xednima"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-3 rounded-sm opacity-70",style:{backgroundColor:n}}),(0,a.jsx)("span",{children:"Lluvia (mm)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)("div",{className:"w-3 h-3 rounded-sm opacity-70",style:{backgroundColor:l}}),(0,a.jsx)("span",{children:"Nieve (cm)"})]})]})]})]})}var ea=s(53459),er=s(6296),ei=s(91958);let en=["asturmet","ecmwf","gfs"];function el(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function ed(e){let t=el(e?.maxTemp),s=el(e?.minTemp);return{maximum:t,minimum:s,range:null===t||null===s?null:[s,t],precipitation:el(e?.totalPrecip)}}let eo={asturmet:{label:"ASTURMET",color:"#2563eb",maximumKey:"asturmetMax",minimumKey:"asturmetMin",rangeKey:"asturmetRange",precipitationKey:"asturmetPrecip"},ecmwf:{label:"ECMWF",color:"#059669",maximumKey:"ecmwfMax",minimumKey:"ecmwfMin",rangeKey:"ecmwfRange",precipitationKey:"ecmwfPrecip"},gfs:{label:"GFS",color:"#7c3aed",maximumKey:"gfsMax",minimumKey:"gfsMin",rangeKey:"gfsRange",precipitationKey:"gfsPrecip"}},em=["ecmwf","gfs"];function ec(e,t){return(0,Z.GP)(new Date(`${e}T12:00:00`),t,{locale:X.es})}function ex(e,t){return"number"==typeof e&&Number.isFinite(e)?`${Math.round(10*e)/10} ${t}`:"â"}function eu({active:e,label:t,payload:s,unit:r}){if(!e||!s?.length||"string"!=typeof t)return null;let i=s.filter(e=>!String(e.dataKey).endsWith("Range")&&"number"==typeof e.value&&Number.isFinite(e.value));return 0===i.length?null:(0,a.jsxs)("div",{className:"min-w-48 rounded-xl border border-border bg-card p-3 text-xs text-card-foreground shadow-lg sm:text-sm",children:[(0,a.jsx)("p",{className:"mb-2 font-semibold capitalize",children:ec(t,"EEEE d 'de' MMMM")}),(0,a.jsx)("ul",{className:"space-y-1.5",children:i.map(e=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-4",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color}}),e.name]}),(0,a.jsx)("span",{className:"font-semibold tabular-nums",children:ex(e.value,r)})]},String(e.dataKey)))})]})}function ep({failed:e,forecasts:t,loading:s,onToggle:r,visibleModels:i}){let n=en.filter(e=>t[e]&&i.has(e)).length;return(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Modelos visibles"}),(0,a.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",role:"group","aria-label":"Alternar modelos de la comparativa",children:en.map(l=>{let d=eo[l],o=!!t[l],m=i.has(l),c=m&&o&&1===n,x=e.includes(l)?"No disponible":s.includes(l)?"Cargando":o?m?"Visible":"Oculto":"Pendiente";return(0,a.jsxs)("button",{type:"button","aria-label":`Alternar modelo ${d.label}`,"aria-pressed":m&&o,disabled:!o||c,onClick:()=>r(l),className:(0,g.cn)("flex min-h-11 items-center justify-between gap-3 rounded-xl border px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",m&&o?"border-border bg-card text-foreground shadow-sm":"border-border bg-muted/40 text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-70"),children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 rounded-sm",style:{backgroundColor:d.color}}),d.label]}),(0,a.jsx)("span",{className:"text-right text-xs font-normal text-muted-foreground",children:x})]},l)})})]})}function eh({rows:e,visibleModels:t}
1){return(0,a.jsxs)("section",{"aria-labelledby":"comparison-temperature-heading",className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{id:"comparison-temperature-heading",className:"text-base font-semibold sm:text-lg",children:"Temperatura (\xb0C)"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"M\xe1xima en l\xednea continua, m\xednima discontinua y rango previsto sombreado."})]}),(0,a.jsx)("div",{className:"chart-scroll-x rounded-xl border border-border bg-card p-2 sm:p-4","aria-label":"Gr\xe1fica comparativa de temperaturas m\xe1ximas y m\xednimas",children:(0,a.jsx)("div",{className:"h-[310px] min-w-[860px] sm:h-[340px]",children:(0,a.jsx)(L.u,{width:"100%",height:"100%",minWidth:0,initialDimension:{width:860,height:310},children:(0,a.jsxs)(F.X,{data:e,margin:{top:12,right:18,bottom:4,left:-8},children:[(0,a.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--color-border)"}),(0,a.jsx)(D.W,{dataKey:"date",tickFormatter:e=>ec(e,"d EEE"),tick:{fill:"var(--color-muted-foreground)",fontSize:12},axisLine:{stroke:"var(--color-border)"},tickLine:!1}),(0,a.jsx)(I.h,{tick:{fill:"var(--color-muted-foreground)",fontSize:12},tickFormatter:e=>`${Math.round(e)}\xb0`,axisLine:!1,tickLine:!1,domain:["dataMin - 2","dataMax + 2"]}),(0,a.jsx)($.m,{content:(0,a.jsx)(eu,{unit:"\xb0C"})}),en.filter(e=>t.has(e)).map(e=>{let t=eo[e];return(0,a.jsx)(ea.Gk,{type:"monotone",dataKey:t.rangeKey,name:`${t.label} intervalo`,stroke:"none",fill:t.color,fillOpacity:.1,connectNulls:!1,isAnimationActive:!1},`${e}-range`)}),en.filter(e=>t.has(e)).flatMap(e=>{let t=eo[e];return[(0,a.jsx)(K.N1,{type:"monotone",dataKey:t.maximumKey,name:`${t.label} m\xe1xima`,stroke:t.color,strokeWidth:2.5,dot:{r:2.5,fill:t.color},activeDot:{r:5},connectNulls:!1,isAnimationActive:!1},`${e}-maximum`),(0,a.jsx)(K.N1,{type:"monotone",dataKey:t.minimumKey,name:`${t.label} m\xednima`,stroke:t.color,strokeWidth:2,strokeDasharray:"6 5",dot:!1,activeDot:{r:5},connectNulls:!1,isAnimationActive:!1},`${e}-minimum`)]})]})})})})]})}function ef({rows:e,visibleModels:t}){return(0,a.jsxs)("section",{"aria-labelledby":"comparison-precipitation-heading",className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{id:"comparison-precipitation-heading",className:"text-base font-semibold sm:text-lg",children:"Precipitaci\xf3n (mm)"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Acumulaci\xf3n diaria prevista por cada modelo."})]}),(0,a.jsx)("div",{className:"chart-scroll-x rounded-xl border border-border bg-card p-2 sm:p-4","aria-label":"Gr\xe1fica comparativa de precipitaci\xf3n diaria",children:(0,a.jsx)("div",{className:"h-[250px] min-w-[860px] sm:h-[280px]",children:(0,a.jsx)(L.u,{width:"100%",height:"100%",minWidth:0,initialDimension:{width:860,height:250},children:(0,a.jsxs)(F.X,{data:e,margin:{top:12,right:18,bottom:4,left:-8},children:[(0,a.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--color-border)"}),(0,a.jsx)(D.W,{dataKey:"date",tickFormatter:e=>ec(e,"d EEE"),tick:{fill:"var(--color-muted-foreground)",fontSize:12},axisLine:{stroke:"var(--color-border)"},tickLine:!1}),(0,a.jsx)(I.h,{unit:" mm",tick:{fill:"var(--color-muted-foreground)",fontSize:12},axisLine:!1,tickLine:!1,domain:[0,"dataMax + 2"]}),(0,a.jsx)($.m,{content:(0,a.jsx)(eu,{unit:"mm"})}),en.filter(e=>t.has(e)).map(e=>{let t=eo[e];return(0,a.jsx)(z.yP,{dataKey:t.precipitationKey,name:`${t.label} precipitaci\xf3n`,fill:t.color,radius:[4,4,0,0],maxBarSize:22,isAnimationActive:!1},e)})]})})})})]})}function eb({rows:e}){return(0,a.jsxs)("details",{className:"rounded-xl border border-border bg-card",children:[(0,a.jsx)("summary",{className:"min-h-11 cursor-pointer px-4 py-3 text-sm font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary",children:"Ver valores en tabla"}),(0,a.jsx)("div",{className:"overflow-x-auto border-t border-border",children:(0,a.jsxs)("table",{className:"min-w-[860px] border-collapse text-left text-xs sm:text-sm",children:[(0,a.jsx)("caption",{className:"sr-only",children:"Comparativa diaria de m\xe1ximas, m\xednimas y precipitaci\xf3n por modelo"}),(0,a.jsxs)("thead",{children:[(0,a.jsxs)("tr",{className:"bg-muted/70",children:[(0,a.jsx)("th",{rowSpan:2,scope:"col",className:"border-b border-r border-border px-3 py-2",children:"D\xeda"}),en.map(e=>(0,a.jsx)("th",{colSpan:3,scope:"colgroup",className:"border-b border-r border-border px-3 py-2 text-center",children:eo[e].label},e))]}),(0,a.jsx)("tr",{className:"bg-muted/40 text-muted-foreground",children:en.flatMap(e=>[(0,a.jsx)("th",{scope:"col",className:"border-b border-border px-3 py-2",children:"M\xe1x."},`${e}-max`),(0,a.jsx)("th",{scope:"col",className:"border-b border-border px-3 py-2",children:"M\xedn."},`${e}-min`),(0,a.jsx)("th",{scope:"col",className:"border-b border-r border-border px-3 py-2",children:"Lluvia"},`${e}-rain`)])})]}),(0,a.jsx)("tbody",{children:e.map(e=>(0,a.jsxs)("tr",{className:"odd:bg-muted/20",children:[(0,a.jsx)("th",{scope:"row",className:"whitespace-nowrap border-r border-border px-3 py-2 font-medium capitalize",children:ec(e.date,"EEE d MMM")}),en.flatMap(t=>{let s=eo[t];return[(0,a.jsx)("td",{className:"px-3 py-2 tabular-nums",children:ex(e[s.maximumKey],"\xb0C")},`${t}-max`),(0,a.jsx)("td",{className:"px-3 py-2 tabular-nums",children:ex(e[s.minimumKey],"\xb0C")},`${t}-min`),(0,a.jsx)("td",{className:"border-r border-border px-3 py-2 tabular-nums",children:ex(e[s.precipitationKey],"mm")},`${t}-rain`)]})]},e.date))})]})})]})}function eg({initialData:e,locationSlug:t,locationName:s}){let[i,n]=(0,r.useState)({asturmet:e}),[d,o]=(0,r.useState)([]),[m,c]=(0,r.useState)(em),[x,u]=(0,r.useState)(()=>({id:0,models:em})),[p,h]=(0,r.useState)(()=>new Set(en));(0,r.useEffect)(()=>{let e=x.models;if(0===e.length)return;let s=!0;return Promise.allSettled(e.map(e=>l.S.getForecast(t,e))).then(t=>
1{s&&(n(s=>{let a={...s};return t.forEach((t,s)=>{"fulfilled"===t.status&&(a[e[s]]=t.value)}),a}),o(t.flatMap((t,s)=>"rejected"===t.status?[e[s]]:[])),c([]))}),()=>{s=!1}},[t,x]);let f=(0,r.useMemo)(()=>(function(e,t,s=14){let a=new Set,r=new Map;for(let s of en){let i=new Map;for(let r of e[s]?.daily??[])r.date<t||(a.add(r.date),i.set(r.date,r));r.set(s,i)}return Array.from(a).sort((e,t)=>e.localeCompare(t)).slice(0,Math.max(0,s)).map(e=>{let t=ed(r.get("asturmet")?.get(e)),s=ed(r.get("ecmwf")?.get(e)),a=ed(r.get("gfs")?.get(e));return{date:e,asturmetMax:t.maximum,asturmetMin:t.minimum,asturmetRange:t.range,asturmetPrecip:t.precipitation,ecmwfMax:s.maximum,ecmwfMin:s.minimum,ecmwfRange:s.range,ecmwfPrecip:s.precipitation,gfsMax:a.maximum,gfsMin:a.minimum,gfsRange:a.range,gfsPrecip:a.precipitation}})})(i,(0,V.S)()),[i]);return(0,a.jsxs)("div",{className:"space-y-6 rounded-2xl border border-border bg-muted/20 p-3 sm:p-5",children:[(0,a.jsxs)("header",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold sm:text-xl",children:"Comparativa de modelos"}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:["Predicci\xf3n de m\xe1xima, m\xednima y precipitaci\xf3n durante 14 d\xedas en ",s,"."]})]}),(0,a.jsx)(ep,{failed:d,forecasts:i,loading:m,onToggle:e=>{h(t=>{let s=new Set(t);if(s.has(e)){if(1===s.size)return t;s.delete(e)}else s.add(e);return s})},visibleModels:p}),m.length>0&&(0,a.jsxs)("div",{role:"status","aria-live":"polite",className:"flex items-center gap-2 rounded-xl border border-border bg-card px-4 py-3 text-sm",children:[(0,a.jsx)(er.A,{className:"h-4 w-4 animate-spin text-primary","aria-hidden":"true"}),"Cargando ",m.map(e=>eo[e].label).join(" y "),"â¦"]}),d.length>0&&0===m.length&&(0,a.jsxs)("div",{role:"alert",className:"flex flex-col gap-3 rounded-xl border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("p",{children:["No se pudieron cargar ",d.map(e=>eo[e].label).join(" y "),". Los dem\xe1s modelos siguen disponibles."]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{let e=d.filter(e=>!i[e]);o([]),c(e),u(t=>({id:t.id+1,models:e}))},className:"inline-flex min-h-11 shrink-0 items-center justify-center gap-2 rounded-lg border border-current px-3 font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[(0,a.jsx)(ei.A,{className:"h-4 w-4","aria-hidden":"true"}),"Reintentar modelos pendientes"]})]}),f.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eh,{rows:f,visibleModels:p}),(0,a.jsx)(ef,{rows:f,visibleModels:p}),(0,a.jsx)(eb,{rows:f}),(0,a.jsx)("p",{className:"rounded-xl bg-sky-50 px-4 py-3 text-xs leading-relaxed text-sky-950 dark:bg-sky-950/40 dark:text-sky-100 sm:text-sm",children:"Cuando los tres modelos se aproximan existe mayor acuerdo entre predicciones. Sus diferencias muestran dispersi\xf3n entre modelos, no una probabilidad calculada."})]}):0===m.length?(0,a.jsx)("p",{role:"alert",className:"rounded-xl border border-border bg-card px-4 py-5 text-sm",children:"No hay d\xedas disponibles para construir la comparativa."}):null]})}var ej=s(93219);function eN({data:e,locationName:t}){let[s,i]=(0,r.useState)(!1),[n,l]=(0,r.useState)(null);if((0,r.useEffect)(()=>{i(!0),l(new Date);let e=setInterval(()=>{l(new Date)},6e4);return()=>clearInterval(e)},[]),!s||!n)return(0,a.jsx)("div",{className:"bg-card/95 backdrop-blur-md rounded-xl border border-border/50 overflow-hidden h-[300px] animate-pulse"});let{dateStr:d,hourStr:o,hour:m}={dateStr:n.toLocaleDateString("en-CA",{timeZone:"Europe/Madrid"}),hour:parseInt(n.toLocaleTimeString("en-GB",{timeZone:"Europe/Madrid",hour:"2-digit",hour12:!1})),hourStr:n.toLocaleTimeString("en-GB",{timeZone:"Europe/Madrid",hour:"2-digit",hour12:!1})+":00"},c=`${d}T${m.toString().padStart(2,"0")}`,x=e.hourly?.find(e=>e.datetime?.startsWith(c)),u=x?x.temp:e.current?.temp,p=x?x.feelsLike:e.current?.feelsLike,f=x?x.icon:e.current?.icon,b=x?x.condition:e.current?.condition,j=ej.A;if(b)try{j=h(b)}catch(e){}let v=e.daily.findIndex(e=>e.date===d);-1===v&&(v=0);let y=e.daily[v],w=e.daily[v+1]||e.daily[0],k=y.date,A=w.date;return(0,a.jsx)("div",{className:"bg-card/95 backdrop-blur-md rounded-xl border border-border/50 overflow-hidden text-card-foreground",children:(0,a.jsxs)("div",{className:"p-6 md:p-8 grid grid-cols-1 lg:grid-cols-2 items-center relative",children:[(0,a.jsx)("div",{className:"flex flex-col items-center justify-center gap-8 z-10 w-full h-full p-4 bg-blue-50/95 rounded-sm",children:(0,a.jsxs)("div",{className:"flex items-center gap-6",children:[f?(0,a.jsx)("img",{src:f,alt:b,className:"w-24 h-24 md:w-32 md:h-32 object-contain drop-shadow-md select-none"}):(0,a.jsx)(j,{className:"w-24 h-24 text-primary",strokeWidth:1.5}),(0,a.jsxs)("div",{className:"flex flex-col items-start",children:[(0,a.jsx)("span",{className:"text-lg font-medium text-muted-foreground
1/80 leading-none mb-1 ml-1",children:o}),(0,a.jsxs)("span",{className:"text-6xl tracking-tighter tabular-nums text-foreground leading-none",children:[void 0!==u?Math.round(u):"--","\xb0"]}),(0,a.jsxs)("span",{className:"text-sm font-light text-muted-foreground pl-1 mt-1 leading-tight",children:["Sensaci\xf3n de ",void 0!==p?Math.round(p):"--","\xb0"]})]})]})}),(0,a.jsx)("div",{className:"w-full z-10 pt-8 lg:pt-0 lg:pl-12",children:(0,a.jsx)("div",{className:"grid grid-cols-4 gap-0 divide-x divide-border/20 bg-background/30 rounded-lg p-2 md:p-6",children:[{label:"Ma\xf1ana",date:k,startHour:6,endHour:12},{label:"Tarde",date:k,startHour:12,endHour:18},{label:"Noche",date:k,startHour:18,endHour:24},{label:"Madrugada",date:A,startHour:0,endHour:6}].map((t,s)=>{var r,i,n;let l,d=(r=t.date,i=t.startHour,n=t.endHour,(l=(e.hourly??[]).filter(e=>"string"==typeof e.datetime&&e.datetime.startsWith(`${r}T`)).map(e=>({h:e,hour:(e=>{if("string"==typeof e?.datetime&&e.datetime.includes("T")){let t=Number(e.datetime.slice(11,13));return Number.isFinite(t)?t:null}if("string"==typeof e?.time){let t=e.time.match(/T(\d{2}):\d{2}/)??e.time.match(/^(\d{2}):\d{2}$/);if(t?.[1]){let e=Number(t[1]);return Number.isFinite(e)?e:null}}return null})(e)})).filter(e=>"number"==typeof e.hour).filter(e=>e.hour>=i&&e.hour<n)).sort((e,t)=>e.hour-t.hour),l.map(e=>e.h)),o=(e=>{let t,s=new Map;for(let t of e){let e="string"==typeof t?.icon?t.icon:null;e&&s.set(e,(s.get(e)??0)+1)}let a=1;for(let[e,r]of s.entries())r>a&&(a=r,t=e);return t})(d);if(0===d.length)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-2 opacity-30",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wider mb-1",children:t.label}),(0,a.jsx)("span",{children:"-"})]},s);let m=d.reduce((e,t)=>e+t.temp,0)/d.length,c=d.reduce((e,t)=>e+(t.precipAmount||0),0),x=d.reduce((e,t)=>e+(t.snow||0),0),u=d.reduce((e,t)=>e+(("number"==typeof t.windSpeed?t.windSpeed:void 0)??("number"==typeof t.windSpeedMs?3.6*t.windSpeedMs:0)),0)/d.length,p=0,h=0;d.forEach(e=>{let t=Math.PI/180*(e.windDeg||0);p+=Math.sin(t),h+=Math.cos(t)});let f=180/Math.PI*Math.atan2(p,h);f<0&&(f+=360);let b=o??d[0].icon,j=x>0,v=!j&&c>0,y=b?(0,a.jsx)("img",{src:b,alt:d[0].condition,className:"w-12 h-12 mx-auto object-contain my-2"}):(0,a.jsx)(ej.A,{className:"w-8 h-8 mx-auto my-2"});return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-between p-2 space-y-3 text-center",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:t.label}),(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[y,(0,a.jsxs)("span",{className:"text-2xl font-light tabular-nums my-1",children:[Math.round(m),"\xb0"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,a.jsx)(G.A,{className:"w-3 h-3 text-muted-foreground",style:{transform:`rotate(${f+180}deg)`}}),Math.round(u),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:"km/h"})]}),(0,a.jsx)("div",{className:(0,g.cn)("flex items-center gap-1 text-xs font-semibold",v||j?"text-primary":"text-muted-foreground/40"),children:j?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(M.A,{className:"w-3 h-3"}),x.toFixed(1),"cm"]}):(0,a.jsxs)(a.Fragment,{children:[v&&(0,a.jsx)(N.A,{className:"w-3 h-3"}),c>0?c.toFixed(1):"0.0","mm"]})})]})]},s)})})})]})})}var ev=s(33605),ey=s(56440);function ew({className:e,...t}){return(0,a.jsx)(ey.bL,{"data-slot":"tabs",className:(0,g.cn)("flex flex-col gap-2",e),...t})}function ek({className:e,...t}){return(0,a.jsx)(ey.B8,{"data-slot":"tabs-list",className:(0,g.cn)("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function eM({className:e,...t}){return(0,a.jsx)(ey.l9,{"data-slot":"tabs-trigger",className:(0,g.cn)("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focu
1s-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function eA({className:e,...t}){return(0,a.jsx)(ey.UC,{"data-slot":"tabs-content",className:(0,g.cn)("flex-1 outline-none",e),...t})}var eS=s(24538),eE=s(14101),eC=s(57420),eT=s(89670);let eL=eT.bL,eF=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(eT.q7,{ref:s,className:(0,g.cn)("border-b",e),...t}));eF.displayName="AccordionItem";let eP=r.forwardRef(({className:e,children:t,...s},r)=>(0,a.jsx)(eT.Y9,{className:"flex",children:(0,a.jsxs)(eT.l9,{ref:r,className:(0,g.cn)("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,(0,a.jsx)(_.A,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));eP.displayName=eT.l9.displayName;let eD=r.forwardRef(({className:e,children:t,...s},r)=>(0,a.jsx)(eT.UC,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:(0,a.jsx)("div",{className:(0,g.cn)("pb-4 pt-0",e),children:t})}));eD.displayName=eT.UC.displayName;var eI=s(41585),ez=s(56572),eK=s(98500),e$=s.n(eK),eW=s(11239),eR=s(88276),eO=s(11145);function eG(){let{hasUnreadNews:e}=(0,eR.Q)();return(0,a.jsx)("aside",{className:"hidden lg:block shrink-0",children:(0,a.jsx)("div",{className:"sticky top-24 space-y-6",children:(0,a.jsxs)("div",{className:"bg-card/95 backdrop-blur-sm border border-border/50 rounded-xl overflow-hidden shadow-sm",children:[(0,a.jsx)("div",{className:"p-5 border-b border-border/50 bg-muted/20",children:(0,a.jsx)("h3",{className:"font-semibold text-base text-foreground/80 uppercase tracking-wider",children:"Navegaci\xf3n"})}),(0,a.jsxs)("div",{className:"p-2 space-y-1",children:[(0,a.jsxs)(e$(),{href:"/noticias","aria-label":(0,eO.iU)(e),className:"flex items-center gap-3 px-4 py-3 text-base font-medium rounded-md hover:bg-muted/50 transition-colors text-foreground/80 hover:text-foreground",children:[(0,a.jsxs)("span",{className:"relative p-2",children:[(0,a.jsx)(d.A,{className:"w-5 h-5 text-primary"}),(0,a.jsx)(eW.O,{visible:e,className:"right-0.5 top-0.5"})]}),"Noticias"]}),(0,a.jsxs)("a",{href:"https://foro.asturmet.com/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-4 py-3 text-base font-medium rounded-md hover:bg-muted/50 transition-colors text-foreground/80 hover:text-foreground",children:[(0,a.jsx)("span",{className:"p-2",children:(0,a.jsx)(eI.A,{className:"w-5 h-5 text-primary"})}),"Foro"]})]}),(0,a.jsx)("div",{className:"px-2 pb-4",children:(0,a.jsx)(eL,{type:"multiple",defaultValue:["mapas"],className:"w-full",children:(0,a.jsxs)(eF,{value:"mapas",className:"border-none",children:[(0,a.jsx)(eP,{className:"px-4 py-3 text-base font-medium hover:no-underline hover:bg-muted/50 rounded-md",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"p-2",children:(0,a.jsx)(ez.A,{className:"w-5 h-5 text-primary"})}),(0,a.jsx)("span",{children:"Mapas"})]})}),(0,a.jsx)(eD,{className:"px-2 pb-2 pt-1",children:(0,a.jsx)("div",{className:"flex flex-col space-y-1 text-sm text-muted-foreground ml-12 border-l-2 border-border/50 pl-4 mt-1",children:[{label:"Temperatura",id:"temperature"},{label:"Precipitaci\xf3n",id:"precipitation"},{label:"Viento",id:"wind"},{label:"Temp. M\xe1xima",id:"tmax"},{label:"Temp. M\xednima",id:"tmin"},{label:"Lluvia Acumulada",id:"precipitation_total"},{label:"Racha Viento",id:"wind_max"}].map(e=>(0,a.jsx)(e$(),{href:`/mapas?layer=${e.id}`,className:"hover:text-foreground hover:translate-x-1 transition-all py-2 cursor-pointer block font-medium",children:e.label},e.id))})})]})})})]})})})}var eH=s(50049),eU=s(22812),e_=s(21628),eZ=s(20986),eV=s(3747);function eX({observation:e,locationSlug:t,freshnessReference:s}){let r=(0,eV.dk)(e.fetchedAt,s),i=(0,eV.vO)(e.observedAt,s);return(0,a.jsx)("li",{children:(0,a.jsxs)(e$(),{href:`/estaciones/aemet/${e.station.idema}?desde=${encodeURIComponent(t)}`,className:"group flex h-full min-h-44 flex-col rounded-xl border bg-card p-5 shadow-sm transition hover:border-sky-300 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"truncate font-semibold",children:e.station.name}),(0,a.jsxs)("p",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(eH.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})," AEMET",(0,a.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,a.jsx)(eS.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,eV.p8)(e.distanceKm,"km",1)]})]}),(0,a.jsx)("span",{className:`shrink-0 rounded-full border px-2.5 py-1 text-xs font-semibold ${(0,eV.QV)(r)}`,children:(0,eV._C)(r)})]}),(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap items-end gap-x-5 gap-y-2",children:[(0,a.jsxs)("p",{className:"flex items-center gap-2 text-2xl font-semibold tabular-nums",children:[(0,a.jsx)(v.A,{className:"h-5 w-5 text-rose-500","aria-hidden":"true"}),(0,eV.p8)(e.metrics.temperatureC,"\xb0C",1)]}),(0,a.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,a.jsx)(N.A,{className:"h-4 w-4 text-sky-500","aria-hidden":"true"}),(0,eV.p8)(e.metrics.relativeHumidityPct,"%")]})]}),i&&(0,a.jsx)("p",{className:"mt-3 text-xs font-medium leading-relaxed text-amber-700 dark:text-amber-300",children:"AEMET todav\xeda n
1o ha publicado una observaci\xf3n m\xe1s reciente."}),(0,a.jsxs)("div",{className:"mt-auto flex items-end justify-between gap-3 pt-4 text-xs text-muted-foreground",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("p",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[(0,a.jsx)(eU.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,a.jsx)("time",{dateTime:e.fetchedAt,title:`Consulta exacta: ${(0,eV.bf)(e.fetchedAt)}`,children:(0,eV.aM)(e.fetchedAt,s)})]}),(0,a.jsxs)("p",{children:["Observaci\xf3n AEMET de las"," ",(0,a.jsx)("time",{dateTime:e.observedAt,title:`Observaci\xf3n exacta: ${(0,eV.bf)(e.observedAt)}`,children:(0,eV.gO)(e.observedAt)})]})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1 font-semibold text-sky-700 group-hover:underline dark:text-sky-300",children:["Ver detalle ",(0,a.jsx)(e_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]})]})})}function eq({locationSlug:e,locationName:t}){let[s,i]=(0,r.useState)(null),[n,l]=(0,r.useState)(!1),[d,o]=(0,r.useState)(!0),[m,c]=(0,r.useState)(0),[x]=(0,r.useState)(()=>new Date),u=(0,r.useCallback)(()=>{o(!0),l(!1),c(e=>e+1)},[]);return(0,r.useEffect)(()=>{let t=new AbortController;return fetch((0,eV.of)(e),{headers:{Accept:"application/json"},signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`observations_${e.status}`);return e.json()}).then(e=>i((0,eV.iM)(e))).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||l(!0)}).finally(()=>{t.signal.aborted||o(!1)}),()=>t.abort()},[m,e]),(0,a.jsxs)("section",{"aria-labelledby":"nearby-observations-title",className:"space-y-5",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-sky-700 dark:text-sky-300",children:"Tiempo real"}),(0,a.jsx)("h2",{id:"nearby-observations-title",className:"mt-1 text-2xl font-light tracking-tight",children:"Observaciones AEMET cercanas"}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:["Datos observados, no una predicci\xf3n, en estaciones pr\xf3ximas a ",t,". Los campos ausentes se muestran como Sin dato."]})]}),s&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Publicado ",(0,eV.bf)(s.publishedAt)]})]}),(0,a.jsxs)("div",{"aria-live":"polite","aria-busy":d,children:[d&&(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",role:"status",children:[(0,a.jsx)("span",{className:"sr-only",children:"Cargando observaciones AEMET"}),[0,1,2,3].map(e=>(0,a.jsx)("div",{className:"h-36 animate-pulse rounded-xl border bg-muted/50"},e))]}),!d&&n&&(0,a.jsxs)("div",{className:"rounded-xl border border-amber-300 bg-amber-50 p-5 text-amber-950 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100",children:[(0,a.jsx)("h3",{className:"font-semibold",children:"Observaciones no disponibles"}),(0,a.jsx)("p",{className:"mt-1 text-sm",children:"El pron\xf3stico sigue disponible. Puedes volver a intentar cargar las estaciones."}),(0,a.jsxs)("button",{type:"button",onClick:u,className:"mt-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-current px-4 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,a.jsx)(eZ.A,{className:"h-4 w-4","aria-hidden":"true"}),"Reintentar observaciones"]})]}),!d&&!n&&s?.stations.length===0&&(0,a.jsxs)("div",{className:"rounded-xl border bg-card p-6",children:[(0,a.jsx)("h3",{className:"font-semibold",children:"No hay estaciones cercanas con datos recientes"}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:["No mostraremos datos de otra zona sin indicarlo. El pron\xf3stico de ",t," no cambia."]})]}),!d&&!n&&s&&s.stations.length>0&&(0,a.jsxs)(a.Fragment,{children:[s.fallbackUsed&&(0,a.jsxs)("p",{className:"mb-3 rounded-lg border border-sky-200 bg-sky-50 px-4 py-3 text-sm text-sky-950 dark:border-sky-900 dark:bg-sky-950/30 dark:text-sky-100",children:["No hab\xeda estaciones dentro de 30 km. Mostramos la m\xe1s cercana dentro de ",s.searchRadiusKm," km."]}),(0,a.jsx)("ul",{className:"grid gap-3 sm:grid-cols-2",children:s.stations.map(t=>(0,a.jsx)(eX,{observation:t,locationSlug:e,freshnessReference:x},t.station.idema))})]})]})]})}var eB=s(37206),eQ=s(44362),eJ=s(65246),eY=s(8764);let e0=(0,eB.default)(()=>Promise.all([s.e(6648),s.e(1761),s.e(6878)]).then(s.bind(s,26878)),{loadableGenerated:{webpack:()=>[26878]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"h-[420px] animate-pulse bg-muted/50"})});function e1({expanded:e=!1,lat:t,lng:s,locationName:i,zoom:n=8}){let l=(0,r.useRef)(null),[d,o]=(0,r.useState)(e),[m,c]=(0,r.useState)(null),[x,u]=(0,r.useState)(!0),[p,h]=(0,r.useState)(!1),[f,b]=(0,r.useState)(0);(0,r.useEffect)(()=>
1{if(d)return;let e=l.current;if(!e)return;if("u"<typeof IntersectionObserver){let e=window.setTimeout(()=>o(!0),0);return()=>window.clearTimeout(e)}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(o(!0),t.disconnect())},{rootMargin:"320px 0px"});return t.observe(e),()=>t.disconnect()},[d]),(0,r.useEffect)(()=>{if(!d)return;let e=new AbortController;return fetch((0,eY.lS)(),{headers:{Accept:"application/json"},signal:e.signal}).then(async e=>{if(!e.ok)throw Error("radar_"+e.status);return e.json()}).then(e=>c((0,eY.v7)(e))).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||h(!0)}).finally(()=>{e.signal.aborted||u(!1)}),()=>e.abort()},[f,d]);let g=(0,r.useCallback)(()=>{c(null),h(!1),u(!0),b(e=>e+1)},[]),j=(0,r.useCallback)(()=>{c(null),h(!0),u(!1)},[]),N=(0,eY.d1)({lat:t,lng:s,locationName:i,zoom:n});return(0,a.jsxs)("section",{ref:l,"aria-labelledby":e?"expanded-radar-title":"local-radar-title",className:"space-y-5",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-sky-700 dark:text-sky-300",children:"Precipitaci\xf3n observada"}),(0,a.jsxs)("h2",{id:e?"expanded-radar-title":"local-radar-title",className:"mt-1 text-2xl font-light tracking-tight md:text-3xl",children:["Radar de lluvia en ",i]}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"\xdaltimo frame disponible, centrado en esta localidad. No es una predicci\xf3n."})]}),!e&&(0,a.jsxs)(e$(),{href:N,className:"inline-flex min-h-11 w-fit items-center gap-2 rounded-lg border px-4 text-sm font-semibold text-sky-700 hover:bg-sky-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-sky-300 dark:hover:bg-sky-950/30",children:[(0,a.jsx)(eQ.A,{className:"h-4 w-4","aria-hidden":"true"}),"Ampliar radar"]})]}),(0,a.jsxs)("div",{className:"overflow-hidden rounded-2xl border bg-card shadow-sm","aria-live":"polite","aria-busy":d&&x,children:[!d&&(0,a.jsxs)("div",{className:"flex h-64 flex-col items-center justify-center gap-3 bg-muted/30 p-6 text-center text-muted-foreground",children:[(0,a.jsx)(eJ.A,{className:"h-10 w-10 text-sky-600","aria-hidden":"true"}),(0,a.jsx)("p",{className:"text-sm",children:"El radar se cargar\xe1 al acercarte a este bloque."})]}),d&&x&&(0,a.jsx)("div",{className:"h-[420px] animate-pulse bg-muted/50",role:"status",children:(0,a.jsx)("span",{className:"sr-only",children:"Cargando radar AEMET"})}),d&&!x&&p&&(0,a.jsxs)("div",{className:"flex min-h-64 flex-col items-center justify-center p-6 text-center",children:[(0,a.jsx)(eJ.A,{className:"h-10 w-10 text-amber-600","aria-hidden":"true"}),(0,a.jsx)("h3",{className:"mt-3 font-semibold",children:"Radar no disponible"}),(0,a.jsx)("p",{className:"mt-1 max-w-lg text-sm text-muted-foreground",children:"El pron\xf3stico y las observaciones siguen disponibles. Puedes volver a intentarlo."}),(0,a.jsxs)("button",{type:"button",onClick:g,className:"mt-4 inline-flex min-h-11 items-center gap-2 rounded-lg border px-4 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,a.jsx)(eZ.A,{className:"h-4 w-4","aria-hidden":"true"}),"Reintentar radar"]})]}),d&&!x&&m&&!p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e0,{expanded:e,lat:t,lng:s,locationName:i,manifest:m,onFrameError:j,zoom:n}),(0,a.jsxs)("div",{className:"space-y-3 border-t p-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 text-sm",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,a.jsx)(eU.A,{className:"h-4 w-4","aria-hidden":"true"}),"Frame ",(0,eY.tL)(m.observedAt)]}),(0,a.jsx)("span",{className:["rounded-full border px-2.5 py-1 text-xs font-semibold",(0,eY.eZ)(m.freshness)].join(" "),children:(0,eY.C6)(m.freshness)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"h-2.5 rounded-full",style:{background:"linear-gradient(to right, "+m.legend.colors.join(",")+")"},"aria-hidden":"true"}),(0,a.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:m.legend.lowLabel}),(0,a.jsx)("span",{children:m.legend.label}),(0,a.jsx)("span",{children:m.legend.highLabel})]})]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[m.attribution," \xb7 Datos provisionales"]})]})]})]})]})}function e2({initialData:e,decodedMunicipio:t,locationName:s}){let{model:d}=(0,i.g)(),[o,m]=(0,r.useState)("list"),[c,x]=(0,r.useState)(0),[u,p]=(0,r.useState)(null),[h,f]=(0,r.useState)({locationKey:t,model:"asturmet",data:e}),b=`${t}:${d}:${c}`;(0,r.useEffect)(()=>
1{if("asturmet"===d)return;let e=!0;return l.S.getForecast(t,d).then(s=>{e&&(p({key:b,data:s,error:!1}),f({locationKey:t,model:d,data:s}))}).catch(()=>{e&&p({key:b,data:null,error:!0})}),()=>{e=!1}},[t,e,d,b]);let{data:g,displayedModel:j,isLoading:N,isError:v}=function({initialData:e,locationKey:t,requestedModel:s,requestKey:a,result:r,retained:i}){if("asturmet"===s)return{data:e,displayedModel:s,isLoading:!1,isError:!1};let n=i?.locationKey===t?i:{locationKey:t,model:"asturmet",data:e},l=r?.key===a;return l&&r.data&&!r.error?{data:r.data,displayedModel:s,isLoading:!1,isError:!1}:{data:n.data,displayedModel:n.model,isLoading:!l,isError:!!l}}({initialData:e,locationKey:t,requestedModel:d,requestKey:b,result:u,retained:h}),y=s?{name:s}:void 0,w=(g.daily||[]).filter(e=>e.date>=(0,V.S)()).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,14);return(0,a.jsxs)("div",{className:"min-h-screen bg-background text-foreground","aria-busy":N,children:[(N||v)&&(0,a.jsx)("div",{className:"fixed inset-x-4 bottom-24 z-[1000] flex justify-center md:inset-x-auto md:right-6 md:bottom-6",children:(0,a.jsx)("div",{role:v?"alert":"status","aria-live":v?"assertive":"polite","aria-atomic":"true",className:"flex max-w-md items-center gap-3 rounded-xl border border-border bg-background/95 px-4 py-3 text-sm shadow-lg backdrop-blur",children:N?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(er.A,{className:"h-4 w-4 shrink-0 animate-spin text-primary","aria-hidden":"true"}),(0,a.jsxs)("p",{children:["Cambiando a ",d.toUpperCase(),"â¦"]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"min-w-0 flex-1",children:["No se pudo cargar ",d.toUpperCase(),". Se sigue mostrando ",j.toUpperCase(),"."]}),(0,a.jsx)("button",{type:"button",className:"min-h-11 shrink-0 rounded-lg bg-primary px-3 font-semibold text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:()=>x(e=>e+1),children:"Reintentar"})]})})}),(0,a.jsx)("div",{className:"relative w-full dark:from-slate-900/40 dark:to-background pt-4 md:pt-12 pb-8 border-b border-border/40",children:(0,a.jsx)("div",{className:"container mx-auto max-w-[1300px] px-4 md:px-6",children:(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-end justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center text-muted-foreground text-xs uppercase tracking-widest font-semibold gap-2",children:[(0,a.jsx)(eS.A,{className:"h-3 w-3"}),(0,a.jsx)(ev.x,{})]}),(0,a.jsx)("h1",{className:"break-words text-3xl md:text-4xl font-light tracking-tight",children:y?.name||g.location.name})]}),"number"==typeof g.location.altitude&&Number.isFinite(g.location.altitude)&&(0,a.jsxs)("p",{className:"shrink-0 pb-1 text-right text-sm md:text-base font-medium text-muted-foreground tabular-nums whitespace-nowrap",children:[Math.round(g.location.altitude)," m de altitud"]})]}),g&&(0,a.jsx)(eN,{data:g,locationName:y?.name||g.location.name})]})})}),(0,a.jsx)("div",{className:"container max-w-[1300px] mx-auto px-4 md:px-6 py-8",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[250px_1fr] gap-12",children:[(0,a.jsx)(eG,{}),(0,a.jsxs)("main",{className:"space-y-12 min-w-0",children:[(0,a.jsx)("section",{className:"mx-auto",children:(0,a.jsxs)(ew,{value:o,onValueChange:m,className:"w-full",children:[(0,a.jsxs)("div",{className:"mb-6 flex items-center justify-between gap-1 sm:gap-4",children:[(0,a.jsxs)("h2",{className:"shrink-0 whitespace-nowrap text-base font-light tracking-tight max-[360px]:text-xs sm:text-2xl",children:[w.length," d\xedas"]}),(0,a.jsxs)("div",{className:"ml-auto flex min-w-0 items-center gap-1 sm:gap-2",children:[(0,a.jsx)(n.S,{compact:!0,variant:"view-controls",onModelChange:()=>{f({locationKey:t,model:j,data:g})}}),(0,a.jsxs)(ek,{className:"bg-muted p-1 rounded-xl h-auto border border-border shadow-sm",children:[(0,a.jsxs)(eM,{value:"comparison","aria-label":"Comparativa",className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium text-muted-foreground transition-all max-[360px]:px-1 sm:px-3 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",children:[(0,a.jsx)(eE.A,{className:"h-4 w-4"})," ",(0,a.jsx)("span",{className:"hidden sm:inline",children:"Comparativa"})]}),(0,a.jsxs)(eM,{value:"list","aria-label":"Lista",className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium text-muted-foreground transition-all max-[360px]:px-1 sm:px-3 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",children:[(0,a.jsx)(eC.A,{className:"h-4 w-4"})," ",(0,a.jsx)("span",{className:"hidden sm:inline",children:"Lista"})]}),(0,a.jsxs)(eM,{value:"map","aria-label":"Mapa",disabled:!0,className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium text-muted-foreground transition-all max-[360px]:px-1 sm:px-3 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm disabled:opacity-50",children:[(0,a.jsx)(eS.A,{className:"h-4 w-4"})," ",(0,a.jsx)("span",{className:"hidden sm:inline",children:"Mapa"})]}),(0,a.jsxs)(eM,{value:"graph","aria-label":"Gr\xe1fica",className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium text-muted-foreground transition-all max-[360px]:px-1 sm:px-3 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm",children:[(0,a.jsx)(ej.A,{className:"h-4 w-4"})," ",(0,a.jsx)("span",{className:"hidden sm:inline",children:"Gr\xe1fica"})]})]})]})]}),(0,a.jsx)(eA,{value:"list",className:"mt-0 animate-in fade-in slide-in-from-bottom-4 duration-500",children:w.length>0&&g.hourly&&(0,a.jsx)(ee,{daily:w,hourly:g.hourly})}),(0,a.jsx)(eA,{value:"graph",className:"mt-0 animate-in fade-in slide-in-from-bottom-4 duration-500",children:w.length>0&&(0,a.jsx)(es,{data:w,hourly:g.hourly})}),(0,a.jsx)(eA,{value:"comparison",className:"mt-0 animate-in fade-in slide-in-from-bottom-4 duration-500",children:"comparison"===o&&(0,a.jsx)(eg,{initialData:e,locationSlug:t,locationName:y?.name||g.location.name},t)})]})}),(0,a.jsx)(eq,{locationSlug:t,locationName:y?.name||g.location.name},t),(0,a.jsx)(e1,{lat:g.location.coords.lat,lng:g.location.coords.lng,locationName:y?.name||g.location.name},"radar-"+t)]})]})})]})}},33605:(e,t,s)=>{"use strict";s.d(t,{x:()=>l});var a=s(95155),r=s(12115),i=s(89999),n=s(11571);function l({resolvedScope:e=null}){let{scope:t,regions:s,setScope:d,getRegion:o}=(0,i.B)();(0,r.useLayoutEffect)(()=>{let t=e??(0,n.f8)(new URLSearchParams(window.location.search).get("scope"),s);t&&d(t)},[s,e,d]);let m=o(e??t)??o(t);return(0,a.jsx)("span",{children:m?.label??"Asturias"})}},40980:(e,t,s)=>{"use strict";s.d(t,{cn:()=>i});var a=s(29722),r=s(622);function i(...e){return(0,r.QP)((0,a.$)(e))}},75262:(e,t,s)=>{"use strict";s.d(t,{S:()=>l});var a=s(95155),r=s(17052),i=s(88314),n=s(40980);function l({compact:e=!1,variant:t="default",onModelChange:s}){let{model:d,setModel:o}=(0,r.g)();return(0,a.jsx)("div",{className:"flex flex-col items-start gap-1",children:(0,a.jsx)("div",{role:"group","aria-label":"Modelo de predicci\xf3n",className:(0,n.cn)("inline-flex max-w-full rounded-xl border border-border p-1","view-controls"===t?"items-center bg-muted shadow-sm":["bg-muted/50",e?"gap-0 sm:gap-1":"gap-1"]),children:i.tP.map(r=>(0,a.jsx)("button",{type:"button","aria-pressed":d===r,onClick:()=>{s?.(r),o(r)}
1,"aria-label":r.toUpperCase(),title:"ecmwf"===r?"ECMWF IFS":r.toUpperCase(),className:(0,n.cn)("rounded-lg text-xs transition-colors sm:text-sm","view-controls"===t?"inline-flex items-center justify-center whitespace-nowrap border border-transparent px-2 py-1.5 font-medium focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-1 focus-visible:outline-ring max-[360px]:px-1 sm:px-3":["font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary",e?"min-h-7 min-w-8 px-1 py-1 sm:min-h-11 sm:min-w-11 sm:px-3 sm:py-0":"min-h-11 px-3"],d===r?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:bg-background hover:text-foreground"),children:e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{"aria-hidden":"true",className:"sm:hidden",children:"asturmet"===r?"AST":"ecmwf"===r?"ECM":"GFS"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:r.toUpperCase()})]}):r.toUpperCase()},r))})})}},75458:(e,t,s)=>{"use strict";s.d(t,{Dq:()=>i,S:()=>r});let a="Europe/Madrid";function r(){let e=new Date;return new Intl.DateTimeFormat("sv-SE",{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function i(){let e=new Date;return parseInt(new Intl.DateTimeFormat("en-US",{timeZone:a,hour:"numeric",hour12:!1}).format(e),10)}},81477:(e,t,s)=>{"use strict";s.d(t,{Wu:()=>n,Zp:()=>i});var a=s(95155);s(12115);var r=s(40980);function i({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"card",className:(0,r.cn)("bg-card/95 text-card-foreground flex flex-col gap-2 rounded-xl border shadow-sm",e),...t})}function n({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-6",e),...t})}},84715:(e,t,s)=>{Promise.resolve().then(s.bind(s,22254))},88276:(e,t,s)=>{"use strict";s.d(t,{NewsNotificationProvider:()=>l,Q:()=>d});var a=s(95155),r=s(12115),i=s(11145);let n=(0,r.createContext)(null);function l({children:e,newsItems:t}){let[s,d]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e,s=()=>{e&&clearTimeout(e);let a=Date.now(),r={};try{r=(0,i.XL)(window.localStorage,a)}catch{}d((0,i.en)(t,r,a).length>0);let n=(0,i.xi)([...t.map(e=>e.publishedAt),...Object.values(r)],a);null!==n&&(e=setTimeout(s,n))},a=e=>{(null===e.key||e.key===i.lu)&&s()};return s(),window.addEventListener(i.cb,s),window.addEventListener("storage",a),()=>{e&&clearTimeout(e),window.removeEventListener(i.cb,s),window.removeEventListener("storage",a)}},[t]),(0,a.jsx)(n.Provider,{value:{hasUnreadNews:s},children:e})}function d(){let e=(0,r.useContext)(n);if(!e)throw Error("useNewsNotificationStatus must be used within NewsNotificationProvider");return e}}},e=>{e.O(0,[8500,9060,9149,8304,5729,7077,9999,3747,8441,8928,7358],()=>e(e.s=84715)),_N_E=e.O()}]);
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.