"use strict";(globalThis.webpackChunkinfinity_hitab_client=globalThis.webpackChunkinfinity_hitab_client||[]).push([[4621],{48536:(t,e,a)=>{a.d(e,{S:()=>c,f:()=>n});var i=a(74003),s=a(79664);const n=async(t,e)=>{try{const a=await s.hj.get(`${i.H}exchange-rate/rate`,{base:t,to:e},{_delay:0});if(0===a.code&&a.data.length>0)return[null,a.data];throw a}catch(t){return["catch error"]}},c=async(t,e,a)=>{try{const n=await s.hj.get(`${i.H}exchange-rate/history`,{code:t,base:e,days:a},{_delay:0});if(0===n.code&&n.data.length>0)return[null,n.data];throw n}catch(t){return["catch error"]}}},64621:(t,e,a)=>{a.r(e),a.d(e,{useRateStore:()=>g});var i=a(74003),s=a(84522),n=a(10435);const c={HKD:{value:111.59},USD:{value:14.3349},EUR:{value:13.6957},GBP:{value:11.8167},JPY:{value:1968.7777},AUD:{value:21.4141}},h=i.sM?[{code:"HKD",name:"港元",flag:"https://static.wetab.link/hitab/currency/HKD.png"},{code:"USD",name:"美元",flag:"https://static.wetab.link/hitab/currency/USD.png"},{code:"EUR",name:"欧元",flag:"https://static.wetab.link/hitab/currency/EUR.png"},{code:"GBP",name:"英镑",flag:"https://static.wetab.link/hitab/currency/GBP.png"},{code:"JPY",name:"日元",flag:"https://static.wetab.link/hitab/currency/JPY.png"},{code:"AUD",name:"澳元",flag:"https://static.wetab.link/hitab/currency/AUD.png"}]:[{code:"HKD",name:"Hong Kong Dollar",flag:"https://static.wetab.link/hitab/currency/HKD.png"},{code:"USD",name:"United States Dollar",flag:"https://static.wetab.link/hitab/currency/USD.png"},{code:"EUR",name:"Euro",flag:"https://static.wetab.link/hitab/currency/EUR.png"},{code:"GBP",name:"British Pound Sterling",flag:"https://static.wetab.link/hitab/currency/GBP.png"},{code:"JPY",name:"Japanese Yen",flag:"https://static.wetab.link/hitab/currency/JPY.png"},{code:"AUD",name:"Australian Dollar",flag:"https://static.wetab.link/hitab/currency/AUD.png"}],o=i.sM?{code:"CNY",name:"人民币",flag:"https://static.wetab.link/hitab/currency/CNY.png",value:100}:{code:"CNY",name:"Chinese Yuan",flag:"https://static.wetab.link/hitab/currency/CNY.png",value:100};var r=a(48536),l=a(80661),d=a.n(l),m=a(94119),u=a(24581);const g=(0,n.Q_)(s.BU.exchangeRate,{syncStorage:{watch:["baseRate","homeStaticRates","homeRatesValues","homeRatesChartData"]},syncCloud:{watch:["baseRate","homeStaticRates"]},state:()=>({modalShow:!1,baseRate:o,flipping:!1,flipingTimer:null,dragId:"",homeStaticRates:h,homeRatesValues:c,homeRatesChartData:{}}),getters:{updateTime(){if(!this.homeRates[0].updateTime)return"";const t=d()(this.homeRates[0].updateTime);return i.sM?t.format("YYYY-MM-DD HH:mm"):t.format("ddd, MMM D, YYYY h:mm A")},homeRates(){const t=this.homeStaticRates;return t.length>6&&(t.length=6),t.map((t=>{var e,a;return{...t,value:null===(e=this.homeRatesValues[t.code])||void 0===e?void 0:e.value,updateTime:null===(a=this.homeRatesValues[t.code])||void 0===a?void 0:a.updateTime,homeChart:this.homeRatesChartData[t.code]}}))}},actions:{setModal(t){m.G.setStatus(u.R.exchangeRate,t),this.modalShow=t},async setHomeRates(t,e){this.homeStaticRates=t.map((t=>({code:t.code,flag:t.flag,name:t.name}))),e&&await this.reqHomeRate()},async addHomeRate(t){const e={code:t.code,name:t.name,flag:t.flag};this.homeStaticRates=[...this.homeStaticRates,e],await this.reqHomeRate()},async setBase(t){this.baseRate={code:t.code,name:t.name,flag:t.flag,value:100},await this.reqHomeRate()},async updateHomeRateDetail(t){await this.reqLastFiveDaysList(t)},setDragId(t){this.dragId=t},async reqHomeRate(){const t=this.baseRate.code,e=this.homeStaticRates.map((t=>t.code)),[a,i]=await(0,r.f)(t,e.toString());if(a||!i)return;const s={};e.forEach(((t,e)=>{const a=i[e];s[t]={value:Number((Number(a.value)*this.baseRate.value).toFixed(4)),updateTime:a.updateTime}})),this.homeRatesValues=s},async reqLastFiveDaysList(t){const e=this.baseRate.code,[a,i]=await(0,r.S)(t,e,5);if(a||!i)return;const s=Object.assign({},this.homeRatesChartData);s[t]={list:i,updateTime:(new Date).valueOf()},this.homeRatesChartData=s},dragSort(t,e){if(t===e)return;const a=[...this.homeStaticRates],i=a.findIndex((t=>e===t.code)),s=a.findIndex((e=>t===e.code));-1!==i&&-1!==s&&(i>s?(a.splice(i+1,0,a[s]),a.splice(s,1)):(a.splice(i,0,a[s]),a.splice(s+1,1)),this.homeStaticRates=a,this.setFlipping(!0))},setFlipping(t){window.clearTimeout(this.flipingTimer),t&&(this.flipping=t,this.flipingTimer=window.setTimeout((()=>{this.flipping=!1}),200))}}})}}]);