-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.555c4775.js.map
1 lines (1 loc) · 10.3 KB
/
index.555c4775.js.map
1
{"mappings":"YAAe,SAAAA,EAA2BC,EAAKC,IAClC,MAAPA,GAAeA,EAAMD,EAAIE,UAAQD,EAAMD,EAAIE,QAC/C,IAAK,IAAIC,EAAI,EAAGC,EAAO,IAAIC,MAAMJ,GAAME,EAAIF,EAAKE,IAAKC,EAAKD,GAAKH,EAAIG,GACnE,OAAOC,ECDM,SAAAE,EAA4BN,GACzC,GAAIK,MAAME,QAAQP,GAAM,OAAOD,EAAkBC,GCHpC,SAAAQ,EAA0BC,GACvC,GAAsB,oBAAXC,QAAmD,MAAzBD,EAAKC,OAAOC,WAA2C,MAAtBF,EAAK,cAAuB,OAAOJ,MAAMO,KAAKH,GCDvG,SAAAI,IACb,MAAM,IAAIC,UAAU,yICCP,SAAAC,EAAqCC,EAAGC,GACrD,GAAKD,EAAL,CACA,GAAiB,iBAANA,EAAgB,OAAOjB,EAAkBiB,EAAGC,GACvD,IAAIC,EAAIC,OAAOC,UAAUC,SAASC,KAAKN,GAAGO,MAAM,GAAG,GAEnD,MADU,WAANL,GAAkBF,EAAEQ,cAAaN,EAAIF,EAAEQ,YAAYC,MAC7C,QAANP,GAAqB,QAANA,EAAoBb,MAAMO,KAAKM,GACxC,cAANA,GAAqB,2CAA2CQ,KAAKR,GAChEnB,EAAkBiB,EAAGC,QAD9B,GCHa,SAAAU,EAA4B3B,GACzC,OAAOM,EAAkBN,IAAQQ,EAAgBR,IAAQe,EAA2Bf,IAAQa,ICJ9F,SAASe,EAAOC,GACZ,IAAIC,EAAQC,SAASF,EAAC,SAAaG,OAAO,GAAI,IAC1CC,EAAa,YAGbA,GADAH,EAAQ,EACM,IACNA,GAAS,GAAOA,EAAQ,GAClB,IACNA,GAAS,IAAQA,EAAQ,GACnB,IAEA,IAGlB,IAAII,EAAYC,SAASC,eAAeH,GAEpCI,EAAUF,SAASG,cAAc,OACrCD,EAAQE,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,QAAUA,EAAc,GAAK,IAEtErC,SAASC,eAAe,cAC9BO,UAAY,mBAAqB+B,EAAc,QAAUA,EAAc,GAAK,IAEzEvC,SAASC,eAAe,eAC9BO,UAAYiB,EAAO,SAEZzB,SAASC,eAAe,gBAC9BO,UAAYa,EAAO,SAEbrB,SAASC,eAAe,gBAC9BO,UAAYe,EAAO,SAEhC,IAAK,IAAIvD,EAAI,EAAGA,EAAI,GAAIA,IAAK,CACzB,IAAIwE,EAAcxC,SAASC,eAAe,UAAYjC,GAClDyE,EAAU1B,EAAO/C,GAGjBwE,EAAYpC,UADZqC,EAAWhB,EAAOM,EACM,6CAEpBU,EAAWhB,EAAOM,EACM,2CAEA,+CAYxC,IAAIW,EAAW1C,SAASC,eAAe,cACnC0C,EAAO,IAAIC,KAAKA,KAAKC,OAErBC,EAAOH,EAAKI,mBAAmB,QAAS,CAAEC,QAAS,SACnDC,EAAQN,EAAKO,UACbC,EAASR,EAAKI,mBAAmB,QAAS,CAAEK,MAAO,SACnDC,EAAUV,EAAKW,WAAa,EAC5BC,EAAQZ,EAAKa,cACjBd,EAASlC,UAAY,mCAAqCsC,EAAO,IAAMG,EAAQ,OAASE,EAAS,QAAUI,EAG3G,IAAIE,EAAY,CAACF,EAAOF,EAASJ,GAAOS,KAAK,KAAO,SAChDC,EAAU,CAACJ,EAAOF,EAASJ,GAAOS,KAAK,KAAO,SAKlDE,MAHU,qFAAuFH,EAAY,aAAeE,EAAU,oBAIjIE,MAAKC,Y,OAAYA,EAASC,UAC1BF,MAAKG,Y,OAzBV,SAAaA,GACTA,EAAI,SAAa,GAAjB,kBAA4CC,QAAQxE,GAEpDmB,EAASoD,EAAI,SAAa,GAAjB,mBAsBKE,CAAIF,M","sources":["node_modules/@swc/helpers/src/_array_like_to_array.mjs","node_modules/@swc/helpers/src/_array_without_holes.mjs","node_modules/@swc/helpers/src/_iterable_to_array.mjs","node_modules/@swc/helpers/src/_non_iterable_spread.mjs","node_modules/@swc/helpers/src/_unsupported_iterable_to_array.mjs","node_modules/@swc/helpers/src/_to_consumable_array.mjs","src/js/index.ts"],"sourcesContent":["export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}\n","import _arrayLikeToArray from './_array_like_to_array.mjs';\n\nexport default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return _arrayLikeToArray(arr);\n}\n","export default function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}\n","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n","import _arrayLikeToArray from './_array_like_to_array.mjs';\n\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))\n return _arrayLikeToArray(o, minLen);\n}\n","import arrayWithoutHoles from './_array_without_holes.mjs';\nimport iterableToArray from './_iterable_to_array.mjs';\nimport nonIterableSpread from './_non_iterable_spread.mjs';\nimport unsupportedIterableToArray from './_unsupported_iterable_to_array.mjs';\n\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}\n","const DECIMALES = 4\n\nfunction pintar(v) {\n let _hora = parseInt(v['datetime'].substr(11, 2))\n let _dashboard = \"dashboard\"\n\n if (_hora < 6) {\n _dashboard += \"1\"\n } else if ((_hora >= 6) && (_hora < 12)) {\n _dashboard += \"2\"\n } else if ((_hora >= 12) && (_hora < 18)) {\n _dashboard += \"3\"\n } else {\n _dashboard += \"4\"\n }\n\n let dashboard = document.getElementById(_dashboard)\n\n let tarjeta = document.createElement('div')\n tarjeta.className = \"bg-white shadow-2xl p-3 rounded-lg m-2\"\n tarjeta.setAttribute(\"id\", \"tarjeta\" + _hora)\n\n let esquema = document.createElement('div')\n esquema.className = \"flex flex-col items-center\"\n\n let precio = document.createElement('h2')\n precio.className = \"text-2xl font-bold text-center\"\n precio.innerText = (v['value'] / 1000).toFixed(DECIMALES) + \" €/kWh\"\n precio.setAttribute(\"id\", \"precio\" + _hora)\n\n let hora = document.createElement('div')\n hora.className = \"text-sm font-light\"\n hora.innerText = _hora + \"h - \" + (_hora + 1) + \"h\"\n hora.setAttribute(\"id\", \"hora\" + _hora)\n\n dashboard.appendChild(tarjeta).appendChild(esquema).appendChild(precio).appendChild(hora)\n}\n\nfunction getStandardDeviation(array) {\n const n = array.length\n const mean = array.reduce((a, b) => a + b) / n\n return Math.sqrt(array.map(x => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n)\n}\n\nfunction calculos(d) {\n let _datos = []\n\n for (let value in d) {\n _datos.push(parseFloat((d[value]['value'] / 1000).toFixed(DECIMALES)))\n }\n\n let _min = Math.min(..._datos)\n let _max = Math.max(..._datos)\n let _avg = _datos.reduce((p, c, _, a) => p + c / a.length, 0)\n let _std = parseFloat(getStandardDeviation(_datos).toFixed(DECIMALES))\n\n _avg = parseFloat(_avg.toFixed(DECIMALES))\n\n let _horaMinima = _datos.indexOf(_min)\n let _horaMaxima = _datos.indexOf(_max)\n\n let _divHoraMinima = document.getElementById(\"horaminima\")\n _divHoraMinima.innerText = \"Franja horaria: \" + _horaMinima + \"h - \" + (_horaMinima + 1) + \"h\"\n\n let _divHoraMaxima = document.getElementById(\"horamaxima\")\n _divHoraMaxima.innerText = \"Franja horaria: \" + _horaMaxima + \"h - \" + (_horaMaxima + 1) + \"h\"\n\n let precioMedio = document.getElementById(\"preciomedio\")\n precioMedio.innerText = _avg + \" €/kWh\"\n\n let precioMinimo = document.getElementById(\"preciominimo\")\n precioMinimo.innerText = _min + \" €/kWh\"\n\n let precioMaximo = document.getElementById(\"preciomaximo\")\n precioMaximo.innerText = _max + \" €/kWh\"\n\n for (let i = 0; i < 25; i++) {\n let tarjetaHora = document.getElementById(\"tarjeta\" + i)\n let _precio = _datos[i]\n\n if (_precio < (_avg - _std)) {\n tarjetaHora.className = \"bg-green-400 shadow-2xl p-3 rounded-lg m-2\"\n } else {\n if (_precio > (_avg + _std)) {\n tarjetaHora.className = \"bg-red-400 shadow-2xl p-3 rounded-lg m-2\"\n } else {\n tarjetaHora.className = \"bg-orange-400 shadow-2xl p-3 rounded-lg m-2\"\n }\n }\n }\n}\n\nfunction etl(data) {\n data[\"included\"][0]['attributes']['values'].forEach(pintar)\n\n calculos(data[\"included\"][0]['attributes']['values'])\n}\n\nlet divFecha = document.getElementById(\"fechadehoy\")\nlet _hoy = new Date(Date.now())\n\nlet _day = _hoy.toLocaleDateString('es-ES', { weekday: 'long' })\nlet _dayN = _hoy.getDate()\nlet _month = _hoy.toLocaleDateString('es-ES', { month: 'long' })\nlet _monthN = _hoy.getMonth() + 1\nlet _year = _hoy.getFullYear()\ndivFecha.innerText = \"Precios de la energía para hoy, \" + _day + \" \" + _dayN + \" de \" + _month + \" del \" + _year\n\n\nlet dateStart = [_year, _monthN, _dayN].join(\"-\") + \"T00:00\"\nlet dateEnd = [_year, _monthN, _dayN].join(\"-\") + \"T23:59\"\n\nlet url = \"https://apidatos.ree.es/es/datos/mercados/precios-mercados-tiempo-real?start_date=\" + dateStart + \"&end_date=\" + dateEnd + \"&time_trunc=hour\"\n\n\nfetch(url)\n .then(response => response.json())\n .then(data => etl(data))"],"names":["$6452d0e01274caf5$export$2e2bcd8739ae039","arr","len","length","i","arr2","Array","$452ee968123f97ce$export$2e2bcd8739ae039","isArray","$13a6544b4092fd9b$export$2e2bcd8739ae039","iter","Symbol","iterator","from","$51240a34355f0c69$export$2e2bcd8739ae039","TypeError","$ccd9946852f6d927$export$2e2bcd8739ae039","o","minLen","n","Object","prototype","toString","call","slice","constructor","name","test","$436dcfa2e0131a95$export$2e2bcd8739ae039","pintar","v","_hora","parseInt","substr","_dashboard","dashboard","document","getElementById","tarjeta","createElement","className","setAttribute","esquema","precio","innerText","toFixed","hora","appendChild","calculos","d","Math","_datos","value","push","parseFloat","array","mean","_min","min","_max","max","_avg","reduce","p","c","_","a","_std","b","sqrt","map","x","pow","_horaMinima","indexOf","_horaMaxima","tarjetaHora","_precio","divFecha","_hoy","Date","now","_day","toLocaleDateString","weekday","_dayN","getDate","_month","month","_monthN","getMonth","_year","getFullYear","dateStart","join","dateEnd","fetch","then","response","json","data","forEach","etl"],"version":3,"file":"index.555c4775.js.map"}