unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
1 lines • 32.7 kB
JavaScript
import{B as e,C as t,D as n,E as r,F as i,G as a,H as o,I as s,M as c,O as l,P as u,S as d,T as f,U as p,V as m,W as h,b as g,j as _,k as v,o as y,s as b,t as ee,v as x,w as te,x as ne,y as S,z as re}from"./chart-BMc0j_v5.js";import"./helpers-Dz6x6iMP.js";var ie={modes:{point(e,t){return w(e,t,{intersect:!0})},nearest(e,t,n){return se(e,t,n)},x(e,t,n){return w(e,t,{intersect:n.intersect,axis:`x`})},y(e,t,n){return w(e,t,{intersect:n.intersect,axis:`y`})}}};function C(e,t,n){return(ie.modes[n.mode]||ie.modes.nearest)(e,t,n)}function ae(e,t,n){return n!==`x`&&n!==`y`?e.inRange(t.x,t.y,`x`,!0)||e.inRange(t.x,t.y,`y`,!0):e.inRange(t.x,t.y,n,!0)}function oe(e,t,n){return n===`x`?{x:e.x,y:t.y}:n===`y`?{x:t.x,y:e.y}:t}function w(e,t,n){return e.visibleElements.filter(e=>n.intersect?e.inRange(t.x,t.y):ae(e,t,n.axis))}function se(e,t,n){let r=1/0;return w(e,t,n).reduce((e,i)=>{let a=v(t,oe(t,i.getCenterPoint(),n.axis));return a<r?(e=[i],r=a):a===r&&e.push(i),e},[]).sort((e,t)=>e._index-t._index).slice(0,1)}var ce=(e,t)=>t>e||e.length>t.length&&e.slice(0,t.length)===t,T=.001,E=(e,t,n)=>Math.min(n,Math.max(t,e));function le(e,t,n){for(let r of Object.keys(e))e[r]=E(e[r],t,n);return e}function ue(e,t,n,r){if(!e||!t||n<=0)return!1;let i=r/2;return(e.x-t.x)**2+(e.y-t.y)**2<=(n+i)**2}function de(e,{x:t,y:n,x2:r,y2:i},a,o){let s=o/2,c=e.x>=t-s-T&&e.x<=r+s+T,l=e.y>=n-s-T&&e.y<=i+s+T;return a===`x`?c:(a===`y`||c)&&l}function D(e,t){let{centerX:n,centerY:r}=e.getProps([`centerX`,`centerY`],t);return{x:n,y:r}}function fe(e,t,n,r=!0){let i=n.split(`.`),a=0;for(let o of t.split(`.`)){let s=i[a++];if(parseInt(o,10)<parseInt(s,10))break;if(ce(s,o)){if(r)throw Error(`${e} v${n} is not supported. v${t} or newer is required.`);return!1}}return!0}var pe=e=>typeof e==`string`&&e.endsWith(`%`),me=e=>parseFloat(e)/100,he=e=>E(me(e),0,1);function ge(e,t){return t===`start`?0:t===`end`?e:pe(t)?he(t)*e:e/2}function O(e,t,n=!0){return typeof t==`number`?t:pe(t)?(n?he(t):me(t))*e:e}function _e(e,t){let{x:n,width:r}=e,i=t.textAlign;return i===`center`?n+r/2:i===`end`||i===`right`?n+r:n}function ve(e,t=`center`){return s(e)?{x:a(e.x,t),y:a(e.y,t)}:(e=a(e,t),{x:e,y:e})}function ye(e){return e&&(l(e.xValue)||l(e.yValue))}function k(e,t,n,r=!1){let i=n.init;if(i)return i===!0?xe(t,r):Se(t,r,f(i,[{chart:e,properties:t,options:n}]))}function be(e,t,n){let r=!1;return t.forEach(t=>{c(e[t])?(r=!0,n[t]=e[t]):l(n[t])&&delete n[t]}),r}function xe({centerX:e,centerY:t},n){return n?{centerX:e,centerY:t,radius:0,width:0,height:0}:{x:e,y:t,x2:e,y2:t,width:0,height:0}}function Se(e,t,n){if(n===!0)return xe(e,t);if(s(n))return n}var A=new Map,Ce=e=>isNaN(e)||e<=0,we=e=>e.reduce(function(e,t){return e+=t.string,e},``);function j(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object HTMLImageElement]`||t===`[object HTMLCanvasElement]`}}function M(e,{x:t,y:n},r){r&&(e.translate(t,n),e.rotate(o(r)),e.translate(-t,-n))}function N(e,t){if(t&&t.borderWidth)return e.lineCap=t.borderCapStyle,e.setLineDash(t.borderDash),e.lineDashOffset=t.borderDashOffset,e.lineJoin=t.borderJoinStyle,e.lineWidth=t.borderWidth,e.strokeStyle=t.borderColor,!0}function P(e,t){e.shadowColor=t.backgroundShadowColor,e.shadowBlur=t.shadowBlur,e.shadowOffsetX=t.shadowOffsetX,e.shadowOffsetY=t.shadowOffsetY}function F(t,n){let r=n.content;if(j(r))return{width:O(r.width,n.width),height:O(r.height,n.height)};let i=n.font,a=_(i)?i.map(t=>e(t)):[e(i)],o=n.textStrokeWidth,s=_(r)?r:[r],c=s.join()+we(a)+o+(t._measureText?`-spriting`:``);return A.has(c)||A.set(c,Ae(t,s,a,o)),A.get(c)}function Te(e,t,n){let{x:r,y:i,width:a,height:o}=t;e.save(),P(e,n);let s=N(e,n);e.fillStyle=n.backgroundColor,e.beginPath(),te(e,{x:r,y:i,w:a,h:o,radius:le(p(n.borderRadius),0,Math.min(a,o)/2)}),e.closePath(),e.fill(),s&&(e.shadowColor=n.borderShadowColor,e.stroke()),e.restore()}function Ee(t,n,r){let i=r.content;if(j(i)){t.save(),t.globalAlpha=Ne(r.opacity,i.style.opacity),t.drawImage(i,n.x,n.y,n.width,n.height),t.restore();return}let a=_(i)?i:[i],o=r.font,s=_(o)?o.map(t=>e(t)):[e(o)],c=r.color,l=_(c)?c:[c],u=_e(n,r),d=n.y+r.textStrokeWidth/2;t.save(),t.textBaseline=`middle`,t.textAlign=r.textAlign,De(t,r)&&je(t,{x:u,y:d},a,s),Me(t,{x:u,y:d},a,{fonts:s,colors:l}),t.restore()}function De(e,t){if(t.textStrokeWidth>0)return e.lineJoin=`round`,e.miterLimit=2,e.lineWidth=t.textStrokeWidth,e.strokeStyle=t.textStrokeColor,!0}function Oe(e,t,n,r){let{radius:i,options:a}=t,o=a.pointStyle,s=a.rotation,c=(s||0)*ne;if(j(o)){e.save(),e.translate(n,r),e.rotate(c),e.drawImage(o,-o.width/2,-o.height/2,o.width,o.height),e.restore();return}Ce(i)||ke(e,{x:n,y:r,radius:i,rotation:s,style:o,rad:c})}function ke(e,{x:n,y:r,radius:i,rotation:a,style:o,rad:s}){let c,l,u,f;switch(e.beginPath(),o){default:e.arc(n,r,i,0,d),e.closePath();break;case`triangle`:e.moveTo(n+Math.sin(s)*i,r-Math.cos(s)*i),s+=t,e.lineTo(n+Math.sin(s)*i,r-Math.cos(s)*i),s+=t,e.lineTo(n+Math.sin(s)*i,r-Math.cos(s)*i),e.closePath();break;case`rectRounded`:f=i*.516,u=i-f,c=Math.cos(s+g)*u,l=Math.sin(s+g)*u,e.arc(n-c,r-l,f,s-S,s-x),e.arc(n+l,r-c,f,s-x,s),e.arc(n+c,r+l,f,s,s+x),e.arc(n-l,r+c,f,s+x,s+S),e.closePath();break;case`rect`:if(!a){u=Math.SQRT1_2*i,e.rect(n-u,r-u,2*u,2*u);break}s+=g;case`rectRot`:c=Math.cos(s)*i,l=Math.sin(s)*i,e.moveTo(n-c,r-l),e.lineTo(n+l,r-c),e.lineTo(n+c,r+l),e.lineTo(n-l,r+c),e.closePath();break;case`crossRot`:s+=g;case`cross`:c=Math.cos(s)*i,l=Math.sin(s)*i,e.moveTo(n-c,r-l),e.lineTo(n+c,r+l),e.moveTo(n+l,r-c),e.lineTo(n-l,r+c);break;case`star`:c=Math.cos(s)*i,l=Math.sin(s)*i,e.moveTo(n-c,r-l),e.lineTo(n+c,r+l),e.moveTo(n+l,r-c),e.lineTo(n-l,r+c),s+=g,c=Math.cos(s)*i,l=Math.sin(s)*i,e.moveTo(n-c,r-l),e.lineTo(n+c,r+l),e.moveTo(n+l,r-c),e.lineTo(n-l,r+c);break;case`line`:c=Math.cos(s)*i,l=Math.sin(s)*i,e.moveTo(n-c,r-l),e.lineTo(n+c,r+l);break;case`dash`:e.moveTo(n,r),e.lineTo(n+Math.cos(s)*i,r+Math.sin(s)*i);break}e.fill()}function Ae(e,t,n,r){e.save();let i=t.length,a=0,o=r;for(let s=0;s<i;s++){let i=n[Math.min(s,n.length-1)];e.font=i.string;let c=t[s];a=Math.max(a,e.measureText(c).width+r),o+=i.lineHeight}return e.restore(),{width:a,height:o}}function je(e,{x:t,y:n},r,i){e.beginPath();let a=0;r.forEach(function(r,o){let s=i[Math.min(o,i.length-1)],c=s.lineHeight;e.font=s.string,e.strokeText(r,t,n+c/2+a),a+=c}),e.stroke()}function Me(e,{x:t,y:n},r,{fonts:i,colors:a}){let o=0;r.forEach(function(r,s){let c=a[Math.min(s,a.length-1)],l=i[Math.min(s,i.length-1)],u=l.lineHeight;e.beginPath(),e.font=l.string,e.fillStyle=c,e.fillText(r,t,n+u/2+o),o+=u,e.fill()})}function Ne(e,t){let n=u(e)?e:t;return u(n)?E(n,0,1):1}var Pe={xScaleID:{min:`xMin`,max:`xMax`,start:`left`,end:`right`,startProp:`x`,endProp:`x2`},yScaleID:{min:`yMin`,max:`yMax`,start:`bottom`,end:`top`,startProp:`y`,endProp:`y2`}};function I(e,t,n){return t=typeof t==`number`?t:e.parse(t),i(t)?e.getPixelForValue(t):n}function L(e,t,n){let r=t[n];if(r||n===`scaleID`)return r;let i=n.charAt(0),a=Object.values(e).filter(e=>e.axis&&e.axis===i);return a.length?a[0].id:i}function Fe(e,t){if(e){let n=e.options.reverse;return{start:I(e,t.min,n?t.end:t.start),end:I(e,t.max,n?t.start:t.end)}}}function Ie(e,t){let{chartArea:n,scales:r}=e,i=r[L(r,t,`xScaleID`)],a=r[L(r,t,`yScaleID`)],o=n.width/2,s=n.height/2;return i&&(o=I(i,t.xValue,i.left+i.width/2)),a&&(s=I(a,t.yValue,a.top+a.height/2)),{x:o,y:s}}function R(e,t){let n=e.scales,r=n[L(n,t,`xScaleID`)],i=n[L(n,t,`yScaleID`)];if(!r&&!i)return{};let{left:a,right:o}=r||e.chartArea,{top:s,bottom:c}=i||e.chartArea,l=Ve(r,{min:t.xMin,max:t.xMax,start:a,end:o});a=l.start,o=l.end;let u=Ve(i,{min:t.yMin,max:t.yMax,start:c,end:s});return s=u.start,c=u.end,{x:a,y:s,x2:o,y2:c,width:o-a,height:c-s,centerX:a+(o-a)/2,centerY:s+(c-s)/2}}function Le(e,t){if(!ye(t)){let n=R(e,t),r=t.radius;(!r||isNaN(r))&&(r=Math.min(n.width,n.height)/2,t.radius=r);let i=r*2,a=n.centerX+t.xAdjust,o=n.centerY+t.yAdjust;return{x:a-r,y:o-r,x2:a+r,y2:o+r,centerX:a,centerY:o,width:i,height:i,radius:r}}return Be(e,t)}function Re(e,t){let{scales:n,chartArea:r}=e,i=n[t.scaleID],a={x:r.left,y:r.top,x2:r.right,y2:r.bottom};return i?He(i,a,t):Ue(n,a,t),a}function ze(e,t,n){let r=R(e,t);return r.initProperties=k(e,r,t,n),r.elements=[{type:`label`,optionScope:`label`,properties:qe(e,r,t),initProperties:r.initProperties}],r}function Be(e,t){let n=Ie(e,t),r=t.radius*2;return{x:n.x-t.radius+t.xAdjust,y:n.y-t.radius+t.yAdjust,x2:n.x+t.radius+t.xAdjust,y2:n.y+t.radius+t.yAdjust,centerX:n.x+t.xAdjust,centerY:n.y+t.yAdjust,radius:t.radius,width:r,height:r}}function Ve(e,t){let n=Fe(e,t)||t;return{start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)}}function He(e,t,n){let r=I(e,n.value,NaN),i=I(e,n.endValue,r);e.isHorizontal()?(t.x=r,t.x2=i):(t.y=r,t.y2=i)}function Ue(e,t,n){for(let r of Object.keys(Pe)){let i=e[L(e,n,r)];if(i){let{min:e,max:a,start:o,end:s,startProp:c,endProp:l}=Pe[r],u=Fe(i,{min:n[e],max:n[a],start:i[o],end:i[s]});t[c]=u.start,t[l]=u.end}}}function We({properties:e,options:t},n,r,i){let{x:a,x2:o,width:s}=e;return Ke({start:a,end:o,size:s,borderWidth:t.borderWidth},{position:r.x,padding:{start:i.left,end:i.right},adjust:t.label.xAdjust,size:n.width})}function Ge({properties:e,options:t},n,r,i){let{y:a,y2:o,height:s}=e;return Ke({start:a,end:o,size:s,borderWidth:t.borderWidth},{position:r.y,padding:{start:i.top,end:i.bottom},adjust:t.label.yAdjust,size:n.height})}function Ke(e,t){let{start:n,end:r,borderWidth:i}=e,{position:a,padding:{start:o,end:s},adjust:c}=t,l=r-i-n-o-s-t.size;return n+i/2+c+ge(l,a)}function qe(e,t,n){let r=n.label;r.backgroundColor=`transparent`,r.callout.display=!1;let i=ve(r.position),a=m(r.padding),o=F(e.ctx,r),s=We({properties:t,options:n},o,i,a),c=Ge({properties:t,options:n},o,i,a),l=o.width+a.width,u=o.height+a.height;return{x:s,y:c,x2:s+l,y2:c+u,width:l,height:u,centerX:s+l/2,centerY:c+u/2,rotation:r.rotation}}function z(e,t,n){let r=Math.cos(n),i=Math.sin(n),a=t.x,o=t.y;return{x:a+r*(e.x-a)-i*(e.y-o),y:o+i*(e.x-a)+r*(e.y-o)}}var B=[`enter`,`leave`],V=B.concat(`click`);function Je(e,t,n){t.listened=be(n,V,t.listeners),t.moveListened=!1,t._getElements=C,B.forEach(e=>{c(n[e])&&(t.moveListened=!0)}),(!t.listened||!t.moveListened)&&t.annotations.forEach(e=>{!t.listened&&c(e.click)&&(t.listened=!0),t.moveListened||B.forEach(n=>{c(e[n])&&(t.listened=!0,t.moveListened=!0)})})}function Ye(e,t,n){if(e.listened)switch(t.type){case`mousemove`:case`mouseout`:return Xe(e,t,n);case`click`:return Qe(e,t,n)}}function Xe(e,t,n){if(!e.moveListened)return;let r;r=t.type===`mousemove`?C(e,t,n.interaction):[];let i=e.hovered;e.hovered=r;let a={state:e,event:t},o=Ze(a,`leave`,i,r);return Ze(a,`enter`,r,i)||o}function Ze({state:e,event:t},n,r,i){let a;for(let o of r)i.indexOf(o)<0&&(a=$e(o.options[n]||e.listeners[n],o,t)||a);return a}function Qe(e,t,n){let r=e.listeners,i=C(e,t,n.interaction),a;for(let e of i)a=$e(e.options.click||r.click,e,t)||a;return a}function $e(e,t,n){return f(e,[t.$context,n])===!0}var H=[`afterDraw`,`beforeDraw`];function et(e,t,n){let r=t.visibleElements;t.hooked=be(n,H,t.hooks),t.hooked||r.forEach(e=>{t.hooked||H.forEach(n=>{c(e.options[n])&&(t.hooked=!0)})})}function tt(e,t,n){if(e.hooked)return f(t.options[n]||e.hooks[n],[t.$context])}function nt(e,t,n){let r=ct(e.scales,t,n),i=it(t,r,`min`,`suggestedMin`);i=it(t,r,`max`,`suggestedMax`)||i,i&&c(t.handleTickRangeOptions)&&t.handleTickRangeOptions()}function rt(e,t){for(let n of e)ot(n,t)}function it(e,t,n,r){if(i(t[n])&&!at(e.options,n,r)){let r=e[n]!==t[n];return e[n]=t[n],r}}function at(e,t,n){return l(e[t])||l(e[n])}function ot(e,t){for(let n of[`scaleID`,`xScaleID`,`yScaleID`]){let r=L(t,e,n);r&&!t[r]&&st(e,n)&&console.warn(`No scale found with id '${r}' for annotation '${e.id}'`)}}function st(e,t){if(t===`scaleID`)return!0;let n=t.charAt(0);for(let t of[`Min`,`Max`,`Value`])if(l(e[n+t]))return!0;return!1}function ct(e,t,n){let r=t.axis,i=t.id,o=r+`ScaleID`,s={min:a(t.min,-1/0),max:a(t.max,1/0)};for(let a of n)a.scaleID===i?lt(a,t,[`value`,`endValue`],s):L(e,a,o)===i&<(a,t,[r+`Min`,r+`Max`,r+`Value`],s);return s}function lt(e,t,n,r){for(let i of n){let n=e[i];if(l(n)){let e=t.parse(n);r.min=Math.min(r.min,e),r.max=Math.max(r.max,e)}}}var U=class extends b{inRange(e,t,n,r){let{x:i,y:a}=z({x:e,y:t},this.getCenterPoint(r),o(-this.options.rotation));return de({x:i,y:a},this.getProps([`x`,`y`,`x2`,`y2`],r),n,this.options.borderWidth)}getCenterPoint(e){return D(this,e)}draw(e){e.save(),M(e,this.getCenterPoint(),this.options.rotation),Te(e,this,this.options),e.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(e,t){return ze(e,t)}};U.id=`boxAnnotation`,U.defaults={adjustScaleRange:!0,backgroundShadowColor:`transparent`,borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderRadius:0,borderShadowColor:`transparent`,borderWidth:1,display:!0,init:void 0,label:{backgroundColor:`transparent`,borderWidth:0,callout:{display:!1},color:`black`,content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:`bold`},height:void 0,opacity:void 0,padding:6,position:`center`,rotation:void 0,textAlign:`start`,textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},U.defaultRoutes={borderColor:`color`,backgroundColor:`color`},U.descriptors={label:{_fallback:!0}};var ut=[`left`,`bottom`,`top`,`right`],W=class extends b{inRange(e,t,n,r){let{x:i,y:a}=z({x:e,y:t},this.getCenterPoint(r),o(-this.rotation));return de({x:i,y:a},this.getProps([`x`,`y`,`x2`,`y2`],r),n,this.options.borderWidth)}getCenterPoint(e){return D(this,e)}draw(e){let t=this.options,n=!l(this._visible)||this._visible;!t.display||!t.content||!n||(e.save(),M(e,this.getCenterPoint(),this.rotation),pt(e,this),Te(e,this,t),Ee(e,bt(this),t),e.restore())}resolveElementProperties(e,t){let n;if(ye(t))n=Ie(e,t);else{let{centerX:r,centerY:i}=R(e,t);n={x:r,y:i}}let r=m(t.padding),i=F(e.ctx,t),a=dt(n,i,t,r);return{initProperties:k(e,a,t),pointX:n.x,pointY:n.y,...a,rotation:t.rotation}}};W.id=`labelAnnotation`,W.defaults={adjustScaleRange:!0,backgroundColor:`transparent`,backgroundShadowColor:`transparent`,borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderRadius:0,borderShadowColor:`transparent`,borderWidth:0,callout:{borderCapStyle:`butt`,borderColor:void 0,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:1,display:!1,margin:5,position:`auto`,side:5,start:`50%`},color:`black`,content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,init:void 0,opacity:void 0,padding:6,position:`center`,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:`center`,textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},W.defaultRoutes={borderColor:`color`};function dt(e,t,n,r){let i=t.width+r.width+n.borderWidth,a=t.height+r.height+n.borderWidth,o=ve(n.position,`center`),s=ft(e.x,i,n.xAdjust,o.x),c=ft(e.y,a,n.yAdjust,o.y);return{x:s,y:c,x2:s+i,y2:c+a,width:i,height:a,centerX:s+i/2,centerY:c+a/2}}function ft(e,t,n=0,r){return e-ge(t,r)+n}function pt(e,t){let{pointX:n,pointY:r,options:i}=t,a=i.callout,s=a&&a.display&&vt(t,a);if(!s||xt(t,a,s))return;if(e.save(),e.beginPath(),!N(e,a))return e.restore();let{separatorStart:c,separatorEnd:l}=mt(t,s),{sideStart:u,sideEnd:d}=gt(t,s,c);(a.margin>0||i.borderWidth===0)&&(e.moveTo(c.x,c.y),e.lineTo(l.x,l.y)),e.moveTo(u.x,u.y),e.lineTo(d.x,d.y);let f=z({x:n,y:r},t.getCenterPoint(),o(-t.rotation));e.lineTo(f.x,f.y),e.stroke(),e.restore()}function mt(e,t){let{x:n,y:r,x2:i,y2:a}=e,o=ht(e,t),s,c;return t===`left`||t===`right`?(s={x:n+o,y:r},c={x:s.x,y:a}):(s={x:n,y:r+o},c={x:i,y:s.y}),{separatorStart:s,separatorEnd:c}}function ht(e,t){let{width:n,height:r,options:i}=e,a=i.callout.margin+i.borderWidth/2;return t===`right`?n+a:t===`bottom`?r+a:-a}function gt(e,t,n){let{y:r,width:i,height:a,options:o}=e,s=o.callout.start,c=_t(t,o.callout),l,u;return t===`left`||t===`right`?(l={x:n.x,y:r+O(a,s)},u={x:l.x+c,y:l.y}):(l={x:n.x+O(i,s),y:n.y},u={x:l.x,y:l.y+c}),{sideStart:l,sideEnd:u}}function _t(e,t){let n=t.side;return e===`left`||e===`top`?-n:n}function vt(e,t){let n=t.position;return ut.includes(n)?n:yt(e,t)}function yt(e,t){let{x:n,y:r,x2:i,y2:a,width:s,height:c,pointX:l,pointY:u,centerX:d,centerY:f,rotation:p}=e,m={x:d,y:f},h=t.start,g=O(s,h),_=O(c,h),y=[n,n+g,n+g,i],b=[r+_,a,r,a],ee=[];for(let e=0;e<4;e++){let t=z({x:y[e],y:b[e]},m,o(p));ee.push({position:ut[e],distance:v(t,{x:l,y:u})})}return ee.sort((e,t)=>e.distance-t.distance)[0].position}function bt({x:e,y:t,width:n,height:r,options:i}){let a=i.borderWidth/2,o=m(i.padding);return{x:e+o.left+a,y:t+o.top+a,width:n-o.left-o.right-i.borderWidth,height:r-o.top-o.bottom-i.borderWidth}}function xt(e,t,n){let{pointX:r,pointY:i}=e,a=t.margin,o=r,s=i;return n===`left`?o+=a:n===`right`?o-=a:n===`top`?s+=a:n===`bottom`&&(s-=a),e.inRange(o,s)}var St=(e,t,n)=>({x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}),Ct=(e,t,n)=>St(t,n,Math.abs((e-t.y)/(n.y-t.y))).x,wt=(e,t,n)=>St(t,n,Math.abs((e-t.x)/(n.x-t.x))).y,G=e=>e*e,Tt=(e,t,{x:n,y:r,x2:i,y2:a},o)=>o===`y`?{start:Math.min(r,a),end:Math.max(r,a),value:t}:{start:Math.min(n,i),end:Math.max(n,i),value:e},Et=(e,t,n,r)=>(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n,Dt=(e,t,n,r)=>({x:Et(e.x,t.x,n.x,r),y:Et(e.y,t.y,n.y,r)}),Ot=(e,t,n,r)=>2*(1-r)*(t-e)+2*r*(n-t),kt=(e,t,n,r)=>-Math.atan2(Ot(e.x,t.x,n.x,r),Ot(e.y,t.y,n.y,r))+.5*S,K=class extends b{inRange(e,t,n,r){let i=this.options.borderWidth/2;if(n!==`x`&&n!==`y`){let n={mouseX:e,mouseY:t},{path:a,ctx:o}=this;if(a){N(o,this.options);let{chart:i}=this.$context,s=e*i.currentDevicePixelRatio,c=t*i.currentDevicePixelRatio,l=o.isPointInStroke(a,s,c)||It(this,n,r);return o.restore(),l}let s=G(i);return Ft(this,n,s,r)||It(this,n,r)}return jt(this,{mouseX:e,mouseY:t},n,{hBorderWidth:i,useFinalPosition:r})}getCenterPoint(e){return D(this,e)}draw(e){let{x:t,y:n,x2:r,y2:i,cp:a,options:o}=this;if(e.save(),!N(e,o))return e.restore();P(e,o);let s=Math.sqrt((r-t)**2+(i-n)**2);if(o.curve&&a)return Xt(e,this,a,s),e.restore();let{startOpts:c,endOpts:l,startAdjust:u,endAdjust:d}=Gt(this),f=Math.atan2(i-n,r-t);e.translate(t,n),e.rotate(f),e.beginPath(),e.moveTo(0+u,0),e.lineTo(s-d,0),e.shadowColor=o.borderShadowColor,e.stroke(),qt(e,0,u,c),qt(e,s,-d,l),e.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(e,t){let n=Re(e,t),{x:r,y:i,x2:a,y2:o}=n,s=Mt(n,e.chartArea),c=s?Pt({x:r,y:i},{x:a,y:o},e.chartArea):{x:r,y:i,x2:a,y2:o,width:Math.abs(a-r),height:Math.abs(o-i)};c.centerX=(a+r)/2,c.centerY=(o+i)/2,c.initProperties=k(e,c,t),t.curve&&(c.cp=Jt(c,t,v({x:c.x,y:c.y},{x:c.x2,y:c.y2})));let l=Lt(e,c,t.label);return l._visible=s,c.elements=[{type:`label`,optionScope:`label`,properties:l,initProperties:c.initProperties}],c}};K.id=`lineAnnotation`;var At={backgroundColor:void 0,backgroundShadowColor:void 0,borderColor:void 0,borderDash:void 0,borderDashOffset:void 0,borderShadowColor:void 0,borderWidth:void 0,display:void 0,fill:void 0,length:void 0,shadowBlur:void 0,shadowOffsetX:void 0,shadowOffsetY:void 0,width:void 0};K.defaults={adjustScaleRange:!0,arrowHeads:{display:!1,end:Object.assign({},At),fill:!1,length:12,start:Object.assign({},At),width:6},borderDash:[],borderDashOffset:0,borderShadowColor:`transparent`,borderWidth:2,curve:!1,controlPoint:{y:`-50%`},display:!0,endValue:void 0,init:void 0,label:{backgroundColor:`rgba(0,0,0,0.8)`,backgroundShadowColor:`transparent`,borderCapStyle:`butt`,borderColor:`black`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderRadius:6,borderShadowColor:`transparent`,borderWidth:0,callout:Object.assign({},W.defaults.callout),color:`#fff`,content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:`bold`},height:void 0,opacity:void 0,padding:6,position:`center`,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:`center`,textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},scaleID:void 0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,value:void 0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},K.descriptors={arrowHeads:{start:{_fallback:!0},end:{_fallback:!0},_fallback:!0}},K.defaultRoutes={borderColor:`color`};function jt(e,{mouseX:t,mouseY:n},r,{hBorderWidth:i,useFinalPosition:a}){let o=Tt(t,n,e.getProps([`x`,`y`,`x2`,`y2`],a),r);return o.value>=o.start-i&&o.value<=o.end+i||It(e,{mouseX:t,mouseY:n},a,r)}function Mt({x:e,y:t,x2:n,y2:r},{top:i,right:a,bottom:o,left:s}){return!(e<s&&n<s||e>a&&n>a||t<i&&r<i||t>o&&r>o)}function Nt({x:e,y:t},n,{top:r,right:i,bottom:a,left:o}){return e<o&&(t=wt(o,{x:e,y:t},n),e=o),e>i&&(t=wt(i,{x:e,y:t},n),e=i),t<r&&(e=Ct(r,{x:e,y:t},n),t=r),t>a&&(e=Ct(a,{x:e,y:t},n),t=a),{x:e,y:t}}function Pt(e,t,n){let{x:r,y:i}=Nt(e,t,n),{x:a,y:o}=Nt(t,e,n);return{x:r,y:i,x2:a,y2:o,width:Math.abs(a-r),height:Math.abs(o-i)}}function Ft(e,{mouseX:t,mouseY:n},r=T,i){let{x:a,y:o,x2:s,y2:c}=e.getProps([`x`,`y`,`x2`,`y2`],i),l=s-a,u=c-o,d=G(l)+G(u),f=d===0?-1:((t-a)*l+(n-o)*u)/d,p,m;return f<0?(p=a,m=o):f>1?(p=s,m=c):(p=a+f*l,m=o+f*u),G(t-p)+G(n-m)<=r}function It(e,{mouseX:t,mouseY:n},r,i){let a=e.label;return a.options.display&&a.inRange(t,n,i,r)}function Lt(e,t,n){let r=n.borderWidth,i=m(n.padding),a=F(e.ctx,n);return zt(t,n,{width:a.width+i.width+r,height:a.height+i.height+r,padding:i},e.chartArea)}function Rt(e){let{x:t,y:n,x2:r,y2:i}=e,a=Math.atan2(i-n,r-t);return a>S/2?a-S:a<S/-2?a+S:a}function zt(e,t,n,r){let{width:i,height:a,padding:s}=n,{xAdjust:c,yAdjust:l}=t,u={x:e.x,y:e.y},d={x:e.x2,y:e.y2},f=t.rotation===`auto`?Rt(e):o(t.rotation),p=Bt(i,a,f),m=Vt(e,t,{labelSize:p,padding:s},r),h=e.cp?Dt(u,e.cp,d,m):St(u,d,m),g={size:p.w,min:r.left,max:r.right,padding:s.left},_={size:p.h,min:r.top,max:r.bottom,padding:s.top},v=Wt(h.x,g)+c,y=Wt(h.y,_)+l;return{x:v-i/2,y:y-a/2,x2:v+i/2,y2:y+a/2,centerX:v,centerY:y,pointX:h.x,pointY:h.y,width:i,height:a,rotation:re(f)}}function Bt(e,t,n){let r=Math.cos(n),i=Math.sin(n);return{w:Math.abs(e*r)+Math.abs(t*i),h:Math.abs(e*i)+Math.abs(t*r)}}function Vt(e,t,n,r){let i,a=Ut(e,r);return i=t.position===`start`?Ht({w:e.x2-e.x,h:e.y2-e.y},n,t,a):t.position===`end`?1-Ht({w:e.x-e.x2,h:e.y-e.y2},n,t,a):ge(1,t.position),i}function Ht(e,t,n,r){let{labelSize:i,padding:a}=t,o=e.w*r.dx,s=e.h*r.dy,c=o>0&&(i.w/2+a.left-r.x)/o,l=s>0&&(i.h/2+a.top-r.y)/s;return E(Math.max(c,l),0,.25)}function Ut(e,t){let{x:n,x2:r,y:i,y2:a}=e,o=Math.min(i,a)-t.top,s=Math.min(n,r)-t.left,c=t.bottom-Math.max(i,a),l=t.right-Math.max(n,r);return{x:Math.min(s,l),y:Math.min(o,c),dx:s<=l?1:-1,dy:o<=c?1:-1}}function Wt(e,t){let{size:n,min:r,max:i,padding:a}=t,o=n/2;return n>i-r?(i+r)/2:(r>=e-a-o&&(e=r+a+o),i<=e+a+o&&(e=i-a-o),e)}function Gt(e){let t=e.options,n=t.arrowHeads&&t.arrowHeads.start,r=t.arrowHeads&&t.arrowHeads.end;return{startOpts:n,endOpts:r,startAdjust:Kt(e,n),endAdjust:Kt(e,r)}}function Kt(e,t){if(!t||!t.display)return 0;let{length:n,width:r}=t,i=e.options.borderWidth/2,a={x:n,y:r+i};return Math.abs(Ct(0,a,{x:0,y:i}))}function qt(e,t,n,r){if(!r||!r.display)return;let{length:i,width:a,fill:o,backgroundColor:s,borderColor:c}=r,l=Math.abs(t-i)+n;e.beginPath(),P(e,r),N(e,r),e.moveTo(l,-a),e.lineTo(t+n,0),e.lineTo(l,a),o===!0?(e.fillStyle=s||c,e.closePath(),e.fill(),e.shadowColor=`transparent`):e.shadowColor=r.borderShadowColor,e.stroke()}function Jt(e,t,n){let{x:r,y:i,x2:a,y2:o,centerX:s,centerY:c}=e,l=Math.atan2(o-i,a-r),u=ve(t.controlPoint,0);return z({x:s+O(n,u.x,!1),y:c+O(n,u.y,!1)},{x:s,y:c},l)}function Yt(e,{x:t,y:n},{angle:r,adjust:i},a){!a||!a.display||(e.save(),e.translate(t,n),e.rotate(r),qt(e,0,-i,a),e.restore())}function Xt(e,t,n,r){let{x:i,y:a,x2:o,y2:s,options:c}=t,{startOpts:l,endOpts:u,startAdjust:d,endAdjust:f}=Gt(t),p={x:i,y:a},m={x:o,y:s},h=kt(p,n,m,0),g=kt(p,n,m,1)-S,_=Dt(p,n,m,d/r),v=Dt(p,n,m,1-f/r),y=new Path2D;e.beginPath(),y.moveTo(_.x,_.y),y.quadraticCurveTo(n.x,n.y,v.x,v.y),e.shadowColor=c.borderShadowColor,e.stroke(y),t.path=y,t.ctx=e,Yt(e,_,{angle:h,adjust:d},l),Yt(e,v,{angle:g,adjust:f},u)}var q=class extends b{inRange(e,t,n,r){let i=this.options.rotation,a=this.options.borderWidth;if(n!==`x`&&n!==`y`)return Zt({x:e,y:t},this.getProps([`width`,`height`,`centerX`,`centerY`],r),i,a);let{x:s,y:c,x2:l,y2:u}=this.getProps([`x`,`y`,`x2`,`y2`],r),d=a/2,f=n===`y`?{start:c,end:u}:{start:s,end:l},p=z({x:e,y:t},this.getCenterPoint(r),o(-i));return p[n]>=f.start-d-T&&p[n]<=f.end+d+T}getCenterPoint(e){return D(this,e)}draw(e){let{width:t,height:n,centerX:r,centerY:i,options:a}=this;e.save(),M(e,this.getCenterPoint(),a.rotation),P(e,this.options),e.beginPath(),e.fillStyle=a.backgroundColor;let o=N(e,a);e.ellipse(r,i,n/2,t/2,S/2,0,2*S),e.fill(),o&&(e.shadowColor=a.borderShadowColor,e.stroke()),e.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(e,t){return ze(e,t,!0)}};q.id=`ellipseAnnotation`,q.defaults={adjustScaleRange:!0,backgroundShadowColor:`transparent`,borderDash:[],borderDashOffset:0,borderShadowColor:`transparent`,borderWidth:1,display:!0,init:void 0,label:Object.assign({},U.defaults.label),rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},q.defaultRoutes={borderColor:`color`,backgroundColor:`color`},q.descriptors={label:{_fallback:!0}};function Zt(e,t,n,r){let{width:i,height:a,centerX:s,centerY:c}=t,l=i/2,u=a/2;if(l<=0||u<=0)return!1;let d=o(n||0),f=r/2||0,p=Math.cos(d),m=Math.sin(d),h=(p*(e.x-s)+m*(e.y-c))**2,g=(m*(e.x-s)-p*(e.y-c))**2;return h/(l+f)**2+g/(u+f)**2<=1.0001}var J=class extends b{inRange(e,t,n,r){let{x:i,y:a,x2:o,y2:s,width:c}=this.getProps([`x`,`y`,`x2`,`y2`,`width`],r),l=this.options.borderWidth;if(n!==`x`&&n!==`y`)return ue({x:e,y:t},this.getCenterPoint(r),c/2,l);let u=l/2,d=n===`y`?{start:a,end:s,value:t}:{start:i,end:o,value:e};return d.value>=d.start-u&&d.value<=d.end+u}getCenterPoint(e){return D(this,e)}draw(e){let t=this.options,n=t.borderWidth;if(t.radius<.1)return;e.save(),e.fillStyle=t.backgroundColor,P(e,t);let r=N(e,t);Oe(e,this,this.centerX,this.centerY),r&&!j(t.pointStyle)&&(e.shadowColor=t.borderShadowColor,e.stroke()),e.restore(),t.borderWidth=n}resolveElementProperties(e,t){let n=Le(e,t);return n.initProperties=k(e,n,t,!0),n}};J.id=`pointAnnotation`,J.defaults={adjustScaleRange:!0,backgroundShadowColor:`transparent`,borderDash:[],borderDashOffset:0,borderShadowColor:`transparent`,borderWidth:1,display:!0,init:void 0,pointStyle:`circle`,radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},J.defaultRoutes={borderColor:`color`,backgroundColor:`color`};var Y=class extends b{inRange(e,t,n,r){if(n!==`x`&&n!==`y`)return this.options.radius>=.1&&this.elements.length>1&&$t(this.elements,e,t,r);let i=z({x:e,y:t},this.getCenterPoint(r),o(-this.options.rotation)),a=this.elements.map(e=>n===`y`?e.bY:e.bX),s=Math.min(...a),c=Math.max(...a);return i[n]>=s&&i[n]<=c}getCenterPoint(e){return D(this,e)}draw(e){let{elements:t,options:n}=this;e.save(),e.beginPath(),e.fillStyle=n.backgroundColor,P(e,n);let r=N(e,n),i=!0;for(let n of t)i?(e.moveTo(n.x,n.y),i=!1):e.lineTo(n.x,n.y);e.closePath(),e.fill(),r&&(e.shadowColor=n.borderShadowColor,e.stroke()),e.restore()}resolveElementProperties(e,t){let n=Le(e,t),{sides:r,rotation:i}=t,a=[],o=2*S/r,s=i*ne;for(let i=0;i<r;i++,s+=o){let r=Qt(n,t,s);r.initProperties=k(e,n,t),a.push(r)}return n.elements=a,n}};Y.id=`polygonAnnotation`,Y.defaults={adjustScaleRange:!0,backgroundShadowColor:`transparent`,borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderShadowColor:`transparent`,borderWidth:1,display:!0,init:void 0,point:{radius:0},radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,sides:3,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},Y.defaultRoutes={borderColor:`color`,backgroundColor:`color`};function Qt({centerX:e,centerY:t},{radius:n,borderWidth:r},i){let a=r/2,o=Math.sin(i),s=Math.cos(i),c={x:e+o*n,y:t-s*n};return{type:`point`,optionScope:`point`,properties:{x:c.x,y:c.y,centerX:c.x,centerY:c.y,bX:e+o*(n+a),bY:t-s*(n+a)}}}function $t(e,t,n,r){let i=!1,a=e[e.length-1].getProps([`bX`,`bY`],r);for(let o of e){let e=o.getProps([`bX`,`bY`],r);e.bY>n!=a.bY>n&&t<(a.bX-e.bX)*(n-e.bY)/(a.bY-e.bY)+e.bX&&(i=!i),a=e}return i}var X={box:U,ellipse:q,label:W,line:K,point:J,polygon:Y};Object.keys(X).forEach(e=>{n.describe(`elements.${X[e].id}`,{_fallback:`plugins.annotation.common`})});var en={update:Object.assign},tn=V.concat(H),nn=(e,t)=>s(t)?dn(e,t):e,Z=e=>e===`color`||e===`font`;function rn(e=`line`){return X[e]?e:(console.warn(`Unknown annotation type: '${e}', defaulting to 'line'`),`line`)}function an(e,t,n,r){let i=sn(e,n.animations,r),a=t.annotations,o=pn(t.elements,a);for(let t=0;t<a.length;t++){let n=a[t],r=ln(o,t,n.type),s=n.setContext(fn(e,r,n)),c=r.resolveElementProperties(e,s);c.skip=on(c),`elements`in c&&(cn(r,c.elements,s,i),delete c.elements),l(r.x)||Object.assign(r,c),Object.assign(r,c.initProperties),c.options=un(s),i.update(r,c)}}function on(e){return isNaN(e.x)||isNaN(e.y)}function sn(e,t,n){return n===`reset`||n===`none`||n===`resize`?en:new ee(e,t)}function cn(e,t,n,r){let i=e.elements||=[];i.length=t.length;for(let e=0;e<t.length;e++){let a=t[e],o=a.properties,s=ln(i,e,a.type,a.initProperties);o.options=un(n[a.optionScope].override(a)),r.update(s,o)}}function ln(e,t,n,r){let i=X[rn(n)],a=e[t];return(!a||!(a instanceof i))&&(a=e[t]=new i,Object.assign(a,r)),a}function un(e){let t=X[rn(e.type)],n={};n.id=e.id,n.type=e.type,n.drawTime=e.drawTime,Object.assign(n,dn(e,t.defaults),dn(e,t.defaultRoutes));for(let t of tn)n[t]=e[t];return n}function dn(e,t){let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Z(r)&&_(a)?n[r]=a.map(e=>nn(e,i)):n[r]=nn(a,i)}return n}function fn(e,t,n){return t.$context||=Object.assign(Object.create(e.getContext()),{element:t,id:n.id,type:`annotation`})}function pn(e,t){let n=t.length,r=e.length;if(r<n){let t=n-r;e.splice(r,0,...Array(t))}else r>n&&e.splice(n,r-n);return e}var mn=`2.2.1`,Q=new Map,hn=V.concat(H),gn={id:`annotation`,version:mn,beforeRegister(){fe(`chart.js`,`3.7`,y.version)},afterRegister(){y.register(X)},afterUnregister(){y.unregister(X)},beforeInit(e){Q.set(e,{annotations:[],elements:[],visibleElements:[],listeners:{},listened:!1,moveListened:!1,hooks:{},hooked:!1,hovered:[]})},beforeUpdate(e,t,n){let r=Q.get(e),i=r.annotations=[],a=n.annotations;s(a)?Object.keys(a).forEach(e=>{let t=a[e];s(t)&&(t.id=e,i.push(t))}):_(a)&&i.push(...a),rt(i,e.scales)},afterDataLimits(e,t){let n=Q.get(e);nt(e,t.scale,n.annotations.filter(e=>e.display&&e.adjustScaleRange))},afterUpdate(e,t,n){let r=Q.get(e);Je(e,r,n),an(e,r,n,t.mode),r.visibleElements=r.elements.filter(e=>!e.skip&&e.options.display),et(e,r,n)},beforeDatasetsDraw(e,t,n){$(e,`beforeDatasetsDraw`,n.clip)},afterDatasetsDraw(e,t,n){$(e,`afterDatasetsDraw`,n.clip)},beforeDraw(e,t,n){$(e,`beforeDraw`,n.clip)},afterDraw(e,t,n){$(e,`afterDraw`,n.clip)},beforeEvent(e,t,n){Ye(Q.get(e),t.event,n)&&(t.changed=!0)},afterDestroy(e){Q.delete(e)},_getState(e){return Q.get(e)},defaults:{animations:{numbers:{properties:[`x`,`y`,`x2`,`y2`,`width`,`height`,`centerX`,`centerY`,`pointX`,`pointY`,`radius`],type:`number`}},clip:!0,interaction:{mode:void 0,axis:void 0,intersect:void 0},common:{drawTime:`afterDatasetsDraw`,init:!1,label:{}}},descriptors:{_indexable:!1,_scriptable:e=>!hn.includes(e)&&e!==`init`,annotations:{_allKeys:!1,_fallback:(e,t)=>`elements.${X[rn(t.type)].id}`},interaction:{_fallback:!0},common:{label:{_indexable:Z,_fallback:!0},_indexable:Z}},additionalOptionScopes:[``]};function $(e,t,n){let{ctx:i,chartArea:a}=e,o=Q.get(e);n&&r(i,a);let s=_n(o.visibleElements,t).sort((e,t)=>e.element.options.z-t.element.options.z);for(let e of s)vn(i,a,o,e);n&&h(i)}function _n(e,t){let n=[];for(let r of e)if(r.options.drawTime===t&&n.push({element:r,main:!0}),r.elements&&r.elements.length)for(let e of r.elements)e.options.display&&e.options.drawTime===t&&n.push({element:e});return n}function vn(e,t,n,r){let i=r.element;r.main?(tt(n,i,`beforeDraw`),i.draw(e,t),tt(n,i,`afterDraw`)):i.draw(e,t)}export{gn as t};