UNPKG

vue-weather-ui

Version:

A beautiful Vue 3 weather UI components library with mini mode support and QWeather integration

2 lines (1 loc) 27.3 kB
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.VueWeatherUI={},E.Vue))})(this,function(E,e){"use strict";const O={feelsLike:{zh:"体感温度",en:"Feels Like"},humidity:{zh:"湿度",en:"Humidity"},wind:{zh:"风向风力",en:"Wind"},pressure:{zh:"气压",en:"Pressure"},visibility:{zh:"能见度",en:"Visibility"},precipitation:{zh:"降水量",en:"Precipitation"},hourlyForecast:{zh:"24小时预报",en:"24 Hour Forecast"},dailyForecast:{zh:"7天预报",en:"7 Day Forecast"},historicalTimeline:{zh:"历史天气时间轴",en:"Historical Weather Timeline"},play:{zh:"播放",en:"Play"},stop:{zh:"停止",en:"Stop"},reset:{zh:"重置",en:"Reset"},selected:{zh:"选中日期",en:"Selected"},total:{zh:"总天数",en:"Total"},days:{zh:"天",en:"days"},maxTemp:{zh:"最高温度",en:"Max Temp"},minTemp:{zh:"最低温度",en:"Min Temp"},weather:{zh:"天气",en:"Weather"},precip:{zh:"降水",en:"Precip"},uvIndex:{zh:"紫外线",en:"UV"},now:{zh:"现在",en:"Now"},today:{zh:"今天",en:"Today"},tomorrow:{zh:"明天",en:"Tomorrow"},updateTime:{zh:"更新时间",en:"Updated"},updateShort:{zh:"更新",en:"Upd"},allMonths:{zh:"全部月份",en:"All Months"}};function B(s){return{t:n=>{const f=O[n];return f?f[s.locale]:n}}}function T(){return{getWeatherIcon:n=>({100:"qi-100",101:"qi-101",102:"qi-102",103:"qi-103",104:"qi-104",150:"qi-150",151:"qi-151",152:"qi-152",153:"qi-153",300:"qi-300",301:"qi-301",302:"qi-302",303:"qi-303",304:"qi-304",305:"qi-305",306:"qi-306",307:"qi-307",308:"qi-308",309:"qi-309",310:"qi-310",311:"qi-311",312:"qi-312",313:"qi-313",314:"qi-314",315:"qi-315",316:"qi-316",317:"qi-317",318:"qi-318",350:"qi-350",351:"qi-351",399:"qi-399",400:"qi-400",401:"qi-401",402:"qi-402",403:"qi-403",404:"qi-404",405:"qi-405",406:"qi-406",407:"qi-407",408:"qi-408",409:"qi-409",410:"qi-410",456:"qi-456",457:"qi-457",499:"qi-499",500:"qi-500",501:"qi-501",502:"qi-502",503:"qi-503",504:"qi-504",507:"qi-507",508:"qi-508",509:"qi-509",510:"qi-510",511:"qi-511",512:"qi-512",513:"qi-513",514:"qi-514",515:"qi-515",900:"qi-900",901:"qi-901",999:"qi-999"})[n]||"qi-100",getWeatherDescription:(n,f)=>{var N;return((N={100:{zh:"晴",en:"Sunny"},101:{zh:"多云",en:"Cloudy"},102:{zh:"少云",en:"Few Clouds"},103:{zh:"晴间多云",en:"Partly Cloudy"},104:{zh:"阴",en:"Overcast"},150:{zh:"晴",en:"Clear"},151:{zh:"晴",en:"Clear"},152:{zh:"晴",en:"Clear"},153:{zh:"晴",en:"Clear"},300:{zh:"阵雨",en:"Shower Rain"},301:{zh:"强阵雨",en:"Heavy Shower Rain"},302:{zh:"雷阵雨",en:"Thundershower"},303:{zh:"强雷阵雨",en:"Heavy Thundershower"},304:{zh:"雷阵雨伴有冰雹",en:"Thundershower with Hail"},305:{zh:"小雨",en:"Light Rain"},306:{zh:"中雨",en:"Moderate Rain"},307:{zh:"大雨",en:"Heavy Rain"},308:{zh:"极端降雨",en:"Extreme Rain"},309:{zh:"毛毛雨",en:"Drizzle"},310:{zh:"暴雨",en:"Storm"},311:{zh:"大暴雨",en:"Heavy Storm"},312:{zh:"特大暴雨",en:"Severe Storm"},313:{zh:"冻雨",en:"Freezing Rain"},399:{zh:"雨",en:"Rain"},500:{zh:"雾",en:"Fog"},501:{zh:"轻雾",en:"Light Fog"},502:{zh:"霾",en:"Haze"},503:{zh:"沙尘暴",en:"Sandstorm"},504:{zh:"浮尘",en:"Dust"},507:{zh:"沙尘",en:"Sand"},508:{zh:"扬沙",en:"Blowing Sand"},900:{zh:"热",en:"Hot"},901:{zh:"冷",en:"Cold"},999:{zh:"未知",en:"Unknown"}}[n])==null?void 0:N[f])||"Unknown"}}}function q(s){return{formatDateTime:(r,l)=>new Date(r).toLocaleDateString(s==="zh"?"zh-CN":"en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",...l}),formatDate:r=>new Date(r).toLocaleDateString(s==="zh"?"zh-CN":"en-US",{month:"short",day:"numeric"}),formatTime:r=>new Date(r).toLocaleTimeString(s==="zh"?"zh-CN":"en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),formatShortTime:r=>new Date(r).toLocaleTimeString(s==="zh"?"zh-CN":"en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),isToday:r=>{const l=new Date,p=new Date(r);return l.toDateString()===p.toDateString()},isTomorrow:r=>{const l=new Date;l.setDate(l.getDate()+1);const p=new Date(r);return l.toDateString()===p.toDateString()},isCurrentHour:r=>{const l=new Date,p=new Date(r);return Math.abs(l.getTime()-p.getTime())<18e5},isCurrentDay:r=>{const l=new Date().toDateString(),p=new Date(r).toDateString();return l===p}}}function W(s){const i=e.computed(()=>s.mini?"mini":"normal"),n=e.computed(()=>s.theme==="light"?{background:"#ffffff",text:"#2d3748",border:"#e2e8f0",hover:"#edf2f7",selected:"#667eea",secondaryText:"#718096",cardBackground:"#f7fafc"}:{background:"#2d3748",text:"#ffffff",border:"#4a5568",hover:"#1a202c",selected:"#667eea",secondaryText:"#a0aec0",cardBackground:"#4a5568"}),f=e.computed(()=>({background:n.value.background,color:n.value.text,padding:s.mini?"12px":"24px",borderRadius:s.mini?"12px":"20px"})),d=e.computed(()=>s.mini?"qweather-icon-sm":"qweather-icon-lg");return{sizeConfig:i,themeColors:n,componentStyles:f,iconSize:d}}const j={key:0,class:"weather-card-header weather-header"},G={class:"location-info"},J={class:"location-name"},K={key:0,class:"location-details"},Q={class:"weather-main"},X={class:"weather-icon"},Y={class:"weather-temp temp-container"},Z={key:0,class:"weather-desc weather-label"},x={key:1,class:"weather-card-body weather-content"},v={key:0,class:"weather-details-grid details-grid"},ee={class:"detail-item"},te={class:"detail-label"},ne={class:"detail-value"},ae={class:"detail-item"},oe={class:"detail-label"},ie={class:"detail-value"},le={class:"detail-item"},se={class:"detail-label"},re={class:"detail-value"},ce={class:"detail-item"},de={class:"detail-label"},me={class:"detail-value"},he={class:"detail-item"},pe={class:"detail-label"},ye={class:"detail-value"},_e={class:"detail-item"},fe={class:"detail-label"},we={class:"detail-value"},Ee={key:1,class:"weather-card-body-mini"},Ne={class:"mini-info-row"},ge={class:"mini-info-item"},Ve={class:"mini-label weather-label"},De={class:"mini-value weather-value"},Se={class:"mini-info-item"},ke={class:"mini-label weather-label"},ze={class:"mini-value weather-value"},Ce={class:"mini-info-item"},$e={class:"mini-label weather-label"},Be={class:"mini-value weather-value"},Te={class:"mini-update-time"},qe={class:"mini-update-text"},be={key:2,class:"weather-card-footer"},Me={class:"update-time"},Ie=e.defineComponent({__name:"WeatherCard",props:{showDetails:{type:Boolean,default:!0},data:{},theme:{default:"light"},locale:{default:"zh"},mini:{type:Boolean,default:!1},showTitle:{type:Boolean,default:!0}},setup(s){const i=s,{t:n}=B(i),{getWeatherIcon:f,getWeatherDescription:d}=T(),{formatDateTime:N,formatShortTime:g}=q(i.locale),{iconSize:V}=W(i),D=e.computed(()=>f(i.data.now.icon)),r=e.computed(()=>d(i.data.now.icon,i.locale)),l=e.computed(()=>i.data.location.name),p=e.computed(()=>{const{country:o,adm1:a,adm2:y}=i.data.location;return i.locale==="zh"?`${y}, ${a}`:`${y}, ${a}, ${o}`}),m=e.computed(()=>`${n("updateTime")}: ${N(i.data.now.fxTime)}`),w=e.computed(()=>`${n("updateShort")}: ${g(i.data.now.fxTime)}`);return(o,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["weather-card weather-component",[o.theme,{mini:o.mini}]])},[o.showTitle?(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",G,[e.createElementVNode("h3",J,e.toDisplayString(l.value),1),o.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",K,e.toDisplayString(p.value),1))]),e.createElementVNode("div",Q,[e.createElementVNode("div",X,[e.createElementVNode("i",{class:e.normalizeClass([D.value,"qweather-icon",e.unref(V)])},null,2)]),e.createElementVNode("div",Y,[e.createElementVNode("span",{class:e.normalizeClass(["temp-value",{mini:o.mini}])},e.toDisplayString(o.data.now.temp),3),e.createElementVNode("span",{class:e.normalizeClass(["temp-unit",{mini:o.mini}])},"°C",2)]),o.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Z,e.toDisplayString(r.value),1))])])):e.createCommentVNode("",!0),o.showDetails?(e.openBlock(),e.createElementBlock("div",x,[o.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",v,[e.createElementVNode("div",ee,[e.createElementVNode("span",te,e.toDisplayString(e.unref(n)("feelsLike")),1),e.createElementVNode("span",ne,e.toDisplayString(o.data.now.temp)+"°C",1)]),e.createElementVNode("div",ae,[e.createElementVNode("span",oe,e.toDisplayString(e.unref(n)("humidity")),1),e.createElementVNode("span",ie,e.toDisplayString(o.data.now.humidity)+"%",1)]),e.createElementVNode("div",le,[e.createElementVNode("span",se,e.toDisplayString(e.unref(n)("wind")),1),e.createElementVNode("span",re,e.toDisplayString(o.data.now.windDir)+" "+e.toDisplayString(o.data.now.windScale)+"级",1)]),e.createElementVNode("div",ce,[e.createElementVNode("span",de,e.toDisplayString(e.unref(n)("pressure")),1),e.createElementVNode("span",me,e.toDisplayString(o.data.now.pressure)+" hPa",1)]),e.createElementVNode("div",he,[e.createElementVNode("span",pe,e.toDisplayString(e.unref(n)("visibility")),1),e.createElementVNode("span",ye,e.toDisplayString(o.data.now.vis)+" km",1)]),e.createElementVNode("div",_e,[e.createElementVNode("span",fe,e.toDisplayString(e.unref(n)("precipitation")),1),e.createElementVNode("span",we,e.toDisplayString(o.data.now.precip)+" mm",1)])])),o.mini?(e.openBlock(),e.createElementBlock("div",Ee,[e.createElementVNode("div",Ne,[e.createElementVNode("span",ge,[e.createElementVNode("span",Ve,e.toDisplayString(e.unref(n)("humidity")),1),e.createElementVNode("span",De,e.toDisplayString(o.data.now.humidity)+"%",1)]),e.createElementVNode("span",Se,[e.createElementVNode("span",ke,e.toDisplayString(e.unref(n)("wind")),1),e.createElementVNode("span",ze,e.toDisplayString(o.data.now.windDir)+" "+e.toDisplayString(o.data.now.windScale)+"级",1)]),e.createElementVNode("span",Ce,[e.createElementVNode("span",$e,e.toDisplayString(e.unref(n)("precipitation")),1),e.createElementVNode("span",Be,e.toDisplayString(o.data.now.precip)+"mm",1)])]),e.createElementVNode("div",Te,[e.createElementVNode("span",qe,e.toDisplayString(w.value),1)])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),o.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",be,[e.createElementVNode("span",Me,e.toDisplayString(m.value),1)]))],2))}}),b=(s,i)=>{const n=s.__vccOpts||s;for(const[f,d]of i)n[f]=d;return n},L=b(Ie,[["__scopeId","data-v-f08bdba0"]]),We={key:0,class:"hourly-header weather-header"},ue={class:"hourly-container"},Fe={class:"hourly-scroll weather-scroll"},He={class:"hourly-time weather-label"},Le={class:"hourly-icon weather-icon"},Pe={class:"hourly-temp temp-container"},Ue={key:0,class:"hourly-desc weather-desc"},Re={key:1,class:"hourly-details"},Ae={class:"detail-row"},Oe={class:"weather-value"},je={class:"detail-row"},Ge={class:"weather-value"},P=b(e.defineComponent({__name:"HourlyForecast",props:{hours:{default:24},data:{},theme:{default:"light"},locale:{default:"zh"},mini:{type:Boolean,default:!1},showTitle:{type:Boolean,default:!0}},setup(s){const i=s,{t:n}=B(i),{getWeatherIcon:f,getWeatherDescription:d}=T(),{formatTime:N,isCurrentHour:g}=q(i.locale),{iconSize:V}=W(i),D=e.computed(()=>i.data.hourly.slice(0,i.hours)),r=m=>g(m)?n("now"):N(m),l=m=>f(m),p=m=>d(m,i.locale);return(m,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["hourly-forecast weather-component",[m.theme,{mini:m.mini}]])},[m.showTitle&&!m.mini?(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("h3",null,e.toDisplayString(e.unref(n)("hourlyForecast")),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",ue,[e.createElementVNode("div",Fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,(o,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:e.normalizeClass(["hourly-item weather-item",{current:e.unref(g)(o.fxTime),mini:m.mini}])},[e.createElementVNode("div",He,e.toDisplayString(r(o.fxTime)),1),e.createElementVNode("div",Le,[e.createElementVNode("i",{class:e.normalizeClass([l(o.icon),"qweather-icon",e.unref(V)])},null,2)]),e.createElementVNode("div",Pe,[e.createElementVNode("span",{class:e.normalizeClass(["temp-value temp-max",{mini:m.mini}])},e.toDisplayString(o.temp),3),e.createElementVNode("span",{class:e.normalizeClass(["temp-unit",{mini:m.mini}])},"°",2)]),m.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ue,e.toDisplayString(p(o.icon)),1)),m.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",Ae,[w[0]||(w[0]=e.createElementVNode("span",{class:"detail-icon"},"💧",-1)),e.createElementVNode("span",Oe,e.toDisplayString(o.humidity)+"%",1)]),e.createElementVNode("div",je,[w[1]||(w[1]=e.createElementVNode("span",{class:"detail-icon"},"💨",-1)),e.createElementVNode("span",Ge,e.toDisplayString(o.windScale)+"级",1)])]))],2))),128))])])],2))}}),[["__scopeId","data-v-ce5bab7c"]]),Je={key:0,class:"daily-header weather-header"},Ke={class:"daily-container weather-content"},Qe={class:"daily-date"},Xe={class:"date-day weather-label"},Ye={key:0,class:"date-week weather-desc"},Ze={class:"daily-weather"},xe={class:"weather-icons"},ve={class:"day-weather"},et={key:0,class:"weather-desc"},tt={key:0,class:"night-weather"},nt={class:"weather-desc"},at={class:"daily-temp"},ot={class:"temp-range temp-container"},it={key:0,class:"temp-bar"},lt={key:0,class:"daily-details"},st={class:"detail-row"},rt={class:"weather-value"},ct={class:"detail-row"},dt={class:"weather-value"},mt={class:"detail-row"},ht={class:"weather-value"},pt={class:"detail-row"},yt={class:"weather-value"},_t={key:1,class:"daily-extra details-grid"},ft={class:"extra-item detail-item"},wt={class:"extra-label detail-label"},Et={class:"extra-value detail-value"},Nt={class:"extra-item detail-item"},gt={class:"extra-label detail-label"},Vt={class:"extra-value detail-value"},U=b(e.defineComponent({__name:"DailyForecast",props:{days:{default:7},data:{},theme:{default:"light"},locale:{default:"zh"},mini:{type:Boolean,default:!1},showTitle:{type:Boolean,default:!0}},setup(s){const i=s,{t:n}=B(i),{getWeatherIcon:f,getWeatherDescription:d}=T(),{formatDate:N,isToday:g,isTomorrow:V}=q(i.locale),{iconSize:D}=W(i),r=e.computed(()=>i.data.daily.slice(0,i.days)),l=a=>g(a)?n("today"):V(a)?n("tomorrow"):N(a),p=a=>new Date(a).toLocaleDateString(i.locale==="zh"?"zh-CN":"en-US",{weekday:"short"}),m=a=>f(a),w=a=>d(a,i.locale),o=a=>{const y=Math.min(...i.data.daily.map(C=>parseInt(C.tempMin))),S=Math.max(...i.data.daily.map(C=>parseInt(C.tempMax)))-y,u=parseInt(a.tempMin),M=parseInt(a.tempMax),z=(u-y)/S*100,F=(M-y)/S*100;return{left:`${z}%`,width:`${F-z}%`}};return(a,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["daily-forecast weather-component",[a.theme,{mini:a.mini}]])},[a.showTitle&&!a.mini?(e.openBlock(),e.createElementBlock("div",Je,[e.createElementVNode("h3",null,e.toDisplayString(e.unref(n)("dailyForecast")),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(_,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:e.normalizeClass(["daily-item weather-item",{today:e.unref(g)(_.fxDate),mini:a.mini}])},[e.createElementVNode("div",Qe,[e.createElementVNode("div",Xe,e.toDisplayString(l(_.fxDate)),1),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ye,e.toDisplayString(p(_.fxDate)),1))]),e.createElementVNode("div",Ze,[e.createElementVNode("div",xe,[e.createElementVNode("div",ve,[e.createElementVNode("i",{class:e.normalizeClass([m(_.iconDay),"qweather-icon",e.unref(D)])},null,2),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",et,e.toDisplayString(w(_.iconDay)),1))]),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",tt,[e.createElementVNode("i",{class:e.normalizeClass([m(_.iconNight),"qweather-icon qweather-icon-sm"])},null,2),e.createElementVNode("div",nt,e.toDisplayString(w(_.iconNight)),1)]))])]),e.createElementVNode("div",at,[e.createElementVNode("div",ot,[e.createElementVNode("span",{class:e.normalizeClass(["temp-max",{mini:a.mini}])},e.toDisplayString(_.tempMax)+"°",3),e.createElementVNode("span",{class:e.normalizeClass(["temp-separator temp-unit",{mini:a.mini}])},"/",2),e.createElementVNode("span",{class:e.normalizeClass(["temp-min",{mini:a.mini}])},e.toDisplayString(_.tempMin)+"°",3)]),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",it,[y[0]||(y[0]=e.createElementVNode("div",{class:"temp-bar-bg"},null,-1)),e.createElementVNode("div",{class:"temp-bar-fill",style:e.normalizeStyle(o(_))},null,4)]))]),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",st,[y[1]||(y[1]=e.createElementVNode("span",{class:"detail-icon"},"🌅",-1)),e.createElementVNode("span",rt,e.toDisplayString(_.sunrise),1)]),e.createElementVNode("div",ct,[y[2]||(y[2]=e.createElementVNode("span",{class:"detail-icon"},"🌇",-1)),e.createElementVNode("span",dt,e.toDisplayString(_.sunset),1)]),e.createElementVNode("div",mt,[y[3]||(y[3]=e.createElementVNode("span",{class:"detail-icon"},"💨",-1)),e.createElementVNode("span",ht,e.toDisplayString(_.windDirDay)+" "+e.toDisplayString(_.windScaleDay)+"级",1)]),e.createElementVNode("div",pt,[y[4]||(y[4]=e.createElementVNode("span",{class:"detail-icon"},"💧",-1)),e.createElementVNode("span",yt,e.toDisplayString(_.humidity)+"%",1)])])),a.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_t,[e.createElementVNode("div",ft,[e.createElementVNode("span",wt,e.toDisplayString(e.unref(n)("precip")),1),e.createElementVNode("span",Et,e.toDisplayString(_.precip)+"mm",1)]),e.createElementVNode("div",Nt,[e.createElementVNode("span",gt,e.toDisplayString(e.unref(n)("uvIndex")),1),e.createElementVNode("span",Vt,e.toDisplayString(_.uvIndex),1)])]))],2))),128))])],2))}}),[["__scopeId","data-v-6e5f7a56"]]),Dt={key:0,class:"timeline-title-row"},St={class:"timeline-title"},kt={key:1,class:"timeline-controls-row"},zt={key:0,class:"timeline-months"},Ct={value:""},$t=["value"],Bt={key:1,class:"timeline-controls"},Tt={key:0,class:"control-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},qt={key:1,class:"control-icon",viewBox:"0 0 24 24",fill:"currentColor"},bt={key:2},Mt={key:0},It={class:"timeline-container"},Wt=["onClick"],ut={class:"day-weather weather-icon"},Ft={class:"day-temp temp-container"},Ht={key:0,class:"day-desc weather-desc"},Lt={key:2,class:"timeline-info weather-divider"},Pt={class:"info-left"},Ut={class:"info-label weather-label"},Rt={class:"info-value weather-value"},At={class:"info-right"},Ot={class:"info-label weather-label"},jt={class:"info-value weather-value"},Gt={key:3,class:"selected-details"},Jt={class:"details-grid"},Kt={class:"detail-item"},Qt={class:"detail-label"},Xt={class:"detail-value"},Yt={class:"detail-item"},Zt={class:"detail-label"},xt={class:"detail-value"},vt={class:"detail-item"},en={class:"detail-label"},tn={class:"detail-value"},nn={class:"detail-item"},an={class:"detail-label"},on={class:"detail-value"},ln={class:"detail-item"},sn={class:"detail-label"},rn={class:"detail-value"},cn={class:"detail-item"},dn={class:"detail-label"},mn={class:"detail-value"},R=b(e.defineComponent({__name:"HistoricalTimeline",props:{style:{},autoPlay:{type:Boolean,default:!1},autoPlayInterval:{default:2e3},showControls:{type:Boolean,default:!0},onDaySelect:{},onDayChange:{},data:{},theme:{default:"light"},locale:{default:"zh"},mini:{type:Boolean,default:!1},showTitle:{type:Boolean,default:!0}},emits:["daySelect","dayChange"],setup(s,{emit:i}){const n=s,f=i,{t:d}=B(n),{getWeatherIcon:N,getWeatherDescription:g}=T(),{formatDate:V,isCurrentDay:D}=q(n.locale),r=e.ref(""),l=e.ref(null),p=e.ref(!1),m=e.ref(null),w=e.ref(null),o=e.computed(()=>{const t=new Set;return n.data.historical.forEach(c=>{const h=c.date.substring(0,7);t.add(h)}),Array.from(t).sort((c,h)=>h.localeCompare(c))}),a=e.computed(()=>r.value?n.data.historical.filter(t=>t.date.startsWith(r.value)):n.data.historical),y=e.computed(()=>{const t=n.style||{textColor:"#2d3748",height:"120px"};return{color:t.textColor,height:t.height}}),_=e.computed(()=>l.value?new Date(l.value.date).toLocaleDateString(n.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"long",day:"numeric"}):n.locale==="zh"?"未选择":"No selection"),S=t=>new Date(t+"-01").toLocaleDateString(n.locale==="zh"?"zh-CN":"en-US",{year:"numeric",month:"short"}),u=t=>V(t),M=t=>N(t),z=t=>g(t,n.locale),F=t=>({fontSize:(n.style||{}).fontSize||"14px"}),C=()=>{if(a.value.length>0){const t=[...a.value].sort((c,h)=>h.date.localeCompare(c.date));$(t[0])}},$=t=>{l.value=t,f("daySelect",t),f("dayChange",t),e.nextTick(()=>{pn()})},pn=()=>{if(!w.value)return;const t=w.value.querySelector(".timeline-day.selected");if(t){const c=w.value,h=c.getBoundingClientRect(),k=t.getBoundingClientRect(),A=c.scrollLeft,fn=k.left-h.left+A,wn=k.width,En=h.width,Nn=fn-En/2+wn/2;c.scrollTo({left:Nn,behavior:"smooth"})}},yn=()=>{p.value=!p.value,p.value?H():I()},H=()=>{a.value.length<=1||(!l.value&&a.value.length>0&&$(a.value[0]),m.value=window.setInterval(()=>{const t=a.value.findIndex(h=>h===l.value);let c;t===-1||t===a.value.length-1?c=0:c=t+1,$(a.value[c])},n.autoPlayInterval))},I=()=>{m.value&&(clearInterval(m.value),m.value=null)},_n=()=>{l.value=null,I(),p.value=!1};return e.onMounted(()=>{if(o.value.length>0&&(r.value=o.value[0]),a.value.length>0){const t=[...a.value].sort((c,h)=>h.date.localeCompare(c.date));$(t[0])}n.autoPlay&&(p.value=!0,H())}),e.onUnmounted(()=>{I()}),e.watch(()=>n.autoPlay,t=>{t?(p.value=!0,H()):(p.value=!1,I())}),(t,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["historical-timeline weather-component",[t.theme,{mini:t.mini}]])},[t.showTitle&&!t.mini?(e.openBlock(),e.createElementBlock("div",Dt,[e.createElementVNode("h3",St,e.toDisplayString(e.unref(d)("historicalTimeline")),1)])):e.createCommentVNode("",!0),!t.mini||t.showControls?(e.openBlock(),e.createElementBlock("div",kt,[!t.mini||t.showControls?(e.openBlock(),e.createElementBlock("div",zt,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":c[0]||(c[0]=h=>r.value=h),onChange:C,class:"month-select weather-button"},[e.createElementVNode("option",Ct,e.toDisplayString(e.unref(d)("allMonths")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(h,k)=>(e.openBlock(),e.createElementBlock("option",{key:k,value:h},e.toDisplayString(S(h)),9,$t))),128))],544),[[e.vModelSelect,r.value]])])):e.createCommentVNode("",!0),!t.mini||t.showControls?(e.openBlock(),e.createElementBlock("div",Bt,[e.createElementVNode("button",{onClick:yn,class:e.normalizeClass(["control-btn weather-button",{active:p.value}])},[p.value?(e.openBlock(),e.createElementBlock("svg",qt,c[2]||(c[2]=[e.createElementVNode("rect",{x:"6",y:"4",width:"4",height:"16"},null,-1),e.createElementVNode("rect",{x:"14",y:"4",width:"4",height:"16"},null,-1)]))):(e.openBlock(),e.createElementBlock("svg",Tt,c[1]||(c[1]=[e.createElementVNode("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)]))),t.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",bt,e.toDisplayString(p.value?e.unref(d)("stop"):e.unref(d)("play")),1))],2),e.createElementVNode("button",{onClick:_n,class:"control-btn weather-button"},[c[3]||(c[3]=e.createElementVNode("svg",{class:"control-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.createElementVNode("path",{d:"M3 3v5h5"})],-1)),t.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Mt,e.toDisplayString(e.unref(d)("reset")),1))])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",It,[e.createElementVNode("div",{class:"timeline-track weather-scroll",style:e.normalizeStyle(y.value),ref_key:"timelineTrack",ref:w},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(h,k)=>(e.openBlock(),e.createElementBlock("div",{key:k,onClick:A=>$(h),class:e.normalizeClass(["timeline-day weather-item",{selected:l.value===h,current:e.unref(D)(h.date),mini:t.mini}]),style:e.normalizeStyle(F())},[e.createElementVNode("div",{class:e.normalizeClass(["day-date weather-label",{mini:t.mini}])},e.toDisplayString(u(h.date)),3),e.createElementVNode("div",ut,[e.createElementVNode("i",{class:e.normalizeClass([M(h.iconDay),t.mini?"qweather-icon-sm":"qweather-icon"])},null,2)]),e.createElementVNode("div",Ft,[e.createElementVNode("span",{class:e.normalizeClass(["temp-max",{mini:t.mini}])},e.toDisplayString(h.tempMax)+"°",3),e.createElementVNode("span",{class:e.normalizeClass(["temp-min",{mini:t.mini}])},e.toDisplayString(h.tempMin)+"°",3)]),t.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ht,e.toDisplayString(z(h.iconDay)),1))],14,Wt))),128))],4)]),t.mini?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Lt,[e.createElementVNode("div",Pt,[e.createElementVNode("span",Ut,e.toDisplayString(e.unref(d)("selected"))+":",1),e.createElementVNode("span",Rt,e.toDisplayString(_.value),1)]),e.createElementVNode("div",At,[e.createElementVNode("span",Ot,e.toDisplayString(e.unref(d)("total"))+":",1),e.createElementVNode("span",jt,e.toDisplayString(a.value.length)+" "+e.toDisplayString(e.unref(d)("days")),1)])])),l.value&&!t.mini?(e.openBlock(),e.createElementBlock("div",Gt,[e.createElementVNode("div",Jt,[e.createElementVNode("div",Kt,[e.createElementVNode("span",Qt,e.toDisplayString(e.unref(d)("maxTemp")),1),e.createElementVNode("span",Xt,e.toDisplayString(l.value.tempMax)+"°C",1)]),e.createElementVNode("div",Yt,[e.createElementVNode("span",Zt,e.toDisplayString(e.unref(d)("minTemp")),1),e.createElementVNode("span",xt,e.toDisplayString(l.value.tempMin)+"°C",1)]),e.createElementVNode("div",vt,[e.createElementVNode("span",en,e.toDisplayString(e.unref(d)("weather")),1),e.createElementVNode("span",tn,[e.createElementVNode("i",{class:e.normalizeClass([M(l.value.iconDay),"qweather-icon"])},null,2),e.createTextVNode(" "+e.toDisplayString(z(l.value.iconDay)),1)])]),e.createElementVNode("div",nn,[e.createElementVNode("span",an,e.toDisplayString(e.unref(d)("wind")),1),e.createElementVNode("span",on,e.toDisplayString(l.value.windDirDay)+" "+e.toDisplayString(l.value.windScaleDay)+"级",1)]),e.createElementVNode("div",ln,[e.createElementVNode("span",sn,e.toDisplayString(e.unref(d)("humidity")),1),e.createElementVNode("span",rn,e.toDisplayString(l.value.humidity)+"%",1)]),e.createElementVNode("div",cn,[e.createElementVNode("span",dn,e.toDisplayString(e.unref(d)("precipitation")),1),e.createElementVNode("span",mn,e.toDisplayString(l.value.precip)+"mm",1)])])])):e.createCommentVNode("",!0)],2))}}),[["__scopeId","data-v-6121082a"]]),hn={install(s){s.component("WeatherCard",L),s.component("HourlyForecast",P),s.component("DailyForecast",U),s.component("HistoricalTimeline",R)}};E.DailyForecast=U,E.HistoricalTimeline=R,E.HourlyForecast=P,E.WeatherCard=L,E.default=hn,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});