{"version":3,"sources":["webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/api/WeatherApi.ts"],"names":["WeatherApi","http","rootPath","mapper","e","AWC","Et0","Etr","H2DispEnd","H2DispStart","Irr","Kc","Ks","Prec","PrecSource","Pu","RAW","Rs","RsSource","Tmax","Tmin","URSource","URmax","URmin","WSource","Wmax","Wmed","date","Date","setHours","effect_pct","p","lastLoadedMonth","lastLoadedYear","this","cancelTokenSource","cancelTokenWeatherHistoryMonth","pkCuaa","plotId","checkToken","cancel","axios","CancelToken","source","get","cancelToken","token","undefined","res","dbGIStoStandardPage","data","toISOString","getMonth","getFullYear"],"mappings":"8PAKqBA,E,WAmCjB,WAAYC,EAAkBC,GAAgB,uBAjCtC,KAAAC,OAAS,SAACC,GAAD,MAAa,CAC1BC,IAAKD,EAAEC,IACPC,IAAKF,EAAEE,IACPC,IAAKH,EAAEG,IACPC,UAAWJ,EAAEI,UACbC,YAAaL,EAAEK,YACfC,IAAKN,EAAEM,IACPC,GAAIP,EAAEO,GACNC,GAAIR,EAAEQ,GACNC,KAAMT,EAAES,KACRC,WAAYV,EAAEU,WACdC,GAAIX,EAAEW,GACNC,IAAKZ,EAAEY,IACPC,GAAIb,EAAEa,GACNC,SAAUd,EAAEc,SACZC,KAAMf,EAAEe,KACRC,KAAMhB,EAAEgB,KACRC,SAAUjB,EAAEiB,SACZC,MAAOlB,EAAEkB,MACTC,MAAOnB,EAAEmB,MACTC,QAASpB,EAAEoB,QACXC,KAAMrB,EAAEqB,KACRC,KAAMtB,EAAEsB,KACRC,KAAM,IAAIC,KAAK,IAAIA,KAAKxB,EAAEuB,MAAME,SAAS,EAAE,EAAE,EAAE,IAC/CC,WAAY1B,EAAE0B,WACdC,EAAG3B,EAAE2B,IAsCD,KAAAC,gBAAiC,KACjC,KAAAC,eAAgC,KA9BpCC,KAAKjC,KAAOA,EACZiC,KAAKhC,SAAWA,EAChBgC,KAAKC,kBAAoB,KACzBD,KAAKE,+BAAiC,K,sHAIn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JAgBA,WAA+BmC,GAA/B,uGACeJ,KAAKjC,KAAK2C,IAAV,uFAA8FN,IAD7G,cACGU,EADH,yBAEIA,EAAIE,MAFR,gD","file":"js/chunk-2d207830.093adbc3.js","sourcesContent":["import { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { dbGIStoStandardPage, PagedResults, PagingParams, standardPagingParamToDbGIS } from \"@abaco/web-common/src/Paging\";\nimport { Weather } from '../models/Weather';\nimport axios, { CancelTokenSource } from \"axios\";\n\nexport default class WeatherApi {\n\n private mapper = (e: any) => ({\n AWC: e.AWC,\n Et0: e.Et0,\n Etr: e.Etr,\n H2DispEnd: e.H2DispEnd,\n H2DispStart: e.H2DispStart,\n Irr: e.Irr,\n Kc: e.Kc,\n Ks: e.Ks,\n Prec: e.Prec,\n PrecSource: e.PrecSource,\n Pu: e.Pu,\n RAW: e.RAW,\n Rs: e.Rs,\n RsSource: e.RsSource,\n Tmax: e.Tmax,\n Tmin: e.Tmin,\n URSource: e.URSource,\n URmax: e.URmax,\n URmin: e.URmin,\n WSource: e.WSource,\n Wmax: e.Wmax,\n Wmed: e.Wmed,\n date: new Date(new Date(e.date).setHours(0,0,0,0)),\n effect_pct: e.effect_pct,\n p: e.p,\n });\n\n private http: HTTPClient;\n private rootPath: string;\n private cancelTokenSource: CancelTokenSource | null;\n private cancelTokenWeatherHistoryMonth: CancelTokenSource | null;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath;\n this.cancelTokenSource = null;\n this.cancelTokenWeatherHistoryMonth = null;\n }\n\n\n public async getPlotForecastWeather(pkCuaa: number, plotId: number, checkToken: boolean): Promise> {\n if (this.cancelTokenSource && checkToken) {\n this.cancelTokenSource.cancel();\n }\n this.cancelTokenSource = axios.CancelToken.source();\n const res = await this.http.get(`/siticatasto/dbgis-servlet/rest_tl_data?svccode=indexes/get_agrimeteo_indexes_full_month&force_cache=N&has_cache=N&lot_id=${plotId}&pk_cuaa=${pkCuaa}`, {\n cancelToken: checkToken ? this.cancelTokenSource?.token : undefined\n });\n return dbGIStoStandardPage(res.data, 17, this.mapper);\n }\n\n public async getPlotHistoricWeather(pkCuaa: number, plotId: number, date: Date, checkToken: boolean): Promise> {\n if (this.cancelTokenSource && checkToken) {\n this.cancelTokenSource.cancel();\n }\n this.cancelTokenSource = axios.CancelToken.source();\n const res = await this.http.get(`/siticatasto/dbgis-servlet/rest_tl_data?svccode=indexes/get_all_agrimeteo_indexes_month&date_ref=${date.toISOString()}&force_cache=N&has_cache=N&lot_id=${plotId}&pk_cuaa=${pkCuaa}`, {\n cancelToken: checkToken ? this.cancelTokenSource?.token : undefined\n });\n return dbGIStoStandardPage(res.data, 20, this.mapper);\n }\n\n private lastLoadedMonth: number | null = null;\n private lastLoadedYear: number | null = null;\n public async getPlotHistoricWeatherMonthToken(pkCuaa: number, plotId: number, date: Date): Promise> {\n const checkToken = this.lastLoadedMonth && this.lastLoadedYear && (this.lastLoadedMonth !== date.getMonth() || this.lastLoadedYear !== date.getFullYear()) ? true : false;\n if (this.cancelTokenWeatherHistoryMonth && checkToken) {\n this.cancelTokenWeatherHistoryMonth.cancel();\n }\n this.cancelTokenWeatherHistoryMonth = axios.CancelToken.source();\n this.lastLoadedMonth = date.getMonth();\n this.lastLoadedYear = date.getFullYear();\n const res = await this.http.get(`/siticatasto/dbgis-servlet/rest_tl_data?svccode=indexes/get_all_agrimeteo_indexes_month&date_ref=${date.toISOString()}&force_cache=N&has_cache=N&lot_id=${plotId}&pk_cuaa=${pkCuaa}`, {\n cancelToken: this.cancelTokenWeatherHistoryMonth?.token\n });\n return dbGIStoStandardPage(res.data, 20, this.mapper);\n }\n\n\n\n public async calculatePlotWeatherData(plotId: number): Promise> {\n const res = await this.http.get(`/siticatasto/dbgis-servlet/rest_tl_data?svccode=qdc/lot_meteo&force=0&lot_id=${plotId}`);\n return res.data;\n }\n\n\n}\n"],"sourceRoot":""}