@idmwx/idmui-gl3 5.7.6 → 5.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -228,16 +228,16 @@ const S = (t, e) => {
228
228
  !t.collected && ((e = this.layers.weather.filter((a) => a.collected)) == null ? void 0 : e.length) >= 6 && (this.layers.weather.filter((a) => a.collected)[0].collected = !1), t.collected = !t.collected, localStorage.setItem(this.collectedLayerCache, JSON.stringify(this.layers.weather)), this.$emit("handleToggleVersion");
229
229
  },
230
230
  handleToggleWindParticle() {
231
- !this.showWindFeather && this.showWindParticle ? this.handleWeatherLayerPick({ weight: 1, name: "Wind", key: "wind", enabled: !0, type: "json", particle: !0 }) : (this.showCurrentParticle && (this.$emit("toggleCurrentParticle", !1), this.showCurrentIsoband || (this.activeWeatherLayers = this.activeWeatherLayers.filter((t) => t.key !== "current"))), this.$emit("toggleWindParticle", !this.showWindParticle), this.$emit("toggleWindParticeVersion"));
231
+ !this.showWindFeather && this.showWindParticle ? this.handleWeatherLayerPick({ weight: 1, name: "Wind", key: "wind", enabled: !0, type: "json", particle: !1 }) : (this.showCurrentParticle && (this.$emit("toggleCurrentParticle", !1), this.showCurrentIsoband || (this.activeWeatherLayers = this.activeWeatherLayers.filter((t) => t.key !== "current"))), this.$emit("toggleWindParticle", !this.showWindParticle), this.$emit("toggleWindParticeVersion"));
232
232
  },
233
233
  handleToggleWindFeather() {
234
- this.showWindFeather && !this.showWindParticle && this.handleWeatherLayerPick({ weight: 1, name: "Wind", key: "wind", enabled: !0, type: "json", particle: !0 }), this.$emit("toggleWindFeather", !this.showWindFeather);
234
+ this.showWindFeather && !this.showWindParticle && this.handleWeatherLayerPick({ weight: 1, name: "Wind", key: "wind", enabled: !0, type: "json", particle: !1 }), this.$emit("toggleWindFeather", !this.showWindFeather);
235
235
  },
236
236
  handleToggleCurrentParticle() {
237
- !this.showCurrentIsoband && this.showCurrentParticle ? this.handleWeatherLayerPick({ weight: 96, name: "Current", key: "current", enabled: !0, type: "json", particle: !0 }) : (this.showWindParticle && (this.$emit("toggleWindParticle", !1), this.showWindFeather || (this.activeWeatherLayers = this.activeWeatherLayers.filter((t) => t.key !== "wind"))), this.$emit("toggleCurrentParticle", !this.showCurrentParticle), this.$emit("toggleCurrentParticeVersion"));
237
+ !this.showCurrentIsoband && this.showCurrentParticle ? this.handleWeatherLayerPick({ weight: 96, name: "Current", key: "current", enabled: !0, type: "json", particle: !1 }) : (this.showWindParticle && (this.$emit("toggleWindParticle", !1), this.showWindFeather || (this.activeWeatherLayers = this.activeWeatherLayers.filter((t) => t.key !== "wind"))), this.$emit("toggleCurrentParticle", !this.showCurrentParticle), this.$emit("toggleCurrentParticeVersion"));
238
238
  },
239
239
  handleToggleCurrentIsoband() {
240
- this.showCurrentIsoband && !this.showCurrentParticle && this.handleWeatherLayerPick({ weight: 96, name: "Current", key: "current", vendor: "cmems", merge: !0, h5: !0, enabled: !0 }), this.$emit("toggleCurrentIsoband", !this.showCurrentIsoband);
240
+ this.showCurrentIsoband && !this.showCurrentParticle && this.handleWeatherLayerPick({ weight: 96, name: "Current", key: "current", enabled: !0, type: "json", particle: !1 }), this.$emit("toggleCurrentIsoband", !this.showCurrentIsoband);
241
241
  },
242
242
  handleOtherLayerPick(t) {
243
243
  this.activeOtherLayers.some((e) => e.key === t.key) ? this.activeOtherLayers = this.activeOtherLayers.filter((e) => e.key !== t.key) : t.enabled && this.activeOtherLayers.push(t), localStorage.setItem(this.activeOtherLayersCache, JSON.stringify(this.activeOtherLayers)), this.$emit("other", this.activeOtherLayers);
@@ -1,4 +1,4 @@
1
- (function(M,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@idm-plugin/tag"),require("moment"),require("axios"),require("moment-timezone"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("mapbox-gl"),require("@idm-plugin/geo"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","moment","axios","moment-timezone","vue","@turf/turf","@mapbox/sphericalmercator","mapbox-gl","@idm-plugin/geo","@idm-plugin/meteo"],j):(M=typeof globalThis<"u"?globalThis:M||self,j(M["idm-gl"]={},M["@idm-plugin/tag"],M.moment,M.axios,M["moment-timezone"],M.Vue,M["@turf/turf"],M["@mapbox/sphericalmercator"],M["mapbox-gl"],M["@idm-plugin/geo"],M["@idm-plugin/meteo"]))})(this,function(M,j,T,K,de,e,Ye,Ke,ne,N,ce){"use strict";var yo=Object.defineProperty;var fo=(M,j,T)=>j in M?yo(M,j,{enumerable:!0,configurable:!0,writable:!0,value:T}):M[j]=T;var H=(M,j,T)=>(fo(M,typeof j!="symbol"?j+"":j,T),T);function Xe(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const i in a)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>a[i]})}}return t.default=a,Object.freeze(t)}const I=Xe(Ye),uo="",wo="",D=(a,t)=>{const i=a.__vccOpts||a;for(const[o,r]of t)i[o]=r;return i},Je={name:"IdmGlLayer",props:{map:{type:Object},mapProjection:{type:String},gateway:{type:String},token:{type:String},top:{type:Number,default:60},layerToggle:{type:Boolean,default:!1},toggleVersion:{type:Number},isLogin:{type:Boolean,default:void 0},showWindFeather:{type:Boolean,default:void 0},showWindParticle:{type:Boolean,default:void 0},showCurrentIsoband:{type:Boolean,default:void 0},showCurrentParticle:{type:Boolean,default:void 0},forecastModel:{type:String}},emits:["weather","other","toggleWindParticle","toggleWindFeather","toggleCurrentParticle","toggleCurrentIsoband","toggleWindParticeVersion","toggleCurrentParticeVersion","coordinate","measure","point","3d","layerToggle","handleToggleVersion","login","forecastModel"],data(){return{autoActive:!0,layers:{weather:[...j.LayerHelper.WEATHER_LAYERS.filter(a=>!["swell-height","swell-direction","current-direction","current-speed"].includes(a.key))],other:[...j.LayerHelper.OTHER_LAYERS.filter(a=>a.enabled)]},activeWeatherLayers:[],activeWeatherLayersCollected:[],activeOtherLayers:[],autoActiveCache:"autoActiveCache",activeWeatherLayersCache:"activeWeatherLayersCache",activeOtherLayersCache:"activeOtherLayersCache",collectedLayerCache:"collectedLayerCache",sourceCache:"defaultSourceCache",windFeatherCollectedCache:"windFeatherCollectedCache",currentIsobandCollectedCache:"currentIsobandCollectedCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.1.0",k:"glCacheVersion"},source:"Best Match",sourceList:[],right:10,rampColorLayers:["visibility","precip3h","temp","water-temp","ice-thickness","ice-cover"],showWindParticleCollected:!1,showWindFeatherCollected:!1,showCurrentParticleCollected:!1,showCurrentIsobandCollected:!1}},computed:{computeLayerClass(){return function(a,t){var o;let i="layer flex-between";return t.some(r=>r.key===a.key)&&(i=i+" active"),(!a.enabled||(o=this.layers.weather)!=null&&o.some(r=>r.key===a.key)&&!this.autoActive||this.rampColorLayers.includes(a.key)&&this.mapProjection==="globe")&&(i=i+" disabled"),i}},hasCollectedLayers(){var a;return((a=this.layers.weather.filter(t=>t.collected))==null?void 0:a.length)>0},computeDateZ(){return function(a){var t;if(a){const i=T(a);return`${(t=i==null?void 0:i.utc())==null?void 0:t.format("MMM-DD/HHmm")}Z`}return"-"}}},watch:{toggleVersion:{handler(){this.$nextTick(()=>{var a;this.right=(((a=document.getElementsByClassName("right-bar")[0])==null?void 0:a.clientWidth)||0)+10})}},source:{handler(a,t){a&&a!==t&&this.$emit("forecastModel",this.source),a&&t&&a!==t&&this.handleConfirm()}},activeWeatherLayers:{handler(a,t){this.autoActive&&(this.activeWeatherLayersCollected=this.activeWeatherLayers,localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))}},showWindParticle:{handler(a,t){this.autoActive&&(this.showWindParticleCollected=this.showWindParticle)}},showWindFeather:{handler(a,t){this.autoActive&&(this.showWindFeatherCollected=this.showWindFeather,localStorage.setItem(this.windFeatherCollectedCache,this.showWindFeatherCollected))}},showCurrentParticle:{handler(a,t){this.autoActive&&(this.showCurrentParticleCollected=this.showCurrentParticle)}},showCurrentIsoband:{handler(a,t){this.autoActive&&(this.showCurrentIsobandCollected=this.showCurrentIsoband,localStorage.setItem(this.currentIsobandCollectedCache,this.showCurrentIsobandCollected))}}},async mounted(){await this.fetchMeteoSource(),this.fetchCache(),this.handleConfirm()},methods:{async fetchMeteoSource(){var t;this.sourceList=[];let a=await K.get(`${this.gateway}/api/arc/meteo2/models`,{headers:{Authorization:this.token}});(a==null?void 0:a.data.code)===0&&(this.sourceList=(t=a==null?void 0:a.data.data)==null?void 0:t.weather)},fetchCache(){const a=localStorage.getItem(this.version.k);this.version.v!==a&&(localStorage.removeItem(this.autoActiveCache),localStorage.removeItem(this.activeWeatherLayersCache),localStorage.removeItem(this.activeOtherLayersCache),localStorage.removeItem(this.windFeatherCollectedCache),localStorage.removeItem(this.currentIsobandCollectedCache),localStorage.setItem(this.version.k,this.version.v));let t=localStorage.getItem(this.autoActiveCache);this.autoActive=t!=="false",t=localStorage.getItem(this.collectedLayerCache);let i=JSON.parse(t||'[{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "collected": true},{"weight": 1, "name": "Wind", "key": "wind", "h5": true, "collected": true},{"weight": 96, "name": "Current", "key": "current", "collected": true},{"weight": 256,"name": "Tropicals","key": "tropicals", "collected": true}]');this.layers.weather.forEach(o=>{o.collected=!!i.some(r=>r.key===o.key&&r.collected)}),t=localStorage.getItem(this.activeWeatherLayersCache),t||localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify([{weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0},{weight:4096,name:"Pressure",key:"prmsl",enabled:!0,type:"json"},{weight:256,name:"Tropicals",key:"tropicals",enabled:!0,type:"json"}])),t=localStorage.getItem(this.activeWeatherLayersCache),i=JSON.parse(t),this.autoActive?this.activeWeatherLayers=[...i]:this.activeWeatherLayersCollected=[...i],i.some(o=>o.key==="wind"&&o.particle)&&(this.$emit("toggleWindParticle",!0),this.showWindParticleCollected=!0),i.some(o=>o.key==="current"&&o.particle)&&(this.$emit("toggleCurrentParticle",!0),this.showCurrentParticleCollected=!0),this.showWindFeatherCollected=JSON.parse(localStorage.getItem(this.windFeatherCollectedCache)),this.showCurrentIsobandCollected=JSON.parse(localStorage.getItem(this.currentIsobandCollectedCache)),this.autoActive&&(this.$emit("toggleWindFeather",this.showWindFeatherCollected),this.$emit("toggleCurrentIsoband",this.showCurrentIsobandCollected)),i.some(o=>o.key==="wind"&&!o.particle&&!this.showWindFeatherCollected)&&(i=i.filter(o=>o.key!=="wind")),i.some(o=>o.key==="current"&&!o.particle&&!this.showCurrentIsobandCollected)&&(i=i.filter(o=>o.key!=="current")),t=localStorage.getItem(this.activeOtherLayersCache),i=JSON.parse(t||'[{"weight":4,"name":"ECA Zones","key":"eca-zones","enabled":true,"type":"json"}, {"weight": 2048,"name": "ENC","key": "enc","h5": true,"enabled": true,"type": "origin"}]'),this.activeOtherLayers=i,t=localStorage.getItem(this.sourceCache),this.source=this.forecastModel?this.forecastModel:t?t==="CMEMS"?"ECMWF":t:this.source,this.$emit("forecastModel",this.source)},handleConfirm(){var a;if(this.autoActive){const t=(a=this.sourceList.find(i=>i.name===this.source))==null?void 0:a.code;this.$emit("weather",JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),t)}this.$emit("other",this.activeOtherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(a){var i;if(this.activeWeatherLayers=JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.rampColorLayers.includes(a.key)&&this.mapProjection==="globe"||!this.autoActive)return!1;(a.key==="wind"&&!this.showWindFeather||a.key==="current"&&!this.showCurrentIsoband)&&(a.particle=!0),this.activeWeatherLayers.some(o=>o.key===a.key)?this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.key!==a.key):this.activeWeatherLayers.length<6&&a.enabled&&(["png","jpg"].includes(a.type)?(this.activeWeatherLayers.forEach(o=>{(o.key==="wind"&&this.showWindFeather||a.key==="current"&&this.showCurrentIsoband)&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))):a.key==="wind"?(this.activeWeatherLayers.forEach(o=>{o.key==="current"&&this.showCurrentIsoband&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))):a.key==="current"&&(this.activeWeatherLayers.forEach(o=>{o.key==="wind"&&this.showWindFeather&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))),this.activeWeatherLayers.push(a));const t=(i=this.sourceList.find(o=>o.name===this.source))==null?void 0:i.code;this.$emit("weather",this.activeWeatherLayers,t)},handleWeatherLayerCollect(a){var t;if(!this.autoActive)return!1;!a.collected&&((t=this.layers.weather.filter(i=>i.collected))==null?void 0:t.length)>=6&&(this.layers.weather.filter(i=>i.collected)[0].collected=!1),a.collected=!a.collected,localStorage.setItem(this.collectedLayerCache,JSON.stringify(this.layers.weather)),this.$emit("handleToggleVersion")},handleToggleWindParticle(){!this.showWindFeather&&this.showWindParticle?this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}):(this.showCurrentParticle&&(this.$emit("toggleCurrentParticle",!1),this.showCurrentIsoband||(this.activeWeatherLayers=this.activeWeatherLayers.filter(a=>a.key!=="current"))),this.$emit("toggleWindParticle",!this.showWindParticle),this.$emit("toggleWindParticeVersion"))},handleToggleWindFeather(){this.showWindFeather&&!this.showWindParticle&&this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}),this.$emit("toggleWindFeather",!this.showWindFeather)},handleToggleCurrentParticle(){!this.showCurrentIsoband&&this.showCurrentParticle?this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",enabled:!0,type:"json",particle:!0}):(this.showWindParticle&&(this.$emit("toggleWindParticle",!1),this.showWindFeather||(this.activeWeatherLayers=this.activeWeatherLayers.filter(a=>a.key!=="wind"))),this.$emit("toggleCurrentParticle",!this.showCurrentParticle),this.$emit("toggleCurrentParticeVersion"))},handleToggleCurrentIsoband(){this.showCurrentIsoband&&!this.showCurrentParticle&&this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",vendor:"cmems",merge:!0,h5:!0,enabled:!0}),this.$emit("toggleCurrentIsoband",!this.showCurrentIsoband)},handleOtherLayerPick(a){this.activeOtherLayers.some(t=>t.key===a.key)?this.activeOtherLayers=this.activeOtherLayers.filter(t=>t.key!==a.key):a.enabled&&this.activeOtherLayers.push(a),localStorage.setItem(this.activeOtherLayersCache,JSON.stringify(this.activeOtherLayers)),this.$emit("other",this.activeOtherLayers)},handleMenuToggle(){this.$emit("layerToggle",!this.layerToggle)},toggleAutoActive(){var t;const a=(t=this.sourceList.find(i=>i.name===this.source))==null?void 0:t.code;this.autoActive=!this.autoActive,localStorage.setItem(this.autoActiveCache,this.autoActive),this.autoActive?(this.$emit("weather",this.activeWeatherLayersCollected,a),this.$emit("toggleWindFeather",localStorage.getItem(this.windFeatherCollectedCache)==="true"),this.$emit("toggleCurrentIsoband",localStorage.getItem(this.currentIsobandCollectedCache)==="true")):(this.$emit("weather",[],a),this.$emit("toggleWindFeather",!1),this.$emit("toggleCurrentIsoband",!1))},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.isLogin?(this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)):this.$emit("login")},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)}}},qe={class:"idm-gl3-layer"},Ze={class:"bar-item layer-bars"},$e={class:"bar-item tool-bars"},et={class:"flex-between"},tt={key:0,class:"iconfont active"},at={key:1,class:"iconfont"},it=["onClick"],rt=["onClick"],ot={key:0,class:"flex-start"},st={key:1,class:"flex-start"},nt={class:"header-box flex-between"},lt={class:"weather-layers card-bg"},ct={class:"layers-title flex-between"},ht={key:0,class:"iconfont active"},dt={key:1,class:"iconfont"},pt={class:"layers-body"},mt={class:"flex-start"},gt=["onClick"],At=["onClick"],yt={key:0,class:"flex-start"},ft={key:1,class:"flex-start"},ut=["onClick"],wt={key:0,class:"iconfont bookmark-icon active"},bt={key:1,class:"iconfont bookmark-icon inactive"},Lt={class:"other-layers card-bg"},Ct={class:"layers-body"},xt=["onClick"],Bt={class:"flex-start"},Et={class:"switch flex-center"},vt={key:0,class:"iconfont active"},It={key:1,class:"iconfont"},kt={class:"source-layers card-bg"},Dt={class:"layers-body"},Pt={key:0},Nt={key:1,class:"radio-tip"},zt={key:2,class:"radio-tip"};function St(a,t,i,o,r,s){const l=e.resolveComponent("ElTooltip"),c=e.resolveComponent("ElRadio"),h=e.resolveComponent("ElRadioGroup"),d=e.resolveComponent("ElScrollbar");return e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",{class:"menu-bar-box",style:e.normalizeStyle({top:i.top+10+"px",right:r.right+"px"})},[e.createElementVNode("div",Ze,[e.createVNode(l,{placement:"left",effect:"light",content:"Menu","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(i.layerToggle?"menu-icon active":"menu-icon"),onClick:t[0]||(t[0]=(...n)=>s.handleMenuToggle&&s.handleMenuToggle(...n))},t[17]||(t[17]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),e.createElementVNode("div",{class:"menu-bar-box",style:e.normalizeStyle({top:i.top+160+"px",right:r.right+"px"})},[e.createElementVNode("div",$e,[e.createVNode(l,{placement:"left",effect:"light",content:"Measure","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showMeasure?"menu-icon active":"menu-icon"),onClick:t[1]||(t[1]=(...n)=>s.handleMeasureToggle&&s.handleMeasureToggle(...n))},t[18]||(t[18]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"Point Meteo","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showPoint?"menu-icon active":"menu-icon"),onClick:t[2]||(t[2]=(...n)=>s.handlePointToggle&&s.handlePointToggle(...n))},t[19]||(t[19]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"Grid","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showCoord?"menu-icon active":"menu-icon"),onClick:t[3]||(t[3]=(...n)=>s.handleCoordToggle&&s.handleCoordToggle(...n))},t[20]||(t[20]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"3D","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.show3d?"menu-icon active":"menu-icon"),onClick:t[4]||(t[4]=(...n)=>s.handle3DToggle&&s.handle3DToggle(...n))},t[21]||(t[21]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),s.hasCollectedLayers?(e.openBlock(),e.createElementBlock("div",{key:0,class:"active-layers",style:e.normalizeStyle({right:r.right+"px",bottom:"100px"})},[e.createElementVNode("div",et,[t[22]||(t[22]=e.createElementVNode("div",{style:{margin:"2px 5px"}},"Weather Layers",-1)),e.createElementVNode("div",{class:"switch flex-center",style:{"font-size":"28px","margin-right":"0"},onClick:t[5]||(t[5]=(...n)=>s.toggleAutoActive&&s.toggleAutoActive(...n))},[r.autoActive?(e.openBlock(),e.createElementBlock("i",tt,"")):(e.openBlock(),e.createElementBlock("i",at,""))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.weather.filter(n=>n.collected),n=>(e.openBlock(),e.createElementBlock("div",{key:n.key,class:e.normalizeClass(s.computeLayerClass(n,r.activeWeatherLayersCollected))},[e.createElementVNode("div",{class:"checkbox",onClick:p=>s.handleWeatherLayerPick(n)},null,8,it),e.createElementVNode("span",{class:"name",onClick:p=>s.handleWeatherLayerPick(n)},e.toDisplayString(n.name),9,rt),n.key==="wind"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",ot,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:t[6]||(t[6]=p=>s.handleToggleWindParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:t[7]||(t[7]=p=>s.handleToggleWindFeather())},"",2)])):e.createCommentVNode("",!0),n.key==="current"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:t[8]||(t[8]=p=>s.handleToggleCurrentParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:t[9]||(t[9]=p=>s.handleToggleCurrentIsoband())},"",2)])):e.createCommentVNode("",!0)],2))),128))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"available-layers flex-center",style:e.normalizeStyle({top:i.top+"px",right:i.layerToggle?"0px":"-240px"})},[e.createElementVNode("div",{class:e.normalizeClass(["list-box",i.layerToggle?"right-bar":""])},[e.createElementVNode("div",nt,[t[23]||(t[23]=e.createElementVNode("div",null,"Layers",-1)),e.createElementVNode("div",{class:"iconfont close-btn",onClick:t[10]||(t[10]=(...n)=>s.handleMenuToggle&&s.handleMenuToggle(...n))},"")]),e.createVNode(d,{style:{flex:"1"}},{default:e.withCtx(()=>[e.createElementVNode("div",lt,[e.createElementVNode("div",ct,[t[24]||(t[24]=e.createElementVNode("div",null,"Weather Layers",-1)),e.createElementVNode("div",{class:"switch flex-center",style:{"margin-right":"0"},onClick:t[11]||(t[11]=(...n)=>s.toggleAutoActive&&s.toggleAutoActive(...n))},[r.autoActive?(e.openBlock(),e.createElementBlock("i",ht,"")):(e.openBlock(),e.createElementBlock("i",dt,""))])]),e.createElementVNode("div",pt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.weather,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.key},[n.hide?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(s.computeLayerClass(n,r.activeWeatherLayersCollected))},[e.createElementVNode("div",mt,[e.createElementVNode("div",{class:"checkbox",onClick:p=>s.handleWeatherLayerPick(n)},null,8,gt),e.createElementVNode("span",{class:"name",onClick:p=>s.handleWeatherLayerPick(n)},e.toDisplayString(n.name),9,At),n.key==="wind"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",yt,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:t[12]||(t[12]=p=>s.handleToggleWindParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:t[13]||(t[13]=p=>s.handleToggleWindFeather())},"",2)])):e.createCommentVNode("",!0),n.key==="current"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",ft,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:t[14]||(t[14]=p=>s.handleToggleCurrentParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:t[15]||(t[15]=p=>s.handleToggleCurrentIsoband())},"",2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{onClick:p=>s.handleWeatherLayerCollect(n)},[n.collected?(e.openBlock(),e.createElementBlock("i",wt,"")):(e.openBlock(),e.createElementBlock("i",bt,""))],8,ut)],2))],64))),128)),t[25]||(t[25]=e.createElementVNode("div",{class:"tip flex-start"},[e.createElementVNode("i",{class:"iconfont bookmark-icon",style:{"align-self":"flex-start",padding:"5px 5px 0 0"}},""),e.createElementVNode("div",null,"You can add the layers to your favorites. (Max 6)")],-1))])]),e.createElementVNode("div",Lt,[t[26]||(t[26]=e.createElementVNode("div",{class:"layers-title"},"Other Layers",-1)),e.createElementVNode("div",Ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.other,n=>{var p;return e.openBlock(),e.createElementBlock("div",{key:n.key,class:e.normalizeClass(["layer flex-between",s.computeLayerClass(n,r.activeOtherLayers)]),onClick:f=>s.handleOtherLayerPick(n)},[e.createElementVNode("div",Bt,[e.createElementVNode("div",Et,[(p=s.computeLayerClass(n,r.activeOtherLayers))!=null&&p.includes("active")?(e.openBlock(),e.createElementBlock("i",vt,"")):(e.openBlock(),e.createElementBlock("i",It,""))]),e.createElementVNode("span",null,e.toDisplayString(n.name),1)])],10,xt)}),128))])]),e.createElementVNode("div",kt,[t[27]||(t[27]=e.createElementVNode("span",{class:"layers-title"},"Forecast Model",-1)),e.createElementVNode("div",Dt,[e.createVNode(h,{modelValue:r.source,"onUpdate:modelValue":t[16]||(t[16]=n=>r.source=n),class:"layer-radio flex-col-start-start",style:{width:"180px","align-items":"flex-start"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceList,(n,p)=>(e.openBlock(),e.createBlock(c,{key:`source${n.name}`,value:n.name},{default:e.withCtx(()=>{var f,u,g,B,w,A;return[e.createTextVNode(e.toDisplayString(n.name)+" ",1),p!==0?(e.openBlock(),e.createElementBlock("span",Pt,e.toDisplayString(n.resolution)+"km "+e.toDisplayString(n.length)+"days",1)):e.createCommentVNode("",!0),p===0?(e.openBlock(),e.createElementBlock("div",Nt,"Provides the best forecast")):(g=(u=(f=n==null?void 0:n.update)==null?void 0:f.default)==null?void 0:u.meta)!=null&&g.initialisationTime?(e.openBlock(),e.createElementBlock("div",zt,"Update: "+e.toDisplayString(s.computeDateZ((A=(w=(B=n==null?void 0:n.update)==null?void 0:B.default)==null?void 0:w.meta)==null?void 0:A.initialisationTime)),1)):e.createCommentVNode("",!0)]}),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])])])]),_:1})],2)],4)])}const Mt=D(Je,[["render",St]]),bo="",Tt={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},current:{type:Object},beforeLayer:{type:String},mapProjection:{type:String},showWindFeather:{type:Boolean,default:!1},showWindParticle:{type:Boolean,default:!1},toggleParticeVersion:{type:Number},toggleVersion:{type:Number}},emits:["particle","showWindFeather"],data(){return{source:"wind-barb-source",barbs:[0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],empty:I.featureCollection([]),right:10,bottom:125,windBarbLoaded:!1}},watch:{"wind.version":{handler(){var a;(a=this.wind)!=null&&a.active&&this.showWindFeather?this.handleRender():this.handleClear()},deep:!0},toggleParticeVersion:{handler(){this.handleParticle()}},showWindFeather:{handler(){this.handleToggle()}}},methods:{handleParticle(){this.$emit("particle",{particle:this.showWindParticle,key:"wind",weight:1})},handleRender(){var a,t,i,o;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const r=new Date().valueOf();let s=0,l=0,c=this.empty;if((a=this.wind)!=null&&a.active&&(c=(t=this.wind)==null?void 0:t.data),(i=this.map)!=null&&i.getSource(this.source))(o=this.map)==null||o.getSource(this.source).setData(c),l=new Date().valueOf()-(r+s),console.log("[wind] update elapsed: ",l,", total: ",s+=l);else{this.map.addSource(this.source,{type:"geojson",data:c});for(let h=0;h<(this.barbs??[]).length-1;h++){const d=(this.barbs??[])[h]||0,n=(this.barbs??[])[h+1]||0,p=d<10?`00${d}kts`:d<100?`0${d}kts`:`${d}kts`;this.map.addLayer({id:p,type:"symbol",filter:["all",[">=","spd",d],["<","spd",n]],source:this.source,layout:{"symbol-placement":"point","icon-image":p,"icon-size":.14,"icon-offset":[0,-20],"icon-allow-overlap":!0,"icon-rotation-alignment":"map","icon-rotate":{property:"dir",stops:[[0,0],[360,360]]}},paint:{"icon-opacity":1,"text-color":"#222"}},this.beforeLayer)}this.windBarbLoaded=!0,l=new Date().valueOf()-(r+s),console.log("[wind] add elapsed: ",l,", total: ",s+=l)}}},handleToggle(){if(!this.windBarbLoaded)this.handleRender();else for(const a of this.barbs??[]){const t=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(t)&&this.map.setLayoutProperty(t,"visibility",this.showWindFeather?"visible":"none")}},handleClear(){for(const a of this.barbs??[]){const t=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(t)&&this.map.removeLayer(t)}this.map.getSource(this.source)&&this.map.removeSource(this.source),this.windBarbLoaded=!1}}};function Qt(a,t,i,o,r,s){return null}const Ht=D(Tt,[["render",Qt]]);class Ne{constructor(t){H(this,"map");H(this,"mercator");H(this,"rampColorLayer");H(this,"rampColorSource");H(this,"particleLayer");H(this,"particleSource");H(this,"rampColorCanvas");H(this,"particleCanvas");H(this,"ratio");this.map=t,this.mercator=new Ke,this.rampColorLayer="ramp-color-layer",this.rampColorSource="ramp-color-source",this.particleLayer="particle-layer",this.particleSource="particle-source",this.rampColorCanvas=document.createElement("canvas"),this.particleCanvas=document.createElement("canvas"),this.ratio=window.devicePixelRatio}convertNLng(t,i=0){return t>180?this.convertNLng(t-360,i+1):t<-180?this.convertNLng(t+360,i+1):[t,i]}getBoundLngLat(){const t=this.map.getBounds();return[[t._sw.lng,t._ne.lat],[t._ne.lng,t._ne.lat],[t._ne.lng,t._sw.lat],[t._sw.lng,t._sw.lat]]}getBoundPixel(){const t=this.map.getBounds(),i=this.map.getZoom()+1,o=[t._ne.lng,t._ne.lat],r=[t._sw.lng,t._sw.lat],[s,l]=this.convertNLng(o[0]),[c,h]=this.convertNLng(r[0]),[d,n]=this.mercator.px([s,o[1]],i),[p,f]=this.mercator.px([c,r[1]],i),u=Math.round(this.mercator.size*Math.pow(2,i)*(l+h));return[p,f,d+u,n]}getBoundRange(){const t=this.map.getZoom()+1,i=this.mercator.size*Math.pow(2,t),o=this.getBoundPixel();return[o[0]/i,o[2]/i,o[3]/i,o[1]/i]}getWorldCopy(t,i){const o=2**i,[r,s,l,c]=t.map(n=>~~(n/(o*256))),h=[];for(let n=c;n<=s;n++)for(let p=r;p<=l;p++)h.push([p,n]);return h.map(n=>{const p=2**i*256;return[n[0]*p,n[1]*p,p]})}resize(){let t=this.map.getSource(this.rampColorSource);t.setCoordinates(this.getBoundLngLat()),t=this.map.getSource(this.particleSource),t.setCoordinates(this.getBoundLngLat()),this.rampColorCanvas.width=this.map._canvas.clientWidth,this.rampColorCanvas.height=this.map._canvas.clientHeight,this.particleCanvas.width=this.map._canvas.clientWidth,this.particleCanvas.height=this.map._canvas.clientHeight}toggle(t){const i=this.map.getLayoutProperty(this.rampColorLayer,"visibility"),o=t?"visible":"none";i!==o&&this.map.setLayoutProperty(this.rampColorLayer,"visibility",o)}toggleParticle(t){const i=this.map.getLayoutProperty(this.particleLayer,"visibility"),o=t?"visible":"none";i!==o&&this.map.setLayoutProperty(this.particleLayer,"visibility",o)}}class le{createShader(t,i,o){const r=t.createShader(i);if(r&&(t.shaderSource(r,o),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)))throw new Error(t.getShaderInfoLog(r)||"error happened while create shader...");return r}createTexture(t,i,o,r,s,l,c){const h=t.createTexture();return t.bindTexture(t.TEXTURE_2D,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,r),s instanceof Uint8Array?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,l,c,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,s),t.bindTexture(t.TEXTURE_2D,null),h}createDataBuffer(t,i,o){if(t){const r=t.createBuffer();return i==="array"?(t.bindBuffer(t.ARRAY_BUFFER,r),o&&t.bufferData(t.ARRAY_BUFFER,o,t.STATIC_DRAW)):i==="element"&&(t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r),o&&t.bufferData(t.ELEMENT_ARRAY_BUFFER,o,t.STATIC_DRAW)),r}return null}createProgram(t,i,o){const r=t.createProgram(),s=this.createShader(t,t.VERTEX_SHADER,i),l=this.createShader(t,t.FRAGMENT_SHADER,o);if(r&&s&&l&&(t.attachShader(r,s),t.attachShader(r,l),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)))throw new Error(t.getProgramInfoLog(r)||"error happened while creating ramp color program");return r}createProgramWrapper(t,i,o){const r=this.createProgram(t,i,o);if(r){const s={program:r},l=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let h=0;h<l;h++){const d=t.getActiveAttrib(r,h);s[d.name]=t.getAttribLocation(r,d.name)}const c=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let h=0;h<c;h++){const d=t.getActiveUniform(r,h);s[d.name]=t.getUniformLocation(r,d.name)}return s}}setup(t,i,o=!1,r,s){const l=document.createElement("canvas");l.width=256,l.height=1;const c=l.getContext("2d");if(c&&t){const h=c==null?void 0:c.createLinearGradient(0,0,256,0);return i.forEach(([d,n])=>{h.addColorStop(d,n)}),c.fillStyle=h,c.fillRect(0,0,256,1),{canvas:l,texture:this.createTexture(t,t.LINEAR,t.LINEAR,t.CLAMP_TO_EDGE,o?new Uint8Array(c.getImageData(0,0,256,1).data):l,r,s)}}}setupParticle(t,i=1e3){const o=Math.ceil(Math.sqrt(i)),r=o*o,s=new Uint8Array(r*4);for(let n=0;n<s.length;n++)s[n]=Math.floor(Math.random()*256);const l=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,o,o),c=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,o,o),h=new Float32Array(r);for(let n=0;n<r;n++)h[n]=n;const d=this.createDataBuffer(t,"array",h);return{resolution:o,total:r,texture0:l,texture1:c,indexBuffer:d}}bind(t,i,o){const r=this.createProgram(t,i,o);if(r){const s=this.createDataBuffer(t,"array",void 0),l=t.getAttribLocation(r,"a_position");t.enableVertexAttribArray(l),t.vertexAttribPointer(l,2,t.FLOAT,!1,0,0);const c=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(t,"array",c);const h=t.getAttribLocation(r,"a_texCoord");return t.enableVertexAttribArray(h),t.vertexAttribPointer(h,2,t.FLOAT,!1,0,0),{program:r,aPositionBuffer:s}}return{}}bindParticle(t,i,o,r,s,l){const c=this.createProgramWrapper(t,i,o),h=this.createProgramWrapper(t,r,s),d=this.createProgramWrapper(t,r,l),n=this.createDataBuffer(t,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),p=t.createFramebuffer();return{particle:c,screen:h,update:d,quadBuffer:n,frameBuffer:p}}draw(t,i,o,r,s,l,c){var h,d;if(i&&o){t.resize(),i==null||i.viewport(0,0,(h=i==null?void 0:i.canvas)==null?void 0:h.width,(d=i==null?void 0:i.canvas)==null?void 0:d.height),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT);try{i.useProgram(o);const n={resolution:i.getUniformLocation(o,"u_resolution"),image:i.getUniformLocation(o,"u_image"),color:i.getUniformLocation(o,"u_color"),scale:i.getUniformLocation(o,"u_scale"),uvRange:i.getUniformLocation(o,"u_range_u_v"),sRange:i.getUniformLocation(o,"u_range_s")};n.resolution&&i.uniform2f(n.resolution,i.canvas.width*t.ratio,i.canvas.height*t.ratio),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,r),n.image&&i.uniform1i(n.image,0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,s),n.color&&i.uniform1i(n.color,1),c!=null&&c.uvRange&&(c!=null&&c.sRange)&&(n.uvRange&&i.uniform2f(n.uvRange,c.uvRange[0],c.uvRange[1]),n.sRange&&i.uniform2f(n.sRange,c.sRange[0],c.sRange[1])),n.scale&&i.uniform1f(n.scale,(c==null?void 0:c.scale)||1);const p=t.getBoundPixel(),f=t.map.getZoom()+1,u=t.getWorldCopy(p,f);for(const g of u){const B=(g[0]-p[0])*t.ratio,w=(g[1]-p[3])*t.ratio,A=g[2]*t.ratio,[m,L,y,x]=[B,A+B,w,A+w],E=new Float32Array([m,y,L,y,m,x,m,x,L,y,L,x]);i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,E,i.STATIC_DRAW),i.drawArrays(i.TRIANGLES,0,6)}}catch(n){console.log(`render failed...${n}`)}}}drawParticle(t,i,o,r,s){var l,c;i&&(i==null||i.viewport(0,0,(l=i==null?void 0:i.canvas)==null?void 0:l.width,(c=i==null?void 0:i.canvas)==null?void 0:c.height),i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,o),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,r.texture0),this.renderScreen(t,i,r,s),this.updateParticles(t,i,r,s))}renderScreen(t,i,o,r){i.bindFramebuffer(i.FRAMEBUFFER,o.frameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.screenTexture,0),i.viewport(0,0,i.canvas.width,i.canvas.height),this.renderScreenTexture(i,o.backgroundTexture,o.screen,o.quadBuffer,.95),this.renderParticles(t,i,o,r),i.bindFramebuffer(i.FRAMEBUFFER,null),this.renderScreenTexture(i,o.screenTexture,o.screen,o.quadBuffer,1);const s=o.backgroundTexture;o.backgroundTexture=o.screenTexture,o.screenTexture=s}renderScreenTexture(t,i,o,r,s){t&&(t.useProgram(o.program),t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(o.a_pos),t.vertexAttribPointer(o.a_pos,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,i),t.uniform1i(o.u_screen,2),t.uniform1f(o.u_opacity,s),t.drawArrays(t.TRIANGLES,0,6))}renderParticles(t,i,o,r){if(i){i.useProgram(o.particle.program),i.bindBuffer(i.ARRAY_BUFFER,o.indexBuffer),i.enableVertexAttribArray(o.particle.a_index),i.vertexAttribPointer(o.particle.a_index,1,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,o.color.texture),i.uniform1i(o.particle.u_factor,0),i.uniform1i(o.particle.u_particles,1),i.uniform1i(o.particle.u_color_ramp,2),i.uniform1f(o.particle.u_particles_resolution,o.resolution*t.ratio),i.uniform1f(o.particle.u_point,t.ratio);const s=t.getBoundRange();i.uniform4f(o.particle.u_viewport,s[0],s[1],s[2],s[3]),i.uniform2f(o.particle.u_factor_min,r.uvRange[0],r.uvRange[0]),i.uniform2f(o.particle.u_factor_max,r.uvRange[1],r.uvRange[1]),i.drawArrays(i.POINTS,0,o.total)}}updateParticles(t,i,o,r){var l,c;if(i){i.bindFramebuffer(i.FRAMEBUFFER,o.frameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.texture1,0),i.viewport(0,0,o.resolution,o.resolution),i.useProgram(o.update.program),i.bindBuffer(i.ARRAY_BUFFER,o.quadBuffer),i.enableVertexAttribArray(o.update.a_pos),i.vertexAttribPointer(o.update.a_pos,2,i.FLOAT,!1,0,0),i.uniform1i(o.update.u_factor,0),i.uniform1i(o.update.u_particles,1);const h=t.getBoundRange();i.uniform4f(o.update.u_viewport,h[0],h[1],h[2],h[3]),i.uniform1f(o.update.u_rand_seed,Math.random()),i.uniform2f(o.update.u_factor_res,(l=o==null?void 0:o.image)==null?void 0:l.width,(c=o==null?void 0:o.image)==null?void 0:c.height),i.uniform2f(o.update.u_factor_min,r.uvRange[0],r.uvRange[0]),i.uniform2f(o.update.u_factor_max,r.uvRange[1],r.uvRange[1]),i.uniform1f(o.update.u_speed_factor,r.speedFactor*t.ratio),i.uniform1f(o.update.u_drop_rate,r.dropRate),i.uniform1f(o.update.u_drop_rate_bump,r.dropRateBump),i.drawArrays(i.TRIANGLES,0,6)}const s=o.texture0;o.texture0=o.texture1,o.texture1=s}resize(t,i){t.resize();const o=new Uint8Array(i.canvas.width*i.canvas.height*4).fill(0,0,i.canvas.width*i.canvas.height*4),r=this.createTexture(i,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,o,i.canvas.width,i.canvas.height),s=this.createTexture(i,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,o,i.canvas.width,i.canvas.height);return{screenTexture:r,backgroundTexture:s}}async loadImg(t){return new Promise(i=>{const o=new Blob([t],{type:t.type}),r=URL.createObjectURL(o),s=new Image;s.crossOrigin="anonymous",s.src=r,s.onload=()=>i(s)})}}class O{}H(O,"vertexSchema",`
1
+ (function(M,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@idm-plugin/tag"),require("moment"),require("axios"),require("moment-timezone"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("mapbox-gl"),require("@idm-plugin/geo"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","moment","axios","moment-timezone","vue","@turf/turf","@mapbox/sphericalmercator","mapbox-gl","@idm-plugin/geo","@idm-plugin/meteo"],j):(M=typeof globalThis<"u"?globalThis:M||self,j(M["idm-gl"]={},M["@idm-plugin/tag"],M.moment,M.axios,M["moment-timezone"],M.Vue,M["@turf/turf"],M["@mapbox/sphericalmercator"],M["mapbox-gl"],M["@idm-plugin/geo"],M["@idm-plugin/meteo"]))})(this,function(M,j,T,K,de,e,Ye,Ke,ne,N,ce){"use strict";var yo=Object.defineProperty;var fo=(M,j,T)=>j in M?yo(M,j,{enumerable:!0,configurable:!0,writable:!0,value:T}):M[j]=T;var H=(M,j,T)=>(fo(M,typeof j!="symbol"?j+"":j,T),T);function Xe(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const i in a)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>a[i]})}}return t.default=a,Object.freeze(t)}const I=Xe(Ye),uo="",wo="",D=(a,t)=>{const i=a.__vccOpts||a;for(const[o,r]of t)i[o]=r;return i},Je={name:"IdmGlLayer",props:{map:{type:Object},mapProjection:{type:String},gateway:{type:String},token:{type:String},top:{type:Number,default:60},layerToggle:{type:Boolean,default:!1},toggleVersion:{type:Number},isLogin:{type:Boolean,default:void 0},showWindFeather:{type:Boolean,default:void 0},showWindParticle:{type:Boolean,default:void 0},showCurrentIsoband:{type:Boolean,default:void 0},showCurrentParticle:{type:Boolean,default:void 0},forecastModel:{type:String}},emits:["weather","other","toggleWindParticle","toggleWindFeather","toggleCurrentParticle","toggleCurrentIsoband","toggleWindParticeVersion","toggleCurrentParticeVersion","coordinate","measure","point","3d","layerToggle","handleToggleVersion","login","forecastModel"],data(){return{autoActive:!0,layers:{weather:[...j.LayerHelper.WEATHER_LAYERS.filter(a=>!["swell-height","swell-direction","current-direction","current-speed"].includes(a.key))],other:[...j.LayerHelper.OTHER_LAYERS.filter(a=>a.enabled)]},activeWeatherLayers:[],activeWeatherLayersCollected:[],activeOtherLayers:[],autoActiveCache:"autoActiveCache",activeWeatherLayersCache:"activeWeatherLayersCache",activeOtherLayersCache:"activeOtherLayersCache",collectedLayerCache:"collectedLayerCache",sourceCache:"defaultSourceCache",windFeatherCollectedCache:"windFeatherCollectedCache",currentIsobandCollectedCache:"currentIsobandCollectedCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.1.0",k:"glCacheVersion"},source:"Best Match",sourceList:[],right:10,rampColorLayers:["visibility","precip3h","temp","water-temp","ice-thickness","ice-cover"],showWindParticleCollected:!1,showWindFeatherCollected:!1,showCurrentParticleCollected:!1,showCurrentIsobandCollected:!1}},computed:{computeLayerClass(){return function(a,t){var o;let i="layer flex-between";return t.some(r=>r.key===a.key)&&(i=i+" active"),(!a.enabled||(o=this.layers.weather)!=null&&o.some(r=>r.key===a.key)&&!this.autoActive||this.rampColorLayers.includes(a.key)&&this.mapProjection==="globe")&&(i=i+" disabled"),i}},hasCollectedLayers(){var a;return((a=this.layers.weather.filter(t=>t.collected))==null?void 0:a.length)>0},computeDateZ(){return function(a){var t;if(a){const i=T(a);return`${(t=i==null?void 0:i.utc())==null?void 0:t.format("MMM-DD/HHmm")}Z`}return"-"}}},watch:{toggleVersion:{handler(){this.$nextTick(()=>{var a;this.right=(((a=document.getElementsByClassName("right-bar")[0])==null?void 0:a.clientWidth)||0)+10})}},source:{handler(a,t){a&&a!==t&&this.$emit("forecastModel",this.source),a&&t&&a!==t&&this.handleConfirm()}},activeWeatherLayers:{handler(a,t){this.autoActive&&(this.activeWeatherLayersCollected=this.activeWeatherLayers,localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))}},showWindParticle:{handler(a,t){this.autoActive&&(this.showWindParticleCollected=this.showWindParticle)}},showWindFeather:{handler(a,t){this.autoActive&&(this.showWindFeatherCollected=this.showWindFeather,localStorage.setItem(this.windFeatherCollectedCache,this.showWindFeatherCollected))}},showCurrentParticle:{handler(a,t){this.autoActive&&(this.showCurrentParticleCollected=this.showCurrentParticle)}},showCurrentIsoband:{handler(a,t){this.autoActive&&(this.showCurrentIsobandCollected=this.showCurrentIsoband,localStorage.setItem(this.currentIsobandCollectedCache,this.showCurrentIsobandCollected))}}},async mounted(){await this.fetchMeteoSource(),this.fetchCache(),this.handleConfirm()},methods:{async fetchMeteoSource(){var t;this.sourceList=[];let a=await K.get(`${this.gateway}/api/arc/meteo2/models`,{headers:{Authorization:this.token}});(a==null?void 0:a.data.code)===0&&(this.sourceList=(t=a==null?void 0:a.data.data)==null?void 0:t.weather)},fetchCache(){const a=localStorage.getItem(this.version.k);this.version.v!==a&&(localStorage.removeItem(this.autoActiveCache),localStorage.removeItem(this.activeWeatherLayersCache),localStorage.removeItem(this.activeOtherLayersCache),localStorage.removeItem(this.windFeatherCollectedCache),localStorage.removeItem(this.currentIsobandCollectedCache),localStorage.setItem(this.version.k,this.version.v));let t=localStorage.getItem(this.autoActiveCache);this.autoActive=t!=="false",t=localStorage.getItem(this.collectedLayerCache);let i=JSON.parse(t||'[{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "collected": true},{"weight": 1, "name": "Wind", "key": "wind", "h5": true, "collected": true},{"weight": 96, "name": "Current", "key": "current", "collected": true},{"weight": 256,"name": "Tropicals","key": "tropicals", "collected": true}]');this.layers.weather.forEach(o=>{o.collected=!!i.some(r=>r.key===o.key&&r.collected)}),t=localStorage.getItem(this.activeWeatherLayersCache),t||localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify([{weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0},{weight:4096,name:"Pressure",key:"prmsl",enabled:!0,type:"json"},{weight:256,name:"Tropicals",key:"tropicals",enabled:!0,type:"json"}])),t=localStorage.getItem(this.activeWeatherLayersCache),i=JSON.parse(t),this.autoActive?this.activeWeatherLayers=[...i]:this.activeWeatherLayersCollected=[...i],i.some(o=>o.key==="wind"&&o.particle)&&(this.$emit("toggleWindParticle",!0),this.showWindParticleCollected=!0),i.some(o=>o.key==="current"&&o.particle)&&(this.$emit("toggleCurrentParticle",!0),this.showCurrentParticleCollected=!0),this.showWindFeatherCollected=JSON.parse(localStorage.getItem(this.windFeatherCollectedCache)),this.showCurrentIsobandCollected=JSON.parse(localStorage.getItem(this.currentIsobandCollectedCache)),this.autoActive&&(this.$emit("toggleWindFeather",this.showWindFeatherCollected),this.$emit("toggleCurrentIsoband",this.showCurrentIsobandCollected)),i.some(o=>o.key==="wind"&&!o.particle&&!this.showWindFeatherCollected)&&(i=i.filter(o=>o.key!=="wind")),i.some(o=>o.key==="current"&&!o.particle&&!this.showCurrentIsobandCollected)&&(i=i.filter(o=>o.key!=="current")),t=localStorage.getItem(this.activeOtherLayersCache),i=JSON.parse(t||'[{"weight":4,"name":"ECA Zones","key":"eca-zones","enabled":true,"type":"json"}, {"weight": 2048,"name": "ENC","key": "enc","h5": true,"enabled": true,"type": "origin"}]'),this.activeOtherLayers=i,t=localStorage.getItem(this.sourceCache),this.source=this.forecastModel?this.forecastModel:t?t==="CMEMS"?"ECMWF":t:this.source,this.$emit("forecastModel",this.source)},handleConfirm(){var a;if(this.autoActive){const t=(a=this.sourceList.find(i=>i.name===this.source))==null?void 0:a.code;this.$emit("weather",JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),t)}this.$emit("other",this.activeOtherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(a){var i;if(this.activeWeatherLayers=JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.rampColorLayers.includes(a.key)&&this.mapProjection==="globe"||!this.autoActive)return!1;(a.key==="wind"&&!this.showWindFeather||a.key==="current"&&!this.showCurrentIsoband)&&(a.particle=!0),this.activeWeatherLayers.some(o=>o.key===a.key)?this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.key!==a.key):this.activeWeatherLayers.length<6&&a.enabled&&(["png","jpg"].includes(a.type)?(this.activeWeatherLayers.forEach(o=>{(o.key==="wind"&&this.showWindFeather||a.key==="current"&&this.showCurrentIsoband)&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))):a.key==="wind"?(this.activeWeatherLayers.forEach(o=>{o.key==="current"&&this.showCurrentIsoband&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))):a.key==="current"&&(this.activeWeatherLayers.forEach(o=>{o.key==="wind"&&this.showWindFeather&&(o.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(o=>o.type==="json"&&!(["wind","current"].includes(o.key)&&o.particle))),this.activeWeatherLayers.push(a));const t=(i=this.sourceList.find(o=>o.name===this.source))==null?void 0:i.code;this.$emit("weather",this.activeWeatherLayers,t)},handleWeatherLayerCollect(a){var t;if(!this.autoActive)return!1;!a.collected&&((t=this.layers.weather.filter(i=>i.collected))==null?void 0:t.length)>=6&&(this.layers.weather.filter(i=>i.collected)[0].collected=!1),a.collected=!a.collected,localStorage.setItem(this.collectedLayerCache,JSON.stringify(this.layers.weather)),this.$emit("handleToggleVersion")},handleToggleWindParticle(){!this.showWindFeather&&this.showWindParticle?this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!1}):(this.showCurrentParticle&&(this.$emit("toggleCurrentParticle",!1),this.showCurrentIsoband||(this.activeWeatherLayers=this.activeWeatherLayers.filter(a=>a.key!=="current"))),this.$emit("toggleWindParticle",!this.showWindParticle),this.$emit("toggleWindParticeVersion"))},handleToggleWindFeather(){this.showWindFeather&&!this.showWindParticle&&this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!1}),this.$emit("toggleWindFeather",!this.showWindFeather)},handleToggleCurrentParticle(){!this.showCurrentIsoband&&this.showCurrentParticle?this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",enabled:!0,type:"json",particle:!1}):(this.showWindParticle&&(this.$emit("toggleWindParticle",!1),this.showWindFeather||(this.activeWeatherLayers=this.activeWeatherLayers.filter(a=>a.key!=="wind"))),this.$emit("toggleCurrentParticle",!this.showCurrentParticle),this.$emit("toggleCurrentParticeVersion"))},handleToggleCurrentIsoband(){this.showCurrentIsoband&&!this.showCurrentParticle&&this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",enabled:!0,type:"json",particle:!1}),this.$emit("toggleCurrentIsoband",!this.showCurrentIsoband)},handleOtherLayerPick(a){this.activeOtherLayers.some(t=>t.key===a.key)?this.activeOtherLayers=this.activeOtherLayers.filter(t=>t.key!==a.key):a.enabled&&this.activeOtherLayers.push(a),localStorage.setItem(this.activeOtherLayersCache,JSON.stringify(this.activeOtherLayers)),this.$emit("other",this.activeOtherLayers)},handleMenuToggle(){this.$emit("layerToggle",!this.layerToggle)},toggleAutoActive(){var t;const a=(t=this.sourceList.find(i=>i.name===this.source))==null?void 0:t.code;this.autoActive=!this.autoActive,localStorage.setItem(this.autoActiveCache,this.autoActive),this.autoActive?(this.$emit("weather",this.activeWeatherLayersCollected,a),this.$emit("toggleWindFeather",localStorage.getItem(this.windFeatherCollectedCache)==="true"),this.$emit("toggleCurrentIsoband",localStorage.getItem(this.currentIsobandCollectedCache)==="true")):(this.$emit("weather",[],a),this.$emit("toggleWindFeather",!1),this.$emit("toggleCurrentIsoband",!1))},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.isLogin?(this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)):this.$emit("login")},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)}}},qe={class:"idm-gl3-layer"},Ze={class:"bar-item layer-bars"},$e={class:"bar-item tool-bars"},et={class:"flex-between"},tt={key:0,class:"iconfont active"},at={key:1,class:"iconfont"},it=["onClick"],rt=["onClick"],ot={key:0,class:"flex-start"},st={key:1,class:"flex-start"},nt={class:"header-box flex-between"},lt={class:"weather-layers card-bg"},ct={class:"layers-title flex-between"},ht={key:0,class:"iconfont active"},dt={key:1,class:"iconfont"},pt={class:"layers-body"},mt={class:"flex-start"},gt=["onClick"],At=["onClick"],yt={key:0,class:"flex-start"},ft={key:1,class:"flex-start"},ut=["onClick"],wt={key:0,class:"iconfont bookmark-icon active"},bt={key:1,class:"iconfont bookmark-icon inactive"},Lt={class:"other-layers card-bg"},Ct={class:"layers-body"},xt=["onClick"],Bt={class:"flex-start"},Et={class:"switch flex-center"},vt={key:0,class:"iconfont active"},It={key:1,class:"iconfont"},kt={class:"source-layers card-bg"},Dt={class:"layers-body"},Pt={key:0},Nt={key:1,class:"radio-tip"},zt={key:2,class:"radio-tip"};function St(a,t,i,o,r,s){const l=e.resolveComponent("ElTooltip"),c=e.resolveComponent("ElRadio"),h=e.resolveComponent("ElRadioGroup"),d=e.resolveComponent("ElScrollbar");return e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",{class:"menu-bar-box",style:e.normalizeStyle({top:i.top+10+"px",right:r.right+"px"})},[e.createElementVNode("div",Ze,[e.createVNode(l,{placement:"left",effect:"light",content:"Menu","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(i.layerToggle?"menu-icon active":"menu-icon"),onClick:t[0]||(t[0]=(...n)=>s.handleMenuToggle&&s.handleMenuToggle(...n))},t[17]||(t[17]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),e.createElementVNode("div",{class:"menu-bar-box",style:e.normalizeStyle({top:i.top+160+"px",right:r.right+"px"})},[e.createElementVNode("div",$e,[e.createVNode(l,{placement:"left",effect:"light",content:"Measure","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showMeasure?"menu-icon active":"menu-icon"),onClick:t[1]||(t[1]=(...n)=>s.handleMeasureToggle&&s.handleMeasureToggle(...n))},t[18]||(t[18]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"Point Meteo","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showPoint?"menu-icon active":"menu-icon"),onClick:t[2]||(t[2]=(...n)=>s.handlePointToggle&&s.handlePointToggle(...n))},t[19]||(t[19]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"Grid","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.showCoord?"menu-icon active":"menu-icon"),onClick:t[3]||(t[3]=(...n)=>s.handleCoordToggle&&s.handleCoordToggle(...n))},t[20]||(t[20]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),e.createVNode(l,{placement:"left",effect:"light",content:"3D","show-after":1e3},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(r.show3d?"menu-icon active":"menu-icon"),onClick:t[4]||(t[4]=(...n)=>s.handle3DToggle&&s.handle3DToggle(...n))},t[21]||(t[21]=[e.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),s.hasCollectedLayers?(e.openBlock(),e.createElementBlock("div",{key:0,class:"active-layers",style:e.normalizeStyle({right:r.right+"px",bottom:"100px"})},[e.createElementVNode("div",et,[t[22]||(t[22]=e.createElementVNode("div",{style:{margin:"2px 5px"}},"Weather Layers",-1)),e.createElementVNode("div",{class:"switch flex-center",style:{"font-size":"28px","margin-right":"0"},onClick:t[5]||(t[5]=(...n)=>s.toggleAutoActive&&s.toggleAutoActive(...n))},[r.autoActive?(e.openBlock(),e.createElementBlock("i",tt,"")):(e.openBlock(),e.createElementBlock("i",at,""))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.weather.filter(n=>n.collected),n=>(e.openBlock(),e.createElementBlock("div",{key:n.key,class:e.normalizeClass(s.computeLayerClass(n,r.activeWeatherLayersCollected))},[e.createElementVNode("div",{class:"checkbox",onClick:p=>s.handleWeatherLayerPick(n)},null,8,it),e.createElementVNode("span",{class:"name",onClick:p=>s.handleWeatherLayerPick(n)},e.toDisplayString(n.name),9,rt),n.key==="wind"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",ot,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:t[6]||(t[6]=p=>s.handleToggleWindParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:t[7]||(t[7]=p=>s.handleToggleWindFeather())},"",2)])):e.createCommentVNode("",!0),n.key==="current"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:t[8]||(t[8]=p=>s.handleToggleCurrentParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:t[9]||(t[9]=p=>s.handleToggleCurrentIsoband())},"",2)])):e.createCommentVNode("",!0)],2))),128))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"available-layers flex-center",style:e.normalizeStyle({top:i.top+"px",right:i.layerToggle?"0px":"-240px"})},[e.createElementVNode("div",{class:e.normalizeClass(["list-box",i.layerToggle?"right-bar":""])},[e.createElementVNode("div",nt,[t[23]||(t[23]=e.createElementVNode("div",null,"Layers",-1)),e.createElementVNode("div",{class:"iconfont close-btn",onClick:t[10]||(t[10]=(...n)=>s.handleMenuToggle&&s.handleMenuToggle(...n))},"")]),e.createVNode(d,{style:{flex:"1"}},{default:e.withCtx(()=>[e.createElementVNode("div",lt,[e.createElementVNode("div",ct,[t[24]||(t[24]=e.createElementVNode("div",null,"Weather Layers",-1)),e.createElementVNode("div",{class:"switch flex-center",style:{"margin-right":"0"},onClick:t[11]||(t[11]=(...n)=>s.toggleAutoActive&&s.toggleAutoActive(...n))},[r.autoActive?(e.openBlock(),e.createElementBlock("i",ht,"")):(e.openBlock(),e.createElementBlock("i",dt,""))])]),e.createElementVNode("div",pt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.weather,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.key},[n.hide?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(s.computeLayerClass(n,r.activeWeatherLayersCollected))},[e.createElementVNode("div",mt,[e.createElementVNode("div",{class:"checkbox",onClick:p=>s.handleWeatherLayerPick(n)},null,8,gt),e.createElementVNode("span",{class:"name",onClick:p=>s.handleWeatherLayerPick(n)},e.toDisplayString(n.name),9,At),n.key==="wind"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",yt,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:t[12]||(t[12]=p=>s.handleToggleWindParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:t[13]||(t[13]=p=>s.handleToggleWindFeather())},"",2)])):e.createCommentVNode("",!0),n.key==="current"&&r.activeWeatherLayersCollected.some(p=>p.key===n.key)?(e.openBlock(),e.createElementBlock("div",ft,[e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:t[14]||(t[14]=p=>s.handleToggleCurrentParticle())},"",2),e.createElementVNode("i",{class:e.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:t[15]||(t[15]=p=>s.handleToggleCurrentIsoband())},"",2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{onClick:p=>s.handleWeatherLayerCollect(n)},[n.collected?(e.openBlock(),e.createElementBlock("i",wt,"")):(e.openBlock(),e.createElementBlock("i",bt,""))],8,ut)],2))],64))),128)),t[25]||(t[25]=e.createElementVNode("div",{class:"tip flex-start"},[e.createElementVNode("i",{class:"iconfont bookmark-icon",style:{"align-self":"flex-start",padding:"5px 5px 0 0"}},""),e.createElementVNode("div",null,"You can add the layers to your favorites. (Max 6)")],-1))])]),e.createElementVNode("div",Lt,[t[26]||(t[26]=e.createElementVNode("div",{class:"layers-title"},"Other Layers",-1)),e.createElementVNode("div",Ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.layers.other,n=>{var p;return e.openBlock(),e.createElementBlock("div",{key:n.key,class:e.normalizeClass(["layer flex-between",s.computeLayerClass(n,r.activeOtherLayers)]),onClick:f=>s.handleOtherLayerPick(n)},[e.createElementVNode("div",Bt,[e.createElementVNode("div",Et,[(p=s.computeLayerClass(n,r.activeOtherLayers))!=null&&p.includes("active")?(e.openBlock(),e.createElementBlock("i",vt,"")):(e.openBlock(),e.createElementBlock("i",It,""))]),e.createElementVNode("span",null,e.toDisplayString(n.name),1)])],10,xt)}),128))])]),e.createElementVNode("div",kt,[t[27]||(t[27]=e.createElementVNode("span",{class:"layers-title"},"Forecast Model",-1)),e.createElementVNode("div",Dt,[e.createVNode(h,{modelValue:r.source,"onUpdate:modelValue":t[16]||(t[16]=n=>r.source=n),class:"layer-radio flex-col-start-start",style:{width:"180px","align-items":"flex-start"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceList,(n,p)=>(e.openBlock(),e.createBlock(c,{key:`source${n.name}`,value:n.name},{default:e.withCtx(()=>{var f,u,g,B,w,A;return[e.createTextVNode(e.toDisplayString(n.name)+" ",1),p!==0?(e.openBlock(),e.createElementBlock("span",Pt,e.toDisplayString(n.resolution)+"km "+e.toDisplayString(n.length)+"days",1)):e.createCommentVNode("",!0),p===0?(e.openBlock(),e.createElementBlock("div",Nt,"Provides the best forecast")):(g=(u=(f=n==null?void 0:n.update)==null?void 0:f.default)==null?void 0:u.meta)!=null&&g.initialisationTime?(e.openBlock(),e.createElementBlock("div",zt,"Update: "+e.toDisplayString(s.computeDateZ((A=(w=(B=n==null?void 0:n.update)==null?void 0:B.default)==null?void 0:w.meta)==null?void 0:A.initialisationTime)),1)):e.createCommentVNode("",!0)]}),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])])])]),_:1})],2)],4)])}const Mt=D(Je,[["render",St]]),bo="",Tt={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},current:{type:Object},beforeLayer:{type:String},mapProjection:{type:String},showWindFeather:{type:Boolean,default:!1},showWindParticle:{type:Boolean,default:!1},toggleParticeVersion:{type:Number},toggleVersion:{type:Number}},emits:["particle","showWindFeather"],data(){return{source:"wind-barb-source",barbs:[0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],empty:I.featureCollection([]),right:10,bottom:125,windBarbLoaded:!1}},watch:{"wind.version":{handler(){var a;(a=this.wind)!=null&&a.active&&this.showWindFeather?this.handleRender():this.handleClear()},deep:!0},toggleParticeVersion:{handler(){this.handleParticle()}},showWindFeather:{handler(){this.handleToggle()}}},methods:{handleParticle(){this.$emit("particle",{particle:this.showWindParticle,key:"wind",weight:1})},handleRender(){var a,t,i,o;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const r=new Date().valueOf();let s=0,l=0,c=this.empty;if((a=this.wind)!=null&&a.active&&(c=(t=this.wind)==null?void 0:t.data),(i=this.map)!=null&&i.getSource(this.source))(o=this.map)==null||o.getSource(this.source).setData(c),l=new Date().valueOf()-(r+s),console.log("[wind] update elapsed: ",l,", total: ",s+=l);else{this.map.addSource(this.source,{type:"geojson",data:c});for(let h=0;h<(this.barbs??[]).length-1;h++){const d=(this.barbs??[])[h]||0,n=(this.barbs??[])[h+1]||0,p=d<10?`00${d}kts`:d<100?`0${d}kts`:`${d}kts`;this.map.addLayer({id:p,type:"symbol",filter:["all",[">=","spd",d],["<","spd",n]],source:this.source,layout:{"symbol-placement":"point","icon-image":p,"icon-size":.14,"icon-offset":[0,-20],"icon-allow-overlap":!0,"icon-rotation-alignment":"map","icon-rotate":{property:"dir",stops:[[0,0],[360,360]]}},paint:{"icon-opacity":1,"text-color":"#222"}},this.beforeLayer)}this.windBarbLoaded=!0,l=new Date().valueOf()-(r+s),console.log("[wind] add elapsed: ",l,", total: ",s+=l)}}},handleToggle(){if(!this.windBarbLoaded)this.handleRender();else for(const a of this.barbs??[]){const t=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(t)&&this.map.setLayoutProperty(t,"visibility",this.showWindFeather?"visible":"none")}},handleClear(){for(const a of this.barbs??[]){const t=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(t)&&this.map.removeLayer(t)}this.map.getSource(this.source)&&this.map.removeSource(this.source),this.windBarbLoaded=!1}}};function Qt(a,t,i,o,r,s){return null}const Ht=D(Tt,[["render",Qt]]);class Ne{constructor(t){H(this,"map");H(this,"mercator");H(this,"rampColorLayer");H(this,"rampColorSource");H(this,"particleLayer");H(this,"particleSource");H(this,"rampColorCanvas");H(this,"particleCanvas");H(this,"ratio");this.map=t,this.mercator=new Ke,this.rampColorLayer="ramp-color-layer",this.rampColorSource="ramp-color-source",this.particleLayer="particle-layer",this.particleSource="particle-source",this.rampColorCanvas=document.createElement("canvas"),this.particleCanvas=document.createElement("canvas"),this.ratio=window.devicePixelRatio}convertNLng(t,i=0){return t>180?this.convertNLng(t-360,i+1):t<-180?this.convertNLng(t+360,i+1):[t,i]}getBoundLngLat(){const t=this.map.getBounds();return[[t._sw.lng,t._ne.lat],[t._ne.lng,t._ne.lat],[t._ne.lng,t._sw.lat],[t._sw.lng,t._sw.lat]]}getBoundPixel(){const t=this.map.getBounds(),i=this.map.getZoom()+1,o=[t._ne.lng,t._ne.lat],r=[t._sw.lng,t._sw.lat],[s,l]=this.convertNLng(o[0]),[c,h]=this.convertNLng(r[0]),[d,n]=this.mercator.px([s,o[1]],i),[p,f]=this.mercator.px([c,r[1]],i),u=Math.round(this.mercator.size*Math.pow(2,i)*(l+h));return[p,f,d+u,n]}getBoundRange(){const t=this.map.getZoom()+1,i=this.mercator.size*Math.pow(2,t),o=this.getBoundPixel();return[o[0]/i,o[2]/i,o[3]/i,o[1]/i]}getWorldCopy(t,i){const o=2**i,[r,s,l,c]=t.map(n=>~~(n/(o*256))),h=[];for(let n=c;n<=s;n++)for(let p=r;p<=l;p++)h.push([p,n]);return h.map(n=>{const p=2**i*256;return[n[0]*p,n[1]*p,p]})}resize(){let t=this.map.getSource(this.rampColorSource);t.setCoordinates(this.getBoundLngLat()),t=this.map.getSource(this.particleSource),t.setCoordinates(this.getBoundLngLat()),this.rampColorCanvas.width=this.map._canvas.clientWidth,this.rampColorCanvas.height=this.map._canvas.clientHeight,this.particleCanvas.width=this.map._canvas.clientWidth,this.particleCanvas.height=this.map._canvas.clientHeight}toggle(t){const i=this.map.getLayoutProperty(this.rampColorLayer,"visibility"),o=t?"visible":"none";i!==o&&this.map.setLayoutProperty(this.rampColorLayer,"visibility",o)}toggleParticle(t){const i=this.map.getLayoutProperty(this.particleLayer,"visibility"),o=t?"visible":"none";i!==o&&this.map.setLayoutProperty(this.particleLayer,"visibility",o)}}class le{createShader(t,i,o){const r=t.createShader(i);if(r&&(t.shaderSource(r,o),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)))throw new Error(t.getShaderInfoLog(r)||"error happened while create shader...");return r}createTexture(t,i,o,r,s,l,c){const h=t.createTexture();return t.bindTexture(t.TEXTURE_2D,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,r),s instanceof Uint8Array?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,l,c,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,s),t.bindTexture(t.TEXTURE_2D,null),h}createDataBuffer(t,i,o){if(t){const r=t.createBuffer();return i==="array"?(t.bindBuffer(t.ARRAY_BUFFER,r),o&&t.bufferData(t.ARRAY_BUFFER,o,t.STATIC_DRAW)):i==="element"&&(t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r),o&&t.bufferData(t.ELEMENT_ARRAY_BUFFER,o,t.STATIC_DRAW)),r}return null}createProgram(t,i,o){const r=t.createProgram(),s=this.createShader(t,t.VERTEX_SHADER,i),l=this.createShader(t,t.FRAGMENT_SHADER,o);if(r&&s&&l&&(t.attachShader(r,s),t.attachShader(r,l),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)))throw new Error(t.getProgramInfoLog(r)||"error happened while creating ramp color program");return r}createProgramWrapper(t,i,o){const r=this.createProgram(t,i,o);if(r){const s={program:r},l=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let h=0;h<l;h++){const d=t.getActiveAttrib(r,h);s[d.name]=t.getAttribLocation(r,d.name)}const c=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let h=0;h<c;h++){const d=t.getActiveUniform(r,h);s[d.name]=t.getUniformLocation(r,d.name)}return s}}setup(t,i,o=!1,r,s){const l=document.createElement("canvas");l.width=256,l.height=1;const c=l.getContext("2d");if(c&&t){const h=c==null?void 0:c.createLinearGradient(0,0,256,0);return i.forEach(([d,n])=>{h.addColorStop(d,n)}),c.fillStyle=h,c.fillRect(0,0,256,1),{canvas:l,texture:this.createTexture(t,t.LINEAR,t.LINEAR,t.CLAMP_TO_EDGE,o?new Uint8Array(c.getImageData(0,0,256,1).data):l,r,s)}}}setupParticle(t,i=1e3){const o=Math.ceil(Math.sqrt(i)),r=o*o,s=new Uint8Array(r*4);for(let n=0;n<s.length;n++)s[n]=Math.floor(Math.random()*256);const l=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,o,o),c=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,o,o),h=new Float32Array(r);for(let n=0;n<r;n++)h[n]=n;const d=this.createDataBuffer(t,"array",h);return{resolution:o,total:r,texture0:l,texture1:c,indexBuffer:d}}bind(t,i,o){const r=this.createProgram(t,i,o);if(r){const s=this.createDataBuffer(t,"array",void 0),l=t.getAttribLocation(r,"a_position");t.enableVertexAttribArray(l),t.vertexAttribPointer(l,2,t.FLOAT,!1,0,0);const c=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(t,"array",c);const h=t.getAttribLocation(r,"a_texCoord");return t.enableVertexAttribArray(h),t.vertexAttribPointer(h,2,t.FLOAT,!1,0,0),{program:r,aPositionBuffer:s}}return{}}bindParticle(t,i,o,r,s,l){const c=this.createProgramWrapper(t,i,o),h=this.createProgramWrapper(t,r,s),d=this.createProgramWrapper(t,r,l),n=this.createDataBuffer(t,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),p=t.createFramebuffer();return{particle:c,screen:h,update:d,quadBuffer:n,frameBuffer:p}}draw(t,i,o,r,s,l,c){var h,d;if(i&&o){t.resize(),i==null||i.viewport(0,0,(h=i==null?void 0:i.canvas)==null?void 0:h.width,(d=i==null?void 0:i.canvas)==null?void 0:d.height),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT);try{i.useProgram(o);const n={resolution:i.getUniformLocation(o,"u_resolution"),image:i.getUniformLocation(o,"u_image"),color:i.getUniformLocation(o,"u_color"),scale:i.getUniformLocation(o,"u_scale"),uvRange:i.getUniformLocation(o,"u_range_u_v"),sRange:i.getUniformLocation(o,"u_range_s")};n.resolution&&i.uniform2f(n.resolution,i.canvas.width*t.ratio,i.canvas.height*t.ratio),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,r),n.image&&i.uniform1i(n.image,0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,s),n.color&&i.uniform1i(n.color,1),c!=null&&c.uvRange&&(c!=null&&c.sRange)&&(n.uvRange&&i.uniform2f(n.uvRange,c.uvRange[0],c.uvRange[1]),n.sRange&&i.uniform2f(n.sRange,c.sRange[0],c.sRange[1])),n.scale&&i.uniform1f(n.scale,(c==null?void 0:c.scale)||1);const p=t.getBoundPixel(),f=t.map.getZoom()+1,u=t.getWorldCopy(p,f);for(const g of u){const B=(g[0]-p[0])*t.ratio,w=(g[1]-p[3])*t.ratio,A=g[2]*t.ratio,[m,L,y,x]=[B,A+B,w,A+w],E=new Float32Array([m,y,L,y,m,x,m,x,L,y,L,x]);i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,E,i.STATIC_DRAW),i.drawArrays(i.TRIANGLES,0,6)}}catch(n){console.log(`render failed...${n}`)}}}drawParticle(t,i,o,r,s){var l,c;i&&(i==null||i.viewport(0,0,(l=i==null?void 0:i.canvas)==null?void 0:l.width,(c=i==null?void 0:i.canvas)==null?void 0:c.height),i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,o),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,r.texture0),this.renderScreen(t,i,r,s),this.updateParticles(t,i,r,s))}renderScreen(t,i,o,r){i.bindFramebuffer(i.FRAMEBUFFER,o.frameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.screenTexture,0),i.viewport(0,0,i.canvas.width,i.canvas.height),this.renderScreenTexture(i,o.backgroundTexture,o.screen,o.quadBuffer,.95),this.renderParticles(t,i,o,r),i.bindFramebuffer(i.FRAMEBUFFER,null),this.renderScreenTexture(i,o.screenTexture,o.screen,o.quadBuffer,1);const s=o.backgroundTexture;o.backgroundTexture=o.screenTexture,o.screenTexture=s}renderScreenTexture(t,i,o,r,s){t&&(t.useProgram(o.program),t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(o.a_pos),t.vertexAttribPointer(o.a_pos,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,i),t.uniform1i(o.u_screen,2),t.uniform1f(o.u_opacity,s),t.drawArrays(t.TRIANGLES,0,6))}renderParticles(t,i,o,r){if(i){i.useProgram(o.particle.program),i.bindBuffer(i.ARRAY_BUFFER,o.indexBuffer),i.enableVertexAttribArray(o.particle.a_index),i.vertexAttribPointer(o.particle.a_index,1,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,o.color.texture),i.uniform1i(o.particle.u_factor,0),i.uniform1i(o.particle.u_particles,1),i.uniform1i(o.particle.u_color_ramp,2),i.uniform1f(o.particle.u_particles_resolution,o.resolution*t.ratio),i.uniform1f(o.particle.u_point,t.ratio);const s=t.getBoundRange();i.uniform4f(o.particle.u_viewport,s[0],s[1],s[2],s[3]),i.uniform2f(o.particle.u_factor_min,r.uvRange[0],r.uvRange[0]),i.uniform2f(o.particle.u_factor_max,r.uvRange[1],r.uvRange[1]),i.drawArrays(i.POINTS,0,o.total)}}updateParticles(t,i,o,r){var l,c;if(i){i.bindFramebuffer(i.FRAMEBUFFER,o.frameBuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.texture1,0),i.viewport(0,0,o.resolution,o.resolution),i.useProgram(o.update.program),i.bindBuffer(i.ARRAY_BUFFER,o.quadBuffer),i.enableVertexAttribArray(o.update.a_pos),i.vertexAttribPointer(o.update.a_pos,2,i.FLOAT,!1,0,0),i.uniform1i(o.update.u_factor,0),i.uniform1i(o.update.u_particles,1);const h=t.getBoundRange();i.uniform4f(o.update.u_viewport,h[0],h[1],h[2],h[3]),i.uniform1f(o.update.u_rand_seed,Math.random()),i.uniform2f(o.update.u_factor_res,(l=o==null?void 0:o.image)==null?void 0:l.width,(c=o==null?void 0:o.image)==null?void 0:c.height),i.uniform2f(o.update.u_factor_min,r.uvRange[0],r.uvRange[0]),i.uniform2f(o.update.u_factor_max,r.uvRange[1],r.uvRange[1]),i.uniform1f(o.update.u_speed_factor,r.speedFactor*t.ratio),i.uniform1f(o.update.u_drop_rate,r.dropRate),i.uniform1f(o.update.u_drop_rate_bump,r.dropRateBump),i.drawArrays(i.TRIANGLES,0,6)}const s=o.texture0;o.texture0=o.texture1,o.texture1=s}resize(t,i){t.resize();const o=new Uint8Array(i.canvas.width*i.canvas.height*4).fill(0,0,i.canvas.width*i.canvas.height*4),r=this.createTexture(i,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,o,i.canvas.width,i.canvas.height),s=this.createTexture(i,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,o,i.canvas.width,i.canvas.height);return{screenTexture:r,backgroundTexture:s}}async loadImg(t){return new Promise(i=>{const o=new Blob([t],{type:t.type}),r=URL.createObjectURL(o),s=new Image;s.crossOrigin="anonymous",s.src=r,s.onload=()=>i(s)})}}class O{}H(O,"vertexSchema",`
2
2
  //canvas 坐标系上的坐标 (x, y)
3
3
  attribute vec2 a_position; //像素坐标
4
4
  attribute vec2 a_texCoord; //纹理坐标
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idmwx/idmui-gl3",
3
3
  "private": false,
4
- "version": "5.7.6",
4
+ "version": "5.7.7",
5
5
  "description": "idm webgl3",
6
6
  "type": "module",
7
7
  "keywords": [