PageSourceSearch

https://finex.cz/wp-content/themes/finex-theme/dist/js/portfolio-chart.84be43ae3c42c9d06d83.js

js finex.cz collected 2026-10-02 05:26:20 UTC 31,095 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[5690],{338:(t,e,i)=>{i.d(e,{j:()=>a});var s=i(7212),n=i(2336);class a extends n.j{dependencies=["RangePlugin"];binds={onView:this.onView.bind(this),onClick:this.onClick.bind(this)};options={customLabels:["Today","Yesterday","Last 7 Days","Last 30 Days","This Month","Last Month"],customPreset:{},position:"left"};getName(){return"PresetPlugin"}onAttach(){if(!Object.keys(this.options.customPreset).length){const t=new s.c,e=()=>{const e=t.clone();e.setDate(1);const i=new Date(t.getFullYear(),t.getMonth()+1,0);return[new s.c(e),new s.c(i)]},i=()=>{const e=t.clone();e.setMonth(e.getMonth()-1),e.setDate(1);const i=new Date(t.getFullYear(),t.getMonth(),0);return[new s.c(e),new s.c(i)]},n=[[t.clone(),t.clone()],[t.clone().subtract(1,"day"),t.clone().subtract(1,"day")],[t.clone().subtract(6,"day"),t.clone()],[t.clone().subtract(29,"day"),t.clone()],e(),i()];Object.values(this.options.customLabels).forEach((t,e)=>{this.options.customPreset[t]=n[e]})}this.picker.on("view",this.binds.onView),this.picker.on("click",this.binds.onClick)}onDetach(){this.picker.off("view",this.binds.onView),this.picker.off("click",this.binds.onClick)}onView(t){const{view:e,target:i}=t.detail;if("Main"===e){const t=document.createElement("div");t.className="preset-plugin-container",Object.keys(this.options.customPreset).forEach(e=>{if(Object.prototype.hasOwnProperty.call(this.options.customPreset,e)){const i=this.options.customPreset[e],s=document.createElement("button");s.className="preset-button unit",s.innerHTML=e,s.dataset.start=i[0].getTime(),s.dataset.end=i[1].getTime(),t.appendChild(s),this.picker.trigger("view",{view:"PresetPluginButton",target:s})}}),i.appendChild(t),i.classList.add(`preset-${this.options.position}`),this.picker.trigger("view",{view:"PresetPluginContainer",target:t})}}onClick(t){const e=t.target;if(e instanceof HTMLElement){const t=e.closest(".unit");if(!(t instanceof HTMLElement))return;if(this.isPresetButton(t)){const e=new s.c(Number(t.dataset.start)),i=new s.c(Number(t.dataset.end));this.picker.options.autoApply?(this.picker.setDateRange(e,i),this.picker.trigger("select",{start:this.picker.getStartDate(),end:this.picker.getEndDate()}),this.picker.hide()):(this.picker.datePicked=[e,i],this.picker.renderAll())}}}isPresetButton(t){return t.classList.contains("preset-button")}}},1142:(t,e,i)=>{i.d(e,{f:()=>a});var s=i(7212),n=i(2336);class a extends n.j{tooltipElement;triggerElement;binds={setStartDate:this.setStartDate.bind(this),setEndDate:this.setEndDate.bind(this),setDateRange:this.setDateRange.bind(this),getStartDate:this.getStartDate.bind(this),getEndDate:this.getEndDate.bind(this),onView:this.onView.bind(this),onShow:this.onShow.bind(this),onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),onClickCalendarDay:this.onClickCalendarDay.bind(this),onClickApplyButton:this.onClickApplyButton.bind(this),parseValues:this.parseValues.bind(this),updateValues:this.updateValues.bind(this),clear:this.clear.bind(this)};options={elementEnd:null,startDate:null,endDate:null,repick:!1,strict:!0,delimiter:" - ",tooltip:!0,tooltipNumber:t=>t,locale:{zero:"",one:"day",two:"",few:"",many:"",other:"days"},documentClick:this.hidePicker.bind(this)};getName(){return"RangePlugin"}onAttach(){this.binds._setStartDate=this.picker.setStartDate,this.binds._setEndDate=this.picker.setEndDate,this.binds._setDateRange=this.picker.setDateRange,this.binds._getStartDate=this.picker.getStartDate,this.binds._getEndDate=this.picker.getEndDate,this.binds._parseValues=this.picker.parseValues,this.binds._updateValues=this.picker.updateValues,this.binds._clear=this.picker.clear,this.binds._onClickCalendarDay=this.picker.onClickCalendarDay,this.binds._onClickApplyButton=this.picker.onClickApplyButton,Object.defineProperties(this.picker,{setStartDate:{configurable:!0,value:this.binds.setStartDate},setEndDate:{configurable:!0,value:this.binds.setEndDate},setDateRange:{configurable:!0,value:this.binds.setDateRange},getStartDate:{configurable:!0,value:this.binds.getStartDate},getEndDate:{configurable:!0,value:this.binds.getEndDate},parseValues:{configurable:!0,value:this.binds.parseValues}
vendor: 4,225 bytes, line 1
1,updateValues:{configurable:!0,value:this.binds.updateValues},clear:{configurable:!0,value:this.binds.clear},onClickCalendarDay:{configurable:!0,value:this.binds.onClickCalendarDay},onClickApplyButton:{configurable:!0,value:this.binds.onClickApplyButton}}),this.options.elementEnd&&(this.options.elementEnd instanceof HTMLElement||(this.options.elementEnd=this.picker.options.doc.querySelector(this.options.elementEnd)),this.options.elementEnd instanceof HTMLInputElement&&(this.options.elementEnd.readOnly=this.picker.options.readonly),"function"==typeof this.picker.options.documentClick&&(document.removeEventListener("click",this.picker.options.documentClick,!0),"function"==typeof this.options.documentClick&&document.addEventListener("click",this.options.documentClick,!0)),this.options.elementEnd.addEventListener("click",this.picker.show.bind(this.picker))),this.options.repick=this.options.repick&&this.options.elementEnd instanceof HTMLElement,this.picker.options.date=null,this.picker.on("view",this.binds.onView),this.picker.on("show",this.binds.onShow),this.picker.on("mouseenter",this.binds.onMouseEnter,!0),this.picker.on("mouseleave",this.binds.onMouseLeave,!0),this.checkIntlPluralLocales()}onDetach(){Object.defineProperties(this.picker,{setStartDate:{configurable:!0,value:this.binds._setStartDate},setEndDate:{configurable:!0,value:this.binds._setEndDate},setDateRange:{configurable:!0,value:this.binds._setDateRange},getStartDate:{configurable:!0,value:this.binds._getStartDate},getEndDate:{configurable:!0,value:this.binds._getEndDate},parseValues:{configurable:!0,value:this.binds._parseValues},updateValues:{configurable:!0,value:this.binds._updateValues},clear:{configurable:!0,value:this.binds._clear},onClickCalendarDay:{configurable:!0,value:this.binds._onClickCalendarDay},onClickApplyButton:{configurable:!0,value:this.binds._onClickApplyButton}}),this.picker.off("view",this.binds.onView),this.picker.off("show",this.binds.onShow),this.picker.off("mouseenter",this.binds.onMouseEnter,!0),this.picker.off("mouseleave",this.binds.onMouseLeave,!0)}parseValues(){if(this.options.startDate||this.options.endDate)this.options.strict?this.options.startDate&&this.options.endDate?this.setDateRange(this.options.startDate,this.options.endDate):(this.options.startDate=null,this.options.endDate=null):(this.options.startDate&&this.setStartDate(this.options.startDate),this.options.endDate&&this.setEndDate(this.options.endDate));else if(this.options.elementEnd)this.options.strict?this.picker.options.element instanceof HTMLInputElement&&this.picker.options.element.value.length&&this.options.elementEnd instanceof HTMLInputElement&&this.options.elementEnd.value.length&&this.setDateRange(this.picker.options.element.value,this.options.elementEnd.value):(this.picker.options.element instanceof HTMLInputElement&&this.picker.options.element.value.length&&this.setStartDate(this.picker.options.element.value),this.options.elementEnd instanceof HTMLInputElement&&this.options.elementEnd.value.length&&this.setEndDate(this.options.elementEnd.value));else if(this.picker.options.element instanceof HTMLInputElement&&this.picker.options.element.value.length){const[t,e]=this.picker.options.element.value.split(this.options.delimiter);this.options.strict?t&&e&&this.setDateRange(t,e):(t&&this.setStartDate(t),e&&this.setEndDate(e))}}updateValues(){const t=this.picker.options.element,e=this.options.elementEnd,i=this.picker.getStartDate(),s=this.picker.getEndDate(),n=i instanceof Date?i.format(this.picker.options.format,this.picker.options.lang):"",a=s instanceof Date?s.format(this.picker.options.format,this.picker.options.lang):"";if(e)t instanceof HTMLInputElement?t.value=n:t instanceof HTMLElement&&(t.innerText=n),e instanceof HTMLInputElement?e.value=a:e instanceof HTMLElement&&(e.innerText=a);else{const e=`${n}${n||a?this.options.delimiter:""}${a}`;t instanceof HTMLInputElement?t.value=e:t instanceof HTMLElement&&(t.innerText=e)}}clear(){this.options.startDate=null,this.options.endDate=null,this.picker.datePicked.length=0,this.updateValues(),this.picker.renderAll(),this.picker.trigger("clear")}onShow(t){const{target:e}=t.detail;this.triggerElement=e,this.picker.options.scrollToDate&&this.get
vendor: 6,178 bytes, line 1
1StartDate()instanceof Date&&this.picker.gotoDate(this.getStartDate()),this.initializeRepick()}onView(t){const{view:e,target:i}=t.detail;if("Main"===e&&(this.tooltipElement=document.createElement("span"),this.tooltipElement.className="range-plugin-tooltip",i.appendChild(this.tooltipElement)),"CalendarDay"===e){const t=new s.c(i.dataset.time),e=this.picker.datePicked,n=e.length?this.picker.datePicked[0]:this.getStartDate(),a=e.length?this.picker.datePicked[1]:this.getEndDate();n&&n.isSame(t,"day")&&i.classList.add("start"),n&&a&&(a.isSame(t,"day")&&i.classList.add("end"),t.isBetween(n,a)&&i.classList.add("in-range"))}if("Footer"===e){const t=1===this.picker.datePicked.length&&!this.options.strict||2===this.picker.datePicked.length;i.querySelector(".apply-button").disabled=!t}}hidePicker(t){let e=t.target,i=null;e.shadowRoot&&(e=t.composedPath()[0],i=e.getRootNode().host),this.picker.isShown()&&i!==this.picker.ui.wrapper&&e!==this.picker.options.element&&e!==this.options.elementEnd&&this.picker.hide()}setStartDate(t){const e=new s.c(t,this.picker.options.format);this.options.startDate=e?e.clone():null,this.updateValues(),this.picker.renderAll()}setEndDate(t){const e=new s.c(t,this.picker.options.format);this.options.endDate=e?e.clone():null,this.updateValues(),this.picker.renderAll()}setDateRange(t,e){const i=new s.c(t,this.picker.options.format),n=new s.c(e,this.picker.options.format);this.options.startDate=i?i.clone():null,this.options.endDate=n?n.clone():null,this.updateValues(),this.picker.renderAll()}getStartDate(){return this.options.startDate instanceof Date?this.options.startDate.clone():null}getEndDate(){return this.options.endDate instanceof Date?this.options.endDate.clone():null}onMouseEnter(t){const e=t.target;if(e instanceof HTMLElement){this.isContainer(e)&&this.initializeRepick();const t=e.closest(".unit");if(!(t instanceof HTMLElement))return;if(this.picker.isCalendarDay(t)){if(1!==this.picker.datePicked.length)return;let e=this.picker.datePicked[0].clone(),i=new s.c(t.dataset.time),n=!1;if(e.isAfter(i,"day")){const t=e.clone();e=i.clone(),i=t.clone(),n=!0}if([...this.picker.ui.container.querySelectorAll(".day")].forEach(a=>{const o=new s.c(a.dataset.time),r=this.picker.Calendar.getCalendarDayView(o);o.isBetween(e,i)&&r.classList.add("in-range"),o.isSame(this.picker.datePicked[0],"day")&&(r.classList.add("start"),r.classList.toggle("flipped",n)),a===t&&(r.classList.add("end"),r.classList.toggle("flipped",n)),a.className=r.className}),this.options.tooltip){const s=this.options.tooltipNumber(i.diff(e,"day")+1);if(s>0){const e=new Intl.PluralRules(this.picker.options.lang).select(s),i=`${s} ${this.options.locale[e]}`;this.showTooltip(t,i)}else this.hideTooltip()}}}}onMouseLeave(t){if(this.isContainer(t.target)&&this.options.repick){const t=this.getStartDate(),e=this.getEndDate();t&&e&&(this.picker.datePicked.length=0,this.picker.renderAll())}}onClickCalendarDay(t){if(this.picker.isCalendarDay(t)){2===this.picker.datePicked.length&&(this.picker.datePicked.length=0);const e=new s.c(t.dataset.time);if(this.picker.datePicked[this.picker.datePicked.length]=e,2===this.picker.datePicked.length&&this.picker.datePicked[0].isAfter(this.picker.datePicked[1])){const t=this.picker.datePicked[1].clone();this.picker.datePicked[1]=this.picker.datePicked[0].clone(),this.picker.datePicked[0]=t.clone()}1!==this.picker.datePicked.length&&this.picker.options.autoApply||this.picker.trigger("preselect",{start:this.picker.datePicked[0]instanceof Date?this.picker.datePicked[0].clone():null,end:this.picker.datePicked[1]instanceof Date?this.picker.datePicked[1].clone():null}),1===this.picker.datePicked.length&&(!this.options.strict&&this.picker.options.autoApply&&(this.picker.options.element===this.triggerElement&&this.setStartDate(this.picker.datePicked[0]),this.options.elementEnd===this.triggerElement&&this.setEndDate(this.picker.datePicked[0]),this.picker.trigger("select",{start:this.picker.getStartDate(),end:this.picker.getEndDate()})),this.picker.renderAll()),2===this.picker.datePicked.length&&(this.picker.options.autoApply?(this.setDateRange(this.picker.datePicked[0],this.picker.datePicked[1]),this.picker.trigger("select",{start:this.picker.getStartDate(),end:this.picker.getEndDate()}),this.picker.hide()):(this.hideTooltip(),this.picker.renderAll()))}}onClickApplyButton(t){this.picker.isApplyButton(t)&&(1!==this.picker.datePicked.length||this.options.strict||(this.picker.options.element===this.triggerElement&&(this.options.endDate=null,this.setStartDate(this.picker.datePicked[0])),this.options.elementEnd===this.triggerElement&&(this.options.startDate=null,this.setEndDate(this.picker.datePicked[0]))),2===this.picker.datePicked.length&&this.setDateRange(this.picker.datePicked[0],this.picker.datePicked[1]),this.picker.trigger("select",{start:this.picker.getStartDate(),end:this.picker.getEndDate()}),this.picker.hide())}showTooltip(t,e){this.tooltipElement.style.visibility="visible",this.tooltipElement.innerHTML=e;const i=this.picker.ui.container.getBoundingClientRect(),s=this.tooltipElement.getBoundingClientRect(),n=t.getBoundingClientRect();let a=n.top,o=n.left;a-=i.top,o-=i.left,a-=s.height,o-=s.width/2,o+=n.width/2,this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${o}px`}hideTooltip(){this.tooltipElement.style.visibility="hidden"}checkIntlPluralLocales(){if(!this.options.tooltip)return;const t=[...new Set([new Intl.PluralRules(this.picker.options.lang).select(0),new Intl.PluralRules(this.picker.options.lang).select(1),new Intl.PluralRules(this.picker.options.lang).select(2),new Intl.PluralRules(this.picker.options.lang).select(6),new Intl.PluralRules(this.picker.options.lang).select(18)])],e=Object.keys(this.options.locale);t.every(t=>e.includes(t))||console.warn(`${this.getName()}: provide locales (${t.join(", ")}) for correct tooltip text.`)}initializeRepick(){if(!this.options.repick)return;const t=this.getStartDate(),e=this.getEndDate();e&&this.triggerElement===this.picker.options.element&&(this.picker.datePicked[0]=e),t&&this.triggerElement===this.options.elementEnd&&(this.picker.datePicked[0]=t)}isContainer(t){return t===this.picker.ui.container}}
vendor: 4,670 bytes, line 1
1},2886:(t,e,i)=>{i.d(e,{J:()=>a});var s=i(7212),n=i(2336);class a extends n.j{priority=1;binds={onView:this.onView.bind(this)};options={minDate:null,maxDate:null,minDays:null,maxDays:null,selectForward:null,selectBackward:null,presets:!0,inseparable:!1,filter:null};getName(){return"LockPlugin"}onAttach(){if(this.options.minDate&&(this.options.minDate=new s.c(this.options.minDate,this.picker.options.format,this.picker.options.lang)),this.options.maxDate&&(this.options.maxDate=new s.c(this.options.maxDate,this.picker.options.format,this.picker.options.lang),this.options.maxDate instanceof s.c&&this.picker.options.calendars>1&&this.picker.calendars[0].isSame(this.options.maxDate,"month"))){const t=this.picker.calendars[0].clone().subtract(1,"month");this.picker.gotoDate(t)}if((this.options.minDays||this.options.maxDays||this.options.selectForward||this.options.selectBackward)&&!this.picker.options.plugins.includes("RangePlugin")){const t=["minDays","maxDays","selectForward","selectBackward"];console.warn(`${this.getName()}: options ${t.join(", ")} required RangePlugin.`)}this.picker.on("view",this.binds.onView)}onDetach(){this.picker.off("view",this.binds.onView)}onView(t){const{view:e,target:i,date:n}=t.detail;if("CalendarHeader"===e&&(this.options.minDate instanceof s.c&&n.isSameOrBefore(this.options.minDate,"month")&&i.classList.add("no-previous-month"),this.options.maxDate instanceof s.c&&n.isSameOrAfter(this.options.maxDate,"month")&&i.classList.add("no-next-month")),"CalendarDay"===e){const t=this.picker.datePicked.length?this.picker.datePicked[0]:null;if(this.testFilter(n))return void i.classList.add("locked");if(this.options.inseparable){if(this.options.minDays){const t=n.clone().subtract(this.options.minDays-1,"day"),e=n.clone().add(this.options.minDays-1,"day");let s=!1,a=!1;for(;t.isBefore(n,"day");){if(this.testFilter(t)){s=!0;break}t.add(1,"day")}for(;e.isAfter(n,"day");){if(this.testFilter(e)){a=!0;break}e.subtract(1,"day")}s&&a&&i.classList.add("not-available")}this.rangeIsNotAvailable(n,t)&&i.classList.add("not-available")}this.dateIsNotAvailable(n,t)&&i.classList.add("not-available")}if(this.options.presets&&"PresetPluginButton"===e){const t=new s.c(Number(i.dataset.start)),e=new s.c(Number(i.dataset.end)),n=e.diff(t,"day"),a=this.options.minDays&&n<this.options.minDays,o=this.options.maxDays&&n>this.options.maxDays;(a||o||this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDate(e)||this.lockMaxDate(e)||this.rangeIsNotAvailable(t,e))&&i.setAttribute("disabled","disabled")}}dateIsNotAvailable(t,e){return this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDays(t,e)||this.lockMaxDays(t,e)||this.lockSelectForward(t)||this.lockSelectBackward(t)}rangeIsNotAvailable(t,e){if(!t||!e)return!1;const i=(t.isSameOrBefore(e,"day")?t:e).clone(),s=(e.isSameOrAfter(t,"day")?e:t).clone();for(;i.isSameOrBefore(s,"day");){if(this.testFilter(i))return!0;i.add(1,"day")}return!1}lockMinDate(t){return this.options.minDate instanceof s.c&&t.isBefore(this.options.minDate,"day")}lockMaxDate(t){return this.options.maxDate instanceof s.c&&t.isAfter(this.options.maxDate,"day")}lockMinDays(t,e){if(this.options.minDays&&e){const i=e.clone().subtract(this.options.minDays-1,"day"),s=e.clone().add(this.options.minDays-1,"day");return t.isBetween(i,s)}return!1}lockMaxDays(t,e){if(this.options.maxDays&&e){const i=e.clone().subtract(this.options.maxDays,"day"),s=e.clone().add(this.options.maxDays,"day");return!t.isBetween(i,s)}return!1}lockSelectForward(t){if(1===this.picker.datePicked.length&&this.options.selectForward){const e=this.picker.datePicked[0].clone();return t.isBefore(e,"day")}return!1}lockSelectBackward(t){if(1===this.picker.datePicked.length&&this.options.selectBackward){const e=this.picker.datePicked[0].clone();return t.isAfter(e,"day")}return!1}testFilter(t){return"function"==typeof this.options.filter&&this.options.filter(t,this.picker.datePicked)}}},6210:(t,e,i)=>{i.d(e,{initializeAddedPortfolioChart:()=>u});var s=i(5285),n=i.n(s),a=i(428),o=i.n(a),r=i(8388),l=i(6739),c=i(7134);const h=t=>`${t}`.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),d=(t,e)=>`<span class="portfolio-stat-chunk">${h(t)}</span> <span class="portfolio-stat-chunk">(${h(e)} %)</span>`;class p{constructor(t,e){this.el=t,this.lines=[],this.userId=e,this.disableTooltip=!1,this.minDate=n()(),this.from=n()().subtract(1,"month"),this.to=n()(),this.currency=(0,l.LZ)(),this.scale=null,this.units=[],this.portfolioData=[],this.splitEventsByUnit={},this.portfolioStates={},this.dataCache={},this.loadConfig(),this.loader=t.find(".loader-wrapper"),this.el.find(".chart
1-container").length&&(this.renderer=null,this.ChartRendererClass=null,Promise.all([i.e(4943),i.e(1699)]).then(i.bind(i,5053)).then(({ChartRenderer:t})=>{this.ChartRendererClass=t,this.ensureRenderer()&&this.setRange(this.from,this.to)}),this.initDatePicker())}ensureRenderer(){if(this.renderer)return!0;if(!this.ChartRendererClass)return!1;const t=this.el.find(".chart-container").get(0);return!(!t||0===t.offsetWidth)&&(this.renderer=new this.ChartRendererClass(t,this.el.find(".legend-wrapper").get(0),this.currency,this.scale),this.renderer.setTooltipVisible(!this.disableTooltip),!0)}initDatePicker(){const t=this.el.find(".datepicker input").not("#tx-add-date").get(0);t&&(this.datePicker&&this.datePicker.engine&&"function"==typeof this.datePicker.engine.destroy&&this.datePicker.engine.destroy(),this.datePicker=new r.l(t,this.from,this.to,this.minDate,(t,e)=>this.setRange(t,e)))}syncDateBoundsWithPortfolioData(){if(!this.portfolioData.length)return;const t=this.portfolioData.reduce((t,e)=>{const i=n()(e.date);return i.isValid()&&(!t||i.isBefore(t))?i:t},null);if(!t)return;const e=t.startOf("day"),i=e.subtract(14,"days"),s=!this.minDate||!this.minDate.isSame(e,"day"),a=!this.from||this.from.isAfter(i);s&&(this.minDate=e,this.el.attr("data-oldest",this.minDate.format("YYYY-MM-DD"))),a&&(this.from=i),s?this.initDatePicker():a&&this.datePicker&&this.datePicker.setRange(this.from.toDate(),this.to.toDate())}reloadUnitData(t=null){(this.ensureRenderer()||t)&&(this.loader.addClass("active"),o().ajax({type:"POST",url:finex.fast_ajax_url,data:{action:"finex_user_get_portfolio",user_id:this.userId,chart:!0,local_currency:this.currency},dataType:"json",success:e=>{const i=e&&"object"==typeof e?e:{};this.portfolioData=Array.isArray(i)?i:i.history||[],this.splitEventsByUnit=Array.isArray(i)?{}:i.split_events_by_unit||{},this.portfolioStates={};const s=-60*(new Date).getTimezoneOffset(),a=new Map;this.portfolioData.forEach(t=>{const e=`${t.type}/${t.unit}`;a.has(e)||a.set(e,{unit:t.unit,type:t.type});const i=n()(t.date).unix()+s;void 0===this.portfolioStates[i]&&(this.portfolioStates[i]={}),this.portfolioStates[i][`${t.type}/${t.unit}`]=t}),this.units=Array.from(a.values()),this.syncDateBoundsWithPortfolioData();const o=Object.keys(this.portfolioStates).sort((t,e)=>t-e);let r=o[0];for(let t=1;t<o.length;t++){const e=this.portfolioStates[o[t]],i={...this.portfolioStates[r],...e};r=o[t],this.portfolioStates[r]=i}const l=t||this.dataReadyCallback||null;this.dataReadyCallback&&(this.dataReadyCallback=null),l&&l(Object.values(this.getState(n()().subtract(1,"days").unix()+s)),Object.values(this.getState(n()().unix()+s))),this.reload()},error:t=>{console.error("Error loading portfolio",t)}}))}loadConfig(){this.minDate=n()(this.el.data("oldest"),"YYYY-MM-DD"),this.from=this.minDate.subtract(14,"days")}getState(t){const e=Object.keys(this.portfolioStates).reduce((e,i)=>i<=t&&i>e?i:e,0);return this.portfolioStates[e]||{}}getSplitMultiplierAfterTimestamp(t,e){const i=this.splitEventsByUnit[t]||[];return i.length?i.reduce((t,i)=>i.timestamp>e?t*i.value:t,1):1}getOwnedForTimestamp(t,e){if(void 0===t.owned_split_adjusted&&void 0===t.owned_manual)return t.owned||0;const i=`${t.type}/${t.unit}`,s=this.getSplitMultiplierAfterTimestamp(i,e),n=parseFloat(t.owned_split_adjusted)||0,a=parseFloat(t.owned_manual)||0;return!Number.isFinite(s)||s<=0?n+a:n/s+a}setRange(t,e,i=!1){this.dataCache=[],this.el.find(".range").removeClass("active"),i&&this.datePicker.setRange(t.toDate(),e.toDate()),this.from=t,this.to=e,this.reloadUnitData()}shouldShowDepositsLine(){const t=this.el.attr("data-show-deposits-chart");return void 0===t||"0"!=`${t}`}async buildDepositsRecords(t,e){if(!t.length||!this.portfolioData.length)return[];const i=this.portfolioData.map(t=>({time:n()(t.date).unix()+e,rawAmount:parseFloat(t.raw_amount??t.amount),price:null!==t.price&&void 0!==t.price?parseFloat(t.price):null,currency:t.currency?`${t.currency}`.toUpperCase():this.currency,localTotalValue:null!==t.local_total_value&&void 0!==t.local_total_value?parseFloat(t.local_total_value):null,unit:t.unit,type:t.type})).filter(t=>Number.isFinite(t.rawAmount)&&"indice"!==t.type&&Math.abs(t.rawAmount)>0&&(Number.isFinite(t.localTotalValue)&&t.localTotalValue>0||Number.isFinite(t.price)&&t.price>0)).sort((t,e)=>t.time-e.time);if(!i.length)return[];const s={};
1i.forEach(t=>{const e=`${t.type}/${t.unit}`;s[e]||(s[e]={type:t.type,unit:t.unit,unitData:null})});const a=Object.values(s);await Promise.allSettled(a.map(async t=>{const e=await c.P.getUnit(t.unit,t.type,[this.currency]);return{key:`${t.type}/${t.unit}`,unitData:e}})).then(t=>{t.forEach(t=>{if("fulfilled"!==t.status||!t.value)return;const{key:e,unitData:i}=t.value;s[e]&&(s[e]={...s[e],unitData:i})})});const o={},r=t=>{if(!t.currency||t.currency===this.currency)return 1;const e=`${t.type}/${t.unit}/${t.currency}/${this.currency}`;if(void 0!==o[e])return o[e];const i=s[`${t.type}/${t.unit}`],n=i?i.unitData:null;if(!n)return o[e]=1,1;const a=n.getPrice(t.currency),r=n.getPrice(this.currency);return o[e]=a&&r&&a>0?r/a:1,o[e]},l=[...t].sort((t,e)=>t-e),h=[];let d=0,p=0;return l.forEach(t=>{for(;d<i.length&&i[d].time<=t;){const t=i[d];let e=null;if(Number.isFinite(t.localTotalValue)&&t.localTotalValue>0)e=t.localTotalValue;else{const i=r(t);e=Math.abs(t.rawAmount)*t.price*i}p+=t.rawAmount>0?e:-e,d+=1}h.push({time:t,value:p})}),h}async buildTodayFallbackRecords(t){const e=n()().unix()+t,i=n()().startOf("day").unix()+t,s=Object.values(this.getState(e)).filter(t=>t&&"indice"!==t.type);if(!s.length)return[];const a=s.map(t=>c.P.getUnit(t.unit,t.type,[this.currency])),o=(await Promise.allSettled(a)).reduce((t,e,i)=>{if("fulfilled"!==e.status||!e.value)return t;const n=e.value.getPrice(this.currency);return n?t+n*s[i].owned:t},0);return[{time:i,value:o},{time:e,value:o}]}async reload(){if(!this.ensureRenderer())return;this.dataCache={};const t=[],e=await(0,l._$)();e&&"false"!==e&&o().ajaxSetup({headers:{Authorization:`Bearer ${e}`}});for(let i=0;i<this.units.length;i++){const{unit:s,type:n}=this.units[i],a={from:this.from.format(l.yQ),to:this.to.format(l.yQ),currency:this.currency,splits:!1,site:finex.api_origin};e&&"false"!==e&&(a.token=e),t.push(o().get(`${finex.api_url}/charts/${n}/${s}/`,a))}const i=new Set,s=new Date,a=[];Promise.allSettled(t).then(async t=>{const e=t.map(t=>t.value||[]);for(let t=0;t<e.length;t++){const o=e[t];if(!o.success){const t=o.error||{description:"Generic error while loading chart data."};console.error(t.description);continue}const{asset:r,type:l,records:c}=o.data||{};if(!r||!l||!Array.isArray(c))continue;c.map(t=>n()(t[0]).unix()+-60*s.getTimezoneOffset()).forEach(t=>i.add(t));const h=c.filter(t=>Number.isFinite(Number(t?.[4]))).map(t=>({time:n()(t[0]).unix()+-60*s.getTimezoneOffset(),value:t[4]}));a.push({asset:r,type:l,records:h})}const o=Array.from(i).sort((t,e)=>t-e);a.forEach(t=>{const{asset:e,type:i,records:s}=t;if(!s.length)return;const n=`${i}/${e}`;this.dataCache[n]={};let a=0;for(let t=0;t<o.length;t++){const{value:e,time:i}=s[a];o[t]>=i&&(a++,a=Math.min(a,s.length-1)),this.dataCache[n][o[t]]={time:o[t],value:e}}});const r=Object.keys(this.portfolioStates).map(t=>Number(t)).sort((t,e)=>t-e),l=r.length?r[0]:null;let c=(null!==l?o.filter(t=>t>=l):o).map(t=>{const e=this.getState(t);return{time:t,value:Object.values(e).reduce((e,i)=>{if(!i||"indice"===i.type)return e;return e+((this.dataCache[`${i.type}/${i.unit}`]||{})[t]||{value:0}).value*this.getOwnedForTimestamp(i,t)},0)}});const h=n()().unix()+-60*s.getTimezoneOffset(),d=r.length>0&&r.every(t=>n().unix(t- -60*s.getTimezoneOffset()).isSame(n().unix(h- -60*s.getTimezoneOffset()),"day"));!c.length&&d&&(c=await this.buildTodayFallbackRecords(-60*s.getTimezoneOffset()));const p=c.map(t=>t.time),u=[{currency:this.currency,unit:"PORTFOLIO",type:"portfolio",data:c}];if(this.shouldShowDepositsLine()){const t=await this.buildDepositsRecords(p,-60*s.getTimezoneOffset());t.length&&u.push({currency:this.currency,unit:"DEPOSITS",type:"deposits",data:t})}this.renderer.setData(u,!0),this.loader.removeClass("active")}).catch(t=>{console.error("Failed to render portfolio chart",t),this.loader.removeClass("active")})}}function u(){const t=o()("#fnx-portfolio"),e=t.data("user-id"),i=new p(t,e);i.dataReadyCallback=(e,i)=>{const s=(0,l.LZ)(),n=[];i.forEach(t=>{n.push(c.P.getUnit(t.unit,t.type,[s]))}),Promise.allSettled(n).then(n=>{const a=n.map(t=>t.value||[]);let r=0,c=0,h=0;const p=parseFloat(t.attr("data-total-buy-cost"))||0,u=parseFloat(t.attr("data-total-sell-proceeds"))||0;for(let t=0;t<a.length;t++){const n=a[t];if(!n||"indice"===n.type)continue;const o=n.getPrice(s);if(o){const t=i.find(t=>t.type===n.type&&t.unit===n.shortname),s=o*(t?t.owned:0),a=o*(e.find(t=>t.type===n.type&&t.unit===n.shortname)||{owned:0}).owned;c+=s,r+=a;const l=1+(Number.isFinite(n.getChange())?n.getChange():0)/100;h+=0!==l?a/l:0}}const f=r-h,k=h?(0,l.G8)(f/h*100):0,m=c+u-p,g=p?(0,l.G8)(m/p*100):0;o()("#portfolio-change").toggleClass("c-success",f>0).toggleClass("c-error",f<0).html(d((0,l.Ac)(f,s),k)),o()("#portfolio-overall-profit").toggleClass("c-success",m>0).toggleClass("c-error",m<0).html(d((0,l.Ac)(m,s),g)),o()("#portfolio-sum").text((0,l.Ac)(c,s))})}
1,o()(document).off("click.fnxHomePortfolioChart",'.tab[data-target="portfolio_tracker"]'),o()(document).on("click.fnxHomePortfolioChart",'.tab[data-target="portfolio_tracker"]',()=>{setTimeout(()=>{i.reloadUnitData()},0)})}},8388:(t,e,i)=>{i.d(e,{l:()=>u});var s=i(5285),n=i.n(s),a=i(8194),o=i(6349),r=i(1142),l=i(338),c=i(2886),h=i(7723),d=i(428),p=i.n(d);const __=h.__,_x=h._x;class u{constructor(t,e,i,s,h,d={}){if(!t)return;this.elem=t,this.startDate=e,this.endDate=i,this.callback=h,this.minDate=s,this.options=d,this.suppressSelect=!1;const u=this.getPresets(),f={j:"D",n:"M",Y:"YYYY"},k=window.finex.date_format.replace(/j|n|Y/gi,t=>f[t]??t);this.engine=new a.iT.create({element:this.elem,plugins:[o.Q,r.f,l.j,c.J],calendars:2,zIndex:50,grid:2,lang:document.documentElement.lang,readonly:!0,LockPlugin:{minDate:n()(this.minDate).toDate(),maxDate:new Date},PresetPlugin:{position:"left",customPreset:u},AmpPlugin:{dropdown:{minYear:n()(this.minDate).format("YYYY"),months:!0,years:!0},darkMode:!1},RangePlugin:{startDate:this.startDate.toDate(),endDate:this.endDate.toDate(),locale:{one:_x("day","one","finex"),two:_x("days","two","finex"),few:_x("days","few","finex"),many:_x("days","many","finex"),other:_x("days","other","finex")}},format:k,css:[`${window.finex.theme_url}/dist/css/easepick.css`],setup:t=>{t.on("select",t=>{if(this.suppressSelect)return;const{start:e,end:i}=t.detail;i.setHours(23,59,59),h(n()(e),n()(i))}),t.on("hide",()=>{p()(".bodyOverlay").removeClass("active")}),t.on("show",()=>{p()(".bodyOverlay").addClass("active")})}})}getPresets(){const t={};t[__("Today","finex")]=[new Date(new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate())),new Date],t[__("Yesterday","finex")]=[n()().subtract(1,"days").startOf("day").toDate(),n()().subtract(1,"days").endOf("day").toDate()],t[__("Last 7 days","finex")]=[n()().subtract(6,"days").startOf("day").toDate(),new Date],t[__("Last 30 days","finex")]=[n()().subtract(1,"month").startOf("day").toDate(),new Date],t[__("Last month","finex")]=[n()().subtract(1,"month").startOf("month").toDate(),n()().subtract(1,"month").endOf("month").toDate()],t[__("This year","finex")]=[new Date((new Date).getFullYear(),0,1),new Date],t[__("Last year","finex")]=[n()().subtract(1,"years").toDate(),new Date];const e=this.options.lastPresetLabel||__("Entire chart","finex"),i=n()(this.minDate).valueOf();return t[e]=[new Date(Math.max(i,1e9)),new Date],t}setRange(t,e){this.engine&&(this.suppressSelect=!0,this.engine.setDateRange(t,e),window.setTimeout(()=>{this.suppressSelect=!1},0))}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.