vvplot 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{C as e,b as t,c as n,d as r,l as i,s as a}from"./chunk-utils.min.js";import{C as o,D as s,E as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,k as x,l as S,m as C,n as w,o as T,p as E,r as D,s as O,t as k,u as A,v as j,w as M,x as N,y as ee}from"./chunk-GeomViolin.min.js";import"./base-utils.esm.min.js";import{a as P,o as F}from"./chunk-utils2.min.js";import{Fragment as I,computed as L,createBlock as R,createCommentVNode as z,createElementBlock as B,createElementVNode as te,createTextVNode as V,createVNode as H,guardReactiveProps as U,mergeProps as W,normalizeProps as G,openBlock as K,renderList as q,toDisplayString as ne,toHandlers as J,unref as Y,useTemplateRef as X,watch as Z}from"vue";var re=Math.PI,ie=2*re,Q=1e-6,ae=ie-Q;function oe(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function se(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return oe;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}function ce(e,t,n,r){return e===n&&t===r}function le(e){let t=Math.floor(e);if(!(t<=15))return ce;let n=10**t,r=function(e){return Math.round(e*n)};return function(e,t,n,i){return r(e)===r(n)&&r(t)===r(i)}}var ue=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?oe:se(e),this._equal=e==null?ce:le(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>Q){if(!(Math.abs(u*s-c*l)>Q)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((re-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>Q&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;if(this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>Q||Math.abs(this._y1-l)>Q)&&this._append`L${c},${l}`,n){if(d<0&&(d=d%ie+ie),d>ae)this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`;else if(d>Q){let a=e+n*Math.cos(i),o=t+n*Math.sin(i);if(d>=re&&this._equal(c,l,a,o)){d/=2;let i=r+d;this._append`A${n},${n},0,${+(d>=re)},${u},${e+n*Math.cos(i)},${t+n*Math.sin(i)}`}this._append`A${n},${n},0,${+(d>=re)},${u},${this._x1=a},${this._y1=o}`}}}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};ue.prototype;function de(e){return function(){return e}}var fe=Math.cos,pe=Math.sin,me=Math.sqrt,he=1e-12,ge=Math.PI;ge/2;var _e=2*ge;function ve(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new ue(t)}Array.prototype.slice;function ye(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function be(e){this._context=e}be.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function xe(e){return new be(e)}function Se(e){return e[0]}function Ce(e){return e[1]}function we(e,t){var n=de(!0),r=null,i=xe,a=null,o=ve(s);e=typeof e==`function`?e:e===void 0?Se:de(e),t=typeof t==`function`?t:t===void 0?Ce:de(t);function s(s){var c,l=(s=ye(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:de(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:de(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:de(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}Ee(xe);function Te(e){this._curve=e}Te.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(e,t){this._curve.point(t*Math.sin(e),t*-Math.cos(e))}};function Ee(e){function t(t){return new Te(e(t))}return t._curve=e,t}me(3),me(1/3)*2;var De=pe(ge/10)/pe(7*ge/10);pe(_e/10)*De,-fe(_e/10)*De,me(3),me(3),me(3)/2,(1/me(12)/2+1)*3;function Oe(){}function ke(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ae(e){this._context=e}Ae.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ke(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ke(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function je(e,t){this._basis=new Ae(e),this._beta=t}je.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var r=e[0],i=t[0],a=e[n]-r,o=t[n]-i,s=-1,c;++s<=n;)c=s/n,this._basis.point(this._beta*e[s]+(1-this._beta)*(r+c*a),this._beta*t[s]+(1-this._beta)*(i+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}},(function e(t){function n(e){return t===1?new Ae(e):new je(e,t)}return n.beta=function(t){return e(+t)},n})(.85);function Me(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Ne(e,t){this._context=e,this._k=(1-t)/6}Ne.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Me(this,this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Me(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var Pe=(function e(t){function n(e){return new Ne(e,t)}return n.tension=function(t){return e(+t)},n})(0);function Fe(e,t){this._context=e,this._k=(1-t)/6}Fe.prototype={areaStart:Oe,areaEnd:Oe,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:Me(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var Ie=(function e(t){function n(e){return new Fe(e,t)}return n.tension=function(t){return e(+t)},n})(0);function Le(e,t){this._context=e,this._k=(1-t)/6}Le.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Me(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},(function e(t){function n(e){return new Le(e,t)}return n.tension=function(t){return e(+t)},n})(0);function Re(e,t,n){var r=e._x1,i=e._y1,a=e._x2,o=e._y2;if(e._l01_a>he){var s=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*s-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,i=(i*s-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>he){var l=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);a=(a*l+e._x1*e._l23_2a-t*e._l12_2a)/u,o=(o*l+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(r,i,a,o,e._x2,e._y2)}function ze(e,t){this._context=e,this._alpha=t}ze.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:Re(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var Be=(function e(t){function n(e){return t?new ze(e,t):new Ne(e,0)}return n.alpha=function(t){return e(+t)},n})(.5);function Ve(e,t){this._context=e,this._alpha=t}Ve.prototype={areaStart:Oe,areaEnd:Oe,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:Re(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var He=(function e(t){function n(e){return t?new Ve(e,t):new Fe(e,0)}return n.alpha=function(t){return e(+t)},n})(.5);function Ue(e,t){this._context=e,this._alpha=t}Ue.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Re(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},(function e(t){function n(e){return t?new Ue(e,t):new Le(e,0)}return n.alpha=function(t){return e(+t)},n})(.5);function We(e){this._context=e}We.prototype={areaStart:Oe,areaEnd:Oe,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function Ge(e){return new We(e)}function Ke(e){return e<0?-1:1}function qe(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(Ke(a)+Ke(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function Je(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Ye(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function Xe(e){this._context=e}Xe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Ye(this,this._t0,Je(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Ye(this,Je(this,n=qe(this,e,t)),n);break;default:Ye(this,this._t0,n=qe(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},Object.create(Xe.prototype).point=function(e,t){Xe.prototype.point.call(this,t,e)};function Ze(e){this._context=e}Ze.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n){if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=Qe(e),i=Qe(t),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],e[o],t[o])}(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function Qe(e){var t,n=e.length-1,r,i=Array(n),a=Array(n),o=Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,a[t]=4,o[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/a[t-1],a[t]-=r,o[t]-=r*o[t-1];for(i[n-1]=o[n-1]/a[n-1],t=n-2;t>=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)a[t]=2*e[t+1]-i[t+1];return[i,a]}function $e(e){return new Ze(e)}var et=/* @__PURE__ */ e({VVGeomBar:()=>o,VVGeomBlank:()=>u,VVGeomBoxplot:()=>N,VVGeomCol:()=>m,VVGeomCurve:()=>ee,VVGeomDensity:()=>j,VVGeomEllipse:()=>f,VVGeomHistogram:()=>v,VVGeomLine:()=>y,VVGeomLinerange:()=>C,VVGeomMarkdown:()=>E,VVGeomMarkdownsegment:()=>_,VVGeomPath:()=>g,VVGeomPoint:()=>A,VVGeomPolygon:()=>S,VVGeomRect:()=>h,VVGeomSegment:()=>O,VVGeomShape:()=>T,VVGeomStick:()=>p,VVGeomText:()=>b,VVGeomTextsegment:()=>D,VVGeomTile:()=>w,VVGeomViolin:()=>k}),tt={key:0},nt={__name:`ElementCurve`,props:{points:{type:Array,default:()=>[]},interpolate:{default:`natural`},fill:String,color:String,linewidth:Number,linetype:String,alpha:{type:Number,default:1},title:String,translateX:{type:Number,default:0},translateY:{type:Number,default:0}},setup(e){let t=L(()=>{let t=typeof e.interpolate==`function`?e.interpolate:n[e.interpolate]??$e;return{d:we().curve(t)(e.points.map(e=>[e.x,e.y])),color:e.color||null,fill:e.fill||null,"fill-opacity":e.alpha==1?null:e.alpha,stroke:e.color||null,"stroke-width":e.linewidth,"stroke-opacity":e.alpha==1?null:e.alpha,"stroke-dasharray":P(e.linetype).join(` `)||null,transform:e.translateX||e.translateY?`translate(${e.translateX}, ${e.translateY})`:null}}),n={cardinal:Pe,cardinalClosed:Ie,catmullRom:Be,catmullRomClosed:He,linear:xe,linearClosed:Ge,natural:$e};return(n,r)=>(K(),B(`path`,G(U(t.value)),[e.title?(K(),B(`title`,tt,ne(e.title),1)):z(``,!0)],16))}},rt={key:0},it={__name:`ElementEllipse`,props:{cx:{type:Number,default:0},cy:{type:Number,default:0},rx:{type:Number,default:0},ry:{type:Number,default:0},angle:{type:Number,default:0},fill:String,color:String,linewidth:Number,linetype:String,alpha:{type:Number,default:1},title:String,translateX:{type:Number,default:0},translateY:{type:Number,default:0}},setup(e){let t=L(()=>{let t=[];return(e.translateX||e.translateY)&&t.push(`translate(${e.translateX}, ${e.translateY})`),e.angle&&t.push(`rotate(${e.angle})`),{cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry,color:e.color||null,fill:e.fill||null,"fill-opacity":e.alpha==1?null:e.alpha,stroke:e.color||null,"stroke-width":e.linewidth,"stroke-opacity":e.alpha==1?null:e.alpha,"stroke-dasharray":P(e.linetype).join(` `)||null,transform:t.join(` `)||null,"transform-origin":`${e.cx} ${e.cy}`}});return(n,r)=>(K(),B(`ellipse`,G(U(t.value)),[e.title?(K(),B(`title`,rt,ne(e.title),1)):z(``,!0)],16))}},at={key:0},ot={__name:`ElementPolygon`,props:{points:{type:Array,default:()=>[]},fill:String,color:String,linewidth:Number,linetype:String,alpha:{type:Number,default:1},title:String,translateX:{type:Number,default:0},translateY:{type:Number,default:0}},setup(e){let t=L(()=>({points:e.points.map(e=>`${e.x},${e.y}`).join(` `),color:e.color||null,fill:e.fill||null,"fill-opacity":e.alpha==1?null:e.alpha,stroke:e.color||null,"stroke-width":e.linewidth,"stroke-opacity":e.alpha==1?null:e.alpha,"stroke-dasharray":P(e.linetype).join(` `)||null,transform:e.translateX||e.translateY?`translate(${e.translateX}, ${e.translateY})`:null}));return(n,r)=>(K(),B(`polygon`,G(U(t.value)),[e.title?(K(),B(`title`,at,ne(e.title),1)):z(``,!0)],16))}},st={scale_attrs:[],coord_scale(e,t){return null},get_range(e,t){if(t==`x`)return e.x??[];if(t==`y`)return e.y??[]},validate(e){return null}},{sum:$,coalesce:ct}=t,lt={legend_glyph:`boxplot`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,n){let r=ct(e.xnudge,0),i=ct(e.ynudge,0);if(e.x){let a=$(n.x?.apply?.(e.x)??e.x,r),o=$(a,e.width?.map?.(e=>-e/2)??-.5),s=$(a,e.width?.map?.(e=>e/2)??.5);return{x:a,xmin:o,xmax:s,lwisker:$(e.lwisker,i),Q1:$(e.Q1,i),median:$(e.median,i),Q3:$(e.Q3,i),uwisker:$(e.uwisker,i),outliers:t.apply((e,{y:t,$raw:n},r)=>$(t,r).map((t,r)=>({x:e,y:t,$raw:n[r]})),a,e.outliers??[],i),$xmin:o,$xmax:s,$ymin:$(e.min,i),$ymax:$(e.max,i)}}if(e.y){let a=$(n.y?.apply?.(e.y)??e.y,i),o=$(a,e.height?.map?.(e=>-e/2)??-.5),s=$(a,e.height?.map?.(e=>e/2)??.5);return{y:a,ymin:o,ymax:s,lwisker:$(e.lwisker,r),Q1:$(e.Q1,r),median:$(e.median,r),Q3:$(e.Q3,r),uwisker:$(e.uwisker,r),outliers:t.apply((e,{x:t,$raw:n},r)=>$(t,r).map((t,r)=>({x:t,y:e,$raw:n[r]})),a,e.outliers??[],r),$xmin:$(e.min,r),$xmax:$(e.max,r),$ymin:o,$ymax:s}}return{}},get_range(e,t){if(t==`x`)return e.x||(e.min??[]).concat(e.max??[]);if(t==`y`)return e.y||(e.min??[]).concat(e.max??[])},validate(e){return[e.$xmin,e.$xmax,e.$ymin,e.$ymax].some(e=>isNaN(e))?null:e}},ut={legend_glyph:`line`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=e.xnudge?.map(e=>+e),r=e.ynudge?.map(e=>+e);return{points:e.points.map((e,i)=>e.map(e=>({x:+(t?.x?.[e.x]??e.x)+(n?.[i]??0),y:+(t?.y?.[e.y]??e.y)+(r?.[i]??0)})))}},get_range(e,t){if(t==`x`)return(e.points??[]).flatMap(e=>e.map(e=>e.x));if(t==`y`)return(e.points??[]).flatMap(e=>e.map(e=>e.y))},validate(e){return!Array.isArray(e.points)||Array.from(e.points).some(e=>isNaN(e.x)||isNaN(e.y))?null:e}},{sum:dt,coalesce:ft}=t,pt={legend_glyph:`tile`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let{A:n,B:r,C:i}=e,a=ft(e.xnudge,0),o=ft(e.ynudge,0);return{cx:dt(t.x?.apply?.(e.cx)??e.cx,a),cy:dt(t.y?.apply?.(e.cy)??e.cy,o),A:n,B:r,C:i}},get_range(e,n){if(n==`x`){let n=t.apply((e,t,n)=>Math.sqrt(n/(e*n-t*t)),e.A??[],e.B??[],e.C??[]);return dt(e.cx??[],n).concat(dt(e.cx??[],t.opposite(n))??[])}if(n==`y`){let n=t.apply((e,t,n)=>Math.sqrt(e/(e*n-t*t)),e.A??[],e.B??[],e.C??[]);return dt(e.cy??[],n).concat(dt(e.cy??[],t.opposite(n))??[])}},validate(e){return isNaN(e.cx)||isNaN(e.cy)||isNaN(e.A)||isNaN(e.B)||isNaN(e.C)||!(e.A*e.C>e.B*e.B)?null:e}},{sum:mt,coalesce:ht}=t,gt={legend_glyph:`line`,scale_attrs:[`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=ht(e.xnudge,0),r=ht(e.ynudge,0);return{x:mt(t.x?.apply?.(e.x)??e.x,n),y:mt(t.y?.apply?.(e.y)??e.y,r),xend:mt(t.x?.apply?.(e.xend)??e.xend,n),yend:mt(t.y?.apply?.(e.yend)??e.yend,r)}},get_range(e,t){if(t==`x`)return(e.x??[]).concat(e.xend??[]);if(t==`y`)return(e.y??[]).concat(e.yend??[])},validate(e){return isNaN(e.x)||isNaN(e.y)||isNaN(e.xend)||isNaN(e.yend)?null:e}},{sum:_t,coalesce:vt}=t,yt={legend_glyph:`text`,scale_attrs:[`size`,`color`,`stroke`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=vt(e.xnudge,0),r=vt(e.ynudge,0);return{x:_t(t.x?.apply?.(e.x)??e.x,n),y:_t(t.y?.apply?.(e.y)??e.y,r)}},get_range(e,t){if(t==`x`)return e.x??[];if(t==`y`)return e.y??[]},validate(e){return isNaN(e.x)||isNaN(e.y)?null:e}},{sum:bt,coalesce:xt}=t,St={legend_glyph:`text`,scale_attrs:[`size`,`color`,`stroke`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=xt(e.xnudge,0),r=xt(e.ynudge,0);return{x:bt(t.x?.apply?.(e.x)??e.x,n),y:bt(t.y?.apply?.(e.y)??e.y,r),xend:bt(t.x?.apply?.(e.xend)??e.xend,n),yend:bt(t.y?.apply?.(e.yend)??e.yend,r)}},get_range(e,t){if(t==`x`)return(e.x??[]).concat(e.xend??[]);if(t==`y`)return(e.y??[]).concat(e.yend??[])},validate(e){return isNaN(e.x)||isNaN(e.xend)||isNaN(e.y)||isNaN(e.yend)?null:e}},{sum:Ct,coalesce:wt}=t,Tt={legend_glyph:`point`,scale_attrs:[`shape`,`size`,`color`,`stroke`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=wt(e.xnudge,0),r=wt(e.ynudge,0);return{x:Ct(t.x?.apply?.(e.x)??e.x,n),y:Ct(t.y?.apply?.(e.y)??e.y,r)}},get_range(e,t){if(t==`x`)return e.x??[];if(t==`y`)return e.y??[]},validate(e){return isNaN(e.x)||isNaN(e.y)?null:e}},Et={legend_glyph:`tile`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=e.xnudge?.map(e=>+e),r=e.ynudge?.map(e=>+e);return{points:e.points.map((e,i)=>e.map(e=>({x:+(t?.x?.[e.x]??e.x)+(n?.[i]??0),y:+(t?.y?.[e.y]??e.y)+(r?.[i]??0)})))}},get_range(e,t){if(t==`x`)return(e.points??[]).flatMap(e=>e.map(e=>e.x));if(t==`y`)return(e.points??[]).flatMap(e=>e.map(e=>e.y))},validate(e){return!Array.isArray(e.points)||Array.from(e.points).some(e=>isNaN(e.x)||isNaN(e.y))?null:e}},{sum:Dt,coalesce:Ot}=t,kt={legend_glyph:`tile`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=Ot(e.xnudge,0),r=Ot(e.ynudge,0);return{xmin:Dt(t.x?.apply?.(e.xmin)??e.xmin,n),xmax:Dt(t.x?.apply?.(e.xmax)??e.xmax,n),ymin:Dt(t.y?.apply?.(e.ymin)??e.ymin,r),ymax:Dt(t.y?.apply?.(e.ymax)??e.ymax,r)}},get_range(e,t){if(t==`x`)return(e.xmin??[]).concat(e.xmax??[]);if(t==`y`)return(e.ymin??[]).concat(e.ymax??[])},validate(e){return isNaN(e.xmin)||isNaN(e.ymin)||isNaN(e.xmax)||isNaN(e.ymax)?null:e}},At={legend_glyph:`tile`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=t.x?.apply?.(e.x)??e.x,r=t.y?.apply?.(e.y)??e.y,i=e.xnudge?.map(e=>+e),a=e.ynudge?.map(e=>+e);return{points:e.points.map((e,o)=>e.map(e=>({x:+(t?.x?.[e.x]??e.x)+(i?.[o]??0)+n[o],y:+(t?.y?.[e.y]??e.y)+(a?.[o]??0)+r[o]})))}},get_values(e,t){if(t==`x`)return e.x;if(t==`y`)return e.y},get_range(e,t){if(t==`x`)return(e.points??[]).flatMap((t,n)=>t.map(t=>t.x+e.x[n]));if(t==`y`)return(e.points??[]).flatMap((t,n)=>t.map(t=>t.y+e.y[n]))},validate(e){return!Array.isArray(e.points)||Array.from(e.points).some(e=>isNaN(e.x)||isNaN(e.y))?null:e}},{sum:jt,coalesce:Mt}=t,Nt={legend_glyph:`line`,scale_attrs:[`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=Mt(e.xnudge,0),r=Mt(e.ynudge,0),i=jt(t.x?.apply?.(e.x)??e.x,n),a=jt(t.y?.apply?.(e.y)??e.y,r);return{x:i,y:a,xend:jt(i,e.dx),yend:jt(a,e.dy)}},get_values(e,t){if(t==`x`)return e.x??[];if(t==`y`)return e.y??[]},get_range(e,t){if(t==`x`)return(e.x??[]).concat(jt(e.x??[],e.dx??0)??[]);if(t==`y`)return(e.y??[]).concat(jt(e.y??[],e.dy??0)??[])},validate(e){return isNaN(e.x)||isNaN(e.y)||isNaN(e.xend)||isNaN(e.yend)?null:e}},{sum:Pt,coalesce:Ft}=t,It={legend_glyph:`text`,scale_attrs:[`size`,`color`,`stroke`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=Ft(e.xnudge,0),r=Ft(e.ynudge,0);return{x:Pt(t.x?.apply?.(e.x)??e.x,n),y:Pt(t.y?.apply?.(e.y)??e.y,r)}},get_range(e,t){if(t==`x`)return e.x??[];if(t==`y`)return e.y??[]},validate(e){return isNaN(e.x)||isNaN(e.y)?null:e}},{sum:Lt,coalesce:Rt}=t,zt={legend_glyph:`text`,scale_attrs:[`size`,`color`,`stroke`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=Rt(e.xnudge,0),r=Rt(e.ynudge,0);return{x:Lt(t.x?.apply?.(e.x)??e.x,n),y:Lt(t.y?.apply?.(e.y)??e.y,r),xend:Lt(t.x?.apply?.(e.xend)??e.xend,n),yend:Lt(t.y?.apply?.(e.yend)??e.yend,r)}},get_range(e,t){if(t==`x`)return(e.x??[]).concat(e.xend??[]);if(t==`y`)return(e.y??[]).concat(e.yend??[])},validate(e){return isNaN(e.x)||isNaN(e.xend)||isNaN(e.y)||isNaN(e.yend)?null:e}},{sum:Bt,coalesce:Vt}=t,Ht={legend_glyph:`tile`,scale_attrs:[`fill`,`color`,`linewidth`,`linetype`,`alpha`],coord_scale(e,t){let n=Vt(e.xnudge,0),r=Vt(e.ynudge,0),i=t.x?.apply?.(e.x)??e.x,a=t.y?.apply?.(e.y)??e.y;return{xmin:Bt(i,e.width?.map?.(e=>-e/2)??-.5,n),xmax:Bt(i,e.width?.map?.(e=>e/2)??.5,n),ymin:Bt(a,e.height?.map?.(e=>-e/2)??-.5,r),ymax:Bt(a,e.height?.map?.(e=>e/2)??.5,r)}},get_values(e,t){if(t==`x`)return e.x;if(t==`y`)return e.y},get_range(e,n){if(n==`x`){let n=t.apply((e,t)=>+e-t/2,e.x??[],e.width??[]),r=t.apply((e,t)=>+e+t/2,e.x??[],e.width??[]);return n.concat(r)}if(n==`y`){let n=t.apply((e,t)=>+e-t/2,e.y??[],e.height??[]),r=t.apply((e,t)=>+e+t/2,e.y??[],e.height??[]);return n.concat(r)}},validate(e){return isNaN(e.xmin)||isNaN(e.ymin)||isNaN(e.xmax)||isNaN(e.ymax)?null:e}},Ut=/* @__PURE__ */ e({blank:()=>st,boxplot:()=>lt,curve:()=>ut,ellipse:()=>pt,line:()=>gt,markdown:()=>yt,markdownsegment:()=>St,point:()=>Tt,polygon:()=>Et,rect:()=>kt,shape:()=>At,stick:()=>Nt,text:()=>It,textsegment:()=>zt,tile:()=>Ht}),Wt=x(function(e,{position:t=`stack`,width:n=.9,height:r=.9}){if(e.x!=null&&e.y!=null)throw Error(`"StatBar" only supports "x" or "y", not both`);let i=e.x?`x`:`y`,o=e[i];if(o==null)throw Error(`Missing aesthetics for "StatBar": "x" or "y"`);if(o.some(e=>typeof e==`number`))throw Error(`"StatBar" requires a discrete aesthetic`);let s=Object.keys(e).filter(e=>!e.startsWith(`$`)),c=a(Object.fromEntries(s.map(t=>[t,e[t]]))),l=a({group:c??0,value:o}),u=Map.groupBy(e.$raw,(e,t)=>l.categories[l[t]]),d=Array.from(u.values()),f=Array.from(u.keys()),p=d.map(e=>e.length),m={$raw:d,$group:f.map(e=>e.group),[i]:f.map(e=>e.value)};for(let e of s)m[e]=f.map(e=>e.group).map(t=>c.categories[t][e]);if(i==`x`?(n??=.9,m.height=p):(r??=.9,m.width=p),t==`stack`){let e=Object.groupBy(m.$group,(e,t)=>c.categories[e][i]),t=f.map(e=>0);for(let n in e){let r=0;for(let i of e[n])t[i]=r,r+=p[i]}i==`x`?(m.y=m.height.map((e,n)=>t[n]+e/2),m.width=f.map(e=>n)):(m.x=m.width.map((e,n)=>t[n]+e/2),m.height=f.map(e=>r))}else if(t==`dodge`){let e=Object.groupBy(m.$group,(e,t)=>c.categories[e][i]),t=m.$group.map(t=>e[c.categories[t][i]]);i==`x`?(m.y=m.height.map(e=>e/2),m.width=t.map(e=>n/e.length),m.xnudge=t.map((e,t)=>(m.xnudge?.[t]??0)+((e.indexOf(m.$group[t])+.5)/e.length-.5)*n)):(m.x=m.width.map(e=>e/2),m.height=t.map(e=>r/e.length),m.ynudge=t.map((e,t)=>(m.ynudge?.[t]??0)+((e.indexOf(m.$group[t])+.5)/e.length-.5)*r))}else i==`x`?(m.y=m.height.map(e=>e/2),m.width=f.map(e=>n)):(m.x=m.width.map(e=>e/2),m.height=f.map(e=>r));return m},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),Gt=x(function(e,{position:t=`dodge`,width:n=.9,height:o=.9}){let s=[`x`,`y`].filter(t=>e[t]==null);if(s.length>0)throw Error(`Missing aesthetics for "StatBoxplot": "${s.join(`", "`)}"`);let c=e.x.some(i),l=e.y.some(i);if(c&&l)throw Error(`Both "x" and "y" are discrete, "StatBoxplot" requires one continuous and one discrete aesthetic`);if(!c&&!l)throw Error(`Both "x" and "y" are continuous, "StatBoxplot" requires one continuous and one discrete aesthetic`);let[u,d]=c?[`y`,`x`]:[`x`,`y`],f=Object.keys(e).filter(e=>e!=u&&!e.startsWith(`$`)),p=a(Object.fromEntries(f.map(t=>[t,e[t]]))),m=a({group:p??0,cate:e[d]}),h=Map.groupBy(m.map((e,t)=>t),(e,t)=>m.categories[m[t]]),g=Array.from(h.keys()),_=Array.from(h.values()).map(t=>t.map(t=>e.$raw[t])),v=Array.from(h.values()).map(t=>t.map(t=>e[u][t])),y=v.map(e=>r.min(e)),b=v.map(e=>r.quantile(e,.25)),x=v.map(e=>r.quantile(e,.5)),S=v.map(e=>r.quantile(e,.75)),C=v.map(e=>r.max(e)),w=v.map((e,t)=>S[t]-b[t]),T=v.map((e,t)=>Math.max(y[t],b[t]-1.5*w[t])),E=v.map((e,t)=>Math.min(C[t],S[t]+1.5*w[t])),D=Array.from(h.values()).map((t,n)=>{let r=t.filter(t=>e[u][t]<T[n]||e[u][t]>E[n]);return{[u]:r.map(t=>e[u][t]),$raw:r.map(t=>e.$raw[t])}}),O={$raw:_,$group:g.map(e=>e.group),min:y,lwisker:T,Q1:b,median:x,Q3:S,uwisker:E,max:C,outliers:D};if(t==`dodge`){let e=Object.groupBy(O.$group,(e,t)=>p.categories[e][d]),t=O.$group.map(t=>e[p.categories[t][d]]);c?(O.width=t.map(e=>n/e.length),O.xnudge=t.map((e,t)=>(O.xnudge?.[t]??0)+((e.indexOf(O.$group[t])+.5)/e.length-.5)*n)):(O.height=t.map(e=>o/e.length),O.ynudge=t.map((e,t)=>(O.ynudge?.[t]??0)+((e.indexOf(O.$group[t])+.5)/e.length-.5)*o))}else c?O.width=g.map(e=>n):O.height=g.map(e=>o);for(let e of f)O[e]=g.map(e=>e.group).map(t=>p.categories[t][e]);return O},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),Kt=x(function(e,{position:t=`stack`,width:n,height:o,orientation:s=`x`}){let c=[`x`,`y`].filter(t=>e[t]==null);if(c.length>0)throw Error(`Missing aesthetics for "StatCol": "${c.join(`", "`)}"`);let l=e.x.some(i),u=e.y.some(i);if(l&&u)throw Error(`Both "x" and "y" are discrete, "StatCol" requires at most one discrete aesthetic`);let d=l==u?s==`y`?`y`:`x`:l?`x`:`y`,f=d==`x`?`y`:`x`,p=Object.keys(e).filter(e=>e!=f&&!e.startsWith(`$`)),m=a(Object.fromEntries(p.map(t=>[t,e[t]]))),h=a({group:m??0,cate:e[d]}),g=Map.groupBy(h.map((e,t)=>t),(e,t)=>h.categories[h[t]]),_=Map.groupBy(e.$raw,(e,t)=>h.categories[h[t]]),v=Array.from(_.keys()),y=Array.from(g.values()).map(t=>t.map(t=>e.$raw[t])),b=Array.from(g.values()).map(t=>r.sum(t.map(t=>e[f][t]))),x={$raw:y,$group:v.map(e=>e.group),[d]:v.map(e=>e.value)};for(let e of p)x[e]=v.map(e=>e.group).map(t=>m.categories[t][e]);if(d==`x`?(n??=l?.9:r.min(r.diff(Array.from(new Set(e[d])).sort((e,t)=>e-t)))*.9,x.height=b):(o??=u?.9:r.min(r.diff(Array.from(new Set(e[d])).sort((e,t)=>e-t)))*.9,x.width=b),t==`stack`){let e=Object.groupBy(x.$group,(e,t)=>m.categories[e][d]),t=v.map(e=>0);for(let n in e){let r=0;for(let i of e[n])t[i]=r,r+=b[i]}d==`x`?(x.y=x.height.map((e,n)=>t[n]+e/2),x.width=v.map(e=>n)):(x.x=x.width.map((e,n)=>t[n]+e/2),x.height=v.map(e=>o))}else if(t==`dodge`){let e=Object.groupBy(x.$group,(e,t)=>m.categories[e][d]),t=x.$group.map(t=>e[m.categories[t][d]]);d==`x`?(x.y=x.height.map(e=>e/2),x.width=t.map(e=>n/e.length),x.xnudge=t.map((e,t)=>(x.xnudge?.[t]??0)+((e.indexOf(x.$group[t])+.5)/e.length-.5)*n)):(x.x=x.width.map(e=>e/2),x.height=t.map(e=>o/e.length),x.ynudge=t.map((e,t)=>(x.ynudge?.[t]??0)+((e.indexOf(x.$group[t])+.5)/e.length-.5)*o))}else d==`x`?(x.y=x.height.map(e=>e/2),x.width=v.map(e=>n)):(x.x=x.width.map(e=>e/2),x.height=v.map(e=>o));return x},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),qt=x(function(e){if(e.points!=null)return e;let t=[`x`,`y`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatCurve": "${t.join(`", "`)}" or "points"`);let r=Object.keys(e).filter(e=>![`x`,`y`].includes(e)&&!e.startsWith(`$`)),i=a(Object.fromEntries(r.map(t=>[t,e[t]]))),o=a({group:i??Array(e.x.length).fill(0)}).map((e,t,n)=>n.categories[e]),s=Map.groupBy(e.$raw,(e,t)=>o[t]),c=Array.from(s.values()),l=Array.from(s.keys()),u={$raw:c,points:Array.from(Map.groupBy(n({x:e.x,y:e.y}),(e,t)=>o[t]).values())};for(let e of r)u[e]=l.map(e=>e.group).map(t=>i.categories[t][e]);return u},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),Jt=x(function(e,{n:t=512,kernel:n=`gaussian`,scale:i=`area`}={}){if(e.x!=null&&e.y!=null)throw Error(`"StatDensity" only supports "x" or "y", not both`);let o=e.x??e.y;if(o==null)throw Error(`Missing aesthetics for "StatDensity": "x" or "y"`);if(o.some(e=>typeof e!=`number`))throw Error(`"StatDensity" requires a continuous aesthetic`);if(n=Xt[n],!n)throw Error(`kernel must be one of ${Object.keys(Xt).map(e=>`"${e}"`).join(`, `)}`);let s=Object.keys(e).filter(e=>![`x`,`y`].includes(e)&&!e.startsWith(`$`)),c=a(Object.fromEntries(s.map(t=>[t,e[t]]))),l=a({group:c??Array(o.length).fill(0)}).map((e,t,n)=>n.categories[e]),u=Map.groupBy(e.$raw,(e,t)=>l[t]),d=Array.from(u.values()),f=Array.from(u.keys()),p=Array.from(Map.groupBy(o,(e,t)=>l[t]).values()),m={$raw:d,$group:f.map(e=>e.group)},h=p.map(e=>{let a=Yt.nrd0(e),{min:o,max:s}=r.extent(e);o-=3*a,s+=3*a;let c=(s-o)/(t-1),l=Array.from({length:t},(e,t)=>o+t*c),u=i===`count`?e.length:1;return l.map(t=>[t,r.mean(e.map(e=>n((t-e)/a)))/a*u])});for(let e of s)m[e]=f.map(t=>c.categories[t.group][e]);return m.points=e.x?h.map(e=>e.map(([e,t])=>({x:e,y:t}))):h.map(e=>e.map(([e,t])=>({x:t,y:e}))),m},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),Yt={nrd0:function(e){e=e.filter(e=>(typeof e==`number`||e instanceof Date)&&isFinite(e));let t=r.sd(e),n=r.quantile(e,.75)-r.quantile(e,.25);return .9*(Math.min(t,n/1.34)||1)*e.length**-.2},nrd:function(e){e=e.filter(e=>(typeof e==`number`||e instanceof Date)&&isFinite(e));let t=r.sd(e),n=r.quantile(e,.75)-r.quantile(e,.25);return 1.06*(Math.min(t,n/1.34)||1)*e.length**-.2}},Xt={uniform:e=>Math.abs(e)<=1?.5:0,triangular:e=>Math.abs(e)<=1?1-Math.abs(e):0,epanechnikov:e=>Math.abs(e)<=1?.75*(1-e**2):0,biweight:e=>Math.abs(e)<=1?15/16*(1-e**2)**2:0,triweight:e=>Math.abs(e)<=1?35/32*(1-e**2)**3:0,tricube:e=>Math.abs(e)<=1?70/81*(1-Math.abs(e)**3)**3:0,gaussian:e=>Math.exp(-.5*e**2)/Math.sqrt(2*Math.PI),cosine:e=>Math.abs(e)<=1?Math.PI/4*Math.cos(Math.PI/2*e):0,logistic:e=>1/Math.cosh(e)**2/Math.PI,sigmoid:e=>2/(Math.exp(e)+Math.exp(-e))**2/Math.PI},Zt=x(function(e,{CI:t=.95}={}){let r=[`x`,`y`].filter(t=>e[t]==null);if(r.length>0)throw Error(`Missing aesthetics for "StatEllipse": "${r.join(`", "`)}" or "points"`);let i=Object.keys(e).filter(e=>![`x`,`y`].includes(e)&&!e.startsWith(`$`)),o=a(Object.fromEntries(i.map(t=>[t,e[t]]))),s=a({group:o??Array(e.x.length).fill(0)}).map((e,t,n)=>n.categories[e]),c=Map.groupBy(e.$raw,(e,t)=>s[t]),l=Array.from(c.values()),u=Array.from(c.keys()),d=-2*Math.log(1-t),f=Array.from(Map.groupBy(n({x:e.x,y:e.y}),(e,t)=>s[t]).values()).map(e=>{let t=e.length,n=e.reduce((e,t)=>e+t.x,0)/t,r=e.reduce((e,t)=>e+t.y,0)/t;if(t<2)return{};let i=e.reduce((e,t)=>e+(t.x-n)**2,0)/(t-1),a=e.reduce((e,t)=>e+(t.x-n)*(t.y-r),0)/(t-1),o=e.reduce((e,t)=>e+(t.y-r)**2,0)/(t-1),s=(i*o-a*a)*d;return{cx:n,cy:r,A:o/s,B:-a/s,C:i/s}}),p={$raw:l,cx:f.map(e=>e.cx??0),cy:f.map(e=>e.cy??0),A:f.map(e=>e.A??0),B:f.map(e=>e.B??0),C:f.map(e=>e.C??0)};for(let e of i)p[e]=u.map(e=>e.group).map(t=>o.categories[t][e]);return p},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),Qt=x(function(e,{bins:t=30,binwidth:n,breaks:i}={}){if(e.x!=null&&e.y!=null)throw Error(`"StatHistogram" only supports "x" or "y", not both`);let o=e.x??e.y;if(o==null)throw Error(`Missing aesthetics for "StatHistogram": "x" or "y"`);if(o.some(e=>typeof e!=`number`))throw Error(`"StatHistogram" requires a continuous aesthetic`);if(i)i.sort((e,t)=>e-t);else{let{min:e,max:a}=r.extent(o);n||=(a-e)/(t-1),i=Array.from({length:t+1},(t,r)=>e+(r-.5)*n)}t=i.length-1;let s=Object.keys(e).filter(e=>![`x`,`y`].includes(e)&&!e.startsWith(`$`)),c=a(Object.fromEntries(s.map(t=>[t,e[t]]))),l=a({group:c??Array(o.length).fill(0),upper:o.map(e=>i.findLast(t=>t<=e)??i[0]),lower:o.map(e=>i.find(t=>t>e)??i[t])}).map((e,t,n)=>n.categories[e]),u=Map.groupBy(e.$raw,(e,t)=>l[t]),d=Array.from(u.values()),f=Array.from(u.keys()),p={$raw:d,count:d.map(e=>e.length),$group:f.map(e=>e.group),upper:f.map(e=>e.upper),lower:f.map(e=>e.lower)};for(let e of s)p[e]=f.map(t=>c.categories[t.group][e]);return e.x?(({upper:e,lower:t,count:n,ymin:r=d.map(()=>0),...i})=>({xmin:e,xmax:t,ymin:r,ymax:n,...i}))(p):(({upper:e,lower:t,count:n,xmin:r=d.map(()=>0),...i})=>({xmin:r,xmax:n,ymin:e,ymax:t,...i}))(p)},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),$t=x(function(e){return e},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),en=x(function(e,{orientation:t=`x`}={}){let n=[`x`,`y`].filter(t=>e[t]==null);if(n.length>0)throw Error(`Missing aesthetics for "StatLine": "${n.join(`", "`)}"`);let r=e.group??Array(e.x.length).fill(null),i=Object.values(r.reduce((e,t,n)=>(e[t]??=[],e[t].push(n),e),{})).map(n=>n.map((n,r)=>[e[t][n],r]).sort((e,t)=>e[0]-t[0]).map((e,t)=>n[e[1]])),a=i.map(e=>e.slice(0,-1).concat(NaN)).reduce((e,t)=>e.concat(t),[]).filter(e=>!isNaN(e)),o=i.map(e=>e.slice(1).concat(NaN)).reduce((e,t)=>e.concat(t),[]).filter(e=>!isNaN(e)),s={};for(let t in e)s[t]=a.map(n=>e[t][n]);return s.xend=o.map(t=>e.x[t]),s.yend=o.map(t=>e.y[t]),s},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),tn=x(function(e){if(e.x!=null){let t=[`x`,`ymin`,`ymax`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatLinerange": "${t.join(`", "`)}"`);return(({x:e,ymin:t,ymax:n,...r})=>({x:e,xend:e,y:t,yend:n,...r}))(e)}if(e.y!=null){let t=[`y`,`xmin`,`xmax`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatLinerange": "${t.join(`", "`)}"`);return(({y:e,xmin:t,xmax:n,...r})=>({y:e,yend:e,x:t,xend:n,...r}))(e)}throw Error(`Missing aesthetics for "StatLinerange": x,ymin,ymax or y,xmin,xmax`)},{core_attrs:[`x`,`y`,`xmin`,`xmax`,`ymin`,`ymax`,`xnudge`,`ynudge`]}),nn=x(function(e){let t=[`x`,`y`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatPath": "${t.join(`", "`)}"`);let n=e.group??Array(e.x.length).fill(null),r=Object.values(n.reduce((e,t,n)=>(e[t]??=[],e[t].push(n),e),{})).map(e=>e.map((t,n)=>e[n])),i=r.map(e=>e.slice(0,-1).concat(NaN)).reduce((e,t)=>e.concat(t),[]).filter(e=>!isNaN(e)),a=r.map(e=>e.slice(1).concat(NaN)).reduce((e,t)=>e.concat(t),[]).filter(e=>!isNaN(e)),o={};for(let t in e)o[t]=i.map(n=>e[t][n]);return o.xend=a.map(t=>e.x[t]),o.yend=a.map(t=>e.y[t]),o},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),rn=x(function(e){let t=[`x`,`y`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatPoint": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),an=x(function(e){if(e.points!=null)return e;let t=[`x`,`y`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatPolygon": "${t.join(`", "`)}" or "points"`);let r=Object.keys(e).filter(e=>![`x`,`y`].includes(e)&&!e.startsWith(`$`)),i=a(Object.fromEntries(r.map(t=>[t,e[t]]))),o=a({group:i??Array(e.x.length).fill(0)}).map((e,t,n)=>n.categories[e]),s=Map.groupBy(e.$raw,(e,t)=>o[t]),c=Array.from(s.values()),l=Array.from(s.keys()),u={$raw:c,points:Array.from(Map.groupBy(n({x:e.x,y:e.y}),(e,t)=>o[t]).values())};for(let e of r)u[e]=l.map(e=>e.group).map(t=>i.categories[t][e]);return u},{core_attrs:[`points`,`xnudge`,`ynudge`]}),on=x(function(e){let t=[`xmin`,`xmax`,`ymin`,`ymax`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatRect": "${t.join(`", "`)}"`);return e},{core_attrs:[`xmin`,`xmax`,`ymin`,`ymax`,`xnudge`,`ynudge`]}),sn=x(function(e){e.xend??=e.x,e.yend??=e.y;let t=[`x`,`y`,`xend`,`yend`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatSegment": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`xend`,`yend`,`xnudge`,`ynudge`]}),cn=x(function(e){let t=[`x`,`y`,`points`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatShape": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`points`,`xnudge`,`ynudge`]}),ln=x(function(e){e.dx??=Array(e.x.length).fill(0),e.dy??=Array(e.y.length).fill(0);let t=[`x`,`y`,`dx`,`dy`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatStick": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`dx`,`dy`,`xnudge`,`ynudge`]}),un=x(function(e){let t=[`x`,`y`,`label`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatText": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`,`label`,`textLength`]}),dn=x(function(e){e.xend??=e.x,e.yend??=e.y;let t=[`x`,`y`,`xend`,`yend`,`label`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatTextsegment": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`xend`,`yend`,`xnudge`,`ynudge`,`label`]}),fn=x(function(e){e.width==null&&e.x.some(e=>typeof e==`string`)&&(e.width=Array(e.x.length).fill(1)),e.height==null&&e.y.some(e=>typeof e==`string`)&&(e.height=Array(e.y.length).fill(1));let t=[`x`,`y`,`width`,`height`].filter(t=>e[t]==null);if(t.length>0)throw Error(`Missing aesthetics for "StatTile": "${t.join(`", "`)}"`);return e},{core_attrs:[`x`,`y`,`width`,`height`,`xnudge`,`ynudge`]}),pn=x(function(e,{n:t=512,kernel:n=`gaussian`,scale:o=`width`,position:s=`dodge`,width:c=.9,height:l=.9}={}){let u=[`x`,`y`].filter(t=>e[t]==null);if(u.length>0)throw Error(`Missing aesthetics for "StatViolin": "${u.join(`", "`)}"`);let d=e.x.some(i),f=e.y.some(i);if(d&&f)throw Error(`Both "x" and "y" are discrete, "StatViolin" requires one continuous and one discrete aesthetic`);if(!d&&!f)throw Error(`Both "x" and "y" are continuous, "StatViolin" requires one continuous and one discrete aesthetic`);if(n=hn[n],!n)throw Error(`kernel must be one of ${Object.keys(hn).map(e=>`"${e}"`).join(`, `)}`);let[p,m,h]=d?[`y`,`x`,c]:[`x`,`y`,l],g=e[p],_=Object.keys(e).filter(e=>e!=p&&!e.startsWith(`$`)),v=a(Object.fromEntries(_.map(t=>[t,e[t]]))),y=a({group:v??Array(g.length).fill(0)}).map((e,t,n)=>n.categories[e]),b=Map.groupBy(e.$raw,(e,t)=>y[t]),x=Array.from(b.values()),S=Array.from(b.keys()),C=Array.from(Map.groupBy(g,(e,t)=>y[t]).values()),w={$raw:x,$group:S.map(e=>e.group),[p]:S.map(e=>0)},T=C.map(e=>{let i=mn.nrd0(e),{min:a,max:s}=r.extent(e);a-=3*i,s+=3*i;let c=(s-a)/(t-1),l=Array.from({length:t},(e,t)=>a+t*c),u=l.map(t=>r.mean(e.map(e=>n((t-e)/i)))/i),d=o==`area`?1:1/r.max(u);return l.map((e,t)=>[e,u[t]*d/2])});for(let e of _)w[e]=S.map(t=>v.categories[t.group][e]);if(s==`dodge`){let e=Object.groupBy(w.$group,(e,t)=>v.categories[e][m]),t=w.$group.map(t=>e[v.categories[t][m]]);T=t.map((e,t)=>T[t].map(([t,n])=>[t,n*h/e.length])),d?w.xnudge=t.map((e,t)=>(w.xnudge?.[t]??0)+((e.indexOf(w.$group[t])+.5)/e.length-.5)*c):w.ynudge=t.map((e,t)=>(w.ynudge?.[t]??0)+((e.indexOf(w.$group[t])+.5)/e.length-.5)*l)}else T=T.map(e=>e.map(([e,t])=>[e,t*h]));return w.points=d?T.map(e=>e.map(([e,t])=>({x:t,y:e})).concat(e.map(([e,t])=>({x:-t,y:e})).reverse())):T.map(e=>e.map(([e,t])=>({x:e,y:t})).concat(e.map(([e,t])=>({x:e,y:-t})).reverse())),w},{core_attrs:[`x`,`y`,`xnudge`,`ynudge`]}),mn={nrd0:function(e){e=e.filter(e=>(typeof e==`number`||e instanceof Date)&&isFinite(e));let t=r.sd(e),n=r.quantile(e,.75)-r.quantile(e,.25);return .9*(Math.min(t,n/1.34)||1)*e.length**-.2},nrd:function(e){e=e.filter(e=>(typeof e==`number`||e instanceof Date)&&isFinite(e));let t=r.sd(e),n=r.quantile(e,.75)-r.quantile(e,.25);return 1.06*(Math.min(t,n/1.34)||1)*e.length**-.2}},hn={uniform:e=>Math.abs(e)<=1?.5:0,triangular:e=>Math.abs(e)<=1?1-Math.abs(e):0,epanechnikov:e=>Math.abs(e)<=1?.75*(1-e**2):0,biweight:e=>Math.abs(e)<=1?15/16*(1-e**2)**2:0,triweight:e=>Math.abs(e)<=1?35/32*(1-e**2)**3:0,tricube:e=>Math.abs(e)<=1?70/81*(1-Math.abs(e)**3)**3:0,gaussian:e=>Math.exp(-.5*e**2)/Math.sqrt(2*Math.PI),cosine:e=>Math.abs(e)<=1?Math.PI/4*Math.cos(Math.PI/2*e):0,logistic:e=>1/Math.cosh(e)**2/Math.PI,sigmoid:e=>2/(Math.exp(e)+Math.exp(-e))**2/Math.PI},gn=/* @__PURE__ */ e({bar:()=>Wt,boxplot:()=>Gt,col:()=>Kt,curve:()=>qt,density:()=>Jt,ellipse:()=>Zt,histogram:()=>Qt,identity:()=>$t,line:()=>en,linerange:()=>tn,path:()=>nn,point:()=>rn,polygon:()=>an,rect:()=>on,segment:()=>sn,shape:()=>cn,stick:()=>ln,text:()=>un,textsegment:()=>dn,tile:()=>fn,violin:()=>pn}),_n={class:`vvplot-layer vvplot-layer-blank`},vn={__name:`BlankSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){return(e,t)=>(K(),B(`g`,_n))}},yn={__name:`Blank`,props:{data:Object,render:String,dpi:Number},setup(e){return(t,n)=>(K(),R(vn,{data:e.data},null,8,[`data`]))}},bn={class:`vvplot-layer vvplot-layer-boxplot`},xn={__name:`BoxplotSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,xmin:s,xmax:c,y:l,ymin:u,ymax:d,lwisker:f,Q1:p,median:m,Q3:h,uwisker:g,outliers:_,$xmin:v,$xmax:y,$ymin:b,$ymax:x,fill:S=`white`,color:C=`black`,linewidth:w,linetype:T,alpha:E,title:D,translateX:O=0,translateY:k=0,class:A,style:j,$raw:M})=>{let{hmin:N,hmax:ee,vmin:P,vmax:I}=e.mapping.coord2pos({xmin:v,xmax:y,ymin:b,ymax:x});if(N<t&&ee<t||N>r&&ee>r||P<i&&I<i||P>a&&I>a)return null;let{hmin:L,hmax:R,vmin:z,vmax:B}=e.mapping.coord2pos(o==null?{ymin:u,ymax:d,xmin:p,xmax:h}:{xmin:s,xmax:c,ymin:p,ymax:h}),{h:te,v:V}=e.mapping.coord2pos(o==null?{y:l,x:f}:{x:o,y:f}),{h:H,v:U}=e.mapping.coord2pos(o==null?{y:l,x:g}:{x:o,y:g}),{h:W,v:G}=e.mapping.coord2pos(o==null?{y:u,x:m}:{x:s,y:m}),{h:K,v:q}=e.mapping.coord2pos(o==null?{y:d,x:m}:{x:c,y:m}),{h:ne,v:J}=e.mapping.coord2pos(o==null?{y:u*.25+d*.75,x:g}:{x:s*.25+c*.75,y:g}),{h:Y,v:X}=e.mapping.coord2pos(o==null?{y:u*.75+d*.25,x:g}:{x:s*.75+c*.25,y:g}),{h:Z,v:re}=e.mapping.coord2pos(o==null?{y:u*.25+d*.75,x:f}:{x:s*.25+c*.75,y:f}),{h:ie,v:Q}=e.mapping.coord2pos(o==null?{y:u*.75+d*.25,x:f}:{x:s*.75+c*.25,y:f});return[{rect:{x:(L+R)/2,width:R-L,y:(z+B)/2,height:B-z,fill:S,color:C,linetype:T,linewidth:w,alpha:E,title:D,translateX:O,translateY:k,class:A,style:j},line:{x1:te,y1:V,x2:H,y2:U,color:C,linetype:T,linewidth:w,alpha:E,translateX:O,translateY:k,class:A,style:j},midline:{x1:W,y1:G,x2:K,y2:q,color:C,linetype:T,linewidth:(w??1)*2,alpha:E,translateX:O,translateY:k,class:A,style:j},uwisker:{x1:ne,y1:J,x2:Y,y2:X,color:C,linetype:T,linewidth:w,alpha:E,translateX:O,translateY:k,class:A,style:j},lwisker:{x1:Z,y1:re,x2:ie,y2:Q,color:C,linetype:T,linewidth:w,alpha:E,translateX:O,translateY:k,class:A,style:j},outliers:_?.map(({x:t,y:r,$raw:i})=>{let{h:a,v:o}=e.mapping.coord2pos({x:t,y:r});return[{x:a,y:o,shape:`circle`,size:4,color:C,alpha:E,translateX:O,translateY:k,class:A,style:j},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),i)]))]})},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),M)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,bn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),B(`g`,null,[H(d,W({ref_for:!0},e.line),null,16),n[0]||=V(),H(c,W({ref_for:!0},e.rect,J(t)),null,16),n[1]||=V(),H(d,W({ref_for:!0},e.midline),null,16),n[2]||=V(),H(d,W({ref_for:!0},e.uwisker),null,16),n[3]||=V(),H(d,W({ref_for:!0},e.lwisker),null,16),n[4]||=V(),(K(!0),B(I,null,q(e.outliers,([e,t])=>(K(),R(M,W({ref_for:!0},e,J(t)),null,16))),256))]))),256))],16))),256))]))}},Sn={__name:`BoxplotCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{x:t,xmin:r,xmax:i,y:a,ymin:s,ymax:c,lwisker:l,Q1:u,median:d,Q3:f,uwisker:p,outliers:m,$xmin:h,$xmax:g,$ymin:_,$ymax:v,fill:y=`white`,color:b=`black`,linewidth:x=1,linetype:S,alpha:C,translateX:w=0,translateY:T=0,$raw:E}of e.data){let{hmin:h,hmax:g,vmin:_,vmax:v}=e.mapping.coord2pos(t==null?{ymin:s,ymax:c,xmin:u,xmax:f}:{xmin:r,xmax:i,ymin:u,ymax:f}),{h:D,v:O}=e.mapping.coord2pos(t==null?{y:a,x:l}:{x:t,y:l}),{h:k,v:A}=e.mapping.coord2pos(t==null?{y:a,x:p}:{x:t,y:p}),{h:j,v:M}=e.mapping.coord2pos(t==null?{y:s,x:d}:{x:r,y:d}),{h:N,v:ee}=e.mapping.coord2pos(t==null?{y:c,x:d}:{x:i,y:d}),{h:F,v:I}=e.mapping.coord2pos(t==null?{y:s*.25+c*.75,x:p}:{x:r*.25+i*.75,y:p}),{h:L,v:R}=e.mapping.coord2pos(t==null?{y:s*.75+c*.25,x:p}:{x:r*.75+i*.25,y:p}),{h:z,v:B}=e.mapping.coord2pos(t==null?{y:s*.25+c*.75,x:l}:{x:r*.25+i*.75,y:l}),{h:te,v:V}=e.mapping.coord2pos(t==null?{y:s*.75+c*.25,x:l}:{x:r*.75+i*.25,y:l});n.globalAlpha=C,n.setLineDash(P(S));let H=new Path2D;H.moveTo(D+w,O+T),H.lineTo(k+w,A+T);let U=new Path2D;U.moveTo(F+w,I+T),U.lineTo(L+w,R+T),U.moveTo(z+w,B+T),U.lineTo(te+w,V+T);let W=new Path2D;W.rect(h+w,_+T,g-h,v-_),o.set(W,E);let G=new Path2D;G.moveTo(j+w,M+T),G.lineTo(N+w,ee+T),b!=null&&b!==`none`&&(n.strokeStyle=b,n.lineWidth=x,n.stroke(H),n.stroke(U)),y!==`none`&&(n.fillStyle=y,n.fill(W)),b!=null&&b!==`none`&&(n.stroke(W),n.lineWidth=x*2,n.stroke(G));for(let{x:t,y:r,$raw:i}of m){let{h:a,v:s}=e.mapping.coord2pos({x:t,y:r}),c=new Path2D;c.arc(a+w,s+T,2,0,Math.PI*2),b!=null&&b!==`none`&&(n.fillStyle=b,n.fill(c)),o.set(c,i)}}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},Cn={__name:`Boxplot`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(Sn,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(xn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},wn={class:`vvplot-layer vvplot-layer-curve`},Tn={__name:`CurveSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({points:o,interpolate:s,fill:c,color:l,linewidth:u,linetype:d,alpha:f,title:p,translateX:m=0,translateY:h=0,markerStart:g,markerEnd:_,class:v,style:y,$raw:b})=>(o=o.map(t=>(({h:e,v:t})=>({x:e,y:t}))(e.mapping.coord2pos(t))),o.every(e=>e.x<t)||o.every(e=>e.x>r)||o.every(e=>e.y<i)||o.every(e=>e.y>a)?null:[{points:o,fill:c,color:l,linetype:d,linewidth:u,alpha:f,title:p,translateX:m,translateY:h,"marker-start":g,"marker-end":_,class:v,style:y,interpolate:s},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),b)]))])).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,wn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(nt,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},En={__name:`CurveCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let{points:t,interpolate:r,fill:i,color:a,linewidth:c,linetype:l,alpha:u,translateX:d=0,translateY:f=0,$raw:p}of e.data){if(t=t.map(t=>(({h:e,v:t})=>({x:e,y:t}))(e.mapping.coord2pos(t))).filter(e=>e.x!=null&&e.y!=null),t.length===0)continue;let m=new Path2D,h=(typeof r==`function`?r:s[r]??$e)(m);h.lineStart();for(let e=0;e<t.length;e++)h.point(t[e].x+d,t[e].y+f);h.lineEnd(),o.set(m,p),n.lineWidth=c,n.globalAlpha=u,n.setLineDash(P(l)),i!==`none`&&(n.fillStyle=i,n.fill(m)),a!=null&&a!==`none`&&(n.strokeStyle=a,n.stroke(m))}for(let e of Array.from(o.keys()).reverse())c.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),s=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of c)if(n.isPointInPath(t,s,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)});let s={cardinal:Pe,cardinalClosed:Ie,catmullRom:Be,catmullRomClosed:He,linear:xe,linearClosed:Ge,natural:$e};return(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},Dn={__name:`Curve`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(En,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(Tn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},On={class:`vvplot-layer vvplot-layer-ellipse`},kn={__name:`EllipseSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({cx:o,cy:s,A:c,B:l,C:u,fill:d,color:f,linewidth:p,linetype:m,alpha:h,title:g,translateX:_=0,translateY:v=0,class:y,style:b,$raw:x})=>{let S=Math.sqrt(u/(c*u-l*l)),C=Math.sqrt(c/(c*u-l*l)),{h:w,v:T}=e.mapping.coord2pos({x:o,y:s}),{h:E,v:D}=e.mapping.coord2pos({x:o-S,y:s-C}),{h:O,v:k}=e.mapping.coord2pos({x:o+S,y:s+C});if(E<t&&O<t||O>r&&E>r||D<i&&k<i||k>a&&D>a)return null;let A=(O-E)/(2*S),j=(k-D)/(2*C);c/=A*A,l/=A*j,u/=j*j;let M=c+u,N=c*u-l*l,ee=Math.sqrt(Math.max(0,M*M/4-N));return[{cx:w,cy:T,rx:1/Math.sqrt(M/2+ee)||0,ry:1/Math.sqrt(M/2-ee)||0,angle:Math.atan2(2*l,c-u)/2*180/Math.PI||0,fill:d,color:f,linetype:m,linewidth:p,alpha:h,title:g,translateX:_,translateY:v,class:y,style:b},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),x)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,On,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(it,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},An={__name:`EllipseCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{cx:t,cy:r,A:i,B:a,C:s,fill:c,color:l,linewidth:u,linetype:d,alpha:f,translateX:p=0,translateY:m=0,$raw:h}of e.data){let g=Math.sqrt(s/(i*s-a*a)),_=Math.sqrt(i/(i*s-a*a)),{h:v,v:y}=e.mapping.coord2pos({x:t,y:r}),{h:b,v:x}=e.mapping.coord2pos({x:t-g,y:r-_}),{h:S,v:C}=e.mapping.coord2pos({x:t+g,y:r+_}),w=(S-b)/(2*g),T=(C-x)/(2*_);i/=w*w,a/=w*T,s/=T*T;let E=i+s,D=i*s-a*a,O=Math.sqrt(Math.max(0,E*E/4-D)),k=1/Math.sqrt(E/2+O),A=1/Math.sqrt(E/2-O),j=Math.atan2(2*a,i-s)/2,M=new Path2D;M.ellipse(v+p,y+m,k,A,j,0,2*Math.PI),o.set(M,h),n.lineWidth=u,n.globalAlpha=f,n.setLineDash(P(d)),c!==`none`&&(n.fillStyle=c,n.fill(M)),l!=null&&l!==`none`&&(n.strokeStyle=l,n.stroke(M))}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},jn={__name:`Ellipse`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(An,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(kn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},Mn={class:`vvplot-layer vvplot-layer-line`},Nn={__name:`LineSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,y:s,xend:c,yend:l,color:u=`black`,linewidth:d,linetype:f,alpha:p,title:m,translateX:h=0,translateY:g=0,markerStart:_,markerEnd:v,class:y,style:b,$raw:x})=>{let{h:S,v:C}=e.mapping.coord2pos({x:o,y:s}),{h:w,v:T}=e.mapping.coord2pos({x:c,y:l});return S<t&&w<t||S>r&&w>r||C<i&&T<i||C>a&&T>a?null:[{x1:S,x2:w,y1:C,y2:T,color:u,linetype:f,linewidth:d,alpha:p,title:m,translateX:h,translateY:g,"marker-start":_,"marker-end":v,class:y,style:b},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),x)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,Mn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(d,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Pn={__name:`LineCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{x:t,y:r,xend:i,yend:a,color:s=`black`,linewidth:c,alpha:l,linetype:u,translateX:d=0,translateY:f=0,$raw:p}of e.data){let{h:m,v:h}=e.mapping.coord2pos({x:t,y:r}),{h:g,v:_}=e.mapping.coord2pos({x:i,y:a}),v=new Path2D;v.moveTo(m+d,h+f),v.lineTo(g+d,_+f),o.set(v,p),n.lineWidth=c,n.globalAlpha=l,n.setLineDash(P(u)),s!=null&&s!==`none`&&(n.strokeStyle=s,n.stroke(v))}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},Fn={__name:`Line`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(Pn,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(Nn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},In={class:`vvplot-layer vvplot-layer-markdown`},Ln={__name:`MarkdownSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,y:s,size:c=4,label:l,title:u,color:d,stroke:f,linewidth:p,linetype:m,alpha:h,anchorX:g,anchorY:_,dockX:v,dockY:y,translateX:b=0,translateY:x=0,angle:S,textLength:C,fontFamily:w=`sans-serif`,textAnchor:T,class:E,style:D,$raw:O})=>{if(l==null)return null;let{h:k,v:A}=e.mapping.coord2pos({x:o,y:s});if(k<t||k>r||A<i||A>a)return null;if(typeof C==`object`){let{x:t=0,y:n=0}=C,{h:r,v:i}=e.mapping.coord2pos({x:o+t/2,y:s+n/2}),{h:a,v:c}=e.mapping.coord2pos({x:o-t/2,y:s-n/2});C=Math.hypot(r-a||0,i-c||0)}if(typeof S==`object`){let{dx:t=0,dy:n=0}=S,{h:r,v:i}=e.mapping.coord2pos({x:o+t,y:s+n});S=Math.atan2(i-A,r-k)*180/Math.PI}return[{x:k,y:A,text:String(l),title:String(u??l),size:c,color:d,stroke:f,linetype:m,linewidth:p,alpha:h,angle:S,translateX:b,translateY:x,class:E,style:D,anchorX:g,anchorY:_,dockX:v,dockY:y,textLength:C,fontFamily:w,textAnchor:T},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),O)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,In,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(s,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Rn={__name:`Markdown`,props:{data:Object,render:String,dpi:Number},setup(e){return(t,n)=>(K(),R(Ln,{data:e.data},null,8,[`data`]))}},zn={class:`vvplot-layer vvplot-layer-segment`},Bn={__name:`MarkdownsegmentSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,xend:s,y:c,yend:l,size:u=4,label:d,title:f,color:p,stroke:m,linewidth:h,linetype:g,alpha:_,anchorX:v,anchorY:y=.5,translateX:b=0,translateY:x=0,fontFamily:S=`sans-serif`,textAlign:C=`start`,inset:w=0,class:T,style:E,$raw:D})=>{if(d==null)return null;let{h:O,v:k}=e.mapping.coord2pos({x:o,y:c}),{h:A,v:j}=e.mapping.coord2pos({x:s,y:l});if(O<t&&A<t||O>r&&A>r||k<i&&j<i||k>a&&j>a)return null;let M=Math.atan2(j-k,A-O),N={text:String(d),title:String(f??d),color:p,alpha:_,size:u,stroke:m,linewidth:h,linetype:g,fontFamily:S,class:T,style:E},ee=Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),D)])),P,I;switch(C){case`stretch`:P=(O+A)/2,I=(k+j)/2,v=.5,N.textLength=Math.hypot(A-O||0,j-k||0);break;case`center`:P=(O+A)/2,I=(k+j)/2,v??=.5;break;case`pre`:P=O,I=k,b-=Math.cos(M)*w,x-=Math.sin(M)*w,v??=1;break;case`end`:P=A,I=j,b-=Math.cos(M)*w,x-=Math.sin(M)*w,v??=1;break;case`post`:P=A,I=j,b+=Math.cos(M)*w,x+=Math.sin(M)*w,v??=0;break;default:P=O,I=k,b+=Math.cos(M)*w,x+=Math.sin(M)*w,v??=0}return Object.assign(N,{x:P,y:I,translateX:b,translateY:x,anchorX:v,anchorY:y,angle:M*180/Math.PI}),[N,ee]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,zn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(s,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Vn={__name:`Markdownsegment`,props:{data:Object,render:String,dpi:Number},setup(e){return(t,n)=>(K(),R(Bn,{data:e.data},null,8,[`data`]))}},Hn={class:`vvplot-layer vvplot-layer-point`},Un={__name:`PointSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,y:s,shape:c,size:l=6,color:u,stroke:d,linetype:f,linewidth:p,alpha:m,title:h,translateX:g=0,translateY:_=0,angle:v,class:y,style:b,$raw:x})=>{let{h:S,v:C}=e.mapping.coord2pos({x:o,y:s});if(S<t||S>r||C<i||C>a)return null;if(typeof v==`object`){let{dx:t=0,dy:n=0}=v,{h:r,v:i}=e.mapping.coord2pos({x:o+t,y:s+n});v=Math.atan2(i-C,r-S)*180/Math.PI}return[{x:S,y:C,shape:c,size:l,color:u,stroke:d,linetype:f,linewidth:p,alpha:m,title:h,angle:v,translateX:g,translateY:_,class:y,style:b},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),x)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,Hn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(M,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Wn={__name:`PointCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i={triangle:e=>`M0-${e*2/3}L${e*.577},${e/3}L-${e*.577},${e/3}Z`,diamond:e=>`M0-${e*.707}L${e*.707},0L0,${e*.707}L-${e*.707},0Z`,square:e=>`M-${e/2}-${e/2}H${e/2}V${e/2}H-${e/2}Z`,plus:e=>`M-${e/10}-${e/2}V-${e/10}H-${e/2}V${e/10}H-${e/10}V${e/2}H${e/10}V${e/10}H${e/2}V-${e/10}H${e/10}V-${e/2}H-${e/10}Z`,cross:e=>`M-${e*.283}-${e*.424}L-${e*.424}-${e*.283}L-${e*.141},0L-${e*.424},${e*.283}L-${e*.283},${e*.424}L0,${e*.141}L${e*.283},${e*.424}L${e*.424},${e*.283}L${e*.141},0L${e*.424},-${e*.283}L${e*.283},-${e*.424}L0,-${e*.141}Z`,arrowhead:e=>`M0,0L${e},${-e*.38}V${e*.38}Z`},a=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),o=X(`container`),s=L(()=>{if(o.value==null)return;let t=document.createElement(`canvas`);t.style.width=a.value.width+`px`,t.style.height=a.value.height+`px`,t.width=a.value.width*e.dpi/96,t.height=a.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let{x:t,y:r,size:a=6,shape:o,color:c,stroke:l,linewidth:u,linetype:d,alpha:f,translateX:p=0,translateY:m=0,angle:h=0,$raw:g}of e.data){let{h:_,v}=e.mapping.coord2pos({x:t,y:r});if(typeof h==`object`){let{dx:n=0,dy:i=0}=h,{h:a,v:o}=e.mapping.coord2pos({x:t+n,y:r+i});h=Math.atan2(o-v,a-_)*180/Math.PI}let y=new Path2D;String(o).startsWith(`path:`)?y.addPath(new Path2D(o.slice(5)),new DOMMatrix().translateSelf(_+p,v+m).rotate(h)):o in i?y.addPath(new Path2D(i[o](a)),new DOMMatrix().translate(_+p,v+m).rotate(h)):y.arc(_+p,v+m,a/2,0,Math.PI*2),s.set(y,g),n.lineWidth=u,n.globalAlpha=f,n.beginPath(),c!==`none`&&(n.fillStyle=c,n.fill(y)),l!=null&&l!==`none`&&(n.strokeStyle=l,n.setLineDash(P(d)),n.stroke(y))}for(let e of Array.from(s.keys()).reverse())c.set(e,s.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),s=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of c)if(n.isPointInPath(t,s,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(s,e=>o.value.replaceChildren(e)),t({dispatchEvent:e=>s.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},a.value,{ref:`container`}),null,16))}},Gn={__name:`Point`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(Wn,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(Un,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},Kn={class:`vvplot-layer vvplot-layer-polygon`},qn={__name:`PolygonSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({points:o,fill:s,color:c,linewidth:l,linetype:u,alpha:d,title:f,translateX:p=0,translateY:m=0,markerStart:h,markerMid:g,markerEnd:_,class:v,style:y,$raw:b})=>(o=o.map(t=>(({h:e,v:t})=>({x:e,y:t}))(e.mapping.coord2pos(t))),o.every(e=>e.x<t)||o.every(e=>e.x>r)||o.every(e=>e.y<i)||o.every(e=>e.y>a)?null:[{points:o,fill:s,color:c,linewidth:l,linetype:u,alpha:d,title:f,translateX:p,translateY:m,"marker-start":h,"marker-mid":g,"marker-end":_,class:v,style:y},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),b)]))])).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,Kn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(ot,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Jn={__name:`PolygonCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{points:t,fill:r,color:i,linewidth:a,linetype:s,alpha:c,translateX:l=0,translateY:u=0,$raw:d}of e.data){if(t=t.map(t=>(({h:e,v:t})=>({x:e,y:t}))(e.mapping.coord2pos(t))).filter(e=>e.x!=null&&e.y!=null),t.length===0)continue;let f=new Path2D;f.moveTo(t[0].x+l,t[0].y+u);for(let e=1;e<t.length;e++)f.lineTo(t[e].x+l,t[e].y+u);f.closePath(),o.set(f,d),n.lineWidth=a,n.globalAlpha=c,n.setLineDash(P(s)),r!==`none`&&(n.fillStyle=r,n.fill(f)),i!=null&&i!==`none`&&(n.strokeStyle=i,n.stroke(f))}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},Yn={__name:`Polygon`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(Jn,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(qn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},Xn={class:`vvplot-layer vvplot-layer-rect`},Zn={__name:`RectSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({xmin:o,xmax:s,ymin:c,ymax:l,fill:u,color:d,linewidth:f,linetype:p,alpha:m,title:h,translateX:g=0,translateY:_=0,class:v,style:y,$raw:b})=>{let{hmin:x,hmax:S,vmin:C,vmax:w}=e.mapping.coord2pos({xmin:o,xmax:s,ymin:c,ymax:l});return x<t&&S<t||x>r&&S>r||C<i&&w<i||C>a&&w>a?null:[{x:(x+S)/2,width:S-x,y:(C+w)/2,height:w-C,fill:u,color:d,linetype:p,linewidth:f,alpha:m,title:h,translateX:g,translateY:_,class:v,style:y},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),b)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,Xn,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(c,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},Qn={__name:`RectCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{xmin:t,xmax:r,ymin:i,ymax:a,fill:s,color:c,linewidth:l,linetype:u,alpha:d,translateX:f=0,translateY:p=0,$raw:m}of e.data){let{hmin:h,hmax:g,vmin:_,vmax:v}=e.mapping.coord2pos({xmin:t,xmax:r,ymin:i,ymax:a}),y=new Path2D;y.rect(h+f,_+p,g-h,v-_),o.set(y,m),n.lineWidth=l,n.globalAlpha=d,n.setLineDash(P(u)),s!==`none`&&(n.fillStyle=s,n.fill(y)),c!==`none`&&c!=null&&(n.strokeStyle=c,n.stroke(y))}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},$n={__name:`Rect`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(Qn,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(Zn,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},er={class:`vvplot-layer vvplot-layer-text`},tr={__name:`TextSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,i=-e.layout.fullHeight*e.extendY-e.layout.t,a=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(o=>o.map(({x:o,y:s,size:c=4,label:l,title:u,color:d,stroke:f,linewidth:p,linetype:m,alpha:h,anchorX:g,anchorY:_,dockX:v,dockY:y,translateX:b=0,translateY:x=0,angle:S,textLength:C,fontFamily:w,textAnchor:T,class:E,style:D,$raw:O})=>{if(l==null)return null;let{h:k,v:A}=e.mapping.coord2pos({x:o,y:s});if(k<t||k>r||A<i||A>a)return null;if(typeof C==`object`){let{x:t=0,y:n=0}=C,{h:r,v:i}=e.mapping.coord2pos({x:o+t/2,y:s+n/2}),{h:a,v:c}=e.mapping.coord2pos({x:o-t/2,y:s-n/2});C=Math.hypot(r-a||0,i-c||0)}if(typeof S==`object`){let{dx:t=0,dy:n=0}=S,{h:r,v:i}=e.mapping.coord2pos({x:o+t,y:s+n});S=Math.atan2(i-A,r-k)*180/Math.PI}return[{x:k,y:A,text:String(l),title:String(u??l),size:c,color:d,stroke:f,linetype:m,linewidth:p,alpha:h,angle:S,translateX:b,translateY:x,class:E,style:D,anchorX:g,anchorY:_,dockX:v,dockY:y,textLength:C,fontFamily:w,textAnchor:T},Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),O)]))]}).filter(e=>e!=null))});return(t,n)=>(K(),B(`g`,er,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t])=>(K(),R(l,W({ref_for:!0},e,J(t)),null,16))),256))],16))),256))]))}},nr={__name:`TextCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let{x:t,y:r,color:i,size:a=4,label:o=``,title:s,stroke:c,linewidth:l,linetype:u,alpha:d,anchorX:f,anchorY:p,dockX:m,dockY:h,translateX:g=0,translateY:_=0,angle:v,textLength:y,fontFamily:b=`sans-serif`,$raw:x}of e.data){n.save();let{h:s,v:x}=e.mapping.coord2pos({x:t,y:r});n.textAlign=`center`,n.textBaseline=`middle`,n.lineWidth=l,n.globalAlpha=d,n.font=`${a*4}px ${b}`,n.setLineDash(P(u)),n.translate(s+g,x+_);let{width:S,fontBoundingBoxAscent:C,fontBoundingBoxDescent:w}=n.measureText(o),T=S,E=C+w;if(typeof y==`object`){let{x:n=0,y:i=0}=y,{h:a,v:o}=e.mapping.coord2pos({x:t+n/2,y:r+i/2}),{h:s,v:c}=e.mapping.coord2pos({x:t-n/2,y:r-i/2});T=Math.hypot(a-s||0,o-c||0)}else y!=null&&(T=y);if(typeof v==`object`){let{dx:n=0,dy:i=0}=v,{h:a,v:o}=e.mapping.coord2pos({x:t+n,y:r+i});v=Math.atan2(o-x,a-s)*180/Math.PI}if(m!=null||h!=null){let e={left:0,center:.5,right:1}[m]??+(m??.5),t={bottom:0,center:.5,top:1}[h]??+(h??.5);isNaN(e)&&(e=.5),isNaN(t)&&(t=.5);let r=T*Math.abs(Math.cos(v*Math.PI/180))+E*Math.abs(Math.sin(v*Math.PI/180)),i=T*Math.abs(Math.sin(v*Math.PI/180))+E*Math.abs(Math.cos(v*Math.PI/180));n.translate(r*(.5-e),i*(t-.5)),n.rotate(v*Math.PI/180)}else{let e={left:0,center:.5,right:1}[f]??+(f??.5),t={bottom:0,center:.5,top:1}[p]??+(p??.5);isNaN(e)&&(e=.5),isNaN(t)&&(t=.5);let r=T,i=E;n.rotate(v*Math.PI/180),n.translate(r*(.5-e),i*(t-.5))}T!=S&&n.scale(T/S,1),i!==`none`&&(n.fillStyle=i,n.fillText(o,0,0)),c!=null&&c!==`none`&&(n.strokeStyle=c,n.strokeText(o,0,0)),n.restore()}for(let e of Array.from(o.keys()).reverse())s.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),c=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of s)if(n.isPointInPath(t,c,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});return Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)}),(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},rr={__name:`Text`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(nr,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(tr,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},ir={class:`vvplot-layer vvplot-layer-textsegment`},ar={__name:`TextsegmentSvg`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,groupClass:null,groupStyle:null},emits:F,setup(e,{emit:t}){let n=t,r=L(()=>{let t=-e.layout.fullWidth*e.extendX-e.layout.l,r=e.layout.fullWidth*(1+e.extendX)-e.layout.l,a=-e.layout.fullHeight*e.extendY-e.layout.t,o=e.layout.fullHeight*(1+e.extendY)-e.layout.t;return Object.values(Object.groupBy(e.data,e=>e.$group)).map(s=>s.map(({x:s,xend:c,y:l,yend:u,size:d=4,label:f,title:p,color:m,stroke:h,linewidth:g,linetype:_,alpha:v,translateX:y=0,translateY:b=0,fontFamily:x=`sans-serif`,textAlign:S=`justify`,angle:C=`auto`,inset:w=0,class:T,style:E,$raw:D})=>{if(f==null)return null;let{h:O,v:k}=e.mapping.coord2pos({x:s,y:l}),{h:A,v:j}=e.mapping.coord2pos({x:c,y:u});if(O<t&&A<t||O>r&&A>r||k<a&&j<a||k>o&&j>o)return null;let M={color:m||null,fill:m||null,"fill-opacity":v==1?null:v,"font-size":d*4,stroke:h||null,"stroke-width":g,"stroke-dasharray":P(_).join(` `)||null,"stroke-opacity":v==1?null:v,"font-family":x,class:T,style:E},N=Object.fromEntries(F.map(t=>[t,r=>n(t,Object.assign(r,{_vhandled:!0}),e.mapping.getCoord(r),D)]));if([`stretch`,`pre`,`start`,`center`,`end`,`post`].includes(S)){let e=Math.atan2(j-k,A-O),t,n,r=String(f).replace(/\x01|\x02/g,``),i=Math.cos(e)*w,a=Math.sin(e)*w;switch(S){case`stretch`:t=(O+A)/2,n=(k+j)/2,M[`text-anchor`]=`middle`,M.textLength=Math.hypot(A-O||0,j-k||0),M.lengthAdjust=`spacingAndGlyphs`;break;case`center`:t=(O+A)/2,n=(k+j)/2,M[`text-anchor`]=`middle`;break;case`pre`:t=O,n=k,y-=i,b-=a,M[`text-anchor`]=`end`;break;case`start`:t=O,n=k,y+=i,b+=a,M[`text-anchor`]=`start`;break;case`end`:t=A,n=j,y-=i,b-=a,M[`text-anchor`]=`end`;break;case`post`:t=A,n=j,y+=i,b+=a,M[`text-anchor`]=`start`}let o=[];return(y||b)&&o.push(`translate(${y}, ${b})`),e&&o.push(`rotate(${e*180/Math.PI})`),Object.assign(M,{x:t,y:n,"dominant-baseline":`central`,"transform-origin":`${t} ${n}`,transform:o.join(` `)||null}),[M,N,r,String(p??String(f).replace(/\x01|\x02/g,``))]}{C===`auto`&&(C=Math.atan2(j-k,A-O)*180/Math.PI);let e=i(String(f)),t=(A-O)/(e.length-1||1),n=(j-k)/(e.length-1||1),r=e.map((e,r)=>[{x:O+r*t,y:k+r*n,"text-anchor":`middle`,"dominant-baseline":`central`,rotate:C},e]);return(y||b)&&(M.transform=`translate(${y}, ${b})`),[M,N,r,String(p??String(f).replace(/\x01|\x02/g,``))]}}).filter(e=>e!=null))});function i(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]==``){let r=n+1;for(;r<e.length&&e[r]!=``;)r++;t.push(e.slice(n+1,r)),n=r}else t.push(e[n]);return t}return(t,n)=>(K(),B(`g`,ir,[(K(!0),B(I,null,q(r.value,t=>(K(),B(`g`,W({class:`vvplot-group`},{ref_for:!0},{class:e.groupClass,style:e.groupStyle}),[(K(!0),B(I,null,q(t,([e,t,r,i])=>(K(),B(`text`,W({ref_for:!0},e,J(t,!0)),[te(`title`,null,ne(i),1),n[0]||=V(),typeof r==`string`?(K(),B(I,{key:0},[V(ne(r.replace(/ /g,`\xA0`)),1)],64)):(K(!0),B(I,{key:1},q(r,([e,t])=>(K(),B(I,null,[t?(K(),B(`tspan`,W({key:0,ref_for:!0},e),ne(t),17)):z(``,!0)],64))),256))],16))),256))],16))),256))]))}},or={__name:`TextsegmentCanvas`,props:{extendX:{type:Number,default:0},extendY:{type:Number,default:0},data:Object,mapping:Object,layout:Object,options:Object,dpi:{type:Number,default:96},groupClass:null,groupStyle:null},emits:F,setup(e,{expose:t,emit:n}){let r=n,i=L(()=>({width:e.layout.fullWidth*(1+e.extendX*2),height:e.layout.fullHeight*(1+e.extendY*2),x:-e.layout.l-e.layout.fullWidth*e.extendX,y:-e.layout.t-e.layout.fullHeight*e.extendY})),a=X(`container`),o=L(()=>{if(a.value==null)return;let t=document.createElement(`canvas`);t.style.width=i.value.width+`px`,t.style.height=i.value.height+`px`,t.width=i.value.width*e.dpi/96,t.height=i.value.height*e.dpi/96;let n=t.getContext(`2d`);n.clearRect(0,0,t.width,t.height),n.scale(e.dpi/96,e.dpi/96),n.translate(e.layout.l+e.layout.fullWidth*e.extendX,e.layout.t+e.layout.fullHeight*e.extendY);let o=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let{x:t,xend:r,y:i,yend:a,size:o=4,label:c=``,title:l,color:u,stroke:d,linewidth:f,linetype:p,alpha:m,translateX:h=0,translateY:g=0,textLength:_,fontFamily:v=`sans-serif`,textAlign:y=`justify`,angle:b=`auto`,inset:x=0,$raw:S}of e.data){let{h:l,v:_}=e.mapping.coord2pos({x:t,y:i}),{h:S,v:C}=e.mapping.coord2pos({x:r,y:a});if(n.save(),n.translate(h,g),n.textBaseline=`middle`,n.lineWidth=f,n.globalAlpha=m,n.font=`${o*4}px ${v}`,n.setLineDash(P(p)),[`stretch`,`pre`,`start`,`center`,`end`,`post`].includes(y)){let e=Math.atan2(C-_,S-l),t=String(c).replace(/\x01|\x02/g,``),r=Math.cos(e)*x,i=Math.sin(e)*x;switch(y){case`stretch`:case`center`:n.translate((l+S)/2,(_+C)/2),n.textAlign=`center`;break;case`pre`:n.translate(l-r,_-i),n.textAlign=`end`;break;case`start`:n.translate(l+r,_+i),n.textAlign=`start`;break;case`end`:n.translate(S-r,C-i),n.textAlign=`end`;break;case`post`:n.translate(S+r,C+i),n.textAlign=`start`}n.rotate(e),y===`stretch`&&n.scale(Math.hypot(S-l||0,C-_||0)/n.measureText(t).width,1),u!==`none`&&(n.fillStyle=u,n.fillText(t,0,0)),d!=null&&d!==`none`&&(n.strokeStyle=d,n.strokeText(t,0,0))}else{let e=b===`auto`?Math.atan2(C-_,S-l):b*Math.PI/180;n.textAlign=`center`;let t=s(String(c)),r=(S-l)/(t.length-1||1),i=(C-_)/(t.length-1||1);for(let a=0;a<t.length;a++){n.save(),n.translate(l+a*r,_+a*i),n.rotate(e);let o=t[a];u!==`none`&&(n.fillStyle=u,n.fillText(o,0,0)),d!=null&&d!==`none`&&(n.strokeStyle=d,n.strokeText(o,0,0)),n.restore()}}n.restore()}for(let e of Array.from(o.keys()).reverse())c.set(e,o.get(e));for(let i of F)t.addEventListener(i,function(a){if(a._vhandled)return;let o=t.getBoundingClientRect(),s=(a.clientX-o.left)*t.width/o.width,l=(a.clientY-o.top)*t.height/o.height;for(let[t,o]of c)if(n.isPointInPath(t,s,l)){r(i,a,e.mapping.getCoord(a),o),a._vhandled=!0;break}});return t});Z(o,e=>a.value.replaceChildren(e)),t({dispatchEvent:e=>o.value?.dispatchEvent?.(e)});function s(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]==``){let r=n+1;for(;r<e.length&&e[r]!=``;)r++;t.push(e.slice(n+1,r)),n=r}else t.push(e[n]);return t}return(e,t)=>(K(),B(`foreignObject`,W({class:`vvplot-layer`},i.value,{ref:`container`}),null,16))}},sr={__name:`Textsegment`,props:{data:Object,render:String,dpi:Number},setup(e,{expose:t}){let n=L(()=>e.render===`svg`?`svg`:e.render===`canvas`||(e.data?.length??0)>1e3?`canvas`:`svg`),r=X(`layer`);return t({dispatchEvent(e){if(typeof r.value?.dispatchEvent!=`function`)return;let t=Y(e);return r.value?.dispatchEvent?.(t),t}}),(t,i)=>n.value===`canvas`?(K(),R(or,{key:0,ref_key:`layer`,ref:r,data:e.data,dpi:e.dpi,style:{"pointer-events":`none`}},null,8,[`data`,`dpi`])):(K(),R(ar,{key:1,ref_key:`layer`,ref:r,data:e.data},null,8,[`data`]))}},cr=/* @__PURE__ */ e({blank:()=>yn,boxplot:()=>Cn,curve:()=>Dn,ellipse:()=>jn,line:()=>Fn,markdown:()=>Rn,markdownsegment:()=>Vn,point:()=>Gn,polygon:()=>Yn,rect:()=>$n,shape:()=>Dn,stick:()=>Fn,text:()=>rr,textsegment:()=>sr,tile:()=>$n}),lr=/* @__PURE__ */ e({components:()=>et,geoms:()=>Ut,renderers:()=>cr,stats:()=>gn});export{ot as a,et as c,Ut as i,cr as n,it as o,gn as r,nt as s,lr as t};