19 lines
296 KiB
JavaScript
Raw Normal View History

2024-11-03 18:35:21 +08:00
import{_ as pt,D as At,W as Ye,G as Lt,m as ut,f as $t,o as S,c as C,a as h,b as y,w as nt,k as K,p as rt,F as ct,r as Ot,t as F,j as T,h as gt,e as V,I as Oa,J as Aa,B as gs,E as Ss,d as st,n as it,g as j,q as U,K as ro,L as lo,M as Js,N as La,A as fi,O as Ta,P as Ks,Q as Ra,R as co,U as Ia,l as ho,T as gi,v as be,C as Xs,V as Gs,s as uo,X as Ms,u as Ea,H as Fa}from"./index.js";import{L as O}from"./localeText.js";import{d as Ut}from"./dayjs.min.js";import{b as Ba}from"./browser.js";import za from"./peerCreate.js";import{V as fo}from"./vue-datepicker.js";import"./wireguard.js";const Na={name:"peerSearch",components:{LocaleText:O},setup(){const s=At(),t=Ye();return{store:s,wireguardConfigurationStore:t}},props:{configuration:Object},data(){return{sort:{status:Lt("Status"),name:Lt("Name"),allowed_ip:Lt("Allowed IPs"),restricted:Lt("Restricted")},interval:{5e3:Lt("5 Seconds"),1e4:Lt("10 Seconds"),3e4:Lt("30 Seconds"),6e4:Lt("1 Minutes")},searchString:"",searchStringTimeout:void 0,showDisplaySettings:!1,showMoreSettings:!1}},methods:{debounce(){this.searchStringTimeout?(clearTimeout(this.searchStringTimeout),this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)):this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)},updateSort(s){ut("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_sort",value:s},t=>{t.status&&this.store.getConfiguration()})},updateRefreshInterval(s){ut("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_refresh_interval",value:s},t=>{t.status&&this.store.getConfiguration()})},downloadAllPeer(){$t(`/api/downloadAllPeers/${this.configuration.Name}`,{},s=>{console.log(s),window.wireguard.generateZipFiles(s,this.configuration.Name)})}},computed:{searchBarPlaceholder(){return Lt("Search Peers...")}}},Va={class:"mb-3"},ja={class:"d-flex gap-2 z-3 peerSearchContainer"},Wa={class:"mt-3 mt-md-0 flex-grow-1"},Ha=["placeholder"],Ua={key:0,class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll displayModal"},Ya={class:"container-md d-flex h-100 w-100"},Ja={class:"m-auto modal-dialog-centered dashboardModal"},Ka={class:"card rounded-3 shadow w-100"},Xa={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},Ga={class:"mb-0 fw-normal"},qa={class:"card-body px-4 pb-4 d-flex gap-3 flex-column"},Qa={class:"text-muted fw-bold mb-2"},Za={class:"list-group"},tr=["onClick"],er={class:"me-auto"},sr={key:0,class:"bi bi-check text-primary"},ir={class:"text-muted fw-bold mb-2"},nr={class:"list-group"},or=["onClick"],ar={class:"me-auto"},rr={key:0,class:"bi bi-check text-primary"},lr={key:0,class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll displayModal"},cr={class:"container-md d-flex h-100 w-100"},dr={class:"m-auto modal-dialog-centered dashboardModal"},hr={class:"card rounded-3 shadow w-100"},ur={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},fr={class:"mb-0"},gr={class:"card-body px-4 pb-4 d-flex gap-3 flex-column pt-0"},pr={class:"text-muted fw-bold mb-2"},mr={class:"list-group"},br={class:"text-muted fw-bold mb-2"},_r={class:"list-group"};function xr(s,t,e,i,n,o){const a=V("LocaleText"),r=V("RouterLink");return S(),C("div",Va,[h("div",ja,[y(r,{to:"create",class:"text-decoration-none btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle shadow-sm"},{default:nt(()=>[t[13]||(t[13]=h("i",{class:"bi bi-plus-lg me-2"},null,-1)),y(a,{t:"Peer"})]),_:1}),h("button",{class:"btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle shadow-sm",onClick:t[0]||(t[0]=l=>this.downloadAllPeer())},[t[14]||(t[14]=h("i",{class:"bi bi-download me-2"},null,-1)),y(a,{t:"Download All"})]),h("div",Wa,[K(h("input",{class:"form-control rounded-3 bg-secondary-subtle border-1 border-secondary-subtle shadow-sm w-100",placeholder:o.searchBarPlaceholder,id:"searchPeers",onKeyup:t[1]||(t[1]=l=>this.debounce()),
* @kurkle/color v0.3.2
* https://github.com/kurkle/color#readme
* (c) 2023 Jukka Kurkela
* Released under the MIT License
*/function Je(s){return s+.5|0}const jt=(s,t,e)=>Math.max(Math.min(s,e),t);function Ae(s){return jt(Je(s*2.55),0,255)}function Yt(s){return jt(Je(s*255),0,255)}function Et(s){return jt(Je(s/2.55)/100,0,1)}function Ti(s){return jt(Je(s*100),0,100)}const vt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},qs=[..."0123456789ABCDEF"],ol=s=>qs[s&15],al=s=>qs[(s&240)>>4]+qs[s&15],qe=s=>(s&240)>>4===(s&15),rl=s=>qe(s.r)&&qe(s.g)&&qe(s.b)&&qe(s.a);function ll(s){var t=s.length,e;return s[0]==="#"&&(t===4||t===5?e={r:255&vt[s[1]]*17,g:255&vt[s[2]]*17,b:255&vt[s[3]]*17,a:t===5?vt[s[4]]*17:255}:(t===7||t===9)&&(e={r:vt[s[1]]<<4|vt[s[2]],g:vt[s[3]]<<4|vt[s[4]],b:vt[s[5]]<<4|vt[s[6]],a:t===9?vt[s[7]]<<4|vt[s[8]]:255})),e}const cl=(s,t)=>s<255?t(s):"";function dl(s){var t=rl(s)?ol:al;return s?"#"+t(s.r)+t(s.g)+t(s.b)+cl(s.a,t):void 0}const hl=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function bo(s,t,e){const i=t*Math.min(e,1-e),n=(o,a=(o+s/30)%12)=>e-i*Math.max(Math.min(a-3,9-a,1),-1);return[n(0),n(8),n(4)]}function ul(s,t,e){const i=(n,o=(n+s/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function fl(s,t,e){const i=bo(s,1,.5);let n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)i[n]*=1-t-e,i[n]+=t;return i}function gl(s,t,e,i,n){return s===n?(t-e)/i+(t<e?6:0):t===n?(e-s)/i+2:(s-t)/i+4}function pi(s){const e=s.r/255,i=s.g/255,n=s.b/255,o=Math.max(e,i,n),a=Math.min(e,i,n),r=(o+a)/2;let l,c,d;return o!==a&&(d=o-a,c=r>.5?d/(2-o-a):d/(o+a),l=gl(e,i,n,d,o),l=l*60+.5),[l|0,c||0,r]}function mi(s,t,e,i){return(Array.isArray(t)?s(t[0],t[1],t[2]):s(t,e,i)).map(Yt)}function bi(s,t,e){return mi(bo,s,t,e)}function pl(s,t,e){return mi(fl,s,t,e)}function ml(s,t,e){return mi(ul,s,t,e)}function _o(s){return(s%360+360)%360}function bl(s){const t=hl.exec(s);let e=255,i;if(!t)return;t[5]!==i&&(e=t[6]?Ae(+t[5]):Yt(+t[5]));const n=_o(+t[2]),o=+t[3]/100,a=+t[4]/100;return t[1]==="hwb"?i=pl(n,o,a):t[1]==="hsv"?i=ml(n,o,a):i=bi(n,o,a),{r:i[0],g:i[1],b:i[2],a:e}}function _l(s,t){var e=pi(s);e[0]=_o(e[0]+t),e=bi(e),s.r=e[0],s.g=e[1],s.b=e[2]}function xl(s){if(!s)return;const t=pi(s),e=t[0],i=Ti(t[1]),n=Ti(t[2]);return s.a<255?`hsla(${e}, ${i}%, ${n}%, ${Et(s.a)})`:`hsl(${e}, ${i}%, ${n}%)`}const Ri={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Ii={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"
* Chart.js v4.4.4
* https://www.chartjs.org
* (c) 2024 Chart.js Contributors
* Released under the MIT License
*/function Tt(){}const Cl=(()=>{let s=0;return()=>s++})();function N(s){return s===null||typeof s>"u"}function q(s){if(Array.isArray&&Array.isArray(s))return!0;const t=Object.prototype.toString.call(s);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function B(s){return s!==null&&Object.prototype.toString.call(s)==="[object Object]"}function Q(s){return(typeof s=="number"||s instanceof Number)&&isFinite(+s)}function _t(s,t){return Q(s)?s:t}function I(s,t){return typeof s>"u"?t:s}const Dl=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100:+s/t,yo=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100*t:+s;function Y(s,t,e){if(s&&typeof s.call=="function")return s.apply(e,t)}function W(s,t,e,i){let n,o,a;if(q(s))for(o=s.length,n=0;n<o;n++)t.call(e,s[n],n);else if(B(s))for(a=Object.keys(s),o=a.length,n=0;n<o;n++)t.call(e,s[a[n]],a[n])}function ps(s,t){let e,i,n,o;if(!s||!t||s.length!==t.length)return!1;for(e=0,i=s.length;e<i;++e)if(n=s[e],o=t[e],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function ms(s){if(q(s))return s.map(ms);if(B(s)){const t=Object.create(null),e=Object.keys(s),i=e.length;let n=0;for(;n<i;++n)t[e[n]]=ms(s[e[n]]);return t}return s}function vo(s){return["__proto__","prototype","constructor"].indexOf(s)===-1}function $l(s,t,e,i){if(!vo(s))return;const n=t[s],o=e[s];B(n)&&B(o)?Ne(n,o,i):t[s]=ms(o)}function Ne(s,t,e){const i=q(t)?t:[t],n=i.length;if(!B(s))return s;e=e||{};const o=e.merger||$l;let a;for(let r=0;r<n;++r){if(a=i[r],!B(a))continue;const l=Object.keys(a);for(let c=0,d=l.length;c<d;++c)o(l[c],s,a,e)}return s}function Ie(s,t){return Ne(s,t,{merger:Ol})}function Ol(s,t,e){if(!vo(s))return;const i=t[s],n=e[s];B(i)&&B(n)?Ie(i,n):Object.prototype.hasOwnProperty.call(t,s)||(t[s]=ms(n))}const Fi={"":s=>s,x:s=>s.x,y:s=>s.y};function Al(s){const t=s.split("."),e=[];let i="";for(const n of t)i+=n,i.endsWith("\\")?i=i.slice(0,-1)+".":(e.push(i),i="");return e}function Ll(s){const t=Al(s);return e=>{for(const i of t){if(i==="")break;e=e&&e[i]}return e}}function Jt(s,t){return(Fi[t]||(Fi[t]=Ll(t)))(s)}function _i(s){return s.charAt(0).toUpperCase()+s.slice(1)}const Ve=s=>typeof s<"u",Kt=s=>typeof s=="function",Bi=(s,t)=>{if(s.size!==t.size)return!1;for(const e of s)if(!t.has(e))return!1;return!0};function Tl(s){return s.type==="mouseup"||s.type==="click"||s.type==="contextmenu"}const G=Math.PI,X=2*G,Rl=X+G,bs=Number.POSITIVE_INFINITY,Il=G/180,et=G/2,te=G/4,zi=G*2/3,Wt=Math.log10,Dt=Math.sign;function Ee(s,t,e){return Math.abs(s-t)<e}function Ni(s){const t=Math.round(s);s=Ee(s,t,s/1e3)?t:s;const e=Math.pow(10,Math.floor(Wt(s))),i=s/e;return(i<=1?1:i<=2?2:i<=5?5:10)*e}function El(s){const t=[],e=Math.sqrt(s);let i;for(i=1;i<e;i++)s%i===0&&(t.push(i),t.push(s/i));return e===(e|0)&&t.push(e),t.sort((n,o)=>n-o).pop(),t}function xe(s){return!isNaN(parseFloat(s))&&isFinite(s)}function Fl(s,t){const e=Math.round(s);return e-t<=s&&e+t>=s}function wo(s,t,e){let i,n,o;for(i=0,n=s.length;i<n;i++)o=s[i][e],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function St(s){return s*(G/180)}function xi(s){return s*(180/G)}function Vi(s){if(!Q(s))return;let t=1,e=0;for(;Math.round(s*t)/t!==s;)t*=10,e++;return e}function ko(s,t){const e=t.x-s.x,i=t.y-s.y,n=Math.sqrt(e*e+i*i);let o=Math.atan2(i,e);return o<-.5*G&&(o+=X),{angle:o,distance:n}}function Qs(s,t){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Bl(s,t){return(s-t+Rl)%X-G}function xt(s){return(s%X+X)%X}function je(s,t,e,i){const n=xt(s),o=xt(t),a=xt(e),r=xt(o-n),l=xt(a-n),c=xt(n-o),d=xt(n-a);return n===o||n===a||i&&o===a||r>l&&c<d}function lt(s,t,e){return Math.max(t,Math.min(e,s))}function zl(s){return lt(s,-32768,32767)}function Ft(s,t,e,i=1e-6){return s>=Math.min(t,e)-i&&s<=Math.max(t,e)+i}function yi(s,t,e){e=e||(a=>s[a]<t);let i=s.length-1,n=0,o;for(;i-n>1;)o=n+i>>1,e(o)?n=o:i=o;return{lo:n,hi:i}}const Bt=(s,t,e,i)=>yi(s,e,i?n=>{const o=s[n][t];return o<e||o===e&&s[n+1][t]===e}:n=>s[n][t]<e),Nl=(s,t,e)=>yi(s,e,i=>s[i][t]>=e);function Vl(s,t,e){let i=0,n=s.length;for(;i<n&&s[i]<t;)i++;for(
* Chart.js v4.4.4
* https://www.chartjs.org
* (c) 2024 Chart.js Contributors
* Released under the MIT License
*/class Hc{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,n){const o=e.listeners[n],a=e.duration;o.forEach(r=>r({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(i-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=Po.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,n)=>{if(!i.running||!i.items.length)return;const o=i.items;let a=o.length-1,r=!1,l;for(;a>=0;--a)l=o[a],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),r=!0):(o[a]=o[o.length-1],o.pop());r&&(n.draw(),this._notify(n,i,t,"progress")),o.length||(i.running=!1,this._notify(n,i,t,"complete"),i.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((i,n)=>Math.max(i,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let n=i.length-1;for(;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Rt=new Hc;const en="transparent",Uc={boolean(s,t,e){return e>.5?t:s},color(s,t,e){const i=Ui(s||en),n=i.valid&&Ui(t||en);return n&&n.valid?n.mix(i,e).hexString():t},number(s,t,e){return s+(t-s)*e}};class Yc{constructor(t,e,i,n){const o=e[i];n=Le([t.to,n,o,t.from]);const a=Le([t.from,o,n]);this._active=!0,this._fn=t.fn||Uc[t.type||typeof a],this._easing=Fe[t.easing]||Fe.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=a,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const n=this._target[this._prop],o=i-this._start,a=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Le([t.to,e,n,t.from]),this._from=Le([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,n=this._prop,o=this._from,a=this._loop,r=this._to;let l;if(this._active=o!==r&&(a||e<i),!this._active){this._target[n]=r,this._notify(!0);return}if(e<0){this._target[n]=o;return}l=e/i%2,l=a&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[n]=this._fn(o,r,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let n=0;n<i.length;n++)i[n][e]()}}class Ho{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!B(t))return;const e=Object.keys(Z.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach(n=>{const o=t[n];if(!B(o))return;const a={};for(const r of e)a[r]=o[r];(q(o.properties)&&o.properties||[n]).forEach(r=>{(r===n||!i.has(r))&&i.set(r,a)})})}_animateOptions(t,e){const i=e.options,n=Kc(t,i);if(!n)return[];const o=this._createAnimations(n,i);return i.$shared&&Jc(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),r=Date.now();let l;for(l=a.length-1;l>=0;--l){const c=a[l];if(c.charAt(0)==="$")continue;if(c==="options"){n.push(...this._animateOptions(t,e));continue}const d=e[c];let u=o[c];const f=i.get(c);if(u)if(f&&u.active()){u.update(f,d,r);continue}else u.cancel();if(!f||!f.duration){t[c]=d;continue}o[c]=u=new Yc(f,t,c,d),n.push(u)}return n}update(t,e){if(this._properties.size===0
`)>-1?s.split(`
`):s}function Ou(s,t){const{element:e,datasetIndex:i,index:n}=t,o=s.getDatasetMeta(i).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:s,label:a,parsed:o.getParsed(n),raw:s.data.datasets[i].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:i,element:e}}function Nn(s,t){const e=s.chart.ctx,{body:i,footer:n,title:o}=s,{boxWidth:a,boxHeight:r}=t,l=ot(t.bodyFont),c=ot(t.titleFont),d=ot(t.footerFont),u=o.length,f=n.length,g=i.length,p=ft(t.padding);let m=p.height,b=0,_=i.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(_+=s.beforeBody.length+s.afterBody.length,u&&(m+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),_){const v=t.displayColors?Math.max(r,l.lineHeight):l.lineHeight;m+=g*v+(_-g)*l.lineHeight+(_-1)*t.bodySpacing}f&&(m+=t.footerMarginTop+f*d.lineHeight+(f-1)*t.footerSpacing);let w=0;const k=function(v){b=Math.max(b,e.measureText(v).width+w)};return e.save(),e.font=c.string,W(s.title,k),e.font=l.string,W(s.beforeBody.concat(s.afterBody),k),w=t.displayColors?a+2+t.boxPadding:0,W(i,v=>{W(v.before,k),W(v.lines,k),W(v.after,k)}),w=0,e.font=d.string,W(s.footer,k),e.restore(),b+=p.width,{width:b,height:m}}function Au(s,t){const{y:e,height:i}=t;return e<i/2?"top":e>s.height-i/2?"bottom":"center"}function Lu(s,t,e,i){const{x:n,width:o}=i,a=e.caretSize+e.caretPadding;if(s==="left"&&n+o+a>t.width||s==="right"&&n-o-a<0)return!0}function Tu(s,t,e,i){const{x:n,width:o}=e,{width:a,chartArea:{left:r,right:l}}=s;let c="center";return i==="center"?c=n<=(r+l)/2?"left":"right":n<=o/2?c="left":n>=a-o/2&&(c="right"),Lu(c,s,t,e)&&(c="center"),c}function Vn(s,t,e){const i=e.yAlign||t.yAlign||Au(s,e);return{xAlign:e.xAlign||t.xAlign||Tu(s,t,e,i),yAlign:i}}function Ru(s,t){let{x:e,width:i}=s;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function Iu(s,t,e){let{y:i,height:n}=s;return t==="top"?i+=e:t==="bottom"?i-=n+e:i-=n/2,i}function jn(s,t,e,i){const{caretSize:n,caretPadding:o,cornerRadius:a}=s,{xAlign:r,yAlign:l}=e,c=n+o,{topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=re(a);let p=Ru(t,r);const m=Iu(t,l,c);return l==="center"?r==="left"?p+=c:r==="right"&&(p-=c):r==="left"?p-=Math.max(d,f)+n:r==="right"&&(p+=Math.max(u,g)+n),{x:lt(p,0,i.width-t.width),y:lt(m,0,i.height-t.height)}}function ls(s,t,e){const i=ft(e.padding);return t==="center"?s.x+s.width/2:t==="right"?s.x+s.width-i.right:s.x+i.left}function Wn(s){return Mt([],It(s))}function Eu(s,t,e){return Xt(s,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Hn(s,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?s.override(e):s}const fa={beforeTitle:Tt,title(s){if(s.length>0){const t=s[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex<i)return e[t.dataIndex]}return""},afterTitle:Tt,beforeBody:Tt,beforeLabel:Tt,label(s){if(this&&this.options&&this.options.mode==="dataset")return s.label+": "+s.formattedValue||s.formattedValue;let t=s.dataset.label||"";t&&(t+=": ");const e=s.formattedValue;return N(e)||(t+=e),t},labelColor(s){const e=s.chart.getDatasetMeta(s.datasetIndex).controller.getStyle(s.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(s){const e=s.chart.getDatasetMeta(s.datasetIndex).controller.getStyle(s.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:Tt,afterBody:Tt,beforeFooter:Tt,footer:Tt,afterFooter:Tt};function mt(s,t,e,i){const n=s[t].call(e,i);return typeof n>"u"?fa[t].call(e,i):n}class Un extends Vt{static positioners=Re;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.a