UNPKG

hydrolang

Version:

A web-based client-side framework for hydrological and environmental analyses

2 lines 223 kB
/*! For license information please see hydrolang.js.LICENSE.txt */ (()=>{var __webpack_modules__={772:(e,t,a)=>{"use strict";a.d(t,{w:()=>n});var r=a(592);function n({params:e,args:t,data:a}={}){return[r.hT({params:{src:"https://www.gstatic.com/charts/loader.js",name:"googleloader"}}),{bar:"google.visualization.BarChart",pie:"google.visualization.PieChart",line:"google.visualization.LineChart",scatter:"google.visualization.ScatterChart",histogram:"google.visualization.Histogram",timeline:"google.visualization.AnnotatedTimeLine",column:"google.visualization.ColumnChart",combo:"google.visualization.ComboChart"},{data:"google.visualization.DataTable",view:"google.visualization.DataView",table:"google.visualization.Table"}]}},536:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{Z:()=>floodDM});var _data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(75),_data_data_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(261),_map_map_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(865);class floodDM{city="";depth=0;mapRendered=!1;selectedfeature=null;async initDamageScenario({params:e,args:t,data:a}={}){let{city:r,depth:n,scenario:o}=t;if(this.city=r,this.depth=n,void 0===e?(this.maptype="leaflet",e={}):void 0===e.maptype?this.maptype="leaflet":this.maptype=e.maptype,"google"===this.maptype&&void 0===e.key)return void console.log("param.key value is required to render a google map");if("100-year"===o)o="x100_year";else{if("500-year"!==o)return void console.log("Pass 100-year or 500-year flood scenario in the args.scenario");o="x500_year"}this.scenario=o;let i,s=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"flooddamage_dt",datatype:o,transform:"eval"},args:{sourceType:this.city}});"Cedar Falls"===this.city&&(i=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"flooddamage_dt",datatype:"utilities",transform:"eval"},args:{sourceType:this.city}}));let l,c=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"flooddamage_dt",datatype:"vehicles",transform:"eval"},args:{sourceType:this.city}}),u=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"flooddamage_dt",datatype:"buildings",transform:"eval"},args:{sourceType:this.city}});"Cedar Falls"!==this.city&&"Cedar Rapids"!==this.city&&"Davenport"!==this.city&&"Waverly"!==this.city||(l=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"flooddamage_dt",datatype:"bridges",transform:"eval"},args:{sourceType:this.city}}));let p=floodDM.featureCollectionCentroid(u);this.mapRendered||(await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.renderMap)({params:{maptype:this.maptype,lat:p[1],lon:p[0]},args:{key:e.key}}),this.mapRendered=!0);let d={Buildings:{Structure:0,Content:0,Income:0,Wage:0,"Relocation Expenses":0,"Rental Income":0,"Loss of Life (Day)":0,"Loss of Life (Night)":0,Debris:0},Vehicles:{Day:0,Night:0},Bridges:{Damage:0},Utilities:{Damage:0}},h={},f=await floodDM.getVehicleDamageFunction();await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"Vehicles Layer",styleFunction:e=>{let t;"google"===this.maptype?(t={},e.forEachProperty((function(e,a){t[a]=e}))):"leaflet"===this.maptype&&(t=e.properties);let a,r,n,o,i,s=t.flood100_avg,l=t.flood500_avg,c=t.area_fe_100yr,u=t.area_fe_500yr,p="PassengerCar",m="LightTruck",g="HeavyTruck";"x100_year"===this.scenario?(a=s,r=c):"x500_year"===this.scenario&&(a=l,r=u);for(let e in f[p])f[p][e].floodDepth==a&&(n=f[p][e].damage);for(let e in f[m])f[m][e].floodDepth==a&&(o=f[m][e].damage);for(let e in f[g])f[g][e].floodDepth==a&&(i=f[g][e].damage);let y=parseInt(n/100*r*t.car_val_day).toLocaleString(),v=parseInt(o/100*r*t.light_val_day).toLocaleString(),b=parseInt(i/100*r*t.heavy_val_day).toLocaleString(),w=parseInt(n/100*r*t.car_val_night).toLocaleString(),_=parseInt(o/100*r*t.light_val_night).toLocaleString(),x=parseInt(i/100*r*t.heavy_val_night).toLocaleString(),E=n/100*r*t.car_val_day+o/100*r*t.light_val_day+i/100*r*t.heavy_val_day,D=n/100*r*t.car_val_night+o/100*r*t.light_val_night+i/100*r*t.heavy_val_night;return isNaN(E)||(d.Vehicles.Day+=E),isNaN(D)||(d.Vehicles.Night+=D),h[t.CensusBloc]={"Block Information":t.CensusBloc,"Flood Scenario:":this.scenario,"Avg. Flood Depth:":a,"Car Count (Day):":t.cars_day,"Car Count (Night):":t.cars_night,"Light Truck Count (Day)":t.light_day,"Light Truck Count (Night)":t.light_night,"Heavy Truck Count (Day)":t.heavy_day,"Heavy Truck Count (Night)":t.heavy_night,"Cars Damage (Day)":y,"Cars Damage (Night)":w,"Light Trucks (Day)":v,"Light Trucks (Night)":_,"Heavy Trucks (Day)":b,"Heavy Truck (Night)":x},{fillColor:E>1e6?"#323232":E>1e5?"#7E7E7E":"#BFBFBF",weight:2,opacity:1,color:"black",dashArray:"3",fillOpacity:.9}},popUpFunction:e=>{let t;return"google"===this.maptype?(t={},e.forEachProperty((function(e,a){t[a]=e}))):"leaflet"===this.maptype&&(t=e.properties),JSON.stringify(h[t.CensusBloc]).replaceAll(",","<br>").replaceAll(/|{|}/g,"")}},data:c}),await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"Flood Inundation Layer",styleFunction:e=>({color:"blue",weight:1,opacity:1,fillColor:"blue",fillOpacity:.5})},data:s});let m=[],g=await floodDM.getPropertyDamageFunction(),y=await floodDM.getLifeLossFunction(),v=await floodDM.getDebrisWeightFunction();if(await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"Properties Layer",styleFunction:e=>{let t;"google"===this.maptype?(t={},e.forEachProperty((function(e,a){t[a]=e}))):"leaflet"===this.maptype&&(t=e.properties);let a,r,n=t.occupancy,i="x100_year"===o?t.depth100:t.depth500,s=g[n].find((e=>e.floodDepth===i)),l=s.structure,c=s.content,u=s.recapturFactor,p=s.incomePerSqftPerDay,h=s.maxTime,f=s.recapturFactor,b=s.wagePerSqftPerDay,w=s.percentOwnerOccupied,_=s.rentalCostPerSqftPerDay,x=s.disruptionCostPerSqft;s.structure>10?(a=[(1-w/100)*x+w/100*(x+_*h*30)],r=(1-w/100)*_*h*30):(a=0,r=0);let E=t.val_struct*l/100,D=t.val_cont*c/100,M=(1-u)*t.sqfoot*p*h*30,T=(1-f)*t.sqfoot*b*h*30,k=t.sqfoot*a,C=t.sqfoot*r,S=E+D+M+T+k+C;isNaN(E)||(d.Buildings.Structure+=E),isNaN(D)||(d.Buildings.Content+=D),isNaN(M)||(d.Buildings.Income+=M),isNaN(T)||(d.Buildings.Wage+=T),isNaN(k)||(d.Buildings["Relocation Expenses"]+=k),isNaN(C)||(d.Buildings["Rental Income"]+=C);let j=y[n].find((e=>e.floodDepth===i&&"over 65"===e.age)),O=y[n].find((e=>e.floodDepth===i&&"under 65"===e.age)),P=j.zone*t.POP_O65DAY+O.zone*t.POP_U65DAY,L=j.zone*t.POP_O65NGT+O.zone*t.POP_U65NGT;isNaN(P)||(d.Buildings["Loss of Life (Day)"]+=P),isNaN(L)||(d.Buildings["Loss of Life (Night)"]+=L);let A=v[n].find((e=>e.floodDepth==i&&"footing"==e.foundationType)),I=A.finishes+A.structure+A.foundation,N=t.sqfoot*I/1e3;if(isNaN(N)||(d.Buildings.Debris+=N),m.push({occupancy:n,gid:t.gid,totalDamageBuild:S,strDamage:E,contDamage:D,incomeLoss:M,wageLoss:T,relocationExpenses:k,rentalIncomeLoss:C,debrisAmount:N,lifeLossDay:P,lifeLossNight:L,inundationDepth:i}),"x100_year"===o){if(t.depth100<1)return{display:"none",color:"none",fillColor:"none"}}else if(t.depth500<1)return{display:"none",color:"none",fillColor:"none"};return{fillColor:S>1e6?"red":S>1e5?"yellow":"green",weight:2,opacity:1,color:"black",fillOpacity:1,radius:4,scale:4,strokeWeight:.7}},popUpFunction:e=>{let t;return"google"===this.maptype?(t={},e.forEachProperty((function(e,a){t[a]=e}))):"leaflet"===this.maptype&&(t=e.properties),JSON.stringify(m.find((e=>e.gid===t.gid))).replaceAll(",","<br>").replaceAll(/|{|}/g,"")}},data:u}),"Cedar Falls"===this.city||"Cedar Rapids"===this.city||"Davenport"===this.city||"Waverly"===this.city){let e=await floodDM.getBridgeDamageFunction();await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"Bridge Layer",styleFunction:t=>{let a,r,n,i,s;"google"===this.maptype?(a={},t.forEachProperty((function(e,t){a[t]=e}))):"leaflet"===this.maptype&&(a=t.properties);let l=a.bridgeT,c=String(a.ScourIndex),u=a.Cost,p=a.flood100;a.flood500,r="x100_year"===o?"100-year":"500-year","100-yr"===r&&"yes"===p?i="100 yr":"500-yr"===r?i="500 yr":n=0;for(let t in e[l])e[l][t].ScourPotential==c&&e[l][t]["Flood Scenario"]==i&&(s=e[l][t]["damage prcnt"]);return n=s*u*1e3,isNaN(n)||(d.Bridges.Damage+=n),{scale:5,radius:2,weight:10,fillColor:"black",color:"black",fillOpacity:.5,strokeWeight:.7}},popUpFunction:t=>{let a;"google"===this.maptype?(a={},t.forEachProperty((function(e,t){a[t]=e}))):"leaflet"===this.maptype&&(a=t.properties),console.log(t);let r,n,i,s,l,c=a.bridgeT,u=String(a.ScourIndex),p=a.Cost,d=a.flood100;a.flood500,r="x100_year"===o?"100-year":"500-year","100-yr"===r&&"yes"===d?i="100 yr":"500-yr"===r?i="500 yr":n=0;for(let t in e[c])e[c][t].ScourPotential==u&&e[c][t]["Flood Scenario"]==i&&(s=e[c][t]["damage prcnt"],l=e[c][t].functional);return n=s*p*1e3,JSON.stringify({Bridge_ID:a.HighwayBri,Bridge_Type:c,Scour_Index:u,Flood_Scenario:i,Damage:100*s,Damage:parseInt(n).toLocaleString(),Functionality:parseInt(100*l)}).replaceAll(",","<br>").replaceAll(/|{|}/g,"")}},data:l})}if("Cedar Falls"===this.city){let e=await floodDM.getUtilityDamageFunction();await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"Utilities Layer",styleFunction:t=>{let a;"google"===this.maptype?(a={},t.forEachProperty((function(e,t){a[t]=e}))):"leaflet"===this.maptype&&(a=t.properties);let r,n,o,i=0,s=a.depth100,l=a.depth500,c=a.UtilFcltyC,u=a.Cost,p=this.scenario;"x100_year"===p?r=s:"x500_year"===p&&(r=l);for(let t in e[c])e[c][t].floodDepth===r&&(o=e[c][t].damage,n=e[c][t].utilitySystem);return i=o/100*u*1e3,isNaN(i)||(d.Utilities.Damage+=i),{scale:2,radius:2,weight:10,fillColor:"#F2B679",color:"#F2B679",fillOpacity:.5,strokeWeight:.7}},popUpFunction:t=>{let a;"google"===this.maptype?(a={},t.forEachProperty((function(e,t){a[t]=e}))):"leaflet"===this.maptype&&(a=t.properties);let r,n,o,i=0,s=a.depth100,l=a.depth500,c=a.UtilFcltyC,u=a.Cost,p=this.scenario;"x100_year"===p?r=s:"x500_year"===p&&(r=l);for(let t in e[c])e[c][t].floodDepth===r&&(o=e[c][t].damage,n=e[c][t].utilitySystem);return i=o/100*u*1e3,JSON.stringify({"Utiltiy ID":a.WasteWater,"Utility Type":n,"Flood depth":r,Damage:parseInt(i)}).replaceAll(",","<br>").replaceAll(/|{|}/g,"")}},data:i})}const b=document.createElement("div");b.innerHTML='<div id="legend" class="content" \n style="display: block; background: rgba(255, 255, 255, 1); padding: 2px 5px; border-style: solid !important;">\n <b>Legend</b>\n <br>\n <span>&#9679;</span> Bridge\n <br>\n <span style="color: orange;">&#9679;</span> Utility\n <br>\n <span style="background-color: blue; color: blue;">&#9679;</span> Flood extent\n <br>\n <b>Building Damage ($)</b>\n <br>\n <span style="color: green;">&#9679;</span> 0 - 100k\n <br>\n <span style="color: yellow;">&#9679;</span> 100k - 1M\n <br>\n <span style="color: red;">&#9679;</span> 1M+\n <br>\n <b>Vehicle Damage ($)</b>\n <br>\n <span style="background-color: #BFBFBF; color: #BFBFBF;">&#9679;</span> 0 - 100k\n <br>\n <span style="background-color: #7E7E7E; color: #7E7E7E;">&#9679;</span> 100k - 1M\n <br>\n <span style="background-color: #323232; color: #323232;">&#9679;</span> 1M+\n </div>',await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.addCustomLegend)({params:{position:"bottom left"},args:{div:b}}),d.Vehicles.Day=floodDM.formatUSDollar(d.Vehicles.Day),d.Vehicles.Night=floodDM.formatUSDollar(d.Vehicles.Night),d.Buildings.Structure=floodDM.formatUSDollar(d.Buildings.Structure),d.Buildings.Content=floodDM.formatUSDollar(d.Buildings.Content),d.Buildings.Income=floodDM.formatUSDollar(d.Buildings.Income),d.Buildings.Wage=floodDM.formatUSDollar(d.Buildings.Wage),d.Buildings["Relocation Expenses"]=floodDM.formatUSDollar(d.Buildings["Relocation Expenses"]),d.Buildings["Rental Income"]=floodDM.formatUSDollar(d.Buildings["Rental Income"]),d.Utilities.Damage=floodDM.formatUSDollar(d.Utilities.Damage),d.Buildings["Loss of Life (Day)"]=Math.floor(d.Buildings["Loss of Life (Day)"]),d.Buildings["Loss of Life (Night)"]=Math.floor(d.Buildings["Loss of Life (Day)"]);let w=floodDM.createTableFromObject({args:{obj:d}}),_=document.createElement("div");return _.appendChild(w),_.style.position="absolute",_.style.float="left",_.style.top="50px",_.style.left="50px",_.style.display="block",_.style.backgroundColor="white",_.style.fontSize="x-small",floodDM.appendCloseButton(_),document.body.appendChild(_),d}static appendCloseButton(e){const t=document.createElement("span");t.classList.add("close-btn"),t.onclick=function(){return this.parentNode.remove(),!1},Object.assign(t.style,{position:"absolute",top:"10px",right:"10px",width:"20px",height:"20px",cursor:"pointer"}),t.appendChild(document.createElement("style")).textContent="\n .close-btn::before,\n .close-btn::after {\n \n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n width: 100%;\n height: 2px;\n background-color: #777;\n transform: translate(-50%, -50%) rotate(45deg);\n \n }\n .close-btn::after {\n transform: translate(-50%, -50%) rotate(-45deg);\n }\n .close-btn:hover::before,\n .close-btn:hover::after {\n \n background-color: #000000;\n \n }\n ",e.style.position="relative",e.appendChild(t)}static async getPropertyDamageFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,propertyLossesUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/business_str_cnt_inputs.js",proxyUrl=`${corsProxyUrl}${propertyLossesUrl}`;try{const response=await fetch(proxyUrl);let propertyLosses=await response.text();return eval(propertyLosses),propertyLosses}catch(e){return console.error("Error fetching property losses data:",e),null}}static async getLifeLossFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,lifeLossesUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/life_inputs.js",proxyUrl=`${corsProxyUrl}${lifeLossesUrl}`;try{const response=await fetch(proxyUrl);let life=await response.text();return eval(life),life}catch(e){return console.error("Error fetching life losses data:",e),null}}static async getDebrisWeightFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,debrisUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/debris_weight.js",proxyUrl=`${corsProxyUrl}${debrisUrl}`;try{const response=await fetch(proxyUrl);let debris=await response.text();return eval(debris),debris}catch(e){return console.error("Error fetching debris weight data:",e),null}}static async getBridgeDamageFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,debrisUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/bridge_function.js",proxyUrl=`${corsProxyUrl}${debrisUrl}`;try{const response=await fetch(proxyUrl);let bridgeDamFun=await response.text();return eval(bridgeDamFun),bridgeDamFun}catch(e){return console.error("Error fetching debris weight data:",e),null}}static async getVehicleDamageFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,debrisUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/vehicle_function.js",proxyUrl=`${corsProxyUrl}${debrisUrl}`;try{const response=await fetch(proxyUrl);let vehicleDamFun=await response.text();return eval(vehicleDamFun),vehicleDamFun}catch(e){return console.error("Error fetching debris weight data:",e),null}}static async getUtilityDamageFunction({params,args,data}={}){const corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,debrisUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/utility_function.js",proxyUrl=`${corsProxyUrl}${debrisUrl}`;try{const response=await fetch(proxyUrl);let utilityDamFun=await response.text();return eval(utilityDamFun),utilityDamFun}catch(e){return console.error("Error fetching debris weight data:",e),null}}async initMitigationScenario({params:e,args:t,data:a}={}){let{city:r,depth:n}=t;this.city=r,this.depth=n,void 0===e?(this.maptype="leaflet",e={}):void 0===e.maptype?this.maptype="leaflet":this.maptype=e.maptype,"google"===this.maptype&&void 0===e.key&&(this.maptype="leaflet");let o=await(0,_data_data_js__WEBPACK_IMPORTED_MODULE_1__.retrieve)({params:{source:"mitigation_dt",datatype:"community_flood_inundation"},args:{sourceType:this.city}}),i=await floodDM.featureCollectionCentroid(o);if(o=await floodDM.getFloodInundation({args:{depth:this.depth},data:o}),this.mapRendered||(await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.renderMap)({params:{maptype:this.maptype,lat:i[1],lon:i[0]},args:{key:e.key}}),this.mapRendered=!0),o.features.length>0){let e=e=>{let t,a,r="gray",n="depth"+String(Math.floor(10*this.depth));return"google"===this.maptype?(t=e.getProperty(n),a=1):"leaflet"===this.maptype&&(t=e.properties[n],a=4),5<t&&t<=10?r="purple":2<t&&t<=5?r="red":0<t&&t<=2&&(r="yellow"),{scale:5,radius:a,fillColor:r,color:"black",weight:1,opacity:1,fillOpacity:.8,strokeWeight:.7}},t=e=>{let t,a="depth"+String(Math.floor(10*this.depth));return"google"===this.maptype?(t={},e.forEachProperty((function(e,a){t[a]=e}))):"leaflet"===this.maptype&&(t=e.properties),`<h4><b>Damage and Mitigation</b><br></h4>\n <b>Building Information</b><br>\n Building ID: ${String(t.gid)}<br>\n Occupancy Type: ${String(t.occupancy2)}<br>\n Flood Depth: ${t[a]} ft<br>`},a=async e=>{"google"===this.maptype?this.selectedfeature=e.feature:"leaflet"===this.maptype&&(this.selectedfeature=e.target.feature),console.log(this.selectedfeature)};await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.Layers)({args:{type:"geojson",name:"mygeoJSON",styleFunction:e,popUpFunction:t,onClickFunction:a},data:o})}let s=await floodDM.getCityFloodDamage({args:{depth:this.depth,city:this.city}});"Cedar Rapids"===r?(s.low_emission="$ 295.3 M",s.high_emission="$ 635.8 M"):"Cedar Falls"===r?(s.low_emission="$ 175.5 M",s.high_emission="$ 332.9 M"):"Waterloo"===r&&(s.low_emission="$ 269.2 M",s.high_emission="$ 785.6 M");let l=floodDM.createTableFromObject({args:{obj:s,tableHeaderText:this.city}}),c=document.createElement("div");c.appendChild(l),c.style.position="absolute",c.style.float="left",c.style.top="50px",c.style.left="50px",c.style.display="block",c.style.backgroundColor="white",c.style.fontSize="x-small",floodDM.appendCloseButton(c),document.body.appendChild(c);const u=document.createElement("div");return u.innerHTML='\n <div id="legend" class="content" \n style="display: block; background: rgba(255, 255, 255, 1); padding: 2px 5px; border-style: solid !important;">\n ">\n <b>LEGEND</b>\n <br>\n <b>Depth</b>\n <br>\n <span style="color: purple;">&#9632;</span> &gt; 5 - 10 ft</span>\n <br>\n <span style="color: red;">&#9632;</span> 2 - 5 ft</span>\n <br>\n <span style="color: yellow;">&#9632;</span> &lt; 2 ft</span>\n </div>\n',await(0,_map_map_js__WEBPACK_IMPORTED_MODULE_2__.addCustomLegend)({params:{position:"bottom right"},args:{div:u}}),s}static featureCollectionCentroid(e){let t=e.features.length,a=e.features.reduce(((e,t)=>[t.geometry.coordinates[0]+e[0],t.geometry.coordinates[1]+e[1]]),[0,0]);return[a[0]/t,a[1]/t]}async runMitigationScenario({params:e,args:t,data:a}={}){let r,{mitigationMeasure:n,mitigationDepth:o,foundationType:i}=t;if(null===this.selectedfeature)return void console.log("Click on a property marker and then run mitigation scenario");"google"===this.maptype?(r={},this.selectedfeature.forEachProperty((function(e,t){r[t]=e}))):"leaflet"===this.maptype&&(r=this.selectedfeature.properties),e={occupancy:r.occupancy2,structuralValue:r.val_struct,contentValue:r.val_cont,buildingArea:r.sqfoot},t={floodDepth:r["depth"+(10*this.depth).toString()],mitigationMeasure:n,mitigationDepth:o,foundationType:i};let s=await floodDM.buildPropertyDMScenario({params:e,args:t,data:a}),l=floodDM.createTableFromObject({args:{obj:s,tableHeaderText:"Damage and Mitigation Summary"}}),c=document.createElement("div");return c.appendChild(l),c.style.position="absolute",c.style.float="left",c.style.top="200px",c.style.left="50px",c.style.display="block",c.style.backgroundColor="white",c.style.fontSize="x-small",floodDM.appendCloseButton(c),document.body.appendChild(c),l}static async getCityFloodDamage({params:e,args:t,data:a}={}){if(!t.city||!t.depth)return"City or depth not found";const r=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint;let n;"Cedar Falls"===t.city?n="cedar_falls":"Cedar Rapids"===t.city?n="cedar_rapids":"Waterloo"===t.city&&(n="waterloo");const o=`${r}https://hydroinformatics.uiowa.edu/lab/midas/communities/${n}.json`;try{const e=await fetch(o);return(await e.json()).city.filter((e=>e.flood_level===t.depth.toString()))[0]}catch(e){return console.error("Error fetching debris weight data:",e),null}}static createTableFromObject({params:e,args:t,data:a}={}){void 0===t.obj&&(t.obj="");let{obj:r,depth:n=0,showHeader:o=!0,tableHeaderText:i=null}=t;const s=document.createElement("table");if(s.style.borderCollapse="collapse",s.style.border="1px solid #fff",null!==i&&0===n){const e=s.insertRow().insertCell();e.textContent=i,e.style.fontWeight="bold",e.style.fontFamily="Arial",e.colSpan=2,e.style.borderRight="1px solid #000"}for(const e in r){const t=s.insertRow(),a=t.insertCell();a.textContent=e,a.style.padding="0 10px 0 10px",a.style.borderRight="1px solid #fff",a.style.backgroundColor="#337bcb",a.style.color="white",a.style.fontFamily="Arial",o&&(a.style.fontWeight="bold");const i=t.insertCell();"object"==typeof r[e]&&null!==r[e]?(i.style.borderBottom="1px solid #fff",i.style.backgroundColor="#fff",i.appendChild(floodDM.createTableFromObject({args:{obj:r[e],depth:n+1,showHeader:!0}}))):i.textContent=r[e]}return s}static getFloodInundation({params:e,args:t,data:a}={}){if(!a.features||!Array.isArray(a.features))return{error:"Invalid data format"};if(!t||"number"!=typeof t.depth)return{error:"Invalid args format"};const r=t.depth;let n=structuredClone(a);return n.features=n.features.filter((e=>e.properties["depth"+String(Math.floor(10*r))]>=1)),n}static async buildPropertyDMScenario({params:e,args:t,data:a}={}){const{occupancy:r,structuralValue:n,contentValue:o,buildingArea:i}=e,{floodDepth:s,mitigationMeasure:l,mitigationDepth:c,foundationType:u}=t,p={occupancy:r,structuralValue:n,contentValue:o,buildingArea:i};if("number"==typeof s){const e=await this.fetchCurvesData(r,s),t=this.calculateLosses(n,o,e);p.floodDepth=s,p.structuralLoss=t.structuralLoss,p.contentLoss=t.contentLoss;let a=p.buildingArea;if(c&&l){const e=await this.getMitigationOptions(u,l,c,a,p);p.mitigationOptions=e}p.structuralLoss=floodDM.formatUSDollar(p.structuralLoss),p.contentLoss=floodDM.formatUSDollar(p.contentLoss),p.structuralValue=floodDM.formatUSDollar(p.structuralValue),p.contentValue=floodDM.formatUSDollar(p.contentValue)}return p}static async fetchCurvesData(e,t){const a=`${_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint}https://hydroinformatics.uiowa.edu/lab/midas/jsons/curves.json`;let r=await fetch(a);return r=await r.json(),r.curves.filter((a=>a.occupancy===e&&a.depth===t.toString())).reduce(((e,a)=>Math.abs(a.depth-t)<Math.abs(e.depth-t)?a:e))}static calculateLosses(e,t,a){const r=e*a.struct_dam_per/100,n=t*a.cont_dam_per/100;return{structuralLoss:1e3*Math.round(r/1e3),contentLoss:1e3*Math.round(n/1e3)}}static async getMitigationOptions(e,t,a,r,n){const o=await this.fetchMitigationData();let i,s;if(!o)return{error:"Failed to fetch mitigation data"};const l=o.mitigation_options;let c=n.structuralLoss,u=n.contentLoss,p=n.floodDepth;for(let n of l)t==n.measure&&n.foundation_type===e?(i=r*n.cost,i=1e3*Math.round(i/1e3),s=c+u-i,s=1e3*Math.round(s/1e3)):"Wet Floodproofing"==t&&a==n.design?(i=4*Math.sqrt(r)*n.cost,i=1e3*Math.round(i/1e3),a<p?(s=-i-c-u,s=1e3*Math.round(s/1e3)):a>=p&&(s=c+u-i-u,s=1e3*Math.round(s/1e3))):t==n.measure&&a==n.design&&("linear"==n.app_type?(i=4*Math.sqrt(r)*n.cost,i=1e3*Math.round(i/1e3),a<p?(s=-i-c-u,s=1e3*Math.round(s/1e3)):a>=p&&(s=c+u-i,s=1e3*Math.round(s/1e3))):"area"==n.app_type&&(i=r*n.cost,i=1e3*Math.round(i/1e3),a<p?(s=-i-c-u,s=1e3*Math.round(s/1e3)):a>=p&&(s=c+u-i,s=1e3*Math.round(s/1e3))));return{measure:t,foundationType:e,cost:floodDM.formatUSDollar(i),benefit:floodDM.formatUSDollar(s)}}static formatUSDollar(e){return isNaN(e)||"number"!=typeof e?"Invalid input":e.toLocaleString("en-US",{style:"currency",currency:"USD"})}static async fetchMitigationData(){const e=`${_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint}https://hydroinformatics.uiowa.edu/lab/midas/jsons/mitigations.json`;try{const t=await fetch(e);return await t.json()}catch(e){return console.error("Error fetching mitigation data:",e),null}}static async getBridgeDamage({params,args,data}={}){const{bridge_type,scour_index,flood_scenario,replacement_value}=args,corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,bridgeDamageUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/bridge_function.js",proxyUrl=`${corsProxyUrl}${bridgeDamageUrl}`;try{const response=await fetch(proxyUrl),data=await response.text();let bridgeDamFun;eval(data);const matchingEntry=bridgeDamFun[bridge_type].find((e=>e.ScourPotential===scour_index&&e["Flood Scenario"]===flood_scenario));if(matchingEntry){const e=matchingEntry["damage prcnt"],t=replacement_value*e,a=replacement_value*(1-functionalPercent);return{damagePercent:e,damageCost:Math.round(t),damage}}return console.warn(`No matching entry found for bridge_type: ${bridge_type}, scour_index: ${scour_index}, and flood_scenario: ${flood_scenario}`),null}catch(e){return console.error("Error fetching bridge damage data:",e),null}}static async getUtilityDamage({params,args,data}={}){const{utility,depth,utilityValue}=args,corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,utilityDamageUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/utility_function.js",proxyUrl=`${corsProxyUrl}${utilityDamageUrl}`;try{const response=await fetch(proxyUrl),data=await response.text();let utilityDamFun;eval(data);const matchingEntry=utilityDamFun[utility].find((e=>e.floodDepth===depth));if(matchingEntry){const e=matchingEntry.damage,t=utilityValue*(e/100);return{damagePercent:e,damageCost:Math.round(t)}}return console.warn(`No matching entry found for utility: ${utility} and depth: ${depth}`),null}catch(e){return console.error("Error fetching utility damage data:",e),null}}static async getPropertyLoss({params,args,data}={}){const{occupancy,depth,foundationType,structureValue,contentValue,area}=args,corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint;let propertyLosses,debris;const propertyLossesUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/business_str_cnt_inputs.js",debrisUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/debris_weight.js",[propertyLossesData,debrisData]=await Promise.all([fetch(`${corsProxyUrl}${propertyLossesUrl}`).then((e=>e.text())),fetch(`${corsProxyUrl}${debrisUrl}`).then((e=>e.text()))]);eval(propertyLossesData),eval(debrisData);const propertyLossEntry=propertyLosses[occupancy].find((e=>e.floodDepth===depth)),debrisEntry=debris[occupancy].find((e=>e.floodDepth===depth&&e.foundationType===foundationType));if(propertyLossEntry&&debrisEntry){const e=propertyLossEntry.structure,t=propertyLossEntry.content,a=structureValue*e/100,r=contentValue*t/100,n=propertyLossEntry.incomePerSqftPerDay*area,o=propertyLossEntry.wagePerSqftPerDay*area,i=(1-propertyLossEntry.percentOwnerOccupied/100)*area*propertyLossEntry.rentalCostPerSqftPerDay*propertyLossEntry.maxTime*30/1e3,s=area*((1-propertyLossEntry.percentOwnerOccupied/100)*propertyLossEntry.disruptionCostPerSqft+propertyLossEntry.percentOwnerOccupied/100*(propertyLossEntry.disruptionCostPerSqft+propertyLossEntry.rentalCostPerSqftPerDay*propertyLossEntry.maxTime*30))/1e3,l=area*debrisEntry.finishes/1e3,c=area*debrisEntry.structure/1e3,u=area*debrisEntry.foundation/1e3,p=l+c+u;return{propertyLoss:{structureLoss:Math.round(a),contentLoss:Math.round(r),structureDamPercent:e,contentDamPercent:t},businessInterruption:{incomeLoss:Math.round((1-propertyLossEntry.recapturFactor)*n*30)*propertyLossEntry.maxTime,wageLoss:Math.round((1-propertyLossEntry.recapturFactor)*o*30)*propertyLossEntry.maxTime,rentalIncome:Math.round(i),relocation:Math.round(s)},debrisAmount:{finishesDebris:Math.round(l),structureDebris:Math.round(c),foundationDebris:Math.round(u),totalDebris:Math.round(p)}}}return console.warn(`No matching entry found for occupancy: ${occupancy}, depth: ${depth}, and foundationType: ${foundationType}`),null}static async getLifeLoss({params,args,data}={}){const{occupancy,depth,peopleOver65,peopleUnder65}=args,corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,lifeLossUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/life_inputs.js",proxyUrl=`${corsProxyUrl}${lifeLossUrl}`;try{const response=await fetch(proxyUrl),data=await response.text();let life;eval(data);const matchingEntryOver65=life[occupancy].find((e=>e.floodDepth===depth&&"over 65"===e.age)),matchingEntryUnder65=life[occupancy].find((e=>e.floodDepth===depth&&"under 65"===e.age));if(matchingEntryOver65||matchingEntryUnder65)return{lifeLossOver65:parseInt(matchingEntryOver65.zone*peopleOver65),lifeLossUnder65:parseInt(matchingEntryUnder65.zone*peopleUnder65)}}catch(e){return console.error("Error fetching utility damage data:",e),null}}static async getVehicleDamage({params,args,data}={}){const{floodDepth,vehicleType,vehicleCount,vehicleValue}=args,corsProxyUrl=_data_datasources_proxy_js__WEBPACK_IMPORTED_MODULE_0__.Z["local-proxy"].endpoint,vehicleDamageUrl="https://hydroinformatics.uiowa.edu/lab/fidas/data/functions/vehicle_function.js",proxyUrl=`${corsProxyUrl}${vehicleDamageUrl}`;try{const response=await fetch(proxyUrl),data=await response.text();let vehicleDamFun;eval(data);const matchingEntry=vehicleDamFun[vehicleType].find((e=>e.floodDepth===floodDepth));if(matchingEntry){const e=matchingEntry.damage,t=vehicleValue*(e/100)*vehicleCount;return{damagePercent:e,damage:Math.round(t)}}return console.warn(`No matching entry found for vehicleType: ${vehicleType} and floodDepth: ${floodDepth}`),null}catch(e){return console.error("Error fetching vehicle damage data:",e),null}}}},254:(e,t,a)=>{"use strict";a.d(t,{Z:()=>r});class r{static copydata({params:e,args:t,data:a}={}){var r,n,o;if("object"!=typeof a||null===a)return a;for(o in r=Array.isArray(a)?[]:{},a)n=a[o],r[o]=this.copydata({data:n});return r}static onearray({params:e,args:t,data:a}={}){var r=[];return r.push(a[1]),r}static range({params:e,args:t,data:a}={}){const r=this.min({data:a}),n=this.max({data:a}),o=e.N||a.length,i=(n-r)/o,s=[];for(let e=0;e<=o;e++)s.push(r+e*i);return s}static datagaps({params:e,args:t,data:a}={}){var r,n=a,o=0;r="object"!=typeof n[0]?this.copydata({data:n}):this.copydata({data:n[1]});for(var i=0;i<r.length;i++)(void 0===r[i]||Number.isNaN(r[i])||!1===r[i])&&o++;return console.log(`Total amount of gaps in data: ${o}.`)}static gapremoval({params:e,args:t,data:a}={}){var r,n=a,o=this.copydata({data:n});if("object"==typeof o[0]){for(var i=o[0],s=o[1],l=0;l<s.length;l++)(void 0===s[l]||Number.isNaN(s[l])||!1===s[l])&&delete i[l];return r=this.cleaner({data:s}),[i=this.cleaner({data:i}),r]}r=this.cleaner({data:o})}static timegaps({params:e,args:t,data:a}={}){var r=e.timestep,n=a,o=this.copydata({data:n});"object"==typeof n[0]&&(o=this.copydata({data:n[0]}));for(var i=[],s=0;s<o.length;s++)"string"==typeof o[0]?i.push(Math.abs(Date.parse(o[s])/6e4)):i.push(o[s]);var l=0,c=[],u=r;for(s=1;s<o.length-1;s++)Math.abs(i[s-1]-i[s])==u&&Math.abs(i[s]-i[s+1])==u||(l++,c.push(o[s]));return 0===c.length?void console.log("No gaps in times!"):(console.log(`Number of time gaps: ${l}`),c)}static gapfiller({params:e,args:t,data:a}={}){var r=this.copydata({data:a}),n=[];"object"==typeof a[0]&&(r=this.copydata({data:a[0]}));for(var o=0;o<r.length;o++)"string"==typeof r[0]?n.push(Math.abs(Date.parse(r[o])/6e4)):n.push(r[o]);e.type}static sum({params:e,args:t,data:a}={}){return a.reduce(((e,t)=>e+t),0)}static mean({params:e,args:t,data:a}={}){return this.sum({data:a})/a.length}static median({params:e,args:t,data:a}={}){const r=a.slice().sort(((e,t)=>e-t)),n=Math.floor(r.length/2);return r.length%2==0?(r[n-1]+r[n])/2:r[n]}static stddev({params:e,args:t,data:a}={}){for(var r=this.mean({data:a}),n=[],o=0;o<a.length;o+=1)n.push((a[o]-r)*(a[o]-r));return Math.sqrt(this.sum({data:n})/n.length)}static variance({params:e,args:t,data:a}={}){const r=this.mean({data:a});return a.map((e=>(e-r)**2)).reduce(((e,t)=>e+t),0)/a.length}static sumsqrd({params:e,args:t,data:a}={}){for(var r=0,n=a.length;--n>=0;)r+=a[n];return r}static min({params:e,args:t,data:a}={}){return Math.min(...a)}static max({params:e,args:t,data:a}={}){return Math.max(...a)}static unique({params:e,args:t,data:a}={}){for(var r={},n=[],o=0;o<a.length;o++)r[a[o]]||(r[a[o]]=!0,n.push(a[o]));return n}static frequency({params:e,args:t,data:a}={}){var r=this.copydata({data:a}),n={};return r.forEach((e=>{n[e]=(n[e]||0)+1})),n}static standardize({params:e,args:t,data:a}={}){for(var r=[],n=this.stddev({data:a}),o=this.mean({data:a}),i=0;i<a.length;i++)r[i]=(a[i]-o)/n;return r}static quantile({params:e,args:t,data:a}={}){var r=a.slice();r.sort((function(e,t){return e-t}));var n=(a.length-1)*e.q;if(n%1==0)return r[n];var o=Math.floor(n),i=n-o;return void 0!==r[o+1]?r[o]+i*(r[o+1]-r[o]):r[o]}static interoutliers({params:e={q1:.25,q2:.75},data:t=[]}={}){const{q1:a,q2:r}=e,n=[...t];let o=[];Array.isArray(t[0])&&([o,n]=t);const i=this.quantile({data:n,params:{q:a}}),s=this.quantile({data:n,params:{q:r}}),l=Math.abs(s-i),c=Math.abs(i-1.5*l),u=Math.abs(s+1.5*l),p=n.filter(((e,t)=>{if(e>=c&&e<=u)return o.length?[o[t],e]:e}));return o.length,p}static normoutliers({params:e={},args:t,data:a}={}){const{lowerBound:r=-.5,upperBound:n=.5}=e,[o,i]=Array.isArray(a[0])?a:[[],a],s=this.standardize({data:i}),l=i.filter(((e,t)=>s[t]<r||s[t]>n)),c=o.filter(((e,t)=>s[t]<r||s[t]>n));return 0===o.length?l:[c,l]}static outremove({params:e,args:t,data:a}={}){var r,n=t.p1,o=t.p2;return r="normalized"===e.type?this.normoutliers({params:{low:n,high:o},data:a}):this.interoutliers({params:{q1:n,q2:o},data:a}),"object"!=typeof a[0]?this.itemfilter(arr,r):[this.itemfilter(arr[0],r[0]),this.itemfilter(arr[1],r[1])]}static correlation({params:e,args:t,data:a}={}){const{set1:r,set2:n}=a,o=r.length+n.length,i=[],s=[],l=[];for(let e=0;e<r.length;e++)i[e]=r[e]*n[e],s[e]=r[e]**2,l[e]=n[e]**2;return(o*this.sum({data:i})-this.sum({data:r})*this.sum({data:n}))/(Math.sqrt(o*this.sum({data:s})-this.sum({data:r})**2)*Math.sqrt(o*this.sum({data:l})-this.sum({data:n})**2))}static efficiencies({params:e,args:t,data:a}={}){let{type:r}=e,[n,o]=a;const i=this.mean({data:n}),s=this.mean({data:o});if("NSE"===r){const e=o.map(((e,t)=>Math.pow(e-n[t],2))),t=n.map((e=>Math.pow(e-i,2)));return 1-this.sum({data:e})/this.sum({data:t})}if("determination"===r){const e=[],t=[],a=[];for(let r=0;r<n.length;r++)e[r]=(o[r]-s)*(n[r]-i),t[r]=Math.pow(o[r]-s,2),a[r]=Math.pow(n[r]-i,2);return console.log(`The values are - Upper: ${this.sum({data:e})}, Lower: ${this.sum({data:t})} and ${this.sum({data:a})}`),Math.pow(this.sum({data:e})/(Math.sqrt(this.sum({data:t}))*Math.sqrt(this.sum({data:a}))),2)}if("agreement"===r){const e=n.map(((e,t)=>Math.pow(e-o[t],2))),t=n.map(((e,t)=>Math.pow(Math.abs(o[t]-i)+Math.abs(e-i),2)));return 1-this.sum({data:e})/this.sum({data:t})}if("all"===r)return{NSE:this.efficiencies({params:{type:"NSE"},data:[n,o]}),r2:this.efficiencies({params:{type:"determination"},data:[n,o]}),d:this.efficiencies({params:{type:"agreement"},data:[n,o]})}}static fastFourier({params:e,args:t,data:a}={}){const r=Math.pow(2,Math.ceil(Math.log2(a.length)));let n=tf.pad1d(a,[0,r-a.length]);const o=tf.zerosLike(n),i=tf.complex(n,o);return tf.spectral.fft(i).arraySync()}static skewness({params:e,arg:t,data:a}={}){const r=a.length,n=this.mean({data:a}),o=a.reduce(((e,t)=>e+Math.pow(t-n,3)),0),i=Math.sqrt(a.reduce(((e,t)=>e+Math.pow(t-n,2)),0)/r);return r/((r-1)*(r-2))*(o/Math.pow(i,3))}static kurtosis({params:e,args:t,data:a}={}){const r=a.length,n=this.mean({data:a}),o=a.reduce(((e,t)=>e+Math.pow(t-n,4)),0),i=this.stddev({data:a});return r*(r+1)/((r-1)*(r-2)*(r-3))*(o/Math.pow(i,4))-3*Math.pow(r-1,2)/((r-2)*(r-3))}static forwardFill({params:e,args:t,data:a}={}){let r=null,n=[];return{data:a.map(((e,t)=>e>0?(r=e,e):null!==r?(n.push(t),r):null)),replaceIndices:n}}static basicstats({params:e,args:t,data:a}={}){"object"==typeof a[0]&&(a=a[1]).shift(),a=(a=a.map((e=>JSON.parse(e)))).map((e=>(e>99998&&(e=0),e)));var r=[],n=[];return n.push("Value"),n.push(a.length),n.push(this.min({data:a})),n.push(this.max({data:a})),n.push(this.sum({data:a})),n.push(this.mean({data:a})),n.push(this.median({data:a})),n.push(this.stddev({data:a})),n.push(this.variance({data:a})),n.push(this.skewness({data:a})),n.push(this.kurtosis({data:a})),r.push(["Metric","Number of values","Minimum Value","Maximum value","Sum","Mean","Median","Standard deviation","Variance","Skewness","Kurtosis"]),r.push(n),r}static MK({params:e,args:t,data:a}){for(var r,n,o=a,i=0,s=0,l=0;l<o.length-1;l++)for(var c=l+1;c<o.length;c++)i+=(s=o[c]-o[l])<0?-1:0==s?0:1;return r=o.length*(o.length-1)*(2*o.length+5)/18,n=i<0?(i-1)/Math.pow(r,.5):0==i?0:(i+1)/Math.pow(r,.5),[2*(1-this.normalcdf({data:Math.abs(n)})),i,n]}static normalcdf({params:e,args:t,data:a}){let r=[];for(var n=0;n<a.length;n++){var o=a[n],i=1/(1+.2316419*Math.abs(o)),s=.3989423*Math.exp(-o*o/2)*i*(.3193815+i*(i*(1.781478+i*(1.330274*i-1.821256))-.3565638));o>0&&(s=1-s),r.push(s)}return r}static computeD({params:e,args:t,data:a}){var{sampleA:r,sampleB:n}=a,o=0;this.min({data:r.concat(n)}),this.max({data:r.concat(n)});let i=r.length,s=n.length;for(var l of this.range({params:{N:1e3},data:a})){var c=r.filter((e=>e<=l)).length/i,u=n.filter((e=>e<=l)).length/s,p=Math.abs(c-u);p>o&&(o=p)}return o}static KS_computePValue({params:e,args:t,data:a}){var r=a[0],n=a[1],o=this.computeD({data:[r,n]}),i=r.length,s=n.length;return[2*Math.exp(-2*o*o*(i*s)/(i+s)),o]}static KS_rejectAtAlpha({params:e,args:t,data:a}){let[r,n]=this.KS_computePValue({data:a});return r<e.alpha}static normalDistribution({params:e,args:t,data:a}){return Math.exp(.5*-(Math.log(2*Math.PI)+e.z*e.z))}static runSimulation({params:e,args:t,data:a}={}){const{multiplier:r}=e||1,n=this.mean({data:a}),o=this.stddev({data:a});var i,s;return i=n-o*r,s=n+o*r,Math.random()*(s-i)+i}static runMonteCarlo({params:e,args:t,data:a}={}){const{iterations:r=100,callback:n}=e||{},o=[];for(let i=0;i<r;i++){let r;if(n)r=n({params:e,args:t,data:a});else{const e=a;r=this.runSimulation({data:e})}o.push(r)}return o}static runVegas({params:e,args:t,data:a}={}){const{iterations:r=100,callback:n}=e||{},o=[];for(let i=0;i<r;i++){let r;if(n)r=n({params:e,args:t,data:a});else for(let e of a){const t=this.runSimulation({data:e});o.push(t)}}return o}static gaussianDist({params:e,args:t,data:a}){const{x:r,mean:n,stddev:o}=e,i=-((r-n)**2)/(2*o**2);return 1/(o*Math.sqrt(2*Math.PI))*Math.exp(i)}static bernoulliDist({params:e,args:t,data:a}={}){const{f:r,s:n}=e;return 0===r?1-n:1===r?n:0}static gevDistribution({params:e,args:t,data:a}={}){const{x:r,mu:n,sigma:o,xi:i}=e,s=(r-n)/o;if(0===i){const e=-s-Math.exp(-s);return Math.exp(e)/o}return Math.pow(1+i*s,-(1/i+1))*Math.exp((-(1+i*s))**(-1/i))/o}static geometricDist({params:e,args:t,data:a}={}){const{s:r}=e||1,{trials:n}=t;return n<1?0:(1-r)**(n-1)*r}static binomialDist({params:e,args:t,data:a}={}){const{trials:r,probSuccess:n}=e,{s:o}=t;return o<0||o>r?0:this.binomialCoefficient(r,o)*n**o*(1-n)**(r-o)}static multinomialDistribution({params:e,args:t,data:a}={}){const{probabilities:r,n}=e,o=r.length,i=[],s=[];for(let e=0;e<n;e++){const e=[];let t=1;for(let a=0;a<o-1;a++){const n=r[a],o=Math.random()*t,i=Math.floor(o/n);e.push(i),t-=i*n}const a=Math.floor(t/r[o-1]);e.push(a),i.push(e),s.push(this.frequency({data:e}))}return{samples:i,frequencies:s}}static logSeriesDist({params:e,args:t,data:a}={}){const{probSuccess:r,trials:n}=e;return n<1?0:-Math.log(1-r)*Math.pow(r,n)/n}static lognormalDist({params:e,args:t,data:a}={}){const{mu:r,sigma:n}=e,{x:o}=t;if(o<=0)return 0;const i=-((Math.log(o)-r)**2)/(2*n**2);return 1/(o*n*Math.sqrt(2*Math.PI))*Math.exp(i)}static gumbelDist({params:e,args:t,data:a}={}){const{mu:r,beta:n}=e,{x:o}=t,i=(o-r)/n;return 1/n*Math.exp(-(i+Math.exp(-i)))}static uniformDist({params:e,args:t,data:a}={}){const{a:r,b:n}=e,{x:o}=t;return o>=r&&o<=n?1/(n-r):0}static simpleMovingAverage({params:e,args:t,data:a}={}){const{windowSize:r}=e;if(r<=0||r>a.length)throw new Error("Invalid window size.");const n=[];for(let e=0;e<=a.length-r;e++){const t=a.slice(e,e+r).reduce(((e,t)=>e+t),0)/r;n.push(t)}return n}static linearMovingAverage({params:e,args:t,data:a}={}){const{windowSize:r}=e;if(r<=0||r>a.length)throw new Error("Invalid window size.");const n=[];let o=0;for(let e=0;e<r;e++)o+=a[e];n.push(o/r);for(let e=r;e<a.length;e++)o+=a[e]-a[e-r],n.push(o/r);return n}static exponentialMovingAverage({params:e,args:t,data:a}={}){const{alpha:r}=e,{dataset:n}=a,o=[];let i=n[0];for(let e=1;e<n.length;e++)i=r*n[e]+(1-r)*i,o.push(i);return o}static poissonProcess({params:e,args:t,data:a}={}){const{type:r="homogeneous",T:n}=e,{lambda:o,rateFunction:i}=t,s=[];let l=0;for(;l<n;){const e=Math.random();l+=("homogeneous"===r?-1/o:-1/i(l))*Math.log(1-e),l<n&&("homogeneous"===r||Math.random()<=i(l)/i(n))&&s.push(l)}return s}static logPearsonTypeIII({params:e,args:t,data:a}={}){const{mu:r,sigma:n,gamma:o}=e,{size:i}=t||10,s=[];for(let e=0;e<i;e++){const e=Math.random(),t=Math.random(),a=r+n*(Math.sqrt(-2*Math.log(e))*Math.cos(2*Math.PI*t)/Math.sqrt(o)),i=Math.exp(a);s.push(i)}return s}static boxPlotDistribution({params:e,args:t,data:a}={}){const{min:r,q1:n,median:o,q3:i,max:s}=e,{size:l}=t,c=[];for(let e=0;e<l;e++){const e=Math.random();let t;t=e<.25?r-(n-r)*Math.random():e<.5?n+(o-n)*Math.random():e<.75?o+(i-o)*Math.random():i+(s-i)*Math.random(),c.push(t)}return c}static meanSquaredError({params:e,args:t,data:a}={}){const{data1:r,data2:n}=a;if(r.length!==n.length)throw new Error("Datasets need to have same length");const o=r.length;let i=0;for(let e=0;e<o;e++){const t=r[e]-n[e];i+=t*t}return i/o}static returnPeriod({params:e,args:t,data:a}={}){const{probability:r}=e;if(r<=0||r>=1)throw new Error("Probability must be between 0 and 1 (exclusive).");return 1/r}static differencing({params:e,args:t,data:a}={}){const r=e.order,n=a;if(r>=n.length)throw new Error("Invalid order for differencing.");return n.slice(r).map(((e,t)=>e-n[t]))}static residualVariance({params:e,args:t,data:a}={}){const r=a;if(!Array.isArray(r))throw new Error("Invalid data. Expecting an array of residuals.");if(r.length<2)throw new Error("Insufficient data. Expecting an array of at least 2 residuals.");const n=r.map((e=>e*e));return n.reduce(((e,t)=>e+t),0)/n.length}static regression({params:e,args:t,data:a}={}){const r=a.X,n=a.y,o=r.map((e=>[1,...e])),i=multiplyMatrix(transposeMatrix(o),o),s=multiplyMatrix(transposeMatrix(o),n),l=matrixInverse(i);return multiplyMatrix(l,s)}static multiregression({params:e,args:t,data:a}={}){const r=a.X,n=a.Y,o=[];for(let e=0;e<n.length;e++){const t={X:r,y:n[e]},a=this.regression({data:t});o.push(a)}return o}static whitesTest({params:e}){const{errors:t,regressors:a}=e;if(t.length!==a.length)throw new Error("Input arrays must have the same length.");const r=t.length,n=a[0].length;let o=0,i=0,s=0;for(let e=0;e<r;e++){const r=t[e],n=a[e];o+=this.dotProduct(n,n),i+=this.dotProduct(n,r),s+=r**2}const l=r*i**2/(o*s);return{testStatistic:l,pValue:1-this.chisqCDF(l,n)}}static breuschPaganTest({params:e}){const{errors:t,regressors:a}=e;if(t.length!==a.length)throw new Error("Input arrays must have the same length.");const r=t.length,n=a[0].length;let o=[];for(let e=0;e<r;e++){const a=t[e];o.push(a**2)}let i=0,s=0,l=0;for(let e=0;e<r;e++){const t=a[e],r=o[e],n=n(t,t);i+=n,s+=n*r,l+=r**2}const c=r/2*(Math.log(s)-1/r*Math.log(i));return{testStatistic:c,pValue:1-chisqCDF(c,n)}}static goldfeldQuandtTest({params:e,args:t,data:a}){const{residuals:r,independentVar:n}=e;if(r.length!==n.length)throw new Error("Input arrays must have the same length.");const o=r.length,i=Math.floor(.4*o),s=n.map(((e,t)=>t)).sort(((e,t)=>n[e]-n[t])),l=s.slice(0,i),c=s.slice(-i),u=l.map((e=>r[e])),p=c.map((e=>r[e])),d=Math.max(...p)**2/Math.min(...u)**2;return{testStatistic:d,pValue:1-chisqCDF(d,i-1)}}static runMarkovChainMonteCarlo({params:e,args:t,data:a}={}){const{iterations:r=100,callback:n}=e||{},o=[];let i=a.initialState;for(let s=0;s<r;s++){let r;r=n?n({params:e,args:t,data:a,currentState:i}):getNextState(a.transitionMatrix,i),o.push(r),i=r}return o}static joinarray({params:e,arg:t,data:a}={}){for(var r=[],n=1;n<a[0].length;n++)r[n]||(r[n]=[]),r[n]=[a[0],a[1]].reduce(((e,t)=>e.map(((e,a)=>e+t[a]))));return r}static flatenise({params:e,args:t,data:a}={}){for(var r=e.columns,n=a,o=[],i=[],s=0;s<r.length;s++)o.push(r[s]);for(var l=0;l<n.length;l++)i.push(n[l].flat());return[o,i]}static numerise({params:e,args:t,data:a}={}){return a.map((e=>parseFloat(e)))}static cleaner({params:e,args:t,data:a}={}){return a.filter((e=>void 0===e||!Number.isNaN(e)))}static itemfilter({params:e,args:t,data:a}={}){return a[0].filter((e=>!a[1].includes(e)))}static dateparser({params:e,args:t,data:a}={}){this.copydata({data:a});for(var r=[],n=0;n<a.length;n++)r.push(new Date(a[n]).toLocaleString());return r}static arrchange({params:e,args:t,data:a}={}){var r,n=this.copydata({data:a});return(r=n)[0].map(((e,t)=>r.map((e=>e[t]))))}static push({params:e,args:t,data:a}={}){for(var r=0;r<a[1].length;r++)for(var n=0;n<a[0].length;n++)a[0][r].push(a[1][r][n]);return arr1}static generateRandomData(e,t=100){let a=[];for(let r=0;r<e;r++)a.push(Math.floor(Math.random()*t));return a}static autocovarianceMatrix({params:e,args:t,data:a}={}){const{lag:r,lags:n}=e||{lag:2,lags:2},o=a.length,i=this.mean({data:a}),s=[],l=[];for(let e=0;e<=r;e++){let t=0;for(let r=e;r<o;r++)t+=(a[r]-i)*(a[r-e]-i);s.push(t/((o-e)*this.variance({data:a})))}for(let e=0;e<=n;e++){const t=[];for(let a=0;a<=n;a++){const r=s[Math.abs(e-a)];t.push(e===a?1:r)}l.push(t)}return{autocorrelation:s,matrix:l}}static binomialCoefficient(e,t){if(0===t||t===e)return 1;if(t>e)return 0;let a=1;for(let r=1;r<=t;r++)a*=(e-r+1)/r;return a}static multiplyMatrix(e,t){const a=e.length,r=e[0].length,n=t[0].length,o=[];for(let i=0;i<a;i++){o[i]=[];for(let a=0;a<n;a++){let n=0;for(let o=0;o<r;o++)n+=e[i][o]*t[o][a];o[i][a]=n}}return o}static transposeMatrix(e){const t=e.length,a=e[0].length,r=[];for(let n=0;n<a;n++){r[n]=[];for(let a=0;a<t;a++)r[n][a]=e[a][n]}return r}static matrixInverse(e){const t=e.length,a=[],r=[];for(let n=0;n<t;n++){r[n]=[],a[n]=[];for(let o=0;o<t;o++)r[n][o]=n===o?1:0,a[n][o]=e[n][o]}for(let e=0;e<t;e++){const n=a[e][e];for(let o=0;o<t;o++)a[e][o]/=n,r[e][o]/=n;for(let n=0;n<t;n++)if(n!==e){const o=a[n][e];for(let i=0;i<t;i++)a[n][i]-=o*a[e][i],r[n][i]-=o*r[e][i]}}return r}static chisqCDF(e,t){let a=Math.exp(-e/2),r=a;for(let n=1;n<t;n++){let t=a;if(a*=e/(2*(n+1)),r+=a,a===t)break}return 1-r}static dotProduct(e,t){if(e.length!=t.length)throw new Error("Input vectors must have the same length.");let a=0;for(let r=0;r<e.length;r++)a+=e[r]*t[r];return a}static getNextState(e,t){const a=Math.random();let r=0;for(let n=0;n<e[t].length;n++)if(r+=e[t][n],a<=r)return n;return t}}},261:(e,t,a)=>{"use strict";a.r(t),a.d(t,{download:()=>j,recursiveSearch:()=>O,retrieve:()=>k,transform:()=>C,upload:()=>S});var r={};a.r(r),a.d(r,{aemet:()=>c,clearcreek:()=>h,eauk:()=>u,envelope:()=>b,epa:()=>f,fema:()=>o,flooddamage_dt:()=>E,hisCentral:()=>g,hydroShare:()=>y,ifis:()=>d,meteoit:()=>p,meteostat:()=>l,mitigation_dt:()=>x,noaa:()=>i,nws:()=>w,proxies:()=>v.Z,usgs:()=>n,waterOneFlow:()=>m,worldbank:()=>s,wqp:()=>_});const n={"instant-values":{endpoint:"http://waterservices.usgs.gov/nwis/iv/",params:{format:null,site:null,stateCd:null,huc:null,countyCd:null,startDT:null,endDT:null},"data-fields":{},methods:{type:"json",method:"GET"}},"daily-values":{endpoint:"http://waterservices.usgs.gov/nwis/dv/",params:{format:null,site:null,stateCd:null,huc:null,countyCd:null,startDT:null,endDT:null},"data-fields":{},methods:{type:"json",method:"GET"}},requirements:{needProxy:!0,requireskey:!1}},o={"disaster-declarations":{endpoint:"https://www.fema.gov/api/open/v2/DisasterDeclarationsSummaries",params:{},"data-fields":{femaDeclarationString:null,disasterNumber:null,state:null,declarationType:null,declarationDate:null,fyDeclared:null,incidentType:null,declarationTitle:null,ihProgramDeclared:null},methods:{type:"json",method:"GET"}},requirements:{needProxy:!1,requireskey:!1}},i={datasets:{endpoint:"https://www.ncdc.noaa.gov/cdo-web/api/v2/datasets",params:{},methods:{type:"json",method:"GET"}},availablestations:{endpoint:"https://www.ncdc.noaa.gov/cdo-web/api/v2/stations",params:{locationid:null,extent:null,limit:null},methods:{type:"json",method:"GET"}},"prec-15min":{endpoint:"https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=PRECIP_15",params:{locationid:null,stationid:null,startdate:null,enddate:null,units:null,limit:null,offset:null,includemetadata:!1},methods:{ty